From patchwork Tue Sep 8 21:18:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22181 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 66FE344BD83 for ; Wed, 9 Sep 2020 00:19:31 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 533FD68B6E5; Wed, 9 Sep 2020 00:19:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AE2F668B6CC for ; Wed, 9 Sep 2020 00:19:28 +0300 (EEST) Received: by mail-wm1-f67.google.com with SMTP id a65so344050wme.5 for ; Tue, 08 Sep 2020 14:19:28 -0700 (PDT) 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=UM2rmfgp02RXo//oaFXLnZoFmAoi7guHbQHQQfyMxI4=; b=neC5oeCW6cUMa+ODRhI0JWbUM19fJusUt5vBjkkxb72GSwiZS8ksaD7F7YE3bFE7I/ 4bivkGWR1Jz57T6pYT2nJfFnntJboPqAhJzd213zox+d/OzM4L//SOPN8pT4PiI7aZyI pGSIyIdMIu/Eip/U2K1rYYw3hhQNc9C9zprI40w8PlIWOWWtzSxFikwx8nFCOsgo9iKZ NFPOqcXuVusp75f8TOEJt0/XbPTaGS8Se7aGGu99EhzM3zg+P35RhPuKmACuZ+rWGA9r KcjbKeMs4jngXY3LlaKyAz6eGDmUA87fFS3g/xXZloxrlI9wjRPDauCofkr50Du4anzZ hp5A== 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=UM2rmfgp02RXo//oaFXLnZoFmAoi7guHbQHQQfyMxI4=; b=nYkp6ukvF/Ma1Bl7vXVwOfPii25tlhnmki08RgZTc3RA/AguG1Hq1zbullqhG9ak5w IvBck/XY88Gcsv+CcP7mtgggKjVGzmvdgmFFoZohMqzsNiAay3418rDJ+D1eYyGv6nXK xqXzM635lwKZIyBjHW3yF+QuGPi+uNuTs6EWl5Xn9z4jRyewB0jLE6J+s2e5WU43UC05 OqEIC/1+rOYkcze6r7g+94s5fA+a7PsDeUSnSNeEUrT+dXqAz6hIuvWyHKibdPLLMvkC uiK2nnKaALwZvI+JKnCHjqg8T8m64xe2JK/UzIrh0eLBy1CSYEdmQSJKb7iTRKEFgot+ PURA== X-Gm-Message-State: AOAM533FO4F273J+tSU2qzi0MFJ3kxpSrXDoaweD1YXBvOLVwUnJgqrA ytryqE9tEvgB4YXI8L7BTI/SenMxKCg= X-Google-Smtp-Source: ABdhPJzK2AG8oPbGG9u6tEy06H45DKv6Z8K7uQ2bvqsfOCvq8QA5oj14QFBD1MG2CyJl5kwEO4SEOA== X-Received: by 2002:a1c:5a56:: with SMTP id o83mr326057wmb.77.1599599967729; Tue, 08 Sep 2020 14:19:27 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id a15sm1074304wrn.3.2020.09.08.14.19.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2020 14:19:27 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 8 Sep 2020 23:18:39 +0200 Message-Id: <20200908211856.16290-8-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200908211856.16290-1-andreas.rheinhardt@gmail.com> References: <20200908211856.16290-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/25] avfilter/af_headphone: Only attempt once to init coeffs 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 headphone filter does most of its initialization after its init function, because it can perform certain tasks only after all but its first input streams have reached eof. When this happens, it allocates certain buffers and errors out if an allocation fails. Yet the filter didn't check whether some of these buffers already exist (which may happen if an earlier attempt has been interrupted in the middle (due to an allocation error)) in which case the old buffers leak. This commit makes sure that initializing the buffers is only attempted once; if not successfull at the first attempt, future calls to the filter will error out. Trying to support resuming initialization doesn't seem worthwhile. Notice that some allocations were freed before a new allocation was performed; yet this effort was incomplete. Said code has been removed. Signed-off-by: Andreas Rheinhardt --- While I am sure about the aim of this patch, I am not sure if simply returning EOF is enough or if I have to use one of those FF_FILTER status macros to return that this filter is finished. libavfilter/af_headphone.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/libavfilter/af_headphone.c b/libavfilter/af_headphone.c index c71f43c5c8..4a68d35e66 100644 --- a/libavfilter/af_headphone.c +++ b/libavfilter/af_headphone.c @@ -425,12 +425,8 @@ static int convert_coeffs(AVFilterContext *ctx, AVFilterLink *inlink) goto fail; } - av_fft_end(s->fft[0]); - av_fft_end(s->fft[1]); s->fft[0] = av_fft_init(av_log2(s->n_fft), 0); s->fft[1] = av_fft_init(av_log2(s->n_fft), 0); - av_fft_end(s->ifft[0]); - av_fft_end(s->ifft[1]); s->ifft[0] = av_fft_init(av_log2(s->n_fft), 1); s->ifft[1] = av_fft_init(av_log2(s->n_fft), 1); @@ -657,13 +653,12 @@ static int activate(AVFilterContext *ctx) if (!eof) return 0; s->eof_hrirs = 1; - } - if (!s->have_hrirs && s->eof_hrirs) { ret = convert_coeffs(ctx, inlink); if (ret < 0) return ret; - } + } else if (!s->have_hrirs) + return AVERROR_EOF; if ((ret = ff_inlink_consume_samples(ctx->inputs[0], s->size, s->size, &in)) > 0) { ret = headphone_frame(s, in, outlink);