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:
@ -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
|
||||
|
||||
Reference in New Issue
Block a user