📄 g729ev_celp2s_acelp_ca.c
字号:
#if (WMOPS) move32();#endif ptr_h1 = ptr_hd; ptr_h2 = ptr_hf; cor = (Word32) 0; FOR(i = k + 1; i < G729EV_G729_NB_POS; i++) { cor = L_mac(cor, *ptr_h1, *ptr_h2); ptr_h1++; ptr_h2++; *p3 = extract_h(cor);#if(WMOPS) move16();#endif cor = L_mac(cor, *ptr_h1, *ptr_h2); ptr_h1++; ptr_h2++; cor = L_mac(cor, *ptr_h1, *ptr_h2); ptr_h1++; ptr_h2++; *p2 = extract_h(cor);#if(WMOPS) move16();#endif cor = L_mac(cor, *ptr_h1, *ptr_h2); ptr_h1++; ptr_h2++; *p1 = extract_h(cor);#if(WMOPS) move16();#endif cor = L_mac(cor, *ptr_h1, *ptr_h2); ptr_h1++; ptr_h2++; *p0 = extract_h(cor);#if(WMOPS) move16();#endif p3 -= ldec; p2 -= ldec; p1 -= ldec; p0 -= ldec; } cor = L_mac(cor, *ptr_h1, *ptr_h2); ptr_h1++; ptr_h2++; *p3 = extract_h(cor);#if(WMOPS) move16();#endif l_fin_sup -= G729EV_G729_NB_POS; l_fin_inf--; ptr_hf += G729EV_G729_STEP; } /*----------------------------------------------------------------------* * Compute rr for AC orthogonalizing search * *----------------------------------------------------------------------*/#if (WMOPS) move32();#endif Max_ACC0 = (Word32) 0; ptr32 = tmp32 + G729EV_G729_L_SUBFR; ptr16 = y1 + G729EV_G729_L_SUBFR; FOR(i = 0; i < G729EV_G729_L_SUBFR; i++) {#if (WMOPS) move32();#endif ACC0 = (Word32) 0; ptr32--; ptr16--; ptr16tmp = ptr16; FOR(j = 0; j <= i; j++) ACC0 = L_mac(ACC0, h_scaled[j], *ptr16tmp++);#if (WMOPS) move32();#endif *ptr32 = ACC0; if (L_sub(L_abs(ACC0), Max_ACC0) > 0) Max_ACC0 = L_abs(ACC0); } shift_y1 = norm_l(Max_ACC0); ptr16 = tmp; FOR(i = 0; i < 40; i++) { *ptr16++ = extract_h(L_shl(tmp32[i], shift_y1)); }#if (WMOPS) move32();#endif ACC0 = (Word32) 0; FOR(i = 0; i < G729EV_G729_L_SUBFR; i++) ACC0 = L_mac(ACC0, y1[i], y1[i]); IF(ACC0 > 0) { shift_div = norm_l(ACC0); tmp16 = extract_h(L_shl(ACC0, shift_div)); r1 = div_s(16384, tmp16); } ELSE {#if (WMOPS) move16(); move16();#endif shift_div = (Word16) 0; r1 = (Word16) 0; } shift_div = sub(sub(shl(shift_y1, 1), shift_div), 1); p0 = rri0i0; p1 = rri1i1; p2 = rri2i2; p3 = rri3i3; p4 = rri4i4;#if (WMOPS) move16(); move16();#endif ii = (Word16) 0; kk = (Word16) 0; FOR(i = 0; i < G729EV_G729_NB_POS; i++) { rt0 = mult(tmp[ii], r1); rt1 = mult(tmp[ii + 1], r1); rt2 = mult(tmp[ii + 2], r1); rt3 = mult(tmp[ii + 3], r1); rt4 = mult(tmp[ii + 4], r1); tmp16 = mult(rt0, tmp[ii]); *p0++ = sub(rri0i0[i], shr(tmp16, shift_div));#if (WMOPS) move16();#endif tmp16 = mult(rt1, tmp[ii + 1]); *p1++ = sub(rri1i1[i], shr(tmp16, shift_div));#if (WMOPS) move16();#endif tmp16 = mult(rt2, tmp[ii + 2]); *p2++ = sub(rri2i2[i], shr(tmp16, shift_div));#if (WMOPS) move16();#endif tmp16 = mult(rt3, tmp[ii + 3]); *p3++ = sub(rri3i3[i], shr(tmp16, shift_div));#if (WMOPS) move16();#endif tmp16 = mult(rt4, tmp[ii + 4]); *p4++ = sub(rri4i4[i], shr(tmp16, shift_div));#if (WMOPS) move16();#endif p01 = rri0i1 + kk; p02 = rri0i2 + kk; p03 = rri0i3 + kk; p04 = rri0i4 + kk; p12 = rri1i2 + kk; p13 = rri1i3 + kk; p14 = rri1i4 + kk; p23 = rri2i3 + kk; p24 = rri2i4 + kk;#if (WMOPS) move16();#endif jj = (Word16) 0; FOR(j = 0; j < G729EV_G729_NB_POS; j++) { tmp16 = mult(rt0, tmp[jj + 1]); *p01++ = sub(rri0i1[kk + j], shr(tmp16, shift_div));#if (WMOPS) move16();#endif tmp16 = mult(rt0, tmp[jj + 2]); *p02++ = sub(rri0i2[kk + j], shr(tmp16, shift_div));#if (WMOPS) move16();#endif tmp16 = mult(rt0, tmp[jj + 3]); *p03++ = sub(rri0i3[kk + j], shr(tmp16, shift_div));#if (WMOPS) move16();#endif tmp16 = mult(rt0, tmp[jj + 4]); *p04++ = sub(rri0i4[kk + j], shr(tmp16, shift_div));#if (WMOPS) move16();#endif tmp16 = mult(rt1, tmp[jj + 2]); *p12++ = sub(rri1i2[kk + j], shr(tmp16, shift_div));#if (WMOPS) move16();#endif tmp16 = mult(rt1, tmp[jj + 3]); *p13++ = sub(rri1i3[kk + j], shr(tmp16, shift_div));#if (WMOPS) move16();#endif tmp16 = mult(rt1, tmp[jj + 4]); *p14++ = sub(rri1i4[kk + j], shr(tmp16, shift_div));#if (WMOPS) move16();#endif tmp16 = mult(rt2, tmp[jj + 3]); *p23++ = sub(rri2i3[kk + j], shr(tmp16, shift_div));#if (WMOPS) move16();#endif tmp16 = mult(rt2, tmp[jj + 4]); *p24++ = sub(rri2i4[kk + j], shr(tmp16, shift_div));#if (WMOPS) move16();#endif jj = add(jj, 5); } ii = add(ii, 5); kk = add(kk, 8); }}/*--------------------------------------------------------------------------* * Function G729EV_CELP2S_cor_h_x_OTH() * * Compute correlations of input response h[] with the target vector X[]. * *--------------------------------------------------------------------------*/void G729EV_CELP2S_cor_h_x_OTH(Word16 h[], /* (i) : Impulse response of filters (Q12) */ Word16 x[], /* (i) : Target vector */ Word16 d[], /* (o) : Correlation between h[] and x[] */ Word16 y1[] /* (i) : ac synthesised signal */ ){ Word32 y32[G729EV_G729_L_SUBFR]; Word32 *p_y32; Word32 ACC0, ACC1, tmp32; Word32 r0, max, s; Word16 tmp[G729EV_G729_L_SUBFR]; Word16 *p_tmp; Word16 *p_d; Word16 i, j; Word16 shift_div, shift_mult; Word16 w16_hi, w16_lo; Word16 tmp16;#if (WMOPS) move32(); move32();#endif ACC0 = (Word32) 0; ACC1 = (Word32) 0; FOR(i = 0; i < G729EV_G729_L_SUBFR; i++) { ACC0 = L_mac(ACC0, x[i], y1[i]); ACC1 = L_mac(ACC1, y1[i], y1[i]); } IF(ACC1 > 0) { /* 1/r1 */ shift_div = norm_l(ACC1); tmp16 = extract_h(L_shl(ACC1, shift_div)); tmp16 = div_s(16384, tmp16); /* r0 * (1/r1) */ shift_mult = norm_l(ACC0); L_Extract(L_shl(ACC0, shift_mult), &w16_hi, &w16_lo); r0 = Mpy_32_16(w16_hi, w16_lo, tmp16); shift_div = sub(15, shift_div); shift_div = add(shift_div, shift_mult); } ELSE {#if (WMOPS) move32(); move16();#endif r0 = (Word32) 0; shift_div = (Word16) 0; } p_tmp = tmp; L_Extract(r0, &w16_hi, &w16_lo); FOR(i = 0; i < G729EV_G729_L_SUBFR; i++) { tmp32 = Mpy_32_16(w16_hi, w16_lo, y1[i]); *p_tmp++ = sub(x[i], extract_l(L_shr(tmp32, shift_div)));#if (WMOPS) move16();#endif } /* first keep the result on 32 bits and find absolute maximum */#if (WMOPS) move32();#endif p_y32 = y32; max = (Word32) 0; FOR(i = 0; i < G729EV_G729_L_SUBFR; i++) { s = L_mult(tmp[i], h[0]); FOR(j = i + 1; j < G729EV_G729_L_SUBFR; j++) s = L_mac(s, tmp[j], h[j - i]);#if (WMOPS) move32();#endif *p_y32++ = s; s = L_abs(s); tmp32 = L_sub(s, max); if (tmp32 > 0L) { max = s;#if (WMOPS) move32();#endif } } /* Find the number of right shifts to do on y32[] */ /* so that maximum is on 13 bits */ j = norm_l(max); if (sub(j, 16) > 0) {#if (WMOPS) move16();#endif j = (Word16) 16; } p_d = d; j = sub(18, j); FOR(i = 0; i < G729EV_G729_L_SUBFR; i++) { *p_d++ = extract_l(L_shr(y32[i], j));#if (WMOPS) move16();#endif }}/*------------------------------------------------------------------------* * Function G729EV_d4i40_17_fast * * -> 17 bits; 4 pulses in a frame of 40 samples * *------------------------------------------------------------------------* * The code length is 40, containing 4 nonzero pulses i0, i1, i2, i3. * * Each pulses can have 8 possible positions (positive or negative) * * except i3 that have 16 possible positions. * * * * i0 (+-1) : 0, 5, 10, 15, 20, 25, 30, 35 * * i1 (+-1) : 1, 6, 11, 16, 21, 26, 31, 36 * * i2 (+-1) : 2, 7, 12, 17, 22, 27, 32, 37 * * i3 (+-1) : 3, 8, 13, 18, 23, 28, 33, 38 * * 4, 9, 14, 19, 24, 29, 34, 39 * *------------------------------------------------------------------------*/Word16 G729EV_CELP2S_d4i40_17_fast( /* (o) : Index of pulses positions. */ Word16 layer, /* (i): 0=8k layer, other=12k layer */ Word16 sp, /* (i): amplitude of the side-pulses */ Word16 b[], /* (i) : LTP residual & Dn */ Word16 dn[], /* (i) : Correlations between h[] and Xn[]. */ Word16 rr[], /* (i) : Correlations of impulse response h[]. */ Word16 h0[], /* (i) Q12: Impulse response of filters for the 1st sample. */ Word16 h[], /* (i) Q12: Impulse response of filters. */ Word16 cod[], /* (o) Q13: Selected algebraic codeword. */ Word16 y[], /* (o) Q12: Filtered algebraic codeword. */ Word16 * sign /* (o) : Signs of 4 pulses. */ ){ Word32 Ek, Ek_share; Word32 xtmp32, ytmp32; Word16 i, j, k; Word16 track, p_max; Word16 max; Word16 i0, i1, i2, i3, ip[5]; Word16 i0_offset, i1_offset, i2_offset, i3_offset; Word16 sign_dn[G729EV_G729_L_SUBFR], sign_dn_inv[G729EV_G729_L_SUBFR], *psign; Word16 *p0, *p1, *p2, *p3, *p4, *p5; Word16 *rri0i0, *rri1i1, *rri2i2, *rri3i3, *rri4i4; Word16 *rri0i1, *rri0i2, *rri0i3, *rri0i4; Word16 *rri1i2, *rri1i3, *rri1i4; Word16 *rri2i3, *rri2i4; Word16 *ptr_rri0i3_i4; Word16 *ptr_rri1i3_i4; Word16 *ptr_rri2i3_i4; Word16 *ptr_rri3i3_i4; Word16 Ck, Ck_share; Word16 num_max, den_max, num, den, prev_num_max, prev_den_max; Word16 xtmp16, ytmp16; Word16 sign_pat[4]; /* Initialize pointers */ rri0i0 = rr; rri1i1 = rri0i0 + G729EV_G729_NB_POS; rri2i2 = rri1i1 + G729EV_G729_NB_POS; rri3i3 = rri2i2 + G729EV_G729_NB_POS; rri4i4 = rri3i3 + G729EV_G729_NB_POS; rri0i1 = rri4i4 + G729EV_G729_NB_POS; rri0i2 = rri0i1 + G729EV_G729_MSIZE; rri0i3 = rri0i2 + G729EV_G729_MSIZE; rri0i4 = rri0i3 + G729EV_G729_MSIZE; rri1i2 = rri0i4 + G729EV_G729_MSIZE; rri1i3 = rri1i2 + G729EV_G729_MSIZE; rri1i4 = rri1i3 + G729EV_G729_MSIZE; rri2i3 = rri1i4 + G729EV_G729_MSIZE; rri2i4 = rri2i3 + G729EV_G729_MSIZE; p0 = sign_dn; p1 = sign_dn_inv; p2 = dn; p3 = b; /* Obtain the signs and absolute values of dn[], b[] */ FOR(i = 0; i < G729EV_G729_L_SUBFR; i++) {#if(WMOPS) move16(); move16();#endif IF(dn[i] >= 0) { *p0++ = MAX_16; *p1++ = MIN_16; *p2++; *p3++; } ELSE { *p0++ = MIN_16; *p1++ = MAX_16; *p2++ = negate(dn[i]); *p3++ = negate(b[i]);#if(WMOPS) move16(); move16();#endif } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -