| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 assert(instISAC->initFlag & BIT_MASK_DEC_INIT); | 2370 assert(instISAC->initFlag & BIT_MASK_DEC_INIT); |
| 2360 assert(!(instISAC->initFlag & BIT_MASK_ENC_INIT)); | 2371 assert(!(instISAC->initFlag & BIT_MASK_ENC_INIT)); |
| 2361 assert(sample_rate_hz == 16000 || sample_rate_hz == 32000); | 2372 assert(sample_rate_hz == 16000 || sample_rate_hz == 32000); |
| 2362 instISAC->encoderSamplingRateKHz = sample_rate_hz / 1000; | 2373 instISAC->encoderSamplingRateKHz = sample_rate_hz / 1000; |
| 2363 } | 2374 } |
| OLD | NEW |