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
1684@item enable-smooth-interintra (@emph{boolean}) (Requires libaom >= v2.0.0)1684@item enable-smooth-interintra (@emph{boolean}) (Requires libaom >= v2.0.0)
1685Enable smooth interintra mode. Default is true.1685Enable smooth interintra mode. Default is true.
1686 1686
1687@item aom-params
1688Set libaom options using a list of @var{key}=@var{value} pairs separated
1689by ":". For a list of supported options, see @command{aomenc --help} under the
1690section "AV1 Specific Options".
1691
1692For example to specify libaom encoding options with @option{-aom-params}:
1693
1694@example
1695ffmpeg -i input -c:v libaom-av1 -b:v 500K -aom-params tune=psnr:enable-tpl-model=1 output.mp4
1696@end example
1697
1687@end table1698@end table
1688 1699
1689@section libsvtav11700@section libsvtav1
libavcodec/libaomenc.c+18−0
@@ -124,6 +124,7 @@ typedef struct AOMEncoderContext { · 123 unmodified lines
124 int enable_diff_wtd_comp;124 int enable_diff_wtd_comp;
125 int enable_dist_wtd_comp;125 int enable_dist_wtd_comp;
126 int enable_dual_filter;126 int enable_dual_filter;
127 AVDictionary *aom_params;
127} AOMContext;128} AOMContext;
128 129
129static const char *const ctlidstr[] = {130static const char *const ctlidstr[] = {
@@ -874,6 +875,20 @@ static av_cold int aom_init(AVCodecContext *avctx, · 744 unmodified lines
874 codecctl_int(avctx, AV1E_SET_ENABLE_INTRABC, ctx->enable_intrabc);875 codecctl_int(avctx, AV1E_SET_ENABLE_INTRABC, ctx->enable_intrabc);
875#endif876#endif
876 877
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
877 // provide dummy value to initialize wrapper, values will be updated each _encode()892 // provide dummy value to initialize wrapper, values will be updated each _encode()
878 aom_img_wrap(&ctx->rawimg, img_fmt, avctx->width, avctx->height, 1,893 aom_img_wrap(&ctx->rawimg, img_fmt, avctx->width, avctx->height, 1,
879 (unsigned char*)1);894 (unsigned char*)1);
@@ -1299,6 +1314,9 @@ static const AVOption options[] = { · 419 unmodified lines
1299 { "enable-masked-comp", "Enable masked compound", OFFSET(enable_masked_comp), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},1314 { "enable-masked-comp", "Enable masked compound", OFFSET(enable_masked_comp), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1300 { "enable-interintra-comp", "Enable interintra compound", OFFSET(enable_interintra_comp), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},1315 { "enable-interintra-comp", "Enable interintra compound", OFFSET(enable_interintra_comp), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1301 { "enable-smooth-interintra", "Enable smooth interintra mode", OFFSET(enable_smooth_interintra), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},1316 { "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
1302 { NULL },1320 { NULL },
1303};1321};
1304 1322

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