diff options
author | Dale Curtis <dalecurtis@chromium.org> | 2024-08-02 16:44:21 +0000 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2024-08-17 12:54:41 +0200 |
commit | a31106d84976bd28e56de35ee8085eebfc6c5e4d (patch) | |
tree | fea0891906a324beaf852bee7873664eb0a19ac4 | |
parent | c779766b5cb940fdf2170c1ad12eacaf62eaf1d0 (diff) | |
download | ffmpeg-a31106d84976bd28e56de35ee8085eebfc6c5e4d.tar.gz |
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>
-rw-r--r-- | libavformat/demux.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/libavformat/demux.c b/libavformat/demux.c index dc65f9ad91..4fd22c4934 100644 --- a/libavformat/demux.c +++ b/libavformat/demux.c @@ -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) { |