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 // |test_frame|. It searches around |expected_delay| in samples between the | 42 // |test_frame|. It searches around |expected_delay| in samples between the |
43 // signals to compensate for the resampling delay. | 43 // signals to compensate for the resampling delay. |
44 float ComputeSNR(const ChannelBuffer<float>& ref, | 44 float ComputeSNR(const ChannelBuffer<float>& ref, |
45 const ChannelBuffer<float>& test, | 45 const ChannelBuffer<float>& test, |
46 int expected_delay) { | 46 int expected_delay) { |
47 VerifyParams(ref, test); | 47 VerifyParams(ref, test); |
48 float best_snr = 0; | 48 float best_snr = 0; |
49 int best_delay = 0; | 49 int best_delay = 0; |
50 | 50 |
51 // Search within one sample of the expected delay. | 51 // Search within one sample of the expected delay. |
52 for (int delay = std::max(expected_delay - 1, 0); | 52 for (int delay = std::max(expected_delay, 1) - 1; |
53 delay <= std::min(expected_delay + 1, ref.num_frames()); | 53 delay <= std::min(expected_delay + 1, ref.num_frames()); |
54 ++delay) { | 54 ++delay) { |
55 float mse = 0; | 55 float mse = 0; |
56 float variance = 0; | 56 float variance = 0; |
57 float mean = 0; | 57 float mean = 0; |
58 for (int i = 0; i < ref.num_channels(); ++i) { | 58 for (int i = 0; i < ref.num_channels(); ++i) { |
59 for (int j = 0; j < ref.num_frames() - delay; ++j) { | 59 for (int j = 0; j < ref.num_frames() - delay; ++j) { |
60 float error = ref.channels()[i][j] - test.channels()[i][j + delay]; | 60 float error = ref.channels()[i][j] - test.channels()[i][j + delay]; |
61 mse += error * error; | 61 mse += error * error; |
62 variance += ref.channels()[i][j] * ref.channels()[i][j]; | 62 variance += ref.channels()[i][j] * ref.channels()[i][j]; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 for (int dst_channel = 0; dst_channel < kChannelsSize; ++dst_channel) { | 148 for (int dst_channel = 0; dst_channel < kChannelsSize; ++dst_channel) { |
149 RunAudioConverterTest(kChannels[src_channel], kSampleRates[src_rate], | 149 RunAudioConverterTest(kChannels[src_channel], kSampleRates[src_rate], |
150 kChannels[dst_channel], kSampleRates[dst_rate]); | 150 kChannels[dst_channel], kSampleRates[dst_rate]); |
151 } | 151 } |
152 } | 152 } |
153 } | 153 } |
154 } | 154 } |
155 } | 155 } |
156 | 156 |
157 } // namespace webrtc | 157 } // namespace webrtc |
OLD | NEW |