📄 decg729fp.c
字号:
} DecodeAdaptCodebookDelays(&decoderObj->prevPitchDelay, &decoderObj->prevFracPitchDelay,delayLine,NSbfr, badPitch,index,(G729Codec_Type)rate); PitchDelay = delayLine[0]; T2[nsubfr] = PitchDelay; /* adaptive codebook decode */ ippsDecodeAdaptiveVector_G729_32f_I(delayLine, &Excitation[NSbfr]); if(decoderObj->objPrm.codecType!=G729A_CODEC) { /* Pitch tracking*/ if( rate == G729E_MODE) { PitchTracking_G729FPE(&decoderObj->prevPitchDelay, &decoderObj->prevFracPitchDelay, &decoderObj->lPrevPitchPT, &decoderObj->lStatPitchPT, &decoderObj->lStatPitch2PT, &decoderObj->lStatFracPT); } else { i = decoderObj->prevPitchDelay; j = decoderObj->prevFracPitchDelay; PitchTracking_G729FPE(&i, &j, &decoderObj->lPrevPitchPT, &decoderObj->lStatPitchPT, &decoderObj->lStatPitch2PT, &decoderObj->lStatFracPT); } } /* Fixed codebook decode*/ ippsZero_32f(ACELPCodeVec,SUBFR_LEN); if (rate == G729_BASE) { /* case base mode or annex A*/ LOCAL_ARRAY(Ipp32s, Position, 4, decoderObj); Ipp32s lTmpIndex, sign; if(bfi != 0) /* Bad frame */ { lTmpIndex = (Ipp32s)Rand_16s(&decoderObj->sFESeed) & (Ipp16s)0x1fff; /* 13 bits random */ sign = (Ipp32s)Rand_16s(&decoderObj->sFESeed) & (Ipp16s)0x000f; /* 4 bits random */ }else{ lTmpIndex = pDecPrm[0]; sign = pDecPrm[1]; } /* First pulse's positions*/ Position[0] = (lTmpIndex&7)*5; /* Second pulse's positions*/ lTmpIndex >>= 3; Position[1] = (lTmpIndex&7)*5 + 1; /* Third pulse's positions*/ lTmpIndex >>= 3; Position[2] = (lTmpIndex&7)*5 + 2; /* Forth pulse's positions*/ lTmpIndex >>= 3; j = lTmpIndex; lTmpIndex >>= 1; Position[3] = (lTmpIndex&7)*5 + 3 + (j&1); /* Decode signs of 4 pulse and compose the algebraic codeword */ for (j=0; j<4; j++) { if (((sign>>j) & 1) != 0) { ACELPCodeVec[Position[j]] = 1.0; } else { ACELPCodeVec[Position[j]] = -1.0; } } pDecPrm += 2; /* for gain decoding in case of frame erasure */ decoderObj->sBWDStatInd = 0; highStatIndicator = 0; LOCAL_ARRAY_FREE(Ipp32s, Position, 4, decoderObj); } else if (rate == G729D_MODE) { /* case annex D*/ LOCAL_ARRAY(Ipp32s, Position, 2, decoderObj); Ipp32s lTmpIndex, sign; if(bfi != 0) /* Bad frame */ { lTmpIndex = (Ipp32s)Rand_16s(&decoderObj->sFESeed) & (Ipp16s)0x1fff; /* 13 bits random */ sign = (Ipp32s)Rand_16s(&decoderObj->sFESeed) & (Ipp16s)0x000f; /* 4 bits random */ }else{ lTmpIndex = pDecPrm[0]; sign = pDecPrm[1]; } /* decode the positions of 4 pulses */ i = lTmpIndex & 15; Position[0] = trackTbl0[i]; lTmpIndex >>= 4; i = lTmpIndex & 31; Position[1] = trackTbl1[i]; /* find the algebraic codeword */ /* decode the signs of 2 pulses */ for (j=0; j<2; j++) { if (((sign>>j) & 1) != 0) { ACELPCodeVec[Position[j]] += 1.0; } else { ACELPCodeVec[Position[j]] -= 1.0; } } pDecPrm += 2; /* for gain decoding in case of frame erasure */ decoderObj->sBWDStatInd = 0; highStatIndicator = 0; LOCAL_ARRAY_FREE(Ipp32s, Position, 2, decoderObj); } else if (rate == G729E_MODE) { /* case annex E*/ LOCAL_ARRAY(Ipp32s, tmp_parm, 5, decoderObj); if(bfi) { tmp_parm[0] = (Ipp32s)Rand_16s(&decoderObj->sFESeed); tmp_parm[1] = (Ipp32s)Rand_16s(&decoderObj->sFESeed); tmp_parm[2] = (Ipp32s)Rand_16s(&decoderObj->sFESeed); tmp_parm[3] = (Ipp32s)Rand_16s(&decoderObj->sFESeed); tmp_parm[4] = (Ipp32s)Rand_16s(&decoderObj->sFESeed); }else{ for(i=0;i<5;i++) tmp_parm[i] = pDecPrm[i]; } if (LPCMode == 0) { Ipp32s pos1, pos2; Ipp32f sign; /* decode the positions and signs of pulses and build the codeword */ pos1 = ((tmp_parm[0] & 7) * 5); if (((tmp_parm[0]>>3) & 1) == 0) sign = 1.; else sign = -1.; ACELPCodeVec[pos1] = sign; pos2 = (((tmp_parm[0]>>4) & 7) * 5); if (pos2 > pos1) sign = -sign; ACELPCodeVec[pos2] += sign; pos1 = ((tmp_parm[1] & 7) * 5) + 1; if (((tmp_parm[1]>>3) & 1) == 0) sign = 1.; else sign = -1.; ACELPCodeVec[pos1] = sign; pos2 = (((tmp_parm[1]>>4) & 7) * 5) + 1; if (pos2 > pos1) sign = -sign; ACELPCodeVec[pos2] += sign; pos1 = ((tmp_parm[2] & 7) * 5) + 2; if (((tmp_parm[2]>>3) & 1) == 0) sign = 1.; else sign = -1.; ACELPCodeVec[pos1] = sign; pos2 = (((tmp_parm[2]>>4) & 7) * 5) + 2; if (pos2 > pos1) sign = -sign; ACELPCodeVec[pos2] += sign; pos1 = ((tmp_parm[3] & 7) * 5) + 3; if (((tmp_parm[3]>>3) & 1) == 0) sign = 1.; else sign = -1.; ACELPCodeVec[pos1] = sign; pos2 = (((tmp_parm[3]>>4) & 7) * 5) + 3; if (pos2 > pos1) sign = -sign; ACELPCodeVec[pos2] += sign; pos1 = ((tmp_parm[4] & 7) * 5) + 4; if (((tmp_parm[4]>>3) & 1) == 0) sign = 1.; else sign = -1.; ACELPCodeVec[pos1] = sign; pos2 = (((tmp_parm[4]>>4) & 7) * 5) + 4; if (pos2 > pos1) sign = -sign; ACELPCodeVec[pos2] += sign; /* for gain decoding in case of frame erasure */ decoderObj->sBWDStatInd = 0; highStatIndicator = 0; } else { Ipp32s lIdxCounter, track, pos1, pos2, pos3; Ipp32f sign; /* decode the positions and signs of pulses and build the codeword */ track = (tmp_parm[0]>>10) & 7; CLIP_TO_UPLEVEL(track,NUM_TRACK_ACELP); for (lIdxCounter=0; lIdxCounter<2; lIdxCounter++) { pos1 = ((tmp_parm[lIdxCounter] & 7) * 5) + track; if (((tmp_parm[lIdxCounter]>>3) & 1) == 0) sign = 1.; else sign = -1.; ACELPCodeVec[pos1] = sign; pos2 = (((tmp_parm[lIdxCounter]>>4) & 7) * 5) + track; if (pos2 > pos1) sign = -sign; ACELPCodeVec[pos2] += sign; pos3 = (((tmp_parm[lIdxCounter]>>7) & 7) * 5) + track; if (pos3 > pos2) sign = -sign; ACELPCodeVec[pos3] += sign; track++; if (track > NUM_TRACK_ACELP) track = 0; } for (lIdxCounter=2; lIdxCounter<5; lIdxCounter++) { pos1 = ((tmp_parm[lIdxCounter] & 7) * 5) + track; if (((tmp_parm[lIdxCounter]>>3) & 1) == 0) sign = 1.; else sign = -1.; ACELPCodeVec[pos1] = sign; pos2 = (((tmp_parm[lIdxCounter]>>4) & 7) * 5) + track; if (pos2 > pos1) sign = -sign; ACELPCodeVec[pos2] += sign; track++; if (track > NUM_TRACK_ACELP) track = 0; } /* for gain decoding in case of frame erasure */ decoderObj->sBWDStatInd++; if (decoderObj->sBWDStatInd >= 30) { highStatIndicator = 1; decoderObj->sBWDStatInd = 30; } else highStatIndicator = 0; } pDecPrm += 5; LOCAL_ARRAY_FREE(Ipp32s, tmp_parm, 5, decoderObj); } ippsHarmonicFilter_32f_I(decoderObj->fBetaPreFilter,PitchDelay,&ACELPCodeVec[PitchDelay],SUBFR_LEN-PitchDelay); /* Decode pitch and codebook gains. */ index = *pDecPrm++; /* index of energy VQ */ if (bfi != 0) { Ipp32f av_pred_en; if(rate == G729E_MODE) { if (decoderObj->lBFICounter < 2) { if (highStatIndicator) decoderObj->fPitchGain = 1.; else decoderObj->fPitchGain = 0.95f; decoderObj->fCodeGain = decoderObj->fCodeGainMemory; } else { decoderObj->fPitchGain = decoderObj->fPitchGainMemory * (decoderObj->fGainMuting); decoderObj->fCodeGain = decoderObj->fCodeGainMemory * (decoderObj->fGainMuting); if (highStatIndicator) { if (decoderObj->lBFICounter > 10) decoderObj->fGainMuting *= 0.995f; } else decoderObj->fGainMuting *= 0.98f; } } else { decoderObj->fPitchGain *= 0.9f; if(decoderObj->fPitchGain > 0.9f) decoderObj->fPitchGain=0.9f; decoderObj->fCodeGain *= 0.98f; } /* Update table of past quantized energies */ av_pred_en = 0.0f; for (i = 0; i < 4; i++) av_pred_en += decoderObj->PastQuantEnergy[i]; av_pred_en = av_pred_en*0.25f - 4.0f; if (av_pred_en < -14.0) av_pred_en = -14.0f; for (i = 3; i > 0; i--) decoderObj->PastQuantEnergy[i] = decoderObj->PastQuantEnergy[i-1]; decoderObj->PastQuantEnergy[0] = av_pred_en; } else { DecodeGain_G729(index, ACELPCodeVec, SUBFR_LEN, &decoderObj->fPitchGain, &decoderObj->fCodeGain, rate, decoderObj->PastQuantEnergy); } /* Update previous gains */ decoderObj->fPitchGainMemory = decoderObj->fPitchGain; decoderObj->fCodeGainMemory = decoderObj->fCodeGain; /* - Update pitch sharpening "fBetaPreFilter" with quantized fPitchGain */ decoderObj->fBetaPreFilter = decoderObj->fPitchGain; CLIP_TO_UPLEVEL(decoderObj->fBetaPreFilter,PITCH_SHARPMAX); CLIP_TO_LOWLEVEL(decoderObj->fBetaPreFilter,PITCH_SHARPMIN); /* Synthesis of speech corresponding to Excitation[] */ if(decoderObj->objPrm.codecType!=G729A_CODEC) { if(bfi != 0) { /* Bad frame */ decoderObj->lBFICounter++; if (decoderObj->lVoicing == 0 ) { PitchGain = 0.; CodeGain = decoderObj->fCodeGain; } else {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -