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_DecoderInterpolateLsp.c 16 17 ******************************************************************/ 18 19 #include "lsf_interpolate_to_poly_dec.h" 20 #include "bw_expand.h" 21 #include "defines.h" 22 #include "constants.h" 23 24 /*----------------------------------------------------------------* 25 * obtain synthesis and weighting filters form lsf coefficients 26 *---------------------------------------------------------------*/ 27 28 void WebRtcIlbcfix_DecoderInterpolateLsp( 29 int16_t *syntdenum, /* (o) synthesis filter coefficients */ 30 int16_t *weightdenum, /* (o) weighting denumerator 31 coefficients */ 32 int16_t *lsfdeq, /* (i) dequantized lsf coefficients */ 33 int16_t length, /* (i) length of lsf coefficient vector */ 34 iLBC_Dec_Inst_t *iLBCdec_inst 35 /* (i) the decoder state structure */ 36 ){ 37 int i, pos, lp_length; 38 int16_t lp[LPC_FILTERORDER + 1], *lsfdeq2; 39 40 lsfdeq2 = lsfdeq + length; 41 lp_length = length + 1; 42 43 if (iLBCdec_inst->mode==30) { 44 /* subframe 1: Interpolation between old and first LSF */ 45 46 WebRtcIlbcfix_LspInterpolate2PolyDec(lp, (*iLBCdec_inst).lsfdeqold, lsfdeq, 47 WebRtcIlbcfix_kLsfWeight30ms[0], length); 48 WEBRTC_SPL_MEMCPY_W16(syntdenum,lp,lp_length); 49 WebRtcIlbcfix_BwExpand(weightdenum, lp, (int16_t*)WebRtcIlbcfix_kLpcChirpSyntDenum, (int16_t)lp_length); 50 51 /* subframes 2 to 6: interpolation between first and last LSF */ 52 53 pos = lp_length; 54 for (i = 1; i < 6; i++) { 55 WebRtcIlbcfix_LspInterpolate2PolyDec(lp, lsfdeq, lsfdeq2, 56 WebRtcIlbcfix_kLsfWeight30ms[i], length); 57 WEBRTC_SPL_MEMCPY_W16(syntdenum + pos,lp,lp_length); 58 WebRtcIlbcfix_BwExpand(weightdenum + pos, lp, 59 (int16_t*)WebRtcIlbcfix_kLpcChirpSyntDenum, (int16_t)lp_length); 60 pos += lp_length; 61 } 62 } else { /* iLBCdec_inst->mode=20 */ 63 /* subframes 1 to 4: interpolation between old and new LSF */ 64 pos = 0; 65 for (i = 0; i < iLBCdec_inst->nsub; i++) { 66 WebRtcIlbcfix_LspInterpolate2PolyDec(lp, iLBCdec_inst->lsfdeqold, lsfdeq, 67 WebRtcIlbcfix_kLsfWeight20ms[i], length); 68 WEBRTC_SPL_MEMCPY_W16(syntdenum+pos,lp,lp_length); 69 WebRtcIlbcfix_BwExpand(weightdenum+pos, lp, 70 (int16_t*)WebRtcIlbcfix_kLpcChirpSyntDenum, (int16_t)lp_length); 71 pos += lp_length; 72 } 73 } 74 75 /* update memory */ 76 77 if (iLBCdec_inst->mode==30) { 78 WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->lsfdeqold, lsfdeq2, length); 79 } else { 80 WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->lsfdeqold, lsfdeq, length); 81 } 82 } 83