Fixed a bug in an Android macro definition in SPL that caused issue 833.

Review URL: https://webrtc-codereview.appspot.com/863007

git-svn-id: http://webrtc.googlecode.com/svn/trunk@2873 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
kma@webrtc.org 2012-10-05 00:27:10 +00:00
parent ac4d70de04
commit 6679dcc6c5
2 changed files with 28 additions and 2 deletions

View File

@ -64,6 +64,7 @@ static __inline WebRtc_Word32 WEBRTC_SPL_MUL_16_16(WebRtc_Word16 a,
return tmp; return tmp;
} }
// TODO(kma): add unit test.
static __inline int32_t WebRtc_MulAccumW16(int16_t a, static __inline int32_t WebRtc_MulAccumW16(int16_t a,
int16_t b, int16_t b,
int32_t c) { int32_t c) {
@ -124,7 +125,12 @@ static __inline WebRtc_Word16 WebRtcSpl_GetSizeInBits(WebRtc_UWord32 n) {
static __inline int WebRtcSpl_NormW32(WebRtc_Word32 a) { static __inline int WebRtcSpl_NormW32(WebRtc_Word32 a) {
WebRtc_Word32 tmp = 0; WebRtc_Word32 tmp = 0;
if (a <= 0) a ^= 0xFFFFFFFF; if (a == 0) {
return 0;
}
else if (a < 0) {
a ^= 0xFFFFFFFF;
}
__asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a)); __asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a));
@ -144,13 +150,19 @@ static __inline int WebRtcSpl_NormU32(WebRtc_UWord32 a) {
static __inline int WebRtcSpl_NormW16(WebRtc_Word16 a) { static __inline int WebRtcSpl_NormW16(WebRtc_Word16 a) {
WebRtc_Word32 tmp = 0; WebRtc_Word32 tmp = 0;
if (a <= 0) a ^= 0xFFFFFFFF; if (a == 0) {
return 0;
}
else if (a < 0) {
a ^= 0xFFFFFFFF;
}
__asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a)); __asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a));
return tmp - 17; return tmp - 17;
} }
// TODO(kma): add unit test.
static __inline WebRtc_Word16 WebRtcSpl_SatW32ToW16(WebRtc_Word32 value32) { static __inline WebRtc_Word16 WebRtcSpl_SatW32ToW16(WebRtc_Word32 value32) {
WebRtc_Word16 out16 = 0; WebRtc_Word16 out16 = 0;
@ -158,4 +170,5 @@ static __inline WebRtc_Word16 WebRtcSpl_SatW32ToW16(WebRtc_Word32 value32) {
return out16; return out16;
} }
#endif // WEBRTC_SPL_SPL_INL_ARMV7_H_ #endif // WEBRTC_SPL_SPL_INL_ARMV7_H_

View File

@ -138,8 +138,20 @@ TEST_F(SplTest, InlineTest) {
char bVersion[8]; char bVersion[8];
EXPECT_EQ(17, WebRtcSpl_GetSizeInBits(a32)); EXPECT_EQ(17, WebRtcSpl_GetSizeInBits(a32));
EXPECT_EQ(0, WebRtcSpl_NormW32(0));
EXPECT_EQ(31, WebRtcSpl_NormW32(-1));
EXPECT_EQ(0, WebRtcSpl_NormW32(WEBRTC_SPL_WORD32_MIN));
EXPECT_EQ(14, WebRtcSpl_NormW32(a32)); EXPECT_EQ(14, WebRtcSpl_NormW32(a32));
EXPECT_EQ(0, WebRtcSpl_NormW16(0));
EXPECT_EQ(15, WebRtcSpl_NormW16(-1));
EXPECT_EQ(0, WebRtcSpl_NormW16(WEBRTC_SPL_WORD16_MIN));
EXPECT_EQ(4, WebRtcSpl_NormW16(b32)); EXPECT_EQ(4, WebRtcSpl_NormW16(b32));
EXPECT_EQ(0, WebRtcSpl_NormU32(0));
EXPECT_EQ(0, WebRtcSpl_NormU32(-1));
EXPECT_EQ(0, WebRtcSpl_NormU32(WEBRTC_SPL_WORD32_MIN));
EXPECT_EQ(15, WebRtcSpl_NormU32(a32)); EXPECT_EQ(15, WebRtcSpl_NormU32(a32));
EXPECT_EQ(104, WebRtcSpl_AddSatW16(a16, b16)); EXPECT_EQ(104, WebRtcSpl_AddSatW16(a16, b16));
@ -147,6 +159,7 @@ TEST_F(SplTest, InlineTest) {
EXPECT_EQ(109410, WebRtcSpl_AddSatW32(a32, b32)); EXPECT_EQ(109410, WebRtcSpl_AddSatW32(a32, b32));
EXPECT_EQ(112832, WebRtcSpl_SubSatW32(a32, b32)); EXPECT_EQ(112832, WebRtcSpl_SubSatW32(a32, b32));
a32 = 0x80000000; a32 = 0x80000000;
b32 = 0x80000000; b32 = 0x80000000;
// Cast to signed int to avoid compiler complaint on gtest.h. // Cast to signed int to avoid compiler complaint on gtest.h.