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

Side by Side Diff: webrtc/modules/audio_coding/codecs/isac/fix/source/pitch_filter.c

Issue 1174813003: Prepare to convert various types to size_t. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Review comments + resync Created 5 years, 6 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 int16_t* gainsQ12, 62 int16_t* gainsQ12,
63 int16_t type) { 63 int16_t type) {
64 int k, ind, cnt; 64 int k, ind, cnt;
65 int16_t sign = 1; 65 int16_t sign = 1;
66 int16_t inystateQQ[PITCH_DAMPORDER]; 66 int16_t inystateQQ[PITCH_DAMPORDER];
67 int16_t ubufQQ[PITCH_INTBUFFSIZE + QLOOKAHEAD]; 67 int16_t ubufQQ[PITCH_INTBUFFSIZE + QLOOKAHEAD];
68 const int16_t Gain = 21299; // 1.3 in Q14 68 const int16_t Gain = 21299; // 1.3 in Q14
69 int16_t oldLagQ7; 69 int16_t oldLagQ7;
70 int16_t oldGainQ12, lagdeltaQ7, curLagQ7, gaindeltaQ12, curGainQ12; 70 int16_t oldGainQ12, lagdeltaQ7, curLagQ7, gaindeltaQ12, curGainQ12;
71 int indW32 = 0, frcQQ = 0; 71 int indW32 = 0, frcQQ = 0;
72 int32_t tmpW32;
73 const int16_t* fracoeffQQ = NULL; 72 const int16_t* fracoeffQQ = NULL;
74 73
75 // Assumptions in ARM assembly for WebRtcIsacfix_PitchFilterCoreARM(). 74 // Assumptions in ARM assembly for WebRtcIsacfix_PitchFilterCoreARM().
76 COMPILE_ASSERT(PITCH_FRACORDER == 9); 75 COMPILE_ASSERT(PITCH_FRACORDER == 9);
77 COMPILE_ASSERT(PITCH_DAMPORDER == 5); 76 COMPILE_ASSERT(PITCH_DAMPORDER == 5);
78 77
79 // Set up buffer and states. 78 // Set up buffer and states.
80 memcpy(ubufQQ, pfp->ubufQQ, sizeof(pfp->ubufQQ)); 79 memcpy(ubufQQ, pfp->ubufQQ, sizeof(pfp->ubufQQ));
81 memcpy(inystateQQ, pfp->ystateQQ, sizeof(inystateQQ)); 80 memcpy(inystateQQ, pfp->ystateQQ, sizeof(inystateQQ));
82 81
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 115
117 // Each frame has 4 60-sample pitch subframes, and each subframe has 5 116 // Each frame has 4 60-sample pitch subframes, and each subframe has 5
118 // 12-sample segments. Each segment need to be processed with 117 // 12-sample segments. Each segment need to be processed with
119 // newly-updated parameters, so we break the pitch filtering into 118 // newly-updated parameters, so we break the pitch filtering into
120 // two for-loops (5 x 12) below. It's also why kDivFactor = 0.2 (in Q15). 119 // two for-loops (5 x 12) below. It's also why kDivFactor = 0.2 (in Q15).
121 for (cnt = 0; cnt < kSegments; cnt++) { 120 for (cnt = 0; cnt < kSegments; cnt++) {
122 // Update parameters for each segment. 121 // Update parameters for each segment.
123 curGainQ12 += gaindeltaQ12; 122 curGainQ12 += gaindeltaQ12;
124 curLagQ7 += lagdeltaQ7; 123 curLagQ7 += lagdeltaQ7;
125 indW32 = CalcLrIntQ(curLagQ7, 7); 124 indW32 = CalcLrIntQ(curLagQ7, 7);
126 tmpW32 = (indW32 << 7) - curLagQ7; 125 frcQQ = ((indW32 << 7) + 64 - curLagQ7) >> 4;
127 frcQQ = (tmpW32 >> 4) + 4;
128 126
129 if (frcQQ == PITCH_FRACS) { 127 if (frcQQ == PITCH_FRACS) {
130 frcQQ = 0; 128 frcQQ = 0;
131 } 129 }
132 fracoeffQQ = kIntrpCoef[frcQQ]; 130 fracoeffQQ = kIntrpCoef[frcQQ];
133 131
134 // Pitch filtering. 132 // Pitch filtering.
135 WebRtcIsacfix_PitchFilterCore(PITCH_SUBFRAME_LEN / kSegments, curGainQ12, 133 WebRtcIsacfix_PitchFilterCore(PITCH_SUBFRAME_LEN / kSegments, curGainQ12,
136 indW32, sign, inystateQQ, ubufQQ, fracoeffQQ, indatQQ, outdatQQ, &ind); 134 indW32, sign, inystateQQ, ubufQQ, fracoeffQQ, indatQQ, outdatQQ, &ind);
137 } 135 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 186
189 csum1QQ = 1; 187 csum1QQ = 1;
190 esumxQQ = 1; 188 esumxQQ = 1;
191 189
192 // Same as function WebRtcIsacfix_PitchFilter(), we break the pitch 190 // Same as function WebRtcIsacfix_PitchFilter(), we break the pitch
193 // filtering into two for-loops (5 x 12) below. 191 // filtering into two for-loops (5 x 12) below.
194 for (cnt = 0; cnt < kSegments; cnt++) { 192 for (cnt = 0; cnt < kSegments; cnt++) {
195 // Update parameters for each segment. 193 // Update parameters for each segment.
196 curLagQ7 += lagdeltaQ7; 194 curLagQ7 += lagdeltaQ7;
197 indW16 = (int16_t)CalcLrIntQ(curLagQ7, 7); 195 indW16 = (int16_t)CalcLrIntQ(curLagQ7, 7);
198 tmpW16 = (indW16 << 7) - curLagQ7; 196 frcQQ = ((indW16 << 7) + 64 - curLagQ7) >> 4;
199 frcQQ = (tmpW16 >> 4) + 4;
200 197
201 if (frcQQ == PITCH_FRACS) { 198 if (frcQQ == PITCH_FRACS) {
202 frcQQ = 0; 199 frcQQ = 0;
203 } 200 }
204 fracoeffQQ = kIntrpCoef[frcQQ]; 201 fracoeffQQ = kIntrpCoef[frcQQ];
205 202
206 pos3QQ = pos - (indW16 + 4); 203 pos3QQ = pos - (indW16 + 4);
207 204
208 for (n = 0; n < PITCH_SUBFRAME_LEN / kSegments; n++) { 205 for (n = 0; n < PITCH_SUBFRAME_LEN / kSegments; n++) {
209 // Filter to get fractional pitch. 206 // Filter to get fractional pitch.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 } 243 }
247 gainsQ12[k] = (int16_t)WEBRTC_SPL_SAT(PITCH_MAX_GAIN_Q12, tmpW32, 0); 244 gainsQ12[k] = (int16_t)WEBRTC_SPL_SAT(PITCH_MAX_GAIN_Q12, tmpW32, 0);
248 } 245 }
249 246
250 // Export buffer and states. 247 // Export buffer and states.
251 memcpy(pfp->ubufQQ, ubufQQ + PITCH_FRAME_LEN, sizeof(pfp->ubufQQ)); 248 memcpy(pfp->ubufQQ, ubufQQ + PITCH_FRAME_LEN, sizeof(pfp->ubufQQ));
252 pfp->oldlagQ7 = lagsQ7[PITCH_SUBFRAMES - 1]; 249 pfp->oldlagQ7 = lagsQ7[PITCH_SUBFRAMES - 1];
253 pfp->oldgainQ12 = gainsQ12[PITCH_SUBFRAMES - 1]; 250 pfp->oldgainQ12 = gainsQ12[PITCH_SUBFRAMES - 1];
254 251
255 } 252 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698