diff mbox

[FFmpeg-devel,v3] lavc/qsvenc: add VDENC support for H264

Message ID 20181127064900.7982-1-linjie.fu@intel.com
State Accepted
Headers show

Commit Message

Fu, Linjie Nov. 27, 2018, 6:49 a.m. UTC
Add VDENC(lowpower mode) support for QSV H264.

It's an experimental function(like lowpower in vaapi) with
some limitations:
- CBR/VBR require HuC which should be explicitly loaded via i915
module parameter(i915.enable_guc=2 for linux kernel version >= 4.16)

use option "-low_power 1" to enable VDENC.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
---
[v2]: modified the commit message and option comments, use AV_OPT_TYPE_BOOL
to replace AV_OPT_TYPE_INT.
[v3]: enable H264 VDENC separately.

 libavcodec/qsvenc.c      | 3 +++
 libavcodec/qsvenc.h      | 2 ++
 libavcodec/qsvenc_h264.c | 3 +++
 3 files changed, 8 insertions(+)

Comments

Zhong Li Nov. 27, 2018, 9:26 a.m. UTC | #1
> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf

> Of Linjie Fu

> Sent: Tuesday, November 27, 2018 2:49 PM

> To: ffmpeg-devel@ffmpeg.org

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

> Subject: [FFmpeg-devel] [PATCH,v3] lavc/qsvenc: add VDENC support for

> H264

> 

> Add VDENC(lowpower mode) support for QSV H264.

> 

> It's an experimental function(like lowpower in vaapi) with some limitations:

> - CBR/VBR require HuC which should be explicitly loaded via i915 module

> parameter(i915.enable_guc=2 for linux kernel version >= 4.16)

> 

> use option "-low_power 1" to enable VDENC.

> 

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

> ---

> [v2]: modified the commit message and option comments, use

> AV_OPT_TYPE_BOOL to replace AV_OPT_TYPE_INT.

> [v3]: enable H264 VDENC separately.

> 

>  libavcodec/qsvenc.c      | 3 +++

>  libavcodec/qsvenc.h      | 2 ++

>  libavcodec/qsvenc_h264.c | 3 +++

>  3 files changed, 8 insertions(+)

> 

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

> 948751daf4..7a031297fe 100644

> --- a/libavcodec/qsvenc.c

> +++ b/libavcodec/qsvenc.c

> @@ -464,6 +464,9 @@ static int init_video_param(AVCodecContext *avctx,

> QSVEncContext *q)

>          }

>      }

> 

> +#if QSV_HAVE_VDENC

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

> MFX_CODINGOPTION_ON:MFX_CODINGOPTION_OFF;

> +#endif


Could add LowPower information in dump_video_param()? 
Then user can check whether it has been enabled at runtime log message.

>      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.h b/libavcodec/qsvenc.h index

> 50cc4267e7..a396aa7d3f 100644

> --- a/libavcodec/qsvenc.h

> +++ b/libavcodec/qsvenc.h

> @@ -44,6 +44,7 @@

>  #define QSV_HAVE_LA     QSV_VERSION_ATLEAST(1, 7)

>  #define QSV_HAVE_LA_DS  QSV_VERSION_ATLEAST(1, 8)  #define

> QSV_HAVE_LA_HRD QSV_VERSION_ATLEAST(1, 11)

> +#define QSV_HAVE_VDENC  QSV_VERSION_ATLEAST(1, 15)

> 

>  #if defined(_WIN32) || defined(__CYGWIN__)

>  #define QSV_HAVE_AVBR   QSV_VERSION_ATLEAST(1, 3)

> @@ -162,6 +163,7 @@ typedef struct QSVEncContext {

>      int recovery_point_sei;

> 

>      int a53_cc;

> +    int low_power;

> 

>  #if QSV_HAVE_MF

>      int mfmode;

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

> 07c9d64e6b..8857959d39 100644

> --- a/libavcodec/qsvenc_h264.c

> +++ b/libavcodec/qsvenc_h264.c

> @@ -153,6 +153,9 @@ static const AVOption options[] = {

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

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

>      { "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, 


Should be "experimental:" instead of "experimental,"
And please also refer Moritz Barsnick's comment in the patch V2.
diff mbox

Patch

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 948751daf4..7a031297fe 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -464,6 +464,9 @@  static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
         }
     }
 
+#if QSV_HAVE_VDENC
+    q->param.mfx.LowPower           = q->low_power ? MFX_CODINGOPTION_ON:MFX_CODINGOPTION_OFF;
+#endif
     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.h b/libavcodec/qsvenc.h
index 50cc4267e7..a396aa7d3f 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -44,6 +44,7 @@ 
 #define QSV_HAVE_LA     QSV_VERSION_ATLEAST(1, 7)
 #define QSV_HAVE_LA_DS  QSV_VERSION_ATLEAST(1, 8)
 #define QSV_HAVE_LA_HRD QSV_VERSION_ATLEAST(1, 11)
+#define QSV_HAVE_VDENC  QSV_VERSION_ATLEAST(1, 15)
 
 #if defined(_WIN32) || defined(__CYGWIN__)
 #define QSV_HAVE_AVBR   QSV_VERSION_ATLEAST(1, 3)
@@ -162,6 +163,7 @@  typedef struct QSVEncContext {
     int recovery_point_sei;
 
     int a53_cc;
+    int low_power;
 
 #if QSV_HAVE_MF
     int mfmode;
diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
index 07c9d64e6b..8857959d39 100644
--- a/libavcodec/qsvenc_h264.c
+++ b/libavcodec/qsvenc_h264.c
@@ -153,6 +153,9 @@  static const AVOption options[] = {
     { "off"    , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_MF_DISABLED }, INT_MIN, INT_MAX,     VE, "mfmode" },
     { "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
 
     { NULL },
 };