Hi!

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

Please comment, Carl Eugen
From 9c51b260a0c65fe7fbf18ac5235f3336be66502c Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffm...@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

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to