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

Side by Side Diff: webrtc/modules/audio_coding/codecs/isac/main/source/decode.c

Issue 1177993003: iSAC: Move global trig tables into the codec instance (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 6 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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 17 matching lines...) Expand all
28 28
29 #include <stdio.h> 29 #include <stdio.h>
30 #include <stdlib.h> 30 #include <stdlib.h>
31 #include <string.h> 31 #include <string.h>
32 32
33 33
34 /* 34 /*
35 * function to decode the bitstream 35 * function to decode the bitstream
36 * returns the total number of bytes in the stream 36 * returns the total number of bytes in the stream
37 */ 37 */
38 int WebRtcIsac_DecodeLb(float* signal_out, ISACLBDecStruct* ISACdecLB_obj, 38 int WebRtcIsac_DecodeLb(const TransformTables* transform_tables,
39 float* signal_out, ISACLBDecStruct* ISACdecLB_obj,
39 int16_t* current_framesamples, 40 int16_t* current_framesamples,
40 int16_t isRCUPayload) { 41 int16_t isRCUPayload) {
41 int k; 42 int k;
42 int len, err; 43 int len, err;
43 int16_t bandwidthInd; 44 int16_t bandwidthInd;
44 45
45 float LP_dec_float[FRAMESAMPLES_HALF]; 46 float LP_dec_float[FRAMESAMPLES_HALF];
46 float HP_dec_float[FRAMESAMPLES_HALF]; 47 float HP_dec_float[FRAMESAMPLES_HALF];
47 48
48 double LPw[FRAMESAMPLES_HALF]; 49 double LPw[FRAMESAMPLES_HALF];
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 return err; 116 return err;
116 } 117 }
117 /* Decode & de-quantize spectrum. */ 118 /* Decode & de-quantize spectrum. */
118 len = WebRtcIsac_DecodeSpec(&ISACdecLB_obj->bitstr_obj, AvgPitchGain_Q12, 119 len = WebRtcIsac_DecodeSpec(&ISACdecLB_obj->bitstr_obj, AvgPitchGain_Q12,
119 kIsacLowerBand, real_f, imag_f); 120 kIsacLowerBand, real_f, imag_f);
120 if (len < 0) { 121 if (len < 0) {
121 return len; 122 return len;
122 } 123 }
123 124
124 /* Inverse transform. */ 125 /* Inverse transform. */
125 WebRtcIsac_Spec2time(real_f, imag_f, LPw, HPw, 126 WebRtcIsac_Spec2time(transform_tables, real_f, imag_f, LPw, HPw,
126 &ISACdecLB_obj->fftstr_obj); 127 &ISACdecLB_obj->fftstr_obj);
127 128
128 /* Convert PitchGains back to float for pitchfilter_post */ 129 /* Convert PitchGains back to float for pitchfilter_post */
129 for (k = 0; k < 4; k++) { 130 for (k = 0; k < 4; k++) {
130 PitchGains[k] = ((float)PitchGains_Q12[k]) / 4096; 131 PitchGains[k] = ((float)PitchGains_Q12[k]) / 4096;
131 } 132 }
132 if (isRCUPayload) { 133 if (isRCUPayload) {
133 for (k = 0; k < 240; k++) { 134 for (k = 0; k < 240; k++) {
134 LPw[k] *= RCU_TRANSCODING_SCALE_INVERSE; 135 LPw[k] *= RCU_TRANSCODING_SCALE_INVERSE;
135 HPw[k] *= RCU_TRANSCODING_SCALE_INVERSE; 136 HPw[k] *= RCU_TRANSCODING_SCALE_INVERSE;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 } 175 }
175 176
176 177
177 /* 178 /*
178 * This decode function is called when the codec is operating in 16 kHz 179 * This decode function is called when the codec is operating in 16 kHz
179 * bandwidth to decode the upperband, i.e. 8-16 kHz. 180 * bandwidth to decode the upperband, i.e. 8-16 kHz.
180 * 181 *
181 * Contrary to lower-band, the upper-band (8-16 kHz) is not split in 182 * Contrary to lower-band, the upper-band (8-16 kHz) is not split in
182 * frequency, but split to 12 sub-frames, i.e. twice as lower-band. 183 * frequency, but split to 12 sub-frames, i.e. twice as lower-band.
183 */ 184 */
184 int WebRtcIsac_DecodeUb16(float* signal_out, ISACUBDecStruct* ISACdecUB_obj, 185 int WebRtcIsac_DecodeUb16(const TransformTables* transform_tables,
186 float* signal_out, ISACUBDecStruct* ISACdecUB_obj,
185 int16_t isRCUPayload) { 187 int16_t isRCUPayload) {
186 int len, err; 188 int len, err;
187 189
188 double halfFrameFirst[FRAMESAMPLES_HALF]; 190 double halfFrameFirst[FRAMESAMPLES_HALF];
189 double halfFrameSecond[FRAMESAMPLES_HALF]; 191 double halfFrameSecond[FRAMESAMPLES_HALF];
190 192
191 double percepFilterParam[(UB_LPC_ORDER + 1) * (SUBFRAMES << 1) + 193 double percepFilterParam[(UB_LPC_ORDER + 1) * (SUBFRAMES << 1) +
192 (UB_LPC_ORDER + 1)]; 194 (UB_LPC_ORDER + 1)];
193 195
194 double real_f[FRAMESAMPLES_HALF]; 196 double real_f[FRAMESAMPLES_HALF];
(...skipping 16 matching lines...) Expand all
211 return len; 213 return len;
212 } 214 }
213 if (isRCUPayload) { 215 if (isRCUPayload) {
214 int n; 216 int n;
215 for (n = 0; n < 240; n++) { 217 for (n = 0; n < 240; n++) {
216 real_f[n] *= RCU_TRANSCODING_SCALE_UB_INVERSE; 218 real_f[n] *= RCU_TRANSCODING_SCALE_UB_INVERSE;
217 imag_f[n] *= RCU_TRANSCODING_SCALE_UB_INVERSE; 219 imag_f[n] *= RCU_TRANSCODING_SCALE_UB_INVERSE;
218 } 220 }
219 } 221 }
220 /* Inverse transform. */ 222 /* Inverse transform. */
221 WebRtcIsac_Spec2time(real_f, imag_f, halfFrameFirst, halfFrameSecond, 223 WebRtcIsac_Spec2time(transform_tables,
224 real_f, imag_f, halfFrameFirst, halfFrameSecond,
222 &ISACdecUB_obj->fftstr_obj); 225 &ISACdecUB_obj->fftstr_obj);
223 226
224 /* Perceptual post-filtering (using normalized lattice filter). */ 227 /* Perceptual post-filtering (using normalized lattice filter). */
225 WebRtcIsac_NormLatticeFilterAr( 228 WebRtcIsac_NormLatticeFilterAr(
226 UB_LPC_ORDER, ISACdecUB_obj->maskfiltstr_obj.PostStateLoF, 229 UB_LPC_ORDER, ISACdecUB_obj->maskfiltstr_obj.PostStateLoF,
227 (ISACdecUB_obj->maskfiltstr_obj).PostStateLoG, halfFrameFirst, 230 (ISACdecUB_obj->maskfiltstr_obj).PostStateLoG, halfFrameFirst,
228 &percepFilterParam[(UB_LPC_ORDER + 1)], signal_out); 231 &percepFilterParam[(UB_LPC_ORDER + 1)], signal_out);
229 232
230 WebRtcIsac_NormLatticeFilterAr( 233 WebRtcIsac_NormLatticeFilterAr(
231 UB_LPC_ORDER, ISACdecUB_obj->maskfiltstr_obj.PostStateLoF, 234 UB_LPC_ORDER, ISACdecUB_obj->maskfiltstr_obj.PostStateLoF,
232 (ISACdecUB_obj->maskfiltstr_obj).PostStateLoG, halfFrameSecond, 235 (ISACdecUB_obj->maskfiltstr_obj).PostStateLoG, halfFrameSecond,
233 &percepFilterParam[(UB_LPC_ORDER + 1) * SUBFRAMES + (UB_LPC_ORDER + 1)], 236 &percepFilterParam[(UB_LPC_ORDER + 1) * SUBFRAMES + (UB_LPC_ORDER + 1)],
234 &signal_out[FRAMESAMPLES_HALF]); 237 &signal_out[FRAMESAMPLES_HALF]);
235 238
236 return len; 239 return len;
237 } 240 }
238 241
239 /* 242 /*
240 * This decode function is called when the codec operates at 0-12 kHz 243 * This decode function is called when the codec operates at 0-12 kHz
241 * bandwidth to decode the upperband, i.e. 8-12 kHz. 244 * bandwidth to decode the upperband, i.e. 8-12 kHz.
242 * 245 *
243 * At the encoder the upper-band is split into two band, 8-12 kHz & 12-16 246 * At the encoder the upper-band is split into two band, 8-12 kHz & 12-16
244 * kHz, and only 8-12 kHz is encoded. At the decoder, 8-12 kHz band is 247 * kHz, and only 8-12 kHz is encoded. At the decoder, 8-12 kHz band is
245 * reconstructed and 12-16 kHz replaced with zeros. Then two bands 248 * reconstructed and 12-16 kHz replaced with zeros. Then two bands
246 * are combined, to reconstruct the upperband 8-16 kHz. 249 * are combined, to reconstruct the upperband 8-16 kHz.
247 */ 250 */
248 int WebRtcIsac_DecodeUb12(float* signal_out, ISACUBDecStruct* ISACdecUB_obj, 251 int WebRtcIsac_DecodeUb12(const TransformTables* transform_tables,
249 int16_t isRCUPayload) { 252 float* signal_out, ISACUBDecStruct* ISACdecUB_obj,
253 int16_t isRCUPayload) {
250 int len, err; 254 int len, err;
251 255
252 float LP_dec_float[FRAMESAMPLES_HALF]; 256 float LP_dec_float[FRAMESAMPLES_HALF];
253 float HP_dec_float[FRAMESAMPLES_HALF]; 257 float HP_dec_float[FRAMESAMPLES_HALF];
254 258
255 double LPw[FRAMESAMPLES_HALF]; 259 double LPw[FRAMESAMPLES_HALF];
256 double HPw[FRAMESAMPLES_HALF]; 260 double HPw[FRAMESAMPLES_HALF];
257 261
258 double percepFilterParam[(UB_LPC_ORDER + 1)*SUBFRAMES]; 262 double percepFilterParam[(UB_LPC_ORDER + 1)*SUBFRAMES];
259 263
(...skipping 17 matching lines...) Expand all
277 } 281 }
278 282
279 if (isRCUPayload) { 283 if (isRCUPayload) {
280 int n; 284 int n;
281 for (n = 0; n < 240; n++) { 285 for (n = 0; n < 240; n++) {
282 real_f[n] *= RCU_TRANSCODING_SCALE_UB_INVERSE; 286 real_f[n] *= RCU_TRANSCODING_SCALE_UB_INVERSE;
283 imag_f[n] *= RCU_TRANSCODING_SCALE_UB_INVERSE; 287 imag_f[n] *= RCU_TRANSCODING_SCALE_UB_INVERSE;
284 } 288 }
285 } 289 }
286 /* Inverse transform. */ 290 /* Inverse transform. */
287 WebRtcIsac_Spec2time(real_f, imag_f, LPw, HPw, &ISACdecUB_obj->fftstr_obj); 291 WebRtcIsac_Spec2time(transform_tables,
292 real_f, imag_f, LPw, HPw, &ISACdecUB_obj->fftstr_obj);
288 /* perceptual post-filtering (using normalized lattice filter) */ 293 /* perceptual post-filtering (using normalized lattice filter) */
289 WebRtcIsac_NormLatticeFilterAr(UB_LPC_ORDER, 294 WebRtcIsac_NormLatticeFilterAr(UB_LPC_ORDER,
290 ISACdecUB_obj->maskfiltstr_obj.PostStateLoF, 295 ISACdecUB_obj->maskfiltstr_obj.PostStateLoF,
291 (ISACdecUB_obj->maskfiltstr_obj).PostStateLoG, 296 (ISACdecUB_obj->maskfiltstr_obj).PostStateLoG,
292 LPw, percepFilterParam, LP_dec_float); 297 LPw, percepFilterParam, LP_dec_float);
293 /* Zero for 12-16 kHz. */ 298 /* Zero for 12-16 kHz. */
294 memset(HP_dec_float, 0, sizeof(float) * (FRAMESAMPLES_HALF)); 299 memset(HP_dec_float, 0, sizeof(float) * (FRAMESAMPLES_HALF));
295 /* Recombine the 2 bands. */ 300 /* Recombine the 2 bands. */
296 WebRtcIsac_FilterAndCombineFloat(HP_dec_float, LP_dec_float, signal_out, 301 WebRtcIsac_FilterAndCombineFloat(HP_dec_float, LP_dec_float, signal_out,
297 &ISACdecUB_obj->postfiltbankstr_obj); 302 &ISACdecUB_obj->postfiltbankstr_obj);
298 return len; 303 return len;
299 } 304 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698