From patchwork Mon Apr 4 11:29:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 35174 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c05:b0:7a:e998:b410 with SMTP id bw5csp1913146pzb; Mon, 4 Apr 2022 04:35:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUNF9bLzMeAlYdcZayggnf5qVqhid24E7vW2WnoAgp2fl/9zv+u6oG52KfGXIrOSIZDWak X-Received: by 2002:a05:6402:4396:b0:418:d776:14c1 with SMTP id o22-20020a056402439600b00418d77614c1mr32511576edc.127.1649072143596; Mon, 04 Apr 2022 04:35:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649072143; cv=none; d=google.com; s=arc-20160816; b=Ny0pk7u2PL9FCL9kRQCMT1jloKEXraWhs9ISqeGAYwTLrPccSN/SpClVFZ3KJ3E0lv xhIkIHFU6fAJkai6r7A7nQcY0GbpQupydglLLy5PcRnL4QRR3vsLfG9yh3ot2/gPleu3 ryBMf7uS676E+0tbHZ31GK4gc7b6EcEpYYslYSKNgwqpNxHiKKD4qSgjtJyUQAUOFLJA CGzlNwAOrhZYOwKqeH8NB1VC3F5+voJOUKhkOlW0M+fC+vzoZ+9L8JzRcgBT7MIq3XZM 3cZc1UPLsr+ghxWl6MtWjs/ABL2yeUBN+OuS0X+HHW8Qs8voC5t9vYJCUaa79vJUWStf Hiaw== 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=nGXhdv6rhxF7Aa4RAZbi0hdE9/WbKtpkjD3bCI0Pn9s=; b=XOAYobZMkUzhsa9CBJh83Hn/+OMzDyoNx+csnnY8pGjKJGqarAJpcXf6OfSBOAtYj6 YHR0gL7TFeNPA0tzDgvl6MK2QBcm5zqdvdUZ4kS9YDlV2tbxTzZ5UEqCB8a2Y+c5oc5v 1eJoAWNxEnOtJf5bUlBHAdJD12KDnIB4b/Sypj2h9iSnXu2skLxIoGtnL9RDo0A/abzO kuHnE5MAxkasBXQ764SyX4AlmELcCFbNWoSAyrbbVa31ckFhyyFHWw2O+7stDzkGgUvr jRp+Cx8NwAon8VgaPnsNj9LkC12Loqsj1ie38BFyAeWYe30iPczwbff78B5JRHc1FQO4 ULCw== 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 m10-20020a1709061eca00b006df889bdb15si6403752ejj.310.2022.04.04.04.35.43; Mon, 04 Apr 2022 04:35:43 -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 4A59168B304; Mon, 4 Apr 2022 14:32:42 +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 2DB7E68B254 for ; Mon, 4 Apr 2022 14:32:22 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 142BE240506 for ; Mon, 4 Apr 2022 13:32:18 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 6BtX1xGOhoew for ; Mon, 4 Apr 2022 13:32:17 +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 E9CCB24050B for ; Mon, 4 Apr 2022 13:32:14 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id B6BB23A0837; Mon, 4 Apr 2022 13:32:11 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Apr 2022 13:29:56 +0200 Message-Id: <20220404113037.13070-9-anton@khirnov.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220404113037.13070-1-anton@khirnov.net> References: <20220404113037.13070-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/49] fftools/ffmpeg: move freeing the output file to ffmpeg_mux.c 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: vXmDJE37oSE1 --- fftools/ffmpeg.c | 14 ++------------ fftools/ffmpeg.h | 1 + fftools/ffmpeg_mux.c | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index cc7855a4cc..69d1949103 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -565,19 +565,9 @@ static void ffmpeg_cleanup(int ret) av_freep(&subtitle_out); /* close files */ - for (i = 0; i < nb_output_files; i++) { - OutputFile *of = output_files[i]; - AVFormatContext *s; - if (!of) - continue; - s = of->ctx; - if (s && s->oformat && !(s->oformat->flags & AVFMT_NOFILE)) - avio_closep(&s->pb); - avformat_free_context(s); - av_dict_free(&of->opts); + for (i = 0; i < nb_output_files; i++) + of_close(&output_files[i]); - av_freep(&output_files[i]); - } for (i = 0; i < nb_output_streams; i++) { OutputStream *ost = output_streams[i]; diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 4425b7a874..ff8ebbfab5 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -690,6 +690,7 @@ int hwaccel_decode_init(AVCodecContext *avctx); /* open the muxer when all the streams are initialized */ int of_check_init(OutputFile *of); int of_write_trailer(OutputFile *of); +void of_close(OutputFile **pof); void of_write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int unqueue); diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 5348eef01d..3cdaa494d7 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -311,3 +311,20 @@ int of_write_trailer(OutputFile *of) return 0; } + +void of_close(OutputFile **pof) +{ + OutputFile *of = *pof; + AVFormatContext *s; + + if (!of) + return; + + s = of->ctx; + if (s && s->oformat && !(s->oformat->flags & AVFMT_NOFILE)) + avio_closep(&s->pb); + avformat_free_context(s); + av_dict_free(&of->opts); + + av_freep(pof); +}