Discussion:
[PATCH] avcodec/qsvenc: add VDENC support for H264 and HEVC
(too old to reply)
Linjie Fu
2018-11-01 06:45:47 UTC
Permalink
Add VDENC(lowpower mode) support for QSV h264 and HEVC
with the limitation of MSDK API verion greater than 1.15.

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 >=4.16)
- HEVC VDENC was supported >= ICE LAKE

use option "-low_power 1" to enable VDENC.

Signed-off-by: Linjie Fu <***@intel.com>
---
libavcodec/qsvenc.c | 3 +++
libavcodec/qsvenc.h | 1 +
libavcodec/qsvenc_h264.c | 3 +++
libavcodec/qsvenc_hevc.c | 3 +++
4 files changed, 10 insertions(+)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 17a0559f3..16d6e79e2 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -472,6 +472,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 2d83c7b1a..997ccf2e3 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)
#define QSV_HAVE_AVBR QSV_VERSION_ATLEAST(1, 3)
diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
index 164f57332..fc2d09154 100644
--- a/libavcodec/qsvenc_h264.c
+++ b/libavcodec/qsvenc_h264.c
@@ -101,6 +101,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", "low power mode for encoder h264_qsv", OFFSET(qsv.low_power), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
+#endif

{ NULL },
};
diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
index 471d17487..c86069c28 100644
--- a/libavcodec/qsvenc_hevc.c
+++ b/libavcodec/qsvenc_hevc.c
@@ -238,6 +238,9 @@ static const AVOption options[] = {
{ "main", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_HEVC_MAIN }, INT_MIN, INT_MAX, VE, "profile" },
{ "main10", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_HEVC_MAIN10 }, INT_MIN, INT_MAX, VE, "profile" },
{ "mainsp", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_HEVC_MAINSP }, INT_MIN, INT_MAX, VE, "profile" },
+#if QSV_HAVE_VDENC
+ { "low_power", "low power mode for encoder hevc_qsv", OFFSET(qsv.low_power), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
+#endif

{ NULL },
};
--
2.17.1
Luca Barbato
2018-11-03 18:13:06 UTC
Permalink
Post by Linjie Fu
Add VDENC(lowpower mode) support for QSV h264 and HEVC
with the limitation of MSDK API verion greater than 1.15.
It's an experimental function(like lowpower in vaapi) with
- CBR/VBR require HuC which should be explicitly loaded via i915
module parameter(i915.enable_guc=2 for >=4.16)
- HEVC VDENC was supported >= ICE LAKE
use option "-low_power 1" to enable VDENC.
---
libavcodec/qsvenc.c | 3 +++
libavcodec/qsvenc.h | 1 +
libavcodec/qsvenc_h264.c | 3 +++
libavcodec/qsvenc_hevc.c | 3 +++
4 files changed, 10 insertions(+)
Looks good, would be great if you could update the documentation about
it since it seems to require some additional setup.

I'd merge it Monday if nobody is against it.

lu
Fu, Linjie
2018-11-05 02:28:02 UTC
Permalink
-----Original Message-----
Barbato
Sent: Sunday, November 4, 2018 02:13
Subject: Re: [libav-devel] [PATCH] avcodec/qsvenc: add VDENC support for
H264 and HEVC
Post by Linjie Fu
Add VDENC(lowpower mode) support for QSV h264 and HEVC
with the limitation of MSDK API verion greater than 1.15.
It's an experimental function(like lowpower in vaapi) with
- CBR/VBR require HuC which should be explicitly loaded via i915
module parameter(i915.enable_guc=2 for >=4.16)
- HEVC VDENC was supported >= ICE LAKE
use option "-low_power 1" to enable VDENC.
---
libavcodec/qsvenc.c | 3 +++
libavcodec/qsvenc.h | 1 +
libavcodec/qsvenc_h264.c | 3 +++
libavcodec/qsvenc_hevc.c | 3 +++
4 files changed, 10 insertions(+)
Looks good, would be great if you could update the documentation about
it since it seems to require some additional setup.
I'd merge it Monday if nobody is against it.
lu
_______________________________________________
libav-devel mailing list
https://lists.libav.org/mailman/listinfo/libav-devel
Modified according to Zhong's comments, see [V2].
Linjie Fu
2018-11-05 02:28:59 UTC
Permalink
Add VDENC(lowpower mode) support for QSV h264 and HEVC

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 kerner version >= 4.16)
- HEVC VDENC was supported >= ICE LAKE

use option "-low_power 1" to enable VDENC.

[V2]: modified the commit message and option comments, use AV_OPT_TYPE_BOOL
to replace AV_OPT_TYPE_INT.

Signed-off-by: Linjie Fu <***@intel.com>
---
libavcodec/qsvenc.c | 3 +++
libavcodec/qsvenc.h | 2 ++
libavcodec/qsvenc_h264.c | 3 +++
libavcodec/qsvenc_hevc.c | 3 +++
4 files changed, 11 insertions(+)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 17a0559f3..16d6e79e2 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -472,6 +472,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 2d83c7b1a..b74b977e8 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)
#define QSV_HAVE_AVBR QSV_VERSION_ATLEAST(1, 3)
@@ -159,6 +160,7 @@ typedef struct QSVEncContext {
int int_ref_cycle_size;
int int_ref_qp_delta;
int recovery_point_sei;
+ int low_power;

#if QSV_HAVE_MF
int mfmode;
diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
index 164f57332..24cdf7082 100644
--- a/libavcodec/qsvenc_h264.c
+++ b/libavcodec/qsvenc_h264.c
@@ -101,6 +101,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, HW platform, BRC modes, etc.", OFFSET(qsv.low_power), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE},
+#endif

{ NULL },
};
diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
index 471d17487..cd9966d01 100644
--- a/libavcodec/qsvenc_hevc.c
+++ b/libavcodec/qsvenc_hevc.c
@@ -238,6 +238,9 @@ static const AVOption options[] = {
{ "main", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_HEVC_MAIN }, INT_MIN, INT_MAX, VE, "profile" },
{ "main10", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_HEVC_MAIN10 }, INT_MIN, INT_MAX, VE, "profile" },
{ "mainsp", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_HEVC_MAINSP }, INT_MIN, INT_MAX, VE, "profile" },
+#if QSV_HAVE_VDENC
+ { "low_power", "enable low power mode (experimental, many limitations by mfx version, HW platform, BRC modes, etc.", OFFSET(qsv.low_power), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
+#endif

{ NULL },
};
--
2.17.1
Continue reading on narkive:
Loading...