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

📄 dec_tf.c

📁 MPEG2/MPEG4编解码参考程序(实现了MPEG4的部分功能)
💻 C
📖 第 1 页 / 共 5 页
字号:
    aacScaleableDecodeInit();  }  if( strstr( decPara, "-aac_sys" )         || ( strstr(decPara, "-mp4ff") != NULL)      ) {    unsigned int x;    char * outLayNr;    char * lopPara;    AUDIO_SPECIFIC_CONFIG *audSpC = &frameData->od->ESDescriptor[frameData->od->streamCount.value-1]->DecConfigDescr.audioSpecificConfig;        switch (audSpC->channelConfiguration.value) {    case 1 :numChannel=1;             break;    case 2 :numChannel=2;             break;    default: CommonExit(1,"wrong channel config");    }    /* currently fix coded !!! */    if ( mainDebugLevel ) {      printf(" TF scaleable decoding NEW flexmux  bitstream syntax\n");    }    bit_rate_decoded = (long int)bitRate;    sampling_rate_decoded = (long int)fSample;    block_size_samples = ( frameData->od->ESDescriptor[0]->DecConfigDescr.audioSpecificConfig.specConf.TFSpecificConfig.frameLength.value ? 960:1024) ;    delay_samples_decoded = 2048;    channel_configuration = CHC_MONO;    if (numChannel ==2){      channel_configuration =CHC_DUAL;    }    qc_select = AAC_SCALABLE;    tf_select = MDCT_AAC;    transport_stream = AAC_RAWDATA_TSTREAM;    if ( ( lopPara = strstr ( decPara, "-lop"))) {      sscanf(&lopPara[4],"%d%d%f",&lopLong,&lopShort,&normBw);      if ((lopLong < 0 ) || (lopLong > 950)) {        CommonExit(-1,"\n lopLong parameter out of range: %d", lopLong);      }      if ((lopShort < 0 ) || (lopShort > 110)) {        CommonExit(-1,"\n lopShort parameter out of range: %d", lopShort);      }      if ((normBw < 0.0F) || (normBw > 1.0F)) {        CommonExit(-1,"\n normalized bandwidth out of range: %f", lopShort);      }      if ( mainDebugLevel ) {        printf("lopLong=%d, lopShort=%d, normalized bandwidth=%3.2f\n", lopLong, lopShort, normBw);      }    }    if ( ( outLayNr = strstr( decPara, "-out") ) ){      sscanf(&outLayNr[4],"%d",&scalOutSelect);      if ( (scalOutSelect < 0 ) || ( scalOutSelect > 7 ) ){        CommonExit(-1,"\n errorn in output layer select %d  ",scalOutSelect);      }       if ( mainDebugLevel ) {        printf("\n for output layer nr. %d is selected ",scalOutSelect);      }    }    tfData->output_select = scalOutSelect;    aacScaleableDecodeInit();    if( strstr(decPara, "-mp4ff") == NULL)  {            for ( x = 0; x < frameData->od->streamCount.value; x++ ){        frameData->layer[x].bitBuf = BsAllocBuffer(64000);      }    }        tfData->tnsBevCore=0;         if( strstr( decPara, "-tnsBevCor" ) ) {      if ( mainDebugLevel ) {        printf("\n DON'T calc tns on core spectrum");      }      tfData->tnsBevCore=1;          }  }    if( strstr( decPara, "-qc_ntt" ) ) {    qc_select = NTT_VQ;  }  /* T.Ishikawa 980625 */  if( strstr(decPara, "-tvq_sys") )    {      qc_select = NTT_VQ_SYS;      for(x=0;x<(int)(frameData->od->streamCount.value);x++)        {          frameData->layer[x].bitBuf = BsAllocBuffer(8200);        }    }  else if( strstr( decPara, "-nttDecLyr") != NULL)    {      qc_select = NTT_VQ;    }  if( strstr( decPara, "-qc_mdct16" ) ) {    qc_select = MDCT_VALUES_16BIT;  }    if( strstr( decPara, "-pred_ltp" ) )    pred_type = NOK_LTP;  if( strstr( decPara, "-pred_nok_bwp" ) )    pred_type = NOK_BWP;  /*always NOK_LTP for TVQ or SCALABLE */  if (qc_select == NTT_VQ_SYS || qc_select == NTT_VQ)    pred_type = NOK_LTP;  if (qc_select == AAC_SCALABLE )    pred_type = NOK_LTP;  /* ----- if no AAC_RAWDATA, get some header information -----*/  if ((transport_stream != AAC_RAWDATA_TSTREAM) &&( qc_select != NTT_VQ_SYS)       && (transport_stream != NO_TSTREAM) ){ /* T.Ishikawa 980526 */    BsGetBit( header_stream, &ultmp, 16 );    if( ultmp != 0x1234 ) {      CommonExit( 1,"Wrong Stream Header" );    }    BsGetBit( header_stream, &ultmp, 24 );    bit_rate_decoded = ultmp;    BsGetBit( header_stream, &ultmp, 24 );    sampling_rate_decoded = ultmp;    BsGetBit( header_stream, &ultmp, 16 );    block_size_samples = ultmp;    BsGetBit( header_stream, &ultmp, 16 );    med_win_in_long = ultmp;    BsGetBit( header_stream, &ultmp, 16 );    short_win_in_long = ultmp;    BsGetBit( header_stream, &ultmp, 16 );    delay_samples_decoded = ultmp;    BsGetBit( header_stream, &ultmp, 8 );    channel_configuration = (enum CH_CONFIG)ultmp;    BsGetBit( header_stream, &ultmp, 32 );    tf_select = (enum TF_MOD_SELECT)ultmp;    BsGetBit( header_stream, &ultmp, 32 );    qc_select = (QC_MOD_SELECT)ultmp;  }  if((qc_select != NTT_VQ) && (qc_select != NTT_VQ_SYS)){ /* T.Ishikawa 980525*/    if (numChannel > 2)      CommonExit(1,"DecTfInit: audio data has more than one channel (%d)",                 numChannel);  }    /* If short blocks, set blocksizeSample manually,      if encoder is up to date for 960s this should be      written/read to/from bitstreamheader */  if (strstr(decPara, "-qc_aac_960")){    useShortWindows=1;    block_size_samples=960;  }  else    useShortWindows=0;    /* -- if AAC_RAWDATA, get "aacraw. "     Note: you must have set -c -aac_raw for decoding  --- */  /*    if( transport_stream == AAC_RAWDATA_TSTREAM ) {    BsGetBit( header_stream, &ultmp, 8 );    BsGetBit( header_stream, &ultmp, 8 );    BsGetBit( header_stream, &ultmp, 8 );    BsGetBit( header_stream, &ultmp, 8 );    BsGetBit( header_stream, &ultmp, 8 );    BsGetBit( header_stream, &ultmp, 8 );    }  */  if (qc_select == NTT_VQ){    int iscl;    /* NTT_VQ supports both LENINFO_STREAM and NO_SYNCWORD. */    BsGetBit(header_stream, &ultmp, 2);    transport_stream = (enum TRANSPORT_STREAM)ultmp;    /* If the ntt_varbit is off, number of bits       per frame should be in the header. */    BsGetBit(header_stream, &ultmp, 1);    ntt_varbit = (enum NTT_VARBIT)ultmp;    if (ntt_varbit == NTT_VARBIT_OFF){      BsGetBit(header_stream, &ultmp, 32);      frameNumBit = ultmp;    }    /* long term predictor */    BsGetBit(header_stream, &ultmp, 1);    ntt_LTP_SW = ultmp;    /* header for base coder */ /* T.Ishikawa 981118 */    BsGetBit(header_stream, &ultmp, 16);    ntt_IBPS= ultmp;    /*      ntt_BPS=(double)ntt_IBPS;    */	    /* header for scalable coder */    BsGetBit(header_stream, &ultmp, ntt_NSclLay_BITS);    ntt_NSclLay = (int)ultmp;    for (iscl=0; iscl<ntt_NSclLay; iscl++){      BsGetBit(header_stream, &ultmp, ntt_IBPS_BITS_SCL);      ntt_IBPS_SCL[iscl] = ultmp;      /*NN        ntt_BPS_SCL[iscl]=(double)ntt_IBPS_SCL[iscl];      */      /*      ntt_BPS_SCL[iscl] = (double)ultmp;*/      fprintf(stderr,"ntt_IBPS_SCL[%d] %d\n",iscl,(int)ultmp);    }  }  /* NTT_TVQ_SYS T.Ishikawa 980525 */  if (qc_select == NTT_VQ_SYS){    int iscl,mat_block_size,mat_total_bitrate;    float mat_sampleFreq = 0;    /* Decoding Condition Setting T.Ishikawa */    mat_block_size =       ( frameData->od->ESDescriptor[0]->DecConfigDescr.audioSpecificConfig.specConf.TFSpecificConfig.frameLength.value ? 960:1024) ;    if ( mainDebugLevel>2 ) {      printf("TTTTTTTTTTTT %5d TTTTTTTTTTT\n",mat_block_size);    }    switch      (frameData->od->ESDescriptor[0]->DecConfigDescr.audioSpecificConfig.samplingFreqencyIndex.value)      {      case 0:        mat_sampleFreq=96000.0;        sampling_rate_decoded=96000;        break;      case 1:        mat_sampleFreq=88200.0;        sampling_rate_decoded=88200;        break;      case 2:        mat_sampleFreq=64000.0;        sampling_rate_decoded=64000;        break;      case 3:        mat_sampleFreq=48000.0;        sampling_rate_decoded=48000;        break;      case 4:        mat_sampleFreq=44100.0;        sampling_rate_decoded=44100;        break;      case 5:        mat_sampleFreq=32000.0;        sampling_rate_decoded=32000;        break;      case 6:        mat_sampleFreq=24000.0;        sampling_rate_decoded=24000;        break;      case 7:        mat_sampleFreq=22050.0;        sampling_rate_decoded=22050;        break;      case 8:        mat_sampleFreq=16000.0;        sampling_rate_decoded=16000;        break;      case 9:        mat_sampleFreq=12000.0;        sampling_rate_decoded=12000;        break;      case 10:        mat_sampleFreq=11025.0;        sampling_rate_decoded=11025;        break;      case 11:        mat_sampleFreq=8000.0;        sampling_rate_decoded=8000;        break;      case 12:      case 13:      case 14:      case 15:        CommonWarning("reserved \n");        break;      default:        CommonWarning("mat_sampleFreq Error !!\n");        break;      }    /* NTT_VQ supports both LENINFO_STREAM and NO_SYNCWORD. */    /*BsGetBit(header_stream, &ultmp, 2);      transport_stream = (enum TRANSPORT_STREAM)ultmp;*/    transport_stream = (enum TRANSPORT_STREAM)0;/* adhoc */    /* If the ntt_varbit is off, number of bits       per frame should be in the header. */    /*BsGetBit(header_stream, &ultmp, 1);      ntt_varbit = (enum NTT_VARBIT)ultmp;*/    ntt_varbit = NTT_VARBIT_OFF;    if (ntt_varbit == NTT_VARBIT_OFF){      /*BsGetBit(header_stream, &ultmp, 32);        frameNumBit = ultmp;*/      /*            CommonWarning("TwinVQ(for System) is not supported !!\n");*/      /*      frameNumBit = (int)(frameData->od->ESDescriptor[0]->DecConfigDescr.avg              Bitrate.value*mat_block_size/mat_sampleFreq);              if ( mainDebugLevel>2 ) {              printf(" ###### %d ######\n",frameNumBit);              }*/    }    /* long term predictor */    /*    BsGetBit(header_stream, &ultmp, 1);          ntt_LTP_SW = ultmp;*/    ntt_LTP_SW = 0;/* adhoc */    /* header for scalable coder */    ntt_NSclLay = frameData->od->streamCount.value-1;    /* ntt_NSclLay = the Number of Enhanced Layer */    ntt_IBPS =       (int)(frameData->od->ESDescriptor[0]->DecConfigDescr.avgBitrate.value);    /*      ntt_BPS =       (float)(frameData->od->ESDescriptor[0]->DecConfigDescr.avgBitrate.value); */    /* T.Ishikawa 980623 */    if ( mainDebugLevel>2 ) {      printf(" ///// ntt_IBPS %d /////\n",ntt_IBPS);      /*        printf(" ///// ntt_BPS %f /////\n",ntt_BPS);      */    }    for (iscl=1; iscl<=ntt_NSclLay; iscl++){      ntt_IBPS_SCL[iscl-1]=(int)        (frameData->od->ESDescriptor[iscl]->DecConfigDescr.avgBitrate.value);      /*        ntt_BPS_SCL[iscl-1]=(float)        (frameData->od->ESDescriptor[iscl]->DecConfigDescr.avgBitrate.value);      */      if ( mainDebugLevel>2 ) {        printf(" ///// ntt_IBPS_SCL[%d] %d /////\n",               iscl-1,ntt_IBPS_SCL[iscl-1]);      }    }    for(mat_total_bitrate=0,iscl=0;iscl<ntt_NSclLay;iscl++)      {        mat_total_bitrate += ntt_IBPS_SCL[iscl];      }    mat_total_bitrate += ntt_IBPS;    frameNumBit = (int)floor(mat_total_bitrate*mat_block_size/mat_sampleFreq);    if ( mainDebugLevel >2) {      printf(" ###### %d ######\n",frameNumBit);    }    block_size_samples = mat_block_size;    delay_samples_decoded=mat_block_size;  }  BsCloseRemove(header_stream,1);  /* currently initializes the scale factor band table; should be moved to a separate module */  /*    if( (qc_select != NTT_VQ) && ( qc_select != NTT_VQ_SYS) ) */{    /* T.Ishikawa 98052*/    EncTf_psycho_acoustic( sampling_rate_decoded ,                            1,                            qc_select,                           block_size_samples,                            chpo_long,                            chpo_short );  }   /* set the return values */  *frameNumSample = block_size_samples;  *delayNumSample = delay_samples_decoded;  /* calc. no of audio channels */  if ((qc_select != NTT_VQ) && ( qc_select != NTT_VQ_SYS)){     /* T.Ishikawa 980525 */    /* table to get the no. of audio channels depending on the value of channel_configuration */    static int  chc_2_chan_nr[CHC_MODES] = { 1, 2, 2, 5 };    max_ch  = chc_2_chan_nr[channel_configuration];  }  else{    max_ch = numChannel;

⌨️ 快捷键说明

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