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

Side by Side Diff: webrtc/modules/audio_mixer/frame_combiner_unittest.cc

Issue 2776113002: Send data from mixer to APM limiter more often. (Closed)
Patch Set: wip Created 3 years, 8 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) 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2017 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 for (const int number_of_channels : {1, 2}) { 50 for (const int number_of_channels : {1, 2}) {
51 const std::vector<AudioFrame*> all_frames = {&frame1, &frame2}; 51 const std::vector<AudioFrame*> all_frames = {&frame1, &frame2};
52 SetUpFrames(rate, number_of_channels); 52 SetUpFrames(rate, number_of_channels);
53 53
54 for (const int number_of_frames : {0, 1, 2}) { 54 for (const int number_of_frames : {0, 1, 2}) {
55 SCOPED_TRACE( 55 SCOPED_TRACE(
56 ProduceDebugText(rate, number_of_channels, number_of_frames)); 56 ProduceDebugText(rate, number_of_channels, number_of_frames));
57 const std::vector<AudioFrame*> frames_to_combine( 57 const std::vector<AudioFrame*> frames_to_combine(
58 all_frames.begin(), all_frames.begin() + number_of_frames); 58 all_frames.begin(), all_frames.begin() + number_of_frames);
59 combiner.Combine(frames_to_combine, number_of_channels, rate, 59 combiner.Combine(frames_to_combine, number_of_channels, rate,
60 &audio_frame_for_mixing); 60 frames_to_combine.size(), &audio_frame_for_mixing);
61 } 61 }
62 } 62 }
63 } 63 }
64 } 64 }
65 65
66 // No APM limiter means no AudioProcessing::NativeRate restriction 66 // No APM limiter means no AudioProcessing::NativeRate restriction
67 // on rate. The rate has to be divisible by 100 since we use 67 // on rate. The rate has to be divisible by 100 since we use
68 // 10 ms frames, though. 68 // 10 ms frames, though.
69 TEST(FrameCombiner, BasicApiCallsNoLimiter) { 69 TEST(FrameCombiner, BasicApiCallsNoLimiter) {
70 FrameCombiner combiner(false); 70 FrameCombiner combiner(false);
71 for (const int rate : {8000, 10000, 11000, 32000, 44100}) { 71 for (const int rate : {8000, 10000, 11000, 32000, 44100}) {
72 for (const int number_of_channels : {1, 2}) { 72 for (const int number_of_channels : {1, 2}) {
73 const std::vector<AudioFrame*> all_frames = {&frame1, &frame2}; 73 const std::vector<AudioFrame*> all_frames = {&frame1, &frame2};
74 SetUpFrames(rate, number_of_channels); 74 SetUpFrames(rate, number_of_channels);
75 75
76 for (const int number_of_frames : {0, 1, 2}) { 76 for (const int number_of_frames : {0, 1, 2}) {
77 SCOPED_TRACE( 77 SCOPED_TRACE(
78 ProduceDebugText(rate, number_of_channels, number_of_frames)); 78 ProduceDebugText(rate, number_of_channels, number_of_frames));
79 const std::vector<AudioFrame*> frames_to_combine( 79 const std::vector<AudioFrame*> frames_to_combine(
80 all_frames.begin(), all_frames.begin() + number_of_frames); 80 all_frames.begin(), all_frames.begin() + number_of_frames);
81 combiner.Combine(frames_to_combine, number_of_channels, rate, 81 combiner.Combine(frames_to_combine, number_of_channels, rate,
82 &audio_frame_for_mixing); 82 frames_to_combine.size(), &audio_frame_for_mixing);
83 } 83 }
84 } 84 }
85 } 85 }
86 } 86 }
87 87
88 TEST(FrameCombiner, CombiningZeroFramesShouldProduceSilence) { 88 TEST(FrameCombiner, CombiningZeroFramesShouldProduceSilence) {
89 FrameCombiner combiner(false); 89 FrameCombiner combiner(false);
90 for (const int rate : {8000, 10000, 11000, 32000, 44100}) { 90 for (const int rate : {8000, 10000, 11000, 32000, 44100}) {
91 for (const int number_of_channels : {1, 2}) { 91 for (const int number_of_channels : {1, 2}) {
92 SCOPED_TRACE(ProduceDebugText(rate, number_of_channels, 0)); 92 SCOPED_TRACE(ProduceDebugText(rate, number_of_channels, 0));
93 93
94 const std::vector<AudioFrame*> frames_to_combine; 94 const std::vector<AudioFrame*> frames_to_combine;
95 combiner.Combine(frames_to_combine, number_of_channels, rate, 95 combiner.Combine(frames_to_combine, number_of_channels, rate,
96 &audio_frame_for_mixing); 96 frames_to_combine.size(), &audio_frame_for_mixing);
97 97
98 const std::vector<int16_t> mixed_data( 98 const std::vector<int16_t> mixed_data(
99 audio_frame_for_mixing.data_, 99 audio_frame_for_mixing.data_,
100 audio_frame_for_mixing.data_ + number_of_channels * rate / 100); 100 audio_frame_for_mixing.data_ + number_of_channels * rate / 100);
101 101
102 const std::vector<int16_t> expected(number_of_channels * rate / 100, 0); 102 const std::vector<int16_t> expected(number_of_channels * rate / 100, 0);
103 EXPECT_EQ(mixed_data, expected); 103 EXPECT_EQ(mixed_data, expected);
104 } 104 }
105 } 105 }
106 } 106 }
107 107
108 TEST(FrameCombiner, CombiningOneFrameShouldNotChangeFrame) { 108 TEST(FrameCombiner, CombiningOneFrameShouldNotChangeFrame) {
109 FrameCombiner combiner(false); 109 FrameCombiner combiner(false);
110 for (const int rate : {8000, 10000, 11000, 32000, 44100}) { 110 for (const int rate : {8000, 10000, 11000, 32000, 44100}) {
111 for (const int number_of_channels : {1, 2}) { 111 for (const int number_of_channels : {1, 2}) {
112 SCOPED_TRACE(ProduceDebugText(rate, number_of_channels, 1)); 112 SCOPED_TRACE(ProduceDebugText(rate, number_of_channels, 1));
113 113
114 SetUpFrames(rate, number_of_channels); 114 SetUpFrames(rate, number_of_channels);
115 std::iota(frame1.data_, frame1.data_ + number_of_channels * rate / 100, 115 std::iota(frame1.data_, frame1.data_ + number_of_channels * rate / 100,
116 0); 116 0);
117 const std::vector<AudioFrame*> frames_to_combine = {&frame1}; 117 const std::vector<AudioFrame*> frames_to_combine = {&frame1};
118 combiner.Combine(frames_to_combine, number_of_channels, rate, 118 combiner.Combine(frames_to_combine, number_of_channels, rate,
119 &audio_frame_for_mixing); 119 frames_to_combine.size(), &audio_frame_for_mixing);
120 120
121 const std::vector<int16_t> mixed_data( 121 const std::vector<int16_t> mixed_data(
122 audio_frame_for_mixing.data_, 122 audio_frame_for_mixing.data_,
123 audio_frame_for_mixing.data_ + number_of_channels * rate / 100); 123 audio_frame_for_mixing.data_ + number_of_channels * rate / 100);
124 124
125 std::vector<int16_t> expected(number_of_channels * rate / 100); 125 std::vector<int16_t> expected(number_of_channels * rate / 100);
126 std::iota(expected.begin(), expected.end(), 0); 126 std::iota(expected.begin(), expected.end(), 0);
127 EXPECT_EQ(mixed_data, expected); 127 EXPECT_EQ(mixed_data, expected);
128 } 128 }
129 } 129 }
130 } 130 }
131 131
132 } // namespace webrtc 132 } // namespace webrtc
OLDNEW
« webrtc/modules/audio_mixer/frame_combiner.cc ('K') | « webrtc/modules/audio_mixer/frame_combiner.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698