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

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

Issue 2739143002: Revert of Enable cpplint and fix cpplint errors in webrtc/*audio (Closed)
Patch Set: 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, 331 WebRtcSpl_ScaleAndAddVectorsWithRound(b16, 3, b16, 2, 2, bTmp16, kVectorSize );
332 kVectorSize);
333 for (size_t kk = 0; kk < kVectorSize; ++kk) { 332 for (size_t kk = 0; kk < kVectorSize; ++kk) {
334 EXPECT_EQ((B[kk]*3+B[kk]*2+2)>>2, bTmp16[kk]); 333 EXPECT_EQ((B[kk]*3+B[kk]*2+2)>>2, bTmp16[kk]);
335 } 334 }
336 335
337 WebRtcSpl_AddAffineVectorToVector(bTmp16, b16, 3, 7, 2, kVectorSize); 336 WebRtcSpl_AddAffineVectorToVector(bTmp16, b16, 3, 7, 2, kVectorSize);
338 for (size_t kk = 0; kk < kVectorSize; ++kk) { 337 for (size_t kk = 0; kk < kVectorSize; ++kk) {
339 EXPECT_EQ(((B[kk]*3+B[kk]*2+2)>>2)+((b16[kk]*3+7)>>2), bTmp16[kk]); 338 EXPECT_EQ(((B[kk]*3+B[kk]*2+2)>>2)+((b16[kk]*3+7)>>2), bTmp16[kk]);
340 } 339 }
341 340
342 WebRtcSpl_ScaleVector(b16, bTmp16, 13, kVectorSize, 2); 341 WebRtcSpl_ScaleVector(b16, bTmp16, 13, kVectorSize, 2);
343 for (size_t kk = 0; kk < kVectorSize; ++kk) { 342 for (size_t kk = 0; kk < kVectorSize; ++kk) {
344 EXPECT_EQ((b16[kk]*13)>>2, bTmp16[kk]); 343 EXPECT_EQ((b16[kk]*13)>>2, bTmp16[kk]);
345 } 344 }
346 WebRtcSpl_ScaleVectorWithSat(b16, bTmp16, 13, kVectorSize, 2); 345 WebRtcSpl_ScaleVectorWithSat(b16, bTmp16, 13, kVectorSize, 2);
347 for (size_t kk = 0; kk < kVectorSize; ++kk) { 346 for (size_t kk = 0; kk < kVectorSize; ++kk) {
348 EXPECT_EQ((b16[kk]*13)>>2, bTmp16[kk]); 347 EXPECT_EQ((b16[kk]*13)>>2, bTmp16[kk]);
349 } 348 }
350 WebRtcSpl_ScaleAndAddVectors(a16, 13, 2, b16, 7, 2, bTmp16, kVectorSize); 349 WebRtcSpl_ScaleAndAddVectors(a16, 13, 2, b16, 7, 2, bTmp16, kVectorSize);
351 for (size_t kk = 0; kk < kVectorSize; ++kk) { 350 for (size_t kk = 0; kk < kVectorSize; ++kk) {
352 EXPECT_EQ(((a16[kk]*13)>>2)+((b16[kk]*7)>>2), bTmp16[kk]); 351 EXPECT_EQ(((a16[kk]*13)>>2)+((b16[kk]*7)>>2), bTmp16[kk]);
353 } 352 }
354 353
355 WebRtcSpl_AddVectorsAndShift(bTmp16, a16, b16, kVectorSize, 2); 354 WebRtcSpl_AddVectorsAndShift(bTmp16, a16, b16, kVectorSize, 2);
356 for (size_t kk = 0; kk < kVectorSize; ++kk) { 355 for (size_t kk = 0; kk < kVectorSize; ++kk) {
357 EXPECT_EQ(B[kk] >> 1, bTmp16[kk]); 356 EXPECT_EQ(B[kk] >> 1, bTmp16[kk]);
358 } 357 }
359 WebRtcSpl_ReverseOrderMultArrayElements(bTmp16, a16, &b16[3], 358 WebRtcSpl_ReverseOrderMultArrayElements(bTmp16, a16, &b16[3], kVectorSize, 2 );
360 kVectorSize, 2);
361 for (size_t kk = 0; kk < kVectorSize; ++kk) { 359 for (size_t kk = 0; kk < kVectorSize; ++kk) {
362 EXPECT_EQ((a16[kk]*b16[3-kk])>>2, bTmp16[kk]); 360 EXPECT_EQ((a16[kk]*b16[3-kk])>>2, bTmp16[kk]);
363 } 361 }
364 WebRtcSpl_ElementwiseVectorMult(bTmp16, a16, b16, kVectorSize, 6); 362 WebRtcSpl_ElementwiseVectorMult(bTmp16, a16, b16, kVectorSize, 6);
365 for (size_t kk = 0; kk < kVectorSize; ++kk) { 363 for (size_t kk = 0; kk < kVectorSize; ++kk) {
366 EXPECT_EQ((a16[kk]*b16[kk])>>6, bTmp16[kk]); 364 EXPECT_EQ((a16[kk]*b16[kk])>>6, bTmp16[kk]);
367 } 365 }
368 366
369 WebRtcSpl_SqrtOfOneMinusXSquared(b16, kVectorSize, bTmp16); 367 WebRtcSpl_SqrtOfOneMinusXSquared(b16, kVectorSize, bTmp16);
370 for (size_t kk = 0; kk < kVectorSize - 1; ++kk) { 368 for (size_t kk = 0; kk < kVectorSize - 1; ++kk) {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 EXPECT_EQ(0, WebRtcSpl_ComplexFFT(B, 3, 1)); 551 EXPECT_EQ(0, WebRtcSpl_ComplexFFT(B, 3, 1));
554 // for (int kk = 0; kk < 16; ++kk) { 552 // for (int kk = 0; kk < 16; ++kk) {
555 // EXPECT_EQ(A[kk], B[kk]); 553 // EXPECT_EQ(A[kk], B[kk]);
556 // } 554 // }
557 EXPECT_EQ(0, WebRtcSpl_ComplexIFFT(B, 3, 1)); 555 EXPECT_EQ(0, WebRtcSpl_ComplexIFFT(B, 3, 1));
558 // for (int kk = 0; kk < 16; ++kk) { 556 // for (int kk = 0; kk < 16; ++kk) {
559 // EXPECT_EQ(A[kk], B[kk]); 557 // EXPECT_EQ(A[kk], B[kk]);
560 // } 558 // }
561 WebRtcSpl_ComplexBitReverse(B, 3); 559 WebRtcSpl_ComplexBitReverse(B, 3);
562 for (int kk = 0; kk < 16; ++kk) { 560 for (int kk = 0; kk < 16; ++kk) {
563 // EXPECT_EQ(A[kk], B[kk]); 561 //EXPECT_EQ(A[kk], B[kk]);
564 } 562 }
565 } 563 }
566 564
567 TEST_F(SplTest, Resample48WithSaturationTest) { 565 TEST_F(SplTest, Resample48WithSaturationTest) {
568 // The test resamples 3*kBlockSize number of samples to 2*kBlockSize number 566 // The test resamples 3*kBlockSize number of samples to 2*kBlockSize number
569 // of samples. 567 // of samples.
570 const size_t kBlockSize = 16; 568 const size_t kBlockSize = 16;
571 569
572 // Saturated input vector of 48 samples. 570 // Saturated input vector of 48 samples.
573 const int32_t kVectorSaturated[3 * kBlockSize + 7] = { 571 const int32_t kVectorSaturated[3 * kBlockSize + 7] = {
(...skipping 26 matching lines...) Expand all
600 // 12-15 are skipped to account for the filter lag. 598 // 12-15 are skipped to account for the filter lag.
601 for (size_t i = 0; i < 12; ++i) { 599 for (size_t i = 0; i < 12; ++i) {
602 EXPECT_EQ(kRefValue32kHz1, out_vector[i]); 600 EXPECT_EQ(kRefValue32kHz1, out_vector[i]);
603 EXPECT_EQ(kRefValue16kHz1, out_vector_w16[i]); 601 EXPECT_EQ(kRefValue16kHz1, out_vector_w16[i]);
604 } 602 }
605 for (size_t i = 16; i < 2 * kBlockSize; ++i) { 603 for (size_t i = 16; i < 2 * kBlockSize; ++i) {
606 EXPECT_EQ(kRefValue32kHz2, out_vector[i]); 604 EXPECT_EQ(kRefValue32kHz2, out_vector[i]);
607 EXPECT_EQ(kRefValue16kHz2, out_vector_w16[i]); 605 EXPECT_EQ(kRefValue16kHz2, out_vector_w16[i]);
608 } 606 }
609 } 607 }
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