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 "modules/audio_coding/codecs/ilbc/simple_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_enc.h"
25
26 /*----------------------------------------------------------------*
27 * lsf interpolator (subrutine to LPCencode)
28 *---------------------------------------------------------------*/
29
WebRtcIlbcfix_SimpleInterpolateLsf(int16_t * syntdenum,int16_t * weightdenum,int16_t * lsf,int16_t * lsfdeq,int16_t * lsfold,int16_t * lsfdeqold,int16_t length,IlbcEncoder * iLBCenc_inst)30 void WebRtcIlbcfix_SimpleInterpolateLsf(
31 int16_t *syntdenum, /* (o) the synthesis filter denominator
32 resulting from the quantized
33 interpolated lsf Q12 */
34 int16_t *weightdenum, /* (o) the weighting filter denominator
35 resulting from the unquantized
36 interpolated lsf Q12 */
37 int16_t *lsf, /* (i) the unquantized lsf coefficients Q13 */
38 int16_t *lsfdeq, /* (i) the dequantized lsf coefficients Q13 */
39 int16_t *lsfold, /* (i) the unquantized lsf coefficients of
40 the previous signal frame Q13 */
41 int16_t *lsfdeqold, /* (i) the dequantized lsf coefficients of the
42 previous signal frame Q13 */
43 int16_t length, /* (i) should equate FILTERORDER */
44 IlbcEncoder *iLBCenc_inst
45 /* (i/o) the encoder state structure */
46 ) {
47 size_t i;
48 int pos, lp_length;
49
50 int16_t *lsf2, *lsfdeq2;
51 /* Stack based */
52 int16_t lp[LPC_FILTERORDER + 1];
53
54 lsf2 = lsf + length;
55 lsfdeq2 = lsfdeq + length;
56 lp_length = length + 1;
57
58 if (iLBCenc_inst->mode==30) {
59 /* subframe 1: Interpolation between old and first set of
60 lsf coefficients */
61
62 /* Calculate Analysis/Syntehsis filter from quantized LSF */
63 WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfdeqold, lsfdeq,
64 WebRtcIlbcfix_kLsfWeight30ms[0],
65 length);
66 WEBRTC_SPL_MEMCPY_W16(syntdenum, lp, lp_length);
67
68 /* Calculate Weighting filter from quantized LSF */
69 WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfold, lsf,
70 WebRtcIlbcfix_kLsfWeight30ms[0],
71 length);
72 WebRtcIlbcfix_BwExpand(weightdenum, lp,
73 (int16_t*)WebRtcIlbcfix_kLpcChirpWeightDenum,
74 (int16_t)lp_length);
75
76 /* subframe 2 to 6: Interpolation between first and second
77 set of lsf coefficients */
78
79 pos = lp_length;
80 for (i = 1; i < iLBCenc_inst->nsub; i++) {
81
82 /* Calculate Analysis/Syntehsis filter from quantized LSF */
83 WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfdeq, lsfdeq2,
84 WebRtcIlbcfix_kLsfWeight30ms[i],
85 length);
86 WEBRTC_SPL_MEMCPY_W16(syntdenum + pos, lp, lp_length);
87
88 /* Calculate Weighting filter from quantized LSF */
89 WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsf, lsf2,
90 WebRtcIlbcfix_kLsfWeight30ms[i],
91 length);
92 WebRtcIlbcfix_BwExpand(weightdenum + pos, lp,
93 (int16_t*)WebRtcIlbcfix_kLpcChirpWeightDenum,
94 (int16_t)lp_length);
95
96 pos += lp_length;
97 }
98
99 /* update memory */
100
101 WEBRTC_SPL_MEMCPY_W16(lsfold, lsf2, length);
102 WEBRTC_SPL_MEMCPY_W16(lsfdeqold, lsfdeq2, length);
103
104 } else { /* iLBCenc_inst->mode==20 */
105 pos = 0;
106 for (i = 0; i < iLBCenc_inst->nsub; i++) {
107
108 /* Calculate Analysis/Syntehsis filter from quantized LSF */
109 WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfdeqold, lsfdeq,
110 WebRtcIlbcfix_kLsfWeight20ms[i],
111 length);
112 WEBRTC_SPL_MEMCPY_W16(syntdenum + pos, lp, lp_length);
113
114 /* Calculate Weighting filter from quantized LSF */
115 WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfold, lsf,
116 WebRtcIlbcfix_kLsfWeight20ms[i],
117 length);
118 WebRtcIlbcfix_BwExpand(weightdenum+pos, lp,
119 (int16_t*)WebRtcIlbcfix_kLpcChirpWeightDenum,
120 (int16_t)lp_length);
121
122 pos += lp_length;
123 }
124
125 /* update memory */
126
127 WEBRTC_SPL_MEMCPY_W16(lsfold, lsf, length);
128 WEBRTC_SPL_MEMCPY_W16(lsfdeqold, lsfdeq, length);
129
130 }
131
132 return;
133 }
134