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

📄 g729ev_fec_ferenc.c

📁 最新的ITU-T的宽带语音编解码标准G.729.1,是对原先的G.729的最好的调整.码流输出速率可以进行自适应调整.满足未来通信要求.希望对大家有所帮助.
💻 C
📖 第 1 页 / 共 2 页
字号:
  IF(Lnoiseen != 0 && Lsegen != 0)  {    /* Normalize segen */    exp_wsp = norm_l(Lsegen);    mant_wsp = extract_h(L_shl(Lsegen, exp_wsp));    exp_wsp = sub(30, exp_wsp);    /* Normalize noiseen */    exp_noise = norm_l(Lnoiseen);    mant_noise = extract_h(L_shl(Lnoiseen, exp_noise));    exp_noise = sub(30, exp_noise);    /* ensure mant_wsp < mant_noise */    mant_wsp = shr(mant_wsp, 1);    exp_wsp = add(exp_wsp, 1);    /*snr_val = segen / noiseen; *//* Total SNR    */    snr_val = div_s(mant_wsp, mant_noise);    exp_snr = sub(exp_wsp, exp_noise);#if(WMOPS)    move16();    move16();#endif    /* Put snr_val in Q9 */    Ltmp = L_shr(snr_val, sub((15 - 9 - 7), exp_snr));  /* Q16 */    Log2(Ltmp, &exp_et, &frac_et);    exp_et = sub(exp_et, 16);    Ltmp = Mpy_32_16(exp_et, frac_et, G729EV_FEC_LG10); /*Ltmp Q14 */    snr_val = round(L_shl(Ltmp, 16 - 5)); /*Q11 -> Q8 */  }  ELSE  {    snr_val = (Word16) 0;#if(WMOPS)    move16();#endif  }  /* average voicing on second half-frame and look-ahead  */  Ltmp = L_mult(voicing[0], 16384);  mean_voi2 = mac_r(Ltmp, voicing[3], 16384);  /* Average the spectral tilt in dB        */  Ltmp = L_mult(ee[0], ee[1]);  een = extract_h(L_shr(Ltmp, 2));  /*Q14 -> Q11 */  een = mac_r(G729EV_FEC_C_EE, een, G729EV_FEC_K_EE);#if(WMOPS)  test();  test();#endif  if (een < 0 || ee[0] < 0 || ee[1] < 0)  {    een = (Word16) 0;#if(WMOPS)    move16();#endif  }  if (sub(een, 512) > 0)        /*0.75 Q9 */  {    een = (Word16) 512;#if(WMOPS)    move16();#endif  }#if(WMOPS)  move16();#endif  /* Compute the zero crossing rate    */  zc = (Word16) 0;  FOR(i = 1; i < G729EV_FEC_L_FRAME_FER; i++)  {#if(WMOPS)    test();#endif    if ((speech[i] <= 0) && (speech[i - 1] > 0))    {      zc = add(zc, 1);    }  }  /* Compute the pitch stability      */  pc = add(abs_s(sub(pit[2], pit[1])), abs_s(sub(pit[3], pit[2])));#if(WMOPS)  move16();  move16();  move16();  move16();  test();  test();  test();#endif  /* This section is needed ot improve signal classification in noisy condition */  tmp_mean = *last_relE;  *last_relE = relE;  fmerit_fac = (Word16) 16384;  IF(sub(abs_s(sub(relE, tmp_mean)), add(abs_s(*relE_var), 6 * 256)) < 0 && (sub(old_clas, G729EV_FEC_UNVOICED) <= 0))  /* absolute variation */  {    fmerit_fac = (Word16) 13107;  }  ELSE if   (sub(sub(relE, tmp_mean), add(*relE_var, 3 * 256)) > 0 && (sub(old_clas, G729EV_FEC_V_TRANSITION) <= 0))  {    fmerit_fac = (Word16) 18022;  }  ELSE if   (sub(sub(relE, tmp_mean), (add(*relE_var, -5 * 256))) < 0 && (sub(old_clas, G729EV_FEC_V_TRANSITION) >= 0))  {    fmerit_fac = (Word16) 9830;  }  *relE_var = mac_r(L_mult(1638, sub(relE, tmp_mean)), 31130, *relE_var);#if(WMOPS)  move16();  move32();#endif   /*------------------------------------------------------------------------*    * transform parameters between 0 & 1        * find unique merit function                *------------------------------------------------------------------------*/  /*corn = G729EV_FEC_K_COR * mean_voi2 + G729EV_FEC_C_COR; */  Ltmp = G729EV_FEC_C_COR;  corn = round(L_shl(L_mac(Ltmp, mean_voi2, G729EV_FEC_K_COR), -4));  /*Q13->Q9 */  if (sub(corn, 512) > 0)  {    corn = (Word16) 512;#if(WMOPS)    move16();#endif  }  if (corn < 0)  {    corn = (Word16) 0;#if(WMOPS)    move16();#endif  }  Ltmp = L_mult(G729EV_FEC_C_ZC_ENC, 4);  /*Q13*Q2 -> Q16 */  zcn = round(L_shl(L_mac(Ltmp, zc, G729EV_FEC_K_ZC_ENC), 16 - 7)); /*Q0*Q15 + Q16 */  if (sub(zcn, 512) > 0)  {    zcn = (Word16) 512;#if(WMOPS)    move16();#endif  }  if (zcn < 0)  {    zcn = (Word16) 0;#if(WMOPS)    move16();#endif  }  Ltmp = L_mult(G729EV_FEC_C_RELE, 256);  /*Q15 ->Q24 */  relEn = round(L_shl(L_mac(Ltmp, relE, G729EV_FEC_K_RELE), 1));  /*relE in Q8 but relEn in Q9 */  if (sub(relEn, 512) > 0)  {    relEn = (Word16) 512;#if(WMOPS)    move16();#endif  }  if (sub(relEn, 256) < 0)  {    relEn = (Word16) 256;#if(WMOPS)    move16();#endif  }  Ltmp = G729EV_FEC_C_PC_ENC;   /*Q16 */  pcn = round(L_shl(L_mac(Ltmp, pc, G729EV_FEC_K_PC_ENC), 16 - 7)); /*Q16 + Q0*Q15 */#if(WMOPS)  move32();#endif  if (sub(pcn, 512) > 0)  {    pcn = (Word16) 512;#if(WMOPS)    move16();#endif  }  if (pcn < 0)  {    pcn = (Word16) 0;#if(WMOPS)    move16();#endif  }  Ltmp = L_mult(G729EV_FEC_C_SNR, 512);  snrn = mac_r(Ltmp, snr_val, G729EV_FEC_K_SNR);  /* Q25 +Q9*Q15 */  if (sub(snrn, 512) > 0)  {    snrn = (Word16) 512;#if(WMOPS)    move16();#endif  }  if (snrn < 0)  {    snrn = (Word16) 0;#if(WMOPS)    move16();#endif  }#if(WMOPS)  move16();  move16();  move16();#endif  IF(sub(relEn, 256) <= 0)  {    var1 = (Word16) 9830;    var2 = (Word16) 19661;    var3 = (Word16) 11796;  }  ELSE if   (sub(relEn, 384) > 0)  {    var1 = (Word16) 11703;    var2 = (Word16) 23406;    var3 = (Word16) 14043;  }  ELSE  {    var1 = (Word16) 9362;    var2 = (Word16) 18725;    var3 = (Word16) 11235;  }  Ltmp = L_mult(een, var1);  Ltmp = L_mac(Ltmp, corn, var2);  Ltmp = L_mac(Ltmp, zcn, var1);  Ltmp = L_mac(Ltmp, relEn, var1);  Ltmp = L_mac(Ltmp, pcn, var1);  fmerit1 = round(L_shl(L_mac(Ltmp, snrn, var2), 16 - 10 - 1)); /*fmerit1 ->Q15 */  /* Correction when noisy condition */  fmerit1 = shl(mult(fmerit_fac, fmerit1), 1);   /*-----------------------------------------------------------------*    * frame classification                      *-----------------------------------------------------------------*/#if(WMOPS)  move16();#endif  IF(sub(relE, -2560) < 0)  {    clas = G729EV_FEC_UNVOICED;  }  ELSE  {    SWITCH(old_clas)    {case G729EV_FEC_VOICED:case G729EV_FEC_ONSET:case G729EV_FEC_V_TRANSITION:      IF(sub(fmerit1, 18350) < 0)      {        clas = G729EV_FEC_UNVOICED;      }      ELSE if   (sub(fmerit1, 22282) < 0)      {        clas = G729EV_FEC_V_TRANSITION;      }      ELSE      {        clas = G729EV_FEC_VOICED;      }      BREAK;case G729EV_FEC_UNVOICED:case G729EV_FEC_UV_TRANSITION:      IF(sub(fmerit1, 20972) > 0)      {        clas = G729EV_FEC_ONSET;      }      ELSE if   (sub(fmerit1, 19005) > 0)      {        clas = G729EV_FEC_UV_TRANSITION;      }      ELSE      {        clas = G729EV_FEC_UNVOICED;      }      BREAK;default:      clas = G729EV_FEC_UNVOICED;      BREAK;    }  }  IF(sub(clas, G729EV_FEC_V_TRANSITION) > 0)  {    *lp_speech = mac_r(L_mult(32440, *lp_speech), 328, Etot);#if(WMOPS)    move16();#endif  }  return clas;}/*---------------------------------------------------------------------* *  Signal classification encoding *---------------------------------------------------------------------*/static Word16 G729EV_FEC_clas_enc(  /* o: quantization index                */                                   const Word16 clas  /* i:   signal clas for current frame   */    ){  Word16    index;#if(WMOPS)  move16();  test();#endif  IF(sub(clas, G729EV_FEC_UNVOICED) == 0)  {    index = (Word16) 0;  }  ELSE if   ((sub(clas, G729EV_FEC_V_TRANSITION) == 0) || (sub(clas, G729EV_FEC_UV_TRANSITION) == 0))  {    index = (Word16) 1;  }  ELSE if   (sub(clas, G729EV_FEC_VOICED) == 0)  {    index = (Word16) 2;  }  ELSE                          /* G729EV_FEC_ONSET        */  {    index = (Word16) 3;  }  return index;}

⌨️ 快捷键说明

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