diff options
author | Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> | 2010-11-08 11:41:21 +0100 |
---|---|---|
committer | Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> | 2010-12-03 15:52:08 +0100 |
commit | b4fb2ac99c257dde0131b014254d163584138416 (patch) | |
tree | f2c7b9bf6922420efb5b6b9ec1eb54540c9c2b8a | |
parent | 283e2b1bcdfea2e23b80e81702c640527873a58f (diff) |
qtdemux: fragmented support; handle ismv stbl atoms
... or lack of some thereof, such as mandatory stsz. Shuffle some code
in _stbl_init to detect this early enough.
-rw-r--r-- | gst/qtdemux/qtdemux.c | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/gst/qtdemux/qtdemux.c b/gst/qtdemux/qtdemux.c index a85376572..b3d1688d7 100644 --- a/gst/qtdemux/qtdemux.c +++ b/gst/qtdemux/qtdemux.c @@ -5122,6 +5122,23 @@ qtdemux_stbl_init (GstQTDemux * qtdemux, QtDemuxStream * stream, GNode * stbl) } } + /* sample size */ + if (!qtdemux_tree_get_child_by_type_full (stbl, FOURCC_stsz, &stream->stsz)) + goto no_samples; + + /* copy atom data into a new buffer for later use */ + stream->stsz.data = g_memdup (stream->stsz.data, stream->stsz.size); + + /* skip version + flags */ + if (!gst_byte_reader_skip (&stream->stsz, 1 + 3) || + !gst_byte_reader_get_uint32_be (&stream->stsz, &stream->sample_size)) + goto corrupt_file; + + if (!gst_byte_reader_get_uint32_be (&stream->stsz, &stream->n_samples)) + goto corrupt_file; + + if (!stream->n_samples) + goto no_samples; /* sample-to-chunk atom */ if (!qtdemux_tree_get_child_by_type_full (stbl, FOURCC_stsc, &stream->stsc)) @@ -5145,19 +5162,6 @@ qtdemux_stbl_init (GstQTDemux * qtdemux, QtDemuxStream * stream, GNode * stbl) goto corrupt_file; - /* sample size */ - if (!qtdemux_tree_get_child_by_type_full (stbl, FOURCC_stsz, &stream->stsz)) - goto corrupt_file; - - /* copy atom data into a new buffer for later use */ - stream->stsz.data = g_memdup (stream->stsz.data, stream->stsz.size); - - /* skip version + flags */ - if (!gst_byte_reader_skip (&stream->stsz, 1 + 3) || - !gst_byte_reader_get_uint32_be (&stream->stsz, &stream->sample_size)) - goto corrupt_file; - - /* chunk offset */ if (qtdemux_tree_get_child_by_type_full (stbl, FOURCC_stco, &stream->stco)) stream->co_size = sizeof (guint32); @@ -5181,9 +5185,6 @@ qtdemux_stbl_init (GstQTDemux * qtdemux, QtDemuxStream * stream, GNode * stbl) if (!gst_byte_reader_skip (&stream->stco, 4)) goto corrupt_file; - if (!gst_byte_reader_get_uint32_be (&stream->stsz, &stream->n_samples)) - goto corrupt_file; - /* make sure there are enough data in the stsz atom */ if (!stream->sample_size) { /* different sizes for each sample */ @@ -5196,18 +5197,6 @@ qtdemux_stbl_init (GstQTDemux * qtdemux, QtDemuxStream * stream, GNode * stbl) goto corrupt_file; } - if (!stream->n_samples) { - gst_qtdemux_stbl_free (stream); - if (!qtdemux->fragmented) { - /* not quite good */ - GST_WARNING_OBJECT (qtdemux, "stream has no samples"); - return FALSE; - } else { - /* may pick up samples elsewhere */ - return TRUE; - } - } - GST_DEBUG_OBJECT (qtdemux, "allocating n_samples %u * %" G_GSIZE_FORMAT " = (%u MB)", stream->n_samples, sizeof (QtDemuxSample), @@ -5256,6 +5245,18 @@ corrupt_file: (_("This file is corrupt and cannot be played.")), (NULL)); return FALSE; } +no_samples: + { + gst_qtdemux_stbl_free (stream); + if (!qtdemux->fragmented) { + /* not quite good */ + GST_WARNING_OBJECT (qtdemux, "stream has no samples"); + return FALSE; + } else { + /* may pick up samples elsewhere */ + return TRUE; + } + } } /* collect samples from the next sample to be parsed up to sample @n for @stream |