AAC音频格式_笔记

参考文章:

AAC音频数据的两种格式

https://blog.csdn.net/coloriy/article/details/52048353

ADTS头文件信息介绍

https://blog.csdn.net/jay100500/article/details/52955232/

ADTS格式分析

http://www.360doc.com/content/15/1022/17/9075092_507596875.shtml

==================================================================================

AAC音频数据有两种格式:

1  ADTS(Audio Data Transport Stream)传输流格式

 

一个AAC原始数据块长度是可变的,对原始帧加上ADTS头进行ADTS 的封装,就形成了ADTS帧,通常将AAC原始帧进行封装后写入文件就可以用播放器播放,用来验证AAC是否正确

ADTS头有7Byte:

       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原始帧包含一段时间内1024个采样及相关数据)

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;    // 同步字,表示一帧开始,固定是 0xff 0xfx 
/* 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. 

 

你可能感兴趣的:(音频编解码)