[FFmpeg-devel] [PATCH] avcodec/libx265: apply lavc maxrate and bufsize
Gyan Doshi
gyandoshi at gmail.com
Mon Jun 18 09:43:14 EEST 2018
On 17-06-2018 09:11 PM, Mark Thompson wrote:
> Given you have these two, maybe set vbvBufferInit from rc_initial_buffer_occupancy as well?
>
> LGTM in either case.
Revised patch attached. Will apply by tonight.
Gyan
-------------- next part --------------
From a6d468b803b839a6cc403da094c7b39cc1ac9f30 Mon Sep 17 00:00:00 2001
From: Gyan Doshi <ffmpeg at gyani.pro>
Date: Mon, 18 Jun 2018 12:09:54 +0530
Subject: [PATCH v2] avcodec/libx265: apply lavc maxrate, bufsize &
rc_init_occupancy
CLI options -maxrate, -bufsize and -rc_init_occupancy can now be picked
up by the x265 wrapper. Min. rc init has to be 1001 to avoid x265
setting it to vbv-bufsize.
---
libavcodec/libx265.c | 8 ++++++++
libavcodec/version.h | 2 +-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index bb457dfe5a..27c90b323f 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -205,6 +205,9 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx)
ctx->params->rc.rateControlMode = X265_RC_ABR;
}
+ ctx->params->rc.vbvBufferSize = avctx->rc_buffer_size / 1000;
+ ctx->params->rc.vbvMaxBitrate = avctx->rc_max_rate / 1000;
+
if (!(avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER))
ctx->params->bRepeatHeaders = 1;
@@ -233,6 +236,11 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx)
}
}
+ if (ctx->params->rc.vbvBufferSize && avctx->rc_initial_buffer_occupancy > 1000 &&
+ ctx->params->rc.vbvBufferInit == 0.9) {
+ ctx->params->rc.vbvBufferInit = (float)avctx->rc_initial_buffer_occupancy / 1000;
+ }
+
if (ctx->profile) {
if (ctx->api->param_apply_profile(ctx->params, ctx->profile) < 0) {
int i;
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 219f56c37d..8f37360054 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
#define LIBAVCODEC_VERSION_MAJOR 58
#define LIBAVCODEC_VERSION_MINOR 20
-#define LIBAVCODEC_VERSION_MICRO 102
+#define LIBAVCODEC_VERSION_MICRO 103
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
--
2.12.2.windows.2
More information about the ffmpeg-devel
mailing list