Reformat the WebRTC code base

Running clang-format with chromium's style guide.

The goal is n-fold:
 * providing consistency and readability (that's what code guidelines are for)
 * preventing noise with presubmit checks and git cl format
 * building on the previous point: making it easier to automatically fix format issues
 * you name it

Please consider using git-hyper-blame to ignore this commit.

Bug: webrtc:9340
Change-Id: I694567c4cdf8cee2860958cfe82bfaf25848bb87
Reviewed-on: https://webrtc-review.googlesource.com/81185
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23660}
This commit is contained in:
Yves Gerey
2018-06-19 15:03:05 +02:00
parent b602123a5a
commit 665174fdbb
1569 changed files with 30495 additions and 30309 deletions

View File

@ -15,7 +15,7 @@
// For ComplexFFT(), the maximum fft order is 10;
// WebRTC APM uses orders of only 7 and 8.
enum {kMaxFFTOrder = 10};
enum { kMaxFFTOrder = 10 };
struct RealFFT;

View File

@ -8,11 +8,10 @@
* be found in the AUTHORS file in the root of the source tree.
*/
/*
* This header file includes all of the fix point signal processing library (SPL) function
* descriptions and declarations.
* For specific function calls, see bottom of file.
* This header file includes all of the fix point signal processing library
* (SPL) function descriptions and declarations. For specific function calls,
* see bottom of file.
*/
#ifndef COMMON_AUDIO_SIGNAL_PROCESSING_INCLUDE_SIGNAL_PROCESSING_LIBRARY_H_
@ -23,63 +22,58 @@
#include "typedefs.h" // NOLINT(build/include)
// Macros specific for the fixed point implementation
#define WEBRTC_SPL_WORD16_MAX 32767
#define WEBRTC_SPL_WORD16_MIN -32768
#define WEBRTC_SPL_WORD32_MAX (int32_t)0x7fffffff
#define WEBRTC_SPL_WORD32_MIN (int32_t)0x80000000
#define WEBRTC_SPL_MAX_LPC_ORDER 14
#define WEBRTC_SPL_MIN(A, B) (A < B ? A : B) // Get min value
#define WEBRTC_SPL_MAX(A, B) (A > B ? A : B) // Get max value
#define WEBRTC_SPL_WORD16_MAX 32767
#define WEBRTC_SPL_WORD16_MIN -32768
#define WEBRTC_SPL_WORD32_MAX (int32_t)0x7fffffff
#define WEBRTC_SPL_WORD32_MIN (int32_t)0x80000000
#define WEBRTC_SPL_MAX_LPC_ORDER 14
#define WEBRTC_SPL_MIN(A, B) (A < B ? A : B) // Get min value
#define WEBRTC_SPL_MAX(A, B) (A > B ? A : B) // Get max value
// TODO(kma/bjorn): For the next two macros, investigate how to correct the code
// for inputs of a = WEBRTC_SPL_WORD16_MIN or WEBRTC_SPL_WORD32_MIN.
#define WEBRTC_SPL_ABS_W16(a) \
(((int16_t)a >= 0) ? ((int16_t)a) : -((int16_t)a))
#define WEBRTC_SPL_ABS_W32(a) \
(((int32_t)a >= 0) ? ((int32_t)a) : -((int32_t)a))
#define WEBRTC_SPL_ABS_W16(a) (((int16_t)a >= 0) ? ((int16_t)a) : -((int16_t)a))
#define WEBRTC_SPL_ABS_W32(a) (((int32_t)a >= 0) ? ((int32_t)a) : -((int32_t)a))
#define WEBRTC_SPL_MUL(a, b) \
((int32_t) ((int32_t)(a) * (int32_t)(b)))
#define WEBRTC_SPL_UMUL(a, b) \
((uint32_t) ((uint32_t)(a) * (uint32_t)(b)))
#define WEBRTC_SPL_UMUL_32_16(a, b) \
((uint32_t) ((uint32_t)(a) * (uint16_t)(b)))
#define WEBRTC_SPL_MUL_16_U16(a, b) \
((int32_t)(int16_t)(a) * (uint16_t)(b))
#define WEBRTC_SPL_MUL(a, b) ((int32_t)((int32_t)(a) * (int32_t)(b)))
#define WEBRTC_SPL_UMUL(a, b) ((uint32_t)((uint32_t)(a) * (uint32_t)(b)))
#define WEBRTC_SPL_UMUL_32_16(a, b) ((uint32_t)((uint32_t)(a) * (uint16_t)(b)))
#define WEBRTC_SPL_MUL_16_U16(a, b) ((int32_t)(int16_t)(a) * (uint16_t)(b))
// clang-format off
// clang-format would choose some identation
// leading to presubmit error (cpplint.py)
#ifndef WEBRTC_ARCH_ARM_V7
// For ARMv7 platforms, these are inline functions in spl_inl_armv7.h
#ifndef MIPS32_LE
// For MIPS platforms, these are inline functions in spl_inl_mips.h
#define WEBRTC_SPL_MUL_16_16(a, b) \
((int32_t) (((int16_t)(a)) * ((int16_t)(b))))
#define WEBRTC_SPL_MUL_16_16(a, b) ((int32_t)(((int16_t)(a)) * ((int16_t)(b))))
#define WEBRTC_SPL_MUL_16_32_RSFT16(a, b) \
(WEBRTC_SPL_MUL_16_16(a, b >> 16) \
+ ((WEBRTC_SPL_MUL_16_16(a, (b & 0xffff) >> 1) + 0x4000) >> 15))
(WEBRTC_SPL_MUL_16_16(a, b >> 16) + \
((WEBRTC_SPL_MUL_16_16(a, (b & 0xffff) >> 1) + 0x4000) >> 15))
#endif
#endif
#define WEBRTC_SPL_MUL_16_32_RSFT11(a, b) \
(WEBRTC_SPL_MUL_16_16(a, (b) >> 16) * (1 << 5) + \
(((WEBRTC_SPL_MUL_16_U16(a, (uint16_t)(b)) >> 1) + 0x0200) >> 10))
(WEBRTC_SPL_MUL_16_16(a, (b) >> 16) * (1 << 5) + \
(((WEBRTC_SPL_MUL_16_U16(a, (uint16_t)(b)) >> 1) + 0x0200) >> 10))
#define WEBRTC_SPL_MUL_16_32_RSFT14(a, b) \
(WEBRTC_SPL_MUL_16_16(a, (b) >> 16) * (1 << 2) + \
(((WEBRTC_SPL_MUL_16_U16(a, (uint16_t)(b)) >> 1) + 0x1000) >> 13))
(WEBRTC_SPL_MUL_16_16(a, (b) >> 16) * (1 << 2) + \
(((WEBRTC_SPL_MUL_16_U16(a, (uint16_t)(b)) >> 1) + 0x1000) >> 13))
#define WEBRTC_SPL_MUL_16_32_RSFT15(a, b) \
((WEBRTC_SPL_MUL_16_16(a, (b) >> 16) * (1 << 1)) + \
(((WEBRTC_SPL_MUL_16_U16(a, (uint16_t)(b)) >> 1) + 0x2000) >> 14))
((WEBRTC_SPL_MUL_16_16(a, (b) >> 16) * (1 << 1)) + \
(((WEBRTC_SPL_MUL_16_U16(a, (uint16_t)(b)) >> 1) + 0x2000) >> 14))
// clang-format on
#define WEBRTC_SPL_MUL_16_16_RSFT(a, b, c) \
(WEBRTC_SPL_MUL_16_16(a, b) >> (c))
#define WEBRTC_SPL_MUL_16_16_RSFT(a, b, c) (WEBRTC_SPL_MUL_16_16(a, b) >> (c))
#define WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(a, b, c) \
((WEBRTC_SPL_MUL_16_16(a, b) + ((int32_t) \
(((int32_t)1) << ((c) - 1)))) >> (c))
((WEBRTC_SPL_MUL_16_16(a, b) + ((int32_t)(((int32_t)1) << ((c)-1)))) >> (c))
// C + the 32 most significant bits of A * B
#define WEBRTC_SPL_SCALEDIFF32(A, B, C) \
(C + (B >> 16) * A + (((uint32_t)(B & 0x0000FFFF) * A) >> 16))
(C + (B >> 16) * A + (((uint32_t)(B & 0x0000FFFF) * A) >> 16))
#define WEBRTC_SPL_SAT(a, b, c) (b > a ? a : b < c ? c : b)
#define WEBRTC_SPL_SAT(a, b, c) (b > a ? a : b < c ? c : b)
// Shifting with negative numbers allowed
// Positive means left shift
@ -87,12 +81,11 @@
// Shifting with negative numbers not allowed
// We cannot do casting here due to signed/unsigned problem
#define WEBRTC_SPL_LSHIFT_W32(x, c) ((x) << (c))
#define WEBRTC_SPL_LSHIFT_W32(x, c) ((x) << (c))
#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) \
((int16_t)((((int16_t)a * 18816) >> 7) & 0x00007fff))
#define WEBRTC_SPL_RAND(a) ((int16_t)((((int16_t)a * 18816) >> 7) & 0x00007fff))
#ifdef __cplusplus
extern "C" {
@ -131,13 +124,10 @@ void WebRtcSpl_CopyFromEndW16(const int16_t* in_vector,
size_t in_vector_length,
size_t samples,
int16_t* out_vector);
void WebRtcSpl_ZerosArrayW16(int16_t* vector,
size_t vector_length);
void WebRtcSpl_ZerosArrayW32(int32_t* vector,
size_t vector_length);
void WebRtcSpl_ZerosArrayW16(int16_t* vector, size_t vector_length);
void WebRtcSpl_ZerosArrayW32(int32_t* vector, size_t vector_length);
// End: Copy and set operations.
// Minimum and maximum operation functions and their pointers.
// Implementation in min_max_operations.c.
@ -297,7 +287,6 @@ size_t WebRtcSpl_MinIndexW32(const int32_t* vector, size_t length);
// End: Minimum and maximum operations.
// Vector scaling operations. Implementation in vector_scaling_operations.c.
// Description at bottom of file.
void WebRtcSpl_VectorBitShiftW16(int16_t* out_vector,
@ -323,9 +312,11 @@ void WebRtcSpl_ScaleVectorWithSat(const int16_t* in_vector,
size_t vector_length,
int16_t right_shifts);
void WebRtcSpl_ScaleAndAddVectors(const int16_t* in_vector1,
int16_t gain1, int right_shifts1,
int16_t gain1,
int right_shifts1,
const int16_t* in_vector2,
int16_t gain2, int right_shifts2,
int16_t gain2,
int right_shifts2,
int16_t* out_vector,
size_t vector_length);
@ -777,7 +768,8 @@ typedef struct {
int32_t S_16_8[8];
} WebRtcSpl_State22khzTo8khz;
void WebRtcSpl_Resample22khzTo8khz(const int16_t* in, int16_t* out,
void WebRtcSpl_Resample22khzTo8khz(const int16_t* in,
int16_t* out,
WebRtcSpl_State22khzTo8khz* state,
int32_t* tmpmem);
@ -790,7 +782,8 @@ typedef struct {
int32_t S_11_22[8];
} WebRtcSpl_State8khzTo22khz;
void WebRtcSpl_Resample8khzTo22khz(const int16_t* in, int16_t* out,
void WebRtcSpl_Resample8khzTo22khz(const int16_t* in,
int16_t* out,
WebRtcSpl_State8khzTo22khz* state,
int32_t* tmpmem);
@ -830,7 +823,8 @@ typedef struct {
int32_t S_32_16[8];
} WebRtcSpl_State48khzTo16khz;
void WebRtcSpl_Resample48khzTo16khz(const int16_t* in, int16_t* out,
void WebRtcSpl_Resample48khzTo16khz(const int16_t* in,
int16_t* out,
WebRtcSpl_State48khzTo16khz* state,
int32_t* tmpmem);
@ -842,7 +836,8 @@ typedef struct {
int32_t S_24_48[8];
} WebRtcSpl_State16khzTo48khz;
void WebRtcSpl_Resample16khzTo48khz(const int16_t* in, int16_t* out,
void WebRtcSpl_Resample16khzTo48khz(const int16_t* in,
int16_t* out,
WebRtcSpl_State16khzTo48khz* state,
int32_t* tmpmem);
@ -855,7 +850,8 @@ typedef struct {
int32_t S_16_8[8];
} WebRtcSpl_State48khzTo8khz;
void WebRtcSpl_Resample48khzTo8khz(const int16_t* in, int16_t* out,
void WebRtcSpl_Resample48khzTo8khz(const int16_t* in,
int16_t* out,
WebRtcSpl_State48khzTo8khz* state,
int32_t* tmpmem);
@ -868,7 +864,8 @@ typedef struct {
int32_t S_24_48[8];
} WebRtcSpl_State8khzTo48khz;
void WebRtcSpl_Resample8khzTo48khz(const int16_t* in, int16_t* out,
void WebRtcSpl_Resample8khzTo48khz(const int16_t* in,
int16_t* out,
WebRtcSpl_State8khzTo48khz* state,
int32_t* tmpmem);
@ -881,11 +878,15 @@ void WebRtcSpl_ResetResample8khzTo48khz(WebRtcSpl_State8khzTo48khz* state);
*
******************************************************************/
void WebRtcSpl_DownsampleBy2(const int16_t* in, size_t len,
int16_t* out, int32_t* filtState);
void WebRtcSpl_DownsampleBy2(const int16_t* in,
size_t len,
int16_t* out,
int32_t* filtState);
void WebRtcSpl_UpsampleBy2(const int16_t* in, size_t len,
int16_t* out, int32_t* filtState);
void WebRtcSpl_UpsampleBy2(const int16_t* in,
size_t len,
int16_t* out,
int32_t* filtState);
/************************************************************
* END OF RESAMPLING FUNCTIONS

View File

@ -8,7 +8,6 @@
* be found in the AUTHORS file in the root of the source tree.
*/
// This header file includes the inline functions in
// the fix point signal processing library.
@ -73,7 +72,7 @@ static __inline int WebRtcSpl_CountLeadingZeros64(uint64_t n) {
#if !defined(MIPS_DSP_R1_LE)
static __inline int16_t WebRtcSpl_SatW32ToW16(int32_t value32) {
int16_t out16 = (int16_t) value32;
int16_t out16 = (int16_t)value32;
if (value32 > 32767)
out16 = 32767;
@ -112,11 +111,11 @@ static __inline int32_t WebRtcSpl_SubSatW32(int32_t a, int32_t b) {
}
static __inline int16_t WebRtcSpl_AddSatW16(int16_t a, int16_t b) {
return WebRtcSpl_SatW32ToW16((int32_t) a + (int32_t) b);
return WebRtcSpl_SatW32ToW16((int32_t)a + (int32_t)b);
}
static __inline int16_t WebRtcSpl_SubSatW16(int16_t var1, int16_t var2) {
return WebRtcSpl_SatW32ToW16((int32_t) var1 - (int32_t) var2);
return WebRtcSpl_SatW32ToW16((int32_t)var1 - (int32_t)var2);
}
#endif // #if !defined(MIPS_DSP_R1_LE)

View File

@ -8,7 +8,6 @@
* be found in the AUTHORS file in the root of the source tree.
*/
/* This header file includes the inline functions for ARM processors in
* the fix point signal processing library.
*/
@ -26,35 +25,37 @@
*/
static __inline int32_t WEBRTC_SPL_MUL_16_32_RSFT16(int16_t a, int32_t b) {
int32_t tmp = 0;
__asm __volatile ("smulwb %0, %1, %2":"=r"(tmp):"r"(b), "r"(a));
__asm __volatile("smulwb %0, %1, %2" : "=r"(tmp) : "r"(b), "r"(a));
return tmp;
}
static __inline int32_t WEBRTC_SPL_MUL_16_16(int16_t a, int16_t b) {
int32_t tmp = 0;
__asm __volatile ("smulbb %0, %1, %2":"=r"(tmp):"r"(a), "r"(b));
__asm __volatile("smulbb %0, %1, %2" : "=r"(tmp) : "r"(a), "r"(b));
return tmp;
}
// TODO(kma): add unit test.
static __inline int32_t WebRtc_MulAccumW16(int16_t a, int16_t b, int32_t c) {
int32_t tmp = 0;
__asm __volatile ("smlabb %0, %1, %2, %3":"=r"(tmp):"r"(a), "r"(b), "r"(c));
__asm __volatile("smlabb %0, %1, %2, %3"
: "=r"(tmp)
: "r"(a), "r"(b), "r"(c));
return tmp;
}
static __inline int16_t WebRtcSpl_AddSatW16(int16_t a, int16_t b) {
int32_t s_sum = 0;
__asm __volatile ("qadd16 %0, %1, %2":"=r"(s_sum):"r"(a), "r"(b));
__asm __volatile("qadd16 %0, %1, %2" : "=r"(s_sum) : "r"(a), "r"(b));
return (int16_t) s_sum;
return (int16_t)s_sum;
}
static __inline int32_t WebRtcSpl_AddSatW32(int32_t l_var1, int32_t l_var2) {
int32_t l_sum = 0;
__asm __volatile ("qadd %0, %1, %2":"=r"(l_sum):"r"(l_var1), "r"(l_var2));
__asm __volatile("qadd %0, %1, %2" : "=r"(l_sum) : "r"(l_var1), "r"(l_var2));
return l_sum;
}
@ -62,7 +63,7 @@ static __inline int32_t WebRtcSpl_AddSatW32(int32_t l_var1, int32_t l_var2) {
static __inline int32_t WebRtcSpl_SubSatW32(int32_t l_var1, int32_t l_var2) {
int32_t l_sub = 0;
__asm __volatile ("qsub %0, %1, %2":"=r"(l_sub):"r"(l_var1), "r"(l_var2));
__asm __volatile("qsub %0, %1, %2" : "=r"(l_sub) : "r"(l_var1), "r"(l_var2));
return l_sub;
}
@ -70,7 +71,7 @@ static __inline int32_t WebRtcSpl_SubSatW32(int32_t l_var1, int32_t l_var2) {
static __inline int16_t WebRtcSpl_SubSatW16(int16_t var1, int16_t var2) {
int32_t s_sub = 0;
__asm __volatile ("qsub16 %0, %1, %2":"=r"(s_sub):"r"(var1), "r"(var2));
__asm __volatile("qsub16 %0, %1, %2" : "=r"(s_sub) : "r"(var1), "r"(var2));
return (int16_t)s_sub;
}
@ -78,7 +79,7 @@ static __inline int16_t WebRtcSpl_SubSatW16(int16_t var1, int16_t var2) {
static __inline int16_t WebRtcSpl_GetSizeInBits(uint32_t n) {
int32_t tmp = 0;
__asm __volatile ("clz %0, %1":"=r"(tmp):"r"(n));
__asm __volatile("clz %0, %1" : "=r"(tmp) : "r"(n));
return (int16_t)(32 - tmp);
}
@ -92,7 +93,7 @@ static __inline int16_t WebRtcSpl_NormW32(int32_t a) {
a ^= 0xFFFFFFFF;
}
__asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a));
__asm __volatile("clz %0, %1" : "=r"(tmp) : "r"(a));
return (int16_t)(tmp - 1);
}
@ -100,9 +101,10 @@ static __inline int16_t WebRtcSpl_NormW32(int32_t a) {
static __inline int16_t WebRtcSpl_NormU32(uint32_t a) {
int tmp = 0;
if (a == 0) return 0;
if (a == 0)
return 0;
__asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a));
__asm __volatile("clz %0, %1" : "=r"(tmp) : "r"(a));
return (int16_t)tmp;
}
@ -117,7 +119,7 @@ static __inline int16_t WebRtcSpl_NormW16(int16_t a) {
a_32 ^= 0xFFFFFFFF;
}
__asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a_32));
__asm __volatile("clz %0, %1" : "=r"(tmp) : "r"(a_32));
return (int16_t)(tmp - 17);
}
@ -126,7 +128,7 @@ static __inline int16_t WebRtcSpl_NormW16(int16_t a) {
static __inline int16_t WebRtcSpl_SatW32ToW16(int32_t value32) {
int32_t out = 0;
__asm __volatile ("ssat %0, #16, %1" : "=r"(out) : "r"(value32));
__asm __volatile("ssat %0, #16, %1" : "=r"(out) : "r"(value32));
return (int16_t)out;
}

View File

@ -8,69 +8,65 @@
* be found in the AUTHORS file in the root of the source tree.
*/
// This header file includes the inline functions in
// the fix point signal processing library.
#ifndef COMMON_AUDIO_SIGNAL_PROCESSING_INCLUDE_SPL_INL_MIPS_H_
#define COMMON_AUDIO_SIGNAL_PROCESSING_INCLUDE_SPL_INL_MIPS_H_
static __inline int32_t WEBRTC_SPL_MUL_16_16(int32_t a,
int32_t b) {
static __inline int32_t WEBRTC_SPL_MUL_16_16(int32_t a, int32_t b) {
int32_t value32 = 0;
int32_t a1 = 0, b1 = 0;
__asm __volatile(
#if defined(MIPS32_R2_LE)
"seh %[a1], %[a] \n\t"
"seh %[b1], %[b] \n\t"
"seh %[a1], %[a] \n\t"
"seh %[b1], %[b] \n\t"
#else
"sll %[a1], %[a], 16 \n\t"
"sll %[b1], %[b], 16 \n\t"
"sra %[a1], %[a1], 16 \n\t"
"sra %[b1], %[b1], 16 \n\t"
"sll %[a1], %[a], 16 \n\t"
"sll %[b1], %[b], 16 \n\t"
"sra %[a1], %[a1], 16 \n\t"
"sra %[b1], %[b1], 16 \n\t"
#endif
"mul %[value32], %[a1], %[b1] \n\t"
: [value32] "=r" (value32), [a1] "=&r" (a1), [b1] "=&r" (b1)
: [a] "r" (a), [b] "r" (b)
: "hi", "lo");
"mul %[value32], %[a1], %[b1] \n\t"
: [value32] "=r"(value32), [a1] "=&r"(a1), [b1] "=&r"(b1)
: [a] "r"(a), [b] "r"(b)
: "hi", "lo");
return value32;
}
static __inline int32_t WEBRTC_SPL_MUL_16_32_RSFT16(int16_t a,
int32_t b) {
static __inline int32_t WEBRTC_SPL_MUL_16_32_RSFT16(int16_t a, int32_t b) {
int32_t value32 = 0, b1 = 0, b2 = 0;
int32_t a1 = 0;
__asm __volatile(
#if defined(MIPS32_R2_LE)
"seh %[a1], %[a] \n\t"
"seh %[a1], %[a] \n\t"
#else
"sll %[a1], %[a], 16 \n\t"
"sra %[a1], %[a1], 16 \n\t"
"sll %[a1], %[a], 16 \n\t"
"sra %[a1], %[a1], 16 \n\t"
#endif
"andi %[b2], %[b], 0xFFFF \n\t"
"sra %[b1], %[b], 16 \n\t"
"sra %[b2], %[b2], 1 \n\t"
"mul %[value32], %[a1], %[b1] \n\t"
"mul %[b2], %[a1], %[b2] \n\t"
"addiu %[b2], %[b2], 0x4000 \n\t"
"sra %[b2], %[b2], 15 \n\t"
"addu %[value32], %[value32], %[b2] \n\t"
: [value32] "=&r" (value32), [b1] "=&r" (b1), [b2] "=&r" (b2),
[a1] "=&r" (a1)
: [a] "r" (a), [b] "r" (b)
: "hi", "lo");
"andi %[b2], %[b], 0xFFFF \n\t"
"sra %[b1], %[b], 16 \n\t"
"sra %[b2], %[b2], 1 \n\t"
"mul %[value32], %[a1], %[b1] \n\t"
"mul %[b2], %[a1], %[b2] \n\t"
"addiu %[b2], %[b2], 0x4000 \n\t"
"sra %[b2], %[b2], 15 \n\t"
"addu %[value32], %[value32], %[b2] \n\t"
: [value32] "=&r"(value32), [b1] "=&r"(b1), [b2] "=&r"(b2), [a1] "=&r"(a1)
: [a] "r"(a), [b] "r"(b)
: "hi", "lo");
return value32;
}
#if defined(MIPS_DSP_R1_LE)
static __inline int16_t WebRtcSpl_SatW32ToW16(int32_t value32) {
__asm __volatile(
"shll_s.w %[value32], %[value32], 16 \n\t"
"sra %[value32], %[value32], 16 \n\t"
: [value32] "+r" (value32)
:);
"shll_s.w %[value32], %[value32], 16 \n\t"
"sra %[value32], %[value32], 16 \n\t"
: [value32] "+r"(value32)
:);
int16_t out16 = (int16_t)value32;
return out16;
}
@ -78,10 +74,9 @@ static __inline int16_t WebRtcSpl_SatW32ToW16(int32_t value32) {
static __inline int16_t WebRtcSpl_AddSatW16(int16_t a, int16_t b) {
int32_t value32 = 0;
__asm __volatile(
"addq_s.ph %[value32], %[a], %[b] \n\t"
: [value32] "=r" (value32)
: [a] "r" (a), [b] "r" (b) );
__asm __volatile("addq_s.ph %[value32], %[a], %[b] \n\t"
: [value32] "=r"(value32)
: [a] "r"(a), [b] "r"(b));
return (int16_t)value32;
}
@ -89,9 +84,9 @@ static __inline int32_t WebRtcSpl_AddSatW32(int32_t l_var1, int32_t l_var2) {
int32_t l_sum;
__asm __volatile(
"addq_s.w %[l_sum], %[l_var1], %[l_var2] \n\t"
: [l_sum] "=r" (l_sum)
: [l_var1] "r" (l_var1), [l_var2] "r" (l_var2) );
"addq_s.w %[l_sum], %[l_var1], %[l_var2] \n\t"
: [l_sum] "=r"(l_sum)
: [l_var1] "r"(l_var1), [l_var2] "r"(l_var2));
return l_sum;
}
@ -99,10 +94,9 @@ static __inline int32_t WebRtcSpl_AddSatW32(int32_t l_var1, int32_t l_var2) {
static __inline int16_t WebRtcSpl_SubSatW16(int16_t var1, int16_t var2) {
int32_t value32;
__asm __volatile(
"subq_s.ph %[value32], %[var1], %[var2] \n\t"
: [value32] "=r" (value32)
: [var1] "r" (var1), [var2] "r" (var2) );
__asm __volatile("subq_s.ph %[value32], %[var1], %[var2] \n\t"
: [value32] "=r"(value32)
: [var1] "r"(var1), [var2] "r"(var2));
return (int16_t)value32;
}
@ -111,9 +105,9 @@ static __inline int32_t WebRtcSpl_SubSatW32(int32_t l_var1, int32_t l_var2) {
int32_t l_diff;
__asm __volatile(
"subq_s.w %[l_diff], %[l_var1], %[l_var2] \n\t"
: [l_diff] "=r" (l_diff)
: [l_var1] "r" (l_var1), [l_var2] "r" (l_var2) );
"subq_s.w %[l_diff], %[l_var1], %[l_var2] \n\t"
: [l_diff] "=r"(l_diff)
: [l_var1] "r"(l_var1), [l_var2] "r"(l_var2));
return l_diff;
}
@ -124,10 +118,10 @@ static __inline int16_t WebRtcSpl_GetSizeInBits(uint32_t n) {
int i32 = 32;
__asm __volatile(
"clz %[bits], %[n] \n\t"
"subu %[bits], %[i32], %[bits] \n\t"
: [bits] "=&r" (bits)
: [n] "r" (n), [i32] "r" (i32) );
"clz %[bits], %[n] \n\t"
"subu %[bits], %[i32], %[bits] \n\t"
: [bits] "=&r"(bits)
: [n] "r"(n), [i32] "r"(i32));
return (int16_t)bits;
}
@ -136,20 +130,20 @@ static __inline int16_t WebRtcSpl_NormW32(int32_t a) {
int zeros = 0;
__asm __volatile(
".set push \n\t"
".set noreorder \n\t"
"bnez %[a], 1f \n\t"
" sra %[zeros], %[a], 31 \n\t"
"b 2f \n\t"
" move %[zeros], $zero \n\t"
"1: \n\t"
"xor %[zeros], %[a], %[zeros] \n\t"
"clz %[zeros], %[zeros] \n\t"
"addiu %[zeros], %[zeros], -1 \n\t"
"2: \n\t"
".set pop \n\t"
: [zeros]"=&r"(zeros)
: [a] "r" (a) );
".set push \n\t"
".set noreorder \n\t"
"bnez %[a], 1f \n\t"
" sra %[zeros], %[a], 31 \n\t"
"b 2f \n\t"
" move %[zeros], $zero \n\t"
"1: \n\t"
"xor %[zeros], %[a], %[zeros] \n\t"
"clz %[zeros], %[zeros] \n\t"
"addiu %[zeros], %[zeros], -1 \n\t"
"2: \n\t"
".set pop \n\t"
: [zeros] "=&r"(zeros)
: [a] "r"(a));
return (int16_t)zeros;
}
@ -157,10 +151,9 @@ static __inline int16_t WebRtcSpl_NormW32(int32_t a) {
static __inline int16_t WebRtcSpl_NormU32(uint32_t a) {
int zeros = 0;
__asm __volatile(
"clz %[zeros], %[a] \n\t"
: [zeros] "=r" (zeros)
: [a] "r" (a) );
__asm __volatile("clz %[zeros], %[a] \n\t"
: [zeros] "=r"(zeros)
: [a] "r"(a));
return (int16_t)(zeros & 0x1f);
}
@ -170,43 +163,41 @@ static __inline int16_t WebRtcSpl_NormW16(int16_t a) {
int a0 = a << 16;
__asm __volatile(
".set push \n\t"
".set noreorder \n\t"
"bnez %[a0], 1f \n\t"
" sra %[zeros], %[a0], 31 \n\t"
"b 2f \n\t"
" move %[zeros], $zero \n\t"
"1: \n\t"
"xor %[zeros], %[a0], %[zeros] \n\t"
"clz %[zeros], %[zeros] \n\t"
"addiu %[zeros], %[zeros], -1 \n\t"
"2: \n\t"
".set pop \n\t"
: [zeros]"=&r"(zeros)
: [a0] "r" (a0) );
".set push \n\t"
".set noreorder \n\t"
"bnez %[a0], 1f \n\t"
" sra %[zeros], %[a0], 31 \n\t"
"b 2f \n\t"
" move %[zeros], $zero \n\t"
"1: \n\t"
"xor %[zeros], %[a0], %[zeros] \n\t"
"clz %[zeros], %[zeros] \n\t"
"addiu %[zeros], %[zeros], -1 \n\t"
"2: \n\t"
".set pop \n\t"
: [zeros] "=&r"(zeros)
: [a0] "r"(a0));
return (int16_t)zeros;
}
static __inline int32_t WebRtc_MulAccumW16(int16_t a,
int16_t b,
int32_t c) {
static __inline int32_t WebRtc_MulAccumW16(int16_t a, int16_t b, int32_t c) {
int32_t res = 0, c1 = 0;
__asm __volatile(
#if defined(MIPS32_R2_LE)
"seh %[a], %[a] \n\t"
"seh %[b], %[b] \n\t"
"seh %[a], %[a] \n\t"
"seh %[b], %[b] \n\t"
#else
"sll %[a], %[a], 16 \n\t"
"sll %[b], %[b], 16 \n\t"
"sra %[a], %[a], 16 \n\t"
"sra %[b], %[b], 16 \n\t"
"sll %[a], %[a], 16 \n\t"
"sll %[b], %[b], 16 \n\t"
"sra %[a], %[a], 16 \n\t"
"sra %[b], %[b], 16 \n\t"
#endif
"mul %[res], %[a], %[b] \n\t"
"addu %[c1], %[c], %[res] \n\t"
: [c1] "=r" (c1), [res] "=&r" (res)
: [a] "r" (a), [b] "r" (b), [c] "r" (c)
: "hi", "lo");
"mul %[res], %[a], %[b] \n\t"
"addu %[c1], %[c], %[res] \n\t"
: [c1] "=r"(c1), [res] "=&r"(res)
: [a] "r"(a), [b] "r"(b), [c] "r"(c)
: "hi", "lo");
return (c1);
}