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

📄 scal_dec_frame.c

📁 语音压缩算法
💻 C
📖 第 1 页 / 共 5 页
字号:
          for (gwin=1;gwin<sfbInfo[windowSequence[MONO_CHAN]]-> group_len[g];gwin++){            for (sfb=0;sfb<max_sfb[firstAacLay];sfb++){                              msMask[win+gwin][sfb]=msMask[win][sfb];/* apply same ms mask to all                                                         subwindows of same group */            }          }          win += sfbInfo[windowSequence[MONO_CHAN]]->group_len[g];        }      }else if (msMaskPres==2){        win=0;        for (g=0;g<sfbInfo[windowSequence[MONO_CHAN]]->num_groups;g++){          for (gwin=0;gwin<sfbInfo[windowSequence[MONO_CHAN]]-> group_len[g];gwin++){            for (sfb=0;sfb<max_sfb[firstAacLay];sfb++){              msMask[win][sfb]=1;            }            win++;          }        }      }      }          diffControlBands =0;    /* tns_channel_mono_layer bit (To DO !!) */    if((layNumChan[firstAacLay]==2) && (coreChannels == 1) && lowRateChannelPresent && !tvqTnsPresent) {      BsGetBit( layer_stream, &ultmp, 1);    }    for (ch=0;ch<layNumChan[firstAacLay];ch++){      /* TNS data */      BsGetBit( layer_stream, &ultmp,1);      tns_data_present[ch] = ultmp;      decodedBits += 1;      if( ultmp ) {        get_tns_vm( layer_stream, sfbInfo[windowSequence[MONO_CHAN]], &tns_info[ch] ,&decodedBits);      } else {        clr_tns( sfbInfo[windowSequence[MONO_CHAN]], &tns_info[ch] );      }          if (coreCodecIdx!=NO_CORE) {        if ((ch==0) || ((ch==1) && (coreChannels==2 ) ) ){          if (windowSequence[MONO_CHAN] ==  EIGHT_SHORT_SEQUENCE){            int g;            for (g=0;g<8;g++){              BsGetBit( layer_stream,&ultmp, 1 );  /* short FSSwitch  1st aacLayer  */              decodedBits += 1;              diffControl[ch][g]= ultmp;              if (ch==0){                diffControlBands +=1;              }            }          } else {            decodeDiffCtrl(layer_stream,diffControl[ch],&decodedBits,                           sfbInfo[windowSequence[MONO_CHAN]]->longFssGroups);/*  FSSwitch 1st aacLayer */            if (ch==0){              diffControlBands +=sfbInfo[windowSequence[MONO_CHAN]]->longFssGroups*4;            }          }        }        if ((coreChannels == 1) && (layNumChan[firstAacLay]==2)){          int g,sfb;          /* diffcontrol lr */          if (windowSequence[MONO_CHAN] ==  EIGHT_SHORT_SEQUENCE){            diffControlBands = 8;            for (g=0;g<8;g++){              BsGetBit( layer_stream,&ultmp, 1 );  /* short FSS */              decodedBits += 1;              diffControl[ch][g]= ultmp;                            }          } else {            diffControlBands = max_sfb[aacLayer-1];            for (sfb=0;sfb< max_sfb[aacLayer-1];sfb++){              if (msMask[0][sfb]==0) {                BsGetBit( layer_stream,&ultmp, 1 );  /* long FSS */                decodedBits += 1;                diffControl[ch][sfb]= ultmp;              } else {                diffControl[ch][sfb]= 0;/* allways on if ms on  channel */              }            }          }        }      } else {	if(pred_type == NOK_LTP)          {            setHuffdec2BitBuffer(layer_stream);            /* LTP data. */            decodedBits +=               nok_lt_decode(windowSequence[MONO_CHAN], &max_sfb[firstAacLay],                             nok_lt_status[ch]->sbk_prediction_used,                             nok_lt_status[ch]->sfb_prediction_used,                             &nok_lt_status[ch]->weight, nok_lt_status[ch]->delay,                            hResilience, hVm, hEpInfo, qc_select, NO_CORE, -1);            ResetReadBitCnt (hVm);          }	else          {            BsGetBit(layer_stream, &ultmp, 1);  /* no prediction data  */            decodedBits += 1;          }      }    }      /* decode 1st AAC Layer */    used_bits[firstAacLay][0] = decodedBits;    aacLayer=firstAacLay;    if(qc_select == AAC_SCALABLE) {      tmp = AacDecodeFrame( layer_stream,                            gc_WRstream,                            spectral_line_vector[aacLayer],                             &(windowSequence[MONO_CHAN]),                             windowShape,                            SCALABLE,                            &max_sfb[aacLayer],                            layNumChan[aacLayer],                            commonWindow[aacLayer],                            sfbInfo,                             sfbCbMap[aacLayer],                            hResilience,                            hVm,                            hHcrSpecData,                            hHcrInfo,                            hEpInfo,                            hConcealment,                            qc_select,			    nok_lt_status);    }    used_bits[aacLayer][1] = tmp;    decodedBits +=tmp;    totalLength = BsBufferNumBit(fd->layer[aacLayer].bitBuf);    BsGetSkip(layer_stream,(totalLength-decodedBits));     BsCloseRemove ( layer_stream ,1);    /* end of 1st aac layer */    layer++;  }  /* read and decode aac_scaleable_extension_stream(s) */    for ( aacLayer=firstAacLay+1;aacLayer<=lastAacLay;aacLayer++){      layer_stream= BsOpenBufferRead(fd->layer[aacLayer].bitBuf);       decodedBits =0;      if (windowSequence[MONO_CHAN]== EIGHT_SHORT_SEQUENCE){        BsGetBit( layer_stream, &ultmp,4);          /* max_sfb_med */        decodedBits += 4;        max_sfb[aacLayer]=ultmp;      } else {        BsGetBit( layer_stream, &ultmp,6);          /*  max_sfb_med */        decodedBits += 6;        max_sfb[aacLayer]=ultmp;      }          if( (layNumChan[aacLayer]==2)){  /* rest of ms mask which was not transmitted in previous layer */        int g,sfb,win,gwin;        int startSfb;        BsGetBit( layer_stream, &ultmp,2);     /* ms_mask_present ? */        decodedBits += 2;        msMaskPres = ultmp;                  if (msMaskPres==1){          win=0;          for (g=0;g<sfbInfo[windowSequence[MONO_CHAN]]->num_groups;g++){            if (layNumChan[aacLayer-1]!=layNumChan[aacLayer]){              startSfb=0;            } else {              startSfb=max_sfb[aacLayer-1];            }            for (sfb=startSfb;sfb<max_sfb[aacLayer];sfb++){              BsGetBit( layer_stream, &ultmp,1);    /* ms_mask */              decodedBits += 1;              msMask[win][sfb]=ultmp;            }            for (gwin=1;gwin<sfbInfo[windowSequence[MONO_CHAN]]-> group_len[g];gwin++){              for (sfb=startSfb;sfb<max_sfb[aacLayer];sfb++){                                msMask[win+gwin][sfb]=msMask[win][sfb];/* apply same ms mask to all                                                           subwindows of same group */              }            }            win += sfbInfo[windowSequence[MONO_CHAN]]-> group_len[g] ;          }                  }else if (msMaskPres==2){          win=0;          for (g=0;g<sfbInfo[windowSequence[MONO_CHAN]]->num_groups;g++){            if (layNumChan[aacLayer-1]!=layNumChan[aacLayer]){              startSfb=0;            } else {              startSfb=max_sfb[aacLayer-1];            }            for (g=0;g<sfbInfo[windowSequence[MONO_CHAN]]->num_groups;g++){              for (gwin=0;gwin<sfbInfo[windowSequence[MONO_CHAN]]-> group_len[g];gwin++){                for (sfb=startSfb;sfb<max_sfb[aacLayer];sfb++){                  msMask[win][sfb]=1;                }                win++;              }            }          }          }      }      diffControlBands =0;                  if ( (layNumChan[aacLayer-1]!=layNumChan[aacLayer]) ) {        int sfb,g;        if ( (layNumChan[aacLayer-1] == 1) && (layNumChan[aacLayer] == 2)  ){          for (ch=0;ch<layNumChan[aacLayer];ch++){            BsGetBit( layer_stream, &ultmp,1);           /* tns for left right*/            tns_ext_present[ch] = ultmp;            decodedBits += 1;            if( ultmp ) {              get_tns_vm( layer_stream, sfbInfo[windowSequence[MONO_CHAN]], &tns_info_ext[ch] ,&decodedBits);            } else {              clr_tns( sfbInfo[windowSequence[MONO_CHAN]], &tns_info_ext[ch] );            }                        if (windowSequence[MONO_CHAN] ==  EIGHT_SHORT_SEQUENCE){              diffControlBands = 8;              for (g=0;g<8;g++){                BsGetBit( layer_stream,&ultmp, 1 );  /* short FSS */                decodedBits += 1;                diffControl[ch][g]= ultmp;                              }            } else {              diffControlBands = max_sfb[aacLayer-1];              for (sfb=0;sfb< max_sfb[aacLayer-1];sfb++){                if (msMask[0][sfb]==0) {                  BsGetBit( layer_stream,&ultmp, 1 );  /* long FSS */                  decodedBits += 1;                  diffControl[ch][sfb]= ultmp;                } else {                  diffControl[ch][sfb]= 0;/* allways on if ms on  channel */                }              }            }          }                }      }      used_bits[aacLayer][0] = decodedBits;          ResetReadBitCnt ( hVm );        /*        {        double zero=0.0;        vcopy( &zero, spectral_line_vector[aacLayer][0], 0, 1,1024 );        vcopy( &zero, spectral_line_vector[aacLayer][1], 0, 1,1024 );        }*/            tmp = AacDecodeFrame( layer_stream,                            gc_WRstream,                            spectral_line_vector[aacLayer],                             &(windowSequence[MONO_CHAN]),                             windowShape,                            SCALABLE,                            &max_sfb[aacLayer],                            layNumChan[aacLayer],                            commonWindow[aacLayer],                            sfbInfo,                             sfbCbMap[aacLayer],                            hResilience,                            hVm,                            hHcrSpecData,                            hHcrInfo,                            hEpInfo,                            hConcealment,                            qc_select,			    nok_lt_status);      used_bits[aacLayer][1] = tmp;      decodedBits +=tmp;      totalLength =   BsBufferNumBit(fd->layer[aacLayer].bitBuf);      BsGetSkip(layer_stream,(totalLength-decodedBits));      BsCloseRemove ( layer_stream ,1);    }  if ( (coreCodecIdx!=NO_CORE) && (output_select > 0) && (tfData->tnsBevCore==0)  ) {    /* tns encoder for mono/core  layer */    int k, j;    Info *info =sfbInfo[windowSequence[MONO_CHAN]];    info->islong = (windowSequence[MONO_CHAN] != EIGHT_SHORT_SEQUENCE);    ch = 0;    for (i=j=0; i<tns_info[ch].n_subblocks; i++) {      float tmp_spec[1024];      for( k=0; k < info->bins_per_sbk[i]; k++ ) {        tmp_spec[k] = spectral_line_vector[0][ch][j+k];      }      tns_encode_subblock( tmp_spec,                           max_sfb[1],   /* max_sfb[wn] Attention: wn and not ch !! */                           info->sbk_sfb_top[i],                           info->islong,                           &(tns_info[ch].info[i]),                           qc_select);                    for( k=0; k < info->bins_per_sbk[i]; k++ ) {        spectral_line_vector[0][ch][j+k] = tmp_spec[k];      }              j += info->bins_per_sbk[i];    }  }    /* compute PNS and restore spectrum */  {    int sfb, maxSfb, lineIdx=0;    int prevSfbCb,sfbCb, sfbWidth;    double energy, zero = 0.0;     if (sfbInfo[windowSequence[MONO_CHAN]]->islong) {       for (aacLayer=firstAacLay+1; aacLayer <= calcMonoLay; aacLayer++) {               /* for the first layer do nothing */        maxSfb = (max_sfb[aacLayer-1]<max_sfb[aacLayer])?max_sfb[aacLayer-1]:max_sfb[aacLayer];                for (ch=0;ch<layNumChan[aacLayer];ch++) {                  for (sfb=0; sfb<maxSfb; sfb++) {            prevSfbCb = (int)sfbCbMap[aacLayer-1][ch][sfb];/* does not work for mono-stereo combination */            sfbCb     = (int)sfbCbMap[aacLayer][ch][sfb];            if (sfb==0) {              sfbWidth = sfbInfo[windowSequence[MONO_CHAN]]->bk_sfb_top[sfb];            }            else {              sfbWidth = sfbInfo[windowSequence[MONO_CHAN]]->bk_sfb_top[sfb]-                sfbInfo[windowSequence[MONO_CHAN]]->bk_sfb_top[sfb-1];            }                        if (prevSfbCb == NOISE_HCB) {              energy = scalprod(&spectral_line_vector[aacLayer][ch][lineIdx],                                 &spectral_line_vector[aacLayer][ch][lineIdx], 1, 1, sfbWidth);              /* if sfb of enhancement layer has MDCT lines, set sfb of previous layer to 0 */              if (energy > 0) {                vcopy(&zero, &spectral_line_vector[aacLayer-1][ch][lineIdx], 0 ,1 ,sfbWidth);              }              else {                sfbCbMap[aacLayer][ch][sfb] = sfbCbMap[aacLayer-1][ch][sfb];                vcopy(&spectral_line_vector[aacLayer-1][ch][lineIdx],                      &spectral_line_vector[aacLayer][ch][lineIdx], 1, 1, sfbWidth);                vcopy(&zero,&spectral_line_vector[aacLayer-1][ch][lineIdx], 0, 1, sfbWidth);                }              if (sfbCb == NOISE_HCB) {                CommonWarning("Two consecutive layers have PNS in same SFB !");              }             }            lineIdx += sfbWidth;           }        }      }        }  }  /* combine all mono layers */  for (aacLayer=firstAacLay+1 ; aacLayer <= calcMonoLay ; aacLayer++) {    if (!debugDiff){      vadd(   spectral_line_vector[firstAacLay][MONO_CHAN],              spectral_line_vector[aacLayer][MONO_CHAN],spectral_line_vector[firstAacLay][MONO_CHAN],                1,1,1, sfbInfo[windowSequence[MONO_CHAN]]->bins_per_bk );    } else {      vcopy (  spectral_line_vector[aacLayer][MONO_CHAN] ,                spectral_line_vector[firstAacLay][MONO_CHAN],               1,1 ,sfbInfo[windowSequence[MONO_CHAN]]->bins_per_bk);    }  }  /* LTP processing. */  if(coreCodecIdx == NO_CORE && pred_type == NOK_LTP)    {      TNS_frame_info *tns_info_ltp[2];          tns_info_ltp[0] = &tns_info[0];      tns_info_ltp[1] = &tns_info[1];          ltp_scal_reconstruct(windowSequence[MONO_CHAN],                           *windowShape, *windowShape,                           layNumChan[firstAacLay],                           spectral_line_vector[firstAacLay],                           sfbInfo[windowSequence[MONO_CHAN]]->bins_per_bk,                           med_win_in_long, short_win_in_long,                           max_sfb[firstAacLay], msMask, nok_lt_status,                            sfbInfo[windowSequence[MONO_CHAN]], 

⌨️ 快捷键说明

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