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

Side by Side Diff: webrtc/modules/audio_coding/codecs/ilbc/cb_construct.c

Issue 2255203002: iLBC: Handle a case of bad input data (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
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
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 iLBC Speech Coder ANSI-C Source Code 13 iLBC Speech Coder ANSI-C Source Code
14 14
15 WebRtcIlbcfix_CbConstruct.c 15 WebRtcIlbcfix_CbConstruct.c
16 16
17 ******************************************************************/ 17 ******************************************************************/
18 18
19 #include "defines.h" 19 #include "defines.h"
20 #include "gain_dequant.h" 20 #include "gain_dequant.h"
21 #include "get_cd_vec.h" 21 #include "get_cd_vec.h"
22 22
23 /*----------------------------------------------------------------* 23 /*----------------------------------------------------------------*
24 * Construct decoded vector from codebook and gains. 24 * Construct decoded vector from codebook and gains.
25 *---------------------------------------------------------------*/ 25 *---------------------------------------------------------------*/
26 26
27 void WebRtcIlbcfix_CbConstruct( 27 int WebRtcIlbcfix_CbConstruct(
28 int16_t *decvector, /* (o) Decoded vector */ 28 int16_t *decvector, /* (o) Decoded vector */
29 int16_t *index, /* (i) Codebook indices */ 29 int16_t *index, /* (i) Codebook indices */
30 int16_t *gain_index, /* (i) Gain quantization indices */ 30 int16_t *gain_index, /* (i) Gain quantization indices */
31 int16_t *mem, /* (i) Buffer for codevector construction */ 31 int16_t *mem, /* (i) Buffer for codevector construction */
32 size_t lMem, /* (i) Length of buffer */ 32 size_t lMem, /* (i) Length of buffer */
33 size_t veclen /* (i) Length of vector */ 33 size_t veclen /* (i) Length of vector */
34 ){ 34 ){
35 size_t j; 35 size_t j;
36 int16_t gain[CB_NSTAGES]; 36 int16_t gain[CB_NSTAGES];
37 /* Stack based */ 37 /* Stack based */
38 int16_t cbvec0[SUBL]; 38 int16_t cbvec0[SUBL];
39 int16_t cbvec1[SUBL]; 39 int16_t cbvec1[SUBL];
40 int16_t cbvec2[SUBL]; 40 int16_t cbvec2[SUBL];
41 int32_t a32; 41 int32_t a32;
42 int16_t *gainPtr; 42 int16_t *gainPtr;
43 43
44 /* gain de-quantization */ 44 /* gain de-quantization */
45 45
46 gain[0] = WebRtcIlbcfix_GainDequant(gain_index[0], 16384, 0); 46 gain[0] = WebRtcIlbcfix_GainDequant(gain_index[0], 16384, 0);
47 gain[1] = WebRtcIlbcfix_GainDequant(gain_index[1], gain[0], 1); 47 gain[1] = WebRtcIlbcfix_GainDequant(gain_index[1], gain[0], 1);
48 gain[2] = WebRtcIlbcfix_GainDequant(gain_index[2], gain[1], 2); 48 gain[2] = WebRtcIlbcfix_GainDequant(gain_index[2], gain[1], 2);
49 49
50 /* codebook vector construction and construction of total vector */ 50 /* codebook vector construction and construction of total vector */
51 51
52 /* Stack based */ 52 /* Stack based */
53 WebRtcIlbcfix_GetCbVec(cbvec0, mem, (size_t)index[0], lMem, veclen); 53 if (!WebRtcIlbcfix_GetCbVec(cbvec0, mem, (size_t)index[0], lMem, veclen))
54 WebRtcIlbcfix_GetCbVec(cbvec1, mem, (size_t)index[1], lMem, veclen); 54 return 0; // Failure.
55 WebRtcIlbcfix_GetCbVec(cbvec2, mem, (size_t)index[2], lMem, veclen); 55 if (!WebRtcIlbcfix_GetCbVec(cbvec1, mem, (size_t)index[1], lMem, veclen))
56 return 0; // Failure.
57 if (!WebRtcIlbcfix_GetCbVec(cbvec2, mem, (size_t)index[2], lMem, veclen))
58 return 0; // Failure.
56 59
57 gainPtr = &gain[0]; 60 gainPtr = &gain[0];
58 for (j=0;j<veclen;j++) { 61 for (j=0;j<veclen;j++) {
59 a32 = (*gainPtr++) * cbvec0[j]; 62 a32 = (*gainPtr++) * cbvec0[j];
60 a32 += (*gainPtr++) * cbvec1[j]; 63 a32 += (*gainPtr++) * cbvec1[j];
61 a32 += (*gainPtr) * cbvec2[j]; 64 a32 += (*gainPtr) * cbvec2[j];
62 gainPtr -= 2; 65 gainPtr -= 2;
63 decvector[j] = (int16_t)((a32 + 8192) >> 14); 66 decvector[j] = (int16_t)((a32 + 8192) >> 14);
64 } 67 }
65 68
66 return; 69 return 1; // Success.
67 } 70 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698