| OLD | NEW |
| 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 /* Resamples a signal to an arbitrary rate. Used by the AEC to compensate for | 11 /* Resamples a signal to an arbitrary rate. Used by the AEC to compensate for |
| 12 * clock skew by resampling the farend signal. | 12 * clock skew by resampling the farend signal. |
| 13 */ | 13 */ |
| 14 | 14 |
| 15 #include "webrtc/modules/audio_processing/aec/aec_resampler.h" | 15 #include "webrtc/modules/audio_processing/aec/aec_resampler.h" |
| 16 | 16 |
| 17 #include <assert.h> | 17 #include <assert.h> |
| 18 #include <math.h> | 18 #include <math.h> |
| 19 #include <stdlib.h> | 19 #include <stdlib.h> |
| 20 #include <string.h> | 20 #include <string.h> |
| 21 | 21 |
| 22 #include "webrtc/modules/audio_processing/aec/aec_core.h" | 22 #include "webrtc/modules/audio_processing/aec/aec_core.h" |
| 23 | 23 |
| 24 namespace webrtc { |
| 25 |
| 24 enum { kEstimateLengthFrames = 400 }; | 26 enum { kEstimateLengthFrames = 400 }; |
| 25 | 27 |
| 26 typedef struct { | 28 typedef struct { |
| 27 float buffer[kResamplerBufferSize]; | 29 float buffer[kResamplerBufferSize]; |
| 28 float position; | 30 float position; |
| 29 | 31 |
| 30 int deviceSampleRateHz; | 32 int deviceSampleRateHz; |
| 31 int skewData[kEstimateLengthFrames]; | 33 int skewData[kEstimateLengthFrames]; |
| 32 int skewDataIndex; | 34 int skewDataIndex; |
| 33 float skewEstimate; | 35 float skewEstimate; |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 xAvg = x / n; | 197 xAvg = x / n; |
| 196 denom = x2 - xAvg * x; | 198 denom = x2 - xAvg * x; |
| 197 | 199 |
| 198 if (denom != 0) { | 200 if (denom != 0) { |
| 199 skew = (xy - xAvg * y) / denom; | 201 skew = (xy - xAvg * y) / denom; |
| 200 } | 202 } |
| 201 | 203 |
| 202 *skewEst = skew; | 204 *skewEst = skew; |
| 203 return 0; | 205 return 0; |
| 204 } | 206 } |
| 207 } // namespace webrtc |
| OLD | NEW |