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++)
{
en += WEBRTC_SPL_MUL_16_16_RSFT(*vectorptr, *vectorptr, scaling);
vectorptr++;
en += (*vectorptr * *vectorptr) >> scaling;
vectorptr++;
}
*scale_factor = scaling;

View File

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

View File

@@ -92,7 +92,7 @@
#define WEBRTC_SPL_RSHIFT_U32(x, c) ((uint32_t)(x) >> (c))
#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
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;
for (i = 0; i < m; i++)
{
*anyptr = (*aptr)
+ (int16_t)WEBRTC_SPL_MUL_16_16_RSFT((*aptr2), (*kptr), 15);
*anyptr = *aptr + (int16_t)((*aptr2 * *kptr) >> 15);
anyptr++;
aptr++;
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++)
{
(*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
int i;
int32_t tmpW32;
const int16_t *inptr;
int16_t *outptr;
inptr = in_vector;
outptr = out_vector;
for (i = 0; i < in_vector_length; i++)
{
tmpW32 = WEBRTC_SPL_MUL_16_16_RSFT(*inptr++, gain, right_shifts);
(*outptr++) = WebRtcSpl_SatW32ToW16(tmpW32);
for (i = 0; i < in_vector_length; i++) {
*outptr++ = WebRtcSpl_SatW32ToW16((*inptr++ * gain) >> right_shifts);
}
}
@@ -137,8 +134,8 @@ void WebRtcSpl_ScaleAndAddVectors(const int16_t *in1, int16_t gain1, int shift1,
for (i = 0; i < vector_length; i++)
{
(*outptr++) = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(gain1, *in1ptr++, shift1)
+ (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(gain2, *in2ptr++, shift2);
*outptr++ = (int16_t)((gain1 * *in1ptr++) >> shift1) +
(int16_t)((gain2 * *in2ptr++) >> shift2);
}
}