[FFmpeg-cvslog] lavf/demux: don't reallocate a AVCodecContext when closing a non-open codec.
Dale Curtis
git at videolan.org
Sat Aug 17 13:56:34 EEST 2024
ffmpeg | branch: master | Dale Curtis <dalecurtis at chromium.org> | Fri Aug 2 16:44:21 2024 +0000| [a31106d84976bd28e56de35ee8085eebfc6c5e4d] | committer: Anton Khirnov
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 at chromium.org>
Signed-off-by: Anton Khirnov <anton at khirnov.net>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a31106d84976bd28e56de35ee8085eebfc6c5e4d
---
libavformat/demux.c | 9 ++++++---
1 file 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) {
More information about the ffmpeg-cvslog
mailing list