From patchwork Thu May 28 20:15:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 19942 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id DB21944A30B for ; Thu, 28 May 2020 23:16:34 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BC73868ACD3; Thu, 28 May 2020 23:16:34 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.red.khirnov.net (unknown [176.97.15.10]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8CF8468AD79 for ; Thu, 28 May 2020 23:16:25 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail.red.khirnov.net (Postfix) with ESMTP id 103B228A6F1 for ; Thu, 28 May 2020 22:16:25 +0200 (CEST) Received: from mail.red.khirnov.net ([IPv6:::1]) by localhost (mail.red.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 46CDnIndy_qc for ; Thu, 28 May 2020 22:16:21 +0200 (CEST) Received: from quelana.khirnov.net (quelana.khirnov.net [IPv6:2a00:c500:561:200::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "quelana.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail.red.khirnov.net (Postfix) with ESMTPS id 8FA6728A6E0 for ; Thu, 28 May 2020 22:16:21 +0200 (CEST) Received: from localhost (quelana.khirnov.net [IPv6:::1]) by quelana.khirnov.net (Postfix) with ESMTP id 2623D22F32 for ; Thu, 28 May 2020 22:16:17 +0200 (CEST) Received: from quelana.khirnov.net ([IPv6:::1]) by localhost (quelana.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id pOpX8J0_o0Pq for ; Thu, 28 May 2020 22:16:15 +0200 (CEST) Received: from libav.daenerys.khirnov.net (libav.daenerys.khirnov.net [IPv6:2a00:c500:561:201::7]) by quelana.khirnov.net (Postfix) with ESMTP id 7BDE420279 for ; Thu, 28 May 2020 22:16:15 +0200 (CEST) Received: by libav.daenerys.khirnov.net (Postfix, from userid 1000) id 39EFA20E00E7; Thu, 28 May 2020 22:16:11 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 28 May 2020 22:15:43 +0200 Message-Id: <20200528201559.22618-1-anton@khirnov.net> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/17] Remove unnecessary use of avcodec_close(). X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Replace it with avcodec_free_context() or drop it completely as appropriate. --- libavcodec/avrndec.c | 3 +-- libavcodec/smvjpegdec.c | 3 +-- libavcodec/tests/options.c | 1 - libavfilter/vf_subtitles.c | 1 - libavfilter/vf_uspp.c | 6 ++---- tests/api/api-band-test.c | 1 - tests/api/api-flac-test.c | 18 ++---------------- tests/api/api-h264-test.c | 1 - tests/api/api-seek-test.c | 1 - 9 files changed, 6 insertions(+), 29 deletions(-) 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;