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, Nfor, Nback, diff, start_pos; | 44 int16_t meml_gotten, diff, start_pos; |
45 int16_t subcount, subframe; | 45 int16_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 { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 WebRtcSpl_MemCpyReversedOrder(&decresidual[start_pos-1], | 103 WebRtcSpl_MemCpyReversedOrder(&decresidual[start_pos-1], |
104 reverseDecresidual, diff); | 104 reverseDecresidual, diff); |
105 } | 105 } |
106 | 106 |
107 /* counter for predicted subframes */ | 107 /* counter for predicted subframes */ |
108 | 108 |
109 subcount=1; | 109 subcount=1; |
110 | 110 |
111 /* forward prediction of subframes */ | 111 /* forward prediction of subframes */ |
112 | 112 |
113 Nfor = iLBCdec_inst->nsub-iLBC_encbits->startIdx-1; | 113 if (iLBCdec_inst->nsub > iLBC_encbits->startIdx + 1) { |
114 | |
115 if( Nfor > 0 ) { | |
116 | 114 |
117 /* setup memory */ | 115 /* setup memory */ |
118 WebRtcSpl_MemSetW16(mem, 0, CB_MEML-STATE_LEN); | 116 WebRtcSpl_MemSetW16(mem, 0, CB_MEML-STATE_LEN); |
119 WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-STATE_LEN, | 117 WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-STATE_LEN, |
120 decresidual+(iLBC_encbits->startIdx-1)*SUBL, STATE_LEN
); | 118 decresidual+(iLBC_encbits->startIdx-1)*SUBL, STATE_LEN
); |
121 | 119 |
122 /* loop over subframes to encode */ | 120 /* loop over subframes to encode */ |
123 | 121 |
| 122 int16_t Nfor = iLBCdec_inst->nsub - iLBC_encbits->startIdx - 1; |
124 for (subframe=0; subframe<Nfor; subframe++) { | 123 for (subframe=0; subframe<Nfor; subframe++) { |
125 | 124 |
126 /* construct decoded vector */ | 125 /* construct decoded vector */ |
127 WebRtcIlbcfix_CbConstruct( | 126 WebRtcIlbcfix_CbConstruct( |
128 &decresidual[(iLBC_encbits->startIdx+1+subframe)*SUBL], | 127 &decresidual[(iLBC_encbits->startIdx+1+subframe)*SUBL], |
129 iLBC_encbits->cb_index+subcount*CB_NSTAGES, | 128 iLBC_encbits->cb_index+subcount*CB_NSTAGES, |
130 iLBC_encbits->gain_index+subcount*CB_NSTAGES, | 129 iLBC_encbits->gain_index+subcount*CB_NSTAGES, |
131 mem, MEM_LF_TBL, SUBL | 130 mem, MEM_LF_TBL, SUBL |
132 ); | 131 ); |
133 | 132 |
134 /* update memory */ | 133 /* update memory */ |
135 memmove(mem, mem + SUBL, (CB_MEML - SUBL) * sizeof(*mem)); | 134 memmove(mem, mem + SUBL, (CB_MEML - SUBL) * sizeof(*mem)); |
136 WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-SUBL, | 135 WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-SUBL, |
137 &decresidual[(iLBC_encbits->startIdx+1+subframe)*SUB
L], SUBL); | 136 &decresidual[(iLBC_encbits->startIdx+1+subframe)*SUB
L], SUBL); |
138 | 137 |
139 subcount++; | 138 subcount++; |
140 } | 139 } |
141 | 140 |
142 } | 141 } |
143 | 142 |
144 /* backward prediction of subframes */ | 143 /* backward prediction of subframes */ |
145 | 144 |
146 Nback = iLBC_encbits->startIdx-1; | 145 if (iLBC_encbits->startIdx > 1) { |
147 | |
148 if( Nback > 0 ){ | |
149 | 146 |
150 /* setup memory */ | 147 /* setup memory */ |
151 | 148 |
152 meml_gotten = SUBL*(iLBCdec_inst->nsub+1-iLBC_encbits->startIdx); | 149 meml_gotten = SUBL*(iLBCdec_inst->nsub+1-iLBC_encbits->startIdx); |
153 if( meml_gotten > CB_MEML ) { | 150 if( meml_gotten > CB_MEML ) { |
154 meml_gotten=CB_MEML; | 151 meml_gotten=CB_MEML; |
155 } | 152 } |
156 | 153 |
157 WebRtcSpl_MemCpyReversedOrder(mem+CB_MEML-1, | 154 WebRtcSpl_MemCpyReversedOrder(mem+CB_MEML-1, |
158 decresidual+(iLBC_encbits->startIdx-1)*SUBL, m
eml_gotten); | 155 decresidual+(iLBC_encbits->startIdx-1)*SUBL, m
eml_gotten); |
159 WebRtcSpl_MemSetW16(mem, 0, (int16_t)(CB_MEML-meml_gotten)); | 156 WebRtcSpl_MemSetW16(mem, 0, (int16_t)(CB_MEML-meml_gotten)); |
160 | 157 |
161 /* loop over subframes to decode */ | 158 /* loop over subframes to decode */ |
162 | 159 |
| 160 int16_t Nback = iLBC_encbits->startIdx - 1; |
163 for (subframe=0; subframe<Nback; subframe++) { | 161 for (subframe=0; subframe<Nback; subframe++) { |
164 | 162 |
165 /* construct decoded vector */ | 163 /* construct decoded vector */ |
166 WebRtcIlbcfix_CbConstruct( | 164 WebRtcIlbcfix_CbConstruct( |
167 &reverseDecresidual[subframe*SUBL], | 165 &reverseDecresidual[subframe*SUBL], |
168 iLBC_encbits->cb_index+subcount*CB_NSTAGES, | 166 iLBC_encbits->cb_index+subcount*CB_NSTAGES, |
169 iLBC_encbits->gain_index+subcount*CB_NSTAGES, | 167 iLBC_encbits->gain_index+subcount*CB_NSTAGES, |
170 mem, MEM_LF_TBL, SUBL | 168 mem, MEM_LF_TBL, SUBL |
171 ); | 169 ); |
172 | 170 |
173 /* update memory */ | 171 /* update memory */ |
174 memmove(mem, mem + SUBL, (CB_MEML - SUBL) * sizeof(*mem)); | 172 memmove(mem, mem + SUBL, (CB_MEML - SUBL) * sizeof(*mem)); |
175 WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-SUBL, | 173 WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-SUBL, |
176 &reverseDecresidual[subframe*SUBL], SUBL); | 174 &reverseDecresidual[subframe*SUBL], SUBL); |
177 | 175 |
178 subcount++; | 176 subcount++; |
179 } | 177 } |
180 | 178 |
181 /* get decoded residual from reversed vector */ | 179 /* get decoded residual from reversed vector */ |
182 WebRtcSpl_MemCpyReversedOrder(decresidual+SUBL*Nback-1, | 180 WebRtcSpl_MemCpyReversedOrder(decresidual+SUBL*Nback-1, |
183 reverseDecresidual, SUBL*Nback); | 181 reverseDecresidual, SUBL*Nback); |
184 } | 182 } |
185 } | 183 } |
OLD | NEW |