diff mbox series

[FFmpeg-devel] lavc/qsvenc: allows the SDK runtime to choose LowPower/non-LowPower modes

Message ID 20201010062243.1478719-1-haihao.xiang@intel.com
State New
Headers show
Series [FFmpeg-devel] lavc/qsvenc: allows the SDK runtime to choose LowPower/non-LowPower modes | expand

Checks

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

Commit Message

Xiang, Haihao Oct. 10, 2020, 6:22 a.m. UTC
The SDK supports LowPower and non-LowPower modes, but some features are
available only under one of the two modes. Currently non-LowPower mode
is always chosen in FFmpeg if the mode is not set explicitly, which will
result in some SDK errors if a feature is unavailable under non-LowPower
mode. With this patch, the mode is unknown in FFmpeg if the mode is not
set explicitly, the SDK is responsible for mode selection
---
This is the new version for "lavc/qsvenc: let the SDK to choose the
encoding mode by default" and the git commit log is updated only

 libavcodec/qsvenc.c | 6 ++++--
 libavcodec/qsvenc.h | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

Comments

Xiang, Haihao Nov. 9, 2020, 1:28 a.m. UTC | #1
@Zhong, @Mark

Could you take a look at this patch when you get a chance?

Thanks
Haihao


> The SDK supports LowPower and non-LowPower modes, but some features are
> available only under one of the two modes. Currently non-LowPower mode
> is always chosen in FFmpeg if the mode is not set explicitly, which will
> result in some SDK errors if a feature is unavailable under non-LowPower
> mode. With this patch, the mode is unknown in FFmpeg if the mode is not
> set explicitly, the SDK is responsible for mode selection
> ---
> This is the new version for "lavc/qsvenc: let the SDK to choose the
> encoding mode by default" and the git commit log is updated only
> 
>  libavcodec/qsvenc.c | 6 ++++--
>  libavcodec/qsvenc.h | 2 +-
>  2 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
> index 1ed8f5d973..cff96e59c9 100644
> --- a/libavcodec/qsvenc.c
> +++ b/libavcodec/qsvenc.c
> @@ -510,7 +510,7 @@ static int init_video_param(AVCodecContext *avctx,
> QSVEncContext *q)
>          }
>      }
>  
> -    if (q->low_power) {
> +    if (q->low_power == 1) {
>  #if QSV_HAVE_VDENC
>          q->param.mfx.LowPower = MFX_CODINGOPTION_ON;
>  #else
> @@ -519,7 +519,9 @@ static int init_video_param(AVCodecContext *avctx,
> QSVEncContext *q)
>          q->low_power = 0;
>          q->param.mfx.LowPower = MFX_CODINGOPTION_OFF;
>  #endif
> -    } else
> +    } else if (q->low_power == -1)
> +        q->param.mfx.LowPower = MFX_CODINGOPTION_UNKNOWN;
> +    else
>          q->param.mfx.LowPower = MFX_CODINGOPTION_OFF;
>  
>      q->param.mfx.CodecProfile       = q->profile;
> diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
> index 4f579d1db1..577775cc1a 100644
> --- a/libavcodec/qsvenc.h
> +++ b/libavcodec/qsvenc.h
> @@ -96,7 +96,7 @@
>  { "adaptive_b",     "Adaptive B-frame
> placement",             OFFSET(qsv.adaptive_b),     AV_OPT_TYPE_INT, { .i64 =
> -1 }, -1,          1, VE },                         \
>  { "b_strategy",     "Strategy to choose between I/P/B-frames",
> OFFSET(qsv.b_strategy),    AV_OPT_TYPE_INT, { .i64 = -1 }, -1,          1, VE
> },                         \
>  { "forced_idr",     "Forcing I frames as IDR
> frames",         OFFSET(qsv.forced_idr),     AV_OPT_TYPE_BOOL,{ .i64 =
> 0  },  0,          1, VE },                         \
> -{ "low_power", "enable low power mode(experimental: many limitations by mfx
> version, BRC modes, etc.)", OFFSET(qsv.low_power), AV_OPT_TYPE_BOOL, { .i64 =
> 0}, 0, 1, VE},\
> +{ "low_power", "enable low power mode(experimental: many limitations by mfx
> version, BRC modes, etc.)", OFFSET(qsv.low_power), AV_OPT_TYPE_BOOL, { .i64 =
> -1}, -1, 1, VE},\
>  
>  extern const AVCodecHWConfigInternal *ff_qsv_enc_hw_configs[];
>
Xiang, Haihao Aug. 11, 2021, 3:12 p.m. UTC | #2
On Sat, 2020-10-10 at 14:22 +0800, Haihao Xiang wrote:
> The SDK supports LowPower and non-LowPower modes, but some features are
> available only under one of the two modes. Currently non-LowPower mode
> is always chosen in FFmpeg if the mode is not set explicitly, which will
> result in some SDK errors if a feature is unavailable under non-LowPower
> mode. With this patch, the mode is unknown in FFmpeg if the mode is not
> set explicitly, the SDK is responsible for mode selection
> ---
> This is the new version for "lavc/qsvenc: let the SDK to choose the
> encoding mode by default" and the git commit log is updated only

Hi,

Is there any comment for this patch? Without this patch, user has to set the
mode to LowPower mode explicitly for some features. It is really inconvenient
because lots of user do not know these features are available only under
LowPower mode. If not objection, I may rebase this patch against the current
master.

Thanks
Haihao

> 
>  libavcodec/qsvenc.c | 6 ++++--
>  libavcodec/qsvenc.h | 2 +-
>  2 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
> index 1ed8f5d973..cff96e59c9 100644
> --- a/libavcodec/qsvenc.c
> +++ b/libavcodec/qsvenc.c
> @@ -510,7 +510,7 @@ static int init_video_param(AVCodecContext *avctx,
> QSVEncContext *q)
>          }
>      }
>  
> -    if (q->low_power) {
> +    if (q->low_power == 1) {
>  #if QSV_HAVE_VDENC
>          q->param.mfx.LowPower = MFX_CODINGOPTION_ON;
>  #else
> @@ -519,7 +519,9 @@ static int init_video_param(AVCodecContext *avctx,
> QSVEncContext *q)
>          q->low_power = 0;
>          q->param.mfx.LowPower = MFX_CODINGOPTION_OFF;
>  #endif
> -    } else
> +    } else if (q->low_power == -1)
> +        q->param.mfx.LowPower = MFX_CODINGOPTION_UNKNOWN;
> +    else
>          q->param.mfx.LowPower = MFX_CODINGOPTION_OFF;
>  
>      q->param.mfx.CodecProfile       = q->profile;
> diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
> index 4f579d1db1..577775cc1a 100644
> --- a/libavcodec/qsvenc.h
> +++ b/libavcodec/qsvenc.h
> @@ -96,7 +96,7 @@
>  { "adaptive_b",     "Adaptive B-frame
> placement",             OFFSET(qsv.adaptive_b),     AV_OPT_TYPE_INT, { .i64 =
> -1 }, -1,          1, VE },                         \
>  { "b_strategy",     "Strategy to choose between I/P/B-frames",
> OFFSET(qsv.b_strategy),    AV_OPT_TYPE_INT, { .i64 = -1 }, -1,          1, VE
> },                         \
>  { "forced_idr",     "Forcing I frames as IDR
> frames",         OFFSET(qsv.forced_idr),     AV_OPT_TYPE_BOOL,{ .i64 =
> 0  },  0,          1, VE },                         \
> -{ "low_power", "enable low power mode(experimental: many limitations by mfx
> version, BRC modes, etc.)", OFFSET(qsv.low_power), AV_OPT_TYPE_BOOL, { .i64 =
> 0}, 0, 1, VE},\
> +{ "low_power", "enable low power mode(experimental: many limitations by mfx
> version, BRC modes, etc.)", OFFSET(qsv.low_power), AV_OPT_TYPE_BOOL, { .i64 =
> -1}, -1, 1, VE},\
>  
>  extern const AVCodecHWConfigInternal *ff_qsv_enc_hw_configs[];
>
James Almer Aug. 11, 2021, 4:06 p.m. UTC | #3
On 8/11/2021 12:12 PM, Xiang, Haihao wrote:
> On Sat, 2020-10-10 at 14:22 +0800, Haihao Xiang wrote:
>> The SDK supports LowPower and non-LowPower modes, but some features are
>> available only under one of the two modes. Currently non-LowPower mode
>> is always chosen in FFmpeg if the mode is not set explicitly, which will
>> result in some SDK errors if a feature is unavailable under non-LowPower
>> mode. With this patch, the mode is unknown in FFmpeg if the mode is not
>> set explicitly, the SDK is responsible for mode selection
>> ---
>> This is the new version for "lavc/qsvenc: let the SDK to choose the
>> encoding mode by default" and the git commit log is updated only
> 
> Hi,
> 
> Is there any comment for this patch? Without this patch, user has to set the
> mode to LowPower mode explicitly for some features. It is really inconvenient
> because lots of user do not know these features are available only under
> LowPower mode. If not objection, I may rebase this patch against the current
> master.

Please do.

> 
> Thanks
> Haihao
> 
>>
>>   libavcodec/qsvenc.c | 6 ++++--
>>   libavcodec/qsvenc.h | 2 +-
>>   2 files changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
>> index 1ed8f5d973..cff96e59c9 100644
>> --- a/libavcodec/qsvenc.c
>> +++ b/libavcodec/qsvenc.c
>> @@ -510,7 +510,7 @@ static int init_video_param(AVCodecContext *avctx,
>> QSVEncContext *q)
>>           }
>>       }
>>   
>> -    if (q->low_power) {
>> +    if (q->low_power == 1) {
>>   #if QSV_HAVE_VDENC
>>           q->param.mfx.LowPower = MFX_CODINGOPTION_ON;
>>   #else
>> @@ -519,7 +519,9 @@ static int init_video_param(AVCodecContext *avctx,
>> QSVEncContext *q)
>>           q->low_power = 0;
>>           q->param.mfx.LowPower = MFX_CODINGOPTION_OFF;
>>   #endif
>> -    } else
>> +    } else if (q->low_power == -1)
>> +        q->param.mfx.LowPower = MFX_CODINGOPTION_UNKNOWN;
>> +    else
>>           q->param.mfx.LowPower = MFX_CODINGOPTION_OFF;
>>   
>>       q->param.mfx.CodecProfile       = q->profile;
>> diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
>> index 4f579d1db1..577775cc1a 100644
>> --- a/libavcodec/qsvenc.h
>> +++ b/libavcodec/qsvenc.h
>> @@ -96,7 +96,7 @@
>>   { "adaptive_b",     "Adaptive B-frame
>> placement",             OFFSET(qsv.adaptive_b),     AV_OPT_TYPE_INT, { .i64 =
>> -1 }, -1,          1, VE },                         \
>>   { "b_strategy",     "Strategy to choose between I/P/B-frames",
>> OFFSET(qsv.b_strategy),    AV_OPT_TYPE_INT, { .i64 = -1 }, -1,          1, VE
>> },                         \
>>   { "forced_idr",     "Forcing I frames as IDR
>> frames",         OFFSET(qsv.forced_idr),     AV_OPT_TYPE_BOOL,{ .i64 =
>> 0  },  0,          1, VE },                         \
>> -{ "low_power", "enable low power mode(experimental: many limitations by mfx
>> version, BRC modes, etc.)", OFFSET(qsv.low_power), AV_OPT_TYPE_BOOL, { .i64 =
>> 0}, 0, 1, VE},\
>> +{ "low_power", "enable low power mode(experimental: many limitations by mfx
>> version, BRC modes, etc.)", OFFSET(qsv.low_power), AV_OPT_TYPE_BOOL, { .i64 =
>> -1}, -1, 1, VE},\
>>   
>>   extern const AVCodecHWConfigInternal *ff_qsv_enc_hw_configs[];
>>   
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
diff mbox series

Patch

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 1ed8f5d973..cff96e59c9 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -510,7 +510,7 @@  static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
         }
     }
 
-    if (q->low_power) {
+    if (q->low_power == 1) {
 #if QSV_HAVE_VDENC
         q->param.mfx.LowPower = MFX_CODINGOPTION_ON;
 #else
@@ -519,7 +519,9 @@  static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
         q->low_power = 0;
         q->param.mfx.LowPower = MFX_CODINGOPTION_OFF;
 #endif
-    } else
+    } else if (q->low_power == -1)
+        q->param.mfx.LowPower = MFX_CODINGOPTION_UNKNOWN;
+    else
         q->param.mfx.LowPower = MFX_CODINGOPTION_OFF;
 
     q->param.mfx.CodecProfile       = q->profile;
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index 4f579d1db1..577775cc1a 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -96,7 +96,7 @@ 
 { "adaptive_b",     "Adaptive B-frame placement",             OFFSET(qsv.adaptive_b),     AV_OPT_TYPE_INT, { .i64 = -1 }, -1,          1, VE },                         \
 { "b_strategy",     "Strategy to choose between I/P/B-frames", OFFSET(qsv.b_strategy),    AV_OPT_TYPE_INT, { .i64 = -1 }, -1,          1, VE },                         \
 { "forced_idr",     "Forcing I frames as IDR frames",         OFFSET(qsv.forced_idr),     AV_OPT_TYPE_BOOL,{ .i64 = 0  },  0,          1, VE },                         \
-{ "low_power", "enable low power mode(experimental: many limitations by mfx version, BRC modes, etc.)", OFFSET(qsv.low_power), AV_OPT_TYPE_BOOL, { .i64 = 0}, 0, 1, VE},\
+{ "low_power", "enable low power mode(experimental: many limitations by mfx version, BRC modes, etc.)", OFFSET(qsv.low_power), AV_OPT_TYPE_BOOL, { .i64 = -1}, -1, 1, VE},\
 
 extern const AVCodecHWConfigInternal *ff_qsv_enc_hw_configs[];