From patchwork Wed Oct 19 15:29:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muhammad Faiz X-Patchwork-Id: 1078 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.133 with SMTP id o127csp254962vsd; Wed, 19 Oct 2016 08:31:27 -0700 (PDT) X-Received: by 10.28.40.67 with SMTP id o64mr267667wmo.5.1476891087706; Wed, 19 Oct 2016 08:31:27 -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 r5si54909580wjl.43.2016.10.19.08.31.22; Wed, 19 Oct 2016 08:31:27 -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 CE79C689B28; Wed, 19 Oct 2016 18:31:17 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf0-f195.google.com (mail-pf0-f195.google.com [209.85.192.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6A0CF689737 for ; Wed, 19 Oct 2016 18:31:11 +0300 (EEST) Received: by mail-pf0-f195.google.com with SMTP id r16so2762760pfg.3 for ; Wed, 19 Oct 2016 08:31:14 -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=EfmtdLXXfnp+fzNlbwP6KDYxzvE0OeoYbXDnGRbBzEY=; b=ot2PbdWazF8EgM/NjX2qpey3s6YA+aonwbSdSX5J04Vl2NJYOFKQo8VmAGnpS4Q9YR xTMxXFS5+SmQWoETihu81pOyHtw/L2LEVoCRN9pogZSWkql85Gzcr8y5euExFAghFaZW mf8J5Y2o5lC8LjT9XDIsYw1qZq1pKUYGdTnYJNPcoVIdCocLDyO2ud6Wp9MHljKdN1v8 b+u5Wn/ikkzVOTbOuNp7WrgSOZNQtnf4n7VMW+rE5OiQHMIaTCo50+AlExXNkuXkgfnn CvrVadDIdwYmm/07615pHfvHNefty0Ryqr7SY2PEtkSMZApdaHaYgiLfIMJdxLqrAIPb tytg== 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=EfmtdLXXfnp+fzNlbwP6KDYxzvE0OeoYbXDnGRbBzEY=; b=UlcesHRdYY23P/gqnR1s/GWxGlPSFz2uO+0dsv3KN0DLcAoK87jQIE/A+JozhBaaN6 tLTI/4LmZxjYSLVPeiIt7fFEoKh3hND+UIT0F2nXWqjZe28fdJ4U2IGZZlYFOqC4xk+u /IbdJ8mKFtNtX/rLR08t5HXyPifw5VkgZeCPcWd3b7YT3n2o/pK0h5NGU9cwNcO1hY60 te72HmXOAIpI2CNu/wkrFjDVkw4ON+V3/UfAd6u99v5aUtc8NLqOyVel1wlkm/18t0pr bF9Ul6wvEgWornUwQfVeJzf2lA3yR+eX4C0QCcvwK4QnAjLmbWXE0QWZZJtjSMi8D95a tO3w== X-Gm-Message-State: AA6/9RlER+e/ESSMYBdkPZ8KsoeZq9IOSi4mEWcb/MAjlQypTTA/70ByGqxjXnYiUYYd9Q== X-Received: by 10.98.211.24 with SMTP id q24mr12259029pfg.69.1476891072599; Wed, 19 Oct 2016 08:31:12 -0700 (PDT) Received: from localhost.localdomain.localdomain ([114.120.238.107]) by smtp.gmail.com with ESMTPSA id o9sm58564312pac.27.2016.10.19.08.31.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Oct 2016 08:31:11 -0700 (PDT) From: Muhammad Faiz To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Oct 2016 22:29:07 +0700 Message-Id: <1476890947-6613-1-git-send-email-mfcc64@gmail.com> X-Mailer: git-send-email 2.5.0 Subject: [FFmpeg-devel] [PATCH] avfilter/firequalizer: use zero phase kernel 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" this makes real-valued kernel Signed-off-by: Muhammad Faiz --- libavfilter/af_firequalizer.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/libavfilter/af_firequalizer.c b/libavfilter/af_firequalizer.c index e799e34..4988717 100644 --- a/libavfilter/af_firequalizer.c +++ b/libavfilter/af_firequalizer.c @@ -198,20 +198,19 @@ static void fast_convolute(FIREqualizerContext *s, const float *kernel_buf, floa if (nsamples <= s->nsamples_max) { float *buf = conv_buf + idx->buf_idx * s->rdft_len; float *obuf = conv_buf + !idx->buf_idx * s->rdft_len + idx->overlap_idx; + int center = s->fir_len/2; int k; - memcpy(buf, data, nsamples * sizeof(*data)); - memset(buf + nsamples, 0, (s->rdft_len - nsamples) * sizeof(*data)); + memset(buf, 0, center * sizeof(*data)); + memcpy(buf + center, data, nsamples * sizeof(*data)); + memset(buf + center + nsamples, 0, (s->rdft_len - nsamples - center) * sizeof(*data)); av_rdft_calc(s->rdft, buf); buf[0] *= kernel_buf[0]; - buf[1] *= kernel_buf[1]; - for (k = 2; k < s->rdft_len; k += 2) { - float re, im; - re = buf[k] * kernel_buf[k] - buf[k+1] * kernel_buf[k+1]; - im = buf[k] * kernel_buf[k+1] + buf[k+1] * kernel_buf[k]; - buf[k] = re; - buf[k+1] = im; + buf[1] *= kernel_buf[s->rdft_len/2]; + for (k = 1; k < s->rdft_len/2; k++) { + buf[2*k] *= kernel_buf[k]; + buf[2*k+1] *= kernel_buf[k]; } av_rdft_calc(s->irdft, buf); @@ -534,8 +533,8 @@ static int generate_kernel(AVFilterContext *ctx, const char *gain, const char *g } memset(s->analysis_buf + center + 1, 0, (s->analysis_rdft_len - s->fir_len) * sizeof(*s->analysis_buf)); - memcpy(rdft_buf, s->analysis_buf + s->analysis_rdft_len - center, center * sizeof(*s->analysis_buf)); - memcpy(rdft_buf + center, s->analysis_buf, (s->rdft_len - center) * sizeof(*s->analysis_buf)); + memcpy(rdft_buf, s->analysis_buf, s->rdft_len/2 * sizeof(*s->analysis_buf)); + memcpy(rdft_buf + s->rdft_len/2, s->analysis_buf + s->analysis_rdft_len - s->rdft_len/2, s->rdft_len/2 * sizeof(*s->analysis_buf)); av_rdft_calc(s->rdft, rdft_buf); for (k = 0; k < s->rdft_len; k++) { @@ -548,6 +547,11 @@ static int generate_kernel(AVFilterContext *ctx, const char *gain, const char *g } } + rdft_buf[s->rdft_len-1] = rdft_buf[1]; + for (k = 0; k < s->rdft_len/2; k++) + rdft_buf[k] = rdft_buf[2*k]; + rdft_buf[s->rdft_len/2] = rdft_buf[s->rdft_len-1]; + if (dump_fp) dump_fir(ctx, dump_fp, ch);