From: Sebastian Dröge Date: Wed, 10 Feb 2010 09:12:18 +0000 (+0100) Subject: ffmpegcolorspace: Add conversions from all ARGB formats to AYUV and back X-Git-Tag: RELEASE-0.10.27~63 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8b1e42f2722424864028097d7d079ac85985e23e;p=platform%2Fupstream%2Fgst-plugins-base.git ffmpegcolorspace: Add conversions from all ARGB formats to AYUV and back --- diff --git a/gst/ffmpegcolorspace/imgconvert.c b/gst/ffmpegcolorspace/imgconvert.c index 405a734..dba12db 100644 --- a/gst/ffmpegcolorspace/imgconvert.c +++ b/gst/ffmpegcolorspace/imgconvert.c @@ -2804,6 +2804,7 @@ static ConvertEntry convert_table[] = { {PIX_FMT_ABGR32, PIX_FMT_GRAY8, abgr32_to_gray}, {PIX_FMT_ABGR32, PIX_FMT_GRAY16_L, abgr32_to_gray16_l}, {PIX_FMT_ABGR32, PIX_FMT_GRAY16_B, abgr32_to_gray16_b}, + {PIX_FMT_ABGR32, PIX_FMT_AYUV4444, abgr32_to_ayuv4444}, {PIX_FMT_ARGB32, PIX_FMT_RGB24, argb32_to_rgb24}, {PIX_FMT_ARGB32, PIX_FMT_RGBA32, argb32_to_rgba32}, @@ -2813,6 +2814,7 @@ static ConvertEntry convert_table[] = { {PIX_FMT_ARGB32, PIX_FMT_GRAY8, argb32_to_gray}, {PIX_FMT_ARGB32, PIX_FMT_GRAY16_L, argb32_to_gray16_l}, {PIX_FMT_ARGB32, PIX_FMT_GRAY16_B, argb32_to_gray16_b}, + {PIX_FMT_ARGB32, PIX_FMT_AYUV4444, argb32_to_ayuv4444}, {PIX_FMT_RGB555, PIX_FMT_RGB24, rgb555_to_rgb24}, {PIX_FMT_RGB555, PIX_FMT_RGB32, rgb555_to_rgba32}, @@ -2901,6 +2903,9 @@ static ConvertEntry convert_table[] = { {PIX_FMT_V308, PIX_FMT_RGB24, v308_to_rgb24}, {PIX_FMT_AYUV4444, PIX_FMT_RGBA32, ayuv4444_to_rgba32}, + {PIX_FMT_AYUV4444, PIX_FMT_ARGB32, ayuv4444_to_argb32}, + {PIX_FMT_AYUV4444, PIX_FMT_BGRA32, ayuv4444_to_bgra32}, + {PIX_FMT_AYUV4444, PIX_FMT_ABGR32, ayuv4444_to_abgr32}, {PIX_FMT_AYUV4444, PIX_FMT_RGB24, ayuv4444_to_rgb24}, }; diff --git a/gst/ffmpegcolorspace/imgconvert_template.h b/gst/ffmpegcolorspace/imgconvert_template.h index 4076625..255e7e8 100644 --- a/gst/ffmpegcolorspace/imgconvert_template.h +++ b/gst/ffmpegcolorspace/imgconvert_template.h @@ -1083,10 +1083,167 @@ bgra32_to_ayuv4444 (AVPicture * dst, const AVPicture * src, } } +static void +ayuv4444_to_bgra32 (AVPicture * dst, const AVPicture * src, + int width, int height) +{ + uint8_t *s, *d, *d1, *s1; + int w, y, cb, cr, r_add, g_add, b_add; + uint8_t *cm = cropTbl + MAX_NEG_CROP; + unsigned int r, g, b, a; + + d = dst->data[0]; + s = src->data[0]; + for (; height > 0; height--) { + d1 = d; + s1 = s; + for (w = width; w > 0; w--) { + a = s1[0]; + YUV_TO_RGB1_CCIR (s1[2], s1[3]); + + YUV_TO_RGB2_CCIR (r, g, b, s1[1]); + RGBA_OUT (d1, r, g, b, a); + d1 += BPP; + s1 += 4; + } + d += dst->linesize[0]; + s += src->linesize[0]; + } +} + #endif /* !defined(bgra32_fcts_done) */ #endif /* defined(FMT_BGRA32) */ +#if defined(FMT_ARGB32) + +#if !defined(argb32_fcts_done) +#define argb32_fcts_done + +static void +ayuv4444_to_argb32 (AVPicture * dst, const AVPicture * src, + int width, int height) +{ + uint8_t *s, *d, *d1, *s1; + int w, y, cb, cr, r_add, g_add, b_add; + uint8_t *cm = cropTbl + MAX_NEG_CROP; + unsigned int r, g, b, a; + + d = dst->data[0]; + s = src->data[0]; + for (; height > 0; height--) { + d1 = d; + s1 = s; + for (w = width; w > 0; w--) { + a = s1[0]; + YUV_TO_RGB1_CCIR (s1[2], s1[3]); + + YUV_TO_RGB2_CCIR (r, g, b, s1[1]); + RGBA_OUT (d1, r, g, b, a); + d1 += BPP; + s1 += 4; + } + d += dst->linesize[0]; + s += src->linesize[0]; + } +} + +static void +argb32_to_ayuv4444 (AVPicture * dst, const AVPicture * src, + int width, int height) +{ + int src_wrap, dst_wrap, x, y; + int r, g, b, a; + uint8_t *d; + const uint8_t *p; + + src_wrap = src->linesize[0] - width * BPP; + dst_wrap = dst->linesize[0] - width * 4; + d = dst->data[0]; + p = src->data[0]; + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { + RGBA_IN (r, g, b, a, p); + d[0] = a; + d[1] = RGB_TO_Y_CCIR (r, g, b); + d[2] = RGB_TO_U_CCIR (r, g, b, 0); + d[3] = RGB_TO_V_CCIR (r, g, b, 0); + p += BPP; + d += 4; + } + p += src_wrap; + d += dst_wrap; + } +} + +#endif /* !defined(argb32_fcts_done) */ + +#endif /* defined(FMT_ARGB32) */ + +#if defined(FMT_ABGR32) +#if !defined(abgr32_fcts_done) +#define abgr32_fcts_done + +static void +abgr32_to_ayuv4444 (AVPicture * dst, const AVPicture * src, + int width, int height) +{ + int src_wrap, dst_wrap, x, y; + int r, g, b, a; + uint8_t *d; + const uint8_t *p; + + src_wrap = src->linesize[0] - width * BPP; + dst_wrap = dst->linesize[0] - width * 4; + d = dst->data[0]; + p = src->data[0]; + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { + RGBA_IN (r, g, b, a, p); + d[0] = a; + d[1] = RGB_TO_Y_CCIR (r, g, b); + d[2] = RGB_TO_U_CCIR (r, g, b, 0); + d[3] = RGB_TO_V_CCIR (r, g, b, 0); + p += BPP; + d += 4; + } + p += src_wrap; + d += dst_wrap; + } +} + +static void +ayuv4444_to_abgr32 (AVPicture * dst, const AVPicture * src, + int width, int height) +{ + uint8_t *s, *d, *d1, *s1; + int w, y, cb, cr, r_add, g_add, b_add; + uint8_t *cm = cropTbl + MAX_NEG_CROP; + unsigned int r, g, b, a; + + d = dst->data[0]; + s = src->data[0]; + for (; height > 0; height--) { + d1 = d; + s1 = s; + for (w = width; w > 0; w--) { + a = s1[0]; + YUV_TO_RGB1_CCIR (s1[2], s1[3]); + + YUV_TO_RGB2_CCIR (r, g, b, s1[1]); + RGBA_OUT (d1, r, g, b, a); + d1 += BPP; + s1 += 4; + } + d += dst->linesize[0]; + s += src->linesize[0]; + } +} + +#endif /* !defined(abgr32_fcts_done) */ + +#endif /* defined(FMT_ABGR32) */ + #ifndef FMT_RGB24 static void glue (rgb24_to_, RGB_NAME) (AVPicture * dst, const AVPicture * src,