diff --git a/libavcodec/avrndec.c b/libavcodec/avrndec.c index 104ff2d904..a7bdab280d 100644 --- a/libavcodec/avrndec.c +++ b/libavcodec/avrndec.c @@ -91,8 +91,7 @@ static av_cold int end(AVCodecContext *avctx) { AVRnContext *a = avctx->priv_data; - avcodec_close(a->mjpeg_avctx); - av_freep(&a->mjpeg_avctx); + avcodec_free_context(&a->mjpeg_avctx); return 0; } diff --git a/libavcodec/smvjpegdec.c b/libavcodec/smvjpegdec.c index 7ea82ebfee..209f3ff334 100644 --- a/libavcodec/smvjpegdec.c +++ b/libavcodec/smvjpegdec.c @@ -84,8 +84,7 @@ static av_cold int smvjpeg_decode_end(AVCodecContext *avctx) jpg->picture_ptr = NULL; av_frame_free(&s->picture[0]); av_frame_free(&s->picture[1]); - ret = avcodec_close(s->avctx); - av_freep(&s->avctx); + avcodec_free_context(&s->avctx); return ret; } diff --git a/libavcodec/tests/options.c b/libavcodec/tests/options.c index 2e19a6eac2..010e3c0145 100644 --- a/libavcodec/tests/options.c +++ b/libavcodec/tests/options.c @@ -167,7 +167,6 @@ static void test_copy(const AVCodec *c1, const AVCodec *c2) avcodec_copy_context(ctx2, ctx1); test_copy_print_codec(ctx1); test_copy_print_codec(ctx2); - avcodec_close(ctx1); } avcodec_free_context(&ctx1); avcodec_free_context(&ctx2); diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c index a3b4029af4..1bd42391e0 100644 --- a/libavfilter/vf_subtitles.c +++ b/libavfilter/vf_subtitles.c @@ -478,7 +478,6 @@ static av_cold int init_subtitles(AVFilterContext *ctx) end: av_dict_free(&codec_opts); - avcodec_close(dec_ctx); avcodec_free_context(&dec_ctx); avformat_close_input(&fmt); return ret; diff --git a/libavfilter/vf_uspp.c b/libavfilter/vf_uspp.c index da4029f4b2..f6fb193433 100644 --- a/libavfilter/vf_uspp.c +++ b/libavfilter/vf_uspp.c @@ -468,10 +468,8 @@ static av_cold void uninit(AVFilterContext *ctx) 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->outbuf); diff --git a/tests/api/api-band-test.c b/tests/api/api-band-test.c index a84f6b7e55..257e741694 100644 --- a/tests/api/api-band-test.c +++ b/tests/api/api-band-test.c @@ -198,7 +198,6 @@ static int video_decode(const char *input_filename) av_packet_unref(&pkt); av_frame_free(&fr); - avcodec_close(ctx); avformat_close_input(&fmt_ctx); avcodec_free_context(&ctx); av_freep(&byte_buffer); diff --git a/tests/api/api-flac-test.c b/tests/api/api-flac-test.c index ae6a9316d8..3fea3258f3 100644 --- a/tests/api/api-flac-test.c +++ b/tests/api/api-flac-test.c @@ -223,20 +223,6 @@ static int run_test(AVCodec *enc, AVCodec *dec, AVCodecContext *enc_ctx, 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) { AVCodec *enc = NULL, *dec = NULL; @@ -265,8 +251,8 @@ int main(void) return 1; if (run_test(enc, dec, enc_ctx, dec_ctx) != 0) return 1; - close_encoder(&enc_ctx); - close_decoder(&dec_ctx); + avcodec_free_context(&enc_ctx); + avcodec_free_context(&dec_ctx); } } diff --git a/tests/api/api-h264-test.c b/tests/api/api-h264-test.c index 60a3ae5ef4..678a1ea166 100644 --- a/tests/api/api-h264-test.c +++ b/tests/api/api-h264-test.c @@ -144,7 +144,6 @@ static int video_decode_example(const char *input_filename) av_packet_unref(&pkt); av_frame_free(&fr); - avcodec_close(ctx); avformat_close_input(&fmt_ctx); avcodec_free_context(&ctx); av_freep(&byte_buffer); diff --git a/tests/api/api-seek-test.c b/tests/api/api-seek-test.c index d0531a2f73..ae33581244 100644 --- a/tests/api/api-seek-test.c +++ b/tests/api/api-seek-test.c @@ -266,7 +266,6 @@ end: av_freep(&crc_array); av_freep(&pts_array); av_frame_free(&fr); - avcodec_close(ctx); avformat_close_input(&fmt_ctx); avcodec_free_context(&ctx); return result;