diff options
author | Aurélien Zanelli <aurelien.zanelli@parrot.com> | 2014-10-01 16:17:46 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2014-10-20 12:18:50 +0200 |
commit | 89455b710629e5c842512ad5d93cff6b771d0d72 (patch) | |
tree | 9d6613380a2f5c982fc7cea66b4ac322144bae2d /gst/videoparsers/gstvc1parse.c | |
parent | ca5971850d7270cec2eb8d0629c634844e6dfe57 (diff) | |
download | gstreamer-plugins-bad-89455b710629e5c842512ad5d93cff6b771d0d72.tar.gz |
vc1parse: select caps according to wmv format at negotiation
Some VC1 decoder can have different caps according to wmv format, ie
WMV3 or WVC1.
So instead of keeping the first available caps, we interserct with
current WMV format.
https://bugzilla.gnome.org/show_bug.cgi?id=738532
Diffstat (limited to 'gst/videoparsers/gstvc1parse.c')
-rw-r--r-- | gst/videoparsers/gstvc1parse.c | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/gst/videoparsers/gstvc1parse.c b/gst/videoparsers/gstvc1parse.c index b00727348..a93e2d611 100644 --- a/gst/videoparsers/gstvc1parse.c +++ b/gst/videoparsers/gstvc1parse.c @@ -115,6 +115,16 @@ static const struct "frame-layer", VC1_STREAM_FORMAT_FRAME_LAYER} }; +static const struct +{ + gchar str[5]; + GstVC1ParseFormat en; +} parse_formats[] = { + { + "WMV3", GST_VC1_PARSE_FORMAT_WMV3}, { + "WVC1", GST_VC1_PARSE_FORMAT_WVC1} +}; + static const gchar * stream_format_to_string (VC1StreamFormat stream_format) { @@ -151,6 +161,12 @@ header_format_from_string (const gchar * header_format) return -1; } +static const gchar * +parse_format_to_string (GstVC1ParseFormat format) +{ + return parse_formats[format].str; +} + static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, @@ -300,7 +316,9 @@ gst_vc1_parse_stop (GstBaseParse * parse) static gboolean gst_vc1_parse_renegotiate (GstVC1Parse * vc1parse) { + GstCaps *in_caps; GstCaps *allowed_caps; + GstCaps *tmp; /* Negotiate with downstream here */ GST_DEBUG_OBJECT (vc1parse, "Renegotiating"); @@ -314,9 +332,25 @@ gst_vc1_parse_renegotiate (GstVC1Parse * vc1parse) GST_DEBUG_OBJECT (vc1parse, "Downstream allowed caps: %" GST_PTR_FORMAT, allowed_caps); - allowed_caps = gst_caps_make_writable (allowed_caps); - allowed_caps = gst_caps_truncate (allowed_caps); - s = gst_caps_get_structure (allowed_caps, 0); + /* Downstream element can have differents caps according to wmv format + * so intersect to select the good caps */ + in_caps = gst_caps_new_simple ("video/x-wmv", + "format", G_TYPE_STRING, parse_format_to_string (vc1parse->format), + NULL); + + tmp = gst_caps_intersect_full (allowed_caps, in_caps, + GST_CAPS_INTERSECT_FIRST); + gst_caps_unref (in_caps); + + if (gst_caps_is_empty (tmp)) { + GST_ERROR_OBJECT (vc1parse, "Empty caps, downstream doesn't support %s", + parse_format_to_string (vc1parse->format)); + gst_caps_unref (tmp); + return FALSE; + } + + tmp = gst_caps_make_writable (tmp); + s = gst_caps_get_structure (tmp, 0); /* If already fixed this does nothing */ gst_structure_fixate_field_string (s, "header-format", "asf"); @@ -343,6 +377,7 @@ gst_vc1_parse_renegotiate (GstVC1Parse * vc1parse) vc1parse->output_stream_format = stream_format_from_string (stream_format); } + gst_caps_unref (tmp); } else if (gst_caps_is_empty (allowed_caps)) { GST_ERROR_OBJECT (vc1parse, "Empty caps"); gst_caps_unref (allowed_caps); |