qtdemux: do not use indexes from sparse stream when seeking in push mode

This makes seeking more accurate in push mode, since the previous
keyframe on a sparse stream might be far away.
This commit is contained in:
Arnaud Vrac 2013-07-16 21:56:07 +02:00 committed by Sebastian Dröge
parent e561d12655
commit 1237898351

View file

@ -1629,17 +1629,25 @@ gst_qtdemux_find_sample (GstQTDemux * qtdemux, gint64 byte_pos, gboolean fw,
i = str->n_samples - 1;
inc = -1;
}
for (; (i >= 0) && (i < str->n_samples); i += inc) {
if (str->samples[i].size &&
((fw && (str->samples[i].offset >= byte_pos)) ||
(!fw &&
(str->samples[i].offset + str->samples[i].size <=
byte_pos)))) {
if (str->samples[i].size == 0)
continue;
if (fw && (str->samples[i].offset < byte_pos))
continue;
if (!fw && (str->samples[i].offset + str->samples[i].size > byte_pos))
continue;
/* move stream to first available sample */
if (set) {
gst_qtdemux_move_stream (qtdemux, str, i);
set_sample = TRUE;
}
/* avoid index from sparse streams since they might be far away */
if (!str->sparse) {
/* determine min/max time */
time = str->samples[i].timestamp + str->samples[i].pts_offset;
time = gst_util_uint64_scale (time, GST_SECOND, str->timescale);
@ -1647,17 +1655,18 @@ gst_qtdemux_find_sample (GstQTDemux * qtdemux, gint64 byte_pos, gboolean fw,
(fw && time < min_time)) {
min_time = time;
}
/* determine stream with leading sample, to get its position */
if (!stream || (fw
&& (str->samples[i].offset < stream->samples[index].offset))
|| (!fw
&& (str->samples[i].offset > stream->samples[index].offset))) {
if (!stream ||
(fw && (str->samples[i].offset < stream->samples[index].offset)) ||
(!fw && (str->samples[i].offset > stream->samples[index].offset))) {
stream = str;
index = i;
}
}
break;
}
}
/* no sample for this stream, mark eos */
if (!set_sample)
gst_qtdemux_move_stream (qtdemux, str, str->n_samples);