[FFmpeg-devel,v2] lavc/qsvenc: expose low_power option in H264 QSV

Submitted by Linjie Fu on March 26, 2019, 5:51 a.m.

Details

Message ID 20190326055119.30611-1-linjie.fu@intel.com
State New
Headers show

Commit Message

Linjie Fu March 26, 2019, 5:51 a.m.
Always exposes low_power option for h264 qsv, and reports a warning
if VDENC is not supported with current version of MSDK.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
---
[v2]: repalce "VDENC" with "low_power" to be more understandable.

 libavcodec/qsvenc.c      | 11 ++++++++++-
 libavcodec/qsvenc_h264.c |  2 --
 2 files changed, 10 insertions(+), 3 deletions(-)

Comments

Zhong Li March 28, 2019, 10:37 a.m.
> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf

> Of Linjie Fu

> Sent: Tuesday, March 26, 2019 1:51 PM

> To: ffmpeg-devel@ffmpeg.org

> Cc: Fu, Linjie <linjie.fu@intel.com>

> Subject: [FFmpeg-devel] [PATCH, v2] lavc/qsvenc: expose low_power option

> in H264 QSV

> 

> Always exposes low_power option for h264 qsv, and reports a warning if

> VDENC is not supported with current version of MSDK.

> 

> Signed-off-by: Linjie Fu <linjie.fu@intel.com>

> ---

> [v2]: repalce "VDENC" with "low_power" to be more understandable.

> 

>  libavcodec/qsvenc.c      | 11 ++++++++++-

>  libavcodec/qsvenc_h264.c |  2 --

>  2 files changed, 10 insertions(+), 3 deletions(-)

> 

> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index

> 5aa020d47b..8264d0a413 100644

> --- a/libavcodec/qsvenc.c

> +++ b/libavcodec/qsvenc.c

> @@ -495,9 +495,18 @@ static int init_video_param(AVCodecContext *avctx,

> QSVEncContext *q)

>          }

>      }

> 

> +    if (q->low_power) {

>  #if QSV_HAVE_VDENC

> -    q->param.mfx.LowPower           = q->low_power ?

> MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;

> +        q->param.mfx.LowPower = MFX_CODINGOPTION_ON; #else

> +        av_log(avctx, AV_LOG_WARNING, "The low_power option is "

> +                            "not supported with this MSDK

> version.\n");

> +        q->low_power = 0;

> +        q->param.mfx.LowPower = MFX_CODINGOPTION_OFF;

>  #endif

> +    } else

> +        q->param.mfx.LowPower = MFX_CODINGOPTION_OFF;

> +

>      q->param.mfx.CodecProfile       = q->profile;

>      q->param.mfx.TargetUsage        = avctx->compression_level;

>      q->param.mfx.GopPicSize         = FFMAX(0, avctx->gop_size);

> diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c index

> f458137848..93044a58c9 100644

> --- a/libavcodec/qsvenc_h264.c

> +++ b/libavcodec/qsvenc_h264.c

> @@ -154,9 +154,7 @@ static const AVOption options[] = {

>      { "auto"   , NULL, 0, AV_OPT_TYPE_CONST, { .i64 =

> MFX_MF_AUTO     }, INT_MIN, INT_MAX,     VE, "mfmode" },

>  #endif

> 

> -#if QSV_HAVE_VDENC

>      { "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}, -#endif

> 

>      { "repeat_pps", "repeat pps for every frame", OFFSET(qsv.repeat_pps),

> AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },


How about move this h264 private option to qsvenc.h to make it a common option for all codecs?
Though it is not supported for all codecs, but IMHO this not a big problem since we will check it at runtime: https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/qsvenc.c#L389 

It will be aligned with ffmpeg-vaapi, and avoid extra effort if other codecs add low_power support.

Patch hide | download patch | download mbox

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 5aa020d47b..8264d0a413 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -495,9 +495,18 @@  static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
         }
     }
 
+    if (q->low_power) {
 #if QSV_HAVE_VDENC
-    q->param.mfx.LowPower           = q->low_power ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
+        q->param.mfx.LowPower = MFX_CODINGOPTION_ON;
+#else
+        av_log(avctx, AV_LOG_WARNING, "The low_power option is "
+                            "not supported with this MSDK version.\n");
+        q->low_power = 0;
+        q->param.mfx.LowPower = MFX_CODINGOPTION_OFF;
 #endif
+    } else
+        q->param.mfx.LowPower = MFX_CODINGOPTION_OFF;
+
     q->param.mfx.CodecProfile       = q->profile;
     q->param.mfx.TargetUsage        = avctx->compression_level;
     q->param.mfx.GopPicSize         = FFMAX(0, avctx->gop_size);
diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
index f458137848..93044a58c9 100644
--- a/libavcodec/qsvenc_h264.c
+++ b/libavcodec/qsvenc_h264.c
@@ -154,9 +154,7 @@  static const AVOption options[] = {
     { "auto"   , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_MF_AUTO     }, INT_MIN, INT_MAX,     VE, "mfmode" },
 #endif
 
-#if QSV_HAVE_VDENC
     { "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},
-#endif
 
     { "repeat_pps", "repeat pps for every frame", OFFSET(qsv.repeat_pps), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },