[FFmpeg-devel] lavc/qsvenc: set HRD buffer size

Submitted by Zhong Li on Dec. 1, 2017, 8:02 p.m.

Details

Message ID 1512158562-24848-1-git-send-email-zhong.li@intel.com
State New
Headers show

Commit Message

Zhong Li Dec. 1, 2017, 8:02 p.m.
Hypothetical Reference Decoding (HRD) model assumes that data flows into a
buffer of the fixed size BufferSizeInKB with a constant bitrate.
BufferSizeInKB represents the maximum possible size of any compressed frames.

Signed-off-by: Zhong Li <zhong.li@intel.com>
---
 libavcodec/qsvenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index c45b2a6..9283d40 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -429,7 +429,7 @@  static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
     q->param.mfx.NumSlice           = avctx->slices;
     q->param.mfx.NumRefFrame        = FFMAX(0, avctx->refs);
     q->param.mfx.EncodedOrder       = 0;
-    q->param.mfx.BufferSizeInKB     = 0;
+    q->param.mfx.BufferSizeInKB     = (avctx->rc_buffer_size > 0) ? avctx->rc_buffer_size / 8000 : 0;
 
     desc = av_pix_fmt_desc_get(sw_format);
     if (!desc)