History

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().

Dale Curtis committed 2 years ago

Commit a31106d1 parent c7797661 file · +6 −3Browse files

Unified · Split

libavformat/demux.c+6−3
@@ -3102,9 +3102,12 @@ find_stream_info_err: · 3101 unmodified lines
31023102 av_freep(&sti->info);
31033103 }
31043104
3105− err = codec_close(sti);
3106− if (err < 0 && ret >= 0)
3107− ret = err;
3105+ if (avcodec_is_open(sti->avctx)) {
3106+ err = codec_close(sti);
3107+ if (err < 0 && ret >= 0)
3108+ ret = err;
3109+ }
3110+
31083111 av_bsf_free(&sti->extract_extradata.bsf);
31093112 }
31103113 if (ic->pb) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t