Merge commit '9e4a5eb51b9f3b2bff0ef08e0074b7fe4893075d'
authorJames Almer <jamrial@gmail.com>
Sat, 28 Oct 2017 17:01:25 +0000 (14:01 -0300)
committerJames Almer <jamrial@gmail.com>
Sat, 28 Oct 2017 17:01:25 +0000 (14:01 -0300)
* commit '9e4a5eb51b9f3b2bff0ef08e0074b7fe4893075d':
  avformat: Free the internal codec context at the end

Merged-by: James Almer <jamrial@gmail.com>
libavformat/utils.c

index 6dbc48d..0ab2f61 100644 (file)
@@ -3875,12 +3875,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
         }
     }
 
-    // close codecs which were opened in try_decode_frame()
-    for (i = 0; i < ic->nb_streams; i++) {
-        st = ic->streams[i];
-        avcodec_close(st->internal->avctx);
-    }
-
     ff_rfps_calculate(ic);
 
     for (i = 0; i < ic->nb_streams; i++) {
@@ -4071,6 +4065,7 @@ find_stream_info_err:
         st = ic->streams[i];
         if (st->info)
             av_freep(&st->info->duration_error);
+        avcodec_close(ic->streams[i]->internal->avctx);
         av_freep(&ic->streams[i]->info);
         av_bsf_free(&ic->streams[i]->internal->extract_extradata.bsf);
         av_packet_free(&ic->streams[i]->internal->extract_extradata.pkt);