ADTS-AAC文件头信息

一、AAC文件头信息

syncword :同步头代表着1个ADTS帧的开始,所有bit置1,即 0xFFF
ID:MPEG标识符,0标识MPEG-4,1标识MPEG-2
Layer: 直接置00
protection_absent:表示是否误码校验。1 no CRC , 0 has CRC
profile:AAC 编码级别, 0: Main Profile, 1:LC(最常用), 2: SSR, 3: reserved.
sampling_frequency_index:采样率标识
Private bit:直接置0,解码时忽略这个参数
channel_configuration: 声道数标识
original_copy: 直接置0,解码时忽略这个参数
home:直接置0,解码时忽略这个参数
 

二、profile(Audio Object Types)


MPEG-4 Audio Object Types:

0: Null
1: AAC Main
2: AAC LC (Low Complexity)
3: AAC SSR (Scalable Sample Rate)
4: AAC LTP (Long Term Prediction)
5: SBR (Spectral Band Replication)
6: AAC Scalable
7: TwinVQ
8: CELP (Code Excited Linear Prediction)
9: HXVC (Harmonic Vector eXcitation Coding)
10: Reserved
11: Reserved
12: TTSI (Text-To-Speech Interface)
13: Main Synthesis
14: Wavetable Synthesis
15: General MIDI
16: Algorithmic Synthesis and Audio Effects
17: ER (Error Resilient) AAC LC
18: Reserved
19: ER AAC LTP
20: ER AAC Scalable
21: ER TwinVQ
22: ER BSAC (Bit-Sliced Arithmetic Coding)
23: ER AAC LD (Low Delay)
24: ER CELP
25: ER HVXC
26: ER HILN (Harmonic and Individual Lines plus Noise)
27: ER Parametric
28: SSC (SinuSoidal Coding)
29: PS (Parametric Stereo)
30: MPEG Surround
31: (Escape value)
32: Layer-1
33: Layer-2
34: Layer-3
35: DST (Direct Stream Transfer)
36: ALS (Audio Lossless)
37: SLS (Scalable LosslesS)
38: SLS non-core
39: ER AAC ELD (Enhanced Low Delay)
40: SMR (Symbolic Music Representation) Simple
41: SMR Main
42: USAC (Unified Speech and Audio Coding) (no SBR)
43: SAOC (Spatial Audio Object Coding)
44: LD MPEG Surround
45: USAC
 

三、Sampling Frequencies


There are 13 supported frequencies:

0: 96000 Hz
1: 88200 Hz
2: 64000 Hz
3: 48000 Hz
4: 44100 Hz
5: 32000 Hz
6: 24000 Hz
7: 22050 Hz
8: 16000 Hz
9: 12000 Hz
10: 11025 Hz
11: 8000 Hz
12: 7350 Hz
13: Reserved
14: Reserved
15: frequency is written explictly
 

typedef struct
{
	unsigned syncword : 12;
	unsigned ID : 1;
	unsigned layer : 2;
	unsigned protection_absent : 1;
	unsigned profile : 2;
	unsigned sampling_frequency_index : 4;
	unsigned private_bit : 1;
	unsigned channel_configuration : 3;
	unsigned original_copy : 1;
	unsigned home : 1;
	//variable
	unsigned copyright_identification_bit : 1;
	unsigned copyright_identification_start : 1;
	unsigned acc_frame_length : 13;
	unsigned adts_buffer_fullness : 11;
	unsigned number_of_raw_data_blocks_in_frame : 2;
} aac_adts_fixed_header_t;


int get_aac_header_from_adts(char *buf, int len, aac_adts_fixed_header_t *header)
{
	// 使用位操作解析 ADTS 固定头部
	header->syncword = ((buf[0] & 0x0F) << 8) | buf[1];
	header->ID = (buf[1] >> 3) & 0x01;
	header->layer = (buf[1] >> 1) & 0x03;
	header->protection_absent = buf[1] & 0x01;
	header->profile = (buf[2] >> 6) & 0x03;
	header->sampling_frequency_index = (buf[2] >> 2) & 0x0F;
	header->private_bit = (buf[2] >> 1) & 0x01;
	header->channel_configuration = ((buf[2] & 0x01) << 2) | (buf[3] >> 6);
	header->original_copy = (buf[3] >> 5) & 0x01;
	header->home = (buf[3] >> 4) & 0x01;
	header->copyright_identification_bit = (buf[3] >> 3) & 0x01;
	header->copyright_identification_start = (buf[3] >> 2) & 0x01;
	header->acc_frame_length = ((buf[3] & 0x03) << 11) | (buf[4] << 3) | (buf[5] >> 5);
	header->adts_buffer_fullness = ((buf[5] & 0x1F) << 6) | (buf[6] >> 2);
	header->number_of_raw_data_blocks_in_frame = buf[6] & 0x03;

	return 0;
}
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值