History

libavcodec/qsvenc: expose only supported options

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.

Dmitry Rogozhkin committed 4 years ago

Commit f8a07c41 parent cc679054 files · +60 −14Browse files

Unified · Split

4 files
  1. libavcodec/qsvenc.h +38 −14
  2. libavcodec/qsvenc_h264.c +12 −0
  3. libavcodec/qsvenc_hevc.c +9 −0
  4. libavcodec/qsvenc_mpeg2.c +1 −0
libavcodec/qsvenc.h+38−14
@@ -89,22 +89,46 @@ · 88 unmodified lines
8989 { "slow", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_3 }, INT_MIN, INT_MAX, VE, "preset" }, \
9090 { "slower", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_2 }, INT_MIN, INT_MAX, VE, "preset" }, \
9191 { "veryslow", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_BEST_QUALITY }, INT_MIN, INT_MAX, VE, "preset" }, \
92−{ "rdo", "Enable rate distortion optimization", OFFSET(qsv.rdo), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \
92+{ "forced_idr", "Forcing I frames as IDR frames", OFFSET(qsv.forced_idr), AV_OPT_TYPE_BOOL,{ .i64 = 0 }, 0, 1, VE }, \
93+{ "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},
94+
95+#define QSV_OPTION_RDO \
96+{ "rdo", "Enable rate distortion optimization", OFFSET(qsv.rdo), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE },
97+
98+#define QSV_OPTION_MAX_FRAME_SIZE \
9399 { "max_frame_size", "Maximum encoded frame size in bytes", OFFSET(qsv.max_frame_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, VE }, \
94100 { "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 }, \
95−{ "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 }, \
96−{ "max_slice_size", "Maximum encoded slice size in bytes", OFFSET(qsv.max_slice_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, VE }, \
97−{ "bitrate_limit", "Toggle bitrate limitations", OFFSET(qsv.bitrate_limit), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \
98−{ "mbbrc", "MB level bitrate control", OFFSET(qsv.mbbrc), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \
99−{ "extbrc", "Extended bitrate control", OFFSET(qsv.extbrc), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \
100−{ "adaptive_i", "Adaptive I-frame placement", OFFSET(qsv.adaptive_i), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \
101−{ "adaptive_b", "Adaptive B-frame placement", OFFSET(qsv.adaptive_b), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \
102−{ "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 }, \
103−{ "b_strategy", "Strategy to choose between I/P/B-frames", OFFSET(qsv.b_strategy), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \
104−{ "forced_idr", "Forcing I frames as IDR frames", OFFSET(qsv.forced_idr), AV_OPT_TYPE_BOOL,{ .i64 = 0 }, 0, 1, VE }, \
105−{ "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},\
106−{ "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}, \
107−{ "low_delay_brc", "Allow to strictly obey avg frame size", OFFSET(qsv.low_delay_brc), AV_OPT_TYPE_BOOL,{ .i64 = -1 }, -1, 1, VE }, \
101+{ "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 },
102+
103+#define QSV_OPTION_MAX_SLICE_SIZE \
104+{ "max_slice_size", "Maximum encoded slice size in bytes", OFFSET(qsv.max_slice_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, VE },
105+
106+#define QSV_OPTION_BITRATE_LIMIT \
107+{ "bitrate_limit", "Toggle bitrate limitations", OFFSET(qsv.bitrate_limit), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE },
108+
109+#define QSV_OPTION_MBBRC \
110+{ "mbbrc", "MB level bitrate control", OFFSET(qsv.mbbrc), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE },
111+
112+#define QSV_OPTION_EXTBRC \
113+{ "extbrc", "Extended bitrate control", OFFSET(qsv.extbrc), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE },
114+
115+#define QSV_OPTION_ADAPTIVE_I \
116+{ "adaptive_i", "Adaptive I-frame placement", OFFSET(qsv.adaptive_i), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE },
117+
118+#define QSV_OPTION_ADAPTIVE_B \
119+{ "adaptive_b", "Adaptive B-frame placement", OFFSET(qsv.adaptive_b), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE },
120+
121+#define QSV_OPTION_P_STRATEGY \
122+{ "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 },
123+
124+#define QSV_OPTION_B_STRATEGY \
125+{ "b_strategy", "Strategy to choose between I/P/B-frames", OFFSET(qsv.b_strategy), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE },
126+
127+#define QSV_OPTION_DBLK_IDC \
128+{ "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},
129+
130+#define QSV_OPTION_LOW_DELAY_BRC \
131+{ "low_delay_brc", "Allow to strictly obey avg frame size", OFFSET(qsv.low_delay_brc), AV_OPT_TYPE_BOOL,{ .i64 = -1 }, -1, 1, VE },
108132
109133 extern const AVCodecHWConfigInternal *const ff_qsv_enc_hw_configs[];
110134
libavcodec/qsvenc_h264.c+12−0
@@ -102,6 +102,18 @@ static av_cold int qsv_enc_close(AVCodecContext *avctx) · 101 unmodified lines
102102 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
103103 static const AVOption options[] = {
104104 QSV_COMMON_OPTS
105+ QSV_OPTION_RDO
106+ QSV_OPTION_MAX_FRAME_SIZE
107+ QSV_OPTION_MAX_SLICE_SIZE
108+ QSV_OPTION_BITRATE_LIMIT
109+ QSV_OPTION_MBBRC
110+ QSV_OPTION_EXTBRC
111+ QSV_OPTION_ADAPTIVE_I
112+ QSV_OPTION_ADAPTIVE_B
113+ QSV_OPTION_P_STRATEGY
114+ QSV_OPTION_B_STRATEGY
115+ QSV_OPTION_DBLK_IDC
116+ QSV_OPTION_LOW_DELAY_BRC
105117
106118 { "cavlc", "Enable CAVLC", OFFSET(qsv.cavlc), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
107119 #if QSV_HAVE_VCM
libavcodec/qsvenc_hevc.c+9−0
@@ -224,6 +224,15 @@ static av_cold int qsv_enc_close(AVCodecContext *avctx) · 223 unmodified lines
224224 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
225225 static const AVOption options[] = {
226226 QSV_COMMON_OPTS
227+ QSV_OPTION_RDO
228+ QSV_OPTION_MAX_FRAME_SIZE
229+ QSV_OPTION_MAX_SLICE_SIZE
230+ QSV_OPTION_MBBRC
231+ QSV_OPTION_EXTBRC
232+ QSV_OPTION_P_STRATEGY
233+ QSV_OPTION_B_STRATEGY
234+ QSV_OPTION_DBLK_IDC
235+ QSV_OPTION_LOW_DELAY_BRC
227236
228237 { "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" },
229238 { "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" },
libavcodec/qsvenc_mpeg2.c+1−0
@@ -64,6 +64,7 @@ static av_cold int qsv_enc_close(AVCodecContext *avctx) · 63 unmodified lines
6464 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
6565 static const AVOption options[] = {
6666 QSV_COMMON_OPTS
67+ QSV_OPTION_RDO
6768
6869 { "profile", NULL, OFFSET(qsv.profile), AV_OPT_TYPE_INT, { .i64 = MFX_PROFILE_UNKNOWN }, 0, INT_MAX, VE, "profile" },
6970 { "unknown", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_UNKNOWN }, INT_MIN, INT_MAX, VE, "profile" },

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t