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