OLD | NEW |
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
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 int samples_per_channel, | 81 size_t samples_per_channel, |
82 int num_channels, | 82 int 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 int 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 int 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(int num_channels); |
105 | 105 |
106 template <typename T> | 106 template <typename T> |
107 float ComputeSNR(const T* ref, const T* test, int 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 (int 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]; |
115 mean += ref[i]; | 115 mean += ref[i]; |
116 } | 116 } |
117 mse /= length; | 117 mse /= length; |
118 *variance /= length; | 118 *variance /= length; |
119 mean /= length; | 119 mean /= length; |
120 *variance -= mean * mean; | 120 *variance -= mean * mean; |
121 | 121 |
(...skipping 24 matching lines...) Expand all Loading... |
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_ |
OLD | NEW |