blob: aa858e94bb124900383a2f1f2e13423f082241d5 [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_InitEncode.c
16
17******************************************************************/
18
Timothy Gu31117832020-12-18 22:25:57 -080019#include "modules/audio_coding/codecs/ilbc/init_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"
niklase@google.com470e71d2011-07-07 08:21:25 +000023
24/*----------------------------------------------------------------*
25 * Initiation of encoder instance.
26 *---------------------------------------------------------------*/
27
Peter Kastinga8b335c2015-06-11 18:51:20 -070028int WebRtcIlbcfix_InitEncode( /* (o) Number of bytes encoded */
pbos@webrtc.orgeb544462014-12-17 15:23:29 +000029 IlbcEncoder *iLBCenc_inst, /* (i/o) Encoder instance */
pbos@webrtc.org0946a562013-04-09 00:28:06 +000030 int16_t mode) { /* (i) frame size mode */
niklase@google.com470e71d2011-07-07 08:21:25 +000031 iLBCenc_inst->mode = mode;
32
33 /* Set all the variables that are dependent on the frame size mode */
34 if (mode==30) {
35 iLBCenc_inst->blockl = BLOCKL_30MS;
36 iLBCenc_inst->nsub = NSUB_30MS;
37 iLBCenc_inst->nasub = NASUB_30MS;
38 iLBCenc_inst->lpc_n = LPC_N_30MS;
39 iLBCenc_inst->no_of_bytes = NO_OF_BYTES_30MS;
40 iLBCenc_inst->no_of_words = NO_OF_WORDS_30MS;
41 iLBCenc_inst->state_short_len=STATE_SHORT_LEN_30MS;
42 }
43 else if (mode==20) {
44 iLBCenc_inst->blockl = BLOCKL_20MS;
45 iLBCenc_inst->nsub = NSUB_20MS;
46 iLBCenc_inst->nasub = NASUB_20MS;
47 iLBCenc_inst->lpc_n = LPC_N_20MS;
48 iLBCenc_inst->no_of_bytes = NO_OF_BYTES_20MS;
49 iLBCenc_inst->no_of_words = NO_OF_WORDS_20MS;
50 iLBCenc_inst->state_short_len=STATE_SHORT_LEN_20MS;
51 }
52 else {
53 return(-1);
54 }
55
56 /* Clear the buffers and set the previous LSF and LSP to the mean value */
57 WebRtcSpl_MemSetW16(iLBCenc_inst->anaMem, 0, LPC_FILTERORDER);
58 WEBRTC_SPL_MEMCPY_W16(iLBCenc_inst->lsfold, WebRtcIlbcfix_kLsfMean, LPC_FILTERORDER);
59 WEBRTC_SPL_MEMCPY_W16(iLBCenc_inst->lsfdeqold, WebRtcIlbcfix_kLsfMean, LPC_FILTERORDER);
60 WebRtcSpl_MemSetW16(iLBCenc_inst->lpc_buffer, 0, LPC_LOOKBACK + BLOCKL_MAX);
61
62 /* Set the filter state of the HP filter to 0 */
63 WebRtcSpl_MemSetW16(iLBCenc_inst->hpimemx, 0, 2);
64 WebRtcSpl_MemSetW16(iLBCenc_inst->hpimemy, 0, 4);
65
66#ifdef SPLIT_10MS
67 /*Zeroing the past samples for 10msec Split*/
68 WebRtcSpl_MemSetW16(iLBCenc_inst->past_samples,0,160);
69 iLBCenc_inst->section = 0;
70#endif
71
Peter Kastingdce40cf2015-08-24 14:52:23 -070072 return (int)(iLBCenc_inst->no_of_bytes);
niklase@google.com470e71d2011-07-07 08:21:25 +000073}