@ -93,7 +93,8 @@ static void lpc_compute_autocorr_c(const double *data, int len, int lag,
* Quantize LPC coefficients
* Quantize LPC coefficients
*/
*/
static void quantize_lpc_coefs ( double * lpc_in , int order , int precision ,
static void quantize_lpc_coefs ( double * lpc_in , int order , int precision ,
int32_t * lpc_out , int * shift , int max_shift , int zero_shift )
int32_t * lpc_out , int * shift , int min_shift ,
int max_shift , int zero_shift )
{
{
int i ;
int i ;
double cmax , error ;
double cmax , error ;
@ -118,7 +119,7 @@ static void quantize_lpc_coefs(double *lpc_in, int order, int precision,
/* calculate level shift which scales max coeff to available bits */
/* calculate level shift which scales max coeff to available bits */
sh = max_shift ;
sh = max_shift ;
while ( ( cmax * ( 1 < < sh ) > qmax ) & & ( sh > 0 ) ) {
while ( ( cmax * ( 1 < < sh ) > qmax ) & & ( sh > min_shift ) ) {
sh - - ;
sh - - ;
}
}
@ -201,7 +202,7 @@ int ff_lpc_calc_coefs(LPCContext *s,
int max_order , int precision ,
int max_order , int precision ,
int32_t coefs [ ] [ MAX_LPC_ORDER ] , int * shift ,
int32_t coefs [ ] [ MAX_LPC_ORDER ] , int * shift ,
enum FFLPCType lpc_type , int lpc_passes ,
enum FFLPCType lpc_type , int lpc_passes ,
int omethod , int max_shift , int zero_shift )
int omethod , int min_shift , int m ax_shift , int zero_shift )
{
{
double autoc [ MAX_LPC_ORDER + 1 ] ;
double autoc [ MAX_LPC_ORDER + 1 ] ;
double ref [ MAX_LPC_ORDER ] = { 0 } ;
double ref [ MAX_LPC_ORDER ] = { 0 } ;
@ -284,10 +285,12 @@ int ff_lpc_calc_coefs(LPCContext *s,
if ( omethod = = ORDER_METHOD_EST ) {
if ( omethod = = ORDER_METHOD_EST ) {
opt_order = estimate_best_order ( ref , min_order , max_order ) ;
opt_order = estimate_best_order ( ref , min_order , max_order ) ;
i = opt_order - 1 ;
i = opt_order - 1 ;
quantize_lpc_coefs ( lpc [ i ] , i + 1 , precision , coefs [ i ] , & shift [ i ] , max_shift , zero_shift ) ;
quantize_lpc_coefs ( lpc [ i ] , i + 1 , precision , coefs [ i ] , & shift [ i ] ,
min_shift , max_shift , zero_shift ) ;
} else {
} else {
for ( i = min_order - 1 ; i < max_order ; i + + ) {
for ( i = min_order - 1 ; i < max_order ; i + + ) {
quantize_lpc_coefs ( lpc [ i ] , i + 1 , precision , coefs [ i ] , & shift [ i ] , max_shift , zero_shift ) ;
quantize_lpc_coefs ( lpc [ i ] , i + 1 , precision , coefs [ i ] , & shift [ i ] ,
min_shift , max_shift , zero_shift ) ;
}
}
}
}