summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2023-03-24 23:08:10 +0200
committerMartin Storsjö <martin@martin.st>2023-04-02 00:34:46 +0300
commit33d06de6381aeaf0e6281f8ba0a39ed3bfda19fa (patch)
tree7cab40a20120a22d1f02fb68f4256fe16e6cedb3 /libavformat
parent182663a58a7a099e02e76da3b0f96d63e5c26a6d (diff)
downloadffmpeg-33d06de6381aeaf0e6281f8ba0a39ed3bfda19fa.tar.gz
libavformat: Account for negative position differences in ff_configure_buffers_for_index
When scanning through the index, account for the fact that the compared samples may be located in an unexpected order in the file; this function is mainly interested in the absolute difference between file locations. Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/seek.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libavformat/seek.c b/libavformat/seek.c
index a236e285c0..faa47f961f 100644
--- a/libavformat/seek.c
+++ b/libavformat/seek.c
@@ -208,9 +208,11 @@ void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance)
for (; i2 < sti2->nb_index_entries; i2++) {
const AVIndexEntry *const e2 = &sti2->index_entries[i2];
int64_t e2_pts = av_rescale_q(e2->timestamp, st2->time_base, AV_TIME_BASE_Q);
+ int64_t cur_delta;
if (e2_pts < e1_pts || e2_pts - (uint64_t)e1_pts < time_tolerance)
continue;
- pos_delta = FFMAX(pos_delta, e1->pos - e2->pos);
+ cur_delta = FFABS(e1->pos - e2->pos);
+ pos_delta = FFMAX(pos_delta, cur_delta);
break;
}
}