PR #26215 opened by Pu Cheng (GeekQAQ)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26215
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26215.patch

h264_flush() resets the SPS, the POC state and the frame counters but
not poc_diff, the smallest POC difference seen between output pictures,
which bounds the POC step used to derive timestamps. After av_bsf_flush()
a stream whose POC advances by 2 per frame following one that advanced
by 1 gets its pts and durations computed with the previous stream's
step.

Signed-off-by: Pu Cheng <[email protected]>



>From 417846b072f8263bafa10c53c769551b51c82b59 Mon Sep 17 00:00:00 2001
From: Pu Cheng <[email protected]>
Date: Fri, 20 Nov 2026 14:08:21 +0800
Subject: [PATCH] avcodec/bsf/dts2pts: reset poc_diff on flush

h264_flush() resets the SPS, the POC state and the frame counters but
not poc_diff, the smallest POC difference seen between output pictures,
which bounds the POC step used to derive timestamps. After av_bsf_flush()
a stream whose POC advances by 2 per frame following one that advanced
by 1 gets its pts and durations computed with the previous stream's
step.

Signed-off-by: Pu Cheng <[email protected]>
---
 libavcodec/bsf/dts2pts.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/bsf/dts2pts.c b/libavcodec/bsf/dts2pts.c
index 6d86a2cf5dd..04739a0d6fc 100644
--- a/libavcodec/bsf/dts2pts.c
+++ b/libavcodec/bsf/dts2pts.c
@@ -398,6 +398,7 @@ static void h264_flush(AVBSFContext *ctx)
 
     memset(&h264->sps, 0, sizeof(h264->sps));
     memset(&h264->poc, 0, sizeof(h264->poc));
+    h264->poc_diff = 0;
     s->nb_frame = -(ctx->par_in->video_delay << 1);
     h264->last_poc = h264->highest_poc = INT_MIN;
 }
-- 
2.54.1

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to