xvimage: avoid caps intersection
authorWim Taymans <wim.taymans@collabora.co.uk>
Mon, 15 Aug 2011 16:39:09 +0000 (18:39 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Mon, 15 Aug 2011 16:39:09 +0000 (18:39 +0200)
Store the video format in the XvImage format list so that we can quickly map
between the two.

sys/xvimage/xvimagepool.c
sys/xvimage/xvimagepool.h
sys/xvimage/xvimagesink.c
sys/xvimage/xvimagesink.h

index a66e49b..855d877 100644 (file)
@@ -516,8 +516,7 @@ xvimage_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
   GST_LOG_OBJECT (pool, "%dx%d, caps %" GST_PTR_FORMAT, info.width, info.height,
       caps);
 
-  priv->im_format =
-      gst_xvimagesink_get_format_from_caps (xvpool->sink, (GstCaps *) caps);
+  priv->im_format = gst_xvimagesink_get_format_from_info (xvpool->sink, &info);
   if (priv->im_format == -1)
     goto unknown_format;
 
@@ -712,8 +711,8 @@ gst_xvimage_buffer_pool_finalize (GObject * object)
 /* This function tries to get a format matching with a given caps in the
    supported list of formats we generated in gst_xvimagesink_get_xv_support */
 gint
-gst_xvimagesink_get_format_from_caps (GstXvImageSink * xvimagesink,
-    GstCaps * caps)
+gst_xvimagesink_get_format_from_info (GstXvImageSink * xvimagesink,
+    GstVideoInfo * info)
 {
   GList *list = NULL;
 
@@ -724,11 +723,9 @@ gst_xvimagesink_get_format_from_caps (GstXvImageSink * xvimagesink,
   while (list) {
     GstXvImageFormat *format = list->data;
 
-    if (format) {
-      if (gst_caps_can_intersect (caps, format->caps)) {
-        return format->format;
-      }
-    }
+    if (format && format->vformat == GST_VIDEO_INFO_FORMAT (info))
+      return format->format;
+
     list = g_list_next (list);
   }
 
index b15f0e0..7136498 100644 (file)
@@ -109,8 +109,8 @@ GstBufferPool *gst_xvimage_buffer_pool_new (GstXvImageSink * xvimagesink);
 gboolean gst_xvimagesink_check_xshm_calls (GstXvImageSink * xvimagesink,
       GstXContext * xcontext);
 
-gint gst_xvimagesink_get_format_from_caps (GstXvImageSink * xvimagesink,
-    GstCaps * caps);
+gint gst_xvimagesink_get_format_from_info (GstXvImageSink * xvimagesink,
+    GstVideoInfo * info);
 
 G_END_DECLS
 
index 45d3710..4b50d1e 100644 (file)
@@ -1043,6 +1043,7 @@ gst_xvimagesink_get_xv_support (GstXvImageSink * xvimagesink,
   for (i = 0; i < nb_formats; i++) {
     GstCaps *format_caps = NULL;
     gboolean is_rgb_format = FALSE;
+    GstVideoFormat vformat;
 
     /* We set the image format of the xcontext to an existing one. This
        is just some valid image format for making our xshm calls check before
@@ -1054,7 +1055,6 @@ gst_xvimagesink_get_xv_support (GstXvImageSink * xvimagesink,
       {
         XvImageFormatValues *fmt = &(formats[i]);
         gint endianness;
-        GstVideoFormat vformat;
 
         endianness =
             (fmt->byte_order == LSBFirst ? G_LITTLE_ENDIAN : G_BIG_ENDIAN);
@@ -1075,8 +1075,6 @@ gst_xvimagesink_get_xv_support (GstXvImageSink * xvimagesink,
       }
       case XvYUV:
       {
-        GstVideoFormat vformat;
-
         vformat = gst_video_format_from_fourcc (formats[i].id);
         if (vformat == GST_VIDEO_FORMAT_UNKNOWN)
           break;
@@ -1099,6 +1097,7 @@ gst_xvimagesink_get_xv_support (GstXvImageSink * xvimagesink,
       format = g_new0 (GstXvImageFormat, 1);
       if (format) {
         format->format = formats[i].id;
+        format->vformat = vformat;
         format->caps = gst_caps_copy (format_caps);
         xcontext->formats_list = g_list_append (xcontext->formats_list, format);
       }
@@ -1565,7 +1564,7 @@ gst_xvimagesink_setcaps (GstBaseSink * bsink, GstCaps * caps)
   xvimagesink->video_width = info.width;
   xvimagesink->video_height = info.height;
 
-  im_format = gst_xvimagesink_get_format_from_caps (xvimagesink, caps);
+  im_format = gst_xvimagesink_get_format_from_info (xvimagesink, &info);
   if (im_format == -1)
     goto invalid_format;
 
index ffa4f90..635ab23 100644 (file)
@@ -163,6 +163,7 @@ struct _GstXWindow
 struct _GstXvImageFormat
 {
   gint format;
+  GstVideoFormat vformat;
   GstCaps *caps;
 };