本文整理汇总了C++中L_mac函数的典型用法代码示例。如果您正苦于以下问题:C++ L_mac函数的具体用法?C++ L_mac怎么用?C++ L_mac使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了L_mac函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Pre_Process
void Pre_Process(
PrpStatus *handle,
Word16 signal[], /* input/output signal */
Word16 lg) /* length of signal */
{
Word16 i, x2;
Word32 L_tmp;
for(i=0; i<lg; i++)
{
x2 = handle->x1;
handle->x1 = handle->x0;
handle->x0 = signal[i];
/* y[i] = b[0]*x[i]/2 + b[1]*x[i-1]/2 + b140[2]*x[i-2]/2 */
/* + a[1]*y[i-1] + a[2] * y[i-2]; */
L_tmp = Mpy_32_16(handle->y1_hi, handle->y1_lo, a140[1]);
L_tmp = L_add(L_tmp, Mpy_32_16(handle->y2_hi, handle->y2_lo, a140[2]));
L_tmp = L_mac(L_tmp, handle->x0, b140[0]);
L_tmp = L_mac(L_tmp, handle->x1, b140[1]);
L_tmp = L_mac(L_tmp, x2, b140[2]);
L_tmp = L_shl(L_tmp, 3); /* Q28 --> Q31 (Q12 --> Q15) */
signal[i] = round(L_tmp);
handle->y2_hi = handle->y1_hi;
handle->y2_lo = handle->y1_lo;
L_Extract(L_tmp, &(handle->y1_hi), &(handle->y1_lo));
}
return;
}
示例2: Post_Process
void Post_Process(
int16_t signal[], /* input/output signal */
int16_t lg) /* length of signal */
{
int16_t i, x2;
int32_t L_tmp;
for(i=0; i<lg; i++)
{
x2 = x1;
x1 = x0;
x0 = signal[i];
/* y[i] = b[0]*x[i] + b[1]*x[i-1] + b[2]*x[i-2] */
/* + a[1]*y[i-1] + a[2] * y[i-2]; */
L_tmp = Mpy_32_16(y1_hi, y1_lo, a100[1]);
L_tmp = L_add(L_tmp, Mpy_32_16(y2_hi, y2_lo, a100[2]));
L_tmp = L_mac(L_tmp, x0, b100[0]);
L_tmp = L_mac(L_tmp, x1, b100[1]);
L_tmp = L_mac(L_tmp, x2, b100[2]);
L_tmp = L_shl(L_tmp, 2); /* Q29 --> Q31 (Q13 --> Q15) */
/* Multiplication by two of output speech with saturation. */
signal[i] = _round(L_shl(L_tmp, 1));
y2_hi = y1_hi;
y2_lo = y1_lo;
L_Extract(L_tmp, &y1_hi, &y1_lo);
}
return;
}
示例3: Deemph2_
void Deemph2_(
Word16 x[], /* (i/o) : input signal overwritten by the output */
Word16 mu, /* (i) Q15 : deemphasis factor */
Word16 L, /* (i) : vector size */
Word16 * mem /* (i/o) : memory (y[-1]) */
)
{
Word16 i;
Word32 L_tmp;
/* saturation can occur in L_mac() */
L_tmp = L_mult(x[0], 16384);
L_tmp = L_mac(L_tmp, *mem, mu);
x[0] = round16(L_tmp);
for (i = 1; i < L; i++)
{
L_tmp = L_mult(x[i], 16384);
L_tmp = L_mac(L_tmp, x[i - 1], mu);
x[i] = round16(L_tmp);
}
*mem = x[L - 1];
return;
}
示例4: Interpol_3
/*---------------------------------------------------------------------------*
* Procedure Interpol_3() *
* ~~~~~~~~~~~~~~~~~~~~~~ *
* For interpolating the normalized correlation with 1/3 resolution. *
*--------------------------------------------------------------------------*/
Word16 Interpol_3( /* (o) : interpolated value */
Word16 *x, /* (i) : input vector */
Word16 frac /* (i) : fraction */
)
{
Word16 i, k;
Word16 *x1, *x2, *c1, *c2;
Word32 s;
if(frac < 0)
{
frac = add(frac, UP_SAMP);
x--;
}
x1 = &x[0];
x2 = &x[1];
c1 = &inter_3[frac];
c2 = &inter_3[sub(UP_SAMP,frac)];
s = 0;
for(i=0, k=0; i< L_INTER4; i++, k+=UP_SAMP)
{
s = L_mac(s, x1[-i], c1[k]);
s = L_mac(s, x2[i], c2[k]);
}
return round(s);
}
示例5: maxeloc
void maxeloc(INT16 *maxloc,
INT32 *maxener,
INT16 *signal,
INT16 dp,
INT16 length,
INT16 ewl)
{
INT32 ener;
register int i;
int tail, front;
ener = 0;
front = add(dp, ewl);
tail = sub(dp, ewl);
for (i = tail; i <= front; i++)
ener = L_mac(ener, signal[i], signal[i]);
*maxloc = 0;
*maxener = ener;
for (i = 1; i < length; i++)
{
front++;
ener = L_msu(ener, signal[tail], signal[tail]);
ener = L_mac(ener, signal[front], signal[front]);
tail++;
if (*maxener < ener)
{
*maxloc = i;
*maxener = ener;
}
}
*maxloc = add(*maxloc,dp);
*maxener = L_shr(*maxener, 1);
}
示例6: sqrts
Word16 sqrts(Word16 x)
{
Word16 xb, y, exp, idx, sub_frac, sub_tab;
Word32 a0;
if(x <= 0){
y = 0;
}
else{
exp = norm_s(x);
/* use 65-entry table */
xb = shl(x, exp); // normalization of x
idx = shr(xb, 9); // for 65 entry table
a0 = L_deposit_h(tabsqrt[idx]); // Q31 table look-up value
sub_frac = shl((Word16)(xb & 0x01FF), 6); // Q15 sub-fraction
sub_tab = sub(tabsqrt[idx+1], tabsqrt[idx]); // Q15 table interval for interpolation
a0 = L_mac(a0, sub_frac, sub_tab); // Q31 linear interpolation between table entries
if(exp & 0x0001){
exp = shr(add(exp, 1), 1); // normalization of sqrt()
a0 = L_shr(a0, exp);
y = intround(a0); // Q15
a0 = L_mac(a0, 13573, y); // Q31 incorporate the missing "/sqrt(2)"
}
else{
exp = shr(exp, 1); // normalization of sqrt()
a0 = L_shr(a0, exp); // Q31
}
y = intround(a0); // Q15
}
return y;
}
示例7: Pre_Process
void Pre_Process(
Word16 signal[], /* input/output signal */
Word16 lg) /* length of signal */
{
Word16 i, x2;
Word32 L_tmp;
for(i=0; i<lg; i++)
{
x2 = x1;
x1 = x0;
x0 = signal[i];
/* y[i] = b[0]*x[i]/2 + b[1]*x[i-1]/2 + b140[2]*x[i-2]/2 */
/* + a[1]*y[i-1] + a[2] * y[i-2]; */
L_tmp = Mpy_32_16(y1_hi, y1_lo, a140[1]);
L_tmp = L_add(L_tmp, Mpy_32_16(y2_hi, y2_lo, a140[2]));
L_tmp = L_mac(L_tmp, x0, b140[0]);
L_tmp = L_mac(L_tmp, x1, b140[1]);
L_tmp = L_mac(L_tmp, x2, b140[2]);
L_tmp = L_shl(L_tmp, 3); /* Q28 --> Q31 (Q12 --> Q15) */
signal[i] = round(L_tmp);
y2_hi = y1_hi;
y2_lo = y1_lo;
L_Extract(L_tmp, &y1_hi, &y1_lo);
}
return;
}
示例8: Post_Process
void Post_Process(
PopStatus *handle,
Word16 signal[], /* input/output signal */
Word16 lg) /* length of signal */
{
Word16 i, x2;
Word32 L_tmp;
for(i=0; i<lg; i++)
{
x2 = handle->x1;
handle->x1 = handle->x0;
handle->x0 = signal[i];
/* y[i] = b[0]*x[i] + b[1]*x[i-1] + b[2]*x[i-2] */
/* + a[1]*y[i-1] + a[2] * y[i-2]; */
L_tmp = Mpy_32_16(handle->y1_hi, handle->y1_lo, a100[1]);
L_tmp = L_add(L_tmp, Mpy_32_16(handle->y2_hi, handle->y2_lo, a100[2]));
L_tmp = L_mac(L_tmp, handle->x0, b100[0]);
L_tmp = L_mac(L_tmp, handle->x1, b100[1]);
L_tmp = L_mac(L_tmp, x2, b100[2]);
L_tmp = L_shl(L_tmp, 2); /* Q29 --> Q31 (Q13 --> Q15) */
/* Multiplication by two of output speech with saturation. */
signal[i] = round(L_shl(L_tmp, 1));
handle->y2_hi = handle->y1_hi;
handle->y2_lo = handle->y1_lo;
L_Extract(L_tmp, &(handle->y1_hi), &(handle->y1_lo));
}
return;
}
示例9: Deemph
//==========================================================================
//函数功能:过滤要求的信号,为32位信号将信号一分为二
//函数参数:"x[]"表示输入信号的输出覆盖,既是输入参数又是输出参数;"mu"表示释
// 放因子,作为输入参数;"L"表示向量的大小,作为输入参数;"mem"表示存
// 储器的记忆
//==========================================================================
void Deemph(
Word16 x[], /* (i/o) : input signal overwritten by the output */
Word16 mu, /* (i) Q15 : deemphasis factor */
Word16 L, /* (i) : vector size */
Word16 * mem /* (i/o) : memory (y[-1]) */
)
{
Word32 i;
Word32 L_tmp;
L_tmp = L_deposit_h(x[0]);
L_tmp = L_mac(L_tmp, *mem, mu);
x[0] = vo_round(L_tmp);
for (i = 1; i < L; i++)
{
L_tmp = L_deposit_h(x[i]);
L_tmp = L_mac(L_tmp, x[i - 1], mu);
x[i] = voround(L_tmp);
}
*mem = x[L - 1];
return;
}
示例10: Calc_RCoeff
static void Calc_RCoeff(Word16 *Coeff, Word16 *RCoeff, Word16 *sh_RCoeff)
{
Word16 i, j;
Word16 sh1;
Word32 L_acc;
/* RCoeff[0] = SUM(j=0->M) Coeff[j] ** 2 */
L_acc = 0L;
for(j=0; j <= M; j++) {
L_acc = L_mac(L_acc, Coeff[j], Coeff[j]);
}
/* Compute exponent RCoeff */
sh1 = norm_l(L_acc);
L_acc = L_shl(L_acc, sh1);
RCoeff[0] = round(L_acc);
/* RCoeff[i] = SUM(j=0->M-i) Coeff[j] * Coeff[j+i] */
for(i=1; i<=M; i++) {
L_acc = 0L;
for(j=0; j<=M-i; j++) {
L_acc = L_mac(L_acc, Coeff[j], Coeff[j+i]);
}
L_acc = L_shl(L_acc, sh1);
RCoeff[i] = round(L_acc);
}
*sh_RCoeff = sh1;
return;
}
示例11: Pre_Process
void
Pre_Process (CodState *coder,
Word16 signal[], /* input/output signal */
Word16 lg)
{ /* length of signal */
Word16 i, x2;
Word32 L_tmp;
for (i = 0; i < lg; i++) {
x2 = coder->x1;
coder->x1 = coder->x0;
coder->x0 = signal[i];
/* y[i] = b[0]*x[i]/2 + b[1]*x[i-1]/2 + b140[2]*x[i-2]/2 */
/* + a[1]*y[i-1] + a[2] * y[i-2]; */
L_tmp = Mpy_32_16 (coder->y1_hi, coder->y1_lo, a140[1]);
L_tmp = L_add (L_tmp, Mpy_32_16 (coder->y2_hi, coder->y2_lo, a140[2]));
L_tmp = L_mac (L_tmp, coder->x0, b140[0]);
L_tmp = L_mac (L_tmp, coder->x1, b140[1]);
L_tmp = L_mac (L_tmp, x2, b140[2]);
L_tmp = L_shl (L_tmp, 3); /* Q28 --> Q31 (Q12 --> Q15) */
signal[i] = wround (L_tmp);
coder->y2_hi = coder->y1_hi;
coder->y2_lo = coder->y1_lo;
L_Extract (L_tmp, &coder->y1_hi, &coder->y1_lo);
}
return;
}
示例12: Deemph_32_
void Deemph_32_(
Word16 x_hi[], /* (i) : input signal (bit31..16) */
Word16 x_lo[], /* (i) : input signal (bit15..4) */
Word16 y[], /* (o) : output signal (x16) */
Word16 mu, /* (i) Q15 : deemphasis factor */
Word16 L, /* (i) : vector size */
Word16 * mem /* (i/o) : memory (y[-1]) */
)
{
Word16 i;
Word32 L_tmp;
/* L_tmp = hi<<16 + lo<<4 */
L_tmp = (Word32)x_hi[0] << 16;
L_tmp = L_tmp + ((Word32)x_lo[0] << 4);
L_tmp = L_shl(L_tmp, 4);
L_tmp = L_mac(L_tmp, *mem, mu); /* saturation can occur here */
y[0] = round16(L_tmp);
for (i = 1; i < L; i++)
{
L_tmp = (Word32)x_hi[i] << 16;
L_tmp = L_tmp + ((Word32)x_lo[i] << 4);
L_tmp = L_shl(L_tmp, 4);
L_tmp = L_mac(L_tmp, y[i - 1], mu); /* saturation can occur here */
y[i] = round16(L_tmp);
}
*mem = y[L - 1];
return;
}
示例13: Autocorr
/*-----------------------------------------------------*
* Function Autocorr() *
* *
* Compute autocorrelations of signal with windowing *
* *
*-----------------------------------------------------*/
void Autocorr(
Word16 x[], /* (i) : Input signal */
Word16 m, /* (i) : LPC order */
Word16 r_h[], /* (o) : Autocorrelations (msb) */
Word16 r_l[] /* (o) : Autocorrelations (lsb) */
)
{
Word16 i, j, norm;
Word16 y[L_WINDOW];
Word32 sum;
extern Flag Overflow;
/* Windowing of signal */
for(i=0; i<L_WINDOW; i++)
{
y[i] = mult_r(x[i], hamwindow[i]);
}
/* Compute r[0] and test for overflow */
do {
Overflow = 0;
sum = 1; /* Avoid case of all zeros */
for(i=0; i<L_WINDOW; i++)
sum = L_mac(sum, y[i], y[i]);
/* If overflow divide y[] by 4 */
if(Overflow != 0)
{
for(i=0; i<L_WINDOW; i++)
{
y[i] = shr(y[i], 2);
}
}
}while (Overflow != 0);
/* Normalization of r[0] */
norm = norm_l(sum);
sum = L_shl(sum, norm);
L_Extract(sum, &r_h[0], &r_l[0]); /* Put in DPF format (see oper_32b) */
/* r[1] to r[m] */
for (i = 1; i <= m; i++)
{
sum = 0;
for(j=0; j<L_WINDOW-i; j++)
sum = L_mac(sum, y[j], y[j+i]);
sum = L_shl(sum, norm);
L_Extract(sum, &r_h[i], &r_l[i]);
}
return;
}
示例14: Lag_max
static Word16 Lag_max( /* output: lag found */
Word16 signal[], /* input : signal used to compute the open loop pitch */
Word16 L_frame, /* input : length of frame to compute pitch */
Word16 lag_max, /* input : maximum lag */
Word16 lag_min, /* input : minimum lag */
Word16 *cor_max) /* output: normalized correlation of selected lag */
{
Word16 i, j;
Word16 *p, *p1;
Word32 max, t0, L_temp;
Word16 max_h, max_l, ener_h, ener_l;
Word16 p_max;
max = MIN_32;
/* initialization used only to suppress Microsoft Visual C++ warnings */
p_max = lag_max;
for (i = lag_max; i >= lag_min; i--)
{
p = signal;
p1 = &signal[-i];
t0 = 0;
for (j=0; j<L_frame; j++, p++, p1++)
t0 = L_mac(t0, *p, *p1);
L_temp = L_sub(t0,max);
if (L_temp >= 0L)
{
max = t0;
p_max = i;
}
}
/* compute energy */
t0 = 0;
p = &signal[-p_max];
for(i=0; i<L_frame; i++, p++)
t0 = L_mac(t0, *p, *p);
/* 1/sqrt(energy), result in Q30 */
t0 = Inv_sqrt(t0);
/* max = max/sqrt(energy) */
/* This result will always be on 16 bits !! */
L_Extract(max, &max_h, &max_l);
L_Extract(t0, &ener_h, &ener_l);
t0 = Mpy_32(max_h, max_l, ener_h, ener_l);
*cor_max = extract_l(t0);
return(p_max);
}
示例15: Corr_xy2
void Corr_xy2(
Word16 xn[], /* (i) Q0 :Target vector. */
Word16 y1[], /* (i) Q0 :Adaptive codebook. */
Word16 y2[], /* (i) Q12 :Filtered innovative vector. */
Word16 g_coeff[], /* (o) Q[exp]:Correlations between xn,y1,y2 */
Word16 exp_g_coeff[] /* (o) :Q-format of g_coeff[] */
)
{
Word16 i,exp;
Word16 exp_y2y2,exp_xny2,exp_y1y2;
Word16 y2y2, xny2, y1y2;
Word32 L_acc;
Word16 scaled_y2[L_SUBFR]; /* Q9 */
/*------------------------------------------------------------------*
* Scale down y2[] from Q12 to Q9 to avoid overflow *
*------------------------------------------------------------------*/
for(i=0; i<L_SUBFR; i++) {
scaled_y2[i] = shr(y2[i], 3); }
/* Compute scalar product <y2[],y2[]> */
L_acc = 1; /* Avoid case of all zeros */
for(i=0; i<L_SUBFR; i++)
L_acc = L_mac(L_acc, scaled_y2[i], scaled_y2[i]); /* L_acc:Q19 */
exp = norm_l(L_acc);
y2y2 = round( L_shl(L_acc, exp) );
exp_y2y2 = add(exp, 19-16); /* Q[19+exp-16] */
g_coeff[2] = y2y2;
exp_g_coeff[2] = exp_y2y2;
/* Compute scalar product <xn[],y2[]> */
L_acc = 1; /* Avoid case of all zeros */
for(i=0; i<L_SUBFR; i++)
L_acc = L_mac(L_acc, xn[i], scaled_y2[i]); /* L_acc:Q10 */
exp = norm_l(L_acc);
xny2 = round( L_shl(L_acc, exp) );
exp_xny2 = add(exp, 10-16); /* Q[10+exp-16] */
g_coeff[3] = negate(xny2);
exp_g_coeff[3] = sub(exp_xny2,1); /* -2<xn,y2> */
/* Compute scalar product <y1[],y2[]> */
L_acc = 1; /* Avoid case of all zeros */
for(i=0; i<L_SUBFR; i++)
L_acc = L_mac(L_acc, y1[i], scaled_y2[i]); /* L_acc:Q10 */
exp = norm_l(L_acc);
y1y2 = round( L_shl(L_acc, exp) );
exp_y1y2 = add(exp, 10-16); /* Q[10+exp-16] */
g_coeff[4] = y1y2;
exp_g_coeff[4] = sub(exp_y1y2,1); ; /* 2<y1,y2> */
return;
}