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

Side by Side Diff: webrtc/common_audio/signal_processing/levinson_durbin.c

Issue 3009123002: Move UBSan warnings from a blacklist to the source (Closed)
Patch Set: Address review comments Created 3 years, 3 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
11 11
12 /* 12 /*
13 * This file contains the function WebRtcSpl_LevinsonDurbin(). 13 * This file contains the function WebRtcSpl_LevinsonDurbin().
14 * The description header can be found in signal_processing_library.h 14 * The description header can be found in signal_processing_library.h
15 * 15 *
16 */ 16 */
17 17
18 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" 18 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h"
19 #include "webrtc/rtc_base/sanitizer.h"
19 20
20 #define SPL_LEVINSON_MAXORDER 20 21 #define SPL_LEVINSON_MAXORDER 20
21 22
22 int16_t WebRtcSpl_LevinsonDurbin(const int32_t* R, int16_t* A, int16_t* K, 23 int16_t RTC_NO_SANITIZE("signed-integer-overflow") // bugs.webrtc.org/5486
23 size_t order) 24 WebRtcSpl_LevinsonDurbin(const int32_t* R, int16_t* A, int16_t* K,
25 size_t order)
24 { 26 {
25 size_t i, j; 27 size_t i, j;
26 // Auto-correlation coefficients in high precision 28 // Auto-correlation coefficients in high precision
27 int16_t R_hi[SPL_LEVINSON_MAXORDER + 1], R_low[SPL_LEVINSON_MAXORDER + 1]; 29 int16_t R_hi[SPL_LEVINSON_MAXORDER + 1], R_low[SPL_LEVINSON_MAXORDER + 1];
28 // LPC coefficients in high precision 30 // LPC coefficients in high precision
29 int16_t A_hi[SPL_LEVINSON_MAXORDER + 1], A_low[SPL_LEVINSON_MAXORDER + 1]; 31 int16_t A_hi[SPL_LEVINSON_MAXORDER + 1], A_low[SPL_LEVINSON_MAXORDER + 1];
30 // LPC coefficients for next iteration 32 // LPC coefficients for next iteration
31 int16_t A_upd_hi[SPL_LEVINSON_MAXORDER + 1], A_upd_low[SPL_LEVINSON_MAXORDER + 1]; 33 int16_t A_upd_hi[SPL_LEVINSON_MAXORDER + 1], A_upd_low[SPL_LEVINSON_MAXORDER + 1];
32 // Reflection coefficient in high precision 34 // Reflection coefficient in high precision
33 int16_t K_hi, K_low; 35 int16_t K_hi, K_low;
34 // Prediction gain Alpha in high precision and with scale factor 36 // Prediction gain Alpha in high precision and with scale factor
35 int16_t Alpha_hi, Alpha_low, Alpha_exp; 37 int16_t Alpha_hi, Alpha_low, Alpha_exp;
36 int16_t tmp_hi, tmp_low; 38 int16_t tmp_hi, tmp_low;
37 int32_t temp1W32, temp2W32, temp3W32; 39 int32_t temp1W32, temp2W32, temp3W32;
38 int16_t norm; 40 int16_t norm;
39 41
40 // Normalize the autocorrelation R[0]...R[order+1] 42 // Normalize the autocorrelation R[0]...R[order+1]
41 43
42 norm = WebRtcSpl_NormW32(R[0]); 44 norm = WebRtcSpl_NormW32(R[0]);
43 45
44 for (i = 0; i <= order; ++i) 46 for (i = 0; i <= order; ++i)
45 { 47 {
46 temp1W32 = R[i] * (1 << norm); 48 temp1W32 = R[i] * (1 << norm);
49 // UBSan: 12 * 268435456 cannot be represented in type 'int'
50
47 // Put R in hi and low format 51 // Put R in hi and low format
48 R_hi[i] = (int16_t)(temp1W32 >> 16); 52 R_hi[i] = (int16_t)(temp1W32 >> 16);
49 R_low[i] = (int16_t)((temp1W32 - ((int32_t)R_hi[i] * 65536)) >> 1); 53 R_low[i] = (int16_t)((temp1W32 - ((int32_t)R_hi[i] * 65536)) >> 1);
50 } 54 }
51 55
52 // K = A[1] = -R[1] / R[0] 56 // K = A[1] = -R[1] / R[0]
53 57
54 temp2W32 = R[1] * (1 << norm); // R[1] in Q31 58 temp2W32 = R[1] * (1 << norm); // R[1] in Q31
55 temp3W32 = WEBRTC_SPL_ABS_W32(temp2W32); // abs R[1] 59 temp3W32 = WEBRTC_SPL_ABS_W32(temp2W32); // abs R[1]
56 temp1W32 = WebRtcSpl_DivW32HiLow(temp3W32, R_hi[0], R_low[0]); // abs(R[1])/ R[0] in Q31 60 temp1W32 = WebRtcSpl_DivW32HiLow(temp3W32, R_hi[0], R_low[0]); // abs(R[1])/ R[0] in Q31
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 for (i = 1; i <= order; i++) 240 for (i = 1; i <= order; i++)
237 { 241 {
238 // temp1W32 in Q27 242 // temp1W32 in Q27
239 temp1W32 = (int32_t)A_hi[i] * 65536 243 temp1W32 = (int32_t)A_hi[i] * 65536
240 + WEBRTC_SPL_LSHIFT_W32((int32_t)A_low[i], 1); 244 + WEBRTC_SPL_LSHIFT_W32((int32_t)A_low[i], 1);
241 // Round and store upper word 245 // Round and store upper word
242 A[i] = (int16_t)(((temp1W32 * 2) + 32768) >> 16); 246 A[i] = (int16_t)(((temp1W32 * 2) + 32768) >> 16);
243 } 247 }
244 return 1; // Stable filters 248 return 1; // Stable filters
245 } 249 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698