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

📄 g729ev_celp2s_decod.c

📁 最新的ITU-T的宽带语音编解码标准G.729.1,是对原先的G.729的最好的调整.码流输出速率可以进行自适应调整.满足未来通信要求.希望对大家有所帮助.
💻 C
📖 第 1 页 / 共 2 页
字号:
#if (WMOPS)        move16();#endif      }      *ptr_t2++ = t0;#if (WMOPS)      move16();#endif      pitch_buf[pDecStat->i_subfr_cnt] = shl(t0, G729EV_FEC_SQPIT);#if (WMOPS)      move16();#endif      IF(sub(clas, G729EV_FEC_UV_TRANSITION) >= 0)      {        pDecStat->fpitch[0] = pDecStat->fpitch[1];        pDecStat->fpitch[1] = add(shl(t0, G729EV_FEC_SQPIT), mult_r(shl(t0_frac, G729EV_FEC_SQPIT), 10922));#if (WMOPS)        move16();        move16();#endif      }    /*-------------------------------------------------*    * - Find the adaptive codebook vector.            *    *-------------------------------------------------*/      G729EV_G729_Pred_lt_3(&exc[i_subfr], t0, t0_frac, G729EV_G729_L_SUBFR);    /*-------------------------------------------------------*    * - Decode innovative codebook.                         *    *-------------------------------------------------------*/      G729EV_G729_Decod_ACELP(prm[1], prm[0], code);      prm += 2;      j = shl(pDecStat->sharp, 1);  /* From Q14 to Q15 */      IF(sub(t0, G729EV_G729_L_SUBFR) < 0)      {        ptr = code + t0;        FOR(i = t0; i < G729EV_G729_L_SUBFR; i++)        {          *ptr++ = add(code[i], mult(code[sub(i, t0)], j));#if (WMOPS)          move16();#endif        }      }  /*-------------------------------------------------*    * - Decode pitch and codebook gains.              *    *-------------------------------------------------*/      index = *prm++;           /* index of energy VQ */#if (WMOPS)      move16();#endif      G729EV_G729_Dec_gain(index, code, G729EV_G729_L_SUBFR, 0, &pDecStat->gain_pitch, &pDecStat->gain_code,                           pDecStat->past_qua_en);      voice_fac = G729EV_FEC_voice_factor(exc + i_subfr, pDecStat->gain_pitch, code, pDecStat->gain_code);      sp = extract_l(L_shr(L_add(voice_fac, 32767), 1));      sp = mult_r(sp, G729EV_CELP2S_SP);  /*-------------------------------------------------------*  * - Decode Second innovative codebook.                  *  *-------------------------------------------------------*/      IF(sub(pDecStat->rate, 12000) >= 0)      {        G729EV_CELP2S_Decod_ACELP(prm2[1], prm2[0], sp, code_enha);        prm2 += 2;      }  /*-------------------------------------------------------------*    * - Update pitch sharpening "sharp" with quantized gain_pitch *    *-------------------------------------------------------------*/      pDecStat->sharp = pDecStat->gain_pitch;#if (WMOPS)      move16();#endif      if (sub(pDecStat->sharp, G729EV_G729_SHARPMAX) > 0)      {        pDecStat->sharp = G729EV_G729_SHARPMAX;#if (WMOPS)        move16();#endif      }      if (sub(pDecStat->sharp, G729EV_G729_SHARPMIN) < 0)      {        pDecStat->sharp = G729EV_G729_SHARPMIN;#if (WMOPS)        move16();#endif      }   /*-------------------------------------------------------*    * - Find the total excitation.                          *    * - Find synthesis speech corresponding to exc[].       *    *-------------------------------------------------------*/      g_p = G729EV_G729_TamFer(pDecStat, pDecStat->gain_pitch,  /*gain */                               t0); /*integer part of the pitch */      g_c = pDecStat->gain_code;#if (WMOPS)      move16();#endif      /* i0_2sub = 2*SubFrNum + i0 */      nb_celp_param->t0[i0_2sub] = t0;      nb_celp_param->t0_frac[i0_2sub] = t0_frac;#if (WMOPS)      move16();      move16();#endif      nb_celp_param->power_ltp[i0_2sub] = 0;#if (WMOPS)      move16();#endif      ptr = exc + i_subfr;      L_temp2 = nb_celp_param->power_ltp[i0_2sub];#if (WMOPS)      move16();      move32();#endif      FOR(i = 0; i < G729EV_G729_L_SUBFR; i++)      {        temp = mult(g_p, exc[i + i_subfr]);        L_temp2 = L_mac0(L_temp2, temp, temp);        /* exc[i] = g_p*exc[i] + g_c*code[i]; */        /* exc[i]  in Q1   g_p in Q14         */        /* code[i] in Q13  g_code in Q1       */        L_temp = L_mult(code[i], g_c);  /* Q13 * Q1 -> Q15 */        L_temp = L_shl(L_temp, 1);  /* Q15 -> Q_N+15  */        L_temp = L_mac(L_temp, exc[i + i_subfr], g_p);  /* Q_N * Q14 -> Q_N+15 */        L_temp = L_shl(L_temp, 1);  /* Q_N+15 -> Q_N+16  */        *ptr++ = round(L_temp);#if (WMOPS)        move16();#endif      }      nb_celp_param->power_ltp[i0_2sub] = L_temp2;#if (WMOPS)      move32();#endif      IF(sub(pDecStat->rate, 12000) >= 0)      {#if (WMOPS)        move16();#endif        index = *prm2++;        nb_celp_param->power_fix[i0_2sub] = 0;#if (WMOPS)        move16();#endif        /* decode gain (optimized version: table lookup) */        g_c_enha = G729EV_CELP2S_dec_gain_Stage2(g_c, index, i0_2sub);        /* Compute excitation for with two inovative codebook         */        /* exc2[i+i_subfr] = g_c_enha * code_enha[i] + exc[i+i_subfr] */        /* exc[i]  in Q1                                              */        /* code_enha[i] in Q13  gain_code_enha in Q1                  */        ptr = exc2 + i_subfr;        L_temp2 = nb_celp_param->power_fix[i0_2sub];#if (WMOPS)        move32();#endif        FOR(i = 0; i < G729EV_G729_L_SUBFR; i++)        {          temp = add(mult(g_c, code[i]), mult(g_c_enha, code_enha[i]));          L_temp2 = L_mac0(L_temp2, temp, temp);          L_temp = L_mult(code_enha[i], g_c_enha);  /* Q13 * Q1 -> Q15 */          L_temp = L_shl(L_temp, 1);  /* Q15 -> Q_N+15   */          L_temp = L_mac(L_temp, exc[i + i_subfr], 16384);  /* Q_N * Q_14 -> Q_N+15 */          L_temp = L_shl(L_temp, 1);  /* Q_N+15 -> Q_N+16 */          *ptr++ = round(L_temp);#if (WMOPS)          move16();#endif        }        nb_celp_param->power_fix[i0_2sub] = L_temp2;#if (WMOPS)        move32();#endif      }      tmp16 = add(pDecStat->i_subfr_cnt, 1);      tmp16 = i_mult(tmp16, 3277);      pDecStat->lp_gainp = add(pDecStat->lp_gainp, mult_r(tmp16, g_p));      pDecStat->lp_gainc = add(pDecStat->lp_gainc, mult_r(tmp16, shl(g_c, 2)));      pDecStat->tilt_code = extract_l(L_shr(L_add(voice_fac, 32767), 2));      pDecStat->i_subfr_cnt = add(pDecStat->i_subfr_cnt, 1);      pA_t += G729EV_G729_MP1;  /* interpolated LPC parameters for next subframe */      i0_2sub = add(i0_2sub, 1);  /* i0++ */    }  }  /*------------*   *  For G729b   *-----------*/  IF(bfi == 0)  {    L_temp = 0L;    FOR(i = 0; i < G729EV_G729_L_FRAME; i++)    {      L_temp = L_mac(L_temp, exc[i], exc[i]);    }                           /* may overflow => last level of SID quantizer */    pDecStat->sh_sid_sav = norm_l(L_temp);    pDecStat->sid_sav = round(L_shl(L_temp, pDecStat->sh_sid_sav));    pDecStat->sh_sid_sav = sub(16, pDecStat->sh_sid_sav);  } /*--------------------------------------------------*  * Update signal for next frame.                    *  * -> shift to the left by L_FRAME  exc[]           *  *--------------------------------------------------*/  G729EV_G729_Copy(&old_exc[G729EV_G729_L_FRAME], &pDecStat->old_exc[0], G729EV_G729_PIT_MAX + G729EV_G729_L_INTERPOL);  G729EV_G729_Copy(exc, coreExc, G729EV_G729_L_FRAME);  G729EV_G729_Copy(exc2, extExc, G729EV_G729_L_FRAME);  G729EV_G729_Copy(A_t_fwd, BfAq, 2 * G729EV_G729_MP1);  /* for G729b */  pDecStat->past_ftyp = ftyp;#if (WMOPS)  move16();#endif  return;}/*-----------------------------------------------------------* *  Function  G729EV_CELP2S_Decod_pos_sig()                   * *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                    * *   Decode positions and signs of the 4 tri-pulse patterns  * *-----------------------------------------------------------*/void G729EV_CELP2S_Decod_pos_sig(Word16 index,  /* (i) : Positions of the 4 pattern */                                 Word16 sign,   /* (i) : Signs of the 4 pattern */                                 Word16 pos[],  /* (o) : Decoded positions */                                 Word16 si[]    /* (o) : Decoded signs */    ){  Word16    i, j;  /* Decode the positions */#ifdef WMOPS  logic16();  move16();#endif  i = index & (Word16) 7;  pos[0] = add(i, shl(i, 2));   /* pos0 =i*5 */  index = shr(index, 3);#ifdef WMOPS  logic16();  move16();#endif  i = index & (Word16) 7;  i = add(i, shl(i, 2));        /* pos1 =i*5+1 */  pos[1] = add(i, 1);  index = shr(index, 3);#ifdef WMOPS  logic16();  move16();#endif  i = index & (Word16) 7;  i = add(i, shl(i, 2));        /* pos2 =i*5+1 */  pos[2] = add(i, 2);  index = shr(index, 3);#ifdef WMOPS  logic16();  logic16();  move16();#endif  j = index & (Word16) 1;  index = shr(index, 1);  i = index & (Word16) 7;  i = add(i, shl(i, 2));        /* pos3 =i*5+3+j */  i = add(i, 3);  pos[3] = add(i, j);  /* Decode the signs */  FOR(j = 0; j < 4; j++)  {#ifdef WMOPS    logic16();    move16();#endif    i = sign & (Word16) 1;    si[j] = i;    sign = shr(sign, 1);  }  return;}/*-----------------------------------------------------------* *  Function  G729EV_CELP2S_Decod_ACELP()                    * *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                    * *   Algebraic codebook decoder.                             * *-----------------------------------------------------------*/void G729EV_CELP2S_Decod_ACELP(Word16 sign,   /* (i)     : Signs of 4 patterns                       */                               Word16 index,  /* (i)     : Positions of the 4 pattern centres        */                               Word16 sp,     /* (i)     : Amplitude of the side pulses.             */                               Word16 cod[]   /* (o) Q13 : algebraic (fixed) codebook excitation     */    ){  Word16    pos[4];  Word16    si[4];  /* Decode the positions and signs */  G729EV_CELP2S_Decod_pos_sig(index, sign, pos, si);  /* Put the tri-pulse patterns */  G729EV_CELP2S_Put4Patterns(pos, si, sp, cod);  return;}

⌨️ 快捷键说明

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