1 /* 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 * 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 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 /****************************************************************** 12 13 iLBC Speech Coder ANSI-C Source Code 14 15 WebRtcIlbcfix_SimpleInterpolateLsf.c 16 17 ******************************************************************/ 18 19 #include "defines.h" 20 #include "lsf_interpolate_to_poly_enc.h" 21 #include "bw_expand.h" 22 #include "constants.h" 23 24 /*----------------------------------------------------------------* 25 * lsf interpolator (subrutine to LPCencode) 26 *---------------------------------------------------------------*/ 27 28 void WebRtcIlbcfix_SimpleInterpolateLsf( 29 int16_t *syntdenum, /* (o) the synthesis filter denominator 30 resulting from the quantized 31 interpolated lsf Q12 */ 32 int16_t *weightdenum, /* (o) the weighting filter denominator 33 resulting from the unquantized 34 interpolated lsf Q12 */ 35 int16_t *lsf, /* (i) the unquantized lsf coefficients Q13 */ 36 int16_t *lsfdeq, /* (i) the dequantized lsf coefficients Q13 */ 37 int16_t *lsfold, /* (i) the unquantized lsf coefficients of 38 the previous signal frame Q13 */ 39 int16_t *lsfdeqold, /* (i) the dequantized lsf coefficients of the 40 previous signal frame Q13 */ 41 int16_t length, /* (i) should equate FILTERORDER */ 42 iLBC_Enc_Inst_t *iLBCenc_inst 43 /* (i/o) the encoder state structure */ 44 ) { 45 int i, pos, lp_length; 46 47 int16_t *lsf2, *lsfdeq2; 48 /* Stack based */ 49 int16_t lp[LPC_FILTERORDER + 1]; 50 51 lsf2 = lsf + length; 52 lsfdeq2 = lsfdeq + length; 53 lp_length = length + 1; 54 55 if (iLBCenc_inst->mode==30) { 56 /* subframe 1: Interpolation between old and first set of 57 lsf coefficients */ 58 59 /* Calculate Analysis/Syntehsis filter from quantized LSF */ 60 WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfdeqold, lsfdeq, 61 WebRtcIlbcfix_kLsfWeight30ms[0], 62 length); 63 WEBRTC_SPL_MEMCPY_W16(syntdenum, lp, lp_length); 64 65 /* Calculate Weighting filter from quantized LSF */ 66 WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfold, lsf, 67 WebRtcIlbcfix_kLsfWeight30ms[0], 68 length); 69 WebRtcIlbcfix_BwExpand(weightdenum, lp, 70 (int16_t*)WebRtcIlbcfix_kLpcChirpWeightDenum, 71 (int16_t)lp_length); 72 73 /* subframe 2 to 6: Interpolation between first and second 74 set of lsf coefficients */ 75 76 pos = lp_length; 77 for (i = 1; i < iLBCenc_inst->nsub; i++) { 78 79 /* Calculate Analysis/Syntehsis filter from quantized LSF */ 80 WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfdeq, lsfdeq2, 81 WebRtcIlbcfix_kLsfWeight30ms[i], 82 length); 83 WEBRTC_SPL_MEMCPY_W16(syntdenum + pos, lp, lp_length); 84 85 /* Calculate Weighting filter from quantized LSF */ 86 WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsf, lsf2, 87 WebRtcIlbcfix_kLsfWeight30ms[i], 88 length); 89 WebRtcIlbcfix_BwExpand(weightdenum + pos, lp, 90 (int16_t*)WebRtcIlbcfix_kLpcChirpWeightDenum, 91 (int16_t)lp_length); 92 93 pos += lp_length; 94 } 95 96 /* update memory */ 97 98 WEBRTC_SPL_MEMCPY_W16(lsfold, lsf2, length); 99 WEBRTC_SPL_MEMCPY_W16(lsfdeqold, lsfdeq2, length); 100 101 } else { /* iLBCenc_inst->mode==20 */ 102 pos = 0; 103 for (i = 0; i < iLBCenc_inst->nsub; i++) { 104 105 /* Calculate Analysis/Syntehsis filter from quantized LSF */ 106 WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfdeqold, lsfdeq, 107 WebRtcIlbcfix_kLsfWeight20ms[i], 108 length); 109 WEBRTC_SPL_MEMCPY_W16(syntdenum + pos, lp, lp_length); 110 111 /* Calculate Weighting filter from quantized LSF */ 112 WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfold, lsf, 113 WebRtcIlbcfix_kLsfWeight20ms[i], 114 length); 115 WebRtcIlbcfix_BwExpand(weightdenum+pos, lp, 116 (int16_t*)WebRtcIlbcfix_kLpcChirpWeightDenum, 117 (int16_t)lp_length); 118 119 pos += lp_length; 120 } 121 122 /* update memory */ 123 124 WEBRTC_SPL_MEMCPY_W16(lsfold, lsf, length); 125 WEBRTC_SPL_MEMCPY_W16(lsfdeqold, lsfdeq, length); 126 127 } 128 129 return; 130 } 131