Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(525)

Side by Side Diff: webrtc/modules/audio_processing/aec/aec_resampler.c

Issue 1227213002: Update audio code to use size_t more correctly, webrtc/modules/audio_processing/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Resync Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/aec/aec_resampler.h ('k') | webrtc/modules/audio_processing/aec/echo_cancellation.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698