Reduce memory usage of PFFFT

Create a thin wrapper around PFFFT_Setup so we can manage it.  Use it
to allocate a set of setup objects that can be shared between FFTFrame
objects for FFTs of the same size.  This is safe because the setup is
only read by the FFTFrrame's when needed.

Make sure the FFT sizes needed by the HRTF kernel are allocated on the
main thread to eliminate any race condition of multiple threads writing
to the setup vector.  This requires passing the sample rate to

Also, the smallest FFT size for the HRTF kernel was smaller than the
smallest size supported by PFFFT.  Just clamp the size to the smallest.

This space optimization does not affect functional behavior so all
existing tests must pass.

Bug: 961912, 961848
Change-Id: Icd71e1ed38fb85b31b2c40ea03b4b2b1fc5dfb2e
Commit-Queue: Raymond Toy <>
Reviewed-by: Kentaro Hara <>
Reviewed-by: Hongchan Choi <>
Cr-Commit-Position: refs/heads/master@{#663271}
6 files changed