📄 owng729fp.h
字号:
}G729CCoder_Obj;
typedef struct _VADmemory{
float MeanLSFVec[LPC_ORDER];
float MinimumBuff[16];
float fMeanEnergy;
float fMeanFullBandEnergy;
float fMeanLowBandEnergy;
float fMeanZeroCrossing;
float fPrevMinEnergy;
float fNextMinEnergy;
float fMinEnergy;
float fPrevEnergy;
int lVADFlag;
int lSilenceCounter;
int lUpdateCounter;
int lSmoothingCounter;
int lFVD;
int lLessEnergyCounter;
}VADmemory;
#define SUMAUTOCORRS_NUM 3
#define SUMAUTOCORRS_SIZE (SUMAUTOCORRS_NUM * LPC_ORDERP1)
#define CURRAUTOCORRS_NUM 2
#define AUTOCORRS_SIZE (CURRAUTOCORRS_NUM * LPC_ORDERP1)
#define GAINS_NUM 2
extern CONST float InitLSP[LPC_ORDER];
extern CONST float InitFrequences[LPC_ORDER];
extern CONST float lagBwd[BWD_LPC_ORDER];
extern CONST float SIDGainTbl[32];
typedef struct _CNGmemory{
float AutoCorrs[AUTOCORRS_SIZE];
float SumAutoCorrs[SUMAUTOCORRS_SIZE];
float Energies[GAINS_NUM];
int lAutoCorrsCounter;
float fCurrGain;
int lFltChangeFlag;
float SIDQuantLSP[LPC_ORDER];
float ReflectCoeffs[LPC_ORDERP1];
int lNumSavedEnergies;
float fSIDGain;
float fPrevEnergy;
int lFrameCounter0;
}CNGmemory;
typedef struct _PSTmemory{
float STPNumCoeff[SHORTTERM_POSTFLT_LEN_E]; /* s.t. numerator coeff. */
float STPMemory[BWD_LPC_ORDER]; /* s.t. postfilter memory */
float ZeroMemory[BWD_LPC_ORDER]; /* null memory to compute h_st */
float ResidualMemory[SIZE_RESISDUAL_MEMORY]; /* A(gamma2) residual */
float gainPrec;
}PSTmemory;
typedef struct _MusDetectMemory{
int lMusicCounter;
float fMusicCounter;
int lZeroMusicCounter;
float fMeanPitchGain;
int lPFlagCounter;
float fMeanPFlagCounter;
int lConscPFlagCounter;
int lRCCounter;
float MeanRC[10];
float fMeanFullBandEnergy;
}MusDetectMemory;
typedef struct _PHDmemory{
int prevDispState;
float gainMem[6];
float prevCbGain;
int onset;
}PHDmemory;
struct _G729FPEncoder_Obj{
G729CCoder_Obj objPrm;
#if !defined (NO_SCRATCH_MEMORY_USED)
ScratchMem_Obj Mem;
#endif
float OldSpeechBuffer[SPEECH_BUFF_LEN];
float fBetaPreFilter;
float OldWeightedSpeechBuffer[FRM_LEN+PITCH_LAG_MAX];
float OldExcitationBuffer[FRM_LEN+PITCH_LAG_MAX+INTERPOL_LEN];
float WeightedFilterMemory[BWD_LPC_ORDER];
float FltMem[BWD_LPC_ORDER];
float OldLSP[LPC_ORDER];
float OldQuantLSP[LPC_ORDER];
float ExcitationError[4];
IppsIIRState_32f *iirstate;
float PastQuantEnergy[4];
float PrevFreq[MOVING_AVER_ORDER][LPC_ORDER]; /* previous LSP vector */
/* Last forkward A(z) for case of unstable filter */
float OldForwardLPC[LPC_ORDERP1];
float OldForwardRC[2];
short sFrameCounter; /* frame counter for VAD*/
/* DTX variables */
int prevVADDec;
int prevPrevVADDec;
short sCNGSeed;
char *vadMem;
char *cngMem;
char *msdMem;
/* G729CA_CODEC*/
float ZeroMemory[LPC_ORDER];
/* Not G.729A */
float SynFltMemory[BWD_LPC_ORDER];
float ErrFltMemory[BWD_LPC_ORDER+SUBFR_LEN];
float UnitImpulse[SUBFR_LEN+BWD_LPC_ORDERP1];
/* for G.729E */
/* for the backward analysis */
float PrevFlt[BWD_LPC_ORDERP1]; /* Previous selected filter */
float SynthBuffer[BWD_ANALISIS_WND_LEN];
int prevLPCMode;
float BackwardLPCMemory[BWD_LPC_ORDERP1];
int isBWDDominant;
float fInterpolationCoeff;
short sGlobalStatInd; /* Mesure of global stationnarity */
short sBWDStatInd; /* Num of consecutive backward frames */
short sValBWDStatInd; /* Value associated with stat_bwd */
/* Last backward A(z) for case of unstable filter */
float OldBackwardLPC[BWD_LPC_ORDERP1];
float OldBackwardRC[2];
int LagBuffer[5];
float PitchGainBuffer[5];
int sBWDFrmCounter;
int sFWDFrmCounter;
int isSmooth;
float LogAreaRatioCoeff[2];
int sSearchTimes;
IppsWinHybridState_G729E_32f *pHWState;
};
struct _G729FPDecoder_Obj{
G729CCoder_Obj objPrm;
#if !defined (NO_SCRATCH_MEMORY_USED)
ScratchMem_Obj Mem;
#endif
float OldExcitationBuffer[FRM_LEN+PITCH_LAG_MAX+INTERPOL_LEN];
float fBetaPreFilter; /* pitch sharpening of previous frame */
int prevPitchDelay; /* integer delay of previous frame */
float fCodeGain; /* Code gain */
float fPitchGain; /* Pitch gain */
float OldLSP[LPC_ORDER];
IppsIIRState_32f *iirstate;
float PastQuantEnergy[4];
float PrevFreq[MOVING_AVER_ORDER][LPC_ORDER]; /* previous LSP vector */
int prevMA; /* previous MA prediction coef.*/
float prevLSF[LPC_ORDER]; /* previous LSF vector */
/* for G.729B */
short sFESeed;
/* CNG variables */
int prevFrameType;
int prevSID[4];/*prev SID need for erased only*/
short sCNGSeed;
float SID;
float fCurrGain;
float SIDLSP[LPC_ORDER];
float fSIDGain;
float SynFltMemory[BWD_LPC_ORDER]; /* Synthesis filter's memory */
char *phdMem;
/* for G.729A */
float PstFltMemoryA[LPC_ORDER];
float fPastGain;
float ResidualBufferA[PITCH_LAG_MAX+SUBFR_LEN]; /* inverse filtered synthesis (with A(z/GAMMA2_POSTFLT)) */
float *ResidualMemory;
float PstSynMemoryA[LPC_ORDER]; /* memory of filter 1/A(z/GAMMA1_POSTFLT) */
float fPreemphMemoryA;
/* Not G.729A */
float SynthBuffer[BWD_ANALISIS_WND_LEN]; /* Synthesis */
int prevFracPitchDelay; /* integer delay of previous frame */
/* for the backward analysis */
float BackwardUnqLPC[BWD_LPC_ORDERP1];
float BackwardLPCMemory[BWD_LPC_ORDERP1];
int lPrevVoicing;
int lPrevBFI;
int prevLPCMode;
float fFEInterpolationCoeff;
float fInterpolationCoeff;
float PrevFlt[BWD_LPC_ORDERP1]; /* Previous selected filter */
int lPrevPitchPT;
int lStatPitchPT;
int lStatPitch2PT;
int lStatFracPT;
/* Last backward A(z) for case of unstable filter */
float OldBackwardLPC[BWD_LPC_ORDERP1];
float OldBackwardRC[2];
float fPitchGainMemory;
float fCodeGainMemory;
float fGainMuting;
int lBFICounter;
int sBWDStatInd;
int lVoicing; /* voicing from previous frame */
float g1PST;
float g2PST;
float gHarmPST;
int sBWDFrmCounter;
int sFWDFrmCounter;
char *pstMem;
IppsWinHybridState_G729E_32f *pHWState;
};
#define G729_CODECFUN(type,name,arg) extern type name arg
__INLINE int Parity( int val){
int temp, nBits, bit;
int sum;
temp = val >> 1;
sum = 1;
for (nBits = 0; nBits <= 5; nBits++) {
temp = temp >> 1;
bit = temp & 0x00000001;
sum += bit;
}
sum = sum & 0x00000001;
return sum;
}
__INLINE short Rand_16s(short *seed)
{
*seed = (short)(*seed * 31821 + 13849);
return(*seed);
}
static __ALIGN32 CONST short modtab[]={1, 2, 0, 1, 2, 0, 1, 2};
__INLINE void DecodeAdaptCodebookDelays(int *prevPitchDelay, int *prevFracPitchDelay,int *delayLine,
int NSbfr, int badPitch,int pitchIndx,G729Codec_Type type){
short minPitchDelay, maxPitchDelay;
if(badPitch == 0){
if (NSbfr == 0) /* if 1st subframe */
{
if (pitchIndx < 197)
{
delayLine[0] = (pitchIndx+2)/3 + 19;
delayLine[1] = pitchIndx - delayLine[0] * 3 + 58;
}
else
{
delayLine[0] = pitchIndx - 112;
delayLine[1] = 0;
}
} else {/* second subframe */
/* find minPitchDelay and maxPitchDelay for 2nd subframe */
minPitchDelay = (short)(delayLine[0] - 5);
CLIP_TO_LOWLEVEL(minPitchDelay,PITCH_LAG_MIN);
maxPitchDelay = (short)(minPitchDelay + 9);
if (maxPitchDelay > PITCH_LAG_MAX)
{
maxPitchDelay = PITCH_LAG_MAX;
minPitchDelay = (short)(maxPitchDelay - 9);
}
if (type == G729D_MODE) {
pitchIndx = pitchIndx & 15;
if (pitchIndx <= 3) {
delayLine[0] = minPitchDelay + pitchIndx;
delayLine[1] = 0;
}
else if (pitchIndx < 12) {
/* *T0_frac = index % 3; */
delayLine[1] = modtab[pitchIndx - 4];
delayLine[0] = (pitchIndx - delayLine[1])/3 + minPitchDelay + 2;
if (delayLine[1] == 2) {
delayLine[1] = -1;
delayLine[0] += 1;
}
}
else {
delayLine[0] = minPitchDelay + pitchIndx - 6;
delayLine[1] = 0;
}
}
else {
delayLine[0] = minPitchDelay + (pitchIndx + 2)/3 - 1;
delayLine[1] = pitchIndx - 2 - 3 * ((pitchIndx + 2)/3 - 1);
}
}
*prevPitchDelay = delayLine[0];
*prevFracPitchDelay = delayLine[1];
}else { /* Bad frame, or parity error */
delayLine[0] = *prevPitchDelay;
if (type == G729E_MODE) {
delayLine[1] = *prevFracPitchDelay;
}
else {
delayLine[1] = 0;
*prevPitchDelay += 1;
CLIP_TO_UPLEVEL(*prevPitchDelay,PITCH_LAG_MAX);
}
}
}
void CodewordImpConv_G729_32f(int index, const float *pSrc1,const float *pSrc2,float *pDst);
#endif /*__OWNCODEC_H__*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -