blob: 9b2a0c0d41ad1a23ce05402220556635509e3840 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
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_LpcEncode.c
16
17******************************************************************/
18
Mirko Bonadei06c2aa92018-02-01 15:11:41 +010019#include "modules/audio_coding/codecs/ilbc/defines.h"
20#include "modules/audio_coding/codecs/ilbc/simple_lpc_analysis.h"
21#include "modules/audio_coding/codecs/ilbc/simple_interpolate_lsf.h"
22#include "modules/audio_coding/codecs/ilbc/simple_lsf_quant.h"
23#include "modules/audio_coding/codecs/ilbc/lsf_check.h"
24#include "modules/audio_coding/codecs/ilbc/constants.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000025
26/*----------------------------------------------------------------*
27 * lpc encoder
28 *---------------------------------------------------------------*/
29
30void WebRtcIlbcfix_LpcEncode(
pbos@webrtc.org0946a562013-04-09 00:28:06 +000031 int16_t *syntdenum, /* (i/o) synthesis filter coefficients
niklase@google.com470e71d2011-07-07 08:21:25 +000032 before/after encoding */
pbos@webrtc.org0946a562013-04-09 00:28:06 +000033 int16_t *weightdenum, /* (i/o) weighting denumerator coefficients
niklase@google.com470e71d2011-07-07 08:21:25 +000034 before/after encoding */
pbos@webrtc.org0946a562013-04-09 00:28:06 +000035 int16_t *lsf_index, /* (o) lsf quantization index */
36 int16_t *data, /* (i) Speech to do LPC analysis on */
pbos@webrtc.orgeb544462014-12-17 15:23:29 +000037 IlbcEncoder *iLBCenc_inst
niklase@google.com470e71d2011-07-07 08:21:25 +000038 /* (i/o) the encoder state structure */
39 ) {
40 /* Stack based */
pbos@webrtc.org0946a562013-04-09 00:28:06 +000041 int16_t lsf[LPC_FILTERORDER * LPC_N_MAX];
42 int16_t lsfdeq[LPC_FILTERORDER * LPC_N_MAX];
niklase@google.com470e71d2011-07-07 08:21:25 +000043
44 /* Calculate LSF's from the input speech */
45 WebRtcIlbcfix_SimpleLpcAnalysis(lsf, data, iLBCenc_inst);
46
47 /* Quantize the LSF's */
48 WebRtcIlbcfix_SimpleLsfQ(lsfdeq, lsf_index, lsf, iLBCenc_inst->lpc_n);
49
50 /* Stableize the LSF's if needed */
51 WebRtcIlbcfix_LsfCheck(lsfdeq, LPC_FILTERORDER, iLBCenc_inst->lpc_n);
52
53 /* Calculate the synthesis and weighting filter coefficients from
54 the optimal LSF and the dequantized LSF */
55 WebRtcIlbcfix_SimpleInterpolateLsf(syntdenum, weightdenum,
56 lsf, lsfdeq, iLBCenc_inst->lsfold,
57 iLBCenc_inst->lsfdeqold, LPC_FILTERORDER, iLBCenc_inst);
58
59 return;
60}