我正在尝试使用libfdk_aac解码AAC编码文件。该文件由使用libfdk_aac生成的原始AAC-LC ADTS数据包流组成。我确信数据格式正确,因为我可以使用VLC和Window Media Player播放文件。
这是我的设置:
UCHAR* inputBuffer = new UCHAR[ 2048 ] ;
UINT bufSize[] = { 0 } ;
INT_PCM* outputBuffer = new INT_PCM[ 4096 ] ;
int outputbufSize = 8192 ;
UINT flags = 0 ;
//Set up the Audio Specific Config
UCHAR* asc = new UCHAR[ 2 ] ;
asc[ 0 ] = (UCHAR) 0x11 ;
asc[ 1 ] = (UCHAR) 0x90 ;
UINT ascSize[] = { 2 } ;
HANDLE_DECODER decoder = aacDecoder_Open( TT_MP4_ADTS, 1 ) ;
AAC_DECODER_ERROR aacError = aacDecoder_ConfigRaw( decoder, &asc, ascSize ) ;
if( aacError )
{
printf( "Configure error\n" ) ;
exit( -1 ) ;
}
int dataAvailable = 1 ;
do
{
//Reads the file and gets the next ADTS packet with one AAC frame
unsigned int adtsPacketSize ;
dataAvailable = readMPEGFile( filePtr, inputBuffer, &adtsPacketSize ) ;
bufSize[ 0 ] = adtsPacketSize ;
aacError = aacDecoder_Fill( decoder, &inputBuffer, bufSize, &bytesValid ) ;
//Check to see if bytesValid == 0
//If bytesValid > 0, keep calling aacDecoder_Fill()
//If bytesValid == 0, decode audio
aacError = aacDecoder_DecodeFrame( decoder, outputBuffer, outputBufSize, flags ) ;
//If no error, write raw PCM data to file.
}while( dataAvailable ) ;
问题是aacDecoder_DecodeFrame继续返回AAC_DEC_NOT_ENOUGH_BITS。调用aacDecoder_GetFreeBytes()表明内部缓冲区没有获取任何输入数据。有关为什么会发生这种情况的任何想法?
答案 0 :(得分:-1)
frame size * channel counts
(e.g. Adobe Audition)