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

📄 g729ev_celp2s_encod.c

📁 最新的ITU-T的宽带语音编解码标准G.729.1,是对原先的G.729的最好的调整.码流输出速率可以进行自适应调整.满足未来通信要求.希望对大家有所帮助.
💻 C
📖 第 1 页 / 共 3 页
字号:
/* ITU-T G.729EV Optimization/Characterization Candidate                         *//* Version:       1.0.a                                                          *//* Revision Date: June 28, 2006                                                  *//*   ITU-T G.729EV Optimization/Characterization Candidate    ANSI-C Source Code   Copyright (c) 2006    France Telecom, Matsushita Electric, Mindspeed, Siemens AG, ETRI, VoiceAge Corp.   All rights reserved*/#include "G729EV_CELP2S_encod.h"/*-----------------------------------------------------------* *  Function  G729EV_CELP2S_InitEncoder()                    * *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                    * *   Variables initialisation for the G.729 coder            * *-----------------------------------------------------------*/void G729EV_CELP2S_InitEncoder(G729EV_G729_CODSTAT * pCodStat,  /* (o)  Core coder parameters   */                               Word16 rate)                     /* (i)  coder rate              */{  Word16    i;  pCodStat->rate = rate;#if (WMOPS)  move16();#endif  /* Static vectors to zero */  G729EV_G729_Set_zero(pCodStat->old_speech, G729EV_G729_L_TOTAL);  G729EV_G729_Set_zero(pCodStat->old_exc, G729EV_G729_PIT_MAX + G729EV_G729_L_INTERPOL);  G729EV_G729_Set_zero(pCodStat->old_wsp, G729EV_G729_PIT_MAX);  G729EV_G729_Set_zero(pCodStat->mem_syn, G729EV_G729_M);  G729EV_G729_Set_zero(pCodStat->mem_w, G729EV_G729_M);  G729EV_G729_Set_zero(pCodStat->mem_w0, G729EV_G729_M);  G729EV_G729_Set_zero(pCodStat->mem_w0_2, G729EV_G729_M_LPC);  G729EV_G729_Set_zero(pCodStat->mem_err2, G729EV_G729_M_LPC);  G729EV_G729_Set_zero(pCodStat->mem_err, G729EV_G729_M);  G729EV_G729_Set_zero(pCodStat->mem_zero, G729EV_G729_L_SUBFR);  G729EV_G729_Set_zero(pCodStat->mem_synth, G729EV_G729_M_LPC);  pCodStat->pit_sharp = G729EV_G729_SHARPMIN;#if (WMOPS)  move16();#endif  /* Initialize past_qua_en */  pCodStat->past_qua_en[0] = (Word16) (-14336);  pCodStat->past_qua_en[1] = (Word16) (-14336);  pCodStat->past_qua_en[2] = (Word16) (-14336);  pCodStat->past_qua_en[3] = (Word16) (-14336);#if (WMOPS)  move16();  move16();  move16();  move16();#endif  /* Initialize lsp_old[] */  pCodStat->lsp_old[0] = (Word16) (30000);  pCodStat->lsp_old[1] = (Word16) (26000);  pCodStat->lsp_old[2] = (Word16) (21000);  pCodStat->lsp_old[3] = (Word16) (15000);  pCodStat->lsp_old[4] = (Word16) (8000);  pCodStat->lsp_old[5] = (Word16) (0);  pCodStat->lsp_old[6] = (Word16) (-8000);  pCodStat->lsp_old[7] = (Word16) (-15000);  pCodStat->lsp_old[8] = (Word16) (-21000);  pCodStat->lsp_old[9] = (Word16) (-26000);#if (WMOPS)  move16();  move16();  move16();  move16();  move16();  move16();  move16();  move16();  move16();  move16();#endif  /* Initialize lsp_old_q[] */  G729EV_G729_Copy(pCodStat->lsp_old, pCodStat->lsp_old_q, G729EV_G729_M);  G729EV_G729_Lsp_encw_reset(pCodStat->freq_prev);  FOR(i = 0; i < 4; i++)  {    pCodStat->L_exc_err[i] = (Word32) 0x00004000L;  /* Q14 */#if (WMOPS)    move32();#endif  }  pCodStat->smooth = (Word16) 1;#if (WMOPS)  move16();#endif  pCodStat->lar_old[0] = (Word16) 0;  pCodStat->lar_old[1] = (Word16) 0;#if (WMOPS)  move16();  move16();#endif  G729EV_G729_Set_zero(pCodStat->old_A, G729EV_G729_MP1);  pCodStat->old_A[0] = (Word16) 4096;#if (WMOPS)  move16();#endif  G729EV_G729_Set_zero(pCodStat->old_rc, 2);  pCodStat->pit_old = (Word16) 40;#if (WMOPS)  move16();#endif  return;}/*-----------------------------------------------------------* *  Function  G729EV_CELP2S_encoder()                        * *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                        * *   Variables initialisation for the G.729 coder            * *-----------------------------------------------------------*/void G729EV_CELP2S_encoder(G729EV_G729_CODSTAT * pCodStat,  /* (i)  core coder states vaiables  */                            Word16 * DataIn,                 /* (i)  data to encode              */                           Word16 * coder_parameters,       /* (o)  coder parameters            */                           Word16 synth[],                  /* (o)  Synthesis signal            */                           Word16 SubFrNum,                 /* (i)  Subframe number             */                           Word16 * celp_Az,                /* (i)  Az buffer                   */                           Word16 * sync_speech,            /* (o)  weighted synthesis          */                           Word16 * resBF8k,                /* (o)  residual signal frame       */                           Word16 * pit,                    /* (o)  open loop pitch             */                           Word16 * t0_out,                 /* (o)  close loop integer pitch    */                           Word16 * t0_fout,                /* (o)  close loop fract. pitch     */                           Word16 * voicing,                /* (o)  frame voicing               */                           Word16 * ee,                     /* (o)  spectral tilt info.         */                           Word16 * diff                    /* (o)  difference signal between                                                                     input and local synthesis at                                                                     12 kbit/s */    ){  Word32    L_temp;  Word16    r_l[G729EV_G729_MP1], r_h[G729EV_G729_MP1]; /* Autocorrelations low and hi */  Word16    rc[G729EV_G729_M];  /* Reflection coefficients. */  Word16    A_t[(G729EV_G729_MP1) * 2]; /* A(z) unquantized for the 2 subframes */  Word16    Aq_t[(G729EV_G729_MP1) * 2];  /* A(z) quantized for the 2 subframes */  Word16    Ap1[G729EV_G729_MP1]; /* A(z) with spectral expansion */  Word16    Ap2[G729EV_G729_MP1]; /* A(z) with spectral expansion */  Word16    lsp_new[G729EV_G729_M];  Word16    lsp_new_q[G729EV_G729_M];  Word16    lsf_int[G729EV_G729_M]; /* Interpolated LSF 1st subframe */  Word16    lsf_new[G729EV_G729_M];  Word16    gamma1[2], gamma2[2]; /* Weighting factor for the 2 subframes  */  Word16    synth_buf[G729EV_G729_L_FRAME]; /* Synthesis signal */  Word16    old_wsp[G729EV_G729_L_FRAME + G729EV_G729_PIT_MAX];  Word16    old_exc[G729EV_G729_L_FRAME + G729EV_G729_PIT_MAX + G729EV_G729_L_INTERPOL];  Word16    ai_zero[G729EV_G729_L_SUBFR + G729EV_G729_M_LPC1];  Word16    mem_err[G729EV_G729_M_LPC + G729EV_G729_L_SUBFR]; /* Filter memory */  Word16    h1[G729EV_G729_L_SUBFR];  /* Impulse response h1[]               */  Word16    xn[G729EV_G729_L_SUBFR];  /* Target vector for pitch search      */  Word16    xn2[G729EV_G729_L_SUBFR]; /* Target vector for codebook search   */  Word16    code[G729EV_G729_L_SUBFR];  /* Fixed codebook excitation           */  Word16    y1[G729EV_G729_L_SUBFR];  /* Filtered adaptive excitation        */  Word16    y2[G729EV_G729_L_SUBFR];  /* Filtered fixed codebook excitation  */  Word16    g_coeff[4];         /* Correlations between xn & y1       */  Word16    g_coeff_cs[5];      /* Corelations between xn, y1, & y2, <y1,y1> */  Word16    exp_g_coeff_cs[5];  /* -2<xn,y1>, <y2,y2>, -2<xn,y2>, 2<y1,y2> */  Word16    old_speech[G729EV_G729_L_TOTAL];  Word16   *A, *Aq;             /* Pointer on A_t and Aq_t         */  Word16   *ana;                /* Pointer on analysis parameters */  Word16   *synth_ptr;          /* Pointer on synthesis buffer */  Word16   *new_speech;         /* Pointer on new speech */  Word16   *speech;             /* Pointer on speech */  Word16   *p_window;           /* Pointer on p_window; */  Word16   *wsp;                /* Pointer on old_wsp */  Word16   *exc;                /* Pointer on old_exc, exitation vector */  Word16   *zero;               /* Pointer on ai_zero */  Word16   *error;              /* Pointer on mem_err, filter's memory */  Word16    i, k, i_subfr, i_gamma, i0;  Word16    T_op, T0, T0_min, T0_max, T0_frac;  Word16    gain_pit, gain_code, index;  Word16    temp;  Word16   *ana2;  Word16    index_enha, ii;  Word16    gain_code_enha = 0;  Word16    exc2[G729EV_G729_L_FRAME];  Word16    mem_err2[G729EV_G729_M_LPC + G729EV_G729_L_SUBFR], *error2;  Word16    xn_enha[G729EV_G729_L_SUBFR]; /* Target vector for codebook search  */  Word16    code_enha[G729EV_G729_L_SUBFR]; /* Fixed codebook excitation          */  Word16    y2_enha[G729EV_G729_L_SUBFR]; /* Filtered fixed codebook excitation */  Word16    exc_enha[G729EV_G729_L_FRAME];  Word16    res1[G729EV_G729_L_SUBFR];  Word16    norm_voiced_fac, voice_fac;  Word16   *ptr, *ptr2;  /* Pointeurs initialisation */  /*----------------------------------------------------------------------*  *      Initialize pointers to speech vector.                            *  *                                                                       *  *                                                                       *  *   |--------------------|-------------|-------------|------------|     *  *     previous speech           sf1           sf2         L_NEXT        *  *                                                                       *  *   <----------------  Total speech vector (L_TOTAL)   ----------->     *  *   <----------------  LPC analysis window (L_WINDOW)  ----------->     *  *   |                   <-- present frame (L_FRAME) -->                 *  * old_speech            |              <-- new speech (L_FRAME) -->     *  * p_window              |              |                                *  *                     speech           |                                *  *                             new_speech                                *  *-----------------------------------------------------------------------*/  new_speech = old_speech + G729EV_G729_MEM_SPEECH; /* New speech     */  p_window = old_speech + G729EV_G729_L_TOTAL - G729EV_G729_L_WINDOW; /* For LPC window */  speech = new_speech - G729EV_G729_L_NEXT; /* Present frame  */  synth_ptr = synth_buf;  G729EV_G729_Copy(pCodStat->old_speech, old_speech, G729EV_G729_MEM_SPEECH);  G729EV_G729_Copy(DataIn, new_speech, G729EV_G729_L_FRAME);  wsp = old_wsp + G729EV_G729_PIT_MAX;  G729EV_G729_Copy(pCodStat->old_wsp, old_wsp, G729EV_G729_PIT_MAX);  exc = old_exc + G729EV_G729_PIT_MAX + G729EV_G729_L_INTERPOL;  G729EV_G729_Copy(pCodStat->old_exc, old_exc, G729EV_G729_PIT_MAX + G729EV_G729_L_INTERPOL);  error = mem_err + G729EV_G729_M;  error2 = mem_err2 + G729EV_G729_M_LPC;  G729EV_G729_Copy(pCodStat->mem_err, mem_err, G729EV_G729_M_LPC);  G729EV_G729_Copy(pCodStat->mem_err2, mem_err2, G729EV_G729_M_LPC);  zero = ai_zero + G729EV_G729_M_LPC1;  ana = coder_parameters;  ana2 = coder_parameters + G729EV_G729_PRM_SIZE;  G729EV_G729_Set_zero(ai_zero, (G729EV_G729_L_SUBFR + G729EV_G729_M_LPC1));  /*------------------------------------------------------------------------*  *  - Perform LPC analysis:                                               *  *       * autocorrelation + lag windowing                                *  *       * Levinson-durbin algorithm to find a[]                          *  *       * convert a[] to lsp[]                                           *  *       * quantize and code the LSPs                                     *  *       * find the interpolated LSPs and convert to a[] for the 2        *  *         subframes (both quantized and unquantized)                     *  *------------------------------------------------------------------------*/  /* LP analysis */  G729EV_G729_AutocorrLPC(p_window, G729EV_G729_M, r_h, r_l); /* Autocorrelations */  G729EV_G729_Lag_window(G729EV_G729_M, r_h, r_l);  /* Lag windowing    */  G729EV_G729_Levinson(r_h, r_l, &A_t[G729EV_G729_MP1], rc, pCodStat->old_A, pCodStat->old_rc); /* Levinson Durbin  */  /*rc[0] = -R1/R0; in Q15 */  *ee = shr(negate(rc[0]), 1);  /*Q14 output */#if (WMOPS)  move16();#endif

⌨️ 快捷键说明

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