在网上找了些关于AAC的资料,整理了一下。 1.http://forum./showthread.php?t=68300 该论坛介绍了很多关于音频解码的知识,写得十分详细,连最基本的有损、无损压缩之类的概念都介绍,当然还有我们关注的AAC。 2.http://www./dvdrip/2006-8-7_14-34-29_2161.html 这篇文章更多是的是对上一网址中的内容的中文翻译,新内容不多 AAC编解码器的开源代码,在之前两篇文章中都有提到。FAAC编码器,FAAD2是解码器。FAAD2中的一些工程文件在VC2008可以直接编译。 包含了AAC编解码器的二进制文件,可以直接运行。 5.http://blog.csdn.net/wlsfling/article/details/5876016 http:///document/audiocomp/0000207.asp 两篇帖子的内容大部分一样,介绍了AAC文件的格式以及解码流程,写得很详细,后一篇有附解码过程中各模块的流程图。 6.http://d.wanfangdata.com.cn/Thesis_Y1035282.aspx 万方上一篇MPEG-4 AAC解码器在DSP上实现的论文,还没有看完,对解码过程以及一些音频编码中的名词讲得很详细,还提出了在DSP上优化的思路。 还有一篇题目为《MPEG.2 AAC音频编码技术及其软件解码器的实现》,提到了解码播放的实现方案,今后可能会用到。 7.http://www./a/201005/9402.html 提供了ISO/IEC 13818-7 Part 7: Advanced Audio Coding (AAC)和ISO/IEC 14496-3 Information technology — Coding of audio-visual objects — Part 3: Audio 标准的PDF文档下载。
几个常见的问题: 1.何为采样率和比特率? 简单来讲,采样率和比特率就像是坐标轴上的横纵坐标。
参考链接:http://wenwen.soso.com/z/q114521200.htm ,该帖子还介绍了CBR/VBR/ABR相关的概念。
2.ADTS格式的AAC文件,一帧的大小是多少,如何计算? 1)ADTS header位于每一个aac帧的开头。 参考链接:http://tieba.baidu.com/f?kz=577031287
3.ADTS格式:(参考链接:http://honwsn./post/41648/497237) ADTS的全称是Audio Data Transport Stream。是AAC音频的传输流格式。 AAC音频格式在MPEG-2(ISO-13318-7 2003)中有定义。AAC后来又被采用到MPEG-4标准中。 1. adts_sequence() { while (nextbits() == syncword) { } 2. adts_frame() { } 3. adts_fixed_header() { } adts_variable_header() { } 详细说明下ADTS头的重要数据部分: syncword 同步字The bit string ‘1111 1111 1111’,说明一个ADTS帧的开始。 ID MPEG 标示符, 设置为1. layer Indicates which layer is used. Set to ‘00’ protection_absent 表示是否误码校验 profile 表示使用哪个级别的AAC,如01 Low Complexity(LC)--- AACLC sampling_frequency_index 表示使用的采样率下标 sampling_frequency_index sampling frequeny [Hz] 0x0 96000 0x1 88200 0x2 64000 0x3 48000 0x4 44100 0x5 32000 0x6 24000 0x7 22050 0x8 16000 0x9 2000 0xa 11025 0xb 8000 0xc reserved 0xd reserved 0xe reserved 0xf reserved channel_configuration 表示声道数 frame_length 一个ADTS帧的长度包括ADTS头和raw data block. adts_buffer_fullness 0x7FF 说明是码率可变的码流 number_of_raw_data_blocks_in_frame 表示ADTS帧中有number_of_raw_data_blocks_in_frame + 1个AAC原始帧. 所以说number_of_raw_data_blocks_in_frame == 0 表示说ADTS帧中有一个AAC数据块并不是说没有。
一个AAC原始数据块长度是可变的,对原始帧加上ADTS头进行ADTS 的封装,就形成了ADTS帧。通常我们将得到的AAC原始帧进行封装后写入文件,用常用的播放器如千千静听即可播放,这是个验证AAC数据是否正确的方法。 进行封装之前,需要了解相关参数,如采样率,声道数,原始数据块的长度等。 下面是把AAC原始数据帧加工为ADTS帧,根据相关参数填写组成7个字节的ADTS头。
unsigned int obj_type = 0; unsigned int num_data_block = frame_length / 1024; // include the header length also frame_length += 7; /* We want the same metadata */ /* Generate ADTS header */ if(adts_header == NULL) return; /* Sync point over a full byte */ adts_header[0] = 0xFF; /* Sync point continued over first 4 bits + static 4 bits * (ID, layer, protection)*/ adts_header[1] = 0xF9; /* Object type over first 2 bits */ adts_header[2] = obj_type << 6;// /* rate index over next 4 bits */ adts_header[2] |= (rate_idx << 2); /* channels over last 2 bits */ adts_header[2] |= (channels & 0x4) >> 2; /* channels continued over next 2 bits + 4 bits at zero */ adts_header[3] = (channels & 0x3) << 6; /* frame size over last 2 bits */ adts_header[3] |= (frame_length & 0x1800) >> 11; /* frame size continued over full byte */ adts_header[4] = (frame_length & 0x1FF8) >> 3; /* frame size continued first 3 bits */ adts_header[5] = (frame_length & 0x7) << 5; /* buffer fullness (0x7FF for VBR) over 5 last bits*/ adts_header[5] |= 0x1F; /* buffer fullness (0x7FF for VBR) continued over 6 first bits + 2 zeros * number of raw data blocks */ adts_header[6] = 0xFC;// one raw data blocks . adts_header[6] |= num_data_block & 0x03; //Set raw Data blocks.
uint8 aac_buf[ADTS_FRAME_SIZE]={0x0ff,0x0f9,0x058,0x80,0,0x1f,0xfc}; 从上述7个字节分析音频参数如下: synword--0xfff ID:0x1--- 1--- MPEG2 identifier, LAYER--00 protection_absent ---01 profile--01 1 Low Complexity profile (LC) AAC-LC smaping_freuency_index---0110-->0x06--->采样率24KHZ channel_configuration --- aac_buf[3] = 0x08---->2---->双声道。。 adts_buffer_fullness--->0x7ff 码率可变的码流 现插入长度参数 wDataLen; void OnAudioAacFrame(byte* data, uint16 wDataLen) { } |
|