PR #23721 opened by JamesGKent
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23721
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23721.patch

# Summary of changes

when a bitstream with b-frames gets corrupted the reorder buffer is increased 
to try accommodate. with this change any restricted compliance prevents this.
when used through gstreamer without this change the latency is increased as the 
buffer grow but gstreamer does not account for this, leading to late and 
dropped frames. in the case of a live stream the strict compliance allows 
keeping a fixed latency



>From 14b101c6b5d26fc9b8fbe812987d626f9c66b93d Mon Sep 17 00:00:00 2001
From: JamesGKent <[email protected]>
Date: Mon, 6 Jul 2026 15:14:05 +0000
Subject: [PATCH] avcodec/h264dec: keep reorder buffer size if strict

when a bitstream with b-frames gets corrupted the reorder buffer is increased 
to try accommodate. with this change any restricted compliance prevents this.
when used through gstreamer without this change the latency is increased as the 
buffer grow but gstreamer does not account for this, leading to late and 
dropped frames. in the case of a live stream the strict compliance allows 
keeping a fixed latency
---
 libavcodec/h264_slice.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 7e2c460293..0863d82967 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1326,7 +1326,7 @@ static int h264_select_output_frame(H264Context *h)
             h->last_pocs[i] = INT_MIN;
         h->last_pocs[0] = cur->poc;
         cur->mmco_reset = 1;
-    } else if(h->avctx->has_b_frames < out_of_order && 
!sps->bitstream_restriction_flag){
+    } else if(h->avctx->has_b_frames < out_of_order && 
!sps->bitstream_restriction_flag && h->avctx->strict_std_compliance <= 
FF_COMPLIANCE_NORMAL){
         int loglevel = h->avctx->frame_num > 1 ? AV_LOG_WARNING : 
AV_LOG_VERBOSE;
         av_log(h->avctx, loglevel, "Increasing reorder buffer to %d\n", 
out_of_order);
         h->avctx->has_b_frames = out_of_order;
-- 
2.52.0

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

Reply via email to