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
commit1f09b4ada212d259b531228db67ca160d280275c (patch)
tree18f3249800ec4787d088436097c9df608b506cb1 /services/audioflinger/AudioResamplerSinc.cpp
parentd88a051aff15fdf5c57e1e5a4083bbd9635af3ad (diff)
downloadframeworks_av-1f09b4ada212d259b531228db67ca160d280275c.zip
frameworks_av-1f09b4ada212d259b531228db67ca160d280275c.tar.gz
frameworks_av-1f09b4ada212d259b531228db67ca160d280275c.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
}