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().
Unified · Split
| @@ -3102,9 +3102,12 @@ find_stream_info_err: · 3101 unmodified lines | ||
| 3102 | 3102 | av_freep(&sti->info); |
| 3103 | 3103 | } |
| 3104 | 3104 | |
| 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 | + | |
| 3108 | 3111 | av_bsf_free(&sti->extract_extradata.bsf); |
| 3109 | 3112 | } |
| 3110 | 3113 | if (ic->pb) { |