📄 decg729.c
字号:
} else { Ipp32s energy; ippsDotProd_16s32s_Sfs(ACELPcodeVec, ACELPcodeVec, LP_SUBFRAME_DIM, &energy, 0); /* ACELPcodeVec energy */ if(decoderObj->codecType == G729D_CODEC) { if(badFrameIndicator) { ippsDecodeGain_G729_16s(0, decoderObj->prevFrameQuantEn, NULL, decoderObj->gains); } else { LOCAL_ARRAY(Ipp16s, gIngx, 2, decoderObj); Ipp16s foo = 1; gIngx[0] = (Ipp16s)(pitchIndx >> CDBK2_BIT_NUM_6K) ; gIngx[1] = (Ipp16s)(pitchIndx & (CDBK2_DIM_6K-1)) ; ippsDecodeGain_G729I_16s(energy, foo, decoderObj->prevFrameQuantEn, gIngx, decoderObj->gains ); LOCAL_ARRAY_FREE(Ipp16s, gIngx, 2, decoderObj); } } else { /* G729E_CODEC*/ if(!badFrameIndicator) { LOCAL_ARRAY(Ipp16s, gIngx, 2, decoderObj); gIngx[0] = (Ipp16s)(pitchIndx >> CDBK2_BIT_NUM) ; gIngx[1] = (Ipp16s)(pitchIndx & (CDBK2_DIM-1)); ippsDecodeGain_G729_16s(energy, decoderObj->prevFrameQuantEn, gIngx, decoderObj->gains); LOCAL_ARRAY_FREE(Ipp16s, gIngx, 2, decoderObj); } else { /* erasure*/ Ipp16s oldCodebookGain = decoderObj->gains[1]; ippsDecodeGain_G729I_16s(0, decoderObj->valGainAttenuation, decoderObj->prevFrameQuantEn, NULL, decoderObj->gains ); if(decoderObj->BFIcount < 2) { decoderObj->gains[0] = (Ipp16s)((statStat)? BWF_HARMONIC : PITCH_GAIN_MAX); decoderObj->gains[1] = oldCodebookGain; } else { if(statStat) { if(decoderObj->BFIcount > 10) decoderObj->valGainAttenuation = (Ipp16s)((decoderObj->valGainAttenuation * 32604)>>15); } else decoderObj->valGainAttenuation = (Ipp16s)((decoderObj->valGainAttenuation * 32112)>>15); } } } } /* update pitch sharpening with quantized gain pitch */ decoderObj->betaPreFilter = decoderObj->gains[0]; if(decoderObj->betaPreFilter > PITCH_SHARP_MAX) decoderObj->betaPreFilter = PITCH_SHARP_MAX; if(decoderObj->betaPreFilter < PITCH_SHARP_MIN) decoderObj->betaPreFilter = PITCH_SHARP_MIN; /* synthesis of speech corresponding to excitation*/ if(badFrameIndicator) { decoderObj->BFIcount++; if(voiceFlag == 0 ) { gC = decoderObj->gains[1]; gPl = 0; } else { gC = 0; gPl = decoderObj->gains[0]; } } else { gC = decoderObj->gains[1]; gPl = decoderObj->gains[0]; } ippsInterpolateC_NR_G729_16s_Sfs(&excitation[subfrIdx],gPl,ACELPcodeVec,gC,&excitation[subfrIdx],LP_SUBFRAME_DIM,14); if(decoderObj->codecType == G729D_CODEC) status = SynthesisFilter_G729_16s_update(ppAz,&excitation[subfrIdx],&synth[subfrIdx],LP_SUBFRAME_DIM,synFltw,BWLPCF_DIM-mAq,0); else status = SynthesisFilter_G729_16s(ppAz,&excitation[subfrIdx],&synth[subfrIdx],LP_SUBFRAME_DIM,synFltw,BWLPCF_DIM-mAq); if(status == ippStsOverflow) { ippsRShiftC_16s_I(2,prevExcitat,L_prevExcitat+LP_FRAME_DIM); SynthesisFilterOvf_G729_16s(ppAz,&excitation[subfrIdx],&synth[subfrIdx],LP_SUBFRAME_DIM,synFltw,BWLPCF_DIM-mAq); } if(decoderObj->codecType == G729D_CODEC) { ippsPhaseDispersion_G729D_16s(&excitation[subfrIdx], phaseDispExcit, decoderObj->gains[1], decoderObj->gains[0], ACELPcodeVec, (IppsPhaseDispersion_State_G729D*)decoderObj->PhDispMem); SynthesisFilter_G729_16s(ppAz,phaseDispExcit,&synth[subfrIdx],LP_SUBFRAME_DIM,synFltw,BWLPCF_DIM-mAq); } else { ippsPhaseDispersionUpdate_G729D_16s(decoderObj->gains[0], decoderObj->gains[1], (IppsPhaseDispersion_State_G729D*)decoderObj->PhDispMem); } ppAz += mAq+1; } } if(badFrameIndicator == 0) { ippsDotProd_16s32s_Sfs(excitation,excitation,LP_FRAME_DIM,&i,-1); decoderObj->SIDflag1 = Exp_32s(i); decoderObj->SIDflag0 = (Ipp16s)(((i << decoderObj->SIDflag1)+0x8000)>>16); decoderObj->SIDflag1 = (Ipp16s)(16 - decoderObj->SIDflag1); } decoderObj->CNGvar = (Ipp16s)fType; if(enerDB(synth, (Ipp16s)LP_FRAME_DIM) >= BWF_HARMONIC_E) tstDominantBWDmode(&decoderObj->BWDcounter2,&decoderObj->FWDcounter2,&dominantBWDmode, (Ipp16s)LPmode); ippsMove_16s(&prevExcitat[LP_FRAME_DIM], &prevExcitat[0], L_prevExcitat); if( LPmode == 0) { ippsCopy_16s(FWDfiltLPC, AzDec, 2*LPF_DIM+2); prevM = LPF_DIM; } else { ippsCopy_16s(BWDfiltLPC, AzDec, 2*BWLPCF1_DIM); prevM = BWLPCF_DIM; } decoderObj->prevBFI = badFrameIndicator; decoderObj->prevLPmode = (Ipp16s)LPmode; decoderObj->prevVoiceFlag = voiceFlag; if(badFrameIndicator != 0) decoderObj->interpCoeff2 = (1<<12); else { if(LPmode == 0) decoderObj->interpCoeff2 = 0; else { if(dominantBWDmode == 1) decoderObj->interpCoeff2 -= 410; else decoderObj->interpCoeff2 -= 2048; if(decoderObj->interpCoeff2 < 0) decoderObj->interpCoeff2= 0; } } decoderObj->voiceFlag = 0; pAz = AzDec; if (decoderObj->pstFltMode) { if((decoderObj->codecType == G729_CODEC)&&(fType>2)) { for(subfrIdx=0; subfrIdx<LP_FRAME_DIM; subfrIdx+=LP_SUBFRAME_DIM) { Post_G729(prevFrameDelay1,(Ipp16s)subfrIdx,pAz,&dst[subfrIdx],&subfrVoiceFlag,decoderObj); if(subfrVoiceFlag != 0) { decoderObj->voiceFlag = subfrVoiceFlag; } pAz += LPF_DIM+1; } } else { parm = decoderObj->decPrm; if(fType<4) { L_hSt = IMP_RESP_LEN; decoderObj->gammaPost1 = BWF1_PST; decoderObj->gammaPost2 = BWF2_PST; decoderObj->gammaHarm = BWF_HARMONIC; } else { L_hSt = IMP_RESP_LEN_E; /* reduce postfiltering */ if((parm[2] == 1) && (dominantBWDmode == 1)) { decoderObj->gammaHarm -= 410; if(decoderObj->gammaHarm < 0) decoderObj->gammaHarm = 0; decoderObj->gammaPost1 -= 1147; if(decoderObj->gammaPost1 < 0) decoderObj->gammaPost1 = 0; decoderObj->gammaPost2 -= 1065; if(decoderObj->gammaPost2 < 0) decoderObj->gammaPost2 = 0; } else { decoderObj->gammaHarm += 410; if(decoderObj->gammaHarm > BWF_HARMONIC_E) decoderObj->gammaHarm = BWF_HARMONIC_E; decoderObj->gammaPost1 += 1147; if(decoderObj->gammaPost1 > BWF1_PST_E) decoderObj->gammaPost1 = BWF1_PST_E; decoderObj->gammaPost2 += 1065; if(decoderObj->gammaPost2 > BWF2_PST_E) decoderObj->gammaPost2 = BWF2_PST_E; } } for(i=0; i<LP_FRAME_DIM; i+=LP_SUBFRAME_DIM) { Post_G729I(prevFrameDelay1, (Ipp16s)i, pAz, &dst[i], &subfrVoiceFlag, L_hSt, prevM, (Ipp16s)fType, decoderObj); if(subfrVoiceFlag != 0) decoderObj->voiceFlag = subfrVoiceFlag; pAz += prevM+1; } } ippsHighPassFilter_G729_16s_ISfs(dst,LP_FRAME_DIM,13,decoderObj->postProc); } else { ippsAdd_16s(synth, synth, dst, LP_FRAME_DIM); } CLEAR_SCRATCH_MEMORY(decoderObj); return APIG729_StsNoErr;}void Post_G729Base( Ipp16s delayVal, /* pitch delayVal given by coder */ Ipp16s subfrIdx, const Ipp16s *srcLPC, /* LPC coefficients for current subframe */ Ipp16s *dstSignal, /* postfiltered output */ Ipp16s *voiceFlag, /* voiceFlag decision 0 = uv, > 0 delayVal */ Ipp16s fType, G729Decoder_Obj *decoderObj ) { Ipp16s bwf1 = decoderObj->gammaPost1; Ipp16s bwf2 = decoderObj->gammaPost2; Ipp16s gamma_harm = decoderObj->gammaHarm; LOCAL_ARRAY(Ipp32s,irACF,2, decoderObj); LOCAL_ALIGN_ARRAY(32, Ipp16s,y, IMP_RESP_LEN_E, decoderObj); LOCAL_ALIGN_ARRAY(32,Ipp16s, LTPsignal, LP_SUBFRAME_DIM+1, decoderObj); LOCAL_ALIGN_ARRAY(32,Ipp16s, LPCdenom, LPF_DIM+1, decoderObj); /* denominator srcLPC */ LOCAL_ALIGN_ARRAY(32,Ipp16s, LPCnum, IMP_RESP_LEN_E, decoderObj); /* numerator srcLPC */ Ipp16s tmp, g0Val, temp, ACFval0, ACFval1; Ipp16s *iirdl = ((SynthesisFilterState*)decoderObj->synFltw0)->buffer; Ipp32s L_g0Val, normVal = 0, status = 0; const Ipp16s *signal_ptr = &decoderObj->LTPostFilt[SYNTH_BWD_DIM+subfrIdx]; irACF[0] = irACF[1] = 0; ippsZero_16s(LPCnum, IMP_RESP_LEN_E); ippsMulPowerC_NR_16s_Sfs(srcLPC,bwf1, LPCdenom,LPF_DIM+1,15); ippsMulPowerC_NR_16s_Sfs(srcLPC,bwf2, LPCnum,LPF_DIM+1,15); ippsResidualFilter_G729_16s((Ipp16s *)signal_ptr, LPCnum, &decoderObj->resFilBuf1[RES_FIL_DIM]); if(fType > 1) ippsLongTermPostFilter_G729_16s(gamma_harm,delayVal, &decoderObj->resFilBuf1[RES_FIL_DIM], LTPsignal + 1, voiceFlag); else { *voiceFlag = 0; ippsCopy_16s(&decoderObj->resFilBuf1[RES_FIL_DIM], LTPsignal + 1, LP_SUBFRAME_DIM); } LTPsignal[0] = decoderObj->preemphFilt; ippsSynthesisFilter_NR_16s_Sfs(LPCdenom, LPCnum,y,IMP_RESP_LEN, 12, &decoderObj->zeroPostFiltVec1[LPF_DIM+1]); status = ippsAutoCorr_NormE_16s32s(y,IMP_RESP_LEN,irACF,2,&normVal); ACFval0 = (Ipp16s)(irACF[0]>>16); ACFval1 = (Ipp16s)(irACF[1]>>16); if( ACFval0 < Abs_16s(ACFval1) || status) { tmp = 0; } else { tmp = (Ipp16s)((Abs_16s(ACFval1)<<15)/ACFval0); if(ACFval1 > 0) { tmp = (Ipp16s)(-tmp); } } ippsAbs_16s_I(y,IMP_RESP_LEN); ippsSum_16s32s_Sfs(y,IMP_RESP_LEN,&L_g0Val,0); g0Val = (Ipp16s)(ShiftL_32s(L_g0Val, 14)>>16); if(g0Val > 1024) { temp = (Ipp16s)((1024<<15)/g0Val); ippsMulC_NR_16s_ISfs(temp,LTPsignal + 1,LP_SUBFRAME_DIM,15); } ippsSynthesisFilter_NR_16s_ISfs(LPCdenom, LTPsignal + 1, LP_SUBFRAME_DIM, 12, &iirdl[BWLPCF_DIM-LPF_DIM]); decoderObj->preemphFilt = LTPsignal[LP_SUBFRAME_DIM]; ippsCopy_16s(<Psignal[LP_SUBFRAME_DIM-LPF_DIM+1], &iirdl[BWLPCF_DIM-LPF_DIM], LPF_DIM ); ippsTiltCompensation_G729E_16s(tmp,LTPsignal, dstSignal); ippsGainControl_G729_16s_I(signal_ptr, dstSignal, &decoderObj->gainExact); ippsMove_16s(&decoderObj->resFilBuf1[LP_SUBFRAME_DIM], &decoderObj->resFilBuf1[0], RES_FIL_DIM); LOCAL_ALIGN_ARRAY_FREE(32,Ipp16s, LPCnum, IMP_RESP_LEN_E, decoderObj); /* numerator srcLPC */ LOCAL_ALIGN_ARRAY_FREE(32,Ipp16s, LPCdenom, LPF_DIM+1, decoderObj); /* denominator srcLPC */ LOCAL_ALIGN_ARRAY_FREE(32, Ipp16s, LTPsignal,LP_SUBFRAME_DIM+1,decoderObj); LOCAL_ALIGN_ARRAY_FREE(32, Ipp16s,y, IMP_RESP_LEN_E,decoderObj); LOCAL_ARRAY_FREE(Ipp32s, irACF, 2,decoderObj); return;}void Post_G729( Ipp16s delayVal, Ipp16s subfrIdx, const Ipp16s *srcLPC, Ipp16s *dstSignal, Ipp16s *voiceFlag, G729Decoder_Obj *decoderObj) { Ipp16s *gainExact = &decoderObj->gainExact; Ipp16s *iirdl = ((SynthesisFilterState*)decoderObj->synFltw0)->buffer; LOCAL_ALIGN_ARRAY(32, Ipp16s,y, IMP_RESP_LEN, decoderObj); LOCAL_ALIGN_ARRAY(32, Ipp16s, LTPsignalBuf, LP_SUBFRAME_DIM+1+LPF_DIM, decoderObj); LOCAL_ALIGN_ARRAY(32, Ipp16s, LPCnum, LPF_DIM+1, decoderObj); Ipp16s tmp; const Ipp16s *res = &decoderObj->LTPostFilt[SYNTH_BWD_DIM+subfrIdx]; Ipp16s *LTPsignal = LTPsignalBuf+LPF_DIM+1; ippsMul_NR_16s_Sfs(g729gammaFac2_pst,srcLPC, LPCnum,LPF_DIM+1,15); ippsResidualFilter_G729_16s(res, LPCnum, decoderObj->resFilBuf1 + RES_FIL_DIM); ippsLongTermPostFilter_G729_16s(BWF_HARMONIC,delayVal, decoderObj->resFilBuf1 + RES_FIL_DIM, LTPsignal+1, &tmp); *voiceFlag = (Ipp16s)(tmp != 0); ippsMove_16s(&decoderObj->resFilBuf1[LP_SUBFRAME_DIM], &decoderObj->resFilBuf1[0], RES_FIL_DIM); ippsCopy_16s(iirdl+20,LTPsignal+1-LPF_DIM, LPF_DIM ); ippsShortTermPostFilter_G729_16s(srcLPC, LTPsignal+1,LTPsignal+1,y); ippsCopy_16s((LTPsignal+1+LP_SUBFRAME_DIM-BWLPCF_DIM), iirdl, BWLPCF_DIM); LTPsignal[0] = decoderObj->preemphFilt; decoderObj->preemphFilt = LTPsignal[LP_SUBFRAME_DIM]; ippsTiltCompensation_G729_16s(y, LTPsignal+1); ippsCopy_16s(LTPsignal+1, dstSignal,LP_SUBFRAME_DIM); ippsGainControl_G729_16s_I(res, dstSignal, gainExact);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -