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 |
(...skipping 22 matching lines...) Expand all Loading... |
33 int skewData[kEstimateLengthFrames]; | 33 int skewData[kEstimateLengthFrames]; |
34 int skewDataIndex; | 34 int skewDataIndex; |
35 float skewEstimate; | 35 float skewEstimate; |
36 } AecResampler; | 36 } AecResampler; |
37 | 37 |
38 static int EstimateSkew(const int* rawSkew, | 38 static int EstimateSkew(const int* rawSkew, |
39 int size, | 39 int size, |
40 int absLimit, | 40 int absLimit, |
41 float* skewEst); | 41 float* skewEst); |
42 | 42 |
43 int WebRtcAec_CreateResampler(void** resampInst) { | 43 void* WebRtcAec_CreateResampler() { |
44 AecResampler* obj = malloc(sizeof(AecResampler)); | 44 return malloc(sizeof(AecResampler)); |
45 *resampInst = obj; | |
46 if (obj == NULL) { | |
47 return -1; | |
48 } | |
49 | |
50 return 0; | |
51 } | 45 } |
52 | 46 |
53 int WebRtcAec_InitResampler(void* resampInst, int deviceSampleRateHz) { | 47 int WebRtcAec_InitResampler(void* resampInst, int deviceSampleRateHz) { |
54 AecResampler* obj = (AecResampler*)resampInst; | 48 AecResampler* obj = (AecResampler*)resampInst; |
55 memset(obj->buffer, 0, sizeof(obj->buffer)); | 49 memset(obj->buffer, 0, sizeof(obj->buffer)); |
56 obj->position = 0.0; | 50 obj->position = 0.0; |
57 | 51 |
58 obj->deviceSampleRateHz = deviceSampleRateHz; | 52 obj->deviceSampleRateHz = deviceSampleRateHz; |
59 memset(obj->skewData, 0, sizeof(obj->skewData)); | 53 memset(obj->skewData, 0, sizeof(obj->skewData)); |
60 obj->skewDataIndex = 0; | 54 obj->skewDataIndex = 0; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 xAvg = x / n; | 200 xAvg = x / n; |
207 denom = x2 - xAvg * x; | 201 denom = x2 - xAvg * x; |
208 | 202 |
209 if (denom != 0) { | 203 if (denom != 0) { |
210 skew = (xy - xAvg * y) / denom; | 204 skew = (xy - xAvg * y) / denom; |
211 } | 205 } |
212 | 206 |
213 *skewEst = skew; | 207 *skewEst = skew; |
214 return 0; | 208 return 0; |
215 } | 209 } |
OLD | NEW |