H264 Format Specific Description

Source: Internet
Author: User

A 1.1-element hierarchical structure of the syntax of H. A bit stream of encoder output, each bit is subordinate to some syntactic element. Syntactic elements are organized into hierarchical structures that describe each of the two H syntax
1.1 Element Hierarchy

In the bit stream of the encoder output, each bit is subordinate to a syntactic element. Syntactic elements are organized into hierarchical structures that describe each level of information.



Figure 1

The layered structure consists of five layers, each of which is a sequence parameter set, an image parameter set, a slice (Slice), a Hong, and a sub-block. The set of parameters is a separate unit of data that does not depend on other syntactic elements outside the set of parameters. Figure 2 describes the relationship between the set of parameters and the syntactic elements outside the set.





Figure 2

A set of parameters is incorrect for a particular image or sequence, and the same set of parameters can be referenced by multiple sets of image parameters, so the same set of image parameters can be referenced by multiple images. A new set of parameters is emitted only when the encoder feels the need to update the contents of the set.



In H. I, the image is organized in sequence. The first image of a sequence is called the IDR image, the IDR image is an I-frame, and the IDR image is introduced in order to decode the synchronization, when the decoder decoding to the IDR image, the reference frame queue is immediately emptied, the decoded data all output or discard, and once again find the parameter set, start a new sequence. Thus, assuming a significant error in the previous sequence, there is an opportunity to get another synchronization here. The image after the IDR image is never decoded using the data from the image before the IDR.



IDR is an i-frame, but I-frames are not necessarily IDR. The image after the I-frame may use the image before the I-Frame for motion reference.


1.2 Descriptive narrations

Descriptive narrative describes the method of extracting syntactic elements from a bit stream.
Number
Grammar
Description

1
AE (e)
CABAC

2
B (8)
Read into a continuous 8 bit

3
CE (v)
Ca VLC

4
F (N)
Read into a continuous n-bit

5
I (n)/I (v)
Read in successive bits and interpret them as signed integers

6
Me (v)
Mapping exponential Golomb entropy coding

7
Se (v)
Symbolic exponential Golomb entropy coding

8
Te (v)
Truncated exponential Golomb entropy coding

9
U (n)/U (v)
Read in successive bits and interpret them as unsigned integers

10
UE (v)
Golomb entropy coding of unsigned exponential


Table 1
1.3 Representation of syntax

The name of the syntactic element consists of a lowercase letter and a series of underscores, and the variable name is made up of uppercase and lowercase letters with no underscores in the middle.
Two syntax table

It defines the syntax of H. A, indicates the syntactic elements appearing in sequence in the code stream, the conditions in which they appear, and the extraction of descriptive narratives. Syntactic tables are layered and nested.

The C field in the syntax table represents the classification of the syntactic element, which is the detailed meaning of the classification for the patch service, such as the following table descriptive narrative.
Nal_unit_type
NAL type
C

0
Not used


1
Non-partitioned, not IDR slices
2,3,4

2
Slice partition A
2

3
Slice partition B
3

4
Edition partition C
4

5
Slices in an IDR image
2,3

6
Supplemental Enhancement Information Unit (SEI)
5

7
Set of sequence parameters
0

8
Set of image parameters
1

9
Delimiter
6

10
End of sequence
7

11
End of code stream
8

12
Fill
9

13..23
Keep


24..31
Do not retain



Table 2
2.1 NAL Syntax

The encoder will each nal separate, complete into a group, because the packet has a head, the decoder can easily detect the demarcation of the NAL, and then remove the nal to decode.

Each nal has a starting code 0x000001, the decoder detects each starting code, as a nal of the beginning of the identification, when detected to the next starting code, the current NAL end. At the same time, it is stipulated that when the 0x000000 is detected, it can also characterize the end of the current nal. When the data in the NAL is 0x000001 or 0x000000, H. X introduces a competition prevention mechanism, assuming that the encoder detects 0x000001 or 0x000000 of NAL data, the encoder inserts a new byte 0x03 before the last byte, so:

0x000000->0x00000300

0x000001->0x00000301

0x000002->0x00000302

0x000003->0x00000303

When the decoder detects the 0x000003, it discards the 03 and restores the original data.

When decoding, the decoder first reads nal data in bytes, counts the length of the NAL, and then starts decoding.


Syntactic
C
Desc

Nal_nuit (Numbytesinnalunit) {/* Numbytesinnalunit is the data length of the statistic */



Forbidden_zero_bit/* equals 0 */
All
F (1)

nal_ref_idc/* current NAL priority, value range 0-3 */
All
U (2)

Nal_unit_type/* nal type, see table 2 descriptive narrative */
All
U (5)

Numbytesinrbsp=0



for (i=1;i<numbytesinnalunit;i++) {



if (i+2<numbytesinnalunit && next_bits) ==0x000003{



/* 0x000003 pseudo-start code, need to delete 0x03 this byte */



rbsp_byte[numbytesinrbsp++]
All
B (8)

rbsp_byte[numbytesinrbsp++]
All
B (8)

i+=2/* after removing the first two 0x00, skip 0x03 */



emulation_prevention_three_byte/* equal to 0x03 */
All
F (8)

}else{



rbsp_byte[numbytesinrbsp++]/* Continue reading the following bytes */
All
B (8)

}



}




Table 3
2.2 Sequence set of parameters (SPS)
Syntactic
C
Desc

SEQ_PARAMETER_SET_RBSP () {



profile_idc/* specify the profile to use */
0
U (8)

Constraint_set0_flag
0
U (1)

Constraint_set1_flag
0
U (1)

Constraint_set1_flag
0
U (1)

Reserved_zero_5bits/* equal to 0 */
0
U (5)

LEVEL_IDC/* Indicates the level used */
0
U (8)

SEQ_PARAMETER_SET_ID/* Indicates the ID number of this sequence of parameters, 0-31, is referenced by the image set, and the encoding needs to produce a new sequence set, using the new ID instead of changing the contents of the original set of parameters */
0
UE (v)

log2_max_frame_num_minus4/* to read the element Frame_num service, Frame_num identify the decoding order of the image, Frame_num decoding function is the UE (v), in which v=log2_max_frame_num_ Minus4+4, this element indicates the maximum value of frame_num at the same time maxframenum=2 (log2_max_frame_num_minus4+4) */
0
UE (v)

Pic_order_cnt_type/* Indicates the POC encoding method, POC identifies the order in which the images are played, the POC can be computed by the frame_num, and can also display the transmission. Three ways to calculate POC */
0
UE (v)

if (pic_order_cnt_type==0)



LOG2_MAX_PIC_ORDER_CNT_LSB_MINUS4/* Indicates the value of the variable maxpicordercntlsb, maxpicordercntlsb=2 (log2_max_pic_order_cnt_lsb_ MINUS4+4) */
0
UE (v)

else if (pic_order_cnt_type==1) {



Delta_pic_order_always_zero_flag/* equals 1 o'clock, elements delta_pic_order_cnt[0] and delta_pic_order_cnt[1] do not appear in the title, and their default value is 0, equal to 0 o'clock, The above two elements appear in the title of */
0
U (1)

Offset_for_non_ref_pic/* Used to calculate non-reference frames or fields poc,[-231,231-1] */
0
Se (v)

offset_for_top_to_bottom_field/* Calculate the base field of the frame for POC */
0
Se (v)

Num_ref_frames_inpic_order_cnt_cycle/* Used to decode poc,[0.255] */
0
UE (v)

for (i=0;i<num_ref_frames_inpic_order_cnt_cycle;i++)



offset_for_ref_frame[i]/* is used to decode the POC, specifying an offset for each element in the loop */
0
Se (v)

}



Num_ref_frames/* The maximum length that the frame queue can reach, [0,16] */
0
UE (v)

Gaps_in_frame_num_value_allowed_flag/* For 1, agree slice header in the frame_num discontinuous */
0
U (1)

PIC_WIDTH_INMBS_MINUS1/* This element adds 1, indicating the width of the image in the macro block picwidthinmbs=pic_width_in_mbs_minus1+1 */
0
UE (v)

PIC_HEIGHT_IN_MAP_UNITS_MINUS1/* This element adds 1, indicating the high width of the image in the macro block picheightinmapunitsmbs=pic_height_in_map_units_minus1+1 */
0
UE (v)

Frame_mbs_only_flag/* equals 0 means that all images in this sequence are frame encoded, equal to 1, that may be frames, or field or frame fields are adaptive, and detailed encoding is determined by other elements. Combining the previous element: Frameheightinmbs= (2-frame_mbs_only_flag) *picheightinmapunits */
0
UE (v)

if (Frame_mbs_only_flag)



Mb_adaptiv_frame_field_flag/* Indicates whether this sequence is a frame-field adaptive mode:

Frame_mbs_only_flag=1, all frames are

Frame_mbs_only_flag=0, mb_adaptiv_frame_field_flag=0, frame field coexistence

Frame_mbs_only_flag=0, mb_adaptiv_frame_field_flag=1, Frame field adaptive and field coexistence */
0
U (1)

Direct_8x8_inference_flag/* is used to indicate the calculation of motion vectors in the direct and skip modes of the B-slice */
0
U (1)

Frame_cropping_flag/* Decoder whether to crop the image after the output, assuming that the left and right side of the cropped width */
0
U (1)

if (Frame_cropping_flag) {



Frame_crop_left_offset
0
UE (1)

Frame_crop_right_offset
0
UE (1)

Frame_crop_top_offset
0
UE (1)

Frame_crop_bottom_offset
0
UE (1)

}



Vui_parameters_present_flag/* Indicates whether the VUI sub-structure is present in the stream, and the VUI substructure is indicated in the appendix for characterization VideoFormat information */
0
U (1)

if (Vui_parameters_present_flag)



Vui_parameters ()
0


Rbsp_trailing_bits ()
0


}




Table 4

H264 Format Specific Description

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.