From: "Martin Storsjö" <martin@martin.st> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v3] libavformat: Account for negative position differences in ff_configure_buffers_for_index Date: Sat, 25 Mar 2023 00:19:35 +0200 Message-ID: <20230324221935.48890-1-martin@martin.st> (raw) 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> --- v3: Avoid mixed declarations and statements. --- libavformat/seek.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/seek.c b/libavformat/seek.c index 818549dfef..ec563cdd12 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; } } -- 2.37.1 (Apple Git-137.1) _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
reply other threads:[~2023-03-24 22:19 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230324221935.48890-1-martin@martin.st \ --to=martin@martin.st \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git