本文整理汇总了C++中L_shl函数的典型用法代码示例。如果您正苦于以下问题:C++ L_shl函数的具体用法?C++ L_shl怎么用?C++ L_shl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了L_shl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: get_pq_polynomials
void get_pq_polynomials(
Word32 *f, /* Q23 */
Word16 *lsp) /* Q15 */
{
Word16 i, n, hi, lo;
Word16 index, offset, coslsp, c;
Word32 a0;
f[0] = L_mult(2048, 2048); // 1.0 Q23
for(i = 1; i <= LPCO ; i++)
f[i]= 0;
for(n=1; n<=(LPCO>>1); n++) {
/* cosine mapping */
index = shr(lsp[2*n-2],9); // Q6
offset = lsp[2*n-2]&(Word16)0x01ff; // Q9
a0 = L_mult(sub(costable[index+1], costable[index]), offset); // Q10
coslsp = add(costable[index], intround(L_shl(a0, 6))); // Q15 cos((double)PI*lsp[2*n-2])
c = coslsp; // Q14 c = 2. * cos((double)PI*lsp[2*n-2])
for(i = 2*n; i >= 2; i--) {
L_Extract(f[i-1], &hi, &lo);
f[i] = L_add(f[i], f[i-2]); // Q23 f[i] += f[i-2]
a0 = Mpy_32_16(hi, lo, c); // Q22
f[i] = L_sub(f[i], L_shl(a0,1)); // Q23 f[i] += f[i-2] - c*f[i-1];
}
f[1] = L_msu(f[1], c, 256); // Q23 f[1] -= c;
}
return;
}
示例4: 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;
}
示例5: 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;
}
示例6: Get_wegt
void Get_wegt(
Word16 flsp[], /* (i) Q13 : M LSP parameters */
Word16 wegt[] /* (o) Q11->norm : M weighting coefficients */
)
{
Word16 i;
Word16 tmp;
Word32 L_acc;
Word16 sft;
Word16 buf[M]; /* in Q13 */
buf[0] = sub( flsp[1], (PI04+8192) ); /* 8192:1.0(Q13) */
for ( i = 1 ; i < M-1 ; i++ ) {
tmp = sub( flsp[i+1], flsp[i-1] );
buf[i] = sub( tmp, 8192 );
}
buf[M-1] = sub( (PI92-8192), flsp[M-2] );
/* */
for ( i = 0 ; i < M ; i++ ) {
if ( buf[i] > 0 ){
wegt[i] = 2048; /* 2048:1.0(Q11) */
}
else {
L_acc = L_mult( buf[i], buf[i] ); /* L_acc in Q27 */
tmp = extract_h( L_shl( L_acc, 2 ) ); /* tmp in Q13 */
L_acc = L_mult( tmp, CONST10 ); /* L_acc in Q25 */
tmp = extract_h( L_shl( L_acc, 2 ) ); /* tmp in Q11 */
wegt[i] = add( tmp, 2048 ); /* wegt in Q11 */
}
}
/* */
L_acc = L_mult( wegt[4], CONST12 ); /* L_acc in Q26 */
wegt[4] = extract_h( L_shl( L_acc, 1 ) ); /* wegt in Q11 */
L_acc = L_mult( wegt[5], CONST12 ); /* L_acc in Q26 */
wegt[5] = extract_h( L_shl( L_acc, 1 ) ); /* wegt in Q11 */
/* wegt: Q11 -> normalized */
tmp = 0;
for ( i = 0; i < M; i++ ) {
if ( sub(wegt[i], tmp) > 0 ) {
tmp = wegt[i];
}
}
sft = norm_s(tmp);
for ( i = 0; i < M; i++ ) {
wegt[i] = shl(wegt[i], sft); /* wegt in Q(11+sft) */
}
return;
}
示例7: 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;
}
示例8: 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;
}
示例9: set_sign
/*-------------------------------------------------------------------*
* Function set_sign() *
* ~~~~~~~~~~~~~~~~~~~~ *
* Set the sign of each pulse position. *
*-------------------------------------------------------------------*/
static void set_sign(
Word16 fac_cn, /* (i) Q15: residual weight for sign determination */
Word16 cn[], /* (i) Q0 : residual after long term prediction */
Word16 dn[], /* (i) Q0 : correlation between target and h[] */
Word16 sign[], /* (o) Q15: sign vector (sign of each position) */
Word16 inv_sign[], /* (o) Q15: inverse of sign[] */
Word16 pos_max[], /* (o) : pos of max of correlation */
Word32 corr[] /* (o) : correlation of each track */
)
{
Word16 i, k, pos, k_cn, k_dn, val;
Word32 s, max;
/* calculate energy for normalization of cn[] and dn[] */
s = 0;
for (i=0; i<L_SUBFR; i++) s = L_mac(s, cn[i], cn[i]);
if (s < 512) s = 512;
s = Inv_sqrt(s);
k_cn = extract_h(L_shl(s, 5)); /* k_cn = 11..23170 */
k_cn = mult(k_cn, fac_cn);
s = 0;
for (i=0; i<L_SUBFR; i++) s = L_mac(s, dn[i], dn[i]);
if (s < 512) s = 512;
s = Inv_sqrt(s);
k_dn = extract_h(L_shl(s, 5)); /* k_dn = 11..23170 */
/* set sign according to en[] = k_cn*cn[] + k_dn*dn[] */
/* find position of maximum of correlation in each track */
for (k=0; k<NB_TRACK; k++) {
max = -1;
for (i=k; i<L_SUBFR; i+=STEP) {
val = dn[i];
s = L_mac(L_mult(k_cn, cn[i]), k_dn, val);
if (s >= 0) {
sign[i] = 32767L; /* sign = +1 (Q15) */
inv_sign[i] = -32768L;
}
else {
sign[i] = -32768L; /* sign = -1 (Q15) */
inv_sign[i] = 32767L;
val = negate(val);
}
dn[i] = val; /* modify dn[] according to the fixed sign */
s = L_abs(s);
if (s > max) {
max = s;
pos = i;
}
}
pos_max[k] = pos;
corr[k] = max;
}
return;
}
示例10: update_exc_err
void update_exc_err(
Word32 *L_exc_err,
Word16 gain_pit, /* (i) pitch gain */
Word16 T0 /* (i) integer part of pitch delay */
)
{
Word16 i, zone1, zone2, n;
Word32 L_worst, L_temp, L_acc;
Word16 hi, lo;
L_worst = -1L;
n = sub(T0, L_SUBFR);
if(n < 0) {
L_Extract(L_exc_err[0], &hi, &lo);
L_temp = Mpy_32_16(hi, lo, gain_pit);
L_temp = L_shl(L_temp, 1);
L_temp = L_add(0x00004000L, L_temp);
L_acc = L_sub(L_temp, L_worst);
if(L_acc > 0L) {
L_worst = L_temp;
}
L_Extract(L_temp, &hi, &lo);
L_temp = Mpy_32_16(hi, lo, gain_pit);
L_temp = L_shl(L_temp, 1);
L_temp = L_add(0x00004000L, L_temp);
L_acc = L_sub(L_temp, L_worst);
if(L_acc > 0L) {
L_worst = L_temp;
}
}
else {
zone1 = tab_zone[n];
i = sub(T0, 1);
zone2 = tab_zone[i];
for(i = zone1; i <= zone2; i++) {
L_Extract(L_exc_err[i], &hi, &lo);
L_temp = Mpy_32_16(hi, lo, gain_pit);
L_temp = L_shl(L_temp, 1);
L_temp = L_add(0x00004000L, L_temp);
L_acc = L_sub(L_temp, L_worst);
if(L_acc > 0L) L_worst = L_temp;
}
}
for(i=3; i>=1; i--) {
L_exc_err[i] = L_exc_err[i-1];
}
L_exc_err[0] = L_worst;
return;
}
示例11: Qua_Sidgain
/*-------------------------------------------------------------------*
* Function Qua_Sidgain *
* ~~~~~~~~~~~ *
*-------------------------------------------------------------------*/
void Qua_Sidgain(
Word16 *ener, /* (i) array of energies */
Word16 *sh_ener, /* (i) corresponding scaling factors */
Word16 nb_ener, /* (i) number of energies or */
Word16 *enerq, /* (o) decoded energies in dB */
Word16 *idx /* (o) SID gain quantization index */
)
{
Word16 i;
Word32 L_x;
Word16 sh1, temp;
Word16 hi, lo;
Word32 L_acc;
if(nb_ener == 0) {
/* Quantize energy saved for frame erasure case */
/* L_x = average_ener */
L_acc = L_deposit_l(*ener);
L_acc = L_shl(L_acc, *sh_ener); /* >> if *sh_ener < 0 */
L_Extract(L_acc, &hi, &lo);
L_x = Mpy_32_16(hi, lo, fact[0]);
sh1 = 0;
}
else {
/*
* Compute weighted average of energies
* ener[i] = enerR[i] x 2**sh_ener[i]
* L_x = k[nb_ener] x SUM(i=0->nb_ener-1) enerR[i]
* with k[nb_ener] = fact_ener / nb_ener x L_FRAME x nbAcf
*/
sh1 = sh_ener[0];
for(i=1; i<nb_ener; i++) {
if(sh_ener[i] < sh1) sh1 = sh_ener[i];
}
sh1 = add(sh1, (16-marg[nb_ener]));
L_x = 0L;
for(i=0; i<nb_ener; i++) {
temp = sub(sh1, sh_ener[i]);
L_acc = L_deposit_l(ener[i]);
L_acc = L_shl(L_acc, temp);
L_x = L_add(L_x, L_acc);
}
L_Extract(L_x, &hi, &lo);
L_x = Mpy_32_16(hi, lo, fact[i]);
}
*idx = Quant_Energy(L_x, sh1, enerq);
return;
}
示例12: Post_Process
void Post_Process(
Word16 signal[], /* input/output signal */
Word16 lg) /* length of signal */
{
Word16 i, x2;
Word32 L_tmp;
Word16 y2_hi, y2_lo, y1_hi, y1_lo, x0, x1;
y2_hi = pg729dec->ppost_pro->y2_hi;
y2_lo = pg729dec->ppost_pro->y2_lo;
y1_hi = pg729dec->ppost_pro->y1_hi;
y1_lo = pg729dec->ppost_pro->y1_lo;
x0 = pg729dec->ppost_pro->x0;
x1 = pg729dec->ppost_pro->x1;
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);
}
pg729dec->ppost_pro->y2_hi = y2_hi;
pg729dec->ppost_pro->y2_lo = y2_lo;
pg729dec->ppost_pro->y1_hi = y1_hi;
pg729dec->ppost_pro->y1_lo = y1_lo;
pg729dec->ppost_pro->x0 = x0;
pg729dec->ppost_pro->x1 = x1;
return;
}
示例13: rmlt_coefs_to_samples
void rmlt_coefs_to_samples(int16_t coefs[],
int16_t old_samples[],
int16_t out_samples[],
int dct_length,
int16_t mag_shift)
{
int i;
int half_dct_length;
int last;
int16_t new_samples[MAX_DCT_LENGTH];
const int16_t *win;
int32_t sum;
half_dct_length = dct_length >> 1;
/* Perform a Type IV (inverse) DCT on the coefficients */
dct_type_iv_s(coefs, new_samples, dct_length);
if (mag_shift > 0)
{
for (i = 0; i < dct_length; i++)
new_samples[i] = shr(new_samples[i], mag_shift);
}
else if (mag_shift < 0)
{
mag_shift = negate(mag_shift);
for (i = 0; i < dct_length; i++)
new_samples[i] = shl(new_samples[i], mag_shift);
}
win = (dct_length == DCT_LENGTH) ? rmlt_to_samples_window : max_rmlt_to_samples_window;
last = half_dct_length - 1;
for (i = 0; i < half_dct_length; i++)
{
/* Get the first half of the windowed samples */
sum = L_mult(win[i], new_samples[last - i]);
sum = L_mac(sum, win[dct_length - i - 1], old_samples[i]);
out_samples[i] = xround(L_shl(sum, 2));
/* Get the second half of the windowed samples */
sum = L_mult(win[half_dct_length + i], new_samples[i]);
sum = L_mac(sum, negate(win[last - i]), old_samples[last - i]);
out_samples[half_dct_length + i] = xround(L_shl(sum, 2));
}
/* Save the second half of the new samples for
next time, when they will be the old samples. */
vec_copyi16(old_samples, &new_samples[half_dct_length], half_dct_length);
}
示例14: Div_32
Word32 Div_32(Word32 L_num, Word16 denom_hi, Word16 denom_lo)
{
Word16 approx, hi, lo, n_hi, n_lo;
Word32 L_32;
/* First approximation: 1 / L_denom = 1/denom_hi */
approx = div_s( (Word16)0x3fff, denom_hi); /* result in Q14 */
/* Note: 3fff = 0.5 in Q15 */
/* 1/L_denom = approx * (2.0 - L_denom * approx) */
L_32 = Mpy_32_16(denom_hi, denom_lo, approx); /* result in Q30 */
L_32 = L_sub( (Word32)0x7fffffffL, L_32); /* result in Q30 */
L_Extract(L_32, &hi, &lo);
L_32 = Mpy_32_16(hi, lo, approx); /* = 1/L_denom in Q29 */
/* L_num * (1/L_denom) */
L_Extract(L_32, &hi, &lo);
L_Extract(L_num, &n_hi, &n_lo);
L_32 = Mpy_32(n_hi, n_lo, hi, lo); /* result in Q29 */
L_32 = L_shl(L_32, 2); /* From Q29 to Q31 */
return( L_32 );
}
示例15: 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;
}