[FFmpeg-devel] [PATCH 1/2] avcodec/libsvtav1: signal CPB properties through side data
Jan Ekström
jeebjp at gmail.com
Sun Mar 27 21:02:10 EEST 2022
This way values such as maxrate/bufsize can be utilized further
down the chain.
The libavcodec values are utilized instead of from the encoder
configuration struct since:
1) both utilize bits per second, so no loss of precision occured.
2) the struct defaults various values to nonzero - even though it
is documented to be unused outside of bit rate based rate
control modes.
---
libavcodec/libsvtav1.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
index 6cf280377e..d89fefdf4c 100644
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -156,6 +156,9 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param,
SvtContext *svt_enc = avctx->priv_data;
const AVPixFmtDescriptor *desc;
AVDictionaryEntry *en = NULL;
+ AVCPBProperties *cpb_props = ff_add_cpb_side_data(avctx);
+ if (!cpb_props)
+ return AVERROR(ENOMEM);
// Update param from options
#if FF_API_SVTAV1_OPTS
@@ -191,6 +194,10 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param,
param->enable_adaptive_quantization = 0;
}
+ cpb_props->buffer_size = avctx->rc_buffer_size;
+ cpb_props->max_bitrate = avctx->rc_max_rate;
+ cpb_props->avg_bitrate = avctx->bit_rate;;
+
#if SVT_AV1_CHECK_VERSION(0, 9, 1)
while ((en = av_dict_get(svt_enc->svtav1_opts, "", en, AV_DICT_IGNORE_SUFFIX))) {
EbErrorType ret = svt_av1_enc_parse_parameter(param, en->key, en->value);
--
2.35.1
More information about the ffmpeg-devel
mailing list