Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Side by Side Diff: webrtc/common_audio/signal_processing/signal_processing_unittest.cc

Issue 2683033004: Enable cpplint and fix cpplint errors in webrtc/*audio (Closed)
Patch Set: Rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 #include <algorithm> 11 #include <algorithm>
12 #include <sstream> 12 #include <sstream>
13 13
14 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" 14 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h"
15 #include "webrtc/test/gtest.h" 15 #include "webrtc/test/gtest.h"
16 16
17 static const size_t kVector16Size = 9; 17 static const size_t kVector16Size = 9;
18 static const int16_t vector16[kVector16Size] = {1, -15511, 4323, 1963, 18 static const int16_t vector16[kVector16Size] = {1, -15511, 4323, 1963,
19 WEBRTC_SPL_WORD16_MAX, 0, WEBRTC_SPL_WORD16_MIN + 5, -3333, 345}; 19 WEBRTC_SPL_WORD16_MAX, 0, WEBRTC_SPL_WORD16_MIN + 5, -3333, 345};
20 20
21 class SplTest : public testing::Test { 21 class SplTest : public testing::Test {
22 protected: 22 protected:
23 SplTest() { 23 SplTest() {
24 WebRtcSpl_Init(); 24 WebRtcSpl_Init();
25 } 25 }
26 virtual ~SplTest() { 26 virtual ~SplTest() {
27 } 27 }
28 }; 28 };
29 29
30 TEST_F(SplTest, MacroTest) { 30 TEST_F(SplTest, MacroTest) {
31 // Macros with inputs. 31 // Macros with inputs.
32 int A = 10; 32 int A = 10;
33 int B = 21; 33 int B = 21;
34 int a = -3; 34 int a = -3;
35 int b = WEBRTC_SPL_WORD32_MAX; 35 int b = WEBRTC_SPL_WORD32_MAX;
36 36
37 EXPECT_EQ(10, WEBRTC_SPL_MIN(A, B)); 37 EXPECT_EQ(10, WEBRTC_SPL_MIN(A, B));
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 321
322 for (size_t kk = 0; kk < kVectorSize; ++kk) { 322 for (size_t kk = 0; kk < kVectorSize; ++kk) {
323 a16[kk] = B[kk]; 323 a16[kk] = B[kk];
324 b16[kk] = B[kk]; 324 b16[kk] = B[kk];
325 } 325 }
326 326
327 WebRtcSpl_AffineTransformVector(bTmp16, b16, 3, 7, 2, kVectorSize); 327 WebRtcSpl_AffineTransformVector(bTmp16, b16, 3, 7, 2, kVectorSize);
328 for (size_t kk = 0; kk < kVectorSize; ++kk) { 328 for (size_t kk = 0; kk < kVectorSize; ++kk) {
329 EXPECT_EQ((B[kk]*3+7)>>2, bTmp16[kk]); 329 EXPECT_EQ((B[kk]*3+7)>>2, bTmp16[kk]);
330 } 330 }
331 WebRtcSpl_ScaleAndAddVectorsWithRound(b16, 3, b16, 2, 2, bTmp16, kVectorSize ); 331 WebRtcSpl_ScaleAndAddVectorsWithRound(b16, 3, b16, 2, 2, bTmp16,
332 kVectorSize);
332 for (size_t kk = 0; kk < kVectorSize; ++kk) { 333 for (size_t kk = 0; kk < kVectorSize; ++kk) {
333 EXPECT_EQ((B[kk]*3+B[kk]*2+2)>>2, bTmp16[kk]); 334 EXPECT_EQ((B[kk]*3+B[kk]*2+2)>>2, bTmp16[kk]);
334 } 335 }
335 336
336 WebRtcSpl_AddAffineVectorToVector(bTmp16, b16, 3, 7, 2, kVectorSize); 337 WebRtcSpl_AddAffineVectorToVector(bTmp16, b16, 3, 7, 2, kVectorSize);
337 for (size_t kk = 0; kk < kVectorSize; ++kk) { 338 for (size_t kk = 0; kk < kVectorSize; ++kk) {
338 EXPECT_EQ(((B[kk]*3+B[kk]*2+2)>>2)+((b16[kk]*3+7)>>2), bTmp16[kk]); 339 EXPECT_EQ(((B[kk]*3+B[kk]*2+2)>>2)+((b16[kk]*3+7)>>2), bTmp16[kk]);
339 } 340 }
340 341
341 WebRtcSpl_ScaleVector(b16, bTmp16, 13, kVectorSize, 2); 342 WebRtcSpl_ScaleVector(b16, bTmp16, 13, kVectorSize, 2);
342 for (size_t kk = 0; kk < kVectorSize; ++kk) { 343 for (size_t kk = 0; kk < kVectorSize; ++kk) {
343 EXPECT_EQ((b16[kk]*13)>>2, bTmp16[kk]); 344 EXPECT_EQ((b16[kk]*13)>>2, bTmp16[kk]);
344 } 345 }
345 WebRtcSpl_ScaleVectorWithSat(b16, bTmp16, 13, kVectorSize, 2); 346 WebRtcSpl_ScaleVectorWithSat(b16, bTmp16, 13, kVectorSize, 2);
346 for (size_t kk = 0; kk < kVectorSize; ++kk) { 347 for (size_t kk = 0; kk < kVectorSize; ++kk) {
347 EXPECT_EQ((b16[kk]*13)>>2, bTmp16[kk]); 348 EXPECT_EQ((b16[kk]*13)>>2, bTmp16[kk]);
348 } 349 }
349 WebRtcSpl_ScaleAndAddVectors(a16, 13, 2, b16, 7, 2, bTmp16, kVectorSize); 350 WebRtcSpl_ScaleAndAddVectors(a16, 13, 2, b16, 7, 2, bTmp16, kVectorSize);
350 for (size_t kk = 0; kk < kVectorSize; ++kk) { 351 for (size_t kk = 0; kk < kVectorSize; ++kk) {
351 EXPECT_EQ(((a16[kk]*13)>>2)+((b16[kk]*7)>>2), bTmp16[kk]); 352 EXPECT_EQ(((a16[kk]*13)>>2)+((b16[kk]*7)>>2), bTmp16[kk]);
352 } 353 }
353 354
354 WebRtcSpl_AddVectorsAndShift(bTmp16, a16, b16, kVectorSize, 2); 355 WebRtcSpl_AddVectorsAndShift(bTmp16, a16, b16, kVectorSize, 2);
355 for (size_t kk = 0; kk < kVectorSize; ++kk) { 356 for (size_t kk = 0; kk < kVectorSize; ++kk) {
356 EXPECT_EQ(B[kk] >> 1, bTmp16[kk]); 357 EXPECT_EQ(B[kk] >> 1, bTmp16[kk]);
357 } 358 }
358 WebRtcSpl_ReverseOrderMultArrayElements(bTmp16, a16, &b16[3], kVectorSize, 2 ); 359 WebRtcSpl_ReverseOrderMultArrayElements(bTmp16, a16, &b16[3],
360 kVectorSize, 2);
359 for (size_t kk = 0; kk < kVectorSize; ++kk) { 361 for (size_t kk = 0; kk < kVectorSize; ++kk) {
360 EXPECT_EQ((a16[kk]*b16[3-kk])>>2, bTmp16[kk]); 362 EXPECT_EQ((a16[kk]*b16[3-kk])>>2, bTmp16[kk]);
361 } 363 }
362 WebRtcSpl_ElementwiseVectorMult(bTmp16, a16, b16, kVectorSize, 6); 364 WebRtcSpl_ElementwiseVectorMult(bTmp16, a16, b16, kVectorSize, 6);
363 for (size_t kk = 0; kk < kVectorSize; ++kk) { 365 for (size_t kk = 0; kk < kVectorSize; ++kk) {
364 EXPECT_EQ((a16[kk]*b16[kk])>>6, bTmp16[kk]); 366 EXPECT_EQ((a16[kk]*b16[kk])>>6, bTmp16[kk]);
365 } 367 }
366 368
367 WebRtcSpl_SqrtOfOneMinusXSquared(b16, kVectorSize, bTmp16); 369 WebRtcSpl_SqrtOfOneMinusXSquared(b16, kVectorSize, bTmp16);
368 for (size_t kk = 0; kk < kVectorSize - 1; ++kk) { 370 for (size_t kk = 0; kk < kVectorSize - 1; ++kk) {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 EXPECT_EQ(0, WebRtcSpl_ComplexFFT(B, 3, 1)); 553 EXPECT_EQ(0, WebRtcSpl_ComplexFFT(B, 3, 1));
552 // for (int kk = 0; kk < 16; ++kk) { 554 // for (int kk = 0; kk < 16; ++kk) {
553 // EXPECT_EQ(A[kk], B[kk]); 555 // EXPECT_EQ(A[kk], B[kk]);
554 // } 556 // }
555 EXPECT_EQ(0, WebRtcSpl_ComplexIFFT(B, 3, 1)); 557 EXPECT_EQ(0, WebRtcSpl_ComplexIFFT(B, 3, 1));
556 // for (int kk = 0; kk < 16; ++kk) { 558 // for (int kk = 0; kk < 16; ++kk) {
557 // EXPECT_EQ(A[kk], B[kk]); 559 // EXPECT_EQ(A[kk], B[kk]);
558 // } 560 // }
559 WebRtcSpl_ComplexBitReverse(B, 3); 561 WebRtcSpl_ComplexBitReverse(B, 3);
560 for (int kk = 0; kk < 16; ++kk) { 562 for (int kk = 0; kk < 16; ++kk) {
561 //EXPECT_EQ(A[kk], B[kk]); 563 // EXPECT_EQ(A[kk], B[kk]);
562 } 564 }
563 } 565 }
564 566
565 TEST_F(SplTest, Resample48WithSaturationTest) { 567 TEST_F(SplTest, Resample48WithSaturationTest) {
566 // The test resamples 3*kBlockSize number of samples to 2*kBlockSize number 568 // The test resamples 3*kBlockSize number of samples to 2*kBlockSize number
567 // of samples. 569 // of samples.
568 const size_t kBlockSize = 16; 570 const size_t kBlockSize = 16;
569 571
570 // Saturated input vector of 48 samples. 572 // Saturated input vector of 48 samples.
571 const int32_t kVectorSaturated[3 * kBlockSize + 7] = { 573 const int32_t kVectorSaturated[3 * kBlockSize + 7] = {
(...skipping 26 matching lines...) Expand all
598 // 12-15 are skipped to account for the filter lag. 600 // 12-15 are skipped to account for the filter lag.
599 for (size_t i = 0; i < 12; ++i) { 601 for (size_t i = 0; i < 12; ++i) {
600 EXPECT_EQ(kRefValue32kHz1, out_vector[i]); 602 EXPECT_EQ(kRefValue32kHz1, out_vector[i]);
601 EXPECT_EQ(kRefValue16kHz1, out_vector_w16[i]); 603 EXPECT_EQ(kRefValue16kHz1, out_vector_w16[i]);
602 } 604 }
603 for (size_t i = 16; i < 2 * kBlockSize; ++i) { 605 for (size_t i = 16; i < 2 * kBlockSize; ++i) {
604 EXPECT_EQ(kRefValue32kHz2, out_vector[i]); 606 EXPECT_EQ(kRefValue32kHz2, out_vector[i]);
605 EXPECT_EQ(kRefValue16kHz2, out_vector_w16[i]); 607 EXPECT_EQ(kRefValue16kHz2, out_vector_w16[i]);
606 } 608 }
607 } 609 }
OLDNEW
« no previous file with comments | « webrtc/common_audio/signal_processing/resample_by_2_internal.h ('k') | webrtc/common_audio/vad/vad_core.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698