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

Side by Side Diff: webrtc/modules/audio_processing/test/test_utils.h

Issue 1316523002: Convert channel counts to size_t. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Fix compile Created 4 years, 11 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) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 RTC_DISALLOW_COPY_AND_ASSIGN(ChannelBufferWavWriter); 72 RTC_DISALLOW_COPY_AND_ASSIGN(ChannelBufferWavWriter);
73 }; 73 };
74 74
75 void WriteIntData(const int16_t* data, 75 void WriteIntData(const int16_t* data,
76 size_t length, 76 size_t length,
77 WavWriter* wav_file, 77 WavWriter* wav_file,
78 RawFile* raw_file); 78 RawFile* raw_file);
79 79
80 void WriteFloatData(const float* const* data, 80 void WriteFloatData(const float* const* data,
81 size_t samples_per_channel, 81 size_t samples_per_channel,
82 int num_channels, 82 size_t num_channels,
83 WavWriter* wav_file, 83 WavWriter* wav_file,
84 RawFile* raw_file); 84 RawFile* raw_file);
85 85
86 // Exits on failure; do not use in unit tests. 86 // Exits on failure; do not use in unit tests.
87 FILE* OpenFile(const std::string& filename, const char* mode); 87 FILE* OpenFile(const std::string& filename, const char* mode);
88 88
89 size_t SamplesFromRate(int rate); 89 size_t SamplesFromRate(int rate);
90 90
91 void SetFrameSampleRate(AudioFrame* frame, 91 void SetFrameSampleRate(AudioFrame* frame,
92 int sample_rate_hz); 92 int sample_rate_hz);
93 93
94 template <typename T> 94 template <typename T>
95 void SetContainerFormat(int sample_rate_hz, 95 void SetContainerFormat(int sample_rate_hz,
96 int num_channels, 96 size_t num_channels,
97 AudioFrame* frame, 97 AudioFrame* frame,
98 rtc::scoped_ptr<ChannelBuffer<T> >* cb) { 98 rtc::scoped_ptr<ChannelBuffer<T> >* cb) {
99 SetFrameSampleRate(frame, sample_rate_hz); 99 SetFrameSampleRate(frame, sample_rate_hz);
100 frame->num_channels_ = num_channels; 100 frame->num_channels_ = num_channels;
101 cb->reset(new ChannelBuffer<T>(frame->samples_per_channel_, num_channels)); 101 cb->reset(new ChannelBuffer<T>(frame->samples_per_channel_, num_channels));
102 } 102 }
103 103
104 AudioProcessing::ChannelLayout LayoutFromChannels(int num_channels); 104 AudioProcessing::ChannelLayout LayoutFromChannels(size_t num_channels);
105 105
106 template <typename T> 106 template <typename T>
107 float ComputeSNR(const T* ref, const T* test, size_t length, float* variance) { 107 float ComputeSNR(const T* ref, const T* test, size_t length, float* variance) {
108 float mse = 0; 108 float mse = 0;
109 float mean = 0; 109 float mean = 0;
110 *variance = 0; 110 *variance = 0;
111 for (size_t i = 0; i < length; ++i) { 111 for (size_t i = 0; i < length; ++i) {
112 T error = ref[i] - test[i]; 112 T error = ref[i] - test[i];
113 mse += error * error; 113 mse += error * error;
114 *variance += ref[i] * ref[i]; 114 *variance += ref[i] * ref[i];
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 // appropriate error message has been printed to stdout. 146 // appropriate error message has been printed to stdout.
147 std::vector<Point> ParseArrayGeometry(const std::string& mic_positions, 147 std::vector<Point> ParseArrayGeometry(const std::string& mic_positions,
148 size_t num_mics); 148 size_t num_mics);
149 149
150 // Same as above, but without the num_mics check for when it isn't available. 150 // Same as above, but without the num_mics check for when it isn't available.
151 std::vector<Point> ParseArrayGeometry(const std::string& mic_positions); 151 std::vector<Point> ParseArrayGeometry(const std::string& mic_positions);
152 152
153 } // namespace webrtc 153 } // namespace webrtc
154 154
155 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_TEST_TEST_UTILS_H_ 155 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_TEST_TEST_UTILS_H_
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/test/process_test.cc ('k') | webrtc/modules/audio_processing/test/test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698