History

avcodec/libaomenc: add support for setting arbitrary libaom options

A new key & value API lets us gain access to newly added parameters without adding explicit support for them in our wrapper. Add an option utilizing this functionality in a similar manner to other encoder libraries' wrappers.

Bohan Li committed 5 years ago

Commit 82aab8a1 parent e0fd35d2 files · +29 −0Browse files

Unified · Split

2 files
  1. doc/encoders.texi +11 −0
  2. libavcodec/libaomenc.c +18 −0
doc/encoders.texi+11−0
@@ -1684,6 +1684,17 @@ Enable interintra compound. Default is true. · 1683 unmodified lines
16841684 @item enable-smooth-interintra (@emph{boolean}) (Requires libaom >= v2.0.0)
16851685 Enable smooth interintra mode. Default is true.
16861686
1687+@item aom-params
1688+Set libaom options using a list of @var{key}=@var{value} pairs separated
1689+by ":". For a list of supported options, see @command{aomenc --help} under the
1690+section "AV1 Specific Options".
1691+
1692+For example to specify libaom encoding options with @option{-aom-params}:
1693+
1694+@example
1695+ffmpeg -i input -c:v libaom-av1 -b:v 500K -aom-params tune=psnr:enable-tpl-model=1 output.mp4
1696+@end example
1697+
16871698 @end table
16881699
16891700 @section libsvtav1
libavcodec/libaomenc.c+18−0
@@ -124,6 +124,7 @@ typedef struct AOMEncoderContext { · 123 unmodified lines
124124 int enable_diff_wtd_comp;
125125 int enable_dist_wtd_comp;
126126 int enable_dual_filter;
127+ AVDictionary *aom_params;
127128 } AOMContext;
128129
129130 static const char *const ctlidstr[] = {
@@ -874,6 +875,20 @@ static av_cold int aom_init(AVCodecContext *avctx, · 744 unmodified lines
874875 codecctl_int(avctx, AV1E_SET_ENABLE_INTRABC, ctx->enable_intrabc);
875876 #endif
876877
878+#if AOM_ENCODER_ABI_VERSION >= 23
879+ {
880+ AVDictionaryEntry *en = NULL;
881+
882+ while ((en = av_dict_get(ctx->aom_params, "", en, AV_DICT_IGNORE_SUFFIX))) {
883+ int ret = aom_codec_set_option(&ctx->encoder, en->key, en->value);
884+ if (ret != AOM_CODEC_OK) {
885+ log_encoder_error(avctx, en->key);
886+ return AVERROR_EXTERNAL;
887+ }
888+ }
889+ }
890+#endif
891+
877892 // provide dummy value to initialize wrapper, values will be updated each _encode()
878893 aom_img_wrap(&ctx->rawimg, img_fmt, avctx->width, avctx->height, 1,
879894 (unsigned char*)1);
@@ -1299,6 +1314,9 @@ static const AVOption options[] = { · 419 unmodified lines
12991314 { "enable-masked-comp", "Enable masked compound", OFFSET(enable_masked_comp), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
13001315 { "enable-interintra-comp", "Enable interintra compound", OFFSET(enable_interintra_comp), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
13011316 { "enable-smooth-interintra", "Enable smooth interintra mode", OFFSET(enable_smooth_interintra), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1317+#if AOM_ENCODER_ABI_VERSION >= 23
1318+ { "aom-params", "Set libaom options using a :-separated list of key=value pairs", OFFSET(aom_params), AV_OPT_TYPE_DICT, { 0 }, 0, 0, VE },
1319+#endif
13021320 { NULL },
13031321 };
13041322

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