1. AAC的音频文件格式有ADIF & ADTS:
以ADTS为例:
头信息包含7个字节分别为:
syncword
同步字
syncword
同步字
syncword 同步字 0XFFF
profile 表示使用哪个级别的AAC,如01 Low Complexity(LC)--- AACLC
sampling_frequency_index 表示使用的采样率下标
channel_configuration 表示声道数
固定ADTS长度为30位
如果需要获得帧的大小需要:31到44位共(13)位的数据
第三个字节的后两位+第四个字节的全部位数+第五个字节的头三位
/* 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.
之后的信息都是编码后的数据,只要按照相应的数据反过来解码就好了吧?
http://blog.csdn.net/leixiaohua1020/article/details/50535042
(雷大大的博客)