From: "Xiang, Haihao" <haihao.xiang-at-intel.com@ffmpeg.org>
To: "ffmpeg-devel@ffmpeg.org" <ffmpeg-devel@ffmpeg.org>
Cc: "Rogozhkin, Dmitry V" <dmitry.v.rogozhkin@intel.com>
Subject: Re: [FFmpeg-devel] [PATCH] libavcodec/qsvenc: expose only supported options
Date: Tue, 24 May 2022 08:51:21 +0000
Message-ID: <42d1e091d7bf88745bd3e84cd694a1d53035cdd8.camel@intel.com> (raw)
In-Reply-To: <1652990056-46383-1-git-send-email-dmitry.v.rogozhkin@intel.com>
On Thu, 2022-05-19 at 12:54 -0700, Dmitry Rogozhkin wrote:
> vp9, hevc, avc, mpeg2 QSV encoders inherit common list
> of options (QSV_COMMON_OPTS) while bunch of options is not
> actually supported by current qsv code. The only codec which
> supportes everything is avc, followed by hevc, while vp9 and
> mpeg2 significantly fall behind. This creates difficulties
> for the users to use qsv encoders. This patch fixes options
> list for encoders leaving only those which are actually
> supported.
>
> Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
> ---
> libavcodec/qsvenc.h | 52 ++++++++++++++++++++++++++++++++++----------
> ---
> libavcodec/qsvenc_h264.c | 12 +++++++++++
> libavcodec/qsvenc_hevc.c | 9 ++++++++
> libavcodec/qsvenc_mpeg2.c | 1 +
> 4 files changed, 60 insertions(+), 14 deletions(-)
>
> diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
> index cb84723..33bbc2a 100644
> --- a/libavcodec/qsvenc.h
> +++ b/libavcodec/qsvenc.h
> @@ -89,22 +89,46 @@
> { "slow", NULL, 0, AV_OPT_TYPE_CONST, { .i64 =
> MFX_TARGETUSAGE_3 }, INT_MIN, INT_MAX, VE, "preset"
> }, \
> { "slower", NULL, 0, AV_OPT_TYPE_CONST, { .i64 =
> MFX_TARGETUSAGE_2 }, INT_MIN, INT_MAX, VE, "preset"
> }, \
> { "veryslow", NULL, 0, AV_OPT_TYPE_CONST, { .i64 =
> MFX_TARGETUSAGE_BEST_QUALITY }, INT_MIN, INT_MAX, VE, "preset"
> }, \
> -{ "rdo", "Enable rate distortion
> optimization", OFFSET(qsv.rdo), AV_OPT_TYPE_INT, { .i64 = -1 },
> -1, 1, VE }, \
> +{ "forced_idr", "Forcing I frames as IDR
> frames", OFFSET(qsv.forced_idr), AV_OPT_TYPE_BOOL,{ .i64 =
> 0 }, 0, 1, VE }, \
> +{ "low_power", "enable low power mode(experimental: many limitations by mfx
> version, BRC modes, etc.)", OFFSET(qsv.low_power), AV_OPT_TYPE_BOOL, { .i64 =
> -1}, -1, 1, VE},
> +
> +#define QSV_OPTION_RDO \
> +{ "rdo", "Enable rate distortion
> optimization", OFFSET(qsv.rdo), AV_OPT_TYPE_INT, { .i64 = -1 },
> -1, 1, VE },
> +
> +#define QSV_OPTION_MAX_FRAME_SIZE \
> { "max_frame_size", "Maximum encoded frame size in
> bytes", OFFSET(qsv.max_frame_size), AV_OPT_TYPE_INT, { .i64 = -1 },
> -1, INT_MAX, VE }, \
> { "max_frame_size_i", "Maximum encoded I frame size in
> bytes",OFFSET(qsv.max_frame_size_i), AV_OPT_TYPE_INT, { .i64 = -1 },
> -1, INT_MAX, VE }, \
> -{ "max_frame_size_p", "Maximum encoded P frame size in
> bytes",OFFSET(qsv.max_frame_size_p), AV_OPT_TYPE_INT, { .i64 = -1 },
> -1, INT_MAX, VE }, \
> -{ "max_slice_size", "Maximum encoded slice size in
> bytes", OFFSET(qsv.max_slice_size), AV_OPT_TYPE_INT, { .i64 = -1 },
> -1, INT_MAX, VE }, \
> -{ "bitrate_limit", "Toggle bitrate
> limitations", OFFSET(qsv.bitrate_limit), AV_OPT_TYPE_INT, { .i64
> = -1 }, -1, 1, VE }, \
> -{ "mbbrc", "MB level bitrate
> control", OFFSET(qsv.mbbrc), AV_OPT_TYPE_INT, { .i64 =
> -1 }, -1, 1, VE }, \
> -{ "extbrc", "Extended bitrate
> control", OFFSET(qsv.extbrc), AV_OPT_TYPE_INT, { .i64 =
> -1 }, -1, 1, VE }, \
> -{ "adaptive_i", "Adaptive I-frame
> placement", OFFSET(qsv.adaptive_i), AV_OPT_TYPE_INT, { .i64 =
> -1 }, -1, 1, VE }, \
> -{ "adaptive_b", "Adaptive B-frame
> placement", OFFSET(qsv.adaptive_b), AV_OPT_TYPE_INT, { .i64 =
> -1 }, -1, 1, VE }, \
> -{ "p_strategy", "Enable P-pyramid: 0-default 1-simple 2-pyramid(bf need
> to be set to 0).", OFFSET(qsv.p_strategy), AV_OPT_TYPE_INT, { .i64 = 0},
> 0, 2, VE }, \
> -{ "b_strategy", "Strategy to choose between I/P/B-frames",
> OFFSET(qsv.b_strategy), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE
> }, \
> -{ "forced_idr", "Forcing I frames as IDR
> frames", OFFSET(qsv.forced_idr), AV_OPT_TYPE_BOOL,{ .i64 =
> 0 }, 0, 1, VE }, \
> -{ "low_power", "enable low power mode(experimental: many limitations by mfx
> version, BRC modes, etc.)", OFFSET(qsv.low_power), AV_OPT_TYPE_BOOL, { .i64 =
> -1}, -1, 1, VE},\
> -{ "dblk_idc", "This option disable deblocking. It has value in range
> 0~2.", OFFSET(qsv.dblk_idc), AV_OPT_TYPE_INT, { .i64 = 0
> }, 0, 2, VE}, \
> -{ "low_delay_brc", "Allow to strictly obey avg frame size",
> OFFSET(qsv.low_delay_brc), AV_OPT_TYPE_BOOL,{ .i64 = -1 }, -1, 1, VE
> }, \
> +{ "max_frame_size_p", "Maximum encoded P frame size in
> bytes",OFFSET(qsv.max_frame_size_p), AV_OPT_TYPE_INT, { .i64 = -1 },
> -1, INT_MAX, VE },
> +
> +#define QSV_OPTION_MAX_SLICE_SIZE \
> +{ "max_slice_size", "Maximum encoded slice size in
> bytes", OFFSET(qsv.max_slice_size), AV_OPT_TYPE_INT, { .i64 = -1 },
> -1, INT_MAX, VE },
> +
> +#define QSV_OPTION_BITRATE_LIMIT \
> +{ "bitrate_limit", "Toggle bitrate
> limitations", OFFSET(qsv.bitrate_limit), AV_OPT_TYPE_INT, { .i64
> = -1 }, -1, 1, VE },
> +
> +#define QSV_OPTION_MBBRC \
> +{ "mbbrc", "MB level bitrate
> control", OFFSET(qsv.mbbrc), AV_OPT_TYPE_INT, { .i64 =
> -1 }, -1, 1, VE },
> +
> +#define QSV_OPTION_EXTBRC \
> +{ "extbrc", "Extended bitrate
> control", OFFSET(qsv.extbrc), AV_OPT_TYPE_INT, { .i64 =
> -1 }, -1, 1, VE },
> +
> +#define QSV_OPTION_ADAPTIVE_I \
> +{ "adaptive_i", "Adaptive I-frame
> placement", OFFSET(qsv.adaptive_i), AV_OPT_TYPE_INT, { .i64 =
> -1 }, -1, 1, VE },
> +
> +#define QSV_OPTION_ADAPTIVE_B \
> +{ "adaptive_b", "Adaptive B-frame
> placement", OFFSET(qsv.adaptive_b), AV_OPT_TYPE_INT, { .i64 =
> -1 }, -1, 1, VE },
> +
> +#define QSV_OPTION_P_STRATEGY \
> +{ "p_strategy", "Enable P-pyramid: 0-default 1-simple 2-pyramid(bf need
> to be set to 0).", OFFSET(qsv.p_strategy), AV_OPT_TYPE_INT, { .i64 = 0},
> 0, 2, VE },
> +
> +#define QSV_OPTION_B_STRATEGY \
> +{ "b_strategy", "Strategy to choose between I/P/B-frames",
> OFFSET(qsv.b_strategy), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE
> },
> +
> +#define QSV_OPTION_DBLK_IDC \
> +{ "dblk_idc", "This option disable deblocking. It has value in range
> 0~2.", OFFSET(qsv.dblk_idc), AV_OPT_TYPE_INT, { .i64 = 0
> }, 0, 2, VE},
> +
> +#define QSV_OPTION_LOW_DELAY_BRC \
> +{ "low_delay_brc", "Allow to strictly obey avg frame size",
> OFFSET(qsv.low_delay_brc), AV_OPT_TYPE_BOOL,{ .i64 = -1 }, -1, 1, VE
> },
>
> extern const AVCodecHWConfigInternal *const ff_qsv_enc_hw_configs[];
>
> diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
> index b4cf9ea..a21961c 100644
> --- a/libavcodec/qsvenc_h264.c
> +++ b/libavcodec/qsvenc_h264.c
> @@ -102,6 +102,18 @@ static av_cold int qsv_enc_close(AVCodecContext *avctx)
> #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
> static const AVOption options[] = {
> QSV_COMMON_OPTS
> + QSV_OPTION_RDO
> + QSV_OPTION_MAX_FRAME_SIZE
> + QSV_OPTION_MAX_SLICE_SIZE
> + QSV_OPTION_BITRATE_LIMIT
> + QSV_OPTION_MBBRC
> + QSV_OPTION_EXTBRC
> + QSV_OPTION_ADAPTIVE_I
> + QSV_OPTION_ADAPTIVE_B
> + QSV_OPTION_P_STRATEGY
> + QSV_OPTION_B_STRATEGY
> + QSV_OPTION_DBLK_IDC
> + QSV_OPTION_LOW_DELAY_BRC
>
> { "cavlc", "Enable
> CAVLC", OFFSET(qsv.cavlc), AV_OPT_TYPE_BOOL
> , { .i64 = 0 }, 0, 1, VE },
> #if QSV_HAVE_VCM
> diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
> index 3a2d50e..bb4de8e 100644
> --- a/libavcodec/qsvenc_hevc.c
> +++ b/libavcodec/qsvenc_hevc.c
> @@ -224,6 +224,15 @@ static av_cold int qsv_enc_close(AVCodecContext *avctx)
> #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
> static const AVOption options[] = {
> QSV_COMMON_OPTS
> + QSV_OPTION_RDO
> + QSV_OPTION_MAX_FRAME_SIZE
> + QSV_OPTION_MAX_SLICE_SIZE
> + QSV_OPTION_MBBRC
> + QSV_OPTION_EXTBRC
> + QSV_OPTION_P_STRATEGY
> + QSV_OPTION_B_STRATEGY
> + QSV_OPTION_DBLK_IDC
> + QSV_OPTION_LOW_DELAY_BRC
>
> { "idr_interval", "Distance (in I-frames) between IDR frames",
> OFFSET(qsv.idr_interval), AV_OPT_TYPE_INT, { .i64 = 0 }, -1, INT_MAX, VE,
> "idr_interval" },
> { "begin_only", "Output an IDR-frame only at the beginning of the
> stream", 0, AV_OPT_TYPE_CONST, { .i64 = -1 }, 0, 0, VE, "idr_interval" },
> diff --git a/libavcodec/qsvenc_mpeg2.c b/libavcodec/qsvenc_mpeg2.c
> index 3f79b48..5cb12a2 100644
> --- a/libavcodec/qsvenc_mpeg2.c
> +++ b/libavcodec/qsvenc_mpeg2.c
> @@ -64,6 +64,7 @@ static av_cold int qsv_enc_close(AVCodecContext *avctx)
> #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
> static const AVOption options[] = {
> QSV_COMMON_OPTS
> + QSV_OPTION_RDO
>
> { "profile", NULL, OFFSET(qsv.profile), AV_OPT_TYPE_INT, { .i64 =
> MFX_PROFILE_UNKNOWN }, 0, INT_MAX, VE, "profile" },
> { "unknown", NULL, 0, AV_OPT_TYPE_CONST, { .i64 =
> MFX_PROFILE_UNKNOWN }, INT_MIN, INT_MAX, VE, "profile" },
LGTM, will apply.
-Haihao
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
prev parent reply other threads:[~2022-05-24 8:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-19 19:54 Dmitry Rogozhkin
2022-05-24 8:51 ` Xiang, Haihao [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=42d1e091d7bf88745bd3e84cd694a1d53035cdd8.camel@intel.com \
--to=haihao.xiang-at-intel.com@ffmpeg.org \
--cc=dmitry.v.rogozhkin@intel.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git