From 19f1c38d4ea16c8c199a1b4cd8d21beef3a70b6c Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Sat, 30 Jul 2011 18:47:44 -0300 Subject: [PATCH] x264enc: Properly set the stream format in setcaps Do not forget to set the selected format to the options string when getting it from caps https://bugzilla.gnome.org/show_bug.cgi?id=655223 --- ext/x264/gstx264enc.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ext/x264/gstx264enc.c b/ext/x264/gstx264enc.c index 08c930b43b..3aa02feadc 100644 --- a/ext/x264/gstx264enc.c +++ b/ext/x264/gstx264enc.c @@ -1553,20 +1553,21 @@ gst_x264_enc_sink_set_caps (GstPad * pad, GstCaps * caps) peer_caps = gst_pad_peer_get_caps_reffed (encoder->srcpad); if (peer_caps) { gint i; - gboolean has_profile_or_level = FALSE; + gboolean has_profile_or_level_or_format = FALSE; for (i = 0; i < gst_caps_get_size (peer_caps); i++) { GstStructure *s = gst_caps_get_structure (peer_caps, i); if (gst_structure_has_name (s, "video/x-h264") && (gst_structure_has_field (s, "profile") || - gst_structure_has_field (s, "level"))) { - has_profile_or_level = TRUE; + gst_structure_has_field (s, "level") || + gst_structure_has_field (s, "stream-format"))) { + has_profile_or_level_or_format = TRUE; break; } } - if (has_profile_or_level) { + if (has_profile_or_level_or_format) { template_caps = gst_pad_get_pad_template_caps (encoder->srcpad); allowed_caps = gst_caps_intersect (peer_caps, template_caps); @@ -1654,8 +1655,10 @@ gst_x264_enc_sink_set_caps (GstPad * pad, GstCaps * caps) if (stream_format) { if (!strcmp (stream_format, "avc")) { encoder->current_byte_stream = GST_X264_ENC_STREAM_FORMAT_AVC; + g_string_append_printf (encoder->option_string, ":annexb=0"); } else if (!strcmp (stream_format, "byte-stream")) { encoder->current_byte_stream = GST_X264_ENC_STREAM_FORMAT_BYTE_STREAM; + g_string_append_printf (encoder->option_string, ":annexb=1"); } else { /* means we have both in caps and _FROM_PROPERTY should be the option */ }