From 7c658c3c0465d5c09c830ff1d3944a91757ac78c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Sachs?= Date: Thu, 20 Apr 2017 11:22:15 +0200 Subject: [PATCH] qtdemux: reset sample_description_id to default Fixes stream where sample_description_id is specified in the tfhd https://bugzilla.gnome.org/show_bug.cgi?id=778337 --- gst/isomp4/qtdemux.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gst/isomp4/qtdemux.c b/gst/isomp4/qtdemux.c index 3a271af670..6a5ed276f0 100644 --- a/gst/isomp4/qtdemux.c +++ b/gst/isomp4/qtdemux.c @@ -414,6 +414,7 @@ struct _QtDemuxStream /* fragmented */ gboolean parsed_trex; + guint32 def_sample_description_index; /* index is 1-based */ guint32 def_sample_duration; guint32 def_sample_size; guint32 def_sample_flags; @@ -2950,7 +2951,7 @@ qtdemux_parse_trex (GstQTDemux * qtdemux, QtDemuxStream * stream, trex = qtdemux_tree_get_child_by_type_full (mvex, FOURCC_trex, &trex_data); while (trex) { - guint32 id = 0, dur = 0, size = 0, flags = 0, dummy = 0; + guint32 id = 0, sdi = 0, dur = 0, size = 0, flags = 0; /* skip version/flags */ if (!gst_byte_reader_skip (&trex_data, 4)) @@ -2959,8 +2960,7 @@ qtdemux_parse_trex (GstQTDemux * qtdemux, QtDemuxStream * stream, goto next; if (id != stream->track_id) goto next; - /* sample description index; ignore */ - if (!gst_byte_reader_get_uint32_be (&trex_data, &dummy)) + if (!gst_byte_reader_get_uint32_be (&trex_data, &sdi)) goto next; if (!gst_byte_reader_get_uint32_be (&trex_data, &dur)) goto next; @@ -2974,6 +2974,7 @@ qtdemux_parse_trex (GstQTDemux * qtdemux, QtDemuxStream * stream, dur, size, flags); stream->parsed_trex = TRUE; + stream->def_sample_description_index = sdi; stream->def_sample_duration = dur; stream->def_sample_size = size; stream->def_sample_flags = flags; @@ -3426,7 +3427,9 @@ qtdemux_parse_tfhd (GstQTDemux * qtdemux, GstByteReader * tfhd, qtdemux_parse_trex (qtdemux, *stream, default_sample_duration, default_sample_size, default_sample_flags); - /* FIXME: Handle TF_SAMPLE_DESCRIPTION_INDEX properly */ + (*stream)->stsd_sample_description_id = + (*stream)->def_sample_description_index - 1; + if (flags & TF_SAMPLE_DESCRIPTION_INDEX) { guint32 sample_description_index; if (!gst_byte_reader_get_uint32_be (tfhd, &sample_description_index))