Broken after 7753a9d62725d5bd8313e2d249acbe1c8af79ab1. Apply only the whitelist early, and the rest with a single call to av_opt_set_dict2() with AV_OPT_SEARCH_CHILDREN, which should be equivalent to the original behaviour.
Unified · Split
| @@ -145,6 +145,7 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code · 144 unmodified lines | ||
| 145 | 145 | int ret = 0; |
| 146 | 146 | AVCodecInternal *avci; |
| 147 | 147 | const FFCodec *codec2; |
| 148 | + const AVDictionaryEntry *e; | |
| 148 | 149 | |
| 149 | 150 | if (avcodec_is_open(avctx)) |
| 150 | 151 | return 0; |
| @@ -175,8 +176,14 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code · 24 unmodified lines | ||
| 175 | 176 | if (avctx->extradata_size < 0 || avctx->extradata_size >= FF_MAX_EXTRADATA_SIZE) |
| 176 | 177 | return AVERROR(EINVAL); |
| 177 | 178 | |
| 178 | − if ((ret = av_opt_set_dict(avctx, options)) < 0) | |
| 179 | − return ret; | |
| 179 | + // set the whitelist from provided options dict, | |
| 180 | + // so we can check it immediately | |
| 181 | + e = options ? av_dict_get(*options, "codec_whitelist", NULL, 0) : NULL; | |
| 182 | + if (e) { | |
| 183 | + ret = av_opt_set(avctx, e->key, e->value, 0); | |
| 184 | + if (ret < 0) | |
| 185 | + return ret; | |
| 186 | + } | |
| 180 | 187 | |
| 181 | 188 | if (avctx->codec_whitelist && av_match_list(codec->name, avctx->codec_whitelist, ',') <= 0) { |
| 182 | 189 | av_log(avctx, AV_LOG_ERROR, "Codec (%s) not on whitelist \'%s\'\n", codec->name, avctx->codec_whitelist); |
| @@ -211,12 +218,14 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code · 28 unmodified lines | ||
| 211 | 218 | av_opt_set_defaults(avctx->priv_data); |
| 212 | 219 | } |
| 213 | 220 | } |
| 214 | − if (codec->priv_class && (ret = av_opt_set_dict(avctx->priv_data, options)) < 0) | |
| 215 | − goto free_and_end; | |
| 216 | 221 | } else { |
| 217 | 222 | avctx->priv_data = NULL; |
| 218 | 223 | } |
| 219 | 224 | |
| 225 | + ret = av_opt_set_dict2(avctx, options, AV_OPT_SEARCH_CHILDREN); | |
| 226 | + if (ret < 0) | |
| 227 | + goto free_and_end; | |
| 228 | + | |
| 220 | 229 | // only call ff_set_dimensions() for non H.264/VP6F/DXV codecs so as not to overwrite previously setup dimensions |
| 221 | 230 | if (!(avctx->coded_width && avctx->coded_height && avctx->width && avctx->height && |
| 222 | 231 | (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_VP6F || avctx->codec_id == AV_CODEC_ID_DXV))) { |