From patchwork Sun Jan 26 06:40:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 17552 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 6F59944BD78 for ; Sun, 26 Jan 2020 09:12:33 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4B55368ADD5; Sun, 26 Jan 2020 09:12:33 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 729E2688035 for ; Sun, 26 Jan 2020 09:12:27 +0200 (EET) Received: by mail-lf1-f41.google.com with SMTP id v201so4024151lfa.11 for ; Sat, 25 Jan 2020 23:12:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XiB7fY4J5BDJ9AcqyaRpzw+Cb4FabEl38qDs/tFLUpI=; b=FUYNkhd1rCUf77+OmM8II488g821TsHw/RhD9doP0cWqWNK0b4+PCWqoglWj0Kbhey Muj5udYFuU16LB/va5fSN6JmiBsOnk0UKovU3EtIQIbnh6lCcvepd2jADijM80qXZZfG ++bhC62ttwfPTQ134IQLTw+X1Sq5qj4rl8lK+u4u3ZGF/eMisQRk16JMutVxJqKQtdN+ id2Gjnw0UbiEqal/m0q4efUVQbgVPQk4u2SP9XAxugs7Raf6ZKSTjliiwCz92YB2opjp DWwC5K9k5nR0igcbqwTeWVDU4J8IDGC4iEDoAzh9zsEn3UT/ext96NNE4hVMvYiGv9pv BFRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XiB7fY4J5BDJ9AcqyaRpzw+Cb4FabEl38qDs/tFLUpI=; b=pZVmmUNgA2Xan8HtE7gEYvxb4gPEaNYRo5k1DLSIogjRDcbm2v5R6HPM7nQwKRJyEV OOyVSt7qNizTYOGDqSYWKw4oQlkZnK9RC/gkgtz92k/9i4Oel3fXwmY1HOMLIlBCn8tx 71GDebO1n6OKwnvP3HC+ccFhOh88iaLG6OM82IymIjz+50CHFTKXKHMAZFGcoAFupLBI 4jhTfWa5qYbg2jN+ic0ryh/4zZQNqMKxR5FiQqVuYIRVbJioG9w1ZvXpdYNktOq0ZL+n NrseB2r4178UvxDsy7fBdCXHJX3/9q1CPrkauzZmpAp6VQlxxo+wkvnArg/EyRWuiSAI WJvw== X-Gm-Message-State: APjAAAUF8J/gWU2LvrobAPm4PmyevHgnh3PcD0LBCoomjH3fDO76QZj6 u/pcTVG2CfdIsbIgJMLOtZDHTiDF X-Google-Smtp-Source: APXvYqzBKfCI6Q8Bedo69ItxbbiayKtl/w4V5SBDzJlp536DwhzXTPJUkls1caFLy4ffzfahG9hi1w== X-Received: by 2002:adf:e547:: with SMTP id z7mr13355340wrm.258.1580020861402; Sat, 25 Jan 2020 22:41:01 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc08bbf.dynamic.kabel-deutschland.de. [188.192.139.191]) by smtp.gmail.com with ESMTPSA id r15sm13412648wmh.21.2020.01.25.22.41.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Jan 2020 22:41:00 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 26 Jan 2020 07:40:50 +0100 Message-Id: <20200126064051.22715-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] avformat/dvenc: Replace write_trailer by deinit function 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The old write_trailer only freed memory, so it is better to make a dedicated deinit function out of it. Given that this function will also be called when writing the header fails, one can also remove code that frees already allocated fifos when allocating another one fails. Signed-off-by: Andreas Rheinhardt --- There is something strange going on in this muxer: eafa8e85929 increased several limits for the number of audio streams to four, yet the initial check in dv_init_mux still makes sure that at most two audio streams exist. Has updating this (and probably also the comment for n_ast which still says that there are up to two stereo tracks allowed) simply been forgotten? libavformat/dvenc.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c index a7d1413eb2..b89ad4d1c8 100644 --- a/libavformat/dvenc.c +++ b/libavformat/dvenc.c @@ -364,10 +364,6 @@ static DVMuxContext* dv_init_mux(AVFormatContext* s) for (i=0; i < c->n_ast; i++) { if (c->ast[i] && !(c->audio_data[i]=av_fifo_alloc_array(100, MAX_AUDIO_FRAME_SIZE))) { - while (i > 0) { - i--; - av_fifo_freep(&c->audio_data[i]); - } goto bail_out; } } @@ -378,13 +374,6 @@ bail_out: return NULL; } -static void dv_delete_mux(DVMuxContext *c) -{ - int i; - for (i=0; i < c->n_ast; i++) - av_fifo_freep(&c->audio_data[i]); -} - static int dv_write_header(AVFormatContext *s) { AVRational rate; @@ -432,10 +421,12 @@ static int dv_write_packet(struct AVFormatContext *s, AVPacket *pkt) * Currently we simply drop the last frame. I don't know whether this * is the best strategy of all */ -static int dv_write_trailer(struct AVFormatContext *s) +static void dv_deinit(AVFormatContext *s) { - dv_delete_mux(s->priv_data); - return 0; + DVMuxContext *c = s->priv_data; + + for (int i = 0; i < c->n_ast; i++) + av_fifo_freep(&c->audio_data[i]); } AVOutputFormat ff_dv_muxer = { @@ -447,5 +438,5 @@ AVOutputFormat ff_dv_muxer = { .video_codec = AV_CODEC_ID_DVVIDEO, .write_header = dv_write_header, .write_packet = dv_write_packet, - .write_trailer = dv_write_trailer, + .deinit = dv_deinit, }; From patchwork Sun Jan 26 07:13:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 17553 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 A570244BD7C for ; Sun, 26 Jan 2020 09:13:32 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7E1DD68AF8E; Sun, 26 Jan 2020 09:13:32 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C734B68AC4C for ; Sun, 26 Jan 2020 09:13:26 +0200 (EET) Received: by mail-wm1-f66.google.com with SMTP id u2so3678644wmc.3 for ; Sat, 25 Jan 2020 23:13:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WLCASxpJk4GOqxjPV0kMLWJ3CdMBzIZ9pE1JeHDjUgI=; b=TvPkc+/rxFMDHM5mDG6QW/XrRR4k5U6+zXIFPFi5BlLA+7US89eedQEtmKMFAarkmL X9G/8ybBy77pwyPs4x8oM2b5nZpuxFlydUTqOZGawdnAGxJfl7dU/dkzmalIDl1Umi3T zA/LNxLODHmEoCkSTasOEM87/lRZFppSImNuL6nHqW2hX9dg1fmhteeaFcKGy5eAAnY6 eXvSra8MtpE8061WAugWJrwQjfF9F/tRC/um/3t+c9nAK3OUMm8yyuKVqwkmBv741YTF zK4B1BheGSGag5OKQ6WtxrGoMhuMXdwyrGzFhJFK3qgcLj51bJopi14d1VTyPcBe6mi0 TlSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WLCASxpJk4GOqxjPV0kMLWJ3CdMBzIZ9pE1JeHDjUgI=; b=W8PETijvgxi6qZiAPrVuGBPjEeS/hOlD3LDXmLgjPsOIP4wxC32URdvdPC3Wr3xyr8 gwbK9vNEVonbEd5/mG6W9NfFQ/9GFj8PK1W257dTsjqDj5/TaJ/vEwsuUzgIpOhEIQyi 7VGKuUE1va9+NXnoC/VpVFY1HbddNCr4rxf3tKkAMfGOE1WrxTYY5urHYTHv5V9PWqxl sC9V7TiqcDw6SDhxnryakc2OahdfGD3p1nCNjVLJv5qL2ELV0XZFeau3esmQTQMQ3XUA 4SAzkTa7weE+pqy+cm/qO4/LH994t6ksR2AExM03m7BaHEJ+P3XzmRvu41MHlcvkbGm5 VzWQ== X-Gm-Message-State: APjAAAWm/BFPHjBPo3gckaRLCSrdgAmco0TkxwJMB+/hR66HgyaVBkUN pu5WoAIrVVYnJET4IEhyxf3JKafF X-Google-Smtp-Source: APXvYqxOucExbX2xv7tzKpG2Pf+pWiaxL7r9ZBN2WAmlfG/clvfoa17w1XqutpW0ZNeqA2N36FNN8g== X-Received: by 2002:a7b:c459:: with SMTP id l25mr6916823wmi.17.1580022806113; Sat, 25 Jan 2020 23:13:26 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc08bbf.dynamic.kabel-deutschland.de. [188.192.139.191]) by smtp.gmail.com with ESMTPSA id p15sm13240577wma.40.2020.01.25.23.13.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Jan 2020 23:13:25 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 26 Jan 2020 08:13:11 +0100 Message-Id: <20200126071311.2394-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200126064051.22715-1-andreas.rheinhardt@gmail.com> References: <20200126064051.22715-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] avformat/dvenc: Don't zero unnecessarily 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The muxing context has already been zeroed when it was allocated, hence it is unnecessary to do it again. Signed-off-by: Andreas Rheinhardt --- libavformat/dvenc.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c index b89ad4d1c8..c71e532771 100644 --- a/libavformat/dvenc.c +++ b/libavformat/dvenc.c @@ -305,9 +305,6 @@ static DVMuxContext* dv_init_mux(AVFormatContext* s) if (s->nb_streams > 5) return NULL; - c->n_ast = 0; - c->ast[0] = c->ast[1] = c->ast[2] = c->ast[3] = NULL; - /* We have to sort out where audio and where video stream is */ for (i=0; inb_streams; i++) { switch (s->streams[i]->codecpar->codec_type) {