⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ld8a.inc

📁 基于ADSP的G.729语音编解码程序
💻 INC
字号:
/*-------------------------------------------------------------------------*
* LD8A.INC---Function prototypes and constants use for G.729A 8kb/s coder. *
* $$01/10/2000 rejustified the tables used in audio codec                  *
*--------------------------------------------------------------------------*/



/*-------------------------------------------------------------------------*
* Codec constant parameters (coder, decoder, and postfilter)               *
*--------------------------------------------------------------------------*/
#define   L_TOTAL       240    /* Total size of speech buffer.             */
#define   L_WINDOW      240    /* Window size in LP analysis.              */
#define   L_NEXT        40     /* Lookahead in LP analysis.                */
#define   L_FRAME       80     /* Frame size.                              */
#define   L_SUBFR       40     /* Subframe size.                           */
#define   NUM_OF_FRAME  2      /* number of subframes in one frame.        */
#define   M             10     /* Order of LP filter.                      */
#define   M_2           5      /* sub order of LP filter                   */
#define   MP1           (M+1)  /* Order of LP filter + 1                   */
#define   PIT_MIN       20     /* Minimum pitch lag.                       */
#define   PIT_MAX       143    /* Maximum pitch lag.                       */
#define   L_INTERPOL    (10+1) /* Length of filter for interpolation.      */
#define   GAMMA1        24576  /* Bandwitdh factor = 0.75   in Q15         */
#define   PRM_SIZE      11     /* Size of vector of analysis parameters.   */
#define   SERIAL_SIZE   40     /* bfi+ number of speech bits               */
#define   SHARPMAX      13017  /* Maximum value of pitch sharpening 0.8 Q14*/
#define   SHARPMIN      3277   /* Minimum value of pitch sharpening 0.2 Q14*/

/*-------------------------------------------------------------------------*
*       LTP constant parameters                                            *
*--------------------------------------------------------------------------*/
#define   UP_SAMP       3
#define   L_INTER10     10
#define   FIR_SIZE_SYN  (UP_SAMP*L_INTER10+1)

/*-------------------------------------------------------------------------*
* Innovative codebook.                                                     *
*--------------------------------------------------------------------------*/
#define   DIM_RR        616 /* size of correlation matrix                  */
#define   NB_POS        8   /* Number of positions for each pulse          */
#define   STEP          5   /* Step betweem position of the same pulse.    */
#define   MSIZE         64  /* vectors size for cross-correlation in pulses*/
#define   _1_2          16384
#define   _1_4          8192
#define   _1_8          4096
#define   _1_16         2048

/*-------------------------------------------------------------------------*
*       LSP constant parameters                                            *
*--------------------------------------------------------------------------*/
#define   NC            5           /* NC = M/2                            */
#define   MA_NP         4           /* MA prediction order for LSP         */
#define   MODE          2           /* number of modes for MA prediction   */
#define   NC0_B         7           /* number of first stage bits          */
#define   NC1_B         5           /* number of second stage bits         */
#define   NC0           (1<<NC0_B)
#define   NC1           (1<<NC1_B)
#define   L_LIMIT       40          /* Q13:0.005                           */
#define   M_LIMIT       25681       /* Q13:3.135                           */
#define   GAP1          10          /* Q13                                 */
#define   GAP2          5           /* Q13                                 */
#define   GAP3          321         /* Q13                                 */
#define   GRID_POINTS   50
#define   PI04          1029        /* Q13  pi*0.04                        */
#define   PI92          23677       /* Q13  pi*0.92                        */
#define   CONST10       20480       /* Q11  10.0                           */
#define   CONST12       19661       /* Q14  1.2                            */

/*-------------------------------------------------------------------------*
* gain VQ constants.                                                       *
*--------------------------------------------------------------------------*/
#define   NCODE1_B      3                /* number of Codebook-bit         */
#define   NCODE2_B      4                /* number of Codebook-bit         */
#define   NCODE1        (1<<NCODE1_B)    /* Codebook 1 size                */
#define   NCODE2        (1<<NCODE2_B)    /* Codebook 2 size                */
#define   NCAN1         4                /* Pre-selecting order for #1     */
#define   NCAN2         8                /* Pre-selecting order for #2     */
#define   INV_COEF      -17103           /* Q19                            */

/*-------------------------------------------------------------------------*
* Bitstream function                                                       *
*--------------------------------------------------------------------------*/
#define   BIT_0			0x007f /* definition of zero-bit in bit-stream     */
#define   BIT_1			0x0081 /* definition of one-bit in bit-stream      */
#define   SYNC_WORD		0x6b21 /* definition of frame erasure flag         */
#define   SIZE_WORD	    80     /* number of speech bits                    */

/*-------------------------------------------------------------------------*
* Post-filter functions.                                                   *
*--------------------------------------------------------------------------*/
#define   L_H 22                /* truncated impulse response of A(z/g1)/A(z/g2) */
#define   GAMMAP        16384   /* 0.5               (Q15)                 */
#define   INV_GAMMAP    21845   /* 1/(1+GAMMAP)      (Q15)                 */
#define   GAMMAP_2      10923   /* GAMMAP/(1+GAMMAP) (Q15)                 */
#define   GAMMA2_PST    18022   /* Formant postfilt factor (numerator)   0.55 Q15 */
#define   GAMMA1_PST    22938   /* Formant postfilt factor (denominator) 0.70 Q15 */
#define   MU            26214   /* Factor for tilt compensation filter   0.8  Q15 */
#define   AGC_FAC       29491   /* Factor for automatic gain control     0.9  Q15 */
#define   AGC_FAC1      (32767 - AGC_FAC)    /* 1-AGC_FAC in Q15            */

/*--------------------------------------------------------------------------*
 * Constants and prototypes for taming procedure.                           *
 *--------------------------------------------------------------------------*/
#define   GPCLIP        15564      /* Maximum pitch gain if taming is needed Q14*/
#define   GPCLIP2       481        /* Maximum pitch gain if taming is needed Q9*/
#define   GP0999        16383      /* Maximum pitch gain if taming is needed   */
#define   THRESH_ERRHI  0x3A98     /* Error threshold taming 16384. * 60000.   */ 
#define   THRESH_ERRLO  0x0000     /* Error threshold taming 16384. * 60000.   */ 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -