[007/264] libx264: export CPB props side data

Message ID 1447012658-16819-8-git-send-email-anton@khirnov.net
State Committed
Headers show

Commit Message

Anton Khirnov Nov. 8, 2015, 7:57 p.m.
---
 libavcodec/libx264.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Derek Buitenhuis Nov. 8, 2015, 8:36 p.m. | #1
On 11/8/2015 7:57 PM, Anton Khirnov wrote:
> ---
>  libavcodec/libx264.c | 8 ++++++++
>  1 file changed, 8 insertions(+)

Missing libx265.c?

- Derek
Anton Khirnov Nov. 9, 2015, 6:33 a.m. | #2
Quoting Derek Buitenhuis (2015-11-08 21:36:45)
> On 11/8/2015 7:57 PM, Anton Khirnov wrote:
> > ---
> >  libavcodec/libx264.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> 
> Missing libx265.c?

It does not seem to support a VBV/HRD compliant mode. Or at least it
does not access max/min bitrate.

Patch

diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index bcbdf84..99dbab6 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -351,6 +351,7 @@  static int convert_pix_fmt(enum AVPixelFormat pix_fmt)
 static av_cold int X264_init(AVCodecContext *avctx)
 {
     X264Context *x4 = avctx->priv_data;
+    AVCPBProperties *cpb_props;
 
 #if CONFIG_LIBX262_ENCODER
     if (avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
@@ -610,6 +611,13 @@  FF_ENABLE_DEPRECATION_WARNINGS
         avctx->extradata_size = p - avctx->extradata;
     }
 
+    cpb_props = ff_add_cpb_sd(avctx);
+    if (!cpb_props)
+        return AVERROR(ENOMEM);
+    cpb_props->buffer_size = x4->params.rc.i_vbv_buffer_size * 1000;
+    cpb_props->max_bitrate = x4->params.rc.i_vbv_max_bitrate * 1000;
+    cpb_props->avg_bitrate = x4->params.rc.i_bitrate         * 1000;
+
     return 0;
 }