PR #26319 opened by Derek Buitenhuis (dwbuiten) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26319 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26319.patch
Apologies in advance for the slop-ness of this one. This one popped up while looking at #26208 as an existing bug. Feel free to just close/nuke it if it doesn't pass the sniff test. # Summary of changes ``` find_prev_closest_index() only set the output time to sample index and sample when the track had CTTS. Without CTTS, the time to sample entries still carry the per-sample STTS durations, and mov_fix_index() emits one entry per index entry it outputs, so tts_index_old has to correspond to the edit's starting sample. Instead, it kept whatever position the previous edit ended at (or 0 for the first edit). For edits not starting at sample 0, or for multiple edits, this assigned the durations of the wrong samples to packets, and once the position ran past the end of the table, no entries were emitted for the remaining packets, which then fell back to the DTS difference for their duration. Set the time to sample index to the found sample when there is no CTTS. In fate-quickdraw, the 15 edits ran the position past the table after the first few, so later packets used DTS differences; now every packet has its sample's STTS duration. ``` <!-- If this PR requires new FATE test samples, attach them to the PR and list their target paths below (relative to the fate-suite root). Attached filenames must match the sample's filename: ```fate-samples # e.g. vorbis/new-sample.ogg ``` --> >From d1f40bd594390a43a8b2099bd1d1dcd3ff571c2c Mon Sep 17 00:00:00 2001 From: Derek Buitenhuis <[email protected]> Date: Tue, 24 Nov 2026 14:48:40 +0000 Subject: [PATCH] avformat/mov: set the time to sample index for edits without CTTS find_prev_closest_index() only set the output time to sample index and sample when the track had CTTS. Without CTTS, the time to sample entries still carry the per-sample STTS durations, and mov_fix_index() emits one entry per index entry it outputs, so tts_index_old has to correspond to the edit's starting sample. Instead, it kept whatever position the previous edit ended at (or 0 for the first edit). For edits not starting at sample 0, or for multiple edits, this assigned the durations of the wrong samples to packets, and once the position ran past the end of the table, no entries were emitted for the remaining packets, which then fell back to the DTS difference for their duration. Set the time to sample index to the found sample when there is no CTTS. In fate-quickdraw, the 15 edits ran the position past the table after the first few, so later packets used DTS differences; now every packet has its sample's STTS duration. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Derek Buitenhuis <[email protected]> --- libavformat/mov.c | 7 +++++++ tests/ref/fate/quickdraw | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index ba9698e73a0..f0492188741 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -4433,6 +4433,13 @@ static int find_prev_closest_index(AVStream *st, (*tts_sample)--; } } + } else if (tts_data && *index >= 0) { + av_assert0(tts_index); + av_assert0(tts_sample); + // Without CTTS, the time to sample entries (which also carry the + // per-sample STTS durations) still have to start at the found frame. + *tts_index = FFMIN(*index, tts_count); + *tts_sample = 0; } /* restore AVStream state*/ diff --git a/tests/ref/fate/quickdraw b/tests/ref/fate/quickdraw index 44610498c8f..5746929502a 100644 --- a/tests/ref/fate/quickdraw +++ b/tests/ref/fate/quickdraw @@ -9,7 +9,7 @@ 0, 3, 3, 1, 921600, 0xc0e68764 0, 4, 4, 1, 921600, 0xc0e68764 0, 5, 5, 1, 921600, 0xc0e68764 -0, 7, 7, 2, 921600, 0x01a16629 +0, 7, 7, 1, 921600, 0x01a16629 0, 9, 9, 1, 921600, 0x01a16629 0, 10, 10, 1, 921600, 0x01a16629 0, 11, 11, 1, 921600, 0x01a16629 -- 2.54.1 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
