⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 decg729fp.c

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 C
📖 第 1 页 / 共 4 页
字号:

         DecodeAdaptCodebookDelays(&decoderObj->prevPitchDelay,&decoderObj->prevFracPitchDelay,delayLine,NSbfr,badPitch,index,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(int, Position, 4, decoderObj);
            int index, sign;

            if(bfi != 0)        /* Bad frame */
            {
               index = (int)Rand_16s(&decoderObj->sFESeed) & (short)0x1fff;     /* 13 bits random */
               sign = (int)Rand_16s(&decoderObj->sFESeed) & (short)0x000f;     /*  4 bits random */
            }else{
               index = pDecPrm[0];
               sign = pDecPrm[1];
            }

            /* First pulse's positions*/
            Position[0] = (index&7)*5;

            /* Second pulse's positions*/
            index >>= 3;
            Position[1] = (index&7)*5 + 1;
            /* Third pulse's positions*/
            index >>= 3;
            Position[2] = (index&7)*5 + 2;

            /* Forth pulse's positions*/
            index >>= 3;
            j = index;
            index >>= 1;
            Position[3] = (index&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(int, Position, 4, decoderObj);
         } else if (rate == G729D_MODE) {
            /* case annex D*/
            LOCAL_ARRAY(int, Position, 2, decoderObj);
            int index, sign;

            if(bfi != 0)        /* Bad frame */
            {
               index = (int)Rand_16s(&decoderObj->sFESeed) & (short)0x1fff;     /* 13 bits random */
               sign = (int)Rand_16s(&decoderObj->sFESeed) & (short)0x000f;     /*  4 bits random */
            }else{
               index = pDecPrm[0];
               sign = pDecPrm[1];
            }

            /* decode the positions of 4 pulses */
            i = index & 15;
            Position[0] = trackTbl0[i];

            index >>= 4;
            i = index & 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(int, Position, 2, decoderObj);
         } else if (rate == G729E_MODE) {
            /* case annex E*/
            LOCAL_ARRAY(int, tmp_parm, 5, decoderObj);

            if(bfi)
            {
               tmp_parm[0] = (int)Rand_16s(&decoderObj->sFESeed);
               tmp_parm[1] = (int)Rand_16s(&decoderObj->sFESeed);
               tmp_parm[2] = (int)Rand_16s(&decoderObj->sFESeed);
               tmp_parm[3] = (int)Rand_16s(&decoderObj->sFESeed);
               tmp_parm[4] = (int)Rand_16s(&decoderObj->sFESeed);
            }else{
               for(i=0;i<5;i++)
                  tmp_parm[i] = pDecPrm[i];
            }

            if (LPCMode == 0) {
               int pos1, pos2;
               float 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 {
               int j, track, pos1, pos2, pos3;
               float 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 (j=0; j<2; j++) {
                  pos1 = ((tmp_parm[j] & 7) * 5) + track;
                  if (((tmp_parm[j]>>3) & 1) == 0) sign = 1.;
                  else sign = -1.;
                  ACELPCodeVec[pos1] = sign;

                  pos2 = (((tmp_parm[j]>>4) & 7) * 5) + track;
                  if (pos2 > pos1) sign = -sign;

                  ACELPCodeVec[pos2] += sign;

                  pos3 = (((tmp_parm[j]>>7) & 7) * 5) + track;
                  if (pos3 > pos2) sign = -sign;

                  ACELPCodeVec[pos3] += sign;

                  track++;
                  if (track > NUM_TRACK_ACELP) track = 0;
               }

               for (j=2; j<5; j++) {
                  pos1 = ((tmp_parm[j] & 7) * 5) + track;
                  if (((tmp_parm[j]>>3) & 1) == 0) sign = 1.;
                  else sign = -1.;
                  ACELPCodeVec[pos1] = sign;

                  pos2 = (((tmp_parm[j]>>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(int, 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)  {
            float  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 {
                  PitchGain = decoderObj->fPitchGain;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -