diff mbox series

[FFmpeg-devel,1/2] avcodec/libsvtav1: signal CPB properties through side data

Message ID 20220327180211.12038-1-jeebjp@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/2] avcodec/libsvtav1: signal CPB properties through side data | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Jan Ekström March 27, 2022, 6:02 p.m. UTC
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 mbox series

Patch

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);