Message ID | AM7PR03MB66601E5577AC290CEB56BD938FDB9@AM7PR03MB6660.eurprd03.prod.outlook.com |
---|---|
State | New |
Headers | show |
Series | [FFmpeg-devel,1/5] avcodec/avcodec: Set options only once via AV_OPT_SEARCH_CHILDREN | expand |
Context | Check | Description |
---|---|---|
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
andriy/make_ppc | success | Make finished |
andriy/make_fate_ppc | success | Make fate finished |
lgtm
diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index 2dd7dd84e0..d806fab393 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -205,12 +205,10 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code av_opt_set_defaults(avctx->priv_data); } } - if (codec->priv_class && (ret = av_opt_set_dict(avctx->priv_data, options)) < 0) - goto free_and_end; } else { avctx->priv_data = NULL; } - if ((ret = av_opt_set_dict(avctx, options)) < 0) + if ((ret = av_opt_set_dict2(avctx, options, AV_OPT_SEARCH_CHILDREN)) < 0) goto free_and_end; if (avctx->codec_whitelist && av_match_list(codec->name, avctx->codec_whitelist, ',') <= 0) {
For codecs with a private class the options are currently first applied to the private context after which the remaining options are applied to the AVCodecContext. This can be done in one step with av_opt_set_dict2() and the AV_OPT_SEARCH_CHILDREN flag. Doing so preserves the current order of applying options (namely children, i.e. private contexts, first), which is important for those decoders that have a "lowres" option of their own (distinct from the generic option). Doing this also avoids (re)allocations: Up until now, for a codec with private class, generic options are not found in the first av_opt_set_dict() call and are therefore put into a new AVDictionary. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/avcodec.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)