summaryrefslogtreecommitdiff
path: root/libavcodec/libsvtav1.c
diff options
context:
space:
mode:
authorJan Ekström <jeebjp@gmail.com>2022-05-09 21:29:44 +0300
committerJan Ekström <jeebjp@gmail.com>2022-05-09 23:08:42 +0300
commitfe100bc556d7b25d301ed65f7ae7a74880770f09 (patch)
tree13359b800b3deadf72b6421db25364810475b4ba /libavcodec/libsvtav1.c
parent70887d44ffa31b95704b85531fc53ddd4d9aab14 (diff)
downloadffmpeg-fe100bc556d7b25d301ed65f7ae7a74880770f09.tar.gz
avcodec/libsvtav1: signal CPB properties through side data
This way values such as maxrate/bufsize can be utilized further down the chain. First, syncs up the max_rate and buffer_size from SVT-AV1 back to avctx, and then in case at least one of the utilized values is nonzero, adds the CPB properties side data.
Diffstat (limited to 'libavcodec/libsvtav1.c')
-rw-r--r--libavcodec/libsvtav1.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
index 2c4ddd4641..d9ebb6aa56 100644
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -297,8 +297,20 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param,
param->profile = FF_PROFILE_AV1_HIGH;
}
- avctx->bit_rate = param->rate_control_mode > 0 ?
- param->target_bit_rate : 0;
+ avctx->bit_rate = param->rate_control_mode > 0 ?
+ param->target_bit_rate : 0;
+ avctx->rc_max_rate = param->max_bit_rate;
+ avctx->rc_buffer_size = param->vbv_bufsize;
+
+ if (avctx->bit_rate || avctx->rc_max_rate || avctx->rc_buffer_size) {
+ AVCPBProperties *cpb_props = ff_add_cpb_side_data(avctx);
+ if (!cpb_props)
+ return AVERROR(ENOMEM);
+
+ cpb_props->buffer_size = avctx->rc_buffer_size;
+ cpb_props->max_bitrate = avctx->rc_max_rate;
+ cpb_props->avg_bitrate = avctx->bit_rate;
+ }
return 0;
}