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.rheinha...@outlook.com> --- libavcodec/avcodec.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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) { -- 2.30.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".