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

Side by Side Diff: webrtc/modules/audio_processing/level_controller/level_controller_unittest.cc

Issue 2283793002: Revert of Added functionality for specifying the initial signal level to use for the gain estimation (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 3 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) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 <vector> 11 #include <vector>
12 12
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "webrtc/base/array_view.h" 14 #include "webrtc/base/array_view.h"
15 #include "webrtc/base/optional.h"
16 #include "webrtc/modules/audio_processing/audio_buffer.h" 15 #include "webrtc/modules/audio_processing/audio_buffer.h"
17 #include "webrtc/modules/audio_processing/include/audio_processing.h" 16 #include "webrtc/modules/audio_processing/include/audio_processing.h"
18 #include "webrtc/modules/audio_processing/level_controller/level_controller.h" 17 #include "webrtc/modules/audio_processing/level_controller/level_controller.h"
19 #include "webrtc/modules/audio_processing/test/audio_buffer_tools.h" 18 #include "webrtc/modules/audio_processing/test/audio_buffer_tools.h"
20 #include "webrtc/modules/audio_processing/test/bitexactness_tools.h" 19 #include "webrtc/modules/audio_processing/test/bitexactness_tools.h"
21 20
22 namespace webrtc { 21 namespace webrtc {
23 namespace { 22 namespace {
24 23
25 const int kNumFramesToProcess = 1000; 24 const int kNumFramesToProcess = 1000;
26 25
27 // Processes a specified amount of frames, verifies the results and reports 26 // Processes a specified amount of frames, verifies the results and reports
28 // any errors. 27 // any errors.
29 void RunBitexactnessTest(int sample_rate_hz, 28 void RunBitexactnessTest(int sample_rate_hz,
30 size_t num_channels, 29 size_t num_channels,
31 rtc::Optional<float> initial_level,
32 rtc::ArrayView<const float> output_reference) { 30 rtc::ArrayView<const float> output_reference) {
33 LevelController level_controller; 31 LevelController level_controller;
34 level_controller.Initialize(sample_rate_hz); 32 level_controller.Initialize(sample_rate_hz);
35 if (initial_level) {
36 level_controller.SetInitialLevel(*initial_level);
37 }
38 33
39 int samples_per_channel = rtc::CheckedDivExact(sample_rate_hz, 100); 34 int samples_per_channel = rtc::CheckedDivExact(sample_rate_hz, 100);
40 const StreamConfig capture_config(sample_rate_hz, num_channels, false); 35 const StreamConfig capture_config(sample_rate_hz, num_channels, false);
41 AudioBuffer capture_buffer( 36 AudioBuffer capture_buffer(
42 capture_config.num_frames(), capture_config.num_channels(), 37 capture_config.num_frames(), capture_config.num_channels(),
43 capture_config.num_frames(), capture_config.num_channels(), 38 capture_config.num_frames(), capture_config.num_channels(),
44 capture_config.num_frames()); 39 capture_config.num_frames());
45 test::InputAudioFile capture_file( 40 test::InputAudioFile capture_file(
46 test::GetApmCaptureTestVectorFileName(sample_rate_hz)); 41 test::GetApmCaptureTestVectorFileName(sample_rate_hz));
47 std::vector<float> capture_input(samples_per_channel * num_channels); 42 std::vector<float> capture_input(samples_per_channel * num_channels);
(...skipping 21 matching lines...) Expand all
69 EXPECT_TRUE(test::VerifyDeinterleavedArray( 64 EXPECT_TRUE(test::VerifyDeinterleavedArray(
70 capture_config.num_frames(), capture_config.num_channels(), 65 capture_config.num_frames(), capture_config.num_channels(),
71 output_reference, capture_output, kVectorElementErrorBound)); 66 output_reference, capture_output, kVectorElementErrorBound));
72 } 67 }
73 68
74 } // namespace 69 } // namespace
75 70
76 TEST(LevelControlBitExactnessTest, DISABLED_Mono8kHz) { 71 TEST(LevelControlBitExactnessTest, DISABLED_Mono8kHz) {
77 const float kOutputReference[] = {-0.013939f, -0.012154f, -0.009054f}; 72 const float kOutputReference[] = {-0.013939f, -0.012154f, -0.009054f};
78 RunBitexactnessTest(AudioProcessing::kSampleRate8kHz, 1, 73 RunBitexactnessTest(AudioProcessing::kSampleRate8kHz, 1,
79 rtc::Optional<float>(), kOutputReference); 74 kOutputReference);
80 } 75 }
81 76
82 TEST(LevelControlBitExactnessTest, DISABLED_Mono16kHz) { 77 TEST(LevelControlBitExactnessTest, DISABLED_Mono16kHz) {
83 const float kOutputReference[] = {-0.013706f, -0.013215f, -0.013018f}; 78 const float kOutputReference[] = {-0.013706f, -0.013215f, -0.013018f};
84 RunBitexactnessTest(AudioProcessing::kSampleRate16kHz, 1, 79 RunBitexactnessTest(AudioProcessing::kSampleRate16kHz, 1,
85 rtc::Optional<float>(), kOutputReference); 80 kOutputReference);
86 } 81 }
87 82
88 TEST(LevelControlBitExactnessTest, DISABLED_Mono32kHz) { 83 TEST(LevelControlBitExactnessTest, DISABLED_Mono32kHz) {
89 const float kOutputReference[] = {-0.014495f, -0.016425f, -0.016085f}; 84 const float kOutputReference[] = {-0.014495f, -0.016425f, -0.016085f};
90 RunBitexactnessTest(AudioProcessing::kSampleRate32kHz, 1, 85 RunBitexactnessTest(AudioProcessing::kSampleRate32kHz, 1,
91 rtc::Optional<float>(), kOutputReference); 86 kOutputReference);
92 } 87 }
93 88
94 // TODO(peah): Investigate why this particular testcase differ between Android 89 // TODO(peah): Investigate why this particular testcase differ between Android
95 // and the rest of the platforms. 90 // and the rest of the platforms.
96 TEST(LevelControlBitExactnessTest, DISABLED_Mono48kHz) { 91 TEST(LevelControlBitExactnessTest, DISABLED_Mono48kHz) {
97 #if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \ 92 #if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
98 defined(WEBRTC_ANDROID)) 93 defined(WEBRTC_ANDROID))
99 const float kOutputReference[] = {-0.014277f, -0.015180f, -0.017437f}; 94 const float kOutputReference[] = {-0.014277f, -0.015180f, -0.017437f};
100 #else 95 #else
101 const float kOutputReference[] = {-0.015949f, -0.016957f, -0.019478f}; 96 const float kOutputReference[] = {-0.015949f, -0.016957f, -0.019478f};
102 #endif 97 #endif
103 RunBitexactnessTest(AudioProcessing::kSampleRate48kHz, 1, 98 RunBitexactnessTest(AudioProcessing::kSampleRate48kHz, 1,
104 rtc::Optional<float>(), kOutputReference); 99 kOutputReference);
105 } 100 }
106 101
107 TEST(LevelControlBitExactnessTest, DISABLED_Stereo8kHz) { 102 TEST(LevelControlBitExactnessTest, DISABLED_Stereo8kHz) {
108 const float kOutputReference[] = {-0.014063f, -0.008450f, -0.012159f, 103 const float kOutputReference[] = {-0.014063f, -0.008450f, -0.012159f,
109 -0.051967f, -0.023202f, -0.047858f}; 104 -0.051967f, -0.023202f, -0.047858f};
110 RunBitexactnessTest(AudioProcessing::kSampleRate8kHz, 2, 105 RunBitexactnessTest(AudioProcessing::kSampleRate8kHz, 2,
111 rtc::Optional<float>(), kOutputReference); 106 kOutputReference);
112 } 107 }
113 108
114 TEST(LevelControlBitExactnessTest, DISABLED_Stereo16kHz) { 109 TEST(LevelControlBitExactnessTest, DISABLED_Stereo16kHz) {
115 const float kOutputReference[] = {-0.012714f, -0.005896f, -0.012220f, 110 const float kOutputReference[] = {-0.012714f, -0.005896f, -0.012220f,
116 -0.053306f, -0.024549f, -0.051527f}; 111 -0.053306f, -0.024549f, -0.051527f};
117 RunBitexactnessTest(AudioProcessing::kSampleRate16kHz, 2, 112 RunBitexactnessTest(AudioProcessing::kSampleRate16kHz, 2,
118 rtc::Optional<float>(), kOutputReference); 113 kOutputReference);
119 } 114 }
120 115
121 TEST(LevelControlBitExactnessTest, DISABLED_Stereo32kHz) { 116 TEST(LevelControlBitExactnessTest, DISABLED_Stereo32kHz) {
122 const float kOutputReference[] = {-0.011737f, -0.007018f, -0.013446f, 117 const float kOutputReference[] = {-0.011737f, -0.007018f, -0.013446f,
123 -0.053505f, -0.026292f, -0.056221f}; 118 -0.053505f, -0.026292f, -0.056221f};
124 RunBitexactnessTest(AudioProcessing::kSampleRate32kHz, 2, 119 RunBitexactnessTest(AudioProcessing::kSampleRate32kHz, 2,
125 rtc::Optional<float>(), kOutputReference); 120 kOutputReference);
126 } 121 }
127 122
128 TEST(LevelControlBitExactnessTest, DISABLED_Stereo48kHz) { 123 TEST(LevelControlBitExactnessTest, DISABLED_Stereo48kHz) {
129 const float kOutputReference[] = {-0.010643f, -0.006334f, -0.011377f, 124 const float kOutputReference[] = {-0.010643f, -0.006334f, -0.011377f,
130 -0.049088f, -0.023600f, -0.050465f}; 125 -0.049088f, -0.023600f, -0.050465f};
131 RunBitexactnessTest(AudioProcessing::kSampleRate48kHz, 2, 126 RunBitexactnessTest(AudioProcessing::kSampleRate48kHz, 2,
132 rtc::Optional<float>(), kOutputReference); 127 kOutputReference);
133 }
134
135 TEST(LevelControlBitExactnessTest, DISABLED_MonoInitial48kHz) {
136 const float kOutputReference[] = {-0.013753f, -0.014623f, -0.016797f};
137 RunBitexactnessTest(AudioProcessing::kSampleRate48kHz, 1,
138 rtc::Optional<float>(2000), kOutputReference);
139 } 128 }
140 129
141 130
142 131
143 } // namespace webrtc 132 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698