You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
avcodec/avcodec: Avoid redundant copies of options in avcodec_open2
It is no longer necessary now that ff_frame_thread_encoder_init() no longer receives an options dictionary. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@@ -135,7 +135,6 @@ static int64_t get_bit_rate(AVCodecContext *ctx)
|
|||||||
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
|
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
AVDictionary *tmp = NULL;
|
|
||||||
AVCodecInternal *avci;
|
AVCodecInternal *avci;
|
||||||
|
|
||||||
if (avcodec_is_open(avctx))
|
if (avcodec_is_open(avctx))
|
||||||
@@ -168,9 +167,6 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
|
|||||||
if (avctx->extradata_size < 0 || avctx->extradata_size >= FF_MAX_EXTRADATA_SIZE)
|
if (avctx->extradata_size < 0 || avctx->extradata_size >= FF_MAX_EXTRADATA_SIZE)
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
|
|
||||||
if (options)
|
|
||||||
av_dict_copy(&tmp, *options, 0);
|
|
||||||
|
|
||||||
lock_avcodec(codec);
|
lock_avcodec(codec);
|
||||||
|
|
||||||
avci = av_mallocz(sizeof(*avci));
|
avci = av_mallocz(sizeof(*avci));
|
||||||
@@ -207,12 +203,12 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
|
|||||||
av_opt_set_defaults(avctx->priv_data);
|
av_opt_set_defaults(avctx->priv_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (codec->priv_class && (ret = av_opt_set_dict(avctx->priv_data, &tmp)) < 0)
|
if (codec->priv_class && (ret = av_opt_set_dict(avctx->priv_data, options)) < 0)
|
||||||
goto free_and_end;
|
goto free_and_end;
|
||||||
} else {
|
} else {
|
||||||
avctx->priv_data = NULL;
|
avctx->priv_data = NULL;
|
||||||
}
|
}
|
||||||
if ((ret = av_opt_set_dict(avctx, &tmp)) < 0)
|
if ((ret = av_opt_set_dict(avctx, options)) < 0)
|
||||||
goto free_and_end;
|
goto free_and_end;
|
||||||
|
|
||||||
if (avctx->codec_whitelist && av_match_list(codec->name, avctx->codec_whitelist, ',') <= 0) {
|
if (avctx->codec_whitelist && av_match_list(codec->name, avctx->codec_whitelist, ',') <= 0) {
|
||||||
@@ -372,15 +368,11 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
|
|||||||
|
|
||||||
end:
|
end:
|
||||||
unlock_avcodec(codec);
|
unlock_avcodec(codec);
|
||||||
if (options) {
|
|
||||||
av_dict_free(options);
|
|
||||||
*options = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
free_and_end:
|
free_and_end:
|
||||||
avcodec_close(avctx);
|
avcodec_close(avctx);
|
||||||
av_dict_free(&tmp);
|
av_dict_free(options);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user