📄 mp4audec.c
字号:
printf("ObjectDescriptor.ODescrId: %ld \n",objDescr.ODescrId.value); printf("ObjectDescriptor.streamCount: %ld \n",objDescr.streamCount.value); printf("ObjectDescriptor.extensionFlag: %ld \n",objDescr.extensionFlag.value); } frameNumBit=0; bitRateLong=0; bitReservSize = 0; for (x=0;x<objDescr.streamCount.value;x++){ int frameNumBitLay, frameLength, celp_sys_align; initESDescr(&(objDescr.ESDescriptor[x])); advanceESDescr(bitStream,objDescr.ESDescriptor[x],0); fSampleLong=samplFreqIndex[objDescr.ESDescriptor[x]->DecConfigDescr.audioSpecificConfig.samplingFreqencyIndex.value]; frameLength = lpcframelength( &(objDescr.ESDescriptor[0]->DecConfigDescr.audioSpecificConfig.specConf.celpSpecificConfig) ); frameNumBitLay = objDescr.ESDescriptor[x]->DecConfigDescr.avgBitrate.value * frameLength / fSampleLong ; sn_ovrhd = objDescr.ESDescriptor[x]->ALConfigDescriptor.seqNumLength.value%8 ? 1:0; celp_sys_align = 8 - (frameNumBitLay % 8); if (celp_sys_align == 8) celp_sys_align = 0; frameNumBitLay += celp_sys_align + (3+sn_ovrhd)*8*(1 + (frameNumBitLay/2040)) ; /* overhead for flexMux transport */ frameNumBit += frameNumBitLay; bitRateLong += objDescr.ESDescriptor[x]->DecConfigDescr.avgBitrate.value; bitReservSize += objDescr.ESDescriptor[x]->DecConfigDescr.bufferSizeDB.value; } frameMinNumBit=0; length= BsCurrentBit(bitStream)/8; align = 8 - BsCurrentBit(bitStream) % 8; if (align == 8) align = 0; if (align != 0) { length += 1; } BsGetBit(bitStream,&(dummy),align) ; if ( (length-odStartByte) != objDescr.ODLength.value) CommonExit(-1,"error in object descriptor read"); bitReservInit= bitReservSize; bitHeaderNumBit=0; mode = MODE_LPC; numChannelOri=objDescr.ESDescriptor[0]->DecConfigDescr.audioSpecificConfig.channelConfiguration.value; frameData.od = &objDescr; } else { frameData.od = NULL; /* for qc_aac we read */ if (BsGetBitInt(bitStream,(unsigned int*)&bsVersion,16) || BsGetBitInt(bitStream,(unsigned int*)&numChannelOri,8) || BsGetBit(bitStream,(unsigned long*)&fSampleLong,32) || BsGetBit(bitStream,(unsigned long*)&bitRateLong,32) || BsGetBitInt(bitStream,(unsigned int*)&frameNumBit,16) || BsGetBitInt(bitStream,(unsigned int*)&frameMinNumBit,16) || BsGetBitInt(bitStream,(unsigned int*)&bitReservSize,16) || BsGetBitInt(bitStream,(unsigned int*)&bitReservInit,16) || BsGetBitInt(bitStream,(unsigned int*)&mode,8) || BsGetBitInt(bitStream,(unsigned int*)&bitHeaderNumBit,16)) CommonExit(1,"Decode: error reading bit stream header (frame)"); if (bsVersion != MP4_BS_VERSION) { CommonWarning("Decode: wrong bitstream version " "(found 0x%4x, need 0x%4x)",bsVersion,MP4_BS_VERSION); return 1; } } if (bitHeaderNumBit > BITHEADERBUFSIZE) CommonExit(1,"Decode: bit stream header too long"); if (BsGetBuffer(bitStream,bitHeader,bitHeaderNumBit)) CommonExit(1,"Decode: error reading bit stream header (core)"); } else{ /* Check if the bitstream has an ADIF header */ if ( GetAdifHeader(bitStream, &adifInfo)) { if ( mainDebugLevel >= 3 ) { printf ( "ADIF Header present\n" ); } numChannelOri = adifInfo.numChannels; fSampleLong = (long) adifInfo.samplingRate; bitRateLong = (long) adifInfo.bitrate; bitReservInit = (long) adifInfo.bitresFullnes; } else { /* raw data */ /* set the profile of the bitstream */ if( strstr( decPara, "-aac_raw" ) ) { if (strstr(decPara, "-main")) adifInfo.profile = Main_Profile; else if( strstr( decPara, "-ssr" ) ) adifInfo.profile = SSR_Profile; else adifInfo.profile = LC_Profile;#ifdef BODO_COMMENT printf ( "#################DECODING AAC RAW BITSTREAM:###########\n " ); printf ( "ATTENTIONE !!!!!!! \n make sure that you specify sampling" "freq and number of channels on cmdline: -s <samplFreq> -n <numchan>\n " ); #endif } numChannel = (numChannelOut != 0) ? numChannelOut : numChannelOri; numChannelOri=numChannel; fSampleLong= (long int) fSampleOut; if (fSampleLong < 8000 ){ CommonExit(-1,"\n wrong sample rate %d \n",fSampleLong); } bitRateLong=128000; } numChannel = numChannelOri; frameNumBit= 1024 * bitRateLong / fSampleLong; if (strstr(decPara, "-qc_aac_960") != NULL) frameNumBit = 960*bitRateLong/fSampleLong ; if (strstr(decPara, "-aac_sca") != NULL || strstr(decPara, "-aac_core_bsac") != NULL) frameNumBit = 960*bitRateLong/fSampleLong ; frameMinNumBit=0; bitReservSize= 6144*numChannel; /* 6144-1366; */ bitReservInit= 6144*numChannel; /* BT 971105 */ bitHeaderNumBit=0; mode = MODE_TF; } /* --- Set debugging options for aac_decoder --- */ /* if (strstr(decPara, "-qc_aac") != NULL){ extern int aacSamplingRate; aacSamplingRate = (int)fSampleLong; } */ /* if (aacDebugString != NULL){ */ /* aacDebugString */ /* } */ headerNumBit = BsCurrentBit(bitStream); frameMaxNumBit = frameNumBit+bitReservSize; fSampleOri = fSampleLong; bitRate = bitRateLong; if (decBitRate == 0) { decBitRate = bitRate; frameDecNumBit = 0; } else { if (decBitRate > bitRate) { CommonWarning("Decode: decBitRate > bitRate, using bitRate"); decBitRate = bitRate; } if (frameMinNumBit < frameNumBit) CommonExit(1,"Decode: scalability not possible for variable bit rate"); if (bitReservSize != 0) CommonExit(1,"Decode: scalability not possible for bit reservoir"); frameDecNumBit = (int)(frameNumBit/bitRate*decBitRate+.5); } if (regionDurat < 0) decNumFrame = -1; else decNumFrame = max(0,(int)(regionDurat*bitRate/frameNumBit)); decStartFrame = max(0,(int)(regionStart*bitRate/frameNumBit+.5)); numChannel = (numChannelOut != 0) ? numChannelOut : numChannelOri; fSample = (fSampleOut != 0) ? fSampleOut : fSampleOri; if(SpeedControlMode) { if(numChannel>1) { CommonWarning("Decode: " "numChannel>1 : PICOLA speed control is disabled\n"); SpeedControlMode = 0; } } PicolaNumSample = 0; if (mainDebugLevel >= 3) { printf("\nmode=%d (3=MODE_TF) \n",mode); printf("numChannelOri=%d\n",numChannelOri); printf("fSampleOri=%.3f Hz (int=%ld)\n",fSampleOri,fSampleLong); printf("numChannel=%d\n",numChannel); printf("fSample=%.3f Hz\n",fSample); printf("speedFact=%.3f",speedFact); if(SpeedControlMode) { printf(" :picola\n"); }else { printf("\n"); } printf("pitchFact=%.3f\n",pitchFact); printf("bitRate=%.3f bit/sec (int=%ld)\n",bitRate,bitRateLong); printf("bitReservSize=%d bit (%.6f sec)\n", bitReservSize,bitReservSize/bitRate); printf("bitReservInit=%d bit\n",bitReservInit); printf("frameNumBit=%d (%.6f sec)\n",frameNumBit,frameNumBit/bitRate); printf("frameDecNumBit=%d\n",frameDecNumBit); printf("frameMinNumBit=%d\n",frameMinNumBit); printf("frameMaxNumBit=%d\n",frameMaxNumBit); printf("bitHeaderNumBit=%d\n",bitHeaderNumBit); printf("headerNumBit=%d\n",headerNumBit); printf("decStartFrame=%d\n",decStartFrame); printf("decNumFrame=%d\n",decNumFrame); } if (testBitStream && frameNumBit != frameMinNumBit) CommonExit(1,"Decode: variable bit rate, bit stream test NOT possible!"); if (regionStart != 0 && frameNumBit != frameMinNumBit) CommonExit(1,"Decode: variable bit rate, start time MUST be 0!"); if (frameMaxNumBit > bitBufSize) CommonExit(1,"Decode: max bit stream frame size too long"); if (mode<=0 || mode>=MODE_NUM) CommonExit(1,"Decode: unknown codec mode %d",mode); codecMode = MP4ModeName[mode]; if (mainDebugLevel >= 3) printf("codecMode=\"%s\"\n",codecMode); if (strstr(decPara, "-mp4ff") != NULL || strstr(decPara, "-hvxc_sys") != NULL || /* AI 990616 */ strstr(decPara, "-celp_sys") != NULL ) { flexMuxDecInit ( &numChannel, decPara, &frameData, &tfData, &lpcData, &nttData, &hvxcData, /* AI 990616 */ audioFileName, &fSample ); if (strstr(decPara, "-hvxc_sys") != NULL) { /* delay compensation for HVXC(AI 99060XX) */ delayNumSample = hvxcData->delayNumSample; } else { delayNumSample=0; } } else { if (!testBitStream) { switch (mode) { case MODE_PAR: DecParInit(numChannel,fSample,decBitRate,decPara, bitHeader,&frameMaxNumSample,&delayNumSample ); break; case MODE_HVXC: hvxcData = DecHvxcInit(numChannel, fSample, decBitRate, decPara, bitHeader, &frameMaxNumSample, &delayNumSample ); break; case MODE_LPC: DecLpcInit(numChannel,fSample,decBitRate,decPara, bitHeader,&frameMaxNumSample,&delayNumSample); break; case MODE_G729: DecG729Init(numChannel,fSample,decBitRate, &frameMaxNumSample,&delayNumSample); break; case MODE_G723: DecG723Init(numChannel,fSample,decBitRate,decPara, &frameMaxNumSample,&delayNumSample); break; case MODE_TF: if (!aacEOF) { CommonWarning("Decode: option '-aaceof' is recommended in AAC mode"); } DecTfInit ( numChannel, fSample, decBitRate, decPara, adifInfo.profile, bitHeader, &frameMaxNumSample, &delayNumSample, aacDebugString, &hVm, &hHcrSpecData, (frameData.od == NULL ? NULL : &frameData), &tfData, &nttData, mainDebugLevel ); hFault->hVm = hVm ; hFault->hHcrSpecData =hHcrSpecData ; hFault->hHcrInfo =hHcrInfo ; hFault->hEpInfo = hEpInfo ; hFault->hConcealment = hConcealment ; hFault->hResilience = hResilience ; break; } } /* if (!testBitStream) */ } /* speed control initialization */ if(SpeedControlMode) PicolaInit(frameMaxNumSample, fSample, speedFact); BsFreeBuffer(bitHeader); if (!testBitStream) { if (strstr(decPara, "-mp4ff") == NULL && strstr(decPara, "-celp_sys") == NULL && strstr(decPara, "-hvxc_sys") == NULL) { /* AI 990616 */ if (mainDebugLevel >= 3) { printf("frameMaxNumSample=%d (%.6f sec/frame)\n", frameMaxNumSample,frameMaxNumSample/fSample); printf("delayNumSample=%d (%.6f sec)\n", delayNumSample,delayNumSample/fSample); } /* allocate buffers */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -