[libav-devel] [PATCH] qsv: Support explicit lookahead downscaling

Li, Zhong zhong.li at intel.com
Tue Dec 12 16:34:59 CET 2017


> From: libav-devel [mailto:libav-devel-bounces at libav.org] On Behalf Of Luca
> Barbato
> Sent: Tuesday, December 12, 2017 10:28 PM
> To: libav-devel at libav.org
> Subject: [libav-devel] [PATCH] qsv: Support explicit lookahead downscaling
> 
> ---
>  libavcodec/qsvenc.c |  4 ++++
>  libavcodec/qsvenc.h | 13 +++++++++++++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index
> 5eacf3ca88..24d9ec4d71 100644
> --- a/libavcodec/qsvenc.c
> +++ b/libavcodec/qsvenc.c
> @@ -604,6 +604,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
>              q->extco2.Trellis = q->trellis;  #endif
> 
> +#if QSV_HAVE_LA_DS
> +            q->extco2.LookAheadDS = q->la_ds; #endif
> +
>  #if QSV_HAVE_BREF_TYPE
>  #if FF_API_PRIVATE_OPT
>  FF_DISABLE_DEPRECATION_WARNINGS
> diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index
> 7f11460d08..7c4c4f8688 100644
> --- a/libavcodec/qsvenc.h
> +++ b/libavcodec/qsvenc.h
> @@ -42,6 +42,7 @@
>  #define QSV_HAVE_BREF_TYPE      QSV_VERSION_ATLEAST(1, 8)
> 
>  #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)
> 
>  #if defined(_WIN32)
> @@ -54,6 +55,12 @@
>  #define QSV_HAVE_QVBR   0
>  #endif
> 
> +#if !QSV_HAVE_LA_DS
> +#define MFX_LOOKAHEAD_DS_OFF 0
> +#define MFX_LOOKAHEAD_DS_2x 0
> +#define MFX_LOOKAHEAD_DS_4x 0
> +#endif
> +
>  #define QSV_COMMON_OPTS \
>  { "async_depth", "Maximum processing parallelism",
> OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 =
> ASYNC_DEPTH_DEFAULT }, 0, INT_MAX, VE },  \
>  { "avbr_accuracy",    "Accuracy of the AVBR ratecontrol",
> OFFSET(qsv.avbr_accuracy),    AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX,
> VE },     \
> @@ -64,6 +71,11 @@
>  { "slow",   NULL, 0, AV_OPT_TYPE_CONST, { .i64 =
> MFX_TARGETUSAGE_BEST_QUALITY  }, INT_MIN, INT_MAX, VE, "preset" },
> \
>  { "la_depth", "Number of frames to analyze before encoding.",
> OFFSET(qsv.la_depth), AV_OPT_TYPE_INT, { .i64 = 9 },   9, 100, VE,
> "la_depth" },  \
>  { "unset", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 9 }, INT_MIN, INT_MAX,
> VE, "la_depth" },  \
> +{ "la_ds", "Downscaling factor for the frames saved for the lookahead
> analisys", OFFSET(qsv.la_ds), AV_OPT_TYPE_INT, { .i64 = -1 },   -1,
> MFX_LOOKAHEAD_DS_4x, VE, "la_ds" }, \
> +{ "auto", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = -1 }, INT_MIN, INT_MAX,
> VE, "la_ds" }, \
> +{ "off", NULL, 0, AV_OPT_TYPE_CONST, { .i64 =
> MFX_LOOKAHEAD_DS_OFF }, INT_MIN, INT_MAX,
> VE, "la_ds" }, \
> +{ "2x", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_LOOKAHEAD_DS_2x },
> INT_MIN, INT_MAX,
> VE, "la_ds" }, \
> +{ "4x", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_LOOKAHEAD_DS_4x },
> INT_MIN, INT_MAX,
> VE, "la_ds" }, \
>  { "vcm",      "Use the video conferencing mode ratecontrol",
> OFFSET(qsv.vcm),      AV_OPT_TYPE_INT, { .i64 = 0  },  0, 1,
> VE },        \
>  { "rdo",            "Enable rate distortion optimization",
> OFFSET(qsv.rdo),            AV_OPT_TYPE_INT, { .i64 = -1 }, -1,
> 1, VE }, \
>  { "max_frame_size", "Maximum encoded frame size in bytes",
> OFFSET(qsv.max_frame_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1,
> UINT16_MAX, VE }, \
> @@ -116,6 +128,7 @@ typedef struct QSVEncContext {
>      int avbr_accuracy;
>      int avbr_convergence;
>      int la_depth;
> +    int la_ds;
>      int vcm;
>      int rdo;
>      int max_frame_size;
> --
> 2.11.1

LGTM, : )


More information about the libav-devel mailing list