Home | History | Annotate | Download | only in ilbc
      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_InitEncode.c
     16 
     17 ******************************************************************/
     18 
     19 #include "defines.h"
     20 #include "constants.h"
     21 
     22 /*----------------------------------------------------------------*
     23  *  Initiation of encoder instance.
     24  *---------------------------------------------------------------*/
     25 
     26 int16_t WebRtcIlbcfix_InitEncode(  /* (o) Number of bytes encoded */
     27     iLBC_Enc_Inst_t *iLBCenc_inst,  /* (i/o) Encoder instance */
     28     int16_t mode) {  /* (i) frame size mode */
     29   iLBCenc_inst->mode = mode;
     30 
     31   /* Set all the variables that are dependent on the frame size mode */
     32   if (mode==30) {
     33     iLBCenc_inst->blockl = BLOCKL_30MS;
     34     iLBCenc_inst->nsub = NSUB_30MS;
     35     iLBCenc_inst->nasub = NASUB_30MS;
     36     iLBCenc_inst->lpc_n = LPC_N_30MS;
     37     iLBCenc_inst->no_of_bytes = NO_OF_BYTES_30MS;
     38     iLBCenc_inst->no_of_words = NO_OF_WORDS_30MS;
     39     iLBCenc_inst->state_short_len=STATE_SHORT_LEN_30MS;
     40   }
     41   else if (mode==20) {
     42     iLBCenc_inst->blockl = BLOCKL_20MS;
     43     iLBCenc_inst->nsub = NSUB_20MS;
     44     iLBCenc_inst->nasub = NASUB_20MS;
     45     iLBCenc_inst->lpc_n = LPC_N_20MS;
     46     iLBCenc_inst->no_of_bytes = NO_OF_BYTES_20MS;
     47     iLBCenc_inst->no_of_words = NO_OF_WORDS_20MS;
     48     iLBCenc_inst->state_short_len=STATE_SHORT_LEN_20MS;
     49   }
     50   else {
     51     return(-1);
     52   }
     53 
     54   /* Clear the buffers and set the previous LSF and LSP to the mean value */
     55   WebRtcSpl_MemSetW16(iLBCenc_inst->anaMem, 0, LPC_FILTERORDER);
     56   WEBRTC_SPL_MEMCPY_W16(iLBCenc_inst->lsfold, WebRtcIlbcfix_kLsfMean, LPC_FILTERORDER);
     57   WEBRTC_SPL_MEMCPY_W16(iLBCenc_inst->lsfdeqold, WebRtcIlbcfix_kLsfMean, LPC_FILTERORDER);
     58   WebRtcSpl_MemSetW16(iLBCenc_inst->lpc_buffer, 0, LPC_LOOKBACK + BLOCKL_MAX);
     59 
     60   /* Set the filter state of the HP filter to 0 */
     61   WebRtcSpl_MemSetW16(iLBCenc_inst->hpimemx, 0, 2);
     62   WebRtcSpl_MemSetW16(iLBCenc_inst->hpimemy, 0, 4);
     63 
     64 #ifdef SPLIT_10MS
     65   /*Zeroing the past samples for 10msec Split*/
     66   WebRtcSpl_MemSetW16(iLBCenc_inst->past_samples,0,160);
     67   iLBCenc_inst->section = 0;
     68 #endif
     69 
     70   return (iLBCenc_inst->no_of_bytes);
     71 }
     72