From patchwork Thu Aug 11 12:39:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sebechlebskyjan@gmail.com X-Patchwork-Id: 151 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.67 with SMTP id o64csp44219vsd; Thu, 11 Aug 2016 05:40:09 -0700 (PDT) X-Received: by 10.194.98.139 with SMTP id ei11mr9317120wjb.19.1470919209522; Thu, 11 Aug 2016 05:40:09 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id wg3si2285520wjb.188.2016.08.11.05.40.09; Thu, 11 Aug 2016 05:40:09 -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; dkim=neutral (body hash did not verify) header.i=@gmail.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; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D2C1868A63F; Thu, 11 Aug 2016 15:40:06 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 78DFE68A5B0 for ; Thu, 11 Aug 2016 15:39:59 +0300 (EEST) Received: by mail-wm0-f68.google.com with SMTP id i138so1139261wmf.3 for ; Thu, 11 Aug 2016 05:40:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=h25GO2WofeM03T24T20vgmSPrrlgWoT4gq9+PqN77lo=; b=hOwY/8XeHdJ1ieMQBSSGkXM49/82j7bCyjOa0shIOE7l5oPD/hSa85gBI5ghIurOna V1Ptcw2gJqiW9wSlRIEiCphbjl1XEvujOzhpCdHgK/OXDPurwAoSLxPde18XbeJtEsVl YjqyF4VqLX0X4rvo5MDPWuf3hj5o7iox9BQ3R1VO2JrWXsL1DRPa+IgymZ5WQynGVw+z jHTlBPPRM0Y+6GWZYJhakNNS3clpEsXQ2GFmDKrLDKS4+yYxK7GVqRhaIvMcaGuS+0gu VMfovxcMuJsL/d+G+Bwv76PDl6fbRqN2ui0E1seBSOdOM47WjUi7C7xG9R1cVAGLcHzr 79vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=h25GO2WofeM03T24T20vgmSPrrlgWoT4gq9+PqN77lo=; b=Uns9jzICOE2KIWTUyYAwJDBNHnTiHGnQBg/U0oP8pRiXscJ1Vh4ScWFxN7vbZBbkIq jULPNGabst5nXgUlohtWkhDbyaD8KwypRJLcIpwtSO6U9PRgANO/ZevEVp+sKD0drq4v OUjRS7U9+Vx+PwgtCWc8+YSRLl0rpMcyEf/zhbKjJ6ScBeFjXXp6Salz2Al7vYqjCZug BkGWllABLkSV98n42mOqwXyVKpNVLDeiTS9paNjWmxRbXjuTJ+YKKhJbNQAosdhAdw3W 8XvNQoRPBB6uNZG99hrq90m94Yr+7Czl1EHk48odhHWj9cdF2BOYiGPX0AVjF4g0BoQg wNxQ== X-Gm-Message-State: AEkooutgcfAGkKgZ9EMy9cL+zRR+A8/QkeCrTQdPAoUa871foB1HzN8KslKSPFywyl0HaA== X-Received: by 10.28.27.143 with SMTP id b137mr9761125wmb.12.1470919199582; Thu, 11 Aug 2016 05:39:59 -0700 (PDT) Received: from localhost.localdomain (157.174.broadband3.iol.cz. [85.70.174.157]) by smtp.gmail.com with ESMTPSA id o4sm2553723wjd.15.2016.08.11.05.39.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Aug 2016 05:39:59 -0700 (PDT) From: sebechlebskyjan@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Thu, 11 Aug 2016 14:39:49 +0200 Message-Id: <1470919189-3468-1-git-send-email-sebechlebskyjan@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <20160810170430.GC5460@nb4> References: <20160810170430.GC5460@nb4> Subject: [FFmpeg-devel] [PATCH v2 05/11] avformat/mux: Refactor muxer deinit from av_write_trailer 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 Cc: Jan Sebechlebsky MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Jan Sebechlebsky Move muxer deinitialization and private resources freeing in a separate static function free_muxer(AVFormatContext*). Signed-off-by: Jan Sebechlebsky --- No changes since the last version, just rebased because of changes in previous patch. libavformat/mux.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/libavformat/mux.c b/libavformat/mux.c index 3ae924c..45f1401 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -1197,9 +1197,27 @@ fail: return ret; } +static void deinit_muxer(AVFormatContext *s) +{ + int i; + + if (s->oformat->deinit) + s->oformat->deinit(s); + + for (i = 0; i < s->nb_streams; i++) { + av_freep(&s->streams[i]->priv_data); + av_freep(&s->streams[i]->index_entries); + } + + if (s->oformat->priv_class) + av_opt_free(s->priv_data); + + av_freep(&s->priv_data); +} + int av_write_trailer(AVFormatContext *s) { - int ret, i; + int ret; for (;; ) { AVPacket pkt; @@ -1244,20 +1262,11 @@ fail: if (ret == AVERROR(EAGAIN)) return ret; - if (s->oformat->deinit) - s->oformat->deinit(s); - if (s->pb) avio_flush(s->pb); if (ret == 0) ret = s->pb ? s->pb->error : 0; - for (i = 0; i < s->nb_streams; i++) { - av_freep(&s->streams[i]->priv_data); - av_freep(&s->streams[i]->index_entries); - } - if (s->oformat->priv_class) - av_opt_free(s->priv_data); - av_freep(&s->priv_data); + deinit_muxer(s); return ret; }