[FFmpeg-devel] lavc/qsvenc: Clip the bitrate, Intel limits it to 65535k

Submitted by Carl Eugen Hoyos on Jan. 10, 2019, 8:52 p.m.

Details

Message ID CAB0OVGoRhvqf_PS9itnN62-+n067y2ZWL=2LcxqQicvCMuv7nw@mail.gmail.com
State Withdrawn
Headers show

Commit Message

Carl Eugen Hoyos Jan. 10, 2019, 8:52 p.m.
Hi!

Attached untested patch tries to limit the effects of setting a high
bitrate for qsv.
Works around ticket #7663.

Please comment, Carl Eugen

Comments

U. Artie Eoff Jan. 10, 2019, 9:32 p.m.
We should use mfxInfoMFX::BRCParamMultiplier to handle high bitrate.  See my new comment in #7663

> -----Original Message-----

> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf Of Carl Eugen Hoyos

> Sent: Thursday, January 10, 2019 12:53 PM

> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>

> Subject: [FFmpeg-devel] [PATCH]lavc/qsvenc: Clip the bitrate, Intel limits it to 65535k

> 

> Hi!

> 

> Attached untested patch tries to limit the effects of setting a high

> bitrate for qsv.

> Works around ticket #7663.

> 

> Please comment, Carl Eugen
Carl Eugen Hoyos Jan. 10, 2019, 9:35 p.m.
2019-01-10 22:32 GMT+01:00, Eoff, Ullysses A <ullysses.a.eoff@intel.com>:
> We should use mfxInfoMFX::BRCParamMultiplier to handle high bitrate.

Sadly, the rules here forbid an answer.
;-)

Carl Eugen
Zhong Li Jan. 11, 2019, 12:14 p.m.
> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf

> Of Carl Eugen Hoyos

> Sent: Friday, January 11, 2019 5:35 AM

> To: FFmpeg development discussions and patches

> <ffmpeg-devel@ffmpeg.org>

> Subject: Re: [FFmpeg-devel] [PATCH]lavc/qsvenc: Clip the bitrate, Intel limits

> it to 65535k

> 

> 2019-01-10 22:32 GMT+01:00, Eoff, Ullysses A <ullysses.a.eoff@intel.com>:

> > We should use mfxInfoMFX::BRCParamMultiplier to handle high bitrate.

> 

> Sadly, the rules here forbid an answer.

> ;-)

> 

> Carl Eugen


I've sent another patch to fix this issue. Could you please help to review and comment?

Patch hide | download patch | download mbox

From 9c51b260a0c65fe7fbf18ac5235f3336be66502c Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Thu, 10 Jan 2019 21:50:04 +0100
Subject: [PATCH] lavc/qsvenc: Clip the bitrate, Intel limits it to 65535k.

Work-around for ticket #7663.
---
 libavcodec/qsvenc.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index e3b5a72..e7083eb 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -558,10 +558,10 @@  static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
 #if QSV_HAVE_VCM
     case MFX_RATECONTROL_VCM:
 #endif
-        q->param.mfx.BufferSizeInKB   = avctx->rc_buffer_size / 8000;
-        q->param.mfx.InitialDelayInKB = avctx->rc_initial_buffer_occupancy / 1000;
-        q->param.mfx.TargetKbps       = avctx->bit_rate / 1000;
-        q->param.mfx.MaxKbps          = avctx->rc_max_rate / 1000;
+        q->param.mfx.BufferSizeInKB   = FFMIN(UINT16_MAX, avctx->rc_buffer_size / 8000);
+        q->param.mfx.InitialDelayInKB = FFMIN(UINT16_MAX, avctx->rc_initial_buffer_occupancy / 1000);
+        q->param.mfx.TargetKbps       = FFMIN(UINT16_MAX, avctx->bit_rate / 1000);
+        q->param.mfx.MaxKbps          = FFMIN(UINT16_MAX, avctx->rc_max_rate / 1000);
         break;
     case MFX_RATECONTROL_CQP:
         quant = avctx->global_quality / FF_QP2LAMBDA;
-- 
1.7.10.4