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. Signed-off-by: Bohan Li <bohanli@google.com>
This commit is contained in:
parent
e0fd35d867
commit
82aab8a4ee
@ -1684,6 +1684,17 @@ Enable interintra compound. Default is true.
|
|||||||
@item enable-smooth-interintra (@emph{boolean}) (Requires libaom >= v2.0.0)
|
@item enable-smooth-interintra (@emph{boolean}) (Requires libaom >= v2.0.0)
|
||||||
Enable smooth interintra mode. Default is true.
|
Enable smooth interintra mode. Default is true.
|
||||||
|
|
||||||
|
@item aom-params
|
||||||
|
Set libaom options using a list of @var{key}=@var{value} pairs separated
|
||||||
|
by ":". For a list of supported options, see @command{aomenc --help} under the
|
||||||
|
section "AV1 Specific Options".
|
||||||
|
|
||||||
|
For example to specify libaom encoding options with @option{-aom-params}:
|
||||||
|
|
||||||
|
@example
|
||||||
|
ffmpeg -i input -c:v libaom-av1 -b:v 500K -aom-params tune=psnr:enable-tpl-model=1 output.mp4
|
||||||
|
@end example
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@section libsvtav1
|
@section libsvtav1
|
||||||
|
@ -124,6 +124,7 @@ typedef struct AOMEncoderContext {
|
|||||||
int enable_diff_wtd_comp;
|
int enable_diff_wtd_comp;
|
||||||
int enable_dist_wtd_comp;
|
int enable_dist_wtd_comp;
|
||||||
int enable_dual_filter;
|
int enable_dual_filter;
|
||||||
|
AVDictionary *aom_params;
|
||||||
} AOMContext;
|
} AOMContext;
|
||||||
|
|
||||||
static const char *const ctlidstr[] = {
|
static const char *const ctlidstr[] = {
|
||||||
@ -874,6 +875,20 @@ static av_cold int aom_init(AVCodecContext *avctx,
|
|||||||
codecctl_int(avctx, AV1E_SET_ENABLE_INTRABC, ctx->enable_intrabc);
|
codecctl_int(avctx, AV1E_SET_ENABLE_INTRABC, ctx->enable_intrabc);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if AOM_ENCODER_ABI_VERSION >= 23
|
||||||
|
{
|
||||||
|
AVDictionaryEntry *en = NULL;
|
||||||
|
|
||||||
|
while ((en = av_dict_get(ctx->aom_params, "", en, AV_DICT_IGNORE_SUFFIX))) {
|
||||||
|
int ret = aom_codec_set_option(&ctx->encoder, en->key, en->value);
|
||||||
|
if (ret != AOM_CODEC_OK) {
|
||||||
|
log_encoder_error(avctx, en->key);
|
||||||
|
return AVERROR_EXTERNAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// provide dummy value to initialize wrapper, values will be updated each _encode()
|
// provide dummy value to initialize wrapper, values will be updated each _encode()
|
||||||
aom_img_wrap(&ctx->rawimg, img_fmt, avctx->width, avctx->height, 1,
|
aom_img_wrap(&ctx->rawimg, img_fmt, avctx->width, avctx->height, 1,
|
||||||
(unsigned char*)1);
|
(unsigned char*)1);
|
||||||
@ -1299,6 +1314,9 @@ static const AVOption options[] = {
|
|||||||
{ "enable-masked-comp", "Enable masked compound", OFFSET(enable_masked_comp), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
|
{ "enable-masked-comp", "Enable masked compound", OFFSET(enable_masked_comp), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
|
||||||
{ "enable-interintra-comp", "Enable interintra compound", OFFSET(enable_interintra_comp), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
|
{ "enable-interintra-comp", "Enable interintra compound", OFFSET(enable_interintra_comp), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
|
||||||
{ "enable-smooth-interintra", "Enable smooth interintra mode", OFFSET(enable_smooth_interintra), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
|
{ "enable-smooth-interintra", "Enable smooth interintra mode", OFFSET(enable_smooth_interintra), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
|
||||||
|
#if AOM_ENCODER_ABI_VERSION >= 23
|
||||||
|
{ "aom-params", "Set libaom options using a :-separated list of key=value pairs", OFFSET(aom_params), AV_OPT_TYPE_DICT, { 0 }, 0, 0, VE },
|
||||||
|
#endif
|
||||||
{ NULL },
|
{ NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user