| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 DISALLOW_COPY_AND_ASSIGN(RawFile); | 43 DISALLOW_COPY_AND_ASSIGN(RawFile); |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 void WriteIntData(const int16_t* data, | 46 void WriteIntData(const int16_t* data, |
| 47 size_t length, | 47 size_t length, |
| 48 WavWriter* wav_file, | 48 WavWriter* wav_file, |
| 49 RawFile* raw_file); | 49 RawFile* raw_file); |
| 50 | 50 |
| 51 void WriteFloatData(const float* const* data, | 51 void WriteFloatData(const float* const* data, |
| 52 int samples_per_channel, | 52 size_t samples_per_channel, |
| 53 int num_channels, | 53 size_t num_channels, |
| 54 WavWriter* wav_file, | 54 WavWriter* wav_file, |
| 55 RawFile* raw_file); | 55 RawFile* raw_file); |
| 56 | 56 |
| 57 // Exits on failure; do not use in unit tests. | 57 // Exits on failure; do not use in unit tests. |
| 58 FILE* OpenFile(const std::string& filename, const char* mode); | 58 FILE* OpenFile(const std::string& filename, const char* mode); |
| 59 | 59 |
| 60 int SamplesFromRate(int rate); | 60 int SamplesFromRate(int rate); |
| 61 | 61 |
| 62 void SetFrameSampleRate(AudioFrame* frame, | 62 void SetFrameSampleRate(AudioFrame* frame, |
| 63 int sample_rate_hz); | 63 int sample_rate_hz); |
| 64 | 64 |
| 65 template <typename T> | 65 template <typename T> |
| 66 void SetContainerFormat(int sample_rate_hz, | 66 void SetContainerFormat(int sample_rate_hz, |
| 67 int num_channels, | 67 size_t num_channels, |
| 68 AudioFrame* frame, | 68 AudioFrame* frame, |
| 69 rtc::scoped_ptr<ChannelBuffer<T> >* cb) { | 69 rtc::scoped_ptr<ChannelBuffer<T> >* cb) { |
| 70 SetFrameSampleRate(frame, sample_rate_hz); | 70 SetFrameSampleRate(frame, sample_rate_hz); |
| 71 frame->num_channels_ = num_channels; | 71 frame->num_channels_ = num_channels; |
| 72 cb->reset(new ChannelBuffer<T>(frame->samples_per_channel_, num_channels)); | 72 cb->reset(new ChannelBuffer<T>(frame->samples_per_channel_, num_channels)); |
| 73 } | 73 } |
| 74 | 74 |
| 75 AudioProcessing::ChannelLayout LayoutFromChannels(int num_channels); | 75 AudioProcessing::ChannelLayout LayoutFromChannels(size_t num_channels); |
| 76 | 76 |
| 77 template <typename T> | 77 template <typename T> |
| 78 float ComputeSNR(const T* ref, const T* test, int length, float* variance) { | 78 float ComputeSNR(const T* ref, const T* test, size_t length, float* variance) { |
| 79 float mse = 0; | 79 float mse = 0; |
| 80 float mean = 0; | 80 float mean = 0; |
| 81 *variance = 0; | 81 *variance = 0; |
| 82 for (int i = 0; i < length; ++i) { | 82 for (size_t i = 0; i < length; ++i) { |
| 83 T error = ref[i] - test[i]; | 83 T error = ref[i] - test[i]; |
| 84 mse += error * error; | 84 mse += error * error; |
| 85 *variance += ref[i] * ref[i]; | 85 *variance += ref[i] * ref[i]; |
| 86 mean += ref[i]; | 86 mean += ref[i]; |
| 87 } | 87 } |
| 88 mse /= length; | 88 mse /= length; |
| 89 *variance /= length; | 89 *variance /= length; |
| 90 mean /= length; | 90 mean /= length; |
| 91 *variance -= mean * mean; | 91 *variance -= mean * mean; |
| 92 | 92 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 114 // Parses the array geometry from the command line. | 114 // Parses the array geometry from the command line. |
| 115 // | 115 // |
| 116 // If a vector with size != num_mics is returned, an error has occurred and an | 116 // If a vector with size != num_mics is returned, an error has occurred and an |
| 117 // appropriate error message has been printed to stdout. | 117 // appropriate error message has been printed to stdout. |
| 118 std::vector<Point> ParseArrayGeometry(const std::string& mic_positions, | 118 std::vector<Point> ParseArrayGeometry(const std::string& mic_positions, |
| 119 size_t num_mics); | 119 size_t num_mics); |
| 120 | 120 |
| 121 } // namespace webrtc | 121 } // namespace webrtc |
| 122 | 122 |
| 123 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_TEST_TEST_UTILS_H_ | 123 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_TEST_TEST_UTILS_H_ |
| OLD | NEW |