mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2026-08-09 17:39:08 +00:00
STTS sample deltas follow decode order, while AVPacket.duration is defined as the interval to the next PTS in presentation order. Assigning the deltas directly therefore produces incorrect packet durations for VFR video with reordered frames. After index construction and edit-list processing, sort samples by PTS and set every duration with a following PTS from adjacent presentation timestamps. This reorders STTS durations where possible and derives intervals produced by the STTS/CTTS combination when necessary. Keep the original timing table if allocation fails or timestamps are invalid. Add FATE coverage for the official VFR H.264 sample and for a generated MPEG-4 case whose presentation intervals are not a permutation of its STTS deltas. Update the HEVC dts2pts CRA reference for the corrected presentation-order durations. Signed-off-by: panboxiaosa <panboxiaosa@gmail.com>