Browse Source

Remove unnecessary use of avcodec_close().

Replace it with avcodec_free_context() or drop it completely as
appropriate.
Anton Khirnov 4 years ago
parent
commit
0d6b4351c6

+ 1 - 2
libavcodec/avrndec.c

@@ -91,8 +91,7 @@ static av_cold int end(AVCodecContext *avctx)
 {
 {
     AVRnContext *a = avctx->priv_data;
     AVRnContext *a = avctx->priv_data;
 
 
-    avcodec_close(a->mjpeg_avctx);
-    av_freep(&a->mjpeg_avctx);
+    avcodec_free_context(&a->mjpeg_avctx);
 
 
     return 0;
     return 0;
 }
 }

+ 1 - 2
libavcodec/smvjpegdec.c

@@ -84,8 +84,7 @@ static av_cold int smvjpeg_decode_end(AVCodecContext *avctx)
     jpg->picture_ptr = NULL;
     jpg->picture_ptr = NULL;
     av_frame_free(&s->picture[0]);
     av_frame_free(&s->picture[0]);
     av_frame_free(&s->picture[1]);
     av_frame_free(&s->picture[1]);
-    ret = avcodec_close(s->avctx);
-    av_freep(&s->avctx);
+    avcodec_free_context(&s->avctx);
     return ret;
     return ret;
 }
 }
 
 

+ 0 - 1
libavcodec/tests/options.c

@@ -167,7 +167,6 @@ static void test_copy(const AVCodec *c1, const AVCodec *c2)
         avcodec_copy_context(ctx2, ctx1);
         avcodec_copy_context(ctx2, ctx1);
         test_copy_print_codec(ctx1);
         test_copy_print_codec(ctx1);
         test_copy_print_codec(ctx2);
         test_copy_print_codec(ctx2);
-        avcodec_close(ctx1);
     }
     }
     avcodec_free_context(&ctx1);
     avcodec_free_context(&ctx1);
     avcodec_free_context(&ctx2);
     avcodec_free_context(&ctx2);

+ 0 - 1
libavfilter/vf_subtitles.c

@@ -478,7 +478,6 @@ static av_cold int init_subtitles(AVFilterContext *ctx)
 
 
 end:
 end:
     av_dict_free(&codec_opts);
     av_dict_free(&codec_opts);
-    avcodec_close(dec_ctx);
     avcodec_free_context(&dec_ctx);
     avcodec_free_context(&dec_ctx);
     avformat_close_input(&fmt);
     avformat_close_input(&fmt);
     return ret;
     return ret;

+ 2 - 4
libavfilter/vf_uspp.c

@@ -468,10 +468,8 @@ static av_cold void uninit(AVFilterContext *ctx)
         av_freep(&uspp->src[i]);
         av_freep(&uspp->src[i]);
     }
     }
 
 
-    for (i = 0; i < (1 << uspp->log2_count); i++) {
-        avcodec_close(uspp->avctx_enc[i]);
-        av_freep(&uspp->avctx_enc[i]);
-    }
+    for (i = 0; i < (1 << uspp->log2_count); i++)
+        avcodec_free_context(&uspp->avctx_enc[i]);
 
 
     av_freep(&uspp->non_b_qp_table);
     av_freep(&uspp->non_b_qp_table);
     av_freep(&uspp->outbuf);
     av_freep(&uspp->outbuf);

+ 0 - 1
tests/api/api-band-test.c

@@ -198,7 +198,6 @@ static int video_decode(const char *input_filename)
 
 
     av_packet_unref(&pkt);
     av_packet_unref(&pkt);
     av_frame_free(&fr);
     av_frame_free(&fr);
-    avcodec_close(ctx);
     avformat_close_input(&fmt_ctx);
     avformat_close_input(&fmt_ctx);
     avcodec_free_context(&ctx);
     avcodec_free_context(&ctx);
     av_freep(&byte_buffer);
     av_freep(&byte_buffer);

+ 2 - 16
tests/api/api-flac-test.c

@@ -223,20 +223,6 @@ static int run_test(AVCodec *enc, AVCodec *dec, AVCodecContext *enc_ctx,
     return 0;
     return 0;
 }
 }
 
 
-static int close_encoder(AVCodecContext **enc_ctx)
-{
-    avcodec_close(*enc_ctx);
-    av_freep(enc_ctx);
-    return 0;
-}
-
-static int close_decoder(AVCodecContext **dec_ctx)
-{
-    avcodec_close(*dec_ctx);
-    av_freep(dec_ctx);
-    return 0;
-}
-
 int main(void)
 int main(void)
 {
 {
     AVCodec *enc = NULL, *dec = NULL;
     AVCodec *enc = NULL, *dec = NULL;
@@ -265,8 +251,8 @@ int main(void)
                 return 1;
                 return 1;
             if (run_test(enc, dec, enc_ctx, dec_ctx) != 0)
             if (run_test(enc, dec, enc_ctx, dec_ctx) != 0)
                 return 1;
                 return 1;
-            close_encoder(&enc_ctx);
-            close_decoder(&dec_ctx);
+            avcodec_free_context(&enc_ctx);
+            avcodec_free_context(&dec_ctx);
         }
         }
     }
     }
 
 

+ 0 - 1
tests/api/api-h264-test.c

@@ -144,7 +144,6 @@ static int video_decode_example(const char *input_filename)
 
 
     av_packet_unref(&pkt);
     av_packet_unref(&pkt);
     av_frame_free(&fr);
     av_frame_free(&fr);
-    avcodec_close(ctx);
     avformat_close_input(&fmt_ctx);
     avformat_close_input(&fmt_ctx);
     avcodec_free_context(&ctx);
     avcodec_free_context(&ctx);
     av_freep(&byte_buffer);
     av_freep(&byte_buffer);

+ 0 - 1
tests/api/api-seek-test.c

@@ -266,7 +266,6 @@ end:
     av_freep(&crc_array);
     av_freep(&crc_array);
     av_freep(&pts_array);
     av_freep(&pts_array);
     av_frame_free(&fr);
     av_frame_free(&fr);
-    avcodec_close(ctx);
     avformat_close_input(&fmt_ctx);
     avformat_close_input(&fmt_ctx);
     avcodec_free_context(&ctx);
     avcodec_free_context(&ctx);
     return result;
     return result;