summaryrefslogtreecommitdiff
path: root/libavcodec/libvpxenc.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2015-10-03 15:19:10 +0200
committerAnton Khirnov <anton@khirnov.net>2015-12-06 10:24:47 +0100
commit03afb62e83516141ba999536fc97575faefb98af (patch)
tree2216fe2d5dc622ce1e4ca6bf757da951abe0e7c0 /libavcodec/libvpxenc.c
parent11c9bd633f635f07a762be1ecd672de55daf4edc (diff)
libvpxenc: export CPB props side data
Diffstat (limited to 'libavcodec/libvpxenc.c')
-rw-r--r--libavcodec/libvpxenc.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index d1e2523e54..a3f7b6c951 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -212,6 +212,7 @@ static av_cold int vpx_init(AVCodecContext *avctx,
{
VP8Context *ctx = avctx->priv_data;
struct vpx_codec_enc_cfg enccfg = { 0 };
+ AVCPBProperties *cpb_props;
int res;
av_log(avctx, AV_LOG_INFO, "%s\n", vpx_codec_version_str());
@@ -362,6 +363,18 @@ static av_cold int vpx_init(AVCodecContext *avctx,
vpx_img_wrap(&ctx->rawimg, ff_vpx_pixfmt_to_imgfmt(avctx->pix_fmt),
avctx->width, avctx->height, 1, (unsigned char *)1);
+ cpb_props = ff_add_cpb_side_data(avctx);
+ if (!cpb_props)
+ return AVERROR(ENOMEM);
+
+ if (enccfg.rc_end_usage == VPX_CBR ||
+ enccfg.g_pass != VPX_RC_ONE_PASS) {
+ cpb_props->max_bitrate = avctx->rc_max_rate;
+ cpb_props->min_bitrate = avctx->rc_min_rate;
+ cpb_props->avg_bitrate = avctx->bit_rate;
+ }
+ cpb_props->buffer_size = avctx->rc_buffer_size;
+
return 0;
}