PR #26422 opened by Romain Beauxis (toots)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26422
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26422.patch

The wrapper never reported the encoder's reorder delay, unlike libx264.
Export it from the parameters the encoder actually uses, since
x265_encoder_open() may change bframes and b-pyramid (all-intra,
intra refresh, MCSTF, temporal layers).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Baptiste Coudurier <[email protected]>
(cherry picked from commit 695768baedfef8eab6e75129750ecec9fd1c6728)


>From b19b76de5528db185d0887a931957afbb16d3194 Mon Sep 17 00:00:00 2001
From: Baptiste Coudurier <[email protected]>
Date: Thu, 12 Nov 2026 13:47:45 -0800
Subject: [PATCH] avcodec/libx265: set has_b_frames

The wrapper never reported the encoder's reorder delay, unlike libx264.
Export it from the parameters the encoder actually uses, since
x265_encoder_open() may change bframes and b-pyramid (all-intra,
intra refresh, MCSTF, temporal layers).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Baptiste Coudurier <[email protected]>
(cherry picked from commit 695768baedfef8eab6e75129750ecec9fd1c6728)
---
 libavcodec/libx265.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index 0ec4f87f5fb..a6738aaa9b5 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -608,6 +608,11 @@ static av_cold int libx265_encode_init(AVCodecContext 
*avctx)
         return AVERROR_INVALIDDATA;
     }
 
+    /* x265 may adjust the B-frame settings when opening the encoder */
+    ctx->api->encoder_parameters(ctx->encoder, ctx->params);
+    avctx->has_b_frames = ctx->params->bframes ?
+                          ctx->params->bBPyramid ? 2 : 1 : 0;
+
     if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
         x265_nal *nal;
         int nnal;
-- 
2.54.1

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

Reply via email to