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

📄 g729ev_g729_pst.c

📁 最新的ITU-T的宽带语音编解码标准G.729.1,是对原先的G.729的最好的调整.码流输出速率可以进行自适应调整.满足未来通信要求.希望对大家有所帮助.
💻 C
📖 第 1 页 / 共 3 页
字号:
      }    }    ELSE    {      L_temp = L_sub(*ptr_L_den1, L_den_max);      if (L_temp > 0L)      {#if (WMOPS)        move32();#endif        L_den_max = *ptr_L_den1;      }    }    ptr_L_den0++;    ptr_L_den1++;    ptr_y_up += G729EV_G729_L_SUBFRP1;    ptr_h += G729EV_G729_LH2_S;  }  if (L_den_max == 0)  {#if (WMOPS)    move16();    move16();    move16();    move16();#endif    *num_gltp = 0;    *den_gltp = 1;    *ltpdel = 0;    *phase = 0;    return;  }  sh_den = sub(16, norm_l(L_den_max));  /* if sh_den <= 0 :  dynamic between current frame */  /* and delay line too high                         */  if (sh_den <= 0)  {#if (WMOPS)    move16();    move16();    move16();    move16();#endif    *num_gltp = 0;    *den_gltp = 1;    *ltpdel = 0;    *phase = 0;    return;  }  /* search sh_num to justify correlations   */  /* sh_num = Max(sh_den, sh_ener)           */  IF(sub(sh_den, sh_ener) >= 0)  {    sh_num = sh_den;  }  ELSE  {    sh_num = sh_ener;  }#if (WMOPS)  move16();#endif  /* Computation of the numerators                */  /* and selection of best num*num/den            */  /* for non null phases                          */  /* Initialize with null phase */  L_acc = L_shr(L_den_int, sh_den); /* sh_den > 0 */  den_max = extract_l(L_acc);  L_acc = L_shr(L_num_int, sh_num); /* sh_num > 0 */  num_max = extract_l(L_acc);  L_acc = L_mult(num_max, num_max);  L_Extract(L_acc, &hi_numsq_max, &lo_numsq_max);#if (WMOPS)  move16();  move16();#endif  phi_max = 0;  ioff = 1;  ptr_L_den0 = L_den0;  ptr_L_den1 = L_den1;  ptr_y_up = y_up;  /* if den_max = 0 : will be selected and declared unvoiced */  /* if num!=0 & den=0 : will be selected and declared unvoiced */  /* degenerated seldom cases, switch off LT is OK */  /* Loop on phase */  FOR(phi = 1; phi < G729EV_G729_F_UP_PST; phi++)  {#if (WMOPS)    move32();#endif    /* compute num for lambda+1 - phi/F_UP_PST */    L_acc = 0L;    FOR(n = 0; n < G729EV_G729_L_SUBFR; n++)    {      L_acc = L_mac(L_acc, ptr_sig_in[n], ptr_y_up[n]);    }    L_acc = L_shr(L_acc, sh_num); /* sh_num > 0 */    IF(L_acc < 0L)    {#if (WMOPS)      move16();#endif      num = 0;    }    ELSE    {      num = extract_l(L_acc);    }    /* selection if num**2/den0 max */    L_acc = L_mult(num, num);    L_Extract(L_acc, &hi_numsq, &lo_numsq);    L_temp0 = Mpy_32_16(hi_numsq, lo_numsq, den_max);#if (WMOPS)    move32();#endif    L_acc = *ptr_L_den0++;    L_acc = L_shr(L_acc, sh_den); /* sh_den > 0 */    den0 = extract_l(L_acc);    L_temp1 = Mpy_32_16(hi_numsq_max, lo_numsq_max, den0);    L_temp = L_sub(L_temp0, L_temp1);    if (L_temp > 0L)    {#if (WMOPS)      move16();      move16();      move16();      move16();      move16();      move16();#endif      num_max = num;      hi_numsq_max = hi_numsq;      lo_numsq_max = lo_numsq;      den_max = den0;      ioff = 0;      phi_max = phi;    }    /* compute num for lambda - phi/F_UP_PST */    ptr_y_up++;#if (WMOPS)    move32();#endif    L_acc = 0L;    FOR(n = 0; n < G729EV_G729_L_SUBFR; n++)    {      L_acc = L_mac(L_acc, ptr_sig_in[n], ptr_y_up[n]);    }    L_acc = L_shr(L_acc, sh_num); /* sh_num > 0 */    IF(L_acc < 0L)    {#if (WMOPS)      move16();#endif      num = 0;    }    ELSE    {      num = extract_l(L_acc);    }    /* selection if num**2/den1 max */    L_acc = L_mult(num, num);    L_Extract(L_acc, &hi_numsq, &lo_numsq);    L_temp0 = Mpy_32_16(hi_numsq, lo_numsq, den_max);#if (WMOPS)    move32();#endif    L_acc = *ptr_L_den1++;    L_acc = L_shr(L_acc, sh_den); /* sh_den > 0 */    den1 = extract_l(L_acc);    L_temp1 = Mpy_32_16(hi_numsq_max, lo_numsq_max, den1);    L_temp = L_sub(L_temp0, L_temp1);    if (L_temp > 0L)    {#if (WMOPS)      move16();      move16();      move16();      move16();      move16();      move16();#endif      num_max = num;      hi_numsq_max = hi_numsq;      lo_numsq_max = lo_numsq;      den_max = den1;      ioff = 1;      phi_max = phi;    }    ptr_y_up += G729EV_G729_L_SUBFR;  }    /***************************************************/    /*** test if normalized crit0[iopt] > THRESHCRIT ***/    /***************************************************/#if (WMOPS)  test();#endif  if ((num_max == 0) || (sub(den_max, 1) <= 0))  {#if (WMOPS)    move16();    move16();    move16();    move16();#endif    *num_gltp = 0;    *den_gltp = 1;    *ltpdel = 0;    *phase = 0;    return;  }  /* compare num**2               */  /* to ener * den * 0.5          */  /* (THRESHCRIT = 0.5)           */  L_temp1 = L_mult(den_max, ener);  L_temp0 = L_Comp(hi_numsq_max, lo_numsq_max);  /* temp = 2 * sh_num - sh_den - sh_ener + 1 */  /* 16 bits with no overflows  */  temp = shl(sh_num, 1);  temp = sub(temp, sh_den);  temp = sub(temp, sh_ener);  temp = add(temp, 1);  IF(temp < 0)  {    temp = negate(temp);        /* no overflow */    L_temp0 = L_shr(L_temp0, temp);  }  ELSE  {    if (temp > 0)      L_temp1 = L_shr(L_temp1, temp);  }  L_temp = L_sub(L_temp0, L_temp1);  IF(L_temp >= 0L)  {#if (WMOPS)    move16();    move16();    move16();    move16();    move16();    move16();#endif    temp = add(lambda, 1);    *ltpdel = sub(temp, ioff);    *off_yup = ioff;    *phase = phi_max;    *num_gltp = num_max;    *den_gltp = den_max;    *sh_den_gltp = sh_den;    *sh_num_gltp = sh_num;  }  ELSE  {#if (WMOPS)    move16();    move16();    move16();    move16();#endif    *num_gltp = 0;    *den_gltp = 1;    *ltpdel = 0;    *phase = 0;  }  return;}/*---------------------------------------------------------------------------- *  filt_plt -  ltp  postfilter *---------------------------------------------------------------------------- */void G729EV_G729_filt_plt(Word16 * s_in,  /* input : input signal with past */                          Word16 * s_ltp, /* input : filtered signal with gain 1 */                          Word16 * s_out, /* output: output signal */                          Word16 gain_plt /* input : filter gain  */    ){  /* Local variables */  Word32    L_acc;  Word16    n;  Word16    gain_plt_1;  gain_plt_1 = sub(32767, gain_plt);  gain_plt_1 = add(gain_plt_1, 1);  /* 2**15 (1 - g) */  FOR(n = 0; n < G729EV_G729_L_SUBFR; n++)  {    /* s_out(n) = gain_plt x s_in(n) + gain_plt_1 x s_ltp(n)        */    L_acc = L_mult(gain_plt, s_in[n]);    L_acc = L_mac(L_acc, gain_plt_1, s_ltp[n]); /* no overflow      */#if (WMOPS)    move16();#endif    s_out[n] = round(L_acc);  }  return;}/*---------------------------------------------------------------------------- *  G729EV_G729_compute_ltp_l : compute delayed signal,                    num & den of gain for fractional delay *                  with long interpolation filter *---------------------------------------------------------------------------- */void G729EV_G729_compute_ltp_l(Word16 * s_in, /* input signal with past */                               Word16 ltpdel, /* delay factor */                               Word16 phase,  /* phase factor */                               Word16 * y_up, /* delayed signal */                               Word16 * num,  /* numerator of LTP gain */                               Word16 * den,  /* denominator of LTP gain */                               Word16 * sh_num, /* justification factor of num */                               Word16 * sh_den  /* justification factor of den */    ){  Word32    L_acc;  extern Word16 tab_hup_l[G729EV_G729_SIZ_TAB_HUP_L];  Word16   *ptr2;  Word16   *ptr_h;  Word16    n, i;  Word16    temp;  temp = sub(phase, 1);  temp = shl(temp, G729EV_G729_L2_LH2_L);  ptr_h = tab_hup_l + temp;     /* tab_hup_l + G729EV_G729_LH2_L * (phase-1) */  temp = sub(G729EV_G729_LH_UP_L, ltpdel);  ptr2 = s_in + temp;;  /* Compute y_up */  FOR(n = 0; n < G729EV_G729_L_SUBFR; n++)  {#if (WMOPS)    move32();    move16();#endif    L_acc = 0L;    FOR(i = 0; i < G729EV_G729_LH2_L; i++)    {      L_acc = L_mac(L_acc, ptr_h[i], (*ptr2--));    }    y_up[n] = round(L_acc);    ptr2 += G729EV_G729_LH2_L_P1;  }  /* Compute num */#if (WMOPS)  move32();#endif  L_acc = 0L;  FOR(n = 0; n < G729EV_G729_L_SUBFR; n++)  {    L_acc = L_mac(L_acc, y_up[n], s_in[n]);  }  IF(L_acc < 0L)  {#if (WMOPS)    move16();    move16();#endif    *num = 0;    *sh_num = 0;  }  ELSE  {    temp = sub(16, norm_l(L_acc));    if (temp < 0)    {#if (WMOPS)      move16();#endif      temp = 0;    }    L_acc = L_shr(L_acc, temp); /* with temp >= 0 */    *num = extract_l(L_acc);    *sh_num = temp;#if (WMOPS)    move16();    move16();#endif  }  /* Compute den */#if (WMOPS)  move32();#endif  L_acc = 0L;  FOR(n = 0; n < G729EV_G729_L_SUBFR; n++)  {    L_acc = L_mac(L_acc, y_up[n], y_up[n]);  }  temp = sub(16, norm_l(L_acc));  if (temp < 0)  {#if (WMOPS)    move16();#endif    temp = 0;  }  L_acc = L_shr(L_acc, temp);   /* with temp >= 0 */  *den = extract_l(L_acc);  *sh_den = temp;#if (WMOPS)  move16();  move16();#endif  return;}/*---------------------------------------------------------------------------- *  G729EV_G729_select_ltp : selects best of (gain1, gain2) *  with gain1 = num1 * 2** sh_num1 / den1 * 2** sh_den1 *  and  gain2 = num2 * 2** sh_num2 / den2 * 2** sh_den2

⌨️ 快捷键说明

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