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 |
(...skipping 23 matching lines...) Expand all Loading... | |
34 | 34 |
35 void WebRtcIlbcfix_DecodeResidual( | 35 void WebRtcIlbcfix_DecodeResidual( |
36 IlbcDecoder *iLBCdec_inst, | 36 IlbcDecoder *iLBCdec_inst, |
37 /* (i/o) the decoder state structure */ | 37 /* (i/o) the decoder state structure */ |
38 iLBC_bits *iLBC_encbits, /* (i/o) Encoded bits, which are used | 38 iLBC_bits *iLBC_encbits, /* (i/o) Encoded bits, which are used |
39 for the decoding */ | 39 for the decoding */ |
40 int16_t *decresidual, /* (o) decoded residual frame */ | 40 int16_t *decresidual, /* (o) decoded residual frame */ |
41 int16_t *syntdenum /* (i) the decoded synthesis filter | 41 int16_t *syntdenum /* (i) the decoded synthesis filter |
42 coefficients */ | 42 coefficients */ |
43 ) { | 43 ) { |
44 int16_t meml_gotten, diff, start_pos; | 44 size_t meml_gotten, diff, start_pos; |
45 int16_t subcount, subframe; | 45 size_t subcount, subframe; |
46 int16_t *reverseDecresidual = iLBCdec_inst->enh_buf; /* Reversed decoded data, used for decoding backwards in time (reuse memory in state) */ | 46 int16_t *reverseDecresidual = iLBCdec_inst->enh_buf; /* Reversed decoded data, used for decoding backwards in time (reuse memory in state) */ |
47 int16_t *memVec = iLBCdec_inst->prevResidual; /* Memory for codebook and filt er state (reuse memory in state) */ | 47 int16_t *memVec = iLBCdec_inst->prevResidual; /* Memory for codebook and filt er state (reuse memory in state) */ |
48 int16_t *mem = &memVec[CB_HALFFILTERLEN]; /* Memory for codebook */ | 48 int16_t *mem = &memVec[CB_HALFFILTERLEN]; /* Memory for codebook */ |
49 | 49 |
50 diff = STATE_LEN - iLBCdec_inst->state_short_len; | 50 diff = STATE_LEN - iLBCdec_inst->state_short_len; |
51 | 51 |
52 if (iLBC_encbits->state_first == 1) { | 52 if (iLBC_encbits->state_first == 1) { |
53 start_pos = (iLBC_encbits->startIdx-1)*SUBL; | 53 start_pos = (iLBC_encbits->startIdx-1)*SUBL; |
54 } else { | 54 } else { |
55 start_pos = (iLBC_encbits->startIdx-1)*SUBL + diff; | 55 start_pos = (iLBC_encbits->startIdx-1)*SUBL + diff; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 | 111 |
112 if (iLBCdec_inst->nsub > iLBC_encbits->startIdx + 1) { | 112 if (iLBCdec_inst->nsub > iLBC_encbits->startIdx + 1) { |
113 | 113 |
114 /* setup memory */ | 114 /* setup memory */ |
115 WebRtcSpl_MemSetW16(mem, 0, CB_MEML-STATE_LEN); | 115 WebRtcSpl_MemSetW16(mem, 0, CB_MEML-STATE_LEN); |
116 WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-STATE_LEN, | 116 WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-STATE_LEN, |
117 decresidual+(iLBC_encbits->startIdx-1)*SUBL, STATE_LEN ); | 117 decresidual+(iLBC_encbits->startIdx-1)*SUBL, STATE_LEN ); |
118 | 118 |
119 /* loop over subframes to encode */ | 119 /* loop over subframes to encode */ |
120 | 120 |
121 int16_t Nfor = iLBCdec_inst->nsub - iLBC_encbits->startIdx - 1; | 121 size_t Nfor = iLBCdec_inst->nsub - iLBC_encbits->startIdx - 1; |
kwiberg-webrtc
2015/08/11 09:33:21
I presume this can't be negative?
Peter Kasting
2015/08/14 00:56:09
Yes, due to the conditional on line 112.
| |
122 for (subframe=0; subframe<Nfor; subframe++) { | 122 for (subframe=0; subframe<Nfor; subframe++) { |
123 | 123 |
124 /* construct decoded vector */ | 124 /* construct decoded vector */ |
125 WebRtcIlbcfix_CbConstruct( | 125 WebRtcIlbcfix_CbConstruct( |
126 &decresidual[(iLBC_encbits->startIdx+1+subframe)*SUBL], | 126 &decresidual[(iLBC_encbits->startIdx+1+subframe)*SUBL], |
127 iLBC_encbits->cb_index+subcount*CB_NSTAGES, | 127 iLBC_encbits->cb_index+subcount*CB_NSTAGES, |
128 iLBC_encbits->gain_index+subcount*CB_NSTAGES, | 128 iLBC_encbits->gain_index+subcount*CB_NSTAGES, |
129 mem, MEM_LF_TBL, SUBL | 129 mem, MEM_LF_TBL, SUBL |
130 ); | 130 ); |
131 | 131 |
(...skipping 17 matching lines...) Expand all Loading... | |
149 if( meml_gotten > CB_MEML ) { | 149 if( meml_gotten > CB_MEML ) { |
150 meml_gotten=CB_MEML; | 150 meml_gotten=CB_MEML; |
151 } | 151 } |
152 | 152 |
153 WebRtcSpl_MemCpyReversedOrder(mem+CB_MEML-1, | 153 WebRtcSpl_MemCpyReversedOrder(mem+CB_MEML-1, |
154 decresidual+(iLBC_encbits->startIdx-1)*SUBL, m eml_gotten); | 154 decresidual+(iLBC_encbits->startIdx-1)*SUBL, m eml_gotten); |
155 WebRtcSpl_MemSetW16(mem, 0, CB_MEML - meml_gotten); | 155 WebRtcSpl_MemSetW16(mem, 0, CB_MEML - meml_gotten); |
156 | 156 |
157 /* loop over subframes to decode */ | 157 /* loop over subframes to decode */ |
158 | 158 |
159 int16_t Nback = iLBC_encbits->startIdx - 1; | 159 size_t Nback = iLBC_encbits->startIdx - 1; |
kwiberg-webrtc
2015/08/11 09:33:21
I presume this can't be negative?
Peter Kasting
2015/08/14 00:56:09
Yes, due to the conditional on line 144.
| |
160 for (subframe=0; subframe<Nback; subframe++) { | 160 for (subframe=0; subframe<Nback; subframe++) { |
161 | 161 |
162 /* construct decoded vector */ | 162 /* construct decoded vector */ |
163 WebRtcIlbcfix_CbConstruct( | 163 WebRtcIlbcfix_CbConstruct( |
164 &reverseDecresidual[subframe*SUBL], | 164 &reverseDecresidual[subframe*SUBL], |
165 iLBC_encbits->cb_index+subcount*CB_NSTAGES, | 165 iLBC_encbits->cb_index+subcount*CB_NSTAGES, |
166 iLBC_encbits->gain_index+subcount*CB_NSTAGES, | 166 iLBC_encbits->gain_index+subcount*CB_NSTAGES, |
167 mem, MEM_LF_TBL, SUBL | 167 mem, MEM_LF_TBL, SUBL |
168 ); | 168 ); |
169 | 169 |
170 /* update memory */ | 170 /* update memory */ |
171 memmove(mem, mem + SUBL, (CB_MEML - SUBL) * sizeof(*mem)); | 171 memmove(mem, mem + SUBL, (CB_MEML - SUBL) * sizeof(*mem)); |
172 WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-SUBL, | 172 WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-SUBL, |
173 &reverseDecresidual[subframe*SUBL], SUBL); | 173 &reverseDecresidual[subframe*SUBL], SUBL); |
174 | 174 |
175 subcount++; | 175 subcount++; |
176 } | 176 } |
177 | 177 |
178 /* get decoded residual from reversed vector */ | 178 /* get decoded residual from reversed vector */ |
179 WebRtcSpl_MemCpyReversedOrder(decresidual+SUBL*Nback-1, | 179 WebRtcSpl_MemCpyReversedOrder(decresidual+SUBL*Nback-1, |
180 reverseDecresidual, SUBL*Nback); | 180 reverseDecresidual, SUBL*Nback); |
181 } | 181 } |
182 } | 182 } |
OLD | NEW |