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

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

Issue 2315693002: iSAC float: Handle errors in upper band decoding (Closed)
Patch Set: Created 4 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
« no previous file with comments | « no previous file | 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 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 } 1246 }
1247 case isac16kHz: { 1247 case isac16kHz: {
1248 numDecodedBytesUB = WebRtcIsac_DecodeUb16( 1248 numDecodedBytesUB = WebRtcIsac_DecodeUb16(
1249 &instISAC->transform_tables, outFrame, decInstUB, isRCUPayload); 1249 &instISAC->transform_tables, outFrame, decInstUB, isRCUPayload);
1250 break; 1250 break;
1251 } 1251 }
1252 default: 1252 default:
1253 return -1; 1253 return -1;
1254 } 1254 }
1255 1255
1256 if (numDecodedBytesUB < 0) {
1257 instISAC->errorCode = numDecodedBytesUB;
1258 return -1;
1259 }
1260 if (numDecodedBytesLB + numDecodedBytesUB > lenEncodedBytes) {
1261 // We have supposedly decoded more bytes than we were given. Likely
1262 // caused by bad input data.
1263 instISAC->errorCode = ISAC_LENGTH_MISMATCH;
1264 return -1;
1265 }
1266
1256 /* It might be less due to garbage. */ 1267 /* It might be less due to garbage. */
1257 if ((numDecodedBytesUB != lenNextStream) && 1268 if ((numDecodedBytesUB != lenNextStream) &&
1258 (numDecodedBytesUB != (lenNextStream - 1269 (numDecodedBytesUB != (lenNextStream -
1259 encoded[numDecodedBytesLB + 1 + numDecodedBytesUB]))) { 1270 encoded[numDecodedBytesLB + 1 + numDecodedBytesUB]))) {
1260 instISAC->errorCode = ISAC_LENGTH_MISMATCH; 1271 instISAC->errorCode = ISAC_LENGTH_MISMATCH;
1261 return -1; 1272 return -1;
1262 } 1273 }
1263 1274
1264 /* If there is no error Upper-band always decodes 1275 /* If there is no error Upper-band always decodes
1265 * 30 ms (480 samples). */ 1276 * 30 ms (480 samples). */
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after
2354 } 2365 }
2355 2366
2356 void WebRtcIsac_SetEncSampRateInDecoder(ISACStruct* inst, 2367 void WebRtcIsac_SetEncSampRateInDecoder(ISACStruct* inst,
2357 int sample_rate_hz) { 2368 int sample_rate_hz) {
2358 ISACMainStruct* instISAC = (ISACMainStruct*)inst; 2369 ISACMainStruct* instISAC = (ISACMainStruct*)inst;
2359 RTC_DCHECK_NE(0, instISAC->initFlag & BIT_MASK_DEC_INIT); 2370 RTC_DCHECK_NE(0, instISAC->initFlag & BIT_MASK_DEC_INIT);
2360 RTC_DCHECK(!(instISAC->initFlag & BIT_MASK_ENC_INIT)); 2371 RTC_DCHECK(!(instISAC->initFlag & BIT_MASK_ENC_INIT));
2361 RTC_DCHECK(sample_rate_hz == 16000 || sample_rate_hz == 32000); 2372 RTC_DCHECK(sample_rate_hz == 16000 || sample_rate_hz == 32000);
2362 instISAC->encoderSamplingRateKHz = sample_rate_hz / 1000; 2373 instISAC->encoderSamplingRateKHz = sample_rate_hz / 1000;
2363 } 2374 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698