/**
* 添加ADTS头
* 一帧AAC+7 = packetLen
* @param packet
* @param packetLen
*/
private void addADTStoPacket(byte[] packet, int packetLen) {
int profile = 2; // AAC LC
int freqIdx = 8; // 16KHz
int chanCfg = 1; // CPE
// fill in ADTS data
packet[0] = (byte) 0xFF;
packet[1] = (byte) 0xF1;
packet[2] = (byte) (((profile - 1) << 6) + (freqIdx << 2) + (chanCfg >> 2));
packet[3] = (byte) (((chanCfg & 3) << 6) + (packetLen >> 11));
packet[4] = (byte) ((packetLen & 0x7FF) >> 3);
packet[5] = (byte) (((packetLen & 7) << 5) + 0x1F);
packet[6] = (byte) 0xFC;
}
- profile:表示使用哪个级别的AAC,如01 Low Complexity(LC) -- AAC LC
profile的值等于 Audio Object Type的值减1.
profile = MPEG-4 Audio Object Type - 1
sampling_frequency_index:采样率的下标
- channel_configuration:声道数,比如2表示立体声双声道

本文深入解析AAC音频编码中ADTS头的添加过程,包括关键参数profile、sampling_frequency_index及channel_configuration的作用与设置方法,为理解AAC编码帧结构提供详实的技术指导。

2270

被折叠的 条评论
为什么被折叠?



