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

📄 g729ev_main_decod.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 <stdlib.h>#include "G729EV_MAIN_defines.h"#include "G729EV_G729_defines.h"#include "G729EV_G729_DecStat.h"#include "G729EV_CELP2S_decod.h"#include "G729EV_MAIN_filt.h"#include "G729EV_MAIN_decod.h"#include "G729EV_G729_ld8k.h"#include "G729EV_G729_TAB_ld8k.h"#include "G729EV_FEC_fer.h"#include "G729EV_MAIN_EnvAdaption.h"#include "G729EV_TDAC_decod.h"#include "G729EV_TDAC_mdct.h"#include "G729EV_TDAC_util.h"#include "G729EV_MAIN_DSPFUNC.h"#include "G729EV_MAIN_prm.h"#include "G729EV_TDAC_post.h"#include "G729EV_CELP2S_post.h"/*--------------------------------------------------------------------------* *  Function  G729EV_MAIN_InitDecoder()                                     * *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                     * *  Decoder Initializations                                                 * *--------------------------------------------------------------------------*/void G729EV_MAIN_InitDecoder(DECSTATMAIN * decstat, /* (o)  decoder states variables    */                             Word16 f8,             /* (i)  8kHz sampled input flag     */                             Word16 g729b_bst,      /* (i)  G.729 bistream mode flag    */                             Word16 low_delay)      /* (i)  Low-delay mode flag         */{  Word16    i;  IF(decstat == NULL)  {    exit(-1);  }  memset(decstat, 0, sizeof(*decstat));  /* set previous bad frame indicator */  decstat->prev_bfi = (Word16) 0;#if(WMOPS)  move16();#endif  /* set the flag for 8kHz sampled output */  decstat->f8 = f8;#if (WMOPS)  move16();#endif  /* set the flag for g729 bitstream mode */  decstat->g729b_bst = g729b_bst;#if(WMOPS)  move16();#endif  decstat->low_delay = low_delay;#if(WMOPS)  move16();#endif  /* initialize QMF filterbank */  G729EV_MAIN_initQMF_syn(&decstat->qmf_syn);  /* initialize CELP decoder */  G729EV_CELP2S_InitDecoder(&decstat->decStG729, g729b_bst);  /* initialize memories for MDCT computation */  G729EV_G729_Set_zero(decstat->mem_mdct_hi, G729EV_MAIN_L_FRAME2);  G729EV_G729_Set_zero(decstat->mem_inv_mdct_hi, G729EV_MAIN_L_FRAME2);  G729EV_G729_Set_zero(decstat->mem_inv_mdct_lo, G729EV_MAIN_L_FRAME2);  G729EV_G729_Set_zero(decstat->sTdbweOld, G729EV_MAIN_L_FRAME2);  decstat->vmhold = (Word16) 0x7fff;  /* Q.15, 1.0 */  decstat->vmlold = (Word16) 0x7fff;  /* Q.15, 1.0 */#if(WMOPS)  move16();  move16();#endif  /* initialize TDBWE decoder */  G729EV_TDBWE_decoder_init(&decstat->tdbwe);  IF(decstat->low_delay > 0) G729EV_MAIN_init_lp3k(&decstat->mem_lp3k);  /* initialize memory of previous CELP-decoded frame (for difference computation in lower band) */  G729EV_G729_Set_zero(decstat->old_celp_output, G729EV_MAIN_L_FRAME2);  /* postfiltering */  G729EV_G729_Set_zero(decstat->mem_pf_in, G729EV_G729_M_LPC);  G729EV_CELP2S_init_post_filter(&decstat->mem_pf);  G729EV_G729_Set_zero(decstat->mem_Az, 4 * G729EV_G729_MP1);  FOR(i = 0; i < (4 * G729EV_G729_MP1); i += G729EV_G729_MP1)  {    decstat->mem_Az[i] = (Word16) 4096;#if(WMOPS)    move16();#endif  }  FOR(i = 0; i < 4; i++)  {    decstat->mem_t0[i] = (Word16) 60;#if(WMOPS)    move16();#endif  }  /* post processing */  IF(low_delay == 0) decstat->mem_postflag = (Word16) 0;  ELSE decstat->mem_postflag = (Word16) 1;#if(WMOPS)  move16();#endif  G729EV_MAIN_init_iir2(&decstat->mem_postpro);  /* perceptual weighting filter of lower band difference signal */  G729EV_G729_Set_zero(decstat->mem_invWz_in, G729EV_G729_M);  G729EV_G729_Set_zero(decstat->mem_invwsp, G729EV_G729_M);  /* bitrate switching initialization */  decstat->count_rcv = G729EV_MAIN_COUNT_RCV_MAX;  decstat->first_frame = (Word16) 1;  decstat->prev_nRcv_hi = (Word16) 0;  decstat->prev_rate = (Word16) 0;#if(WMOPS)  move16();  move16();  move16();  move16();#endif  /* init FEC variables */  decstat->lp_ener_FER = (Word16) (256 * 60); /* Q8 */  decstat->lastgood = G729EV_FEC_UNVOICED;  decstat->plast_good = G729EV_FEC_UNVOICED;  decstat->old_enrLP = (Word16) 0;  /*Q4 */#if(WMOPS)  move16();  move16();  move16();  move16();#endif  G729EV_G729_Set_zero(decstat->synth_buf, G729EV_G729_PIT_MAX);  /* initialize memory for median filter to smooth the gamma parameters of the postfilter */  FOR(i = 0; i < G729EV_MAIN_NMAX; i++)  {    decstat->tab_Th[i] = (Word16) 0;#if(WMOPS)    move16();#endif  }}/*--------------------------------------------------------------------------* *  Function  G729EV_MAIN_Decode()                                          * *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                          * *  Main decoder routine                                                    * *--------------------------------------------------------------------------*/void G729EV_MAIN_Decode(DECSTATMAIN * decstat,      /* (i)  decoder states variables        */                        Word16 * itu_192_bitstream, /* (i)  G.192 bitstream to decode       */                        Word16 * tabout,            /* (o)  20 ms  speech signal            */                        Word16 rate,                /* (i)  Decoding rate                   */                        Word16 bfi                  /* (i)  Bad Frame Indicator             */){  G729EV_CELP2S_PARAM nb_celp_param;  G729EV_MAIN_PFSTAT *pfstat;  Word32    Ltmp;  Word32    L_enr_q;            /* Q0 */  Word16    celp_output[G729EV_MAIN_L_FRAME2];  Word16    output_lo[G729EV_MAIN_L_FRAME2];  Word16    output_hi[G729EV_MAIN_L_FRAME2];  Word16    output_hiTdbwe[G729EV_MAIN_L_FRAME2];  Word16    diff_q[G729EV_MAIN_L_FRAME2];  Word16    yq_lo[G729EV_MAIN_L_FRAME2];  Word16    yq_hi[G729EV_MAIN_L_FRAME2];  Word16    yt_hi[G729EV_MAIN_L_FRAME2];  Word16    pst_in[G729EV_MAIN_L_FRAME2];  Word16    parameters_tdbwe[G729EV_TDBWE_NB_PARAMETERS]; /* Q.10 */  Word16    pf_in_buffer[G729EV_G729_M_LPC + G729EV_MAIN_L_FRAME2];  Word16    coreExc[G729EV_MAIN_L_FRAME2], extExc[G729EV_MAIN_L_FRAME2], BfAq[4 * G729EV_G729_MP1];  Word16    pitch_buf[G729EV_MAIN_NB_SUBFR];  Word16    mem_syntmp[G729EV_G729_M];  Word16    ind_fer[3];  Word16    parm_FEC[13];  Word16    coder_parameters[G729EV_G729_PRM_SIZE_MAX * 2 + 10];  Word16   *ptr_Az;  Word16   *pf_in;  Word16   *coder_param_ptr;  Word16    i_frame, i, j, ind;  Word16    nb_bits_to_decode;  Word16    nb_bits_left;  Word16    nb_bits_used;  Word16    nb_bits_max;  Word16    norm_MDCT;  Word16    norm_local;  Word16    diff_norm;  Word16    nRcv_hi;  Word16    t0_first;           /* Pitch lag in 1st subframe   */  Word16    ga1_post, ga2_post;  Word16    tmp16;  Word16    clas;  Word16    FerPitch;  Word16    begin_index_low, end_index_low, begin_index_high, end_index_high; /*beggining & end of the false alarm zone */  /* set pointer to parameters */  coder_param_ptr = coder_parameters;  /* compute number of bits to decode */  nb_bits_to_decode = rate / 50;  /* set FEC variables */  L_enr_q = (Word32) - 1;  clas = decstat->lastgood;  pitch_buf[0] = decstat->decStG729.pit_mem[0];  pitch_buf[1] = decstat->decStG729.pit_mem[1];  pitch_buf[2] = decstat->decStG729.pit_mem[2];  pitch_buf[3] = decstat->decStG729.pit_mem[3];#if(WMOPS)  move32();  move16();  move16();  move16();  move16();  move16();  move16();#endif  ind_fer[0] = (Word16) - 1000;  ind_fer[1] = (Word16) - 1000;  ind_fer[2] = (Word16) - 1000;#if(WMOPS)  move16();  move16();  move16();#endif  /* set frame type (ftyp) for G.729B decoding */#if(WMOPS)  test();#endif  IF((decstat->g729b_bst) && (bfi))  {    IF(decstat->decStG729.past_ftyp == 1)    {      decstat->decStG729.ftyp[0] = 1;      decstat->decStG729.ftyp[1] = 1;    } ELSE    {      decstat->decStG729.ftyp[0] = 0;      decstat->decStG729.ftyp[1] = 0;    }#if(WMOPS)    move16();    move16();#endif  }#if(WMOPS)  test();  test();#endif  IF((!bfi) || ((decstat->g729b_bst) && (decstat->decStG729.ftyp[0] == 0)))  {    /************************************ decode received frame (bfi=0) **************************/    /***************************     * Initialize bit counters *     ***************************/    /* set number of bits for 20-ms frame */    nb_bits_max = G729EV_MAX_BITRATE / 50;  /* maximal bit allocation (-> 32 kbit/s) */    nb_bits_left = nb_bits_to_decode;       /* number of bits available for decoder */    nb_bits_used = (Word16) 0;              /* number of bits used */#if(WMOPS)    move16();    move16();    move16();#endif    /*******************************************     * Read bitstream and demultiplex parameters     *******************************************/    G729EV_MAIN_bit2param(itu_192_bitstream, nb_bits_to_decode, coder_parameters, ind_fer, decstat);    /*********************************************************     * decode FEC information (clas, puslse offset and energy)     *********************************************************/    IF(sub(rate, 12000) >= 0)    {      clas = G729EV_FEC_dec(&(decstat->lastgood), decstat->plast_good, decstat->prev_bfi, ind_fer, &L_enr_q, rate);    }    /************************************************************************     * Update decoder CELP parameters if previous frame was erased (recovery)     ************************************************************************/    IF((sub(decstat->prev_bfi, 1) == 0) && (decstat->low_delay == 0))    {      coder_parameters[3] = G729EV_G729_Check_Parity_Pitch(coder_parameters[2], coder_parameters[3]);#if(WMOPS)      move16();#endif      /* The new clas is already known with the 14 kbit/s bitstream */      G729EV_FEC_dec_bf(coder_parameters, decstat->old_celp_output, BfAq, G729EV_FEC_SINGLE_FRAME,                        &(decstat->lastgood), pitch_buf, decstat->old_enrLP,                        decstat->decStG729.old_exc, &(decstat->decStG729), clas, ind_fer[2]);      /* Update to be done before decoding a good frame */      FerPitch = shr(add(pitch_buf[0], G729EV_FEC_QPIT2), G729EV_FEC_SQPIT);      if (sub(FerPitch, G729EV_G729_PIT_MIN) < 0)      {        FerPitch = G729EV_G729_PIT_MIN;#if(WMOPS)        move16();#endif      }      if (sub(FerPitch, G729EV_G729_PIT_MAX) > 0)      {        FerPitch = G729EV_G729_PIT_MAX;#if(WMOPS)        move16();#endif      }      G729EV_G729_UpdateMemTam(&decstat->decStG729, decstat->decStG729.lp_gainp, FerPitch);      G729EV_G729_UpdateMemTam(&decstat->decStG729, decstat->decStG729.lp_gainp, FerPitch);

⌨️ 快捷键说明

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