[FFmpeg-devel] [PATCH 1/2] qsvdec: factor common options out

Linjie Fu linjie.justin.fu at gmail.com
Thu Dec 10 10:57:45 EET 2020


On Thu, Nov 26, 2020 at 1:30 PM Haihao Xiang <haihao.xiang at intel.com> wrote:
>
> ---
>  libavcodec/qsvdec.h       | 13 +++++++++++++
>  libavcodec/qsvdec_h2645.c | 12 ++----------
>  libavcodec/qsvdec_other.c |  6 +-----
>  3 files changed, 16 insertions(+), 15 deletions(-)
>
> diff --git a/libavcodec/qsvdec.h b/libavcodec/qsvdec.h
> index f3b7344cba..10e8cf7f91 100644
> --- a/libavcodec/qsvdec.h
> +++ b/libavcodec/qsvdec.h
> @@ -36,6 +36,19 @@
>  #include "hwconfig.h"
>  #include "qsv_internal.h"
>
> +#define QSVDEC_COMMON_OPTIONS \
> +    { "async_depth", \
> +      "Internal parallelization depth, the higher the value the higher the latency.", \
> +      OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, \
> +      { .i64 = ASYNC_DEPTH_DEFAULT }, 1, INT_MAX, VD }, \
> +    { "gpu_copy", \
> +      "A GPU-accelerated copy between video and system memory", \
> +      OFFSET(qsv.gpu_copy), AV_OPT_TYPE_INT, \
> +      { .i64 = MFX_GPUCOPY_DEFAULT }, MFX_GPUCOPY_DEFAULT, MFX_GPUCOPY_OFF, VD, "gpu_copy" }, \
> +        { "default", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_DEFAULT }, 0, 0, VD, "gpu_copy" }, \
> +        { "on",      NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_ON },      0, 0, VD, "gpu_copy" }, \
> +        { "off",     NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_OFF },     0, 0, VD, "gpu_copy" }
> +
>  typedef struct QSVContext {
>      // the session used for decoding
>      mfxSession session;
> diff --git a/libavcodec/qsvdec_h2645.c b/libavcodec/qsvdec_h2645.c
> index 02c41883b6..f767033ecf 100644
> --- a/libavcodec/qsvdec_h2645.c
> +++ b/libavcodec/qsvdec_h2645.c
> @@ -184,7 +184,7 @@ static void qsv_decode_flush(AVCodecContext *avctx)
>
>  #if CONFIG_HEVC_QSV_DECODER
>  static const AVOption hevc_options[] = {
> -    { "async_depth", "Internal parallelization depth, the higher the value the higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 1, INT_MAX, VD },
> +    QSVDEC_COMMON_OPTIONS,
>
>      { "load_plugin", "A user plugin to load in an internal session", OFFSET(load_plugin), AV_OPT_TYPE_INT, { .i64 = LOAD_PLUGIN_HEVC_HW }, LOAD_PLUGIN_NONE, LOAD_PLUGIN_HEVC_HW, VD, "load_plugin" },
>      { "none",     NULL, 0, AV_OPT_TYPE_CONST, { .i64 = LOAD_PLUGIN_NONE },    0, 0, VD, "load_plugin" },
> @@ -194,10 +194,6 @@ static const AVOption hevc_options[] = {
>      { "load_plugins", "A :-separate list of hexadecimal plugin UIDs to load in an internal session",
>          OFFSET(qsv.load_plugins), AV_OPT_TYPE_STRING, { .str = "" }, 0, 0, VD },
>
> -    { "gpu_copy", "A GPU-accelerated copy between video and system memory", OFFSET(qsv.gpu_copy), AV_OPT_TYPE_INT, { .i64 = MFX_GPUCOPY_DEFAULT }, MFX_GPUCOPY_DEFAULT, MFX_GPUCOPY_OFF, VD, "gpu_copy"},
> -        { "default", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_DEFAULT }, 0, 0, VD, "gpu_copy"},
> -        { "on",      NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_ON },      0, 0, VD, "gpu_copy"},
> -        { "off",     NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_OFF },     0, 0, VD, "gpu_copy"},
>      { NULL },
>  };
>
> @@ -232,12 +228,8 @@ AVCodec ff_hevc_qsv_decoder = {
>
>  #if CONFIG_H264_QSV_DECODER
>  static const AVOption options[] = {
> -    { "async_depth", "Internal parallelization depth, the higher the value the higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 1, INT_MAX, VD },
> +    QSVDEC_COMMON_OPTIONS,
>
> -    { "gpu_copy", "A GPU-accelerated copy between video and system memory", OFFSET(qsv.gpu_copy), AV_OPT_TYPE_INT, { .i64 = MFX_GPUCOPY_DEFAULT }, MFX_GPUCOPY_DEFAULT, MFX_GPUCOPY_OFF, VD, "gpu_copy"},
> -        { "default", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_DEFAULT }, 0, 0, VD, "gpu_copy"},
> -        { "on",      NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_ON },      0, 0, VD, "gpu_copy"},
> -        { "off",     NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_OFF },     0, 0, VD, "gpu_copy"},
>      { NULL },
>  };
>
> diff --git a/libavcodec/qsvdec_other.c b/libavcodec/qsvdec_other.c
> index 2775e07955..65cefff2ab 100644
> --- a/libavcodec/qsvdec_other.c
> +++ b/libavcodec/qsvdec_other.c
> @@ -180,12 +180,8 @@ static void qsv_decode_flush(AVCodecContext *avctx)
>  #define OFFSET(x) offsetof(QSVOtherContext, x)
>  #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
>  static const AVOption options[] = {
> -    { "async_depth", "Internal parallelization depth, the higher the value the higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 1, INT_MAX, VD },
> +    QSVDEC_COMMON_OPTIONS,
>
> -    { "gpu_copy", "A GPU-accelerated copy between video and system memory", OFFSET(qsv.gpu_copy), AV_OPT_TYPE_INT, { .i64 = MFX_GPUCOPY_DEFAULT }, MFX_GPUCOPY_DEFAULT, MFX_GPUCOPY_OFF, VD, "gpu_copy"},
> -        { "default", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_DEFAULT }, 0, 0, VD, "gpu_copy"},
> -        { "on",      NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_ON },      0, 0, VD, "gpu_copy"},
> -        { "off",     NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_OFF },     0, 0, VD, "gpu_copy"},
>      { NULL },
>  };
>
looks reasonable to me.


More information about the ffmpeg-devel mailing list