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:
parent
e561d12655
commit
1237898351
@ -1629,17 +1629,25 @@ gst_qtdemux_find_sample (GstQTDemux * qtdemux, gint64 byte_pos, gboolean fw,
|
|||||||
i = str->n_samples - 1;
|
i = str->n_samples - 1;
|
||||||
inc = -1;
|
inc = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; (i >= 0) && (i < str->n_samples); i += inc) {
|
for (; (i >= 0) && (i < str->n_samples); i += inc) {
|
||||||
if (str->samples[i].size &&
|
if (str->samples[i].size == 0)
|
||||||
((fw && (str->samples[i].offset >= byte_pos)) ||
|
continue;
|
||||||
(!fw &&
|
|
||||||
(str->samples[i].offset + str->samples[i].size <=
|
if (fw && (str->samples[i].offset < byte_pos))
|
||||||
byte_pos)))) {
|
continue;
|
||||||
/* move stream to first available sample */
|
|
||||||
if (set) {
|
if (!fw && (str->samples[i].offset + str->samples[i].size > byte_pos))
|
||||||
gst_qtdemux_move_stream (qtdemux, str, i);
|
continue;
|
||||||
set_sample = TRUE;
|
|
||||||
}
|
/* 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 */
|
/* determine min/max time */
|
||||||
time = str->samples[i].timestamp + str->samples[i].pts_offset;
|
time = str->samples[i].timestamp + str->samples[i].pts_offset;
|
||||||
time = gst_util_uint64_scale (time, GST_SECOND, str->timescale);
|
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)) {
|
(fw && time < min_time)) {
|
||||||
min_time = time;
|
min_time = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* determine stream with leading sample, to get its position */
|
/* determine stream with leading sample, to get its position */
|
||||||
if (!stream || (fw
|
if (!stream ||
|
||||||
&& (str->samples[i].offset < stream->samples[index].offset))
|
(fw && (str->samples[i].offset < stream->samples[index].offset)) ||
|
||||||
|| (!fw
|
(!fw && (str->samples[i].offset > stream->samples[index].offset))) {
|
||||||
&& (str->samples[i].offset > stream->samples[index].offset))) {
|
|
||||||
stream = str;
|
stream = str;
|
||||||
index = i;
|
index = i;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* no sample for this stream, mark eos */
|
/* no sample for this stream, mark eos */
|
||||||
if (!set_sample)
|
if (!set_sample)
|
||||||
gst_qtdemux_move_stream (qtdemux, str, str->n_samples);
|
gst_qtdemux_move_stream (qtdemux, str, str->n_samples);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user