📄 owng729.h
字号:
Ipp16s *pDst, int len, char *pMemUpdated, int HistLen);
IppStatus SynthesisFilter_G729_16s_update (const Ipp16s *pLPC, const Ipp16s *pSrc,
Ipp16s *pDst, int len, char *pMemUpdated, int hLen,
int update);
void SynthesisFilterOvf_G729_16s_I(const Ipp16s *pLPC, Ipp16s *pSrcDst,
int len, char *pMemUpdated, int HistLen);
void SynthesisFilterOvf_G729_16s (const Ipp16s *pLPC, const Ipp16s *pSrc,
Ipp16s *pDst, int len, char *pMemUpdated, int HistLen);
void SynthesisFilterInit_G729 (char *pMemUpdated);
void SynthesisFilterSize_G729 (int *pSize);
void CodewordImpConv_G729(int index, const short *pSrc1,const short *pSrc2,short *pDst);
void _ippsRCToLAR_G729_16s (const Ipp16s*pSrc, Ipp16s*pDst, int len);
void _ippsPWGammaFactor_G729_16s (const Ipp16s*pLAR, const Ipp16s*pLSF,
Ipp16s *flat, Ipp16s*pGamma1, Ipp16s*pGamma2, Ipp16s *pMem );
void CNG_encoder(short *exc, short *prevSubfrLSPquant, short *Aq, short *ana, G729Encoder_Obj *encoderObj);
void CNG_Update(short *pSrc, short val, short vad, G729Encoder_Obj *encoderObj);
void Post_G729(short idx, short id, const short *LPC, short *pDst, short *voiceFlag, G729Decoder_Obj *decoderObj);
void Post_G729AB(short idx, short id, const short *LPC, short *pDst, short vad, G729Decoder_Obj *decoderObj);
void Post_G729I(short idx, short id, const short *LPC, short *pDst, short *val, short val1, short val2,
short fType, G729Decoder_Obj *decoderObj);
void Post_G729Base(short idx, short id, const short *LPC, short *pDst, short *voiceFlag, short ftyp, G729Decoder_Obj *decoderObj);
void updateExcErr_G729(short x, int y, int *err);
short calcErr_G729(int val, int *pSrc);
void BWDLagWindow(int *pSrc, int *pDst);
void SetLPCMode_G729E(short *signal_ptr, short *aFwd, short *pBwdLPC,
short *lpMode, short *lspnew, short *lspold,
G729Encoder_Obj *encoderObj);
void PitchTracking_G729E(short *val1, short *val2, short *prevPitch,
short *pitchStat, short *pitchStatIntDelay, short *pitchStatFracDelay);
short enerDB(short *synth, short L);
void tstDominantBWDmode(short *BWDcounter2,short *FWDcounter2,short *highStat, short mode);
void Init_CNG_encoder(G729Encoder_Obj *encoderObj);
void Log2_G729(int val, short *pDst1, short *pDst2);
extern CONST short gammaFac1[2*(LPF_DIM+1)];
extern CONST short g729gammaFac1_pst[LPF_DIM+1];
extern CONST short g729gammaFac2_pst[LPF_DIM+1];
extern CONST short cngSeedOut[CNG_STACK_SIZE];
extern CONST short cngCache[CNG_STACK_SIZE][LP_SUBFRAME_DIM];
extern CONST short LUT1[CDBK1_DIM];
extern CONST short presetLSP[LPF_DIM];
extern CONST int cngInvSqrt[CNG_STACK_SIZE];
extern CONST short resetPrevLSP[LPF_DIM];
extern CONST short LUT2[CDBK2_DIM];
extern CONST short presetOldA[LPF_DIM+1];
extern CONST short areas[L_prevExcitat-1+3];
extern CONST short SIDgain[32];
extern CONST short NormTG729i[256];
extern CONST short NormTG729i2[256];
__INLINE short Rand_16s(short *seed){
*seed = *seed *31821 + 13849;
return(*seed);
}
__INLINE short ShiftR_NR_16s(short n, unsigned short x) {
short const1 = (x==0)? 0: (1<<(x-1));
return(n+const1)>>x;
}
__INLINE short ShiftL_16s(short x, unsigned short n)
{
int max = IPP_MAX_16S >> n;
int min = IPP_MIN_16S >> n;
if(x > max) return IPP_MAX_16S;
else if(x < min) return IPP_MIN_16S;
return (short)(x<<n);
}
__INLINE int ShiftL_32s(int x, unsigned short n)
{
int max = IPP_MAX_32S >> n;
int min = IPP_MIN_32S >> n;
if(x > max) return IPP_MAX_32S;
else if(x < min) return IPP_MIN_32S;
return (x<<n);
}
__INLINE int ownSqrt_32s(int val) {
int i, j;
short n1=0,n2=BWF_HARMONIC;
for( i = 0 ; i < 14 ; i ++ ) {
j = (n1 + n2);
j *=j;
if( val >= j )
n1 += n2 ;
n2 >>= 1 ;
}
return n1;
}
__INLINE short Cnvrt_32s16s(int val) {
if(IPP_MAX_16S < val)
return IPP_MAX_16S;
else
if(IPP_MIN_16S > val)
return IPP_MIN_16S;
return(short)(val);
}
__INLINE int Cnvrt_64s32s(__INT64 val) {
if(IPP_MAX_32S < val)
return IPP_MAX_32S;
else
if(IPP_MIN_32S > val)
return IPP_MIN_32S;
return(int)val;
}
__INLINE short Abs_16s(short val) {
if(val<0) {
if(IPP_MIN_16S == val)
return IPP_MAX_16S;
val = -val;
}
return val;
}
__INLINE int Sub_32s(int val1,int val2) {
return Cnvrt_64s32s((__INT64)val1 - val2);
}
__INLINE short Sub_16s(int val1,int val2) {
int tmp = val1 - val2;
if(tmp>IPP_MAX_16S)
return IPP_MAX_16S;
else
if(tmp<IPP_MIN_16S)
return IPP_MIN_16S;
return tmp;
}
__INLINE short Add_16s(short val1, short val2) {
int tmp = val1 + val2;
if(tmp>IPP_MAX_16S)
return IPP_MAX_16S;
else
if(tmp<IPP_MIN_16S)
return IPP_MIN_16S;
return tmp;
}
__INLINE int Add_32s(int val1,int val2) {
Ipp64s tmp = (Ipp64s)val1 + val2;
if(tmp>IPP_MAX_32S)
return IPP_MAX_32S;
else
if(tmp<IPP_MIN_32S)
return IPP_MIN_32S;
return(int)tmp;
}
__INLINE int Round_32s(int val) {
int tmp = Add_32s(val,0x8000);
return(tmp >> 16);
}
__INLINE short Exp_16s_Pos(unsigned short x)
{
if((x>>8)==0)
return NormTG729i2[x];
else {
return NormTG729i[(x>>8)];
}
}
__INLINE short Exp_32s_Pos(unsigned int x){
if (x == 0) return 0;
if((x>>16)==0) return (16+Exp_16s_Pos((unsigned short) x));
return Exp_16s_Pos((unsigned short)(x>>16));
}
__INLINE short Norm_32s_I(int *x){
short i;
int y = *x;
if (y == 0) return 0;
if (y == -1) {*x =IPP_MIN_32S;return 31;}
if (y < 0) y = ~y;
i = Exp_32s_Pos(y);
*x <<= i;
return i;
}
__INLINE short Norm_32s16s(int x) {
short i;
int y = x;
if (y == 0) return 0;
if (y == -1) { return 31;}
if (y < 0) y = ~y;
i = Exp_32s_Pos(y);
return i;
}
__INLINE short Exp_16s(short val) {
short i;
if(val == 0)
return 0;
if((short)IPP_MAX_16U == val)
return 15;
if(val < 0)
val = ~val;
for(i = 0; val < (short)BWF_HARMONIC; i++)
val <<= 1;
return i;
}
__INLINE int Mul2_32s(int val) {
if(val > 0x3fffffff)
return IPP_MAX_32S;
else
if( val < 0xc0000000)
return IPP_MIN_32S;
return(val <<= 1);
}
__INLINE short Negate_16s(short val) {
if(IPP_MIN_16S == val)
return IPP_MAX_16S;
return(short)-val;
}
__INLINE int equality( int val) {
int temp, i, bit;
int sum;
sum = 1;
temp = val >> 1;
for(i = 0; i <6; i++) {
temp >>= 1;
bit = temp & 1;
sum += bit;
}
sum &= 1;
return sum;
}
static __ALIGN32 CONST short table0[8]={
1*1, 2*1, 0*1,
1*1, 2*1, 0*1,
1*1, 2*1};
__INLINE void DecodeAdaptCodebookDelays(short *prevFrameDelay, short *prevFrameDelay2,short *delay,
int id, int bad_pitch,int pitchIndx,G729Codec_Type type) {
short minPitchSearchDelay, maxPitchSearchDelay;
if(bad_pitch == 0) {
if(id == 0) { /*if 1-st subframe */
if(pitchIndx < 197) {
delay[0] = (pitchIndx+2)/3 + 19;
delay[1] = pitchIndx - delay[0] *3 + 58;
} else {
delay[0] = pitchIndx - 112;
delay[1] = 0;
}
} else {
/*find minPitchSearchDelay and maxPitchSearchDelay for 2-nd subframe */
minPitchSearchDelay = delay[0] - 5;
if(minPitchSearchDelay < MIN_PITCH_LAG)
minPitchSearchDelay = MIN_PITCH_LAG;
maxPitchSearchDelay = minPitchSearchDelay + 9;
if(maxPitchSearchDelay > MAX_PITCH_LAG) {
maxPitchSearchDelay = MAX_PITCH_LAG;
minPitchSearchDelay = MAX_PITCH_LAG - 9;
}
if(type == G729D_CODEC /* i.e. 6.4 kbps */) {
pitchIndx = pitchIndx & 15;
if(pitchIndx <= 3) {
delay[0] = minPitchSearchDelay + pitchIndx;
delay[1] = 0;
} else if(pitchIndx < 12) {
delay[1] = table0[pitchIndx - 4];
delay[0] = (pitchIndx - delay[1])/3 + 2 + minPitchSearchDelay;
if(delay[1] == 2) {
delay[1] = -1;
delay[0]++;
}
} else {
delay[0] = minPitchSearchDelay + pitchIndx - 6;
delay[1] = 0;
}
} else {
delay[0] = minPitchSearchDelay + (pitchIndx + 2)/3 - 1;
delay[1] = pitchIndx - 2 - 3 *((pitchIndx + 2)/3 - 1);
}
}
*prevFrameDelay = delay[0];
*prevFrameDelay2 = delay[1];
} else { /* non-equal or bad frame*/
delay[0] = *prevFrameDelay;
if(type == G729E_CODEC) {
delay[1] = *prevFrameDelay2;
} else {
delay[1] = 0;
*prevFrameDelay += 1;
if(*prevFrameDelay > MAX_PITCH_LAG) {
*prevFrameDelay = MAX_PITCH_LAG;
}
}
}
}
__INLINE short Mul_16s_Sfs(short x, short y, int scaleFactor) {
return(x*y) >> scaleFactor;
}
__INLINE int Mul_32s(int val1,int val2) {
short tmpHigh,tmpLow,tmp2High,tmp2Low;
int tmp,tmp1,tmp2;
tmpHigh = val1 >> 15;
tmpLow = val1 & IPP_MAX_16S;
tmp2High = val2 >> 15;
tmp2Low = val2 & IPP_MAX_16S;
tmp1 = Mul_16s_Sfs(tmpHigh,tmp2Low,15);
tmp2 = Mul_16s_Sfs(tmpLow,tmp2High,15);
tmp = tmpHigh*tmp2High;
tmp += tmp1;
tmp += tmp2;
return(tmp<<1);
}
#endif /*__OWNCODEC_H__*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -