Index: webrtc/common_audio/signal_processing/signal_processing_unittest.cc |
diff --git a/webrtc/common_audio/signal_processing/signal_processing_unittest.cc b/webrtc/common_audio/signal_processing/signal_processing_unittest.cc |
index cc05dfa88fa7f7edf8f40a22c041042cbea4c272..a593c4d5bce6d304efded19a00b1fd2addf111d5 100644 |
--- a/webrtc/common_audio/signal_processing/signal_processing_unittest.cc |
+++ b/webrtc/common_audio/signal_processing/signal_processing_unittest.cc |
@@ -11,7 +11,7 @@ |
#include "testing/gtest/include/gtest/gtest.h" |
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" |
-static const int kVector16Size = 9; |
+static const size_t kVector16Size = 9; |
static const int16_t vector16[kVector16Size] = {1, -15511, 4323, 1963, |
WEBRTC_SPL_WORD16_MAX, 0, WEBRTC_SPL_WORD16_MIN + 5, -3333, 345}; |
@@ -157,7 +157,7 @@ TEST_F(SplTest, MathOperationsTest) { |
} |
TEST_F(SplTest, BasicArrayOperationsTest) { |
- const int kVectorSize = 4; |
+ const size_t kVectorSize = 4; |
int B[] = {4, 12, 133, 1100}; |
int16_t b16[kVectorSize]; |
int32_t b32[kVectorSize]; |
@@ -166,27 +166,27 @@ TEST_F(SplTest, BasicArrayOperationsTest) { |
int32_t bTmp32[kVectorSize]; |
WebRtcSpl_MemSetW16(b16, 3, kVectorSize); |
- for (int kk = 0; kk < kVectorSize; ++kk) { |
+ for (size_t kk = 0; kk < kVectorSize; ++kk) { |
EXPECT_EQ(3, b16[kk]); |
} |
WebRtcSpl_ZerosArrayW16(b16, kVectorSize); |
- for (int kk = 0; kk < kVectorSize; ++kk) { |
+ for (size_t kk = 0; kk < kVectorSize; ++kk) { |
EXPECT_EQ(0, b16[kk]); |
} |
WebRtcSpl_MemSetW32(b32, 3, kVectorSize); |
- for (int kk = 0; kk < kVectorSize; ++kk) { |
+ for (size_t kk = 0; kk < kVectorSize; ++kk) { |
EXPECT_EQ(3, b32[kk]); |
} |
WebRtcSpl_ZerosArrayW32(b32, kVectorSize); |
- for (int kk = 0; kk < kVectorSize; ++kk) { |
+ for (size_t kk = 0; kk < kVectorSize; ++kk) { |
EXPECT_EQ(0, b32[kk]); |
} |
- for (int kk = 0; kk < kVectorSize; ++kk) { |
+ for (size_t kk = 0; kk < kVectorSize; ++kk) { |
bTmp16[kk] = (int16_t)kk; |
bTmp32[kk] = (int32_t)kk; |
} |
WEBRTC_SPL_MEMCPY_W16(b16, bTmp16, kVectorSize); |
- for (int kk = 0; kk < kVectorSize; ++kk) { |
+ for (size_t kk = 0; kk < kVectorSize; ++kk) { |
EXPECT_EQ(b16[kk], bTmp16[kk]); |
} |
// WEBRTC_SPL_MEMCPY_W32(b32, bTmp32, kVectorSize); |
@@ -194,36 +194,36 @@ TEST_F(SplTest, BasicArrayOperationsTest) { |
// EXPECT_EQ(b32[kk], bTmp32[kk]); |
// } |
WebRtcSpl_CopyFromEndW16(b16, kVectorSize, 2, bTmp16); |
- for (int kk = 0; kk < 2; ++kk) { |
- EXPECT_EQ(kk+2, bTmp16[kk]); |
+ for (size_t kk = 0; kk < 2; ++kk) { |
+ EXPECT_EQ(static_cast<int16_t>(kk+2), bTmp16[kk]); |
} |
- for (int kk = 0; kk < kVectorSize; ++kk) { |
+ for (size_t kk = 0; kk < kVectorSize; ++kk) { |
b32[kk] = B[kk]; |
b16[kk] = (int16_t)B[kk]; |
} |
WebRtcSpl_VectorBitShiftW32ToW16(bTmp16, kVectorSize, b32, 1); |
- for (int kk = 0; kk < kVectorSize; ++kk) { |
+ for (size_t kk = 0; kk < kVectorSize; ++kk) { |
EXPECT_EQ((B[kk]>>1), bTmp16[kk]); |
} |
WebRtcSpl_VectorBitShiftW16(bTmp16, kVectorSize, b16, 1); |
- for (int kk = 0; kk < kVectorSize; ++kk) { |
+ for (size_t kk = 0; kk < kVectorSize; ++kk) { |
EXPECT_EQ((B[kk]>>1), bTmp16[kk]); |
} |
WebRtcSpl_VectorBitShiftW32(bTmp32, kVectorSize, b32, 1); |
- for (int kk = 0; kk < kVectorSize; ++kk) { |
+ for (size_t kk = 0; kk < kVectorSize; ++kk) { |
EXPECT_EQ((B[kk]>>1), bTmp32[kk]); |
} |
WebRtcSpl_MemCpyReversedOrder(&bTmp16[3], b16, kVectorSize); |
- for (int kk = 0; kk < kVectorSize; ++kk) { |
+ for (size_t kk = 0; kk < kVectorSize; ++kk) { |
EXPECT_EQ(b16[3-kk], bTmp16[kk]); |
} |
} |
TEST_F(SplTest, ExeptionsHandlingMinMaxOperationsTest) { |
// Test how the functions handle exceptional cases. |
- const int kVectorSize = 2; |
+ const size_t kVectorSize = 2; |
int16_t vector16[kVectorSize] = {0}; |
int32_t vector32[kVectorSize] = {0}; |
@@ -252,7 +252,7 @@ TEST_F(SplTest, ExeptionsHandlingMinMaxOperationsTest) { |
} |
TEST_F(SplTest, MinMaxOperationsTest) { |
- const int kVectorSize = 17; |
+ const size_t kVectorSize = 17; |
// Vectors to test the cases where minimum values have to be caught |
// outside of the unrolled loops in ARM-Neon. |
@@ -267,8 +267,10 @@ TEST_F(SplTest, MinMaxOperationsTest) { |
WebRtcSpl_MinValueW16(vector16, kVectorSize)); |
EXPECT_EQ(WEBRTC_SPL_WORD32_MIN, |
WebRtcSpl_MinValueW32(vector32, kVectorSize)); |
- EXPECT_EQ(kVectorSize - 1, WebRtcSpl_MinIndexW16(vector16, kVectorSize)); |
- EXPECT_EQ(kVectorSize - 1, WebRtcSpl_MinIndexW32(vector32, kVectorSize)); |
+ EXPECT_EQ(static_cast<int>(kVectorSize - 1), |
+ WebRtcSpl_MinIndexW16(vector16, kVectorSize)); |
+ EXPECT_EQ(static_cast<int>(kVectorSize - 1), |
+ WebRtcSpl_MinIndexW32(vector32, kVectorSize)); |
// Test the cases where maximum values have to be caught |
// outside of the unrolled loops in ARM-Neon. |
@@ -283,9 +285,12 @@ TEST_F(SplTest, MinMaxOperationsTest) { |
WebRtcSpl_MaxAbsValueW32(vector32, kVectorSize)); |
EXPECT_EQ(WEBRTC_SPL_WORD32_MAX, |
WebRtcSpl_MaxValueW32(vector32, kVectorSize)); |
- EXPECT_EQ(kVectorSize - 1, WebRtcSpl_MaxAbsIndexW16(vector16, kVectorSize)); |
- EXPECT_EQ(kVectorSize - 1, WebRtcSpl_MaxIndexW16(vector16, kVectorSize)); |
- EXPECT_EQ(kVectorSize - 1, WebRtcSpl_MaxIndexW32(vector32, kVectorSize)); |
+ EXPECT_EQ(static_cast<int>(kVectorSize - 1), |
+ WebRtcSpl_MaxAbsIndexW16(vector16, kVectorSize)); |
+ EXPECT_EQ(static_cast<int>(kVectorSize - 1), |
+ WebRtcSpl_MaxIndexW16(vector16, kVectorSize)); |
+ EXPECT_EQ(static_cast<int>(kVectorSize - 1), |
+ WebRtcSpl_MaxIndexW32(vector32, kVectorSize)); |
// Test the cases where multiple maximum and minimum values are present. |
vector16[1] = WEBRTC_SPL_WORD16_MAX; |
@@ -315,59 +320,59 @@ TEST_F(SplTest, MinMaxOperationsTest) { |
} |
TEST_F(SplTest, VectorOperationsTest) { |
- const int kVectorSize = 4; |
+ const size_t kVectorSize = 4; |
int B[] = {4, 12, 133, 1100}; |
int16_t a16[kVectorSize]; |
int16_t b16[kVectorSize]; |
int16_t bTmp16[kVectorSize]; |
- for (int kk = 0; kk < kVectorSize; ++kk) { |
+ for (size_t kk = 0; kk < kVectorSize; ++kk) { |
a16[kk] = B[kk]; |
b16[kk] = B[kk]; |
} |
WebRtcSpl_AffineTransformVector(bTmp16, b16, 3, 7, 2, kVectorSize); |
- for (int kk = 0; kk < kVectorSize; ++kk) { |
+ for (size_t kk = 0; kk < kVectorSize; ++kk) { |
EXPECT_EQ((B[kk]*3+7)>>2, bTmp16[kk]); |
} |
WebRtcSpl_ScaleAndAddVectorsWithRound(b16, 3, b16, 2, 2, bTmp16, kVectorSize); |
- for (int kk = 0; kk < kVectorSize; ++kk) { |
+ for (size_t kk = 0; kk < kVectorSize; ++kk) { |
EXPECT_EQ((B[kk]*3+B[kk]*2+2)>>2, bTmp16[kk]); |
} |
WebRtcSpl_AddAffineVectorToVector(bTmp16, b16, 3, 7, 2, kVectorSize); |
- for (int kk = 0; kk < kVectorSize; ++kk) { |
+ for (size_t kk = 0; kk < kVectorSize; ++kk) { |
EXPECT_EQ(((B[kk]*3+B[kk]*2+2)>>2)+((b16[kk]*3+7)>>2), bTmp16[kk]); |
} |
WebRtcSpl_ScaleVector(b16, bTmp16, 13, kVectorSize, 2); |
- for (int kk = 0; kk < kVectorSize; ++kk) { |
+ for (size_t kk = 0; kk < kVectorSize; ++kk) { |
EXPECT_EQ((b16[kk]*13)>>2, bTmp16[kk]); |
} |
WebRtcSpl_ScaleVectorWithSat(b16, bTmp16, 13, kVectorSize, 2); |
- for (int kk = 0; kk < kVectorSize; ++kk) { |
+ for (size_t kk = 0; kk < kVectorSize; ++kk) { |
EXPECT_EQ((b16[kk]*13)>>2, bTmp16[kk]); |
} |
WebRtcSpl_ScaleAndAddVectors(a16, 13, 2, b16, 7, 2, bTmp16, kVectorSize); |
- for (int kk = 0; kk < kVectorSize; ++kk) { |
+ for (size_t kk = 0; kk < kVectorSize; ++kk) { |
EXPECT_EQ(((a16[kk]*13)>>2)+((b16[kk]*7)>>2), bTmp16[kk]); |
} |
WebRtcSpl_AddVectorsAndShift(bTmp16, a16, b16, kVectorSize, 2); |
- for (int kk = 0; kk < kVectorSize; ++kk) { |
+ for (size_t kk = 0; kk < kVectorSize; ++kk) { |
EXPECT_EQ(B[kk] >> 1, bTmp16[kk]); |
} |
WebRtcSpl_ReverseOrderMultArrayElements(bTmp16, a16, &b16[3], kVectorSize, 2); |
- for (int kk = 0; kk < kVectorSize; ++kk) { |
+ for (size_t kk = 0; kk < kVectorSize; ++kk) { |
EXPECT_EQ((a16[kk]*b16[3-kk])>>2, bTmp16[kk]); |
} |
WebRtcSpl_ElementwiseVectorMult(bTmp16, a16, b16, kVectorSize, 6); |
- for (int kk = 0; kk < kVectorSize; ++kk) { |
+ for (size_t kk = 0; kk < kVectorSize; ++kk) { |
EXPECT_EQ((a16[kk]*b16[kk])>>6, bTmp16[kk]); |
} |
WebRtcSpl_SqrtOfOneMinusXSquared(b16, kVectorSize, bTmp16); |
- for (int kk = 0; kk < kVectorSize - 1; ++kk) { |
+ for (size_t kk = 0; kk < kVectorSize - 1; ++kk) { |
EXPECT_EQ(32767, bTmp16[kk]); |
} |
EXPECT_EQ(32749, bTmp16[kVectorSize - 1]); |
@@ -376,7 +381,7 @@ TEST_F(SplTest, VectorOperationsTest) { |
} |
TEST_F(SplTest, EstimatorsTest) { |
- const int16_t kOrder = 2; |
+ const size_t kOrder = 2; |
const int32_t unstable_filter[] = { 4, 12, 133, 1100 }; |
const int32_t stable_filter[] = { 1100, 133, 12, 4 }; |
int16_t lpc[kOrder + 2] = { 0 }; |
@@ -386,15 +391,15 @@ TEST_F(SplTest, EstimatorsTest) { |
EXPECT_EQ(0, WebRtcSpl_LevinsonDurbin(unstable_filter, lpc, refl, kOrder)); |
EXPECT_EQ(1, WebRtcSpl_LevinsonDurbin(stable_filter, lpc, refl, kOrder)); |
- for (int i = 0; i < kOrder + 2; ++i) { |
+ for (size_t i = 0; i < kOrder + 2; ++i) { |
EXPECT_EQ(lpc_result[i], lpc[i]); |
EXPECT_EQ(refl_result[i], refl[i]); |
} |
} |
TEST_F(SplTest, FilterTest) { |
- const int kVectorSize = 4; |
- const int kFilterOrder = 3; |
+ const size_t kVectorSize = 4; |
+ const size_t kFilterOrder = 3; |
int16_t A[] = {1, 2, 33, 100}; |
int16_t A5[] = {1, 2, 33, 100, -5}; |
int16_t B[] = {4, 12, 133, 110}; |
@@ -407,7 +412,7 @@ TEST_F(SplTest, FilterTest) { |
WebRtcSpl_ZerosArrayW16(bState, kVectorSize); |
WebRtcSpl_ZerosArrayW16(bStateLow, kVectorSize); |
- for (int kk = 0; kk < kVectorSize; ++kk) { |
+ for (size_t kk = 0; kk < kVectorSize; ++kk) { |
data_in[kk] = A[kk]; |
data_out[kk] = 0; |
} |
@@ -460,10 +465,10 @@ TEST_F(SplTest, DotProductWithScaleTest) { |
TEST_F(SplTest, CrossCorrelationTest) { |
// Note the function arguments relation specificed by API. |
- const int kCrossCorrelationDimension = 3; |
+ const size_t kCrossCorrelationDimension = 3; |
const int kShift = 2; |
const int kStep = 1; |
- const int kSeqDimension = 6; |
+ const size_t kSeqDimension = 6; |
const int16_t kVector16[kVector16Size] = {1, 4323, 1963, |
WEBRTC_SPL_WORD16_MAX, WEBRTC_SPL_WORD16_MIN + 5, -3333, -876, 8483, 142}; |
@@ -484,7 +489,7 @@ TEST_F(SplTest, CrossCorrelationTest) { |
expected = kExpectedNeon; |
} |
#endif |
- for (int i = 0; i < kCrossCorrelationDimension; ++i) { |
+ for (size_t i = 0; i < kCrossCorrelationDimension; ++i) { |
EXPECT_EQ(expected[i], vector32[i]); |
} |
} |
@@ -497,17 +502,17 @@ TEST_F(SplTest, AutoCorrelationTest) { |
EXPECT_EQ(-1, WebRtcSpl_AutoCorrelation(vector16, kVector16Size, |
kVector16Size + 1, vector32, &scale)); |
- EXPECT_EQ(kVector16Size, |
+ EXPECT_EQ(static_cast<int>(kVector16Size), |
WebRtcSpl_AutoCorrelation(vector16, kVector16Size, |
kVector16Size - 1, vector32, &scale)); |
EXPECT_EQ(3, scale); |
- for (int i = 0; i < kVector16Size; ++i) { |
+ for (size_t i = 0; i < kVector16Size; ++i) { |
EXPECT_EQ(expected[i], vector32[i]); |
} |
} |
TEST_F(SplTest, SignalProcessingTest) { |
- const int kVectorSize = 4; |
+ const size_t kVectorSize = 4; |
int A[] = {1, 2, 33, 100}; |
const int16_t kHanning[4] = { 2399, 8192, 13985, 16384 }; |
int16_t b16[kVectorSize]; |
@@ -516,7 +521,7 @@ TEST_F(SplTest, SignalProcessingTest) { |
int bScale = 0; |
- for (int kk = 0; kk < kVectorSize; ++kk) { |
+ for (size_t kk = 0; kk < kVectorSize; ++kk) { |
b16[kk] = A[kk]; |
} |
@@ -535,11 +540,11 @@ TEST_F(SplTest, SignalProcessingTest) { |
//// } |
WebRtcSpl_GetHanningWindow(bTmp16, kVectorSize); |
- for (int kk = 0; kk < kVectorSize; ++kk) { |
+ for (size_t kk = 0; kk < kVectorSize; ++kk) { |
EXPECT_EQ(kHanning[kk], bTmp16[kk]); |
} |
- for (int kk = 0; kk < kVectorSize; ++kk) { |
+ for (size_t kk = 0; kk < kVectorSize; ++kk) { |
b16[kk] = A[kk]; |
} |
EXPECT_EQ(11094 , WebRtcSpl_Energy(b16, kVectorSize, &bScale)); |
@@ -569,7 +574,7 @@ TEST_F(SplTest, FFTTest) { |
TEST_F(SplTest, Resample48WithSaturationTest) { |
// The test resamples 3*kBlockSize number of samples to 2*kBlockSize number |
// of samples. |
- const int kBlockSize = 16; |
+ const size_t kBlockSize = 16; |
// Saturated input vector of 48 samples. |
const int32_t kVectorSaturated[3 * kBlockSize + 7] = { |
@@ -600,11 +605,11 @@ TEST_F(SplTest, Resample48WithSaturationTest) { |
// Comparing output values against references. The values at position |
// 12-15 are skipped to account for the filter lag. |
- for (int i = 0; i < 12; ++i) { |
+ for (size_t i = 0; i < 12; ++i) { |
EXPECT_EQ(kRefValue32kHz1, out_vector[i]); |
EXPECT_EQ(kRefValue16kHz1, out_vector_w16[i]); |
} |
- for (int i = 16; i < 2 * kBlockSize; ++i) { |
+ for (size_t i = 16; i < 2 * kBlockSize; ++i) { |
EXPECT_EQ(kRefValue32kHz2, out_vector[i]); |
EXPECT_EQ(kRefValue16kHz2, out_vector_w16[i]); |
} |