ADTS
If the data is to be streamed within an MPEG-2 transport stream, a self-synchronizing format called an Audio Data Transport Stream (ADTS) is used, consisting of a series of frames, each frame having a header followed by the AAC audio data.
- ADTS由一連串的ADTS Frame組成.
- 每個(gè)Frame由ADTS Header和AAC audio data組成.
用AAC Audio ES Viewer
工具打開一個(gè).aac
文件進(jìn)行分析:
ADTS的每一幀都有頭信息彰导,上圖中綠色的7個(gè)字節(jié)為當(dāng)前adts_frame
的ADTS Header
, 前三個(gè)字節(jié)0xFFF
為同步字符.
adts_sequence
adts_frame
一個(gè)AAC原始數(shù)據(jù)塊長度是可變的,對(duì)原始幀加上ADTS頭進(jìn)行ADTS的封裝,就形成了ADTS幀.
adts_fixed_header
syncword **
總是0xFFF
, 代表一個(gè)ADTS幀的開始, 用于同步.
解碼器可通過0xFFF
確定每個(gè)ADTS的開始位置.
因?yàn)樗拇嬖冢獯a可以在這個(gè)流中任何位置開始, 即可以在任意幀解碼**哥牍。ID
MPEG Version: 0 for MPEG-4, 1 for MPEG-2layer
always: '00'protection_absent
Warning, set to 1 if there is no CRC and 0 if there is CRC
-
profile
表示使用哪個(gè)級(jí)別的AAC芽隆,如01 Low Complexity(LC) -- AAC LC
profile的值等于 Audio Object Type的值減1.
profile = MPEG-4 Audio Object Type - 1
-
sampling_frequency_index
采樣率的下標(biāo).
采樣率的下標(biāo)與采樣率對(duì)應(yīng)
通過上表可查詢出下標(biāo)對(duì)應(yīng)的采樣率.
比如sampling_frequency_index=5
對(duì)應(yīng)的采樣率為32000
.
-
channel_configuration
聲道數(shù). 比如2
表示立體聲雙聲道.
channel_configuration
adts_variable_header
-
aac_frame_length
一個(gè)ADTS幀的長度包括ADTS頭和AAC原始流.
frame length, this value must include 7 or 9 bytes of header length:
aac_frame_length = (protection_absent == 1 ? 7 : 9) + size(AACFrame)
protection_absent=0時(shí), header length=9bytes
protection_absent=1時(shí), header length=7bytes
adts_buffer_fullness
0x7FF 說明是碼率可變的碼流.number_of_raw_data_blocks_in_frame
表示ADTS幀中有number_of_raw_data_blocks_in_frame + 1個(gè)AAC原始幀.
所以說number_of_raw_data_blocks_in_frame == 0 表示說ADTS幀中有一個(gè)AAC數(shù)據(jù)塊。
(一個(gè)AAC原始幀包含一段時(shí)間內(nèi)1024個(gè)采樣及相關(guān)數(shù)據(jù))
References:
13818-7(AAC).pdf
http://www.cnblogs.com/caosiyang/archive/2012/07/16/2594029.html
http://blog.csdn.net/bsplover/article/details/7426476
http://www.reibang.com/p/0bff0fc2bf28
http://blog.csdn.net/whygosofar/article/details/4853743
https://wiki.multimedia.cx/index.php?title=ADTS