From patchwork Tue Sep 8 21:18: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: 22194 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 5F74A44BE02 for ; Wed, 9 Sep 2020 00:20:46 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C366B68B75A; Wed, 9 Sep 2020 00:19:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2E01268B76F for ; Wed, 9 Sep 2020 00:19:40 +0300 (EEST) Received: by mail-wm1-f65.google.com with SMTP id e11so452284wme.0 for ; Tue, 08 Sep 2020 14:19:40 -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=dwPvuJna/+049PVxJcRI4sACnpZXA4YcdwLEvxQQbK0=; b=EBCgf4sJ4+MoWCRz1itYH0E0Vu3z2qd4yMW4VmQhe/j9yHtSntzfd+138s6m5oauCo WAqgVQfTSfJWfACGVSDTVFXKTQsg7dtWUKlwFtrzeyG9YEHylYgauCdyGfSYPN2mzv1b 0OVqvTWNIYcuBz5ppi6QIgs70/ohX0RQ8fHCapmnBKwLR+KZkbQ3o8Rjz+/TlcSAfTko KPE1YO4idI+osvtP9+Rmo3QUZ55gnI8+scRDd7JwwCb8Ce271gKrOtbP8dwb7+7EADLX VQCYuAIsM3B/Nx/cMITR5G+3TSgPIQ907gxrGnuiQxoz6kwZ5VyNnh+mxIT5w9yBhCkC n4dw== 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=dwPvuJna/+049PVxJcRI4sACnpZXA4YcdwLEvxQQbK0=; b=qLLd6A9QptuuBBSzUdGlrhstdSsYm9odufY2xALQZoGLUkta/l3ix6XoHWs89vzOoI 8TSaK3D2M8/RcG4z8FjuyQuMZY3GDJ2jK+ePSSbHQZ4hVzLEOUL645KageakOI6NS+va wshOQe75yP6iFqfERLFnRm8KJoL44zMXzTJhPEoTyPawvnbwWIr1nBGPWM5FdYvr5BE0 o8SljmGTTZWBDnWAWBnzkeSdFtkrgOITvtAdlV1O7ADKKoJ/u1mOODaWt6P7EWvaFyQS QmKRRhxHKiv5HVE/KGlxmYJMAeBO3PdhexABps1SNYsAYzPiCsGX2of44JxKho8w1Dw+ J3jw== X-Gm-Message-State: AOAM530Da/xORhGhW8J+hVaxgAkOU33XI5KaeKIGj6OCcq0DwB4tb2+1 R529+p+cGHqbOFoXV+SEaFAvMRoyWbI= X-Google-Smtp-Source: ABdhPJz12dyOuZpC4G698Dzg4Eafb9zwHSMhn8ikq/myGAXGoYVKnKQH0/ZvtUqPGAQlEOugbcxX3Q== X-Received: by 2002:a1c:7215:: with SMTP id n21mr351200wmc.154.1599599979366; Tue, 08 Sep 2020 14:19:39 -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.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2020 14:19:38 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 8 Sep 2020 23:18:50 +0200 Message-Id: <20200908211856.16290-19-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 19/25] avfilter/af_headphone: Only keep one AVFrame at a time 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" Despite the headphone filter only using one AVFrame at a time, it kept an array each of whose entries contained a pointer to an AVFrame at all times; the pointers were mostly NULL. This commit instead replaces them by using a single pointer to an AVFrame on the stack of the only function that actually uses them. Signed-off-by: Andreas Rheinhardt --- libavfilter/af_headphone.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/libavfilter/af_headphone.c b/libavfilter/af_headphone.c index d57ecb1f50..c84142e1ce 100644 --- a/libavfilter/af_headphone.c +++ b/libavfilter/af_headphone.c @@ -77,7 +77,6 @@ typedef struct HeadphoneContext { AVFloatDSPContext *fdsp; struct headphone_inputs { - AVFrame *frame; int ir_len; int eof; } *in; @@ -367,6 +366,7 @@ static int convert_coeffs(AVFilterContext *ctx, AVFilterLink *inlink) const int ir_len = s->ir_len; int nb_input_channels = ctx->inputs[0]->channels; float gain_lin = expf((s->gain - 3 * nb_input_channels) / 20 * M_LN10); + AVFrame *frame; int ret = 0; int n_fft; int i, j, k; @@ -432,14 +432,14 @@ static int convert_coeffs(AVFilterContext *ctx, AVFilterLink *inlink) } } - for (i = 0; i < s->nb_inputs - 1; i++) { + for (i = 0; i < s->nb_inputs - 1; av_frame_free(&frame), i++) { int len = s->in[i + 1].ir_len; float *ptr; - ret = ff_inlink_consume_samples(ctx->inputs[i + 1], len, len, &s->in[i + 1].frame); + ret = ff_inlink_consume_samples(ctx->inputs[i + 1], len, len, &frame); if (ret < 0) goto fail; - ptr = (float *)s->in[i + 1].frame->extended_data[0]; + ptr = (float *)frame->extended_data[0]; if (s->hrir_fmt == HRIR_STEREO) { int idx = av_get_channel_layout_channel_index(inlink->channel_layout, @@ -502,17 +502,11 @@ static int convert_coeffs(AVFilterContext *ctx, AVFilterLink *inlink) } } } - - av_frame_free(&s->in[i + 1].frame); } s->have_hrirs = 1; fail: - - for (i = 0; i < s->nb_inputs - 1; i++) - av_frame_free(&s->in[i + 1].frame); - return ret; }