Remove unnecessary use of avcodec_close().

Replace it with avcodec_free_context() or drop it completely as
appropriate.
This commit is contained in:
Anton Khirnov 2020-05-27 09:30:46 +02:00
parent 9dfb19baeb
commit 0d6b4351c6
9 changed files with 6 additions and 29 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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;