Refactor common_audio/signal_processing: Removed usage of WEBRTC_SPL_MUL_16_16_RSFT

The macro is defined as
#define WEBRTC_SPL_MUL_16_16_RSFT(a, b, c) \
(WEBRTC_SPL_MUL_16_16(a, b) >> (c))

where the latter macro is in C defined as
#define WEBRTC_SPL_MUL_16_16(a, b) \
((int32_t) (((int16_t)(a)) * ((int16_t)(b))))
(For definitions on ARMv7 and MIPS, see common_audio/signal_processing/include/spl_inl_{armv7,mips}.h)

The replacement consists of
- avoiding casts to int16_t if inputs already are int16_t
- adding explicit cast to <type> if result is assigned to <type> (other than int or int32_t)
- minor cleanups like remove of unnecessary parentheses and style changes

BUG=3348, 3353
TESTED=locally on Linux for both fixed and floating point and trybots
R=kwiberg@webrtc.org

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

Cr-Commit-Position: refs/heads/master@{#8853}
This commit is contained in:
Bjorn Volcker
2015-03-25 13:29:49 +01:00
parent 245989b22a
commit 1ccd8b4281
5 changed files with 11 additions and 17 deletions

View File

@@ -27,8 +27,8 @@ int32_t WebRtcSpl_Energy(int16_t* vector, int vector_length, int* scale_factor)
for (i = 0; i < looptimes; i++) for (i = 0; i < looptimes; i++)
{ {
en += WEBRTC_SPL_MUL_16_16_RSFT(*vectorptr, *vectorptr, scaling); en += (*vectorptr * *vectorptr) >> scaling;
vectorptr++; vectorptr++;
} }
*scale_factor = scaling; *scale_factor = scaling;

View File

@@ -32,8 +32,7 @@ void WebRtcSpl_ReverseOrderMultArrayElements(int16_t *out, const int16_t *in,
const int16_t *winptr = win; const int16_t *winptr = win;
for (i = 0; i < vector_length; i++) for (i = 0; i < vector_length; i++)
{ {
(*outptr++) = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(*inptr++, *outptr++ = (int16_t)((*inptr++ * *winptr--) >> right_shifts);
*winptr--, right_shifts);
} }
} }
@@ -47,8 +46,7 @@ void WebRtcSpl_ElementwiseVectorMult(int16_t *out, const int16_t *in,
const int16_t *winptr = win; const int16_t *winptr = win;
for (i = 0; i < vector_length; i++) for (i = 0; i < vector_length; i++)
{ {
(*outptr++) = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(*inptr++, *outptr++ = (int16_t)((*inptr++ * *winptr++) >> right_shifts);
*winptr++, right_shifts);
} }
} }

View File

@@ -92,7 +92,7 @@
#define WEBRTC_SPL_RSHIFT_U32(x, c) ((uint32_t)(x) >> (c)) #define WEBRTC_SPL_RSHIFT_U32(x, c) ((uint32_t)(x) >> (c))
#define WEBRTC_SPL_RAND(a) \ #define WEBRTC_SPL_RAND(a) \
((int16_t)(WEBRTC_SPL_MUL_16_16_RSFT((a), 18816, 7) & 0x00007fff)) ((int16_t)((((int16_t)a * 18816) >> 7) & 0x00007fff))
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@@ -41,8 +41,7 @@ void WebRtcSpl_ReflCoefToLpc(const int16_t *k, int use_order, int16_t *a)
any[m + 1] = *kptr >> 3; any[m + 1] = *kptr >> 3;
for (i = 0; i < m; i++) for (i = 0; i < m; i++)
{ {
*anyptr = (*aptr) *anyptr = *aptr + (int16_t)((*aptr2 * *kptr) >> 15);
+ (int16_t)WEBRTC_SPL_MUL_16_16_RSFT((*aptr2), (*kptr), 15);
anyptr++; anyptr++;
aptr++; aptr++;
aptr2--; aptr2--;

View File

@@ -97,7 +97,7 @@ void WebRtcSpl_ScaleVector(const int16_t *in_vector, int16_t *out_vector,
for (i = 0; i < in_vector_length; i++) for (i = 0; i < in_vector_length; i++)
{ {
(*outptr++) = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(*inptr++, gain, right_shifts); *outptr++ = (int16_t)((*inptr++ * gain) >> right_shifts);
} }
} }
@@ -107,17 +107,14 @@ void WebRtcSpl_ScaleVectorWithSat(const int16_t *in_vector, int16_t *out_vector,
{ {
// Performs vector operation: out_vector = (gain*in_vector)>>right_shifts // Performs vector operation: out_vector = (gain*in_vector)>>right_shifts
int i; int i;
int32_t tmpW32;
const int16_t *inptr; const int16_t *inptr;
int16_t *outptr; int16_t *outptr;
inptr = in_vector; inptr = in_vector;
outptr = out_vector; outptr = out_vector;
for (i = 0; i < in_vector_length; i++) for (i = 0; i < in_vector_length; i++) {
{ *outptr++ = WebRtcSpl_SatW32ToW16((*inptr++ * gain) >> right_shifts);
tmpW32 = WEBRTC_SPL_MUL_16_16_RSFT(*inptr++, gain, right_shifts);
(*outptr++) = WebRtcSpl_SatW32ToW16(tmpW32);
} }
} }
@@ -137,8 +134,8 @@ void WebRtcSpl_ScaleAndAddVectors(const int16_t *in1, int16_t gain1, int shift1,
for (i = 0; i < vector_length; i++) for (i = 0; i < vector_length; i++)
{ {
(*outptr++) = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(gain1, *in1ptr++, shift1) *outptr++ = (int16_t)((gain1 * *in1ptr++) >> shift1) +
+ (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(gain2, *in2ptr++, shift2); (int16_t)((gain2 * *in2ptr++) >> shift2);
} }
} }