| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 return 0; | 57 return 0; |
| 58 } | 58 } |
| 59 | 59 |
| 60 void WebRtcAec_FreeResampler(void* resampInst) { | 60 void WebRtcAec_FreeResampler(void* resampInst) { |
| 61 AecResampler* obj = (AecResampler*)resampInst; | 61 AecResampler* obj = (AecResampler*)resampInst; |
| 62 free(obj); | 62 free(obj); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void WebRtcAec_ResampleLinear(void* resampInst, | 65 void WebRtcAec_ResampleLinear(void* resampInst, |
| 66 const float* inspeech, | 66 const float* inspeech, |
| 67 int size, | 67 size_t size, |
| 68 float skew, | 68 float skew, |
| 69 float* outspeech, | 69 float* outspeech, |
| 70 int* size_out) { | 70 size_t* size_out) { |
| 71 AecResampler* obj = (AecResampler*)resampInst; | 71 AecResampler* obj = (AecResampler*)resampInst; |
| 72 | 72 |
| 73 float* y; | 73 float* y; |
| 74 float be, tnew; | 74 float be, tnew; |
| 75 int tn, mm; | 75 size_t tn, mm; |
| 76 | 76 |
| 77 assert(size >= 0); | |
| 78 assert(size <= 2 * FRAME_LEN); | 77 assert(size <= 2 * FRAME_LEN); |
| 79 assert(resampInst != NULL); | 78 assert(resampInst != NULL); |
| 80 assert(inspeech != NULL); | 79 assert(inspeech != NULL); |
| 81 assert(outspeech != NULL); | 80 assert(outspeech != NULL); |
| 82 assert(size_out != NULL); | 81 assert(size_out != NULL); |
| 83 | 82 |
| 84 // Add new frame data in lookahead | 83 // Add new frame data in lookahead |
| 85 memcpy(&obj->buffer[FRAME_LEN + kResamplingDelay], | 84 memcpy(&obj->buffer[FRAME_LEN + kResamplingDelay], |
| 86 inspeech, | 85 inspeech, |
| 87 size * sizeof(inspeech[0])); | 86 size * sizeof(inspeech[0])); |
| 88 | 87 |
| 89 // Sample rate ratio | 88 // Sample rate ratio |
| 90 be = 1 + skew; | 89 be = 1 + skew; |
| 91 | 90 |
| 92 // Loop over input frame | 91 // Loop over input frame |
| 93 mm = 0; | 92 mm = 0; |
| 94 y = &obj->buffer[FRAME_LEN]; // Point at current frame | 93 y = &obj->buffer[FRAME_LEN]; // Point at current frame |
| 95 | 94 |
| 96 tnew = be * mm + obj->position; | 95 tnew = be * mm + obj->position; |
| 97 tn = (int)tnew; | 96 tn = (size_t)tnew; |
| 98 | 97 |
| 99 while (tn < size) { | 98 while (tn < size) { |
| 100 | 99 |
| 101 // Interpolation | 100 // Interpolation |
| 102 outspeech[mm] = y[tn] + (tnew - tn) * (y[tn + 1] - y[tn]); | 101 outspeech[mm] = y[tn] + (tnew - tn) * (y[tn + 1] - y[tn]); |
| 103 mm++; | 102 mm++; |
| 104 | 103 |
| 105 tnew = be * mm + obj->position; | 104 tnew = be * mm + obj->position; |
| 106 tn = (int)tnew; | 105 tn = (int)tnew; |
| 107 } | 106 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 xAvg = x / n; | 200 xAvg = x / n; |
| 202 denom = x2 - xAvg * x; | 201 denom = x2 - xAvg * x; |
| 203 | 202 |
| 204 if (denom != 0) { | 203 if (denom != 0) { |
| 205 skew = (xy - xAvg * y) / denom; | 204 skew = (xy - xAvg * y) / denom; |
| 206 } | 205 } |
| 207 | 206 |
| 208 *skewEst = skew; | 207 *skewEst = skew; |
| 209 return 0; | 208 return 0; |
| 210 } | 209 } |
| OLD | NEW |