Home | History | Annotate | Download | only in inc
      1 /*
      2  ** Copyright 2003-2010, VisualOn, Inc.
      3  **
      4  ** Licensed under the Apache License, Version 2.0 (the "License");
      5  ** you may not use this file except in compliance with the License.
      6  ** You may obtain a copy of the License at
      7  **
      8  **     http://www.apache.org/licenses/LICENSE-2.0
      9  **
     10  ** Unless required by applicable law or agreed to in writing, software
     11  ** distributed under the License is distributed on an "AS IS" BASIS,
     12  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  ** See the License for the specific language governing permissions and
     14  ** limitations under the License.
     15  */
     16 
     17 
     18 /*--------------------------------------------------------------------------*
     19  *                         DTX.H					    *
     20  *--------------------------------------------------------------------------*
     21  *       Static memory, constants and frametypes for the DTX 		    *
     22  *--------------------------------------------------------------------------*/
     23 
     24 #ifndef __DTX_H__
     25 #define __DTX_H__
     26 
     27 #define DTX_MAX_EMPTY_THRESH 50
     28 #define DTX_HIST_SIZE 8
     29 #define DTX_HIST_SIZE_MIN_ONE 7
     30 #define DTX_ELAPSED_FRAMES_THRESH (24 + 7 -1)
     31 #define DTX_HANG_CONST 7                   /* yields eight frames of SP HANGOVER  */
     32 #define INV_MED_THRESH 14564
     33 #define ISF_GAP  128                       /* 50 */
     34 #define ONE_MINUS_ISF_GAP 16384 - ISF_GAP
     35 #define ISF_GAP   128
     36 #define ISF_DITH_GAP   448
     37 #define ISF_FACTOR_LOW 256
     38 #define ISF_FACTOR_STEP 2
     39 #define GAIN_THR 180
     40 #define GAIN_FACTOR 75
     41 
     42 typedef struct
     43 {
     44     Word16 isf_hist[M * DTX_HIST_SIZE];
     45     Word16 log_en_hist[DTX_HIST_SIZE];
     46     Word16 hist_ptr;
     47     Word16 log_en_index;
     48     Word16 cng_seed;
     49     /* DTX handler stuff */
     50     Word16 dtxHangoverCount;
     51     Word16 decAnaElapsedCount;
     52     Word32 D[28];
     53     Word32 sumD[DTX_HIST_SIZE];
     54 } dtx_encState;
     55 
     56 #define SPEECH 0
     57 #define DTX 1
     58 #define DTX_MUTE 2
     59 
     60 #define TX_SPEECH 0
     61 #define TX_SID_FIRST 1
     62 #define TX_SID_UPDATE 2
     63 #define TX_NO_DATA 3
     64 
     65 #define RX_SPEECH_GOOD 0
     66 #define RX_SPEECH_PROBABLY_DEGRADED 1
     67 #define RX_SPEECH_LOST 2
     68 #define RX_SPEECH_BAD 3
     69 #define RX_SID_FIRST 4
     70 #define RX_SID_UPDATE 5
     71 #define RX_SID_BAD 6
     72 #define RX_NO_DATA 7
     73 
     74 /*****************************************************************************
     75  *
     76  * DEFINITION OF DATA TYPES
     77  *****************************************************************************/
     78 
     79 Word16 dtx_enc_init(dtx_encState ** st, Word16 isf_init[], VO_MEM_OPERATOR *pMemOP);
     80 Word16 dtx_enc_reset(dtx_encState * st, Word16 isf_init[]);
     81 void dtx_enc_exit(dtx_encState ** st, VO_MEM_OPERATOR *pMemOP);
     82 
     83 Word16 dtx_enc(
     84      dtx_encState * st,                    /* i/o : State struct                                         */
     85      Word16 isf[M],                        /* o   : CN ISF vector                                        */
     86      Word16 * exc2,                        /* o   : CN excitation                                        */
     87      Word16 ** prms
     88 );
     89 
     90 Word16 dtx_buffer(
     91      dtx_encState * st,                    /* i/o : State struct                    */
     92      Word16 isf_new[],                     /* i   : isf vector                      */
     93      Word32 enr,                           /* i   : residual energy (in L_FRAME)    */
     94      Word16 codec_mode
     95 );
     96 
     97 void tx_dtx_handler(dtx_encState * st,     /* i/o : State struct           */
     98      Word16 vad_flag,                      /* i   : vad decision           */
     99      Word16 * usedMode                     /* i/o : mode changed or not    */
    100 );
    101 
    102 void Qisf_ns(
    103      Word16 * isf1,                        /* input : ISF in the frequency domain (0..0.5) */
    104      Word16 * isf_q,                       /* output: quantized ISF                        */
    105      Word16 * indice                       /* output: quantization indices                 */
    106 );
    107 
    108 
    109 void Disf_ns(
    110      Word16 * indice,                      /* input:  quantization indices                  */
    111      Word16 * isf_q                        /* input : ISF in the frequency domain (0..0.5)  */
    112 );
    113 
    114 #endif  //__DTX_H__
    115 
    116