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

Side by Side Diff: webrtc/modules/audio_processing/audio_processing_unittest.cc

Issue 2320053003: webrtc/modules/audio_processing: Use RTC_DCHECK() instead of assert() (Closed)
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) 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 <math.h> 11 #include <math.h>
12 #include <stdio.h> 12 #include <stdio.h>
13 13
14 #include <algorithm> 14 #include <algorithm>
15 #include <limits> 15 #include <limits>
16 #include <memory> 16 #include <memory>
17 #include <queue> 17 #include <queue>
18 18
19 #include "webrtc/base/arraysize.h" 19 #include "webrtc/base/arraysize.h"
20 #include "webrtc/base/checks.h"
20 #include "webrtc/common_audio/include/audio_util.h" 21 #include "webrtc/common_audio/include/audio_util.h"
21 #include "webrtc/common_audio/resampler/include/push_resampler.h" 22 #include "webrtc/common_audio/resampler/include/push_resampler.h"
22 #include "webrtc/common_audio/resampler/push_sinc_resampler.h" 23 #include "webrtc/common_audio/resampler/push_sinc_resampler.h"
23 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" 24 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h"
24 #include "webrtc/modules/audio_processing/beamformer/mock_nonlinear_beamformer.h " 25 #include "webrtc/modules/audio_processing/beamformer/mock_nonlinear_beamformer.h "
25 #include "webrtc/modules/audio_processing/common.h" 26 #include "webrtc/modules/audio_processing/common.h"
26 #include "webrtc/modules/audio_processing/include/audio_processing.h" 27 #include "webrtc/modules/audio_processing/include/audio_processing.h"
27 #include "webrtc/modules/audio_processing/test/protobuf_utils.h" 28 #include "webrtc/modules/audio_processing/test/protobuf_utils.h"
28 #include "webrtc/modules/audio_processing/test/test_utils.h" 29 #include "webrtc/modules/audio_processing/test/test_utils.h"
29 #include "webrtc/modules/include/module_common_types.h" 30 #include "webrtc/modules/include/module_common_types.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 size_t TotalChannelsFromLayout(AudioProcessing::ChannelLayout layout) { 86 size_t TotalChannelsFromLayout(AudioProcessing::ChannelLayout layout) {
86 switch (layout) { 87 switch (layout) {
87 case AudioProcessing::kMono: 88 case AudioProcessing::kMono:
88 return 1; 89 return 1;
89 case AudioProcessing::kMonoAndKeyboard: 90 case AudioProcessing::kMonoAndKeyboard:
90 case AudioProcessing::kStereo: 91 case AudioProcessing::kStereo:
91 return 2; 92 return 2;
92 case AudioProcessing::kStereoAndKeyboard: 93 case AudioProcessing::kStereoAndKeyboard:
93 return 3; 94 return 3;
94 } 95 }
95 assert(false); 96 RTC_NOTREACHED();
96 return 0; 97 return 0;
97 } 98 }
98 99
99 int TruncateToMultipleOf10(int value) { 100 int TruncateToMultipleOf10(int value) {
100 return (value / 10) * 10; 101 return (value / 10) * 10;
101 } 102 }
102 103
103 void MixStereoToMono(const float* stereo, float* mono, 104 void MixStereoToMono(const float* stereo, float* mono,
104 size_t samples_per_channel) { 105 size_t samples_per_channel) {
105 for (size_t i = 0; i < samples_per_channel; ++i) 106 for (size_t i = 0; i < samples_per_channel; ++i)
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 size_t num_reverse_output_channels, 259 size_t num_reverse_output_channels,
259 StreamDirection file_direction) { 260 StreamDirection file_direction) {
260 std::ostringstream ss; 261 std::ostringstream ss;
261 ss << name << "_i" << num_input_channels << "_" << input_rate / 1000 << "_ir" 262 ss << name << "_i" << num_input_channels << "_" << input_rate / 1000 << "_ir"
262 << num_reverse_input_channels << "_" << reverse_input_rate / 1000 << "_"; 263 << num_reverse_input_channels << "_" << reverse_input_rate / 1000 << "_";
263 if (num_output_channels == 1) { 264 if (num_output_channels == 1) {
264 ss << "mono"; 265 ss << "mono";
265 } else if (num_output_channels == 2) { 266 } else if (num_output_channels == 2) {
266 ss << "stereo"; 267 ss << "stereo";
267 } else { 268 } else {
268 assert(false); 269 RTC_NOTREACHED();
269 } 270 }
270 ss << output_rate / 1000; 271 ss << output_rate / 1000;
271 if (num_reverse_output_channels == 1) { 272 if (num_reverse_output_channels == 1) {
272 ss << "_rmono"; 273 ss << "_rmono";
273 } else if (num_reverse_output_channels == 2) { 274 } else if (num_reverse_output_channels == 2) {
274 ss << "_rstereo"; 275 ss << "_rstereo";
275 } else { 276 } else {
276 assert(false); 277 RTC_NOTREACHED();
277 } 278 }
278 ss << reverse_output_rate / 1000; 279 ss << reverse_output_rate / 1000;
279 ss << "_d" << file_direction << "_pcm"; 280 ss << "_d" << file_direction << "_pcm";
280 281
281 std::string filename = ss.str(); 282 std::string filename = ss.str();
282 if (temp_filenames[filename].empty()) 283 if (temp_filenames[filename].empty())
283 temp_filenames[filename] = test::TempFilename(test::OutputPath(), filename); 284 temp_filenames[filename] = test::TempFilename(test::OutputPath(), filename);
284 return temp_filenames[filename]; 285 return temp_filenames[filename];
285 } 286 }
286 287
(...skipping 17 matching lines...) Expand all
304 // 305 //
305 // |int_data| and |float_data| are just temporary space that must be 306 // |int_data| and |float_data| are just temporary space that must be
306 // sufficiently large to hold the 10 ms chunk. 307 // sufficiently large to hold the 10 ms chunk.
307 bool ReadChunk(FILE* file, int16_t* int_data, float* float_data, 308 bool ReadChunk(FILE* file, int16_t* int_data, float* float_data,
308 ChannelBuffer<float>* cb) { 309 ChannelBuffer<float>* cb) {
309 // The files always contain stereo audio. 310 // The files always contain stereo audio.
310 size_t frame_size = cb->num_frames() * 2; 311 size_t frame_size = cb->num_frames() * 2;
311 size_t read_count = fread(int_data, sizeof(int16_t), frame_size, file); 312 size_t read_count = fread(int_data, sizeof(int16_t), frame_size, file);
312 if (read_count != frame_size) { 313 if (read_count != frame_size) {
313 // Check that the file really ended. 314 // Check that the file really ended.
314 assert(feof(file)); 315 RTC_DCHECK(feof(file));
315 return false; // This is expected. 316 return false; // This is expected.
316 } 317 }
317 318
318 S16ToFloat(int_data, frame_size, float_data); 319 S16ToFloat(int_data, frame_size, float_data);
319 if (cb->num_channels() == 1) { 320 if (cb->num_channels() == 1) {
320 MixStereoToMono(float_data, cb->channels()[0], cb->num_frames()); 321 MixStereoToMono(float_data, cb->channels()[0], cb->num_frames());
321 } else { 322 } else {
322 Deinterleave(float_data, cb->num_frames(), 2, 323 Deinterleave(float_data, cb->num_frames(), 2,
323 cb->channels()); 324 cb->channels());
324 } 325 }
(...skipping 2442 matching lines...) Expand 10 before | Expand all | Expand 10 after
2767 std::tr1::make_tuple(16000, 32000, 48000, 32000, 25, 35), 2768 std::tr1::make_tuple(16000, 32000, 48000, 32000, 25, 35),
2768 std::tr1::make_tuple(16000, 32000, 32000, 32000, 25, 0), 2769 std::tr1::make_tuple(16000, 32000, 32000, 32000, 25, 0),
2769 std::tr1::make_tuple(16000, 32000, 16000, 32000, 25, 20), 2770 std::tr1::make_tuple(16000, 32000, 16000, 32000, 25, 20),
2770 std::tr1::make_tuple(16000, 16000, 48000, 16000, 35, 20), 2771 std::tr1::make_tuple(16000, 16000, 48000, 16000, 35, 20),
2771 std::tr1::make_tuple(16000, 16000, 32000, 16000, 35, 20), 2772 std::tr1::make_tuple(16000, 16000, 32000, 16000, 35, 20),
2772 std::tr1::make_tuple(16000, 16000, 16000, 16000, 0, 0))); 2773 std::tr1::make_tuple(16000, 16000, 16000, 16000, 0, 0)));
2773 #endif 2774 #endif
2774 2775
2775 } // namespace 2776 } // namespace
2776 } // namespace webrtc 2777 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/audio_processing_impl.cc ('k') | webrtc/modules/audio_processing/common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698