Commit 695768baed for ffmpeg
commit 695768baedfef8eab6e75129750ecec9fd1c6728
Author: Baptiste Coudurier <baptiste.coudurier@gmail.com>
Date: Thu Nov 12 13:47:45 2026 -0800
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 <noreply@anthropic.com>
Signed-off-by: Baptiste Coudurier <baptiste.coudurier@gmail.com>
diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index 0ec4f87f5f..a6738aaa9b 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;