OLD | NEW |
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_GetCbVec.c | 15 WebRtcIlbcfix_GetCbVec.c |
16 | 16 |
17 ******************************************************************/ | 17 ******************************************************************/ |
18 | 18 |
| 19 #include "get_cd_vec.h" |
| 20 |
19 #include "defines.h" | 21 #include "defines.h" |
20 #include "constants.h" | 22 #include "constants.h" |
21 #include "create_augmented_vec.h" | 23 #include "create_augmented_vec.h" |
22 | 24 |
23 /*----------------------------------------------------------------* | 25 /*----------------------------------------------------------------* |
24 * Construct codebook vector for given index. | 26 * Construct codebook vector for given index. |
25 *---------------------------------------------------------------*/ | 27 *---------------------------------------------------------------*/ |
26 | 28 |
27 void WebRtcIlbcfix_GetCbVec( | 29 bool WebRtcIlbcfix_GetCbVec( |
28 int16_t *cbvec, /* (o) Constructed codebook vector */ | 30 int16_t *cbvec, /* (o) Constructed codebook vector */ |
29 int16_t *mem, /* (i) Codebook buffer */ | 31 int16_t *mem, /* (i) Codebook buffer */ |
30 size_t index, /* (i) Codebook index */ | 32 size_t index, /* (i) Codebook index */ |
31 size_t lMem, /* (i) Length of codebook buffer */ | 33 size_t lMem, /* (i) Length of codebook buffer */ |
32 size_t cbveclen /* (i) Codebook vector length */ | 34 size_t cbveclen /* (i) Codebook vector length */ |
33 ){ | 35 ){ |
34 size_t k, base_size; | 36 size_t k, base_size; |
35 size_t lag; | 37 size_t lag; |
36 /* Stack based */ | 38 /* Stack based */ |
37 int16_t tempbuff2[SUBL+5]; | 39 int16_t tempbuff2[SUBL+5]; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 /* do filtering to get the codebook vector */ | 88 /* do filtering to get the codebook vector */ |
87 | 89 |
88 WebRtcSpl_FilterMAFastQ12( | 90 WebRtcSpl_FilterMAFastQ12( |
89 &mem[memIndTest+4], cbvec, (int16_t*)WebRtcIlbcfix_kCbFiltersRev, | 91 &mem[memIndTest+4], cbvec, (int16_t*)WebRtcIlbcfix_kCbFiltersRev, |
90 CB_FILTERLEN, cbveclen); | 92 CB_FILTERLEN, cbveclen); |
91 } | 93 } |
92 | 94 |
93 /* interpolated vectors */ | 95 /* interpolated vectors */ |
94 | 96 |
95 else { | 97 else { |
| 98 if (cbveclen < SUBL) { |
| 99 // We're going to fill in cbveclen + 5 elements of tempbuff2 in |
| 100 // WebRtcSpl_FilterMAFastQ12, less than the SUBL + 5 elements we'll be |
| 101 // using in WebRtcIlbcfix_CreateAugmentedVec. This error is caused by |
| 102 // bad values in |index| (which come from the encoded stream). Tell the |
| 103 // caller that things went south, and that the decoder state is now |
| 104 // corrupt (because it's half-way through an update that we can't |
| 105 // complete). |
| 106 return false; |
| 107 } |
| 108 |
96 /* Stuff zeros outside memory buffer */ | 109 /* Stuff zeros outside memory buffer */ |
97 memIndTest = lMem-cbveclen-CB_FILTERLEN; | 110 memIndTest = lMem-cbveclen-CB_FILTERLEN; |
98 WebRtcSpl_MemSetW16(mem+lMem, 0, CB_HALFFILTERLEN); | 111 WebRtcSpl_MemSetW16(mem+lMem, 0, CB_HALFFILTERLEN); |
99 | 112 |
100 /* do filtering */ | 113 /* do filtering */ |
101 WebRtcSpl_FilterMAFastQ12( | 114 WebRtcSpl_FilterMAFastQ12( |
102 &mem[memIndTest+7], tempbuff2, (int16_t*)WebRtcIlbcfix_kCbFiltersRev, | 115 &mem[memIndTest+7], tempbuff2, (int16_t*)WebRtcIlbcfix_kCbFiltersRev, |
103 CB_FILTERLEN, cbveclen+5); | 116 CB_FILTERLEN, cbveclen+5); |
104 | 117 |
105 /* Calculate lag index */ | 118 /* Calculate lag index */ |
106 lag = (cbveclen<<1)-20+index-base_size-lMem-1; | 119 lag = (cbveclen<<1)-20+index-base_size-lMem-1; |
107 | 120 |
108 WebRtcIlbcfix_CreateAugmentedVec(lag, tempbuff2+SUBL+5, cbvec); | 121 WebRtcIlbcfix_CreateAugmentedVec(lag, tempbuff2+SUBL+5, cbvec); |
109 } | 122 } |
110 } | 123 } |
| 124 |
| 125 return true; // Success. |
111 } | 126 } |
OLD | NEW |