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

📄 scal_dec_frame.c

📁 语音压缩算法
💻 C
📖 第 1 页 / 共 5 页
字号:
                           tns_info_ltp, qc_select);    }  /* combine all stereo layers */      if (firstStLay!=-1 ) {    for (aacLayer=firstStLay+1 ; aacLayer <= output_select ; aacLayer++) {      for (ch=0;ch<layNumChan[aacLayer];ch++){        vadd(   spectral_line_vector[firstStLay][ch],spectral_line_vector[aacLayer][ch],                spectral_line_vector[firstStLay][ch],                  1,1,1, sfbInfo[windowSequence[MONO_CHAN]]->bins_per_bk );      }    }  }    /* fss for aac mono layer */  if ( (output_select > 0) && (lastMonoLay>0) ){    double tmp[1024];    low_spec=spectral_line_vector[0][0];    shortFssWidth = sfbInfo[windowSequence[MONO_CHAN]]->shortFssWidth;    if (lowRateChannelPresent) {      FSSwitch( low_spec, spectral_line_vector[firstAacLay][MONO_CHAN],                tmp,                diffControl[MONO_CHAN], sfbInfo[windowSequence[MONO_CHAN]] ,                diffControlBands , shortFssWidth,1 );          vcopy (  tmp, spectral_line_vector[firstAacLay][MONO_CHAN],1,1 ,               sfbInfo[windowSequence[MONO_CHAN]]->bins_per_bk);    }        }   if ( ( layNumChan[firstAacLay]==1 )  && ( layNumChan[lastAacLay]==2 ) ) {    vcopy (  spectral_line_vector[firstAacLay][MONO_CHAN] ,              spectral_line_vector[firstAacLay][MONO_CHAN+1],             1,1 ,sfbInfo[windowSequence[MONO_CHAN]]->bins_per_bk);          }  low_spec=spectral_line_vector[firstAacLay][MONO_CHAN];  /* fss for aac stereo layer */  if ( (output_select >= firstStLay ) && (firstStLay!=-1 ) && (layNumChan[firstAacLay]==1)){    double tmp_spec[1024];    /* inverse ms matrix */        multCoreSpecMsFac(sfbInfo[windowSequence[MONO_CHAN]],msMask,low_spec,tmp_spec);    if (layNumChan[firstAacLay]==2 ){      shortFssWidth = sfbInfo[windowSequence[MONO_CHAN]]->shortFssWidth;    }else{      if  (max_sfb[aacLayer-1]!=0) {        shortFssWidth = sfbInfo[windowSequence[MONO_CHAN]]->sbk_sfb_top[0][ max_sfb[firstStLay-1]-1] ;       } else {        shortFssWidth=0;      }    }    for (ch=0;ch<layNumChan[firstStLay];ch++){                          FSSwitchSt( tmp_spec,                   spectral_line_vector[firstStLay][ch],                  spectral_line_vector[firstAacLay][ch],                  diffControl[ch],                  diffControlBands,                  sfbInfo[windowSequence[MONO_CHAN]],                   msMask,                  ch );        }    doInverseMsMatrix( sfbInfo[windowSequence[MONO_CHAN]],spectral_line_vector[firstAacLay][0],                        spectral_line_vector[firstAacLay][1],  msMask );  } else if ((output_select >= firstStLay ) && (firstStLay!=-1 )              && (coreCodecIdx != NTT_TVQ) ){    double tmp_spec[1024];    doInverseMsMatrix( sfbInfo[windowSequence[MONO_CHAN]],spectral_line_vector[firstStLay][0],                        spectral_line_vector[firstStLay][1],  msMask );    if (lowRateChannelPresent){      multCoreSpecMsFac(sfbInfo[windowSequence[MONO_CHAN]],msMask,low_spec,tmp_spec);      for (ch=0;ch<layNumChan[firstStLay];ch++){                            FSSwitch( tmp_spec, spectral_line_vector[firstStLay][ch],                  spectral_line_vector[firstAacLay][ch],                  diffControl[ch], sfbInfo[windowSequence[MONO_CHAN]] ,                  diffControlBands , sfbInfo[windowSequence[MONO_CHAN]]->shortFssWidth ,1 );          }    }  }  if (output_select) {    if (layNumChan[output_select]==2){      for (ch=0;ch<layNumChan[lastAacLay];ch++){        vcopy( spectral_line_vector[firstAacLay][ch] ,   spectral_line_vector[0][ch] , 1, 1,                 sfbInfo[windowSequence[MONO_CHAN]]->bins_per_bk );       }            } else {      for (ch=0;ch<numChannels;ch++){        vcopy( spectral_line_vector[firstAacLay][MONO_CHAN] ,   spectral_line_vector[0][ch] , 1, 1,                 sfbInfo[windowSequence[MONO_CHAN]]->bins_per_bk );       }            }  } else {    if ((layNumChan[lastAacLay]==2)&&(layNumChan[output_select]==1)){      vcopy( spectral_line_vector[0][0] ,   spectral_line_vector[0][1] , 1, 1,               sfbInfo[windowSequence[MONO_CHAN]]->bins_per_bk );     }  }  /* Bandwidth control */  if ((lopLong != 0) && (max_sfb[lastAacLay] != 0) && (output_select == 0)) {    int maxline;          if (normBw == 0.0F) {      maxline = sfbInfo[windowSequence[MONO_CHAN]]->sbk_sfb_top[0][max_sfb[lastAacLay]-1];    }    else {      maxline = (int)((float)(sfbInfo[windowSequence[MONO_CHAN]]->bins_per_bk                               /sfbInfo[windowSequence[MONO_CHAN]]->nsbk)*normBw + 0.5);    }     for (ch=0; ch<layNumChan[lastAacLay]; ch++) {      dec_lowpass(spectral_line_vector[0][ch], lopLong, lopShort, maxline,                  sfbInfo[windowSequence[MONO_CHAN]]->bins_per_bk, windowSequence[MONO_CHAN],                  sfbInfo[windowSequence[MONO_CHAN]]->nsbk);    }  }  /* tns decoder for tns of main header */  if  ( ! (            (output_select == 0) && (lowRateChannelPresent) && (tfData->tnsBevCore==0)            ) )  {    TNS_frame_info tns_stereo_info[2];    if (layNumChan[firstAacLay] ==1 ){      tns_stereo_info[0] = tns_info[0];      tns_stereo_info[1] = tns_info[0];          } else {      tns_stereo_info[0] = tns_info[0];      tns_stereo_info[1] = tns_info[1];          }    for (ch=0;ch<layNumChan[lastAacLay];ch++){            int k, j;      Info *info = sfbInfo[windowSequence[MONO_CHAN]];            for (i=j=0; i<tns_stereo_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_decode_subblock( tmp_spec,                             max_sfb[output_select],                               info->sbk_sfb_top[i],                             info->islong,                             &(tns_stereo_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];      }    }  }  /* tns decoder for tns of 1st extension header */  if ( ( (firstStLay>=1) && (output_select >= firstStLay) && (!lowRateChannelPresent) )        || ( (firstStLay>=2) && (output_select >= firstStLay) && (lowRateChannelPresent))       ) {    TNS_frame_info tns_stereo_info[2];        tns_stereo_info[0] = tns_info_ext[0];    tns_stereo_info[1] = tns_info_ext[1];              for (ch=0;ch<layNumChan[lastAacLay];ch++){            int k, j;      Info *info = sfbInfo[windowSequence[MONO_CHAN]];      if (tns_ext_present[ch]==1){        for (i=j=0; i<tns_stereo_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_decode_subblock( tmp_spec,                               max_sfb[output_select],                                 info->sbk_sfb_top[i],                               info->islong,                               &(tns_stereo_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];        }      }    }  }#ifdef DEBUGPLOT_FHG   plotSend("c", "mdctCore",  MTV_DOUBLE,1024, low_spec , NULL);  plotSend("l", "mdctSpecL",  MTV_DOUBLE_SQA,1024, spectral_line_vector[0][0] , NULL);  /*   plotSend("r", "mdctSpecR" , MTV_DOUBLE,1024, spectral_line_vector[firstAacLay][1] , NULL); */#endif       /* increment granule counter */  gran += 1;  if( gran == nrGranules ) {    gran = 0;  }}void tfScaleableAUDecode ( int          numChannels,                            FRAME_DATA*  fd, /* config data , obj descr. etc. */                           TF_DATA*     tfData,                           LPC_DATA*    lpcData,                                                      ntt_DATA*           nttData,                           HANDLE_FAULT_TOLERANT hFault,                           QC_MOD_SELECT      qc_select                            ){#if 0  BsBitStream*       fixed_stream;  BsBitStream*       gc_WRstream[];  WINDOW_SEQUENCE        windowSequence[MAX_TIME_CHANNELS];  int*               flexMuxBits;  double*            spectral_line_vector[MAX_TF_LAYER][MAX_TIME_CHANNELS];  Info**             sfbInfo;  int                numChannels;  int                lopLong;  int                lopShort;  float              normBw;  WINDOW_SHAPE*      windowShape;  QC_MOD_SELECT      qc_select;  HANDLE_RESILIENCE  hResilience;  HANDLE_BUFFER      hVm;  HANDLE_BUFFER      hHcrSpecData;  HANDLE_HCR         hHcrInfo;  FRAME_DATA*        fd;  HANDLE_EP_INFO     hEpInfo;  HANDLE_CONCEALMENT hConcealment;  int                short_win_in_long;  PRED_TYPE          pred_type;#endif      int                med_win_in_long=2; /* dummy , not used */  int                short_win_in_long = 8;  BsBitStream*       gc_DummyStream[MAX_TIME_CHANNELS]={0x0};    BsBitStream* layer_stream ;    int                lopLong=0;  int                lopShort=0;  float              normBw=0.0f;  int            shortFssWidth;  double*        low_spec;  int lowRateChannelPresent;  enum CORE_CODEC  coreCodecIdx;  int     lastAacLay = 0;    int     firstAacLay = 0;    int     layNumChan[MAX_TF_LAYER];  int     firstStLay;  int     lastMonoLay;  unsigned long  ultmp,codedBlockType;  int            diffControl  [2][ 60 ] = {{0x0}};  int            diffControlLR[2][ 60 ] = {{0x0}};  int            commonWindow[MAX_TF_LAYER];  int            aacLayer = 0;  int            layer;  int            ch,calcMonoLay;  int            diffControlBands;  int            diffControlBandsExt,diffControlBandsLR ;  int            i;  int            tmp = 0;  int            msMask[8][60]={{0x0}};  int            msMaskPres = 0;  TNS_frame_info tns_info[MAX_TIME_CHANNELS];  TNS_frame_info tns_info_ext[MAX_TIME_CHANNELS];  byte           max_sfb[Winds];  byte           sfbCbMap[MAX_TF_LAYER][MAX_TIME_CHANNELS][MAXBANDS] = {{{0x0}}};  int            groupInfo = 0;  int            tns_data_present[2];  int            tns_ext_present[2];  int            used_bits[4][2];  int            decodedBits;  ntt_INDEX     index, index_scl;  int           coreChannels;  unsigned long totalLength;  int           tvqTnsPresent;  int           output_select;  /* init */  decodedBits       = 0;  tvqTnsPresent     = 0;  coreChannels      = 0;  tns_ext_present[0]= 0;  tns_ext_present[1]= 0;    output_select = tfData->output_select;    index.nttDataBase=nttData->nttDataBase;  index_scl.nttDataScl=nttData->nttDataScl;  index.numChannel =numChannels;  index_scl.numChannel =numChannels;  /*********************/  layer=0;  getModeFromOD(fd->od,&lowRateChannelPresent ,layNumChan ,&lastAacLay ,&firstStLay,&coreCodecIdx,                  commonWindow);    if(coreCodecIdx==NTT_TVQ)     output_select -= index_scl.nttDataScl->ntt_NSclLay;  if (output_select>lastAacLay) output_select=lastAacLay;  if (output_select<0) output_select=0; /* YB 980508 */  if (firstStLay>=0)    lastMonoLay=firstStLay-1;/* debug */  else     lastMonoLay=lastAacLay;/* debug */  if (output_select > lastMonoLay ){    calcMonoLay=lastMonoLay ;  } else {    calcMonoLay=output_select ;        }  /* open the first layer bitbuffer  to read :     can  be a AAC or TwinVq bitbuffer as core */  if (fd->layer[layer].NoAUInBuffer<=0) { CommonWarning("no Access unit; skiping frame"); return ;}  layer_stream= BsOpenBufferRead(fd->layer[layer].bitBuf);  /*      According to the new bitstream syntax (98/11/12),      there is no more ics_reserved_bit for scalable  */  if ( (coreCodecIdx==CC_CELP_MPEG4) ) {    float coreSig[1024];    int i,k;    int ifactor=tfData->samplFreqFacCore;    firstAacLay = 1;     /* celp decoder */    coreChannels      = 1;    while ( GetNumVal ( tfData->coreModuloBuffer ) < tfData->block_size_samples ) {      if (BsGetBuffer( layer_stream, lpcData->coreBitBuf, lpcData->bitsPerFrame) )        CommonExit(-11,"Decode core bitstream : error get buffer");      DecLpcFrameNew(lpcData->coreBitBuf,lpcData->sampleBuf,lpcData,&tmp);            if (tmp!=lpcData->bitsPerFrame)        CommonExit(1,"celp decoder error, wrong num bit read");      /*    upsampling  */      for( i=0; i< lpcData->frameNumSample ;i++ ) {        coreSig[i*ifactor] = lpcData->sampleBuf[0][i] * ifactor;        for( k=1; k<ifactor; k++ ) {          coreSig[i*ifactor+k] = 0;        }      }            #ifdef DEBUGPLOT     plotSend("c", "timeCore2",  MTV_FLOAT,tfData->block_size_samples/ifactor,lpcData->sampleBuf[0] , NULL);#endif    AddFloatModuloBufferValues( tfData->coreModuloBuffer,coreSig ,                                 lpcData->frameNumSample * tfData->samplFreqFacCore);    }    /* prepare decoding of next layer *//*     fd->layer[layer].NoAUInBuffer--; */    BsCloseRemove(layer_stream,1);    fd->layer[layer].NoAUInBuffer--;    layer++;  }  if (!(lowRateChannelPresent && (coreCodecIdx==NTT_TVQ))      && (lastAacLay>=0)      && (fd->layer[layer].NoAUInBuffer>0)){    layer_stream= BsOpenBufferRead(fd->layer[layer].bitBuf);            /* bugfix by tmn@iis.fhg.de ; after official release date  99-08-09 */       BsGetBit( layer_stream, &ultmp,1); /* reserved bit */    decodedBits += 1;    BsGetBit( layer_stream, &ultmp,2); /* window_sequence */    codedBlockType = (int)ultmp;    decodedBits += 2;    switch (   codedBlockType )      {      case 0:       tfData->windowSequence[MONO_CHAN] =  ONLY_LONG_S

⌨️ 快捷键说明

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