summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/AudioResamplerSinc.cpp
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2012-10-30 13:51:44 -0700
committerMathias Agopian <mathias@google.com>2012-10-30 13:51:44 -0700
commitd7a3c142b3ce4ed26e025533f57bef9e4ec58740 (patch)
tree0659fcefa8fe4d25b276bc0f837a32c9b5e2657a /services/audioflinger/AudioResamplerSinc.cpp
parentcca56d5784c02a5f02ce5e47c3d6583d71a2469b (diff)
downloadframeworks_av-d7a3c142b3ce4ed26e025533f57bef9e4ec58740.zip
frameworks_av-d7a3c142b3ce4ed26e025533f57bef9e4ec58740.tar.gz
frameworks_av-d7a3c142b3ce4ed26e025533f57bef9e4ec58740.tar.bz2
fix SINC resampler on non ARM architectures
make sure the C version of the code generates the same output than the ARM assemply version. Change-Id: Ide218785c35d02598b2d7278e646b1b178148698
Diffstat (limited to 'services/audioflinger/AudioResamplerSinc.cpp')
-rw-r--r--services/audioflinger/AudioResamplerSinc.cpp20
1 files changed, 5 insertions, 15 deletions
diff --git a/services/audioflinger/AudioResamplerSinc.cpp b/services/audioflinger/AudioResamplerSinc.cpp
index edfed49..e0ea4a4 100644
--- a/services/audioflinger/AudioResamplerSinc.cpp
+++ b/services/audioflinger/AudioResamplerSinc.cpp
@@ -141,11 +141,8 @@ int32_t mulRL(int left, int32_t in, uint32_t vRL)
}
return out;
#else
- if (left) {
- return int16_t(in>>16) * int16_t(vRL&0xFFFF);
- } else {
- return int16_t(in>>16) * int16_t(vRL>>16);
- }
+ int16_t v = left ? int16_t(vRL) : int16_t(vRL>>16);
+ return int32_t((int64_t(in) * v) >> 16);
#endif
}
@@ -160,9 +157,7 @@ int32_t mulAdd(int16_t in, int32_t v, int32_t a)
: );
return out;
#else
- return a + in * (v>>16);
- // improved precision
- // return a + in * (v>>16) + ((in * (v & 0xffff)) >> 16);
+ return a + int32_t((int64_t(v) * in) >> 16);
#endif
}
@@ -184,13 +179,8 @@ int32_t mulAddRL(int left, uint32_t inRL, int32_t v, int32_t a)
}
return out;
#else
- if (left) {
- return a + (int16_t(inRL&0xFFFF) * (v>>16));
- //improved precision
- // return a + (int16_t(inRL&0xFFFF) * (v>>16)) + ((int16_t(inRL&0xFFFF) * (v & 0xffff)) >> 16);
- } else {
- return a + (int16_t(inRL>>16) * (v>>16));
- }
+ int16_t s = left ? int16_t(inRL) : int16_t(inRL>>16);
+ return a + int32_t((int64_t(v) * s) >> 16);
#endif
}