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