From patchwork Fri Oct 14 10:15:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 38732 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4a86:b0:9d:28a3:170e with SMTP id fn6csp244251pzb; Fri, 14 Oct 2022 03:18:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7HfIcNZzMNSh9FCh/FG3p/VOspfeYsFo8QUGLWQ9JGV25/D00c9rx4uxR2MuIKpHqdGyeb X-Received: by 2002:a05:6402:520d:b0:45a:31cb:f5bd with SMTP id s13-20020a056402520d00b0045a31cbf5bdmr3677081edd.119.1665742725279; Fri, 14 Oct 2022 03:18:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665742725; cv=none; d=google.com; s=arc-20160816; b=Jzwok7n5ymzwDmXAO+qoVfL46oww3MBem3yddy5i1Dyaj9J29YPVqRv8RHdYoM9bgh mlXKbj2J7qVFqAQLhxeSaRs6xMU/tYKvayB2MKCmCWQXM3MV0Raa7cCoy1+3EIGfigNq HAQNDJUVF+w7+MGxuTuQb8UAfHKCzu9DjcfcdG9+DeIi+hCDC5hJMpdMAR4RKpyJYlMG GSVbloZ+MfUHMYE9FZT8I3ibjZLu7ksl0g0navh5Ofq1o1Iey76Spn2W2Xu1y1T5MPwM fX0WU0Nf6T1cgUwy4rjfiRG/9pvw4iVJ4Cjwxn7SbzrIwUJYGNFQP5Q6v6KYHBlbULDP LtQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=54A4qXXl1GvywkbTs2JyoPbAMZ8xYGJw2D38yx2bwBA=; b=JQUFRHCt40X4mcgzmXVmhplVbx4WGGkISwcY0/C9o20mJDBlWiOfDHpwcJvubQNjpE ZQZ/F2u2C1Rjv8/BDEiiBB5AtXDrVhXrhRR1dQ1dG7SvV+hsI/BTu8meExzcAfR5MWO8 br940kQMKZ1UkR7o4x+i9sw/pSqmlUULVz5HSkAg52WjiIZGR+qdOqdnaml5qJh+HgOa Q3StfaYHYSKUDg8bJ5tWD2zeIPdX4TVMhWnmdZ1lDHCUEAxVBFkNI99QI4+eKaccFSKh h75M4rPM6+FdxxjwZPrIu1zwoKf+H5H69uTaT/i1PYIxp1bpFIdoPQiNX2Uoczm0TYwF OXiw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id en16-20020a056402529000b00457166171c6si1727259edb.432.2022.10.14.03.18.44; Fri, 14 Oct 2022 03:18:45 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 040D568BDA6; Fri, 14 Oct 2022 13:18:34 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2A61068BD71 for ; Fri, 14 Oct 2022 13:18:26 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id DF2772400F4 for ; Fri, 14 Oct 2022 12:18:25 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id ua1jLTAeijyy for ; Fri, 14 Oct 2022 12:18:25 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (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 "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id E41B62404F8 for ; Fri, 14 Oct 2022 12:18:24 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 1F6CC3A168C for ; Fri, 14 Oct 2022 12:18:24 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 14 Oct 2022 12:15:44 +0200 Message-Id: <20221014101548.3486-5-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221014101548.3486-1-anton@khirnov.net> References: <20221013134904.10104-1-anton@khirnov.net> <20221014101548.3486-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 18/22] fftools/ffmpeg: remove a cleanup block at the end of transcode() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: 1czB7HnhQATY Some of it is already duplicated in ost_free() - those parts can be just dropped(). The rest is moved to ost_free(), as it properly belongs there. --- fftools/ffmpeg.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index b98065d2a0..4e9ea731ff 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -509,6 +509,14 @@ static void ost_free(OutputStream **post) if (!ost) return; + if (ost->logfile) { + if (fclose(ost->logfile)) + av_log(NULL, AV_LOG_ERROR, + "Error closing logfile, loss of information possible: %s\n", + av_err2str(AVERROR(errno))); + ost->logfile = NULL; + } + av_bsf_free(&ost->bsf_ctx); av_frame_free(&ost->filtered_frame); @@ -521,6 +529,9 @@ static void ost_free(OutputStream **post) av_expr_free(ost->forced_keyframes_pexpr); av_freep(&ost->avfilter); av_freep(&ost->logfile_prefix); + av_freep(&ost->forced_kf_pts); + av_freep(&ost->apad); + av_freep(&ost->disposition); #if FFMPEG_OPT_MAP_CHANNEL av_freep(&ost->audio_channels_map); @@ -4033,24 +4044,6 @@ static int transcode(void) fail: free_input_threads(); - for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) { - if (ost) { - if (ost->logfile) { - if (fclose(ost->logfile)) - av_log(NULL, AV_LOG_ERROR, - "Error closing logfile, loss of information possible: %s\n", - av_err2str(AVERROR(errno))); - ost->logfile = NULL; - } - av_freep(&ost->forced_kf_pts); - av_freep(&ost->apad); - av_freep(&ost->disposition); - av_dict_free(&ost->encoder_opts); - av_dict_free(&ost->sws_dict); - av_dict_free(&ost->swr_opts); - } - } - return ret; }