diff mbox

[FFmpeg-devel] lavc/libx265: signal CPB properties through side data

Message ID 20190223003528.16182-1-jeebjp@gmail.com
State Accepted
Commit 4635f649534bb4e3e051be4e416bfdd78074d0b7
Headers show

Commit Message

Jan Ekström Feb. 23, 2019, 12:35 a.m. UTC
This way values such as maxrate/bufsize can be utilized
further down the chain.
---
 libavcodec/libx265.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Jan Ekström March 2, 2019, 5:12 p.m. UTC | #1
On Sat, Feb 23, 2019 at 2:35 AM Jan Ekström <jeebjp@gmail.com> wrote:
>
> This way values such as maxrate/bufsize can be utilized
> further down the chain.
> ---

Ping.

This is similar to what the libx264 and libvpx wrappers do, and
enables modules such as hlsenc, movenc and mpegenc in libavformat
utilize the rate control values (such as max rate/bit rate) for
signaling purposes.

Jan
Derek Buitenhuis March 3, 2019, 9:30 p.m. UTC | #2
On 23/02/2019 00:35, Jan Ekström wrote:
> This way values such as maxrate/bufsize can be utilized
> further down the chain.
> ---
>  libavcodec/libx265.c | 8 ++++++++
>  1 file changed, 8 insertions(+)

OK.

- Derek
Jan Ekström March 3, 2019, 9:44 p.m. UTC | #3
On Sun, Mar 3, 2019 at 11:31 PM Derek Buitenhuis
<derek.buitenhuis@gmail.com> wrote:
>
> On 23/02/2019 00:35, Jan Ekström wrote:
> > This way values such as maxrate/bufsize can be utilized
> > further down the chain.
> > ---
> >  libavcodec/libx265.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
>
> OK.
>
> - Derek

Thanks for the review, applied.

Jan
diff mbox

Patch

diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index 98415366da..fe39f45241 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -79,6 +79,7 @@  static av_cold int libx265_encode_close(AVCodecContext *avctx)
 static av_cold int libx265_encode_init(AVCodecContext *avctx)
 {
     libx265Context *ctx = avctx->priv_data;
+    AVCPBProperties *cpb_props = NULL;
 
     ctx->api = x265_api_get(av_pix_fmt_desc_get(avctx->pix_fmt)->comp[0].depth);
     if (!ctx->api)
@@ -208,6 +209,13 @@  static av_cold int libx265_encode_init(AVCodecContext *avctx)
     ctx->params->rc.vbvBufferSize = avctx->rc_buffer_size / 1000;
     ctx->params->rc.vbvMaxBitrate = avctx->rc_max_rate    / 1000;
 
+    cpb_props = ff_add_cpb_side_data(avctx);
+    if (!cpb_props)
+        return AVERROR(ENOMEM);
+    cpb_props->buffer_size = ctx->params->rc.vbvBufferSize * 1000;
+    cpb_props->max_bitrate = ctx->params->rc.vbvMaxBitrate * 1000;
+    cpb_props->avg_bitrate = ctx->params->rc.bitrate       * 1000;
+
     if (!(avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER))
         ctx->params->bRepeatHeaders = 1;