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

Side by Side Diff: webrtc/modules/audio_processing/ns/nsx_core_mips.c

Issue 1894483002: Prevents a segfault in the noise suppression code on ARMv7 with NEON instructions and Mips platform… (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 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) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 nShifts = 7 - inst->stages; // WIDTH_PR_MAP_SHIFT - inst->stages + 5; 124 nShifts = 7 - inst->stages; // WIDTH_PR_MAP_SHIFT - inst->stages + 5;
125 //use larger width in tanh map for pause regions 125 //use larger width in tanh map for pause regions
126 if (tmp32no1 < 0) { 126 if (tmp32no1 < 0) {
127 tmpIndFX = 0; 127 tmpIndFX = 0;
128 tmp32no1 = -tmp32no1; 128 tmp32no1 = -tmp32no1;
129 //widthPrior = widthPrior * 2.0; 129 //widthPrior = widthPrior * 2.0;
130 nShifts++; 130 nShifts++;
131 } 131 }
132 tmp32no1 = WEBRTC_SPL_SHIFT_W32(tmp32no1, nShifts); // Q14 132 tmp32no1 = WEBRTC_SPL_SHIFT_W32(tmp32no1, nShifts); // Q14
133 // compute indicator function: sigmoid map 133 // compute indicator function: sigmoid map
134 tableIndex = (int16_t)(tmp32no1 >> 14); 134 if (tmp32no1 < (16<<14) && tmp32no1 >= 0) {
135 if ((tableIndex < 16) && (tableIndex >= 0)) { 135 tableIndex = (int16_t)(tmp32no1 >> 14);
136 tmp16no2 = kIndicatorTable[tableIndex]; 136 tmp16no2 = kIndicatorTable[tableIndex];
137 tmp16no1 = kIndicatorTable[tableIndex + 1] - kIndicatorTable[tableIndex]; 137 tmp16no1 = kIndicatorTable[tableIndex + 1] - kIndicatorTable[tableIndex];
138 frac = (int16_t)(tmp32no1 & 0x00003fff); // Q14 138 frac = (int16_t)(tmp32no1 & 0x00003fff); // Q14
139 tmp16no2 += (int16_t)((tmp16no1 * frac) >> 14); 139 tmp16no2 += (int16_t)((tmp16no1 * frac) >> 14);
140 if (tmpIndFX == 0) { 140 if (tmpIndFX == 0) {
141 tmpIndFX = 8192 - tmp16no2; // Q14 141 tmpIndFX = 8192 - tmp16no2; // Q14
142 } else { 142 } else {
143 tmpIndFX = 8192 + tmp16no2; // Q14 143 tmpIndFX = 8192 + tmp16no2; // Q14
144 } 144 }
145 } 145 }
(...skipping 10 matching lines...) Expand all
156 tmpIndFX = 0; 156 tmpIndFX = 0;
157 tmpU32no2 = tmpU32no1 - inst->thresholdSpecFlat; 157 tmpU32no2 = tmpU32no1 - inst->thresholdSpecFlat;
158 //widthPrior = widthPrior * 2.0; 158 //widthPrior = widthPrior * 2.0;
159 nShifts++; 159 nShifts++;
160 } 160 }
161 tmpU32no1 = WebRtcSpl_DivU32U16(tmpU32no2 << nShifts, 25); //Q14 161 tmpU32no1 = WebRtcSpl_DivU32U16(tmpU32no2 << nShifts, 25); //Q14
162 // compute indicator function: sigmoid map 162 // compute indicator function: sigmoid map
163 // FLOAT code 163 // FLOAT code
164 // indicator1 = 0.5 * (tanh(sgnMap * widthPrior * 164 // indicator1 = 0.5 * (tanh(sgnMap * widthPrior *
165 // (threshPrior1 - tmpFloat1)) + 1.0); 165 // (threshPrior1 - tmpFloat1)) + 1.0);
166 tableIndex = (int16_t)(tmpU32no1 >> 14); 166 if (tmp32no1 < (16<<14) && tmp32no1 >= 0) {
hlundin-webrtc 2016/04/15 08:28:31 This is wrong. The old code deals with tmpU32no1,
ivoc 2016/04/15 08:37:25 Oops, you're right. These wonderfully descriptive
167 if (tableIndex < 16) { 167 tableIndex = (int16_t)(tmp32no1 >> 14);
168 tmp16no2 = kIndicatorTable[tableIndex]; 168 tmp16no2 = kIndicatorTable[tableIndex];
169 tmp16no1 = kIndicatorTable[tableIndex + 1] - kIndicatorTable[tableIndex]; 169 tmp16no1 = kIndicatorTable[tableIndex + 1] - kIndicatorTable[tableIndex];
170 frac = (int16_t)(tmpU32no1 & 0x00003fff); // Q14 170 frac = (int16_t)(tmpU32no1 & 0x00003fff); // Q14
171 tmp16no2 += (int16_t)((tmp16no1 * frac) >> 14); 171 tmp16no2 += (int16_t)((tmp16no1 * frac) >> 14);
172 if (tmpIndFX) { 172 if (tmpIndFX) {
173 tmpIndFX = 8192 + tmp16no2; // Q14 173 tmpIndFX = 8192 + tmp16no2; // Q14
174 } else { 174 } else {
175 tmpIndFX = 8192 - tmp16no2; // Q14 175 tmpIndFX = 8192 - tmp16no2; // Q14
176 } 176 }
177 } 177 }
(...skipping 25 matching lines...) Expand all
203 tmpIndFX = 0; 203 tmpIndFX = 0;
204 tmpU32no2 = tmpU32no3 - tmpU32no1; 204 tmpU32no2 = tmpU32no3 - tmpU32no1;
205 //widthPrior = widthPrior * 2.0; 205 //widthPrior = widthPrior * 2.0;
206 nShifts--; 206 nShifts--;
207 } 207 }
208 tmpU32no1 = tmpU32no2 >> nShifts; 208 tmpU32no1 = tmpU32no2 >> nShifts;
209 // compute indicator function: sigmoid map 209 // compute indicator function: sigmoid map
210 /* FLOAT code 210 /* FLOAT code
211 indicator2 = 0.5 * (tanh(widthPrior * (tmpFloat1 - threshPrior2)) + 1.0); 211 indicator2 = 0.5 * (tanh(widthPrior * (tmpFloat1 - threshPrior2)) + 1.0);
212 */ 212 */
213 tableIndex = (int16_t)(tmpU32no1 >> 14); 213 if (tmp32no1 < (16<<14) && tmp32no1 >= 0) {
hlundin-webrtc 2016/04/15 08:28:31 Same here. Wrong variable.
ivoc 2016/04/15 08:37:25 Fixed.
214 if (tableIndex < 16) { 214 tableIndex = (int16_t)(tmp32no1 >> 14);
215 tmp16no2 = kIndicatorTable[tableIndex]; 215 tmp16no2 = kIndicatorTable[tableIndex];
216 tmp16no1 = kIndicatorTable[tableIndex + 1] - kIndicatorTable[tableIndex]; 216 tmp16no1 = kIndicatorTable[tableIndex + 1] - kIndicatorTable[tableIndex];
217 frac = (int16_t)(tmpU32no1 & 0x00003fff); // Q14 217 frac = (int16_t)(tmpU32no1 & 0x00003fff); // Q14
218 tmp16no2 += (int16_t)WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND( 218 tmp16no2 += (int16_t)WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(
219 tmp16no1, frac, 14); 219 tmp16no1, frac, 14);
220 if (tmpIndFX) { 220 if (tmpIndFX) {
221 tmpIndFX = 8192 + tmp16no2; 221 tmpIndFX = 8192 + tmp16no2;
222 } else { 222 } else {
223 tmpIndFX = 8192 - tmp16no2; 223 tmpIndFX = 8192 - tmp16no2;
224 } 224 }
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 "4: \n\t" 993 "4: \n\t"
994 ".set pop \n\t" 994 ".set pop \n\t"
995 : [t0] "=&r" (t0), [r0] "=&r" (r0), [r1] "=&r" (r1), 995 : [t0] "=&r" (t0), [r0] "=&r" (r0), [r1] "=&r" (r1),
996 [r2] "=&r" (r2), [r3] "=&r" (r3) 996 [r2] "=&r" (r2), [r3] "=&r" (r3)
997 : [len] "r" (len), [shift] "r" (shift), [in] "r" (in), 997 : [len] "r" (len), [shift] "r" (shift), [in] "r" (in),
998 [out] "r" (out) 998 [out] "r" (out)
999 : "memory" 999 : "memory"
1000 ); 1000 );
1001 } 1001 }
1002 1002
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698