/* Copyright (c) 2009-2010 Xiph.Org Foundation
Written by Jean-Marc Valin */ /* Redistributionanduseinsourceandbinaryforms,withorwithout modification,arepermittedprovidedthatthefollowingconditions aremet:
OPUS_CLEAR(lpc, p); #ifdef FIXED_POINT if (ac[0] != 0) #else if (ac[0] > 1e-10f) #endif
{ for (i = 0; i < p; i++) { /* Sum up this iteration's reflection coefficient */
opus_val32 rr = 0; #ifdefined (FIXED_POINT) && OPUS_FAST_INT64
opus_int64 acc = 0; for (j = 0; j < i; j++)
acc += (opus_int64)(lpc[j]) * (opus_int64)(ac[i - j]);
rr = (opus_val32)SHR64(acc, 31); #else for (j = 0; j < i; j++)
rr += MULT32_32_Q31(lpc[j],ac[i - j]); #endif
rr += SHR32(ac[i + 1],6);
r = -frac_div32(SHL32(rr,6), error); /* Update LPC coefficients and total error */
lpc[i] = SHR32(r,6); for (j = 0; j < (i+1)>>1; j++)
{
opus_val32 tmp1, tmp2;
tmp1 = lpc[j];
tmp2 = lpc[i-1-j];
lpc[j] = tmp1 + MULT32_32_Q31(r,tmp2);
lpc[i-1-j] = tmp2 + MULT32_32_Q31(r,tmp1);
}
error = error - MULT32_32_Q31(MULT32_32_Q31(r,r),error); /* Bail out once we get 30 dB gain */ #ifdef FIXED_POINT if (error<=SHR32(ac[0],10)) break; #else if (error<=.001f*ac[0]) break; #endif
}
} #ifdef FIXED_POINT
{ /* Convert the int32 lpcs to int16 and ensure there are no wrap-arounds. Thisreusesthelogicinsilk_LPC_fit()andsilk_bwexpander_32().Anybug
fixes should also be applied there. */ int iter, idx = 0;
opus_val32 maxabs, absval, chirp_Q16, chirp_minus_one_Q16;
for (iter = 0; iter < 10; iter++) {
maxabs = 0; for (i = 0; i < p; i++) {
absval = ABS32(lpc[i]); if (absval > maxabs) {
maxabs = absval;
idx = i;
}
}
maxabs = PSHR32(maxabs, 13); /* Q25->Q12 */
/* Apply bandwidth expansion. */ for (i = 0; i < p - 1; i++) {
lpc[i] = MULT32_32_Q16(chirp_Q16, lpc[i]);
chirp_Q16 += PSHR32(MULT32_32_32(chirp_Q16, chirp_minus_one_Q16), 16);
}
lpc[p - 1] = MULT32_32_Q16(chirp_Q16, lpc[p - 1]);
} else { break;
}
}
if (iter == 10) { /* If the coeffs still do not fit into the 16 bit range after 10 iterations,
fall back to the A(z)=1 filter. */
OPUS_CLEAR(lpc, p);
_lpc[0] = 4096; /* Q12 */
} else { for (i = 0; i < p; i++) {
_lpc[i] = EXTRACT16(PSHR32(lpc[i], 13)); /* Q25->Q12 */
}
}
} #endif
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.