lavf/demux: don't reallocate a AVCodecContext when closing a non-open codec.

This results in an unnecessary ~800k allocation with H.264. A
nearby callsite uses avcodec_is_open() to avoid this, so do the
same when exiting avformat_find_stream_info().

Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
This commit is contained in:
Dale Curtis 2024-08-02 16:44:21 +00:00 committed by Anton Khirnov
parent c779766b5c
commit a31106d849
1 changed files with 6 additions and 3 deletions

View File

@ -3102,9 +3102,12 @@ find_stream_info_err:
av_freep(&sti->info);
}
err = codec_close(sti);
if (err < 0 && ret >= 0)
ret = err;
if (avcodec_is_open(sti->avctx)) {
err = codec_close(sti);
if (err < 0 && ret >= 0)
ret = err;
}
av_bsf_free(&sti->extract_extradata.bsf);
}
if (ic->pb) {