mirror of https://git.ffmpeg.org/ffmpeg.git
lavf/mov.c: Correct keyframe search in edit list to return the very first keyframe/frame with matching timestamp. Fixes ticket#5904
Signed-off-by: Sasi Inguva <isasi@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
15ccaa344c
commit
7e538c9475
|
@ -2847,11 +2847,23 @@ static int64_t find_prev_closest_index(AVStream *st,
|
||||||
AVIndexEntry *e_keep = st->index_entries;
|
AVIndexEntry *e_keep = st->index_entries;
|
||||||
int nb_keep = st->nb_index_entries;
|
int nb_keep = st->nb_index_entries;
|
||||||
int64_t found = -1;
|
int64_t found = -1;
|
||||||
|
int64_t i = 0;
|
||||||
|
|
||||||
st->index_entries = e_old;
|
st->index_entries = e_old;
|
||||||
st->nb_index_entries = nb_old;
|
st->nb_index_entries = nb_old;
|
||||||
found = av_index_search_timestamp(st, timestamp, flag | AVSEEK_FLAG_BACKWARD);
|
found = av_index_search_timestamp(st, timestamp, flag | AVSEEK_FLAG_BACKWARD);
|
||||||
|
|
||||||
|
// Keep going backwards in the index entries until the timestamp is the same.
|
||||||
|
if (found >= 0) {
|
||||||
|
for (i = found; i > 0 && e_old[i].timestamp == e_old[i - 1].timestamp;
|
||||||
|
i--) {
|
||||||
|
if ((flag & AVSEEK_FLAG_ANY) ||
|
||||||
|
(e_old[i - 1].flags & AVINDEX_KEYFRAME)) {
|
||||||
|
found = i - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* restore AVStream state*/
|
/* restore AVStream state*/
|
||||||
st->index_entries = e_keep;
|
st->index_entries = e_keep;
|
||||||
st->nb_index_entries = nb_keep;
|
st->nb_index_entries = nb_keep;
|
||||||
|
|
Loading…
Reference in New Issue