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

📄 g729ev_celp2s_decod.c

📁 最新的ITU-T的宽带语音编解码标准G.729.1,是对原先的G.729的最好的调整.码流输出速率可以进行自适应调整.满足未来通信要求.希望对大家有所帮助.
💻 C
📖 第 1 页 / 共 2 页
字号:
/* 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_decod.h"#include "G729EV_G729B_util.h"#include "G729EV_G729B_tab_dtx.h"#include "G729EV_G729B_sid.h"/*--------------------------------------------------------------------------* *  Function  G729EV_CELP2S_InitDecoder()                                   * *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                   * *  Variables initialisation for the CELP2S                                 * *--------------------------------------------------------------------------*/void G729EV_CELP2S_InitDecoder(G729EV_G729_DECSTAT * pDecStat,  /* (i/o)    Core decoder parameters     */                                Word16 g729b_bst)                /* (i)      G.729 bitstream mode flag   */{  Word16    i;  /* initialize lsp_old */  pDecStat->lsp_old[0] = (Word16) (30000);  pDecStat->lsp_old[1] = (Word16) (26000);  pDecStat->lsp_old[2] = (Word16) (21000);  pDecStat->lsp_old[3] = (Word16) (15000);  pDecStat->lsp_old[4] = (Word16) (8000);  pDecStat->lsp_old[5] = (Word16) (0);  pDecStat->lsp_old[6] = (Word16) (-8000);  pDecStat->lsp_old[7] = (Word16) (-15000);  pDecStat->lsp_old[8] = (Word16) (-21000);  pDecStat->lsp_old[9] = (Word16) (-26000);#if (WMOPS)  move16();  move16();  move16();  move16();  move16();  move16();  move16();  move16();  move16();  move16();#endif  /* vectors to zero */  G729EV_G729_Set_zero(pDecStat->old_exc, G729EV_G729_PIT_MAX + G729EV_G729_L_INTERPOL);  G729EV_G729_Set_zero(pDecStat->mem_syn, G729EV_G729_M);  pDecStat->seed_fer = (Word16) 21845;#if (WMOPS)  move16();#endif  pDecStat->sharp = G729EV_G729_SHARPMIN;  pDecStat->gain_code = 0;  pDecStat->gain_pitch = 0;#if (WMOPS)  move16();  move16();  move16();  move16();  move16();#endif  pDecStat->past_qua_en[0] = (Word16) (-14336);  pDecStat->past_qua_en[1] = (Word16) (-14336);  pDecStat->past_qua_en[2] = (Word16) (-14336);  pDecStat->past_qua_en[3] = (Word16) (-14336);#if (WMOPS)  move16();  move16();  move16();  move16();#endif  G729EV_G729_Lsp_decw_reset(pDecStat->freq_prev, pDecStat->prev_lsp, &(pDecStat->prev_ma));  G729EV_G729_Set_zero(pDecStat->MemTam, G729EV_G729_MEM_LEN_TAM);  pDecStat->lp_gainp = (Word16) 0;  /*Q14 */  pDecStat->lp_gainc = (Word16) 0;  /*Q3 */  pDecStat->i_subfr_cnt = (Word16) 0;  pDecStat->stab_fac = (Word16) 0;  /*Q15 */  pDecStat->tilt_code = (Word16) 0; /*Q15 */  pDecStat->upd_cnt = G729EV_FEC_MAX_UPD_CNT;  pDecStat->Lenr_old = (Word16) 0;  /*Q0 */  pDecStat->fpitch[0] = (Word16) (G729EV_FEC_QPIT * G729EV_G729_PIT_MIN);  pDecStat->fpitch[1] = (Word16) (G729EV_FEC_QPIT * G729EV_G729_PIT_MIN);  pDecStat->old_fpitch = (Word16) (G729EV_FEC_QPIT * 40);  pDecStat->pit_mem[0] = (Word16) (G729EV_FEC_QPIT * 20);  pDecStat->pit_mem[1] = (Word16) (G729EV_FEC_QPIT * 20);  pDecStat->pit_mem[2] = (Word16) (G729EV_FEC_QPIT * 20);  pDecStat->pit_mem[3] = (Word16) (G729EV_FEC_QPIT * 20);  pDecStat->pit_mem[4] = (Word16) (G729EV_FEC_QPIT * 20);  pDecStat->bfi_mem = (Word16) 0;#if (WMOPS)  move16();  move16();  move16();  move16();  move16();  move16();  move16();  move16();  move16();  move16();  move16();  move16();  move16();  move16();  move16();  move16();#endif  /* G.729B mode */  pDecStat->g729b_bst = g729b_bst;  pDecStat->ftyp[0] = 1;  pDecStat->ftyp[1] = 1;  pDecStat->sid_sav = 0;  pDecStat->sh_sid_sav = 1;  pDecStat->sid_gain = tab_Sidgain[0];  pDecStat->past_ftyp = 1;  pDecStat->seed = INIT_SEED;  FOR(i = 0; i < 4; i++)  {    pDecStat->L_exc_err[i] = (Word32) 0x00004000L;  /* Q14 */#if (WMOPS)    move32();#endif  }  pDecStat->lspSid[0] = 31441;  pDecStat->lspSid[1] = 27566;  pDecStat->lspSid[2] = 21458;  pDecStat->lspSid[3] = 13612;  pDecStat->lspSid[4] = 4663;  pDecStat->lspSid[5] = -4663;  pDecStat->lspSid[6] = -13612;  pDecStat->lspSid[7] = -21458;  pDecStat->lspSid[8] = -27566;  pDecStat->lspSid[9] = -31441;  Init_lsfq_noise(pDecStat);#if (WMOPS)  move16();  move16();  move16();  move16();  move16();  move16();  move16();  move16();  move16();  move16();  move16();  move16();  move16();  move16();  move16();  move16();  move16();  move16();#endif  return;}/*--------------------------------------------------------------------------* *  Function  G729EV_CELP2S_decoder()                                       * *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                   * *  Core Codec decoder                                                      * *--------------------------------------------------------------------------*/void G729EV_CELP2S_decoder(G729EV_G729_DECSTAT * pDecStat,      /* (i/o)    Core decoder parameters     */                           Word16 * coder_parameters,           /* (i)      decoder parameters          */                           Word16 rate,                         /* (i)      decoder rate                */                           Word16 SubFrNum,                     /* (i)      subframe number             */                           G729EV_CELP2S_PARAM * nb_celp_param, /* (i/o)    celp parameters             */                           Word16 * BfAq,                       /* (i)      A_t_fwd parameters          */                            Word16 * coreExc,                    /* (o)      8k excitation               */                           Word16 * extExc,                     /* (o)      12k excitation              */                           Word16 * pitch_buf,                  /* (o)      pitch buffer                */                           Word16 clas,                         /* (i)      FEC information             */                           Word16 bfi)                          /* (i)      Bad frame information       */{  Word32    L_temp;  Word32    L_temp2;  Word16    temp;  /* Array of the coded parameters */  Word16    old_exc[G729EV_G729_L_FRAME + G729EV_G729_PIT_MAX + G729EV_G729_L_INTERPOL];  Word16    A_t_fwd[2 * G729EV_G729_MP1]; /* LPC Forward filter  */  Word16    synth_buf[G729EV_G729_L_FRAME + G729EV_G729_M_LPC]; /* synthesis signal buffer  */  Word16    lsp_new[G729EV_G729_M]; /* LSPs              */  Word16    code[G729EV_G729_L_SUBFR];  /* ACELP codevector  */  Word16    t2[2];  Word16   *prm;                /* Pointer on analysis parameters */  Word16   *exc;                /* Pointer on exitation vector */  Word16   *synth;  Word16   *pA_t;               /* Pointer on A_t */  Word16   *ptr_t2;             /* Pointer on t2 */  Word16    i, i_subfr, j;  Word16    t0, t0_frac, index;  Word16    g_p, g_c;           /* fixed and adaptive codebook gain  */  Word16    t0_first;           /* Pitch lag in 1st subframe       */  Word16    g_c_enha;  Word16    code_enha[G729EV_G729_L_SUBFR];  Word16    exc2[G729EV_G729_L_FRAME];  Word16   *prm2;  Word16    sp;  Word16    voice_fac, tmp16;  Word16   *ptr, i0_2sub;  /* for G.729B */  Word16    ftyp;  Word16    lsfq_mem[G729EV_G729_MA_NP][G729EV_G729_M];  /*Test if Decoder Initialized */  IF(pDecStat == NULL)  {    return;  }#if (WMOPS)  move16();#endif  pDecStat->rate = rate;  IF(sub(rate, 12000) >= 0)  {    coder_parameters[3] = G729EV_G729_Check_Parity_Pitch(coder_parameters[2], coder_parameters[3]);#if (WMOPS)    move16();#endif  }  /* initialize pointers and restore memory */  G729EV_G729_Copy(pDecStat->old_exc, old_exc, G729EV_G729_PIT_MAX + G729EV_G729_L_INTERPOL);  exc = old_exc + G729EV_G729_PIT_MAX + G729EV_G729_L_INTERPOL;  prm = coder_parameters;  prm2 = &coder_parameters[G729EV_G729_PRM_SIZE];  synth = synth_buf + G729EV_G729_M_LPC;  G729EV_G729_Copy(pDecStat->mem_syn, synth_buf, G729EV_G729_M_LPC);  ftyp = pDecStat->ftyp[SubFrNum];#if(WMOPS)  move16();#endif  /* Processing non active frames (SID & not transmitted) */  IF(sub(ftyp, (Word16) 1) != 0)  {    G729EV_G729B_Get_decfreq_prev(pDecStat->freq_prev, lsfq_mem);    G729EV_G729B_Dec_cng(pDecStat,                         pDecStat->past_ftyp,                         pDecStat->sid_sav,                         pDecStat->sh_sid_sav,                         prm,                         exc,                         pDecStat->lsp_old,                         A_t_fwd, &pDecStat->seed, lsfq_mem, &pDecStat->sid_gain, &pDecStat->cur_gain, ftyp);    G729EV_G729B_Update_decfreq_prev(pDecStat->freq_prev, lsfq_mem);    G729EV_G729_Copy(A_t_fwd, &nb_celp_param->Az[2 * SubFrNum * G729EV_G729_MP1], 2 * G729EV_G729_MP1);    pDecStat->sharp = G729EV_G729_SHARPMIN;#if(WMOPS)    move16();#endif  }  ELSE  {    pDecStat->seed = INIT_SEED;#if(WMOPS)    move16();#endif    /* ------------- */    /* LPC decoding  */    /* ------------- */    /* Decode the LSPs */    pDecStat->stab_fac =        G729EV_G729_D_lsp(pDecStat->freq_prev, pDecStat->prev_lsp, &pDecStat->prev_ma, prm, lsp_new, 0);    prm += 2;    /* Interpolation of LPC for the 2 subframes */    G729EV_G729_Int_qlpc(pDecStat->lsp_old, lsp_new, A_t_fwd);    G729EV_G729_Copy(A_t_fwd, &nb_celp_param->Az[2 * SubFrNum * G729EV_G729_MP1], 2 * G729EV_G729_MP1);    /* update the LSFs for the next frame */    G729EV_G729_Copy(lsp_new, pDecStat->lsp_old, G729EV_G729_M);    pA_t = A_t_fwd;/*------------------------------------------------------------------------* *          Loop for every subframe in the analysis frame                 * *------------------------------------------------------------------------* * The subframe size is L_SUBFR and the loop is repeated L_FRAME/L_SUBFR  * *  times                                                                 * *     - decode the pitch delay                                           * *     - decode algebraic code                                            * *     - decode pitch and codebook gains                                  * *     - find the excitation and compute synthesis speech                 * *------------------------------------------------------------------------*/    ptr_t2 = t2;                /* pointer to interpolated LPC parameters */    i0_2sub = shl(SubFrNum, 1); /* i0_2sub = 2*SubFrNum + i0 */#if (WMOPS)    move16();#endif    FOR(i_subfr = 0; i_subfr < G729EV_G729_L_FRAME; i_subfr += G729EV_G729_L_SUBFR)    {      index = *prm++;           /* pitch index */#if (WMOPS)      move16();#endif      IF(i_subfr == 0)      {        /* get parity check result */        i = *prm++;#if (WMOPS)        move16();#endif        G729EV_G729_Dec_lag3(index, G729EV_G729_PIT_MIN, G729EV_G729_PIT_MAX, i_subfr, &t0, &t0_frac);        t0_first = t0;          /* If first frame */#if (WMOPS)        move16();#endif      }      ELSE                      /* second subframe */      {        G729EV_G729_Dec_lag3(index, G729EV_G729_PIT_MIN, G729EV_G729_PIT_MAX, i_subfr, &t0, &t0_frac);      }      G729EV_FEC_pitch_pred(0, &t0, &t0_frac, pDecStat->pit_mem, &(pDecStat->bfi_mem));      if (i_subfr == 0)      {        t0_first = t0;

⌨️ 快捷键说明

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