1、 raw_data_block(); else adts_header_error_check(); for (i = 0; i <= number_of_raw_data_blocks_in_frame; i+) adts_raw_data_block_error_check(); 3. adts_fixed_header() syncword: 12 bslbf ID: 1 bslbf layer: 2 uimsbf protection_absent: profile: sampling_frequency_index: 4 uimsbf private_bit: channel_
2、configuration: 3 uimsbf original/copy: home: adts_variable_header() copyright_identification_bit: copyright_identification_start: frame_length: 13 bslbf adts_buffer_fullness: 11 bslbf number_of_raw_data_blocks_in_frame: 2 uimsfb 详细说明下ADTS头的重要数据部分: syncword 同步字The bit string 1111 1111 1111,说明一个ADTS帧的
3、开始。 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
4、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原
5、始帧. 所以说number_of_raw_data_blocks_in_frame = 0 表示说ADTS帧中有一个AAC数据块并不是说没有。(一个AAC原始帧包含一段时间内1024个采样及相关数据) 二 封装AAC为ADTS帧 一个AAC原始数据块长度是可变的,对原始帧加上ADTS头进行ADTS 的封装,就形成了ADTS帧。通常我们将得到的AAC原始帧进行封装后写入文件,用常用的播放器如千千静听即可播放,这是个验证AAC数据是否正确的方法。 进行封装前,需要了解相关参数,如采样率,声道数,原始数据块的长度等。下面把AAC原始数据帧加工为ADTS帧,据相关参数填写组成7字节的ADTS头。 Th
6、e ADTS header is defined below - 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_header0
7、= 0xFF; /* Sync point continued over first 4 bits + static 4 bits * (ID, layer, protection)*/ adts_header1 = 0xF9; /* Object type over first 2 bits */ adts_header2 = obj_type & 6;/ /* rate index over next 4 bits */ adts_header2 |= (rate_idx & 2); /* channels over last 2 bits */ adts_header2 |= (chan
8、nels & 0x4) > 2; /* channels continued over next 2 bits + 4 bits at zero */ adts_header3 = (channels & 0x3) & /* frame size over last 2 bits */ adts_header3 |= (frame_length & 0x1800) & 11; /* frame size continued over full byte */ adts_header4 = (frame_length & 0x1FF8) & 3; /* frame size con
9、tinued first 3 bits */ adts_header5 = (frame_length & 0x7) & 5; /* buffer fullness (0x7FF for VBR) over 5 last bits*/ adts_header5 |= 0x1F; /* buffer fullness (0x7FF for VBR) continued over 6 first bits + 2 zeros * number of raw data blocks */ adts_header6 = 0xFC;/ one raw data blocks . adts_header6
10、 |= num_data_block & 0x03; /Set raw Data blocks. 在CMMB中,采用AAC音频压缩标准,默认状况下,编码参数如下:双声道,采样率24KHZ,帧长变长,码流可变码率的码流,一般采用的AAC profile为AAC-LC。将从CMMB复用帧解析的一个AAC原始帧封装为ADTS帧的方法如下:uint8 aac_bufADTS_FRAME_SIZE=0x0ff,0x0f9,0x058,0x80,0,0x1f,0xfc; 从上述7个字节分析音频参数如下: synword-0xfff 0x1- 1- MPEG2 identifier, LAYER-00 pr
11、otection_absent -01 profile-01 1 Low Complexity profile (LC) AAC-LC smaping_freuency_index-0110-&0x06-&采样率24KHZ channel_configuration - aac_buf3 = 0x08-&2-&双声道。 adts_buffer_fullness-&0x7ff 码率可变的码流 现插入长度参数 wDataLen; void OnAudioAacFrame(byte* data, uint16 wDataLen) unsigned int num_data_block = wData
12、Len / 1024; uint16 frame_Length; frame_Length = wDataLen + 7; aac_buf3 |= (frame_length &/ the upper 2 bit aac_buf4 = (frame_length &/ the middle 8 bit aac_buf5 |= (frame_length &/the last 3 bit aac_bug6 |= num_data_block & emcpy(&aac_buf7,data,wDataLen); /形成一个ADTS帧写入文件。 fwrite(aac_buf,wDataLen+7,sizeof(byte),f_audio);三 LATM格 LATM 的全称为“Low-overhead MPEG-4 Audio TransportMultiplex”(低开销音频传输复用),是MPEG-4 AAC制定的一种高效率的码流传输方式,MPEG
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1