summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/AudioResamplerDyn.cpp
diff options
context:
space:
mode:
authorAndy Hung <hunga@google.com>2014-02-10 15:00:16 -0800
committerAndy Hung <hunga@google.com>2014-02-11 13:41:27 -0800
commita3bb9a3a25b58669d75da4f73764ac4c2bf34158 (patch)
treeb918f7d8be8ebd75106e6ede3fab9102edc5eedb /services/audioflinger/AudioResamplerDyn.cpp
parentc99144dd2766c499701a7bd7db2d9d8697127186 (diff)
downloadframeworks_av-a3bb9a3a25b58669d75da4f73764ac4c2bf34158.zip
frameworks_av-a3bb9a3a25b58669d75da4f73764ac4c2bf34158.tar.gz
frameworks_av-a3bb9a3a25b58669d75da4f73764ac4c2bf34158.tar.bz2
Proper adjustment of filterlength for downsampling
Bug: 12963040 Change-Id: I772b8efd3f7eae6d075994b210dd0168f5365f4d Signed-off-by: Andy Hung <hunga@google.com>
Diffstat (limited to 'services/audioflinger/AudioResamplerDyn.cpp')
-rw-r--r--services/audioflinger/AudioResamplerDyn.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/services/audioflinger/AudioResamplerDyn.cpp b/services/audioflinger/AudioResamplerDyn.cpp
index cd67df5..54c2309 100644
--- a/services/audioflinger/AudioResamplerDyn.cpp
+++ b/services/audioflinger/AudioResamplerDyn.cpp
@@ -283,17 +283,25 @@ void AudioResamplerDyn::setSampleRate(int32_t inSampleRate) {
// 32b coefficients, 64 length
useS32 = true;
stopBandAtten = 98.;
- halfLength = 32;
+ if (inSampleRate >= mSampleRate * 4) {
+ halfLength = 48;
+ } else if (inSampleRate >= mSampleRate * 2) {
+ halfLength = 40;
+ } else {
+ halfLength = 32;
+ }
} else if (mFilterQuality == DYN_LOW_QUALITY) {
// 16b coefficients, 16-32 length
useS32 = false;
stopBandAtten = 80.;
- if (mSampleRate >= inSampleRate * 2) {
+ if (inSampleRate >= mSampleRate * 4) {
+ halfLength = 24;
+ } else if (inSampleRate >= mSampleRate * 2) {
halfLength = 16;
} else {
halfLength = 8;
}
- if (mSampleRate >= inSampleRate) {
+ if (inSampleRate <= mSampleRate) {
tbwCheat = 1.05;
} else {
tbwCheat = 1.03;
@@ -303,14 +311,14 @@ void AudioResamplerDyn::setSampleRate(int32_t inSampleRate) {
// note: > 64 length filters with 16b coefs can have quantization noise problems
useS32 = false;
stopBandAtten = 84.;
- if (mSampleRate >= inSampleRate * 4) {
+ if (inSampleRate >= mSampleRate * 4) {
halfLength = 32;
- } else if (mSampleRate >= inSampleRate * 2) {
+ } else if (inSampleRate >= mSampleRate * 2) {
halfLength = 24;
} else {
halfLength = 16;
}
- if (mSampleRate >= inSampleRate) {
+ if (inSampleRate <= mSampleRate) {
tbwCheat = 1.03;
} else {
tbwCheat = 1.01;