diff options
author | Andy Hung <hunga@google.com> | 2014-07-20 14:04:19 -0700 |
---|---|---|
committer | Andy Hung <hunga@google.com> | 2014-07-21 21:59:51 -0700 |
commit | 42b011166ece30969667e0ff9dcf4832568c9c1a (patch) | |
tree | 16f653a56d0daaeb02dfd27659ac96796163e8dc /services/audioflinger/AudioResamplerFirProcess.h | |
parent | 8bce84142802ecdc1794d59488ede629801a5cba (diff) | |
download | frameworks_av-42b011166ece30969667e0ff9dcf4832568c9c1a.zip frameworks_av-42b011166ece30969667e0ff9dcf4832568c9c1a.tar.gz frameworks_av-42b011166ece30969667e0ff9dcf4832568c9c1a.tar.bz2 |
Fix multichannel integer resampling and add tests
Change-Id: I384bf8317d4f03616bf9f2b458a8700965d5cf56
Diffstat (limited to 'services/audioflinger/AudioResamplerFirProcess.h')
-rw-r--r-- | services/audioflinger/AudioResamplerFirProcess.h | 36 |
1 files changed, 10 insertions, 26 deletions
diff --git a/services/audioflinger/AudioResamplerFirProcess.h b/services/audioflinger/AudioResamplerFirProcess.h index bb0f1c9..d130013 100644 --- a/services/audioflinger/AudioResamplerFirProcess.h +++ b/services/audioflinger/AudioResamplerFirProcess.h @@ -109,40 +109,25 @@ public: } }; -/* - * Helper template functions for interpolating filter coefficients. - */ - -template<typename TC, typename T> -void adjustLerp(T& lerpP __unused) -{ -} - -template<int32_t, typename T> -void adjustLerp(T& lerpP) -{ - lerpP >>= 16; // lerpP is 32bit for NEON int32_t, but always 16 bit for non-NEON path -} - template<typename TC, typename TINTERP> -static inline +inline TC interpolate(TC coef_0, TC coef_1, TINTERP lerp) { return lerp * (coef_1 - coef_0) + coef_0; } -template<int16_t, uint32_t> -static inline -int16_t interpolate(int16_t coef_0, int16_t coef_1, uint32_t lerp) -{ - return (static_cast<int16_t>(lerp) * ((coef_1-coef_0)<<1)>>16) + coef_0; +template<> +inline +int16_t interpolate<int16_t, uint32_t>(int16_t coef_0, int16_t coef_1, uint32_t lerp) +{ // in some CPU architectures 16b x 16b multiplies are faster. + return (static_cast<int16_t>(lerp) * static_cast<int16_t>(coef_1 - coef_0) >> 15) + coef_0; } -template<int32_t, uint32_t> -static inline -int32_t interpolate(int32_t coef_0, int32_t coef_1, uint32_t lerp) +template<> +inline +int32_t interpolate<int32_t, uint32_t>(int32_t coef_0, int32_t coef_1, uint32_t lerp) { - return mulAdd(static_cast<int16_t>(lerp), (coef_1-coef_0)<<1, coef_0); + return (lerp * static_cast<int64_t>(coef_1 - coef_0) >> 31) + coef_0; } /* class scope for passing in functions into templates */ @@ -283,7 +268,6 @@ void Process(TO* const out, TINTERP lerpP, const TO* const volumeLR) { - adjustLerp<TC, TINTERP>(lerpP); // coefficient type adjustment for interpolations ProcessBase<CHANNELS, STRIDE, InterpCompute>(out, count, coefsP, coefsN, sP, sN, lerpP, volumeLR); } |