Commit 13ed50b8 authored by Fabrizio Gennari's avatar Fabrizio Gennari Committed by Tim-Philipp Müller

gst/avi/gstavidemux.c: Fix index creation when we have to scan the file to...

gst/avi/gstavidemux.c: Fix index creation when we have to scan the file to create an index. There may be other types ...

Original commit message from CVS:
Patch by: Fabrizio Gennari  <fabrizio dot ge at tiscali dot it>
* gst/avi/gstavidemux.c: (gst_avi_demux_peek_tag),
(gst_avi_demux_next_data_buffer), (gst_avi_demux_stream_scan):
Fix index creation when we have to scan the file to create
an index. There may be other types of RIFF 'LIST' chunks than
'movi' and we need to skip them properly as well or we'll end up
reading garbage (#336889). Some other cosmetic changes.
parent 37d04ac0
2006-04-20 Tim-Philipp Müller <tim at centricular dot net>
Patch by: Fabrizio Gennari <fabrizio dot ge at tiscali dot it>
* gst/avi/gstavidemux.c: (gst_avi_demux_peek_tag),
(gst_avi_demux_next_data_buffer), (gst_avi_demux_stream_scan):
Fix index creation when we have to scan the file to create
an index. There may be other types of RIFF 'LIST' chunks than
'movi' and we need to skip them properly as well or we'll end up
reading garbage (#336889). Some other cosmetic changes.
2006-04-20 Tim-Philipp Müller <tim at centricular dot net>
* ext/flac/gstflacdec.c: (gst_flac_dec_loop),
......
......@@ -1605,9 +1605,10 @@ gst_avi_demux_peek_tag (GstAviDemux * avi, guint64 offset, guint32 * tag,
*size = GST_READ_UINT32_LE (GST_BUFFER_DATA (buf) + 4);
gst_buffer_unref (buf);
GST_LOG_OBJECT (avi,
"Tag[%" GST_FOURCC_FORMAT "] (size:%d) %lld -- %lld",
GST_FOURCC_ARGS (*tag), *size, offset, offset + (guint64) * size);
GST_LOG_OBJECT (avi, "Tag[%" GST_FOURCC_FORMAT "] (size:%d) %"
G_GINT64_FORMAT " -- %" G_GINT64_FORMAT, GST_FOURCC_ARGS (*tag),
*size, offset + 8, offset + 8 + (gint64) * size);
beach:
return res;
}
......@@ -1631,9 +1632,7 @@ gst_avi_demux_next_data_buffer (GstAviDemux * avi, guint64 * offset,
if ((res = gst_avi_demux_peek_tag (avi, off, tag, &siz)) != GST_FLOW_OK)
break;
if (*tag == GST_RIFF_TAG_LIST)
off += 8;
else if (*tag == GST_RIFF_LIST_movi)
off += 4;
off += 12;
else {
*offset = off + 8;
*size = siz;
......@@ -1663,7 +1662,6 @@ gst_avi_demux_stream_scan (GstAviDemux * avi,
guint64 length;
gint64 tmplength;
guint32 tag;
GstPad *peer;
GList *list = NULL;
guint index_size = 0;
......@@ -1674,12 +1672,10 @@ gst_avi_demux_stream_scan (GstAviDemux * avi,
GST_LOG_OBJECT (avi, "Creating index %s existing index",
(*index) ? "with" : "without");
if (!(peer = gst_pad_get_peer (avi->sinkpad)))
return FALSE;
if (!(gst_pad_query_duration (peer, &format, &tmplength)))
if (!gst_pad_query_peer_duration (avi->sinkpad, &format, &tmplength))
return FALSE;
length = tmplength;
gst_object_unref (peer);
if (*index) {
entry = g_list_last (*index)->data;
......@@ -1706,8 +1702,7 @@ gst_avi_demux_stream_scan (GstAviDemux * avi,
&size)) != GST_FLOW_OK)
break;
stream_nr = CHUNKID_TO_STREAMNR (tag);
if (stream_nr < 0 || stream_nr >= avi->num_streams)
continue;
if (stream_nr >= 0 && stream_nr < avi->num_streams) {
stream = &avi->stream[stream_nr];
/* pre-allocate */
......@@ -1756,9 +1751,10 @@ gst_avi_demux_stream_scan (GstAviDemux * avi,
G_GUINT64_FORMAT ", time %" GST_TIME_FORMAT " for stream %d",
index_size - 1, entry->frames_before, entry->offset,
GST_TIME_ARGS (entry->ts), entry->stream_nr);
}
/* update position */
pos += ((size + 1) & ~1);
pos += GST_ROUND_UP_2 (size);
if (pos > length) {
GST_WARNING_OBJECT (avi,
"Stopping index lookup since we are further than EOF");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment