From 703e34a04f31e46beeafcba6275bb602035ceae1 Mon Sep 17 00:00:00 2001 From: Alessio Bazzica Date: Fri, 29 Mar 2019 13:02:40 +0100 Subject: [PATCH] APM PFFFT wrapper: Add frequency domain convolution Wrapping pffft_zconvolve_accumulate() Bug: webrtc:9577 Change-Id: I68b7da4d08c28583f5abd59d906603754c94c00f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/130500 Reviewed-by: Ivo Creusen Commit-Queue: Alessio Bazzica Cr-Commit-Position: refs/heads/master@{#27358} --- modules/audio_processing/utility/pffft_wrapper.cc | 11 +++++++++++ modules/audio_processing/utility/pffft_wrapper.h | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/modules/audio_processing/utility/pffft_wrapper.cc b/modules/audio_processing/utility/pffft_wrapper.cc index 2361326f25..88642fb12b 100644 --- a/modules/audio_processing/utility/pffft_wrapper.cc +++ b/modules/audio_processing/utility/pffft_wrapper.cc @@ -121,4 +121,15 @@ void Pffft::BackwardTransform(const FloatBuffer& in, } } +void Pffft::FrequencyDomainConvolve(const FloatBuffer& fft_x, + const FloatBuffer& fft_y, + FloatBuffer* out, + float scaling) { + RTC_DCHECK_EQ(fft_x.size(), GetBufferSize(fft_size_, fft_type_)); + RTC_DCHECK_EQ(fft_x.size(), fft_y.size()); + RTC_DCHECK_EQ(fft_x.size(), out->size()); + pffft_zconvolve_accumulate(pffft_status_, fft_x.const_data(), + fft_y.const_data(), out->data(), scaling); +} + } // namespace webrtc diff --git a/modules/audio_processing/utility/pffft_wrapper.h b/modules/audio_processing/utility/pffft_wrapper.h index a30b97031f..160f0da059 100644 --- a/modules/audio_processing/utility/pffft_wrapper.h +++ b/modules/audio_processing/utility/pffft_wrapper.h @@ -73,6 +73,15 @@ class Pffft { // Computes the backward fast Fourier transform. void BackwardTransform(const FloatBuffer& in, FloatBuffer* out, bool ordered); + // Multiplies the frequency components of |fft_x| and |fft_y| and accumulates + // them into |out|. The arrays must have been obtained with + // ForwardTransform(..., /*ordered=*/false) - i.e., |fft_x| and |fft_y| must + // not be ordered. + void FrequencyDomainConvolve(const FloatBuffer& fft_x, + const FloatBuffer& fft_y, + FloatBuffer* out, + float scaling = 1.f); + private: const size_t fft_size_; const FftType fft_type_;