From 515d4a9a6d1a5b541f1a6bb23ff2dee9fc834457 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 15 Aug 2011 18:39:09 +0200 Subject: [PATCH] xvimage: avoid caps intersection Store the video format in the XvImage format list so that we can quickly map between the two. --- sys/xvimage/xvimagepool.c | 15 ++++++--------- sys/xvimage/xvimagepool.h | 4 ++-- sys/xvimage/xvimagesink.c | 7 +++---- sys/xvimage/xvimagesink.h | 1 + 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/sys/xvimage/xvimagepool.c b/sys/xvimage/xvimagepool.c index a66e49bb20..855d8771d1 100644 --- a/sys/xvimage/xvimagepool.c +++ b/sys/xvimage/xvimagepool.c @@ -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); } diff --git a/sys/xvimage/xvimagepool.h b/sys/xvimage/xvimagepool.h index b15f0e05bc..7136498b47 100644 --- a/sys/xvimage/xvimagepool.h +++ b/sys/xvimage/xvimagepool.h @@ -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 diff --git a/sys/xvimage/xvimagesink.c b/sys/xvimage/xvimagesink.c index 45d37104af..4b50d1ebe1 100644 --- a/sys/xvimage/xvimagesink.c +++ b/sys/xvimage/xvimagesink.c @@ -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; diff --git a/sys/xvimage/xvimagesink.h b/sys/xvimage/xvimagesink.h index ffa4f90ea2..635ab2344d 100644 --- a/sys/xvimage/xvimagesink.h +++ b/sys/xvimage/xvimagesink.h @@ -163,6 +163,7 @@ struct _GstXWindow struct _GstXvImageFormat { gint format; + GstVideoFormat vformat; GstCaps *caps; };