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

📄 g729ev_celp2s_encod.c

📁 最新的ITU-T的宽带语音编解码标准G.729.1,是对原先的G.729的最好的调整.码流输出速率可以进行自适应调整.满足未来通信要求.希望对大家有所帮助.
💻 C
📖 第 1 页 / 共 3 页
字号:
  G729EV_G729_Az_lsp(&A_t[G729EV_G729_MP1], lsp_new, pCodStat->lsp_old);  /* From A(z) to lsp */  /* LSP quantization */  G729EV_G729_Qua_lsp(lsp_new, lsp_new_q, ana, pCodStat->freq_prev);  /* !!!! pb avec lsp_new_q */  ana += 2;                     /* Advance analysis parameters pointer */  /*--------------------------------------------------------------------*  * Find interpolated LPC parameters in all subframes (both quantized  *  * and unquantized).                                                  *  * The interpolated parameters are in array A_t[] of size (M+1)*4     *  * and the quantized interpolated parameters are in array Aq_t[]      *  *--------------------------------------------------------------------*/  G729EV_G729_Int_lpc(pCodStat->lsp_old, lsp_new, lsf_int, lsf_new, A_t);  G729EV_G729_Int_qlpc(pCodStat->lsp_old_q, lsp_new_q, Aq_t);  G729EV_G729_Copy(Aq_t, &celp_Az[2 * SubFrNum * G729EV_G729_MP1], 2 * G729EV_G729_MP1);  /* update the LSPs for the next frame */  G729EV_G729_Copy(lsp_new, pCodStat->lsp_old, G729EV_G729_M);  G729EV_G729_Copy(lsp_new_q, pCodStat->lsp_old_q, G729EV_G729_M);  /*----------------------------------------------------------------------*  * - Find the weighting factors                                         *  *----------------------------------------------------------------------*/  G729EV_G729_perc_var(gamma1, gamma2, lsf_int, lsf_new, rc, &pCodStat->smooth, pCodStat->lar_old);  /*----------------------------------------------------------------------*  * - Find the weighted input speech w_sp[] for the whole speech frame   *  * - Find the open-loop pitch delay                                     *  *----------------------------------------------------------------------*/  G729EV_G729_Weight_Az(&A_t[0], gamma1[0], G729EV_G729_M, Ap1);  G729EV_G729_Weight_Az(&A_t[0], gamma2[0], G729EV_G729_M, Ap2);  G729EV_G729_Residu(Ap1, &speech[0], &wsp[0], G729EV_G729_L_SUBFR);  G729EV_G729_Syn_filt(Ap2, &wsp[0], &wsp[0], G729EV_G729_L_SUBFR, pCodStat->mem_w, 1);  G729EV_G729_Weight_Az(&A_t[G729EV_G729_MP1], gamma1[1], G729EV_G729_M, Ap1);  G729EV_G729_Weight_Az(&A_t[G729EV_G729_MP1], gamma2[1], G729EV_G729_M, Ap2);  G729EV_G729_Residu(Ap1, &speech[G729EV_G729_L_SUBFR], &wsp[G729EV_G729_L_SUBFR], G729EV_G729_L_SUBFR);  G729EV_G729_Syn_filt(Ap2, &wsp[G729EV_G729_L_SUBFR], &wsp[G729EV_G729_L_SUBFR], G729EV_G729_L_SUBFR, pCodStat->mem_w,                       1);  /* Find open loop pitch lag */  T_op =      G729EV_G729_Pitch_ol(wsp, G729EV_G729_PIT_MIN, G729EV_G729_PIT_MAX, G729EV_G729_L_FRAME, voicing,                           &(pCodStat->pit_old));  /* Range for closed loop pitch search in 1st subframe */  T0_min = sub(T_op, 3);  if (sub(T0_min, G729EV_G729_PIT_MIN) < 0)  {    T0_min = G729EV_G729_PIT_MIN;#if (WMOPS)    move16();#endif  }  T0_max = add(T0_min, 6);  IF(sub(T0_max, G729EV_G729_PIT_MAX) > 0)  {    T0_max = G729EV_G729_PIT_MAX;    T0_min = sub(T0_max, 6);#if (WMOPS)    move16();#endif  }  /*------------------------------------------------------------------------*  *          Loop for every subframe in the analysis frame                 *  *------------------------------------------------------------------------*  *  To find the pitch and innovation parameters. The subframe size is     *  *  L_SUBFR and the loop is repeated 2 times.                             *  *     - find the weighted LPC coefficients                               *  *     - find the LPC residual signal res[]                               *  *     - compute the target signal for pitch search                       *  *     - compute impulse response of weighted synthesis filter (h1[])     *  *     - find the closed-loop pitch parameters                            *  *     - encode the pitch delay                                           *  *     - update the impulse response h1[] by including fixed-gain pitch   *  *     - find target vector for codebook search                           *  *     - codebook search                                                  *  *     - encode codebook address                                          *  *     - VQ of pitch and codebook gains                                   *  *     - find synthesis speech                                            *  *     - update states of weighting filter                                *  *------------------------------------------------------------------------*/  A = A_t;                      /* pointer to interpolated LPC parameters           */  Aq = Aq_t;                    /* pointer to interpolated quantized LPC parameters */  i_gamma = 0;#if (WMOPS)  move16();#endif  FOR(i0 = 0; i0 < G729EV_G729_L_FRAME / G729EV_G729_L_SUBFR; i0++)  {    i_subfr = i_mult(i0, G729EV_G729_L_SUBFR);    /*---------------------------------------------------------------*     * Find the weighted LPC coefficients for the weighting filter.  *     *---------------------------------------------------------------*/    G729EV_G729_Weight_Az(A, gamma1[i_gamma], G729EV_G729_M, Ap1);    G729EV_G729_Weight_Az(A, gamma2[i_gamma], G729EV_G729_M, Ap2);    i_gamma = add(i_gamma, 1);    /*---------------------------------------------------------------*    * Compute impulse response, h1[], of weighted synthesis filter  *    *---------------------------------------------------------------*/    G729EV_G729_Copy(Ap1, ai_zero, G729EV_G729_MP1);    G729EV_G729_Syn_filt(Aq, ai_zero, h1, G729EV_G729_L_SUBFR, zero, 0);    G729EV_G729_Syn_filt(Ap2, h1, h1, G729EV_G729_L_SUBFR, zero, 0);    /*------------------------------------------------------------------------*    *                                                                        *    *          Find the target vector for pitch search:                      *    *          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                       *    *                                                                        *    *              |------|  res[n]                                          *    *  speech[n]---| A(z) |--------                                          *    *              |------|       |   |--------| error[n]  |------|          *    *                    zero -- (-)--| 1/A(z) |-----------| W(z) |-- target *    *                    exc          |--------|           |------|          *    *                                                                        *    * Instead of subtracting the zero-input response of filters from         *    * the weighted input speech, the above configuration is used to       *    * compute the target vector. This configuration gives better performance *    * with fixed-point implementation. The memory of 1/A(z) is updated by    *    * filtering (res[n]-exc[n]) through 1/A(z), or simply by subtracting     *    * the synthesis speech from the input speech:                            *    *    error[n] = speech[n] - syn[n].                                      *    * The memory of W(z) is updated by filtering error[n] through W(z),      *    * or more simply by subtracting the filtered adaptive and fixed          *    * codebook excitations from the target:                                  *    *     target[n] - gain_pit*y1[n] - gain_code*y2[n]                       *    * as these signals are already available.                                *    *                                                                        *    *------------------------------------------------------------------------*/    /* Input signal is in Q0 and the output residual signal is in Q1 */    /* Since the input signal has been downscaled by two during pre-processing and       because the LP filter is expected to produce a prediction gain, no saturation is       expected when setting the excitation in Q1 */    G729EV_G729_Residu2(Aq, &speech[i_subfr], &exc[i_subfr], G729EV_G729_L_SUBFR);  /* LPC residual */    IF(sub(pCodStat->rate, 12000) >= 0)    {      /* Save residual. This input will be needed to compute the error signal in the residual domain */      G729EV_G729_Copy(&exc[i_subfr], &exc2[i_subfr], G729EV_G729_L_SUBFR);    }    G729EV_G729_Syn_filt2(Aq, &exc[i_subfr], error, G729EV_G729_L_SUBFR, mem_err, 0);    G729EV_G729_Residu2(Ap1, error, xn, G729EV_G729_L_SUBFR);    /* xn is in Q1 prior to the synthesis filter and in Q0 after... */    G729EV_G729_Syn_filt2(Ap2, xn, xn, G729EV_G729_L_SUBFR, pCodStat->mem_w0, 0); /* target signal xn[] */    /* Save residual signal (will be needed to compute second second stage target */    G729EV_G729_Copy(exc + i_subfr, res1, G729EV_G729_L_SUBFR);    /*----------------------------------------------------------------------*    *                 Closed-loop fractional pitch search                  *    *----------------------------------------------------------------------*/    /* function G729EV_G729_Convolve (used in G729EV_G729_Pitch_fr3) has been modified       from the original G.729 standard to account for the new Q1 format used for the excitation */    T0 = G729EV_G729_Pitch_fr3(&exc[i_subfr], xn, h1, G729EV_G729_L_SUBFR, T0_min, T0_max, i_subfr, &T0_frac);    index = G729EV_G729_Enc_lag3(T0, T0_frac, &T0_min, &T0_max, G729EV_G729_PIT_MIN, G729EV_G729_PIT_MAX, i_subfr);    *ana++ = index;#if (WMOPS)    move16();#endif    IF(i_subfr == 0)    {      *ana++ = G729EV_G729_Parity_Pitch(index);#if (WMOPS)      move16();#endif    }    *pit++ = T0;#if (WMOPS)    move16();#endif    /*-----------------------------------------------------------------*    *   - find unity gain pitch excitation (adaptive codebook entry)  *    *     with fractional interpolation.                              *    *   - find filtered pitch exc. y1[]=exc[] convolve with h1[])     *    *   - compute pitch gain and limit between 0 and 1.2              *    *   - update target vector for codebook search                    *    *   - find LTP residual.                                          *    *-----------------------------------------------------------------*/    G729EV_G729_Pred_lt_3(&exc[i_subfr], T0, T0_frac, G729EV_G729_L_SUBFR);    /* function G729EV_G729_Convolve has been modified       from the original G.729 standard to account for the new Q1 format used for the excitation        Therefore, exc is in Q1 but y1 remains in Q12 */    G729EV_G729_Convolve(&exc[i_subfr], h1, y1, G729EV_G729_L_SUBFR);    gain_pit = G729EV_G729_G_pitch(xn, y1, g_coeff, G729EV_G729_L_SUBFR);    /* clip pitch gain if taming is necessary */    temp = G729EV_G729_test_err(pCodStat, T0, T0_frac);    IF(sub(temp, 1) == 0)    {      if (sub(gain_pit, G729EV_G729_GPCLIP) > 0)      {        gain_pit = G729EV_G729_GPCLIP;#if (WMOPS)        move16();#endif      }    }    /* xn2[i]   = xn[i] - y1[i] * gain_pit  */    ptr = xn2;    FOR(i = 0; i < G729EV_G729_L_SUBFR; i++)    {      L_temp = L_mult(y1[i], gain_pit);      L_temp = L_shl(L_temp, 1);  /* gain_pit in Q14 */      *ptr++ = sub(xn[i], extract_h(L_temp));#if (WMOPS)      move16();#endif    }    /*-----------------------------------------------------*    * - Innovative codebook search.                       *    *-----------------------------------------------------*/    {      Word16    h[G729EV_G729_L_SUBFR];      /* The impulse respond h1 should not be modified by the codebook search routine because               it will be used as an input to the second inovative codebook search. h1 is therefore                 duplicated into a temporary memory space before calling G729EV_G729_ACELP_code_A */      G729EV_G729_Copy(h1, h, G729EV_G729_L_SUBFR);      /* Compute residual after long term prediction */      FOR(i = 0; i < G729EV_G729_L_SUBFR; i++)      {        L_temp = L_mult(res1[i], 16384);        L_temp = L_msu(L_temp, exc[i + i_subfr], gain_pit); /* gain_pit in Q14 */        L_temp = L_shl(L_temp, 1);        res1[i] = round(L_temp);      }      index = G729EV_CELP2S_ACELP_code_A_OTH(xn2, res1, h, T0, pCodStat->pit_sharp, code, y2, &i, y1);      *ana++ = index;           /* Positions index */      *ana++ = i;               /* Signs index     */#if (WMOPS)

⌨️ 快捷键说明

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