From patchwork Tue Jan 11 09:58:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 33206 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp3544866iog; Tue, 11 Jan 2022 01:59:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJz92eCuXIz6hCWD8hCXMFC5cPHZko5vhXYCamN06AHveauFLohk/cxBguiuo5GnhWRR6Ojw X-Received: by 2002:a05:6402:1907:: with SMTP id e7mr3557866edz.44.1641895174645; Tue, 11 Jan 2022 01:59:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1641895174; cv=none; d=google.com; s=arc-20160816; b=ITnDZEr/PrHx2GlX9yxNZe8a2mtUEyBYfQrszJk+PBWzgE+Zy/F1wDJCKE7sU5CHtJ kZ/mwT9/7BEQBUUhM+fYaXwopNOqWrlV6KT6G/ysuSclVLnctQ/I+T0TxkcyNBOcf3y2 xNQQYh6sZHQJyIK+Cx6xtGBK2o32xsdrDfhWelgpyS7TcJ9I4ge4BD4r0lgPJT8CuPbc VVwYaM54pOq8+Jw9OD4uTW714Cv4bIWdTjdcnqQXiPdEQ2WskW1EKt67EEAFhzQRMPqC seoJ/2SZWeQGrhVrxadXoWYSzkuElobCGks9tLmmmt3sZP1ftBfN29cPGXoHmMA2G+yE 3rCw== 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=rdZb+jeMPRdhb92sqUDGNKVcAXUeHFlzJ+xy3FFBaBM=; b=D08zXildAhMbs27Wpf5cC1dJd1BsFJI4UKLvwXhTZrAcv7057tl2NXOCUQSh0xHu8d dV+Dz1N3QGGQSp/gmzdwQOYLlDApgqbOyzy0Q2xxvWuRcKnDEbPSJ40Zq85mfsISP+wZ SJfHVxEZLh4twrAff0Jj3V2E866zSThgn3/j3KYBHTqE/ddr+54NS0Zh3TNi9L8qX7v1 7bH1WV7es9FfPRVK0zPOtcH3LkmZvfWQ88mioS+PioO2x3lOQlCm+rKiXBRo3PmHnsCK G2YATH+skK5R8JSxOOqWOUcCcEvquDSFBL0x6o/8p4Qelia6Hvy2aPmvvmpHkNBvC3Jn Tiag== 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 z7si4858582edb.528.2022.01.11.01.59.34; Tue, 11 Jan 2022 01:59:34 -0800 (PST) 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 5FB8868AEB1; Tue, 11 Jan 2022 11:59:12 +0200 (EET) 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 543E5680134 for ; Tue, 11 Jan 2022 11:59:05 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 163C0240179 for ; Tue, 11 Jan 2022 10:59:05 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id QOUrbO3uRqM7 for ; Tue, 11 Jan 2022 10:59:03 +0100 (CET) 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 448D92404FE for ; Tue, 11 Jan 2022 10:59:02 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id DE3F93A0746; Tue, 11 Jan 2022 10:59:01 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 11 Jan 2022 10:58:07 +0100 Message-Id: <20220111095830.31542-5-anton@khirnov.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220111095830.31542-1-anton@khirnov.net> References: <20220111095830.31542-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/28] 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: ZQJJtlRCJe12 --- 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 87e8b0be59..320ab8e0ca 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -567,19 +567,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 91c313d8ef..288e0f2981 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -687,6 +687,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 c65ed3631a..12ee3c2357 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -312,3 +312,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); +}