return out16;
}
+static __inline int32_t WebRtcSpl_AddSatW32(int32_t l_var1, int32_t l_var2) {
+ int32_t l_sum;
+
+ // Perform long addition
+ l_sum = l_var1 + l_var2;
+
+ if (l_var1 < 0) { // Check for underflow.
+ if ((l_var2 < 0) && (l_sum >= 0)) {
+ l_sum = (int32_t)0x80000000;
+ }
+ } else { // Check for overflow.
+ if ((l_var2 > 0) && (l_sum < 0)) {
+ l_sum = (int32_t)0x7FFFFFFF;
+ }
+ }
+
+ return l_sum;
+}
+
+static __inline int32_t WebRtcSpl_SubSatW32(int32_t l_var1, int32_t l_var2) {
+ int32_t l_diff;
+
+ // Perform subtraction.
+ l_diff = l_var1 - l_var2;
+
+ if (l_var1 < 0) { // Check for underflow.
+ if ((l_var2 > 0) && (l_diff > 0)) {
+ l_diff = (int32_t)0x80000000;
+ }
+ } else { // Check for overflow.
+ if ((l_var2 < 0) && (l_diff < 0)) {
+ l_diff = (int32_t)0x7FFFFFFF;
+ }
+ }
+
+ return l_diff;
+}
+
static __inline int16_t WebRtcSpl_AddSatW16(int16_t a, int16_t b) {
return WebRtcSpl_SatW32ToW16((int32_t) a + (int32_t) b);
}
#if !defined(MIPS32_LE)
static __inline int16_t WebRtcSpl_GetSizeInBits(uint32_t n) {
- int bits;
+ int16_t bits;
if (0xFFFF0000 & n) {
bits = 16;
return bits;
}
-static __inline int WebRtcSpl_NormW32(int32_t a) {
- int zeros;
+static __inline int16_t WebRtcSpl_NormW32(int32_t a) {
+ int16_t zeros;
if (a == 0) {
return 0;
return zeros;
}
-static __inline int WebRtcSpl_NormU32(uint32_t a) {
- int zeros;
+static __inline int16_t WebRtcSpl_NormU32(uint32_t a) {
+ int16_t zeros;
if (a == 0) return 0;
return zeros;
}
-static __inline int WebRtcSpl_NormW16(int16_t a) {
- int zeros;
+static __inline int16_t WebRtcSpl_NormW16(int16_t a) {
+ int16_t zeros;
if (a == 0) {
return 0;
#endif // WEBRTC_ARCH_ARM_V7
-// The following functions have no optimized versions.
-// TODO(kma): Consider saturating add/sub instructions in X86 platform.
-#if !defined(MIPS_DSP_R1_LE)
-static __inline int32_t WebRtcSpl_AddSatW32(int32_t l_var1, int32_t l_var2) {
- int32_t l_sum;
-
- // Perform long addition
- l_sum = l_var1 + l_var2;
-
- if (l_var1 < 0) { // Check for underflow.
- if ((l_var2 < 0) && (l_sum >= 0)) {
- l_sum = (int32_t)0x80000000;
- }
- } else { // Check for overflow.
- if ((l_var2 > 0) && (l_sum < 0)) {
- l_sum = (int32_t)0x7FFFFFFF;
- }
- }
-
- return l_sum;
-}
-
-static __inline int32_t WebRtcSpl_SubSatW32(int32_t l_var1, int32_t l_var2) {
- int32_t l_diff;
-
- // Perform subtraction.
- l_diff = l_var1 - l_var2;
-
- if (l_var1 < 0) { // Check for underflow.
- if ((l_var2 > 0) && (l_diff > 0)) {
- l_diff = (int32_t)0x80000000;
- }
- } else { // Check for overflow.
- if ((l_var2 < 0) && (l_diff < 0)) {
- l_diff = (int32_t)0x7FFFFFFF;
- }
- }
-
- return l_diff;
-}
-#endif // #if !defined(MIPS_DSP_R1_LE)
-
#endif // WEBRTC_SPL_SPL_INL_H_