[FFmpeg-devel] [PATCH] Swscale - RGB48 to YUV conversion

Michael Niedermayer michaelni
Tue May 26 14:16:26 CEST 2009


On Tue, May 26, 2009 at 10:13:13AM +0300, Kostya wrote:
> $subj

>  swscale.c          |   44 ++++++++++++++++++++++++++++++++++++++++++++
>  swscale_internal.h |    4 +++-
>  swscale_template.c |   14 ++++++++++++++
>  3 files changed, 61 insertions(+), 1 deletion(-)
> 0eba08c312b5c5477da219eed3a8a8f2d53f85ee  48bpp-in.patch
> Index: swscale.c
> ===================================================================
> --- swscale.c	(revision 29324)
> +++ swscale.c	(working copy)
> @@ -108,6 +108,8 @@
>          || (x)==PIX_FMT_YUVA420P    \
>          || (x)==PIX_FMT_YUYV422     \
>          || (x)==PIX_FMT_UYVY422     \
> +        || (x)==PIX_FMT_RGB48BE     \
> +        || (x)==PIX_FMT_RGB48LE     \
>          || (x)==PIX_FMT_RGB32       \
>          || (x)==PIX_FMT_RGB32_1     \
>          || (x)==PIX_FMT_BGR24       \
> @@ -1122,6 +1124,48 @@
>      }
>  }
>  
> +static inline void rgb48ToY(uint8_t *dst, const uint8_t *src, int width)
> +{
> +    int i;
> +    for (i = 0; i < width; i++) {
> +        int r = src[i*6+0];
> +        int g = src[i*6+2];
> +        int b = src[i*6+4];
> +
> +        dst[i] = (RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
> +    }
> +}
> +
> +static inline void rgb48ToUV(uint8_t *dstU, uint8_t *dstV,
> +                             uint8_t *src1, uint8_t *src2, int width)
> +{
> +    int i;
> +    assert(src1==src2);
> +    for (i = 0; i < width; i++) {
> +        int r = src1[6*i + 0];
> +        int g = src1[6*i + 2];
> +        int b = src1[6*i + 4];
> +
> +        dstU[i] = (RU*r + GU*g + BU*b + (257<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
> +        dstV[i] = (RV*r + GV*g + BV*b + (257<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
> +    }
> +}
> +
> +static inline void rgb48ToUV_half(uint8_t *dstU, uint8_t *dstV,
> +                                  uint8_t *src1, uint8_t *src2, int width)
> +{
> +    int i;
> +    assert(src1==src2);
> +    for (i = 0; i < width; i++) {
> +        int r= src1[12*i + 0] + src1[12*i + 6];
> +        int g= src1[12*i + 2] + src1[12*i + 8];
> +        int b= src1[12*i + 4] + src1[12*i + 10];
> +
> +        dstU[i]= (RU*r + GU*g + BU*b + (257<<RGB2YUV_SHIFT)) >> (RGB2YUV_SHIFT+1);
> +        dstV[i]= (RV*r + GV*g + BV*b + (257<<RGB2YUV_SHIFT)) >> (RGB2YUV_SHIFT+1);
> +    }
> +}
> +
>  #define BGR2Y(type, name, shr, shg, shb, maskr, maskg, maskb, RY, GY, BY, S)\
>  static inline void name(uint8_t *dst, const uint8_t *src, long width, uint32_t *unused)\
>  {\

it would be nice if this wouldnt loose the 16bit per component

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The worst form of inequality is to try to make unequal things equal.
-- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090526/a3d6c11f/attachment.pgp>



More information about the ffmpeg-devel mailing list