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

📄 g729ev_celp2s_encod.c

📁 最新的ITU-T的宽带语音编解码标准G.729.1,是对原先的G.729的最好的调整.码流输出速率可以进行自适应调整.满足未来通信要求.希望对大家有所帮助.
💻 C
📖 第 1 页 / 共 3 页
字号:
      move16();      move16();#endif    }    /*-----------------------------------------------------*    * - Quantization of gains.                            *    *-----------------------------------------------------*/    g_coeff_cs[0] = g_coeff[0]; /* <y1,y1> */    exp_g_coeff_cs[0] = negate(g_coeff[1]); /* Q-Format:XXX -> JPN  */    g_coeff_cs[1] = negate(g_coeff[2]); /* (xn,y1) -> -2<xn,y1> */    exp_g_coeff_cs[1] = negate(add(g_coeff[3], 1)); /* Q-Format:XXX -> JPN  */#if (WMOPS)    move16();    move16();    move16();    move16();#endif    G729EV_G729_Corr_xy2(xn, y1, y2, g_coeff_cs, exp_g_coeff_cs); /* Q0 Q0 Q12 ^Qx ^Q0 */    /* g_coeff_cs[3]:exp_g_coeff_cs[3] = <y2,y2>   */    /* g_coeff_cs[4]:exp_g_coeff_cs[4] = -2<xn,y2> */    /* g_coeff_cs[5]:exp_g_coeff_cs[5] = 2<y1,y2>  */#if (WMOPS)    move16();#endif    *ana++ = G729EV_G729_Qua_gain(code, g_coeff_cs, exp_g_coeff_cs,                                  G729EV_G729_L_SUBFR, &gain_pit, &gain_code, temp, pCodStat->past_qua_en);    voice_fac = G729EV_FEC_voice_factor(exc + i_subfr, gain_pit, code, gain_code);    norm_voiced_fac = extract_l(L_shr(L_add(voice_fac, 32768), 1));    /*------------------------------------------------------*    * - Find the total excitation                          *    * - find synthesis speech corresponding to exc[]       *    * - update filters memories for finding the target     *    *   vector in the next subframe                        *    *   (update error[-m..-1] and mem_w_err[])             *    *   update error function for taming process           *    *------------------------------------------------------*/    ptr = exc + i_subfr;    FOR(i = 0; i < G729EV_G729_L_SUBFR; i++)    {      /* exc[i] = gain_pit*exc[i] + gain_code*code[i]; */      /* exc[i]  in Q1   gain_pit in Q14               */      /* code[i] in Q13  gain_cod in Q1                */      L_temp = L_mult(code[i], gain_code);  /* Q13 * Q1 -> Q15 */      L_temp = L_shl(L_temp, 1);  /* Q15 -> Q16  */      L_temp = L_mac(L_temp, exc[i + i_subfr], gain_pit); /* Q1 * Q14 -> Q16 */      L_temp = L_shl(L_temp, 1);  /* Q16 -> Q17  */      *ptr++ = round(L_temp);   /* exc in Q1   */#if (WMOPS)      move16();#endif    }    /* G729EV_G729_Syn_filt2 takes into account that exc is in Q1 to produce Q0 outputs */    G729EV_G729_Syn_filt2(Aq, &exc[i_subfr], &synth_ptr[i_subfr], G729EV_G729_L_SUBFR, pCodStat->mem_syn, 1);    /* Addition of a second fixed codebook (12Kbit/s mode)   */    IF(sub(pCodStat->rate, 12000) >= 0)    {      Word16    i;      Word16    res2[G729EV_G729_L_SUBFR];      /* Compute the error signal (input to the second stage) in the residual domain */      /* exc  -> residual of the 1st stage output signal                             */      /* exc2 -> residual of the input signal                                        */      ptr = res2;      FOR(i = 0; i < G729EV_G729_L_SUBFR; i++)      {        *ptr++ = sub(exc2[i + i_subfr], exc[i + i_subfr]);#if (WMOPS)        move16();#endif      }      /* exc2 -> residual of the error signal                                        */      /*--------------------------------------------------------*              * Find the target vector for the second fixed codebook   *      *--------------------------------------------------------*/      G729EV_G729_Syn_filt2(Aq, res2, error2, G729EV_G729_L_SUBFR, mem_err2, 0);      G729EV_G729_Residu2(Ap1, error2, xn_enha, G729EV_G729_L_SUBFR);      /* xn_enha is in Q1 as an input to G729EV_G729_Syn_filt2 and in Q0 as an output */      G729EV_G729_Syn_filt2(Ap2, xn_enha, xn_enha, G729EV_G729_L_SUBFR, pCodStat->mem_w0_2, 0); /* target signal xn_enha[] */                                                     /*-----------------------------------------------------*                                                     * - Innovative codebook search.                       *      *-----------------------------------------------------*/      /* search in fixed-codebook:  */      index_enha = G729EV_CELP2S_ACELP_code_2NDLAYER(xn_enha, res2, h1, norm_voiced_fac, code_enha, y2_enha, &ii);      *ana2++ = index_enha;     /* Positions index */      *ana2++ = ii;             /* Signs index     */#if (WMOPS)      move16();      move16();#endif      i = add(i0, shl(SubFrNum, 1));      {        /* quantize second fixed codebook gain */        index = G729EV_CELP2S_qua_gain_Stage2(gain_code, xn_enha, y2_enha, G729EV_G729_L_SUBFR, i);        /* Save Gain index */        *ana2++ = index;#if (WMOPS)        move16();#endif        /* Get Quantized gain value */        gain_code_enha = G729EV_CELP2S_dec_gain_Stage2(gain_code, index, i);      }      /*-----------------------------------------------------*      *   Find final output excitation                      *      * exc_enha =  exc[] + gain_code_enha * code_enha[]    *      *    exc[] = gain_pit * exc[-T] + gain_code * code [] *       *-----------------------------------------------------*/      ptr = exc_enha + i_subfr;      FOR(i = 0; i < G729EV_G729_L_SUBFR; i++)      {        /* exc_enha[i+i_subfr] = gain_code_enha * code_enha[i] + exc[i+i_subfr] */        /* exc[i]  in Q1                                            */        /* code_enha[i] in Q13  gain_code_enha in Q1                */        L_temp = L_mult(code_enha[i], gain_code_enha);  /* Q13 * Q1 -> Q15  */        L_temp = L_shl(L_temp, 1);  /* Q15 -> Q16       */        L_temp = L_mac(L_temp, exc[i + i_subfr], 16384);  /* Q1 * Q_14 -> Q16 */        L_temp = L_shl(L_temp, 1);  /* Q16 -> Q17 */        *ptr++ = round(L_temp); /* exc_enha in Q1 */#if (WMOPS)        move16();#endif      }      /* Compute synthesis signal. exc_enha[] / A(z)    */      /* G729EV_G729_Syn_filt2 takes into account that exc_enha is in Q1 to produce Q0 outputs */      G729EV_G729_Syn_filt2(Aq, &exc_enha[i_subfr], &synth[i_subfr], G729EV_G729_L_SUBFR, pCodStat->mem_synth, 1);      /* compute difference signal between input and local synthesis */      FOR(i = 0; i < G729EV_G729_L_SUBFR; i++)      {        diff[i_subfr + i] = sub(speech[i_subfr + i], synth[i_subfr + i]);#if(WMOPS)        move16();#endif      }    }  /*------------------------------------------------------------*    * - Update pitch sharpening "sharp" with quantized gain_pit  *    *------------------------------------------------------------*/    pCodStat->pit_sharp = gain_pit;#if (WMOPS)    move16();#endif    if (sub(pCodStat->pit_sharp, G729EV_G729_SHARPMAX) > 0)    {      pCodStat->pit_sharp = G729EV_G729_SHARPMAX;#if (WMOPS)      move16();#endif    }    if (sub(pCodStat->pit_sharp, G729EV_G729_SHARPMIN) < 0)    {      pCodStat->pit_sharp = G729EV_G729_SHARPMIN;#if (WMOPS)      move16();#endif    }    G729EV_G729_update_exc_err(pCodStat->L_exc_err, gain_pit, T0);    ptr = mem_err;    ptr2 = pCodStat->mem_w0;    FOR(i = G729EV_G729_L_SUBFR - G729EV_G729_M; i < G729EV_G729_L_SUBFR; i++)    {      *ptr++ = sub(speech[i_subfr + i], synth_ptr[i_subfr + i]);      temp = extract_h(L_shl(L_mult(y1[i], gain_pit), 1));      k = extract_h(L_shl(L_mult(y2[i], gain_code), 2));      *ptr2++ = sub(xn[i], add(temp, k));#if (WMOPS)      move16();      move16();#endif    }    IF(sub(pCodStat->rate, 12000) >= 0)    {      ptr = mem_err2;      ptr2 = pCodStat->mem_w0_2;      FOR(i = G729EV_G729_L_SUBFR - G729EV_G729_M; i < G729EV_G729_L_SUBFR; i++)      {        *ptr++ = sub(speech[i_subfr + i], synth[i_subfr + i]);        k = extract_h(L_shl(L_mult(y2_enha[i], gain_code_enha), 2));        *ptr2++ = sub(xn_enha[i], k);#if (WMOPS)        move16();        move16();#endif      }    }    A += G729EV_G729_MP1;       /* interpolated LPC parameters for next subframe */    Aq += G729EV_G729_MP1;  }  /* at this stage DataSynth comprises the synthesis at 12k while synth_ptr comprises     the synthesis at 8k     if the rate is 8k, overwrite DataSynth */  IF(sub(pCodStat->rate, 8000) == 0) G729EV_G729_Copy(synth_ptr, synth, G729EV_G729_L_FRAME);    /*--------------------------------------------------*     * Update signal for next frame.                    *     * -> shift to the left by L_FRAME:                 *     *     speech[], wsp[] and  exc[]                   *     *--------------------------------------------------*/  G729EV_G729_Copy(mem_err, pCodStat->mem_err, G729EV_G729_M_LPC);  G729EV_G729_Copy(&old_wsp[G729EV_G729_L_FRAME], &pCodStat->old_wsp[0], G729EV_G729_PIT_MAX);  G729EV_G729_Copy(&old_exc[G729EV_G729_L_FRAME], &pCodStat->old_exc[0], G729EV_G729_PIT_MAX + G729EV_G729_L_INTERPOL);  G729EV_G729_Copy(&old_speech[G729EV_G729_L_FRAME], &pCodStat->old_speech[0], G729EV_G729_MEM_SPEECH);  G729EV_G729_Copy(mem_err2, pCodStat->mem_err2, G729EV_G729_M_LPC);  G729EV_G729_Copy(&old_speech[G729EV_G729_L_FRAME], &pCodStat->old_speech[0], G729EV_G729_MEM_SPEECH);  /* Find wsyn *//* 0.268 WMOPS should validate a another domain to compute SNR tv */  *t0_out = T0;  *t0_fout = T0_frac;#if (WMOPS)  move16();  move16();#endif  G729EV_G729_Copy(exc2, resBF8k, G729EV_G729_L_FRAME);  G729EV_G729_Copy(speech, sync_speech, G729EV_G729_L_FRAME);  return;}

⌨️ 快捷键说明

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