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

Side by Side Diff: webrtc/modules/audio_coding/codecs/isac/main/source/entropy_coding.c

Issue 1979973003: Fix UBSan errors (left shift of negative value, left shift overflows int) (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: variable name 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
« no previous file with comments | « webrtc/modules/audio_coding/codecs/isac/main/source/arith_routines_hist.c ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 diffQ16[n] = (CS_ptrQ9[n] * (CorrQ11[1] >> shftVal) + 2) >> 2; 155 diffQ16[n] = (CS_ptrQ9[n] * (CorrQ11[1] >> shftVal) + 2) >> 2;
156 } 156 }
157 for (k = 2; k < AR_ORDER; k += 2) { 157 for (k = 2; k < AR_ORDER; k += 2) {
158 CS_ptrQ9 = WebRtcIsac_kCos[k]; 158 CS_ptrQ9 = WebRtcIsac_kCos[k];
159 for (n = 0; n < FRAMESAMPLES / 8; n++) { 159 for (n = 0; n < FRAMESAMPLES / 8; n++) {
160 diffQ16[n] += (CS_ptrQ9[n] * (CorrQ11[k + 1] >> shftVal) + 2) >> 2; 160 diffQ16[n] += (CS_ptrQ9[n] * (CorrQ11[k + 1] >> shftVal) + 2) >> 2;
161 } 161 }
162 } 162 }
163 163
164 for (k = 0; k < FRAMESAMPLES / 8; k++) { 164 for (k = 0; k < FRAMESAMPLES / 8; k++) {
165 CurveQ16[FRAMESAMPLES_QUARTER - 1 - k] = CurveQ16[k] - 165 int32_t diff_q16_shifted = (int32_t)((uint32_t)(diffQ16[k]) << shftVal);
166 (diffQ16[k] << shftVal); 166 CurveQ16[FRAMESAMPLES_QUARTER - 1 - k] = CurveQ16[k] - diff_q16_shifted;
167 CurveQ16[k] += diffQ16[k] << shftVal; 167 CurveQ16[k] += diff_q16_shifted;
168 } 168 }
169 } 169 }
170 170
171 /* Generate array of dither samples in Q7. */ 171 /* Generate array of dither samples in Q7. */
172 static void GenerateDitherQ7Lb(int16_t* bufQ7, uint32_t seed, 172 static void GenerateDitherQ7Lb(int16_t* bufQ7, uint32_t seed,
173 int length, int16_t AvgPitchGain_Q12) { 173 int length, int16_t AvgPitchGain_Q12) {
174 int k, shft; 174 int k, shft;
175 int16_t dither1_Q7, dither2_Q7, dither_gain_Q14; 175 int16_t dither1_Q7, dither2_Q7, dither_gain_Q14;
176 176
177 /* This threshold should be equal to that in decode_spec(). */ 177 /* This threshold should be equal to that in decode_spec(). */
(...skipping 1879 matching lines...) Expand 10 before | Expand all | Expand 10 after
2057 /* Use the same CDF table as for bandwidth 2057 /* Use the same CDF table as for bandwidth
2058 * both take two values with equal probability. */ 2058 * both take two values with equal probability. */
2059 if (WebRtcIsac_DecHistOneStepMulti(&intVar, streamData, 2059 if (WebRtcIsac_DecHistOneStepMulti(&intVar, streamData,
2060 kOneBitEqualProbCdf_ptr, 2060 kOneBitEqualProbCdf_ptr,
2061 kOneBitEqualProbInitIndex, 1) < 0) { 2061 kOneBitEqualProbInitIndex, 1) < 0) {
2062 return -ISAC_RANGE_ERROR_DECODE_BANDWITH; 2062 return -ISAC_RANGE_ERROR_DECODE_BANDWITH;
2063 } 2063 }
2064 *jitterInfo = (int16_t)(intVar); 2064 *jitterInfo = (int16_t)(intVar);
2065 return 0; 2065 return 0;
2066 } 2066 }
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/codecs/isac/main/source/arith_routines_hist.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698