From patchwork Sun Oct 16 23:16:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muhammad Faiz X-Patchwork-Id: 1030 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.133 with SMTP id o127csp121494vsd; Sun, 16 Oct 2016 16:18:14 -0700 (PDT) X-Received: by 10.28.61.134 with SMTP id k128mr6050043wma.51.1476659894578; Sun, 16 Oct 2016 16:18:14 -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 br5si37240800wjb.189.2016.10.16.16.18.14; Sun, 16 Oct 2016 16:18:14 -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 BF07B689919; Mon, 17 Oct 2016 02:18:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pa0-f66.google.com (mail-pa0-f66.google.com [209.85.220.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B123268974E for ; Mon, 17 Oct 2016 02:18:04 +0300 (EEST) Received: by mail-pa0-f66.google.com with SMTP id os4so4452555pac.3 for ; Sun, 16 Oct 2016 16:18:06 -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; bh=ZGs82IsmM/T91jcMx25NNfJch+D0kWLu3/YBQS/zovo=; b=V9F/aU9N5DKrnXCqyleNWE+m8U6TlFmvP2kFmpc4sIsS70jZviirHjCBHF6ZpBG4qS Y3MmNGHshyomHuAgBdNZ5kp3TxhbDq1tMWHbELfYfhH8rENY9YmSnKGJ10dlAOI/xSf9 XQ0GiGDlT1OV7xvvE8u/folrpsGltg67VyRw0iT7Bm8gDtMhA9j4U7YVHOI8xdLLX+os Axxw5Jpa7Qz5F/lBWQSjMmtsIeNqR0nfeI+tbj4rx92OQrwc8dywTbtVJ6GBydmV6sMo ZSydH81T4EhUKcKs+Z1hIwEZstEJfbxkA08AWk4Sn4+s4SaVGBMSSROUxYaqmpw8cutB KjTw== 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; bh=ZGs82IsmM/T91jcMx25NNfJch+D0kWLu3/YBQS/zovo=; b=PTyPaz7aYktPTHR8D6h4kgYTwZce3hOzwSXH1sLHIGka/xmEpZvAuEr+KkOEgvlKhG IPcazG8l6Y2L8XTYvJPqbW8BuJ5RydWAoXyX4xrAOpQBWUwqW3SfyeWJQyE7X5vfuPo2 kiJ5veeFSDRX+dkhQTonE1fHRR6zcKAzZiBU149d+8U2y7Jz3Hl5eHnXl+nThhQAM6A4 oVx5RJ6rpEK4Snp3ihPqk1pP4ijz11HAWSp/Dt5Wg7rfTCSk/qpyVmBDNAYBSXcEahjb QLRNAoZb1n6+URfy6lCwjDNi8aUMPcy282vZNWHqs2hL+QlyDybfk6T6bZZ/FJG3z4CG RhKg== X-Gm-Message-State: AA6/9RmRlDwcru4MskiNRvc3h1lzlJICKWLIsonXetIQ6BnHInyzptNbpCAh79c0YV7J/g== X-Received: by 10.66.11.104 with SMTP id p8mr27937418pab.202.1476659885391; Sun, 16 Oct 2016 16:18:05 -0700 (PDT) Received: from localhost.localdomain.localdomain ([202.67.46.2]) by smtp.gmail.com with ESMTPSA id x1sm13402120pax.7.2016.10.16.16.18.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 16 Oct 2016 16:18:04 -0700 (PDT) From: Muhammad Faiz To: ffmpeg-devel@ffmpeg.org Date: Mon, 17 Oct 2016 06:16:02 +0700 Message-Id: <1476659762-27088-1-git-send-email-mfcc64@gmail.com> X-Mailer: git-send-email 2.5.0 Subject: [FFmpeg-devel] [PATCH] avfilter/firequalizer: optimize gain/gain_entry command 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: Muhammad Faiz MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" do not rebuild when gain/gain_entry command are equal with old gain/gain_entry Signed-off-by: Muhammad Faiz --- libavfilter/af_firequalizer.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/libavfilter/af_firequalizer.c b/libavfilter/af_firequalizer.c index 78d7767..aed3e28 100644 --- a/libavfilter/af_firequalizer.c +++ b/libavfilter/af_firequalizer.c @@ -453,6 +453,9 @@ static int generate_kernel(AVFilterContext *ctx, const char *gain, const char *g return 0; } +#define SELECT_GAIN(s) (s->gain_cmd ? s->gain_cmd : s->gain) +#define SELECT_GAIN_ENTRY(s) (s->gain_entry_cmd ? s->gain_entry_cmd : s->gain_entry) + static int config_input(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; @@ -510,8 +513,7 @@ static int config_input(AVFilterLink *inlink) if (s->fixed) inlink->min_samples = inlink->max_samples = inlink->partial_buf_size = s->nsamples_max; - return generate_kernel(ctx, s->gain_cmd ? s->gain_cmd : s->gain, - s->gain_entry_cmd ? s->gain_entry_cmd : s->gain_entry); + return generate_kernel(ctx, SELECT_GAIN(s), SELECT_GAIN_ENTRY(s)); } static int filter_frame(AVFilterLink *inlink, AVFrame *frame) @@ -567,11 +569,16 @@ static int process_command(AVFilterContext *ctx, const char *cmd, const char *ar if (!strcmp(cmd, "gain")) { char *gain_cmd; + if (SELECT_GAIN(s) && !strcmp(SELECT_GAIN(s), args)) { + av_log(ctx, AV_LOG_DEBUG, "equal gain, do not rebuild.\n"); + return 0; + } + gain_cmd = av_strdup(args); if (!gain_cmd) return AVERROR(ENOMEM); - ret = generate_kernel(ctx, gain_cmd, s->gain_entry_cmd ? s->gain_entry_cmd : s->gain_entry); + ret = generate_kernel(ctx, gain_cmd, SELECT_GAIN_ENTRY(s)); if (ret >= 0) { av_freep(&s->gain_cmd); s->gain_cmd = gain_cmd; @@ -581,11 +588,16 @@ static int process_command(AVFilterContext *ctx, const char *cmd, const char *ar } else if (!strcmp(cmd, "gain_entry")) { char *gain_entry_cmd; + if (SELECT_GAIN_ENTRY(s) && !strcmp(SELECT_GAIN_ENTRY(s), args)) { + av_log(ctx, AV_LOG_DEBUG, "equal gain_entry, do not rebuild.\n"); + return 0; + } + gain_entry_cmd = av_strdup(args); if (!gain_entry_cmd) return AVERROR(ENOMEM); - ret = generate_kernel(ctx, s->gain_cmd ? s->gain_cmd : s->gain, gain_entry_cmd); + ret = generate_kernel(ctx, SELECT_GAIN(s), gain_entry_cmd); if (ret >= 0) { av_freep(&s->gain_entry_cmd); s->gain_entry_cmd = gain_entry_cmd;