[an error occurred while processing this directive]
|
|
Операции:
L_deposit_h : out = in shl 16;
L_shr: out = in shr n; арифм.
L_shl: out = in shl n; арифм. + огр. по переполн.
L_mac, L_msu : acc = acc +- a*b; fractional + огр. по переполн.
div_l : out = acc/in; fractional (|acc| меньше |in})
round : out = (in+0x8000) shr 16;
negate : out = -in; огр. по переполн.
L_abs : out = |in|; огр. по переполн.
L_mls : out = acc*in; fractional Q31*Q15 + огр. по переполн. вых. Q31
Word16 Durbin( Word16 *Lpc, Word16 *Corr, Word16 Err, Word16 *Pk2 )
{
int i,j ;Word16 Temp[LpcOrder] ;
Word16 Pk ;Word32 Acc0,Acc1,Acc2 ;
/*
* Initialize the LPC vector
*/
for ( i = 0 ; i < LpcOrder ; i ++ )
Lpc[i] = (Word16) 0 ;/*
* Do the recursion. At the ith step, the algorithm computes the
* (i+1)th - order MMSE linear prediction filter.
*/
for ( i = 0 ; i < LpcOrder ; i ++ ) {/*
* Compute the partial correlation (parcor) coefficient
*//* Start parcor computation */
Acc0 = L_deposit_h( Corr[i] ) ;
Acc0 = L_shr( Acc0, (Word16) 2 ) ;
for ( j = 0 ; j < i ; j ++ )
Acc0 = L_msu( Acc0, Lpc[j], Corr[i-j-1] ) ;
Acc0 = L_shl( Acc0, (Word16) 2 ) ;/* Save sign */
Acc1 = Acc0 ;
Acc0 = L_abs( Acc0 ) ;/* Finish parcor computation */
Acc2 = L_deposit_h( Err ) ;
if ( Acc0 >= Acc2 ) {
*Pk2 = 32767;
break ;
}Pk = div_l( Acc0, Err ) ;
if ( Acc1 >= 0 )
Pk = negate(Pk) ;/*
* Sine detector
*/
if ( i == 1 ) *Pk2 = Pk;/*
* Compute the ith LPC coefficient
*/
Acc0 = L_deposit_h( negate(Pk) ) ;
Acc0 = L_shr( Acc0, (Word16) 2 ) ;
Lpc[i] = round( Acc0 ) ;/*
* Update the prediction error
*/
Acc1 = L_mls( Acc1, Pk ) ;
Acc1 = L_add( Acc1, Acc2 ) ;
Err = round( Acc1 ) ;/*
* Compute the remaining LPC coefficients
*/
for ( j = 0 ; j < i ; j ++ )
Temp[j] = Lpc[j] ;for ( j = 0 ; j < i ; j ++ ) {
Acc0 = L_deposit_h( Lpc[j] ) ;
Acc0 = L_mac( Acc0, Pk, Temp[i-j-1] ) ;
Lpc[j] = round( Acc0 ) ;
}
}return Err ;
}
E-mail: info@telesys.ru