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

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

Issue 1989803002: Fix UBSan errors (left shift of negative value) (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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) 2011 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2011 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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 sh = WebRtcSpl_NormW32(tmp32); // tmp32 is the gain 267 sh = WebRtcSpl_NormW32(tmp32); // tmp32 is the gain
268 den16 = (int16_t) WEBRTC_SPL_SHIFT_W32(tmp32, sh-16); //Q(27+sh-16) = Q(sh+1 1) (all 16 bits are value bits) 268 den16 = (int16_t) WEBRTC_SPL_SHIFT_W32(tmp32, sh-16); //Q(27+sh-16) = Q(sh+1 1) (all 16 bits are value bits)
269 inv_gain32 = WebRtcSpl_DivW32W16((int32_t)2147483647, den16); // 1/gain in Q 31/Q(sh+11) = Q(20-sh) 269 inv_gain32 = WebRtcSpl_DivW32W16((int32_t)2147483647, den16); // 1/gain in Q 31/Q(sh+11) = Q(20-sh)
270 270
271 //initial conditions 271 //initial conditions
272 inv_gain16 = (int16_t)(inv_gain32 >> 2); // 1/gain in Q(20-sh-2) = Q(18-sh) 272 inv_gain16 = (int16_t)(inv_gain32 >> 2); // 1/gain in Q(20-sh-2) = Q(18-sh)
273 273
274 for (i=0;i<HALF_SUBFRAMELEN;i++) 274 for (i=0;i<HALF_SUBFRAMELEN;i++)
275 { 275 {
276 276
277 tmp32 = lat_inQ25[i + temp1] << 1; // Q25->Q26 277 tmp32 = lat_inQ25[i + temp1] * (1 << 1); // Q25->Q26
278 tmp32 = WEBRTC_SPL_MUL_16_32_RSFT16(inv_gain16, tmp32); //lat_in[]*inv_gai n in (Q(18-sh)*Q26)>>16 = Q(28-sh) 278 tmp32 = WEBRTC_SPL_MUL_16_32_RSFT16(inv_gain16, tmp32); //lat_in[]*inv_gai n in (Q(18-sh)*Q26)>>16 = Q(28-sh)
279 tmp32 = WEBRTC_SPL_SHIFT_W32(tmp32, -(28-sh)); // lat_in[]*inv_gain in Q0 279 tmp32 = WEBRTC_SPL_SHIFT_W32(tmp32, -(28-sh)); // lat_in[]*inv_gain in Q0
280 280
281 ARfQ0vec[i] = (int16_t)WebRtcSpl_SatW32ToW16(tmp32); // Q0 281 ARfQ0vec[i] = (int16_t)WebRtcSpl_SatW32ToW16(tmp32); // Q0
282 } 282 }
283 283
284 // Get the state of f & g for the first input, for all orders. 284 // Get the state of f & g for the first input, for all orders.
285 for (i = orderCoef; i > 0; i--) 285 for (i = orderCoef; i > 0; i--)
286 { 286 {
287 tmp32 = (cthQ15[i - 1] * ARfQ0vec[0] - sthQ15[i - 1] * stateGQ0[i - 1] + 287 tmp32 = (cthQ15[i - 1] * ARfQ0vec[0] - sthQ15[i - 1] * stateGQ0[i - 1] +
(...skipping 19 matching lines...) Expand all
307 /* cannot use memcpy in the following */ 307 /* cannot use memcpy in the following */
308 308
309 for (i=0;i<ord_1;i++) 309 for (i=0;i<ord_1;i++)
310 { 310 {
311 stateGQ0[i] = ARgQ0vec[i]; 311 stateGQ0[i] = ARgQ0vec[i];
312 } 312 }
313 } 313 }
314 314
315 return; 315 return;
316 } 316 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698