diff mbox series

[FFmpeg-devel] avcodec/qsvenc: clip global_quality for ICQ modes.

Message ID 20210711044415.875-1-ffmpeg@gyani.pro
State Accepted
Headers show
Series [FFmpeg-devel] avcodec/qsvenc: clip global_quality for ICQ modes. | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Gyan Doshi July 11, 2021, 4:44 a.m. UTC
Allowed range is 1 to 51.

Ref: https://software.intel.com/content/www/us/en/develop/articles/advanced-bitrate-control-methods-in-intel-media-sdk.html
---
 doc/encoders.texi   | 3 ++-
 libavcodec/qsvenc.c | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

Comments

Xiang, Haihao July 12, 2021, 1:14 a.m. UTC | #1
On Sun, 2021-07-11 at 10:14 +0530, Gyan Doshi wrote:
> Allowed range is 1 to 51.
> 
> Ref: 
> https://software.intel.com/content/www/us/en/develop/articles/advanced-bitrate-control-methods-in-intel-media-sdk.html
> ---
>  doc/encoders.texi   | 3 ++-
>  libavcodec/qsvenc.c | 2 +-
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/doc/encoders.texi b/doc/encoders.texi
> index 4c38996372..8fccd73691 100644
> --- a/doc/encoders.texi
> +++ b/doc/encoders.texi
> @@ -3119,7 +3119,8 @@ also set (the @option{-qscale} ffmpeg option).
>  @option{look_ahead} option is also set.
>  
>  @item
> -@var{ICQ} -- intelligent constant quality otherwise.
> +@var{ICQ} -- intelligent constant quality otherwise. For the ICQ modes,
> global
> +quality range is 1 to 51, with 1 being the best quality.
>  @end itemize
>  
>  @item
> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
> index ca2b42cafd..b9a922d6b9 100644
> --- a/libavcodec/qsvenc.c
> +++ b/libavcodec/qsvenc.c
> @@ -650,7 +650,7 @@ static int init_video_param(AVCodecContext *avctx,
> QSVEncContext *q)
>      case MFX_RATECONTROL_LA_ICQ:
>          q->extco2.LookAheadDepth = q->look_ahead_depth;
>      case MFX_RATECONTROL_ICQ:
> -        q->param.mfx.ICQQuality  = avctx->global_quality;
> +        q->param.mfx.ICQQuality  = av_clip(avctx->global_quality, 1, 51);
>          break;
>  #endif
>  #endif

LGTM

Thanks
Haihao
Gyan Doshi July 12, 2021, 4:04 a.m. UTC | #2
On 2021-07-12 06:44, Xiang, Haihao wrote:
> On Sun, 2021-07-11 at 10:14 +0530, Gyan Doshi wrote:
>> Allowed range is 1 to 51.
>>
>> Ref:
>> https://software.intel.com/content/www/us/en/develop/articles/advanced-bitrate-control-methods-in-intel-media-sdk.html
>> ---
>>   doc/encoders.texi   | 3 ++-
>>   libavcodec/qsvenc.c | 2 +-
>>   2 files changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/doc/encoders.texi b/doc/encoders.texi
>> index 4c38996372..8fccd73691 100644
>> --- a/doc/encoders.texi
>> +++ b/doc/encoders.texi
>> @@ -3119,7 +3119,8 @@ also set (the @option{-qscale} ffmpeg option).
>>   @option{look_ahead} option is also set.
>>   
>>   @item
>> -@var{ICQ} -- intelligent constant quality otherwise.
>> +@var{ICQ} -- intelligent constant quality otherwise. For the ICQ modes,
>> global
>> +quality range is 1 to 51, with 1 being the best quality.
>>   @end itemize
>>   
>>   @item
>> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
>> index ca2b42cafd..b9a922d6b9 100644
>> --- a/libavcodec/qsvenc.c
>> +++ b/libavcodec/qsvenc.c
>> @@ -650,7 +650,7 @@ static int init_video_param(AVCodecContext *avctx,
>> QSVEncContext *q)
>>       case MFX_RATECONTROL_LA_ICQ:
>>           q->extco2.LookAheadDepth = q->look_ahead_depth;
>>       case MFX_RATECONTROL_ICQ:
>> -        q->param.mfx.ICQQuality  = avctx->global_quality;
>> +        q->param.mfx.ICQQuality  = av_clip(avctx->global_quality, 1, 51);
>>           break;
>>   #endif
>>   #endif
> LGTM

Thanks. Pushed as 1aa9dcd091ed9cebf06c4c6a9c96ff80a54722f4

Regards,
Gyan
diff mbox series

Patch

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 4c38996372..8fccd73691 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -3119,7 +3119,8 @@  also set (the @option{-qscale} ffmpeg option).
 @option{look_ahead} option is also set.
 
 @item
-@var{ICQ} -- intelligent constant quality otherwise.
+@var{ICQ} -- intelligent constant quality otherwise. For the ICQ modes, global
+quality range is 1 to 51, with 1 being the best quality.
 @end itemize
 
 @item
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index ca2b42cafd..b9a922d6b9 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -650,7 +650,7 @@  static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
     case MFX_RATECONTROL_LA_ICQ:
         q->extco2.LookAheadDepth = q->look_ahead_depth;
     case MFX_RATECONTROL_ICQ:
-        q->param.mfx.ICQQuality  = avctx->global_quality;
+        q->param.mfx.ICQQuality  = av_clip(avctx->global_quality, 1, 51);
         break;
 #endif
 #endif