?? pitch_a.c
字號:
/*---------------------------------------------------------------------------*
* Pitch related functions *
* ~~~~~~~~~~~~~~~~~~~~~~~ *
*---------------------------------------------------------------------------*/
#include "typedef.h"
#include "basic_op.h"
#include "oper_32b.h"
#include "ld8a.h"
#include "tab_ld8a.h"
/*--------------------------------------------------------------------------*
* Function Pitch_fr3_fast() *
* ~~~~~~~~~~~~~~~~~~~~~~~~~~ *
* Fast version of the pitch close loop. *
*--------------------------------------------------------------------------*/
extern Word32 Dot_Product(Word16 x[],Word16 y[], Word16 lg);
Word16 Pitch_fr3_fast(/* (o) : pitch period. */
Word16 exc[], /* (i) : excitation buffer */
Word16 xn[], /* (i) : target vector */
Word16 h[], /* (i) Q12 : impulse response of filters. */
Word16 L_subfr, /* (i) : Length of subframe */
Word16 t0_min, /* (i) : minimum value in the searched range. */
Word16 t0_max, /* (i) : maximum value in the searched range. */
Word16 i_subfr, /* (i) : indicator for first subframe. */
Word16 *pit_frac /* (o) : chosen fraction. */
)
{
Word16 t, t0;
Word16 Dn[L_SUBFR];
Word16 exc_tmp[L_SUBFR];
Word32 max, corr, L_temp;
/*-----------------------------------------------------------------*
* Compute correlation of target vector with impulse response. *
*-----------------------------------------------------------------*/
Cor_h_X(h, xn, Dn);
/*-----------------------------------------------------------------*
* Find maximum integer delay. *
*-----------------------------------------------------------------*/
max = MIN_32;
t0 = t0_min; /* Only to remove warning from some compilers */
for(t=t0_min; t<=t0_max; t++)
{
corr = Dot_Product(Dn, &exc[-t], L_subfr);
L_temp = L_sub(corr, max);
if(L_temp > 0) {max = corr; t0 = t; }
}
/*-----------------------------------------------------------------*
* Test fractions. *
*-----------------------------------------------------------------*/
/* Fraction 0 */
Pred_lt_3(exc, t0, 0, L_subfr);
max = Dot_Product(Dn, exc, L_subfr);
*pit_frac = 0;
/* If first subframe and lag > 84 do not search fractional pitch */
if( (i_subfr == 0) && (sub(t0, 84) > 0) )
return t0;
Copy(exc, exc_tmp, L_subfr);
/* Fraction -1/3 */
Pred_lt_3(exc, t0, -1, L_subfr);
corr = Dot_Product(Dn, exc, L_subfr);
L_temp = L_sub(corr, max);
if(L_temp > 0) {
max = corr;
*pit_frac = -1;
Copy(exc, exc_tmp, L_subfr);
}
/* Fraction +1/3 */
Pred_lt_3(exc, t0, 1, L_subfr);
corr = Dot_Product(Dn, exc, L_subfr);
L_temp = L_sub(corr, max);
if(L_temp > 0) {
max = corr;
*pit_frac = 1;
}
else
Copy(exc_tmp, exc, L_subfr);
return t0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -