xvimage: avoid caps intersection

Store the video format in the XvImage format list so that we can quickly map
between the two.
This commit is contained in:
Wim Taymans 2011-08-15 18:39:09 +02:00
parent 8fe31fa12e
commit 515d4a9a6d
4 changed files with 12 additions and 15 deletions

View 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);
}

View 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

View 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;

View file

@ -163,6 +163,7 @@ struct _GstXWindow
struct _GstXvImageFormat
{
gint format;
GstVideoFormat vformat;
GstCaps *caps;
};