From 629092a79a3c07a5e75087599d63e70c7fd27e47 Mon Sep 17 00:00:00 2001 From: Luca Ognibene Date: Tue, 22 Nov 2005 09:24:29 +0000 Subject: [PATCH] gst/ffmpegcolorspace/: #318353); use gst_structure_has_name(). Original commit message from CVS: * gst/ffmpegcolorspace/gstffmpegcodecmap.c: (gst_ffmpeg_pixfmt_to_caps), (gst_ffmpeg_caps_to_pixfmt): * gst/ffmpegcolorspace/gstffmpegcolorspace.c: (gst_ffmpegcsp_caps_remove_format_info): * gst/ffmpegcolorspace/imgconvert.c: * gst/ffmpegcolorspace/imgconvert_template.h: Forward-port fixes from the 0.8 branch (patch by Luca Ognibene, #318353); use gst_structure_has_name(). --- ChangeLog | 11 ++++ gst/ffmpegcolorspace/gstffmpegcodecmap.c | 99 +++++++++++++++++------------- gst/ffmpegcolorspace/gstffmpegcolorspace.c | 9 +++ gst/ffmpegcolorspace/imgconvert.c | 2 + gst/ffmpegcolorspace/imgconvert_template.h | 40 +++++++++++- 5 files changed, 118 insertions(+), 43 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1a4ec52..5ed72c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2005-11-22 Tim-Philipp Müller + + * gst/ffmpegcolorspace/gstffmpegcodecmap.c: + (gst_ffmpeg_pixfmt_to_caps), (gst_ffmpeg_caps_to_pixfmt): + * gst/ffmpegcolorspace/gstffmpegcolorspace.c: + (gst_ffmpegcsp_caps_remove_format_info): + * gst/ffmpegcolorspace/imgconvert.c: + * gst/ffmpegcolorspace/imgconvert_template.h: + Forward-port fixes from the 0.8 branch (patch by Luca Ognibene, + #318353); use gst_structure_has_name(). + 2005-11-22 Julien MOUTTE * sys/ximage/ximagesink.c: (gst_ximagesink_event_thread), diff --git a/gst/ffmpegcolorspace/gstffmpegcodecmap.c b/gst/ffmpegcolorspace/gstffmpegcodecmap.c index cc60e25..1c114eb 100644 --- a/gst/ffmpegcolorspace/gstffmpegcodecmap.c +++ b/gst/ffmpegcolorspace/gstffmpegcodecmap.c @@ -150,7 +150,7 @@ gst_ffmpeg_pixfmt_to_caps (enum PixelFormat pix_fmt, AVCodecContext * context) fmt = GST_MAKE_FOURCC ('Y', '4', '2', 'B'); break; case PIX_FMT_YUV444P: - /* .. */ + fmt = GST_MAKE_FOURCC ('Y', '4', '4', '4'); break; case PIX_FMT_RGB32: bpp = 32; @@ -201,15 +201,16 @@ gst_ffmpeg_pixfmt_to_caps (enum PixelFormat pix_fmt, AVCodecContext * context) depth = 32; endianness = G_BIG_ENDIAN; #if (G_BYTE_ORDER == G_BIG_ENDIAN) - r_mask = 0x00ff0000; - g_mask = 0x0000ff00; - b_mask = 0x000000ff; - a_mask = 0xff000000; -#else r_mask = 0x0000ff00; g_mask = 0x00ff0000; b_mask = 0xff000000; a_mask = 0x000000ff; +#else + r_mask = 0x00ff0000; + g_mask = 0x0000ff00; + b_mask = 0x000000ff; + a_mask = 0xff000000; + #endif break; case PIX_FMT_YUV410P: @@ -240,41 +241,48 @@ gst_ffmpeg_pixfmt_to_caps (enum PixelFormat pix_fmt, AVCodecContext * context) case PIX_FMT_AYUV4444: fmt = GST_MAKE_FOURCC ('A', 'Y', 'U', 'V'); break; + case PIX_FMT_GRAY8: + bpp = depth = 8; + caps = GST_FF_VID_CAPS_NEW ("video/x-raw-gray", + "bpp", G_TYPE_INT, bpp, "depth", G_TYPE_INT, depth, NULL); + break; default: /* give up ... */ break; } - if (bpp != 0) { - if (a_mask != 0) { - caps = GST_FF_VID_CAPS_NEW ("video/x-raw-rgb", - "bpp", G_TYPE_INT, bpp, - "depth", G_TYPE_INT, depth, - "red_mask", G_TYPE_INT, r_mask, - "green_mask", G_TYPE_INT, g_mask, - "blue_mask", G_TYPE_INT, b_mask, - "alpha_mask", G_TYPE_INT, a_mask, - "endianness", G_TYPE_INT, endianness, NULL); - } else if (r_mask != 0) { - caps = GST_FF_VID_CAPS_NEW ("video/x-raw-rgb", - "bpp", G_TYPE_INT, bpp, - "depth", G_TYPE_INT, depth, - "red_mask", G_TYPE_INT, r_mask, - "green_mask", G_TYPE_INT, g_mask, - "blue_mask", G_TYPE_INT, b_mask, - "endianness", G_TYPE_INT, endianness, NULL); - } else { - caps = GST_FF_VID_CAPS_NEW ("video/x-raw-rgb", - "bpp", G_TYPE_INT, bpp, - "depth", G_TYPE_INT, depth, - "endianness", G_TYPE_INT, endianness, NULL); - if (context) { - gst_ffmpeg_set_palette (caps, context); + if (caps == NULL) { + if (bpp != 0) { + if (a_mask != 0) { + caps = GST_FF_VID_CAPS_NEW ("video/x-raw-rgb", + "bpp", G_TYPE_INT, bpp, + "depth", G_TYPE_INT, depth, + "red_mask", G_TYPE_INT, r_mask, + "green_mask", G_TYPE_INT, g_mask, + "blue_mask", G_TYPE_INT, b_mask, + "alpha_mask", G_TYPE_INT, a_mask, + "endianness", G_TYPE_INT, endianness, NULL); + } else if (r_mask != 0) { + caps = GST_FF_VID_CAPS_NEW ("video/x-raw-rgb", + "bpp", G_TYPE_INT, bpp, + "depth", G_TYPE_INT, depth, + "red_mask", G_TYPE_INT, r_mask, + "green_mask", G_TYPE_INT, g_mask, + "blue_mask", G_TYPE_INT, b_mask, + "endianness", G_TYPE_INT, endianness, NULL); + } else { + caps = GST_FF_VID_CAPS_NEW ("video/x-raw-rgb", + "bpp", G_TYPE_INT, bpp, + "depth", G_TYPE_INT, depth, + "endianness", G_TYPE_INT, endianness, NULL); + if (context) { + gst_ffmpeg_set_palette (caps, context); + } } + } else if (fmt) { + caps = GST_FF_VID_CAPS_NEW ("video/x-raw-yuv", + "format", GST_TYPE_FOURCC, fmt, NULL); } - } else if (fmt) { - caps = GST_FF_VID_CAPS_NEW ("video/x-raw-yuv", - "format", GST_TYPE_FOURCC, fmt, NULL); } if (caps != NULL) { @@ -456,7 +464,7 @@ gst_ffmpeg_caps_to_pixfmt (const GstCaps * caps, if (!raw) return; - if (strcmp (gst_structure_get_name (structure), "video/x-raw-yuv") == 0) { + if (gst_structure_has_name (structure, "video/x-raw-yuv")) { guint32 fourcc; if (gst_structure_get_fourcc (structure, "format", &fourcc)) { @@ -482,15 +490,12 @@ gst_ffmpeg_caps_to_pixfmt (const GstCaps * caps, case GST_MAKE_FOURCC ('A', 'Y', 'U', 'V'): context->pix_fmt = PIX_FMT_AYUV4444; break; -#if 0 - case FIXME: + case GST_MAKE_FOURCC ('Y', '4', '4', '4'): context->pix_fmt = PIX_FMT_YUV444P; break; -#endif } } - } else if (strcmp (gst_structure_get_name (structure), - "video/x-raw-rgb") == 0) { + } else if (gst_structure_has_name (structure, "video/x-raw-rgb")) { gint bpp = 0, rmask = 0, endianness = 0, amask = 0, depth = 0; if (gst_structure_get_int (structure, "bpp", &bpp) && @@ -500,9 +505,9 @@ gst_ffmpeg_caps_to_pixfmt (const GstCaps * caps, case 32: if (gst_structure_get_int (structure, "alpha_mask", &amask)) { #if (G_BYTE_ORDER == G_BIG_ENDIAN) - if (rmask == 0x00ff0000) -#else if (rmask == 0x0000ff00) +#else + if (rmask == 0x00ff0000) #endif context->pix_fmt = PIX_FMT_BGRA32; else @@ -553,6 +558,16 @@ gst_ffmpeg_caps_to_pixfmt (const GstCaps * caps, } } } + } else if (gst_structure_has_name (structure, "video/x-raw-gray")) { + gint bpp = 0; + + if (gst_structure_get_int (structure, "bpp", &bpp)) { + switch (bpp) { + case 8: + context->pix_fmt = PIX_FMT_GRAY8; + break; + } + } } } diff --git a/gst/ffmpegcolorspace/gstffmpegcolorspace.c b/gst/ffmpegcolorspace/gstffmpegcolorspace.c index 3ef03c2..ca6ff13 100644 --- a/gst/ffmpegcolorspace/gstffmpegcolorspace.c +++ b/gst/ffmpegcolorspace/gstffmpegcolorspace.c @@ -92,6 +92,7 @@ gst_ffmpegcsp_caps_remove_format_info (GstCaps * caps) int i; GstStructure *structure; GstCaps *rgbcaps; + GstCaps *graycaps; caps = gst_caps_copy (caps); @@ -117,7 +118,15 @@ gst_ffmpegcsp_caps_remove_format_info (GstCaps * caps) gst_structure_set_name (structure, "video/x-raw-rgb"); } + graycaps = gst_caps_copy (caps); + for (i = 0; i < gst_caps_get_size (graycaps); i++) { + structure = gst_caps_get_structure (graycaps, i); + + gst_structure_set_name (structure, "video/x-raw-gray"); + } + + gst_caps_append (caps, graycaps); gst_caps_append (caps, rgbcaps); return caps; diff --git a/gst/ffmpegcolorspace/imgconvert.c b/gst/ffmpegcolorspace/imgconvert.c index 64e7a11..e3bfdd6 100644 --- a/gst/ffmpegcolorspace/imgconvert.c +++ b/gst/ffmpegcolorspace/imgconvert.c @@ -1674,6 +1674,7 @@ bitcopy_n (unsigned int a, int n) /* bgra32 handling */ #define RGB_NAME bgra32 +#define FMT_BGRA32 #define RGB_IN(r, g, b, s)\ {\ @@ -1903,6 +1904,7 @@ static ConvertEntry convert_table[] = { {PIX_FMT_RGBA32, PIX_FMT_YUV420P, rgba32_to_yuv420p}, {PIX_FMT_RGBA32, PIX_FMT_GRAY8, rgba32_to_gray}, {PIX_FMT_RGBA32, PIX_FMT_AYUV4444, rgba32_to_ayuv4444}, + {PIX_FMT_BGRA32, PIX_FMT_AYUV4444, bgra32_to_ayuv4444}, {PIX_FMT_BGR24, PIX_FMT_RGB24, bgr24_to_rgb24}, {PIX_FMT_BGR24, PIX_FMT_YUV420P, bgr24_to_yuv420p}, diff --git a/gst/ffmpegcolorspace/imgconvert_template.h b/gst/ffmpegcolorspace/imgconvert_template.h index 976d275..5e9c032 100644 --- a/gst/ffmpegcolorspace/imgconvert_template.h +++ b/gst/ffmpegcolorspace/imgconvert_template.h @@ -467,6 +467,9 @@ static void glue(RGB_NAME, _to_rgba32)(AVPicture *dst, const AVPicture *src, d += dst_wrap; } } +#endif /* !defined(FMT_RGBA32) && defined(RGBA_OUT) */ + +#if defined(FMT_RGBA32) #if !defined(rgba32_fcts_done) #define rgba32_fcts_done @@ -527,7 +530,42 @@ static void rgba32_to_ayuv4444(AVPicture *dst, const AVPicture *src, #endif /* !defined(rgba32_fcts_done) */ -#endif /* !defined(FMT_RGBA32) && defined(RGBA_OUT) */ +#endif /* defined(FMT_RGBA32) */ + +#if defined(FMT_BGRA32) +#if !defined(bgra32_fcts_done) +#define bgra32_fcts_done + +static void bgra32_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