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 14 matching lines...) Expand all Loading... |
25 #include "do_plc.h" | 25 #include "do_plc.h" |
26 #include "constants.h" | 26 #include "constants.h" |
27 #include "enhancer_interface.h" | 27 #include "enhancer_interface.h" |
28 #include "xcorr_coef.h" | 28 #include "xcorr_coef.h" |
29 #include "lsf_check.h" | 29 #include "lsf_check.h" |
30 | 30 |
31 /*----------------------------------------------------------------* | 31 /*----------------------------------------------------------------* |
32 * frame residual decoder function (subrutine to iLBC_decode) | 32 * frame residual decoder function (subrutine to iLBC_decode) |
33 *---------------------------------------------------------------*/ | 33 *---------------------------------------------------------------*/ |
34 | 34 |
35 void WebRtcIlbcfix_DecodeResidual( | 35 int 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 size_t meml_gotten, diff, start_pos; | 44 size_t meml_gotten, diff, start_pos; |
45 size_t subcount, subframe; | 45 size_t subcount, subframe; |
(...skipping 19 matching lines...) Expand all Loading... |
65 if (iLBC_encbits->state_first) { /* put adaptive part in the end */ | 65 if (iLBC_encbits->state_first) { /* put adaptive part in the end */ |
66 | 66 |
67 /* setup memory */ | 67 /* setup memory */ |
68 | 68 |
69 WebRtcSpl_MemSetW16(mem, 0, CB_MEML - iLBCdec_inst->state_short_len); | 69 WebRtcSpl_MemSetW16(mem, 0, CB_MEML - iLBCdec_inst->state_short_len); |
70 WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-iLBCdec_inst->state_short_len, decresidual
+start_pos, | 70 WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-iLBCdec_inst->state_short_len, decresidual
+start_pos, |
71 iLBCdec_inst->state_short_len); | 71 iLBCdec_inst->state_short_len); |
72 | 72 |
73 /* construct decoded vector */ | 73 /* construct decoded vector */ |
74 | 74 |
75 WebRtcIlbcfix_CbConstruct( | 75 if (!WebRtcIlbcfix_CbConstruct( |
76 &decresidual[start_pos+iLBCdec_inst->state_short_len], | 76 &decresidual[start_pos + iLBCdec_inst->state_short_len], |
77 iLBC_encbits->cb_index, iLBC_encbits->gain_index, | 77 iLBC_encbits->cb_index, iLBC_encbits->gain_index, |
78 mem+CB_MEML-ST_MEM_L_TBL, | 78 mem + CB_MEML - ST_MEM_L_TBL, ST_MEM_L_TBL, diff)) |
79 ST_MEM_L_TBL, diff); | 79 return 0; // Error. |
80 | 80 |
81 } | 81 } |
82 else {/* put adaptive part in the beginning */ | 82 else {/* put adaptive part in the beginning */ |
83 | 83 |
84 /* setup memory */ | 84 /* setup memory */ |
85 | 85 |
86 meml_gotten = iLBCdec_inst->state_short_len; | 86 meml_gotten = iLBCdec_inst->state_short_len; |
87 WebRtcSpl_MemCpyReversedOrder(mem+CB_MEML-1, | 87 WebRtcSpl_MemCpyReversedOrder(mem+CB_MEML-1, |
88 decresidual+start_pos, meml_gotten); | 88 decresidual+start_pos, meml_gotten); |
89 WebRtcSpl_MemSetW16(mem, 0, CB_MEML - meml_gotten); | 89 WebRtcSpl_MemSetW16(mem, 0, CB_MEML - meml_gotten); |
90 | 90 |
91 /* construct decoded vector */ | 91 /* construct decoded vector */ |
92 | 92 |
93 WebRtcIlbcfix_CbConstruct( | 93 if (!WebRtcIlbcfix_CbConstruct(reverseDecresidual, iLBC_encbits->cb_index, |
94 reverseDecresidual, | 94 iLBC_encbits->gain_index, |
95 iLBC_encbits->cb_index, iLBC_encbits->gain_index, | 95 mem + CB_MEML - ST_MEM_L_TBL, ST_MEM_L_TBL, |
96 mem+CB_MEML-ST_MEM_L_TBL, | 96 diff)) |
97 ST_MEM_L_TBL, diff | 97 return 0; // Error. |
98 ); | |
99 | 98 |
100 /* get decoded residual from reversed vector */ | 99 /* get decoded residual from reversed vector */ |
101 | 100 |
102 WebRtcSpl_MemCpyReversedOrder(&decresidual[start_pos-1], | 101 WebRtcSpl_MemCpyReversedOrder(&decresidual[start_pos-1], |
103 reverseDecresidual, diff); | 102 reverseDecresidual, diff); |
104 } | 103 } |
105 | 104 |
106 /* counter for predicted subframes */ | 105 /* counter for predicted subframes */ |
107 | 106 |
108 subcount=1; | 107 subcount=1; |
109 | 108 |
110 /* forward prediction of subframes */ | 109 /* forward prediction of subframes */ |
111 | 110 |
112 if (iLBCdec_inst->nsub > iLBC_encbits->startIdx + 1) { | 111 if (iLBCdec_inst->nsub > iLBC_encbits->startIdx + 1) { |
113 | 112 |
114 /* setup memory */ | 113 /* setup memory */ |
115 WebRtcSpl_MemSetW16(mem, 0, CB_MEML-STATE_LEN); | 114 WebRtcSpl_MemSetW16(mem, 0, CB_MEML-STATE_LEN); |
116 WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-STATE_LEN, | 115 WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-STATE_LEN, |
117 decresidual+(iLBC_encbits->startIdx-1)*SUBL, STATE_LEN
); | 116 decresidual+(iLBC_encbits->startIdx-1)*SUBL, STATE_LEN
); |
118 | 117 |
119 /* loop over subframes to encode */ | 118 /* loop over subframes to encode */ |
120 | 119 |
121 size_t Nfor = iLBCdec_inst->nsub - iLBC_encbits->startIdx - 1; | 120 size_t Nfor = iLBCdec_inst->nsub - iLBC_encbits->startIdx - 1; |
122 for (subframe=0; subframe<Nfor; subframe++) { | 121 for (subframe=0; subframe<Nfor; subframe++) { |
123 | 122 |
124 /* construct decoded vector */ | 123 /* construct decoded vector */ |
125 WebRtcIlbcfix_CbConstruct( | 124 if (!WebRtcIlbcfix_CbConstruct( |
126 &decresidual[(iLBC_encbits->startIdx+1+subframe)*SUBL], | 125 &decresidual[(iLBC_encbits->startIdx + 1 + subframe) * SUBL], |
127 iLBC_encbits->cb_index+subcount*CB_NSTAGES, | 126 iLBC_encbits->cb_index + subcount * CB_NSTAGES, |
128 iLBC_encbits->gain_index+subcount*CB_NSTAGES, | 127 iLBC_encbits->gain_index + subcount * CB_NSTAGES, mem, MEM_LF_TBL, |
129 mem, MEM_LF_TBL, SUBL | 128 SUBL)) |
130 ); | 129 return 0; // Error; |
131 | 130 |
132 /* update memory */ | 131 /* update memory */ |
133 memmove(mem, mem + SUBL, (CB_MEML - SUBL) * sizeof(*mem)); | 132 memmove(mem, mem + SUBL, (CB_MEML - SUBL) * sizeof(*mem)); |
134 WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-SUBL, | 133 WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-SUBL, |
135 &decresidual[(iLBC_encbits->startIdx+1+subframe)*SUB
L], SUBL); | 134 &decresidual[(iLBC_encbits->startIdx+1+subframe)*SUB
L], SUBL); |
136 | 135 |
137 subcount++; | 136 subcount++; |
138 } | 137 } |
139 | 138 |
140 } | 139 } |
(...skipping 12 matching lines...) Expand all Loading... |
153 WebRtcSpl_MemCpyReversedOrder(mem+CB_MEML-1, | 152 WebRtcSpl_MemCpyReversedOrder(mem+CB_MEML-1, |
154 decresidual+(iLBC_encbits->startIdx-1)*SUBL, m
eml_gotten); | 153 decresidual+(iLBC_encbits->startIdx-1)*SUBL, m
eml_gotten); |
155 WebRtcSpl_MemSetW16(mem, 0, CB_MEML - meml_gotten); | 154 WebRtcSpl_MemSetW16(mem, 0, CB_MEML - meml_gotten); |
156 | 155 |
157 /* loop over subframes to decode */ | 156 /* loop over subframes to decode */ |
158 | 157 |
159 size_t Nback = iLBC_encbits->startIdx - 1; | 158 size_t Nback = iLBC_encbits->startIdx - 1; |
160 for (subframe=0; subframe<Nback; subframe++) { | 159 for (subframe=0; subframe<Nback; subframe++) { |
161 | 160 |
162 /* construct decoded vector */ | 161 /* construct decoded vector */ |
163 WebRtcIlbcfix_CbConstruct( | 162 if (!WebRtcIlbcfix_CbConstruct( |
164 &reverseDecresidual[subframe*SUBL], | 163 &reverseDecresidual[subframe * SUBL], |
165 iLBC_encbits->cb_index+subcount*CB_NSTAGES, | 164 iLBC_encbits->cb_index + subcount * CB_NSTAGES, |
166 iLBC_encbits->gain_index+subcount*CB_NSTAGES, | 165 iLBC_encbits->gain_index + subcount * CB_NSTAGES, mem, MEM_LF_TBL, |
167 mem, MEM_LF_TBL, SUBL | 166 SUBL)) |
168 ); | 167 return 0; // Error. |
169 | 168 |
170 /* update memory */ | 169 /* update memory */ |
171 memmove(mem, mem + SUBL, (CB_MEML - SUBL) * sizeof(*mem)); | 170 memmove(mem, mem + SUBL, (CB_MEML - SUBL) * sizeof(*mem)); |
172 WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-SUBL, | 171 WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-SUBL, |
173 &reverseDecresidual[subframe*SUBL], SUBL); | 172 &reverseDecresidual[subframe*SUBL], SUBL); |
174 | 173 |
175 subcount++; | 174 subcount++; |
176 } | 175 } |
177 | 176 |
178 /* get decoded residual from reversed vector */ | 177 /* get decoded residual from reversed vector */ |
179 WebRtcSpl_MemCpyReversedOrder(decresidual+SUBL*Nback-1, | 178 WebRtcSpl_MemCpyReversedOrder(decresidual+SUBL*Nback-1, |
180 reverseDecresidual, SUBL*Nback); | 179 reverseDecresidual, SUBL*Nback); |
181 } | 180 } |
| 181 |
| 182 return 1; // Success. |
182 } | 183 } |
OLD | NEW |