AAC ADTS LATM Format analysis

Source: Internet
Author: User
Tags reserved

AAC ADTS LATM format Analysis

 

one, Adts format :

The full name of Adts is the audio Data Transport Stream. is the transport stream format for AAC audio.

The AAC audio format is defined in MPEG-2 (ISO-13318-7 2003). AAC was later adopted in the MPEG-4 standard.

1. Adts_sequence ()

{

while (nextbits () = = Syncword) {

Adts_frame ();

}

}

2. Adts_frame ()

{

Adts_fixed_header ();

Adts_variable_header ();

if (Number_of_raw_data_blocks_in_frame = = 0) {

Adts_error_check ();

Raw_data_block ();

}

else {

Adts_header_error_check ();

for (i = 0; I <= number_of_raw_data_blocks_in_frame; i++) {

Raw_data_block ();

Adts_raw_data_block_error_check ();

}

}

}

3.

Adts_fixed_header ()

{

Syncword; bslbf

ID; 1 bslbf

Layer 2 UIMSBF

Protection_absent; 1 bslbf

Profile 2 UIMSBF

Sampling_frequency_index; 4 UIMSBF

Private_bit; 1 bslbf

Channel_configuration; 3 UIMSBF

Original/copy; 1 bslbf

Home 1 bslbf

}

Adts_variable_header ()

{

Copyright_identification_bit; 1 bslbf

Copyright_identification_start; 1 bslbf

Frame_length; bslbf

adts_buffer_fullness; bslbf

Number_of_raw_data_blocks_in_frame; 2 UIMSFB

}

Detailed description of the important data section of the Adts head:

Syncword Sync Word The bit string ' 1111 1111 1111 ', which illustrates the beginning of a Adts frame.

ID MPEG designator, set to 1.

Layer indicates which layer is used. Set to ' 00 '

Protection_absent Indicates whether the error check

Profile indicates which level of AAC to use, such as complexity Low (LC)---AACLC

Sampling_frequency_index indicates the sample rate subscript used

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 indicates the number of channels

Frame_length the length of a Adts frame includes the Adts header and the raw data block.

Adts_buffer_fullness 0x7ff Description is a code stream with variable rate

Number_of_raw_data_blocks_in_frame

Indicates that there are Number_of_raw_data_blocks_in_frame + 1 AAC original frames in the Adts frame.

So number_of_raw_data_blocks_in_frame = = 0 says that there is an AAC data block in the Adts frame that doesn't say no. (An AAC original frame contains 1024 samples and related data over a period of time)

Second, package AAC for Adts frame

The length of an AAC raw block is variable, and a Adts frame is formed by Adts the original frame plus the Adts header. Usually we will get the AAC original frame after encapsulation to write to the file, with the usual players such as listening to play, this is a way to verify that the AAC data is correct.

Before encapsulation, you need to know the relevant parameters, such as sample rate, number of channels, length of original data block, etc.

The following is the AAC raw data frame processing as Adts frame, according to the relevant parameters to complete the composition of the 7-byte Adts head.

The 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 through a full byte */

Adts_header[0] = 0xFF;

/* 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.