From: Julien M. <do...@us...> - 2003-11-28 21:48:04
|
CVS Root: /cvsroot/gstreamer Module: gst-plugins Changes by: dolphy Date: Fri Nov 28 2003 13:48:03 PST Log message: First Try to fix RGB image formats Modified files: sys/xvimage : xvimagesink.c xvimagesink.h Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/sys/xvimage/xvimagesink.c.diff?r1=1.9&r2=1.10 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/sys/xvimage/xvimagesink.h.diff?r1=1.5&r2=1.6 ====Begin Diffs==== Index: xvimagesink.c =================================================================== RCS file: /cvsroot/gstreamer/gst-plugins/sys/xvimage/xvimagesink.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- xvimagesink.c 26 Nov 2003 10:12:05 -0000 1.9 +++ xvimagesink.c 28 Nov 2003 21:47:51 -0000 1.10 @@ -351,15 +351,23 @@ /* First let's check that XVideo extension is available */ if (!XQueryExtension (xcontext->disp, "XVideo", &i, &i, &i)) - return NULL; + { + GST_DEBUG ("XVideo extension is not available"); + return NULL; + } /* Then we get adaptors list */ if (Success != XvQueryAdaptors (xcontext->disp, xcontext->root, &nb_adaptors, &adaptors)) - return NULL; + { + GST_DEBUG ("Failed getting XV adaptors list"); + return NULL; + } xcontext->xv_port_id = 0; + GST_DEBUG ("Found %d XV adaptor(s)", nb_adaptors); + /* Now search for an adaptor that supports XvImageMask */ for (i = 0; i < nb_adaptors && !xcontext->xv_port_id; i++) { @@ -401,18 +409,37 @@ switch (formats[i].type) { case XvRGB: - format_caps = GST_CAPS_NEW ("xvimagesink_caps", - "video/x-raw-rgb", - "endianness", GST_PROPS_INT (xcontext->endianness), - "depth", GST_PROPS_INT (xcontext->depth), - "bpp", GST_PROPS_INT (xcontext->bpp), - "blue_mask", GST_PROPS_INT (formats[i].red_mask), - "green_mask", GST_PROPS_INT (formats[i].green_mask), - "red_mask", GST_PROPS_INT (formats[i].blue_mask), - "width", GST_PROPS_INT_RANGE (0, G_MAXINT), - "height", GST_PROPS_INT_RANGE (0, G_MAXINT), - "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)); - break; + { + format_caps = GST_CAPS_NEW ("xvimagesink_caps", + "video/x-raw-rgb", + "endianness", GST_PROPS_INT (xcontext->endianness), + "depth", GST_PROPS_INT (xcontext->depth), + "bpp", GST_PROPS_INT (xcontext->bpp), + "blue_mask", GST_PROPS_INT (formats[i].red_mask), + "green_mask", GST_PROPS_INT (formats[i].green_mask), + "red_mask", GST_PROPS_INT (formats[i].blue_mask), + "width", GST_PROPS_INT_RANGE (0, G_MAXINT), + "height", GST_PROPS_INT_RANGE (0, G_MAXINT), + "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)); + + /* For RGB caps we store them and the image + format so that we can get back the format + when sinkconnect will give us a caps without + format property */ + if (format_caps) + { + GstXvImageFormat *format = NULL; + format = g_new0 (GstXvImageFormat, 1); + if (format) + { + format->format = formats[i].id; + format->caps = gst_caps_copy (format_caps); + xcontext->formats_list = g_list_append ( + xcontext->formats_list, format); + } + } + break; + } case XvYUV: format_caps = GST_CAPS_NEW ("xvimagesink_caps", "video/x-raw-yuv", @@ -540,9 +567,24 @@ static void gst_xvimagesink_xcontext_clear (GstXvImageSink *xvimagesink) { + GList *list; + g_return_if_fail (xvimagesink != NULL); g_return_if_fail (GST_IS_XVIMAGESINK (xvimagesink)); + list = xvimagesink->xcontext->formats_list; + + while (list) + { + GstXvImageFormat *format = list->data; + gst_caps_unref (format->caps); + g_free (format); + list = g_list_next (list); + } + + if (xvimagesink->xcontext->formats_list) + g_list_free (xvimagesink->xcontext->formats_list); + gst_caps_unref (xvimagesink->xcontext->caps); g_mutex_lock (xvimagesink->x_lock); @@ -559,6 +601,35 @@ /* Element stuff */ +static gint +gst_xvimagesink_get_fourcc_from_caps (GstXvImageSink *xvimagesink, + GstCaps *caps) +{ + gint fourcc = 0; + GList *list = NULL; + + g_return_val_if_fail (xvimagesink != NULL, 0); + g_return_val_if_fail (GST_IS_XVIMAGESINK (xvimagesink), 0); + + list = xvimagesink->xcontext->formats_list; + + while (list) + { + GstXvImageFormat *format = list->data; + + if (format) + { + GstCaps *icaps = NULL; + icaps = gst_caps_intersect (caps, format->caps); + if (icaps) + fourcc = format->format; + } + list = g_list_next (list); + } + + return fourcc; +} + static GstCaps * gst_xvimagesink_getcaps (GstPad *pad, GstCaps *caps) { @@ -614,6 +685,9 @@ if (gst_caps_has_fixed_property (caps, "format")) gst_caps_get_fourcc_int (caps, "format", &xvimagesink->xcontext->im_format); + else + xvimagesink->xcontext->im_format = gst_xvimagesink_get_fourcc_from_caps ( + xvimagesink, caps); if (gst_caps_has_fixed_property (caps, "pixel_width")) gst_caps_get_int (caps, "pixel_width", &xvimagesink->pixel_width); Index: xvimagesink.h =================================================================== RCS file: /cvsroot/gstreamer/gst-plugins/sys/xvimage/xvimagesink.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- xvimagesink.h 27 Nov 2003 16:10:01 -0000 1.5 +++ xvimagesink.h 28 Nov 2003 21:47:51 -0000 1.6 @@ -56,7 +56,8 @@ typedef struct _GstXContext GstXContext; typedef struct _GstXWindow GstXWindow; typedef struct _GstXvImage GstXvImage; - +typedef struct _GstXvImageFormat GstXvImageFormat; + typedef struct _GstXvImageSink GstXvImageSink; typedef struct _GstXvImageSinkClass GstXvImageSinkClass; @@ -82,6 +83,8 @@ XvPortID xv_port_id; gint im_format; + GList *formats_list; + GstCaps *caps; }; @@ -93,7 +96,13 @@ GC gc; }; -/* XImage stuff */ +/* XvImage format stuff */ +struct _GstXvImageFormat { + gint format; + GstCaps *caps; +}; + +/* XvImage stuff */ struct _GstXvImage { XvImage *xvimage; |