blob: 7343530a5e274e74a182ac038d6c76c36aa7770a [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:251/*
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
Timothy Gu31117832020-12-19 06:25:5719#include "modules/audio_coding/codecs/ilbc/simple_interpolate_lsf.h"
20
Mirko Bonadei06c2aa92018-02-01 14:11:4121#include "modules/audio_coding/codecs/ilbc/bw_expand.h"
22#include "modules/audio_coding/codecs/ilbc/constants.h"
Timothy Gu31117832020-12-19 06:25:5723#include "modules/audio_coding/codecs/ilbc/defines.h"
24#include "modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_enc.h"
niklase@google.com470e71d2011-07-07 08:21:2525
26/*----------------------------------------------------------------*
27 * lsf interpolator (subrutine to LPCencode)
28 *---------------------------------------------------------------*/
29
30void WebRtcIlbcfix_SimpleInterpolateLsf(
pbos@webrtc.org0946a562013-04-09 00:28:0631 int16_t *syntdenum, /* (o) the synthesis filter denominator
niklase@google.com470e71d2011-07-07 08:21:2532 resulting from the quantized
33 interpolated lsf Q12 */
pbos@webrtc.org0946a562013-04-09 00:28:0634 int16_t *weightdenum, /* (o) the weighting filter denominator
niklase@google.com470e71d2011-07-07 08:21:2535 resulting from the unquantized
36 interpolated lsf Q12 */
pbos@webrtc.org0946a562013-04-09 00:28:0637 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
niklase@google.com470e71d2011-07-07 08:21:2540 the previous signal frame Q13 */
pbos@webrtc.org0946a562013-04-09 00:28:0641 int16_t *lsfdeqold, /* (i) the dequantized lsf coefficients of the
niklase@google.com470e71d2011-07-07 08:21:2542 previous signal frame Q13 */
pbos@webrtc.org0946a562013-04-09 00:28:0643 int16_t length, /* (i) should equate FILTERORDER */
pbos@webrtc.orgeb544462014-12-17 15:23:2944 IlbcEncoder *iLBCenc_inst
niklase@google.com470e71d2011-07-07 08:21:2545 /* (i/o) the encoder state structure */
46 ) {
Peter Kastingdce40cf2015-08-24 21:52:2347 size_t i;
48 int pos, lp_length;
niklase@google.com470e71d2011-07-07 08:21:2549
pbos@webrtc.org0946a562013-04-09 00:28:0650 int16_t *lsf2, *lsfdeq2;
niklase@google.com470e71d2011-07-07 08:21:2551 /* Stack based */
pbos@webrtc.org0946a562013-04-09 00:28:0652 int16_t lp[LPC_FILTERORDER + 1];
niklase@google.com470e71d2011-07-07 08:21:2553
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 */
turajs@google.comac55f7b2011-08-26 16:02:1663 WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfdeqold, lsfdeq,
64 WebRtcIlbcfix_kLsfWeight30ms[0],
65 length);
niklase@google.com470e71d2011-07-07 08:21:2566 WEBRTC_SPL_MEMCPY_W16(syntdenum, lp, lp_length);
67
68 /* Calculate Weighting filter from quantized LSF */
turajs@google.comac55f7b2011-08-26 16:02:1669 WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfold, lsf,
70 WebRtcIlbcfix_kLsfWeight30ms[0],
71 length);
72 WebRtcIlbcfix_BwExpand(weightdenum, lp,
pbos@webrtc.org0946a562013-04-09 00:28:0673 (int16_t*)WebRtcIlbcfix_kLpcChirpWeightDenum,
74 (int16_t)lp_length);
niklase@google.com470e71d2011-07-07 08:21:2575
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 */
turajs@google.comac55f7b2011-08-26 16:02:1683 WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfdeq, lsfdeq2,
84 WebRtcIlbcfix_kLsfWeight30ms[i],
85 length);
niklase@google.com470e71d2011-07-07 08:21:2586 WEBRTC_SPL_MEMCPY_W16(syntdenum + pos, lp, lp_length);
87
88 /* Calculate Weighting filter from quantized LSF */
turajs@google.comac55f7b2011-08-26 16:02:1689 WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsf, lsf2,
90 WebRtcIlbcfix_kLsfWeight30ms[i],
91 length);
niklase@google.com470e71d2011-07-07 08:21:2592 WebRtcIlbcfix_BwExpand(weightdenum + pos, lp,
pbos@webrtc.org0946a562013-04-09 00:28:0693 (int16_t*)WebRtcIlbcfix_kLpcChirpWeightDenum,
94 (int16_t)lp_length);
niklase@google.com470e71d2011-07-07 08:21:2595
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 */
turajs@google.comac55f7b2011-08-26 16:02:16109 WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfdeqold, lsfdeq,
110 WebRtcIlbcfix_kLsfWeight20ms[i],
111 length);
niklase@google.com470e71d2011-07-07 08:21:25112 WEBRTC_SPL_MEMCPY_W16(syntdenum + pos, lp, lp_length);
113
114 /* Calculate Weighting filter from quantized LSF */
turajs@google.comac55f7b2011-08-26 16:02:16115 WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfold, lsf,
116 WebRtcIlbcfix_kLsfWeight20ms[i],
117 length);
niklase@google.com470e71d2011-07-07 08:21:25118 WebRtcIlbcfix_BwExpand(weightdenum+pos, lp,
pbos@webrtc.org0946a562013-04-09 00:28:06119 (int16_t*)WebRtcIlbcfix_kLpcChirpWeightDenum,
120 (int16_t)lp_length);
niklase@google.com470e71d2011-07-07 08:21:25121
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}