OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 for (size_t kk = 0; kk < kVectorSize; ++kk) { | 214 for (size_t kk = 0; kk < kVectorSize; ++kk) { |
215 EXPECT_EQ((B[kk]>>1), bTmp32[kk]); | 215 EXPECT_EQ((B[kk]>>1), bTmp32[kk]); |
216 } | 216 } |
217 | 217 |
218 WebRtcSpl_MemCpyReversedOrder(&bTmp16[3], b16, kVectorSize); | 218 WebRtcSpl_MemCpyReversedOrder(&bTmp16[3], b16, kVectorSize); |
219 for (size_t kk = 0; kk < kVectorSize; ++kk) { | 219 for (size_t kk = 0; kk < kVectorSize; ++kk) { |
220 EXPECT_EQ(b16[3-kk], bTmp16[kk]); | 220 EXPECT_EQ(b16[3-kk], bTmp16[kk]); |
221 } | 221 } |
222 } | 222 } |
223 | 223 |
224 TEST_F(SplTest, ExeptionsHandlingMinMaxOperationsTest) { | |
225 // Test how the functions handle exceptional cases. | |
226 const size_t kVectorSize = 2; | |
227 int16_t vector16[kVectorSize] = {0}; | |
228 int32_t vector32[kVectorSize] = {0}; | |
229 | |
230 EXPECT_EQ(-1, WebRtcSpl_MaxAbsValueW16(vector16, 0)); | |
231 EXPECT_EQ(-1, WebRtcSpl_MaxAbsValueW16(NULL, kVectorSize)); | |
232 EXPECT_EQ(WEBRTC_SPL_WORD16_MIN, WebRtcSpl_MaxValueW16(vector16, 0)); | |
233 EXPECT_EQ(WEBRTC_SPL_WORD16_MIN, WebRtcSpl_MaxValueW16(NULL, kVectorSize)); | |
234 EXPECT_EQ(WEBRTC_SPL_WORD16_MAX, WebRtcSpl_MinValueW16(vector16, 0)); | |
235 EXPECT_EQ(WEBRTC_SPL_WORD16_MAX, WebRtcSpl_MinValueW16(NULL, kVectorSize)); | |
236 EXPECT_EQ(-1, WebRtcSpl_MaxAbsValueW32(vector32, 0)); | |
237 EXPECT_EQ(-1, WebRtcSpl_MaxAbsValueW32(NULL, kVectorSize)); | |
238 EXPECT_EQ(WEBRTC_SPL_WORD32_MIN, WebRtcSpl_MaxValueW32(vector32, 0)); | |
239 EXPECT_EQ(WEBRTC_SPL_WORD32_MIN, WebRtcSpl_MaxValueW32(NULL, kVectorSize)); | |
240 EXPECT_EQ(WEBRTC_SPL_WORD32_MAX, WebRtcSpl_MinValueW32(vector32, 0)); | |
241 EXPECT_EQ(WEBRTC_SPL_WORD32_MAX, WebRtcSpl_MinValueW32(NULL, kVectorSize)); | |
242 EXPECT_EQ(-1, WebRtcSpl_MaxAbsIndexW16(vector16, 0)); | |
243 EXPECT_EQ(-1, WebRtcSpl_MaxAbsIndexW16(NULL, kVectorSize)); | |
244 EXPECT_EQ(-1, WebRtcSpl_MaxIndexW16(vector16, 0)); | |
245 EXPECT_EQ(-1, WebRtcSpl_MaxIndexW16(NULL, kVectorSize)); | |
246 EXPECT_EQ(-1, WebRtcSpl_MaxIndexW32(vector32, 0)); | |
247 EXPECT_EQ(-1, WebRtcSpl_MaxIndexW32(NULL, kVectorSize)); | |
248 EXPECT_EQ(-1, WebRtcSpl_MinIndexW16(vector16, 0)); | |
249 EXPECT_EQ(-1, WebRtcSpl_MinIndexW16(NULL, kVectorSize)); | |
250 EXPECT_EQ(-1, WebRtcSpl_MinIndexW32(vector32, 0)); | |
251 EXPECT_EQ(-1, WebRtcSpl_MinIndexW32(NULL, kVectorSize)); | |
252 } | |
253 | |
254 TEST_F(SplTest, MinMaxOperationsTest) { | 224 TEST_F(SplTest, MinMaxOperationsTest) { |
255 const size_t kVectorSize = 17; | 225 const size_t kVectorSize = 17; |
256 | 226 |
257 // Vectors to test the cases where minimum values have to be caught | 227 // Vectors to test the cases where minimum values have to be caught |
258 // outside of the unrolled loops in ARM-Neon. | 228 // outside of the unrolled loops in ARM-Neon. |
259 int16_t vector16[kVectorSize] = {-1, 7485, 0, 3333, | 229 int16_t vector16[kVectorSize] = {-1, 7485, 0, 3333, |
260 -18283, 0, 12334, -29871, 988, -3333, | 230 -18283, 0, 12334, -29871, 988, -3333, |
261 345, -456, 222, 999, 888, 8774, WEBRTC_SPL_WORD16_MIN}; | 231 345, -456, 222, 999, 888, 8774, WEBRTC_SPL_WORD16_MIN}; |
262 int32_t vector32[kVectorSize] = {-1, 0, 283211, 3333, | 232 int32_t vector32[kVectorSize] = {-1, 0, 283211, 3333, |
263 8712345, 0, -3333, 89345, -374585456, 222, 999, 122345334, | 233 8712345, 0, -3333, 89345, -374585456, 222, 999, 122345334, |
264 -12389756, -987329871, 888, -2, WEBRTC_SPL_WORD32_MIN}; | 234 -12389756, -987329871, 888, -2, WEBRTC_SPL_WORD32_MIN}; |
265 | 235 |
266 EXPECT_EQ(WEBRTC_SPL_WORD16_MIN, | 236 EXPECT_EQ(WEBRTC_SPL_WORD16_MIN, |
267 WebRtcSpl_MinValueW16(vector16, kVectorSize)); | 237 WebRtcSpl_MinValueW16(vector16, kVectorSize)); |
268 EXPECT_EQ(WEBRTC_SPL_WORD32_MIN, | 238 EXPECT_EQ(WEBRTC_SPL_WORD32_MIN, |
269 WebRtcSpl_MinValueW32(vector32, kVectorSize)); | 239 WebRtcSpl_MinValueW32(vector32, kVectorSize)); |
270 EXPECT_EQ(static_cast<int>(kVectorSize - 1), | 240 EXPECT_EQ(kVectorSize - 1, WebRtcSpl_MinIndexW16(vector16, kVectorSize)); |
271 WebRtcSpl_MinIndexW16(vector16, kVectorSize)); | 241 EXPECT_EQ(kVectorSize - 1, WebRtcSpl_MinIndexW32(vector32, kVectorSize)); |
272 EXPECT_EQ(static_cast<int>(kVectorSize - 1), | |
273 WebRtcSpl_MinIndexW32(vector32, kVectorSize)); | |
274 | 242 |
275 // Test the cases where maximum values have to be caught | 243 // Test the cases where maximum values have to be caught |
276 // outside of the unrolled loops in ARM-Neon. | 244 // outside of the unrolled loops in ARM-Neon. |
277 vector16[kVectorSize - 1] = WEBRTC_SPL_WORD16_MAX; | 245 vector16[kVectorSize - 1] = WEBRTC_SPL_WORD16_MAX; |
278 vector32[kVectorSize - 1] = WEBRTC_SPL_WORD32_MAX; | 246 vector32[kVectorSize - 1] = WEBRTC_SPL_WORD32_MAX; |
279 | 247 |
280 EXPECT_EQ(WEBRTC_SPL_WORD16_MAX, | 248 EXPECT_EQ(WEBRTC_SPL_WORD16_MAX, |
281 WebRtcSpl_MaxAbsValueW16(vector16, kVectorSize)); | 249 WebRtcSpl_MaxAbsValueW16(vector16, kVectorSize)); |
282 EXPECT_EQ(WEBRTC_SPL_WORD16_MAX, | 250 EXPECT_EQ(WEBRTC_SPL_WORD16_MAX, |
283 WebRtcSpl_MaxValueW16(vector16, kVectorSize)); | 251 WebRtcSpl_MaxValueW16(vector16, kVectorSize)); |
284 EXPECT_EQ(WEBRTC_SPL_WORD32_MAX, | 252 EXPECT_EQ(WEBRTC_SPL_WORD32_MAX, |
285 WebRtcSpl_MaxAbsValueW32(vector32, kVectorSize)); | 253 WebRtcSpl_MaxAbsValueW32(vector32, kVectorSize)); |
286 EXPECT_EQ(WEBRTC_SPL_WORD32_MAX, | 254 EXPECT_EQ(WEBRTC_SPL_WORD32_MAX, |
287 WebRtcSpl_MaxValueW32(vector32, kVectorSize)); | 255 WebRtcSpl_MaxValueW32(vector32, kVectorSize)); |
288 EXPECT_EQ(static_cast<int>(kVectorSize - 1), | 256 EXPECT_EQ(kVectorSize - 1, WebRtcSpl_MaxAbsIndexW16(vector16, kVectorSize)); |
289 WebRtcSpl_MaxAbsIndexW16(vector16, kVectorSize)); | 257 EXPECT_EQ(kVectorSize - 1, WebRtcSpl_MaxIndexW16(vector16, kVectorSize)); |
290 EXPECT_EQ(static_cast<int>(kVectorSize - 1), | 258 EXPECT_EQ(kVectorSize - 1, WebRtcSpl_MaxIndexW32(vector32, kVectorSize)); |
291 WebRtcSpl_MaxIndexW16(vector16, kVectorSize)); | |
292 EXPECT_EQ(static_cast<int>(kVectorSize - 1), | |
293 WebRtcSpl_MaxIndexW32(vector32, kVectorSize)); | |
294 | 259 |
295 // Test the cases where multiple maximum and minimum values are present. | 260 // Test the cases where multiple maximum and minimum values are present. |
296 vector16[1] = WEBRTC_SPL_WORD16_MAX; | 261 vector16[1] = WEBRTC_SPL_WORD16_MAX; |
297 vector16[6] = WEBRTC_SPL_WORD16_MIN; | 262 vector16[6] = WEBRTC_SPL_WORD16_MIN; |
298 vector16[11] = WEBRTC_SPL_WORD16_MIN; | 263 vector16[11] = WEBRTC_SPL_WORD16_MIN; |
299 vector32[1] = WEBRTC_SPL_WORD32_MAX; | 264 vector32[1] = WEBRTC_SPL_WORD32_MAX; |
300 vector32[6] = WEBRTC_SPL_WORD32_MIN; | 265 vector32[6] = WEBRTC_SPL_WORD32_MIN; |
301 vector32[11] = WEBRTC_SPL_WORD32_MIN; | 266 vector32[11] = WEBRTC_SPL_WORD32_MIN; |
302 | 267 |
303 EXPECT_EQ(WEBRTC_SPL_WORD16_MAX, | 268 EXPECT_EQ(WEBRTC_SPL_WORD16_MAX, |
304 WebRtcSpl_MaxAbsValueW16(vector16, kVectorSize)); | 269 WebRtcSpl_MaxAbsValueW16(vector16, kVectorSize)); |
305 EXPECT_EQ(WEBRTC_SPL_WORD16_MAX, | 270 EXPECT_EQ(WEBRTC_SPL_WORD16_MAX, |
306 WebRtcSpl_MaxValueW16(vector16, kVectorSize)); | 271 WebRtcSpl_MaxValueW16(vector16, kVectorSize)); |
307 EXPECT_EQ(WEBRTC_SPL_WORD16_MIN, | 272 EXPECT_EQ(WEBRTC_SPL_WORD16_MIN, |
308 WebRtcSpl_MinValueW16(vector16, kVectorSize)); | 273 WebRtcSpl_MinValueW16(vector16, kVectorSize)); |
309 EXPECT_EQ(WEBRTC_SPL_WORD32_MAX, | 274 EXPECT_EQ(WEBRTC_SPL_WORD32_MAX, |
310 WebRtcSpl_MaxAbsValueW32(vector32, kVectorSize)); | 275 WebRtcSpl_MaxAbsValueW32(vector32, kVectorSize)); |
311 EXPECT_EQ(WEBRTC_SPL_WORD32_MAX, | 276 EXPECT_EQ(WEBRTC_SPL_WORD32_MAX, |
312 WebRtcSpl_MaxValueW32(vector32, kVectorSize)); | 277 WebRtcSpl_MaxValueW32(vector32, kVectorSize)); |
313 EXPECT_EQ(WEBRTC_SPL_WORD32_MIN, | 278 EXPECT_EQ(WEBRTC_SPL_WORD32_MIN, |
314 WebRtcSpl_MinValueW32(vector32, kVectorSize)); | 279 WebRtcSpl_MinValueW32(vector32, kVectorSize)); |
315 EXPECT_EQ(6, WebRtcSpl_MaxAbsIndexW16(vector16, kVectorSize)); | 280 EXPECT_EQ(6u, WebRtcSpl_MaxAbsIndexW16(vector16, kVectorSize)); |
316 EXPECT_EQ(1, WebRtcSpl_MaxIndexW16(vector16, kVectorSize)); | 281 EXPECT_EQ(1u, WebRtcSpl_MaxIndexW16(vector16, kVectorSize)); |
317 EXPECT_EQ(1, WebRtcSpl_MaxIndexW32(vector32, kVectorSize)); | 282 EXPECT_EQ(1u, WebRtcSpl_MaxIndexW32(vector32, kVectorSize)); |
318 EXPECT_EQ(6, WebRtcSpl_MinIndexW16(vector16, kVectorSize)); | 283 EXPECT_EQ(6u, WebRtcSpl_MinIndexW16(vector16, kVectorSize)); |
319 EXPECT_EQ(6, WebRtcSpl_MinIndexW32(vector32, kVectorSize)); | 284 EXPECT_EQ(6u, WebRtcSpl_MinIndexW32(vector32, kVectorSize)); |
320 } | 285 } |
321 | 286 |
322 TEST_F(SplTest, VectorOperationsTest) { | 287 TEST_F(SplTest, VectorOperationsTest) { |
323 const size_t kVectorSize = 4; | 288 const size_t kVectorSize = 4; |
324 int B[] = {4, 12, 133, 1100}; | 289 int B[] = {4, 12, 133, 1100}; |
325 int16_t a16[kVectorSize]; | 290 int16_t a16[kVectorSize]; |
326 int16_t b16[kVectorSize]; | 291 int16_t b16[kVectorSize]; |
327 int16_t bTmp16[kVectorSize]; | 292 int16_t bTmp16[kVectorSize]; |
328 | 293 |
329 for (size_t kk = 0; kk < kVectorSize; ++kk) { | 294 for (size_t kk = 0; kk < kVectorSize; ++kk) { |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 EXPECT_EQ(expected[i], vector32[i]); | 458 EXPECT_EQ(expected[i], vector32[i]); |
494 } | 459 } |
495 } | 460 } |
496 | 461 |
497 TEST_F(SplTest, AutoCorrelationTest) { | 462 TEST_F(SplTest, AutoCorrelationTest) { |
498 int scale = 0; | 463 int scale = 0; |
499 int32_t vector32[kVector16Size]; | 464 int32_t vector32[kVector16Size]; |
500 const int32_t expected[kVector16Size] = {302681398, 14223410, -121705063, | 465 const int32_t expected[kVector16Size] = {302681398, 14223410, -121705063, |
501 -85221647, -17104971, 61806945, 6644603, -669329, 43}; | 466 -85221647, -17104971, 61806945, 6644603, -669329, 43}; |
502 | 467 |
503 EXPECT_EQ(-1, WebRtcSpl_AutoCorrelation(vector16, kVector16Size, | 468 EXPECT_EQ(kVector16Size, |
504 kVector16Size + 1, vector32, &scale)); | |
505 EXPECT_EQ(static_cast<int>(kVector16Size), | |
506 WebRtcSpl_AutoCorrelation(vector16, kVector16Size, | 469 WebRtcSpl_AutoCorrelation(vector16, kVector16Size, |
507 kVector16Size - 1, vector32, &scale)); | 470 kVector16Size - 1, vector32, &scale)); |
508 EXPECT_EQ(3, scale); | 471 EXPECT_EQ(3, scale); |
509 for (size_t i = 0; i < kVector16Size; ++i) { | 472 for (size_t i = 0; i < kVector16Size; ++i) { |
510 EXPECT_EQ(expected[i], vector32[i]); | 473 EXPECT_EQ(expected[i], vector32[i]); |
511 } | 474 } |
512 } | 475 } |
513 | 476 |
514 TEST_F(SplTest, SignalProcessingTest) { | 477 TEST_F(SplTest, SignalProcessingTest) { |
515 const size_t kVectorSize = 4; | 478 const size_t kVectorSize = 4; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 // 12-15 are skipped to account for the filter lag. | 570 // 12-15 are skipped to account for the filter lag. |
608 for (size_t i = 0; i < 12; ++i) { | 571 for (size_t i = 0; i < 12; ++i) { |
609 EXPECT_EQ(kRefValue32kHz1, out_vector[i]); | 572 EXPECT_EQ(kRefValue32kHz1, out_vector[i]); |
610 EXPECT_EQ(kRefValue16kHz1, out_vector_w16[i]); | 573 EXPECT_EQ(kRefValue16kHz1, out_vector_w16[i]); |
611 } | 574 } |
612 for (size_t i = 16; i < 2 * kBlockSize; ++i) { | 575 for (size_t i = 16; i < 2 * kBlockSize; ++i) { |
613 EXPECT_EQ(kRefValue32kHz2, out_vector[i]); | 576 EXPECT_EQ(kRefValue32kHz2, out_vector[i]); |
614 EXPECT_EQ(kRefValue16kHz2, out_vector_w16[i]); | 577 EXPECT_EQ(kRefValue16kHz2, out_vector_w16[i]); |
615 } | 578 } |
616 } | 579 } |
OLD | NEW |