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

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

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

Powered by Google App Engine
This is Rietveld 408576698