H264 SPS PPS Detailed

Source: Internet
Author: User
Tags numeric value
1. Learning Route

Step1, preliminary understanding of H264, understanding H264 Data frame Classification and recognition

Step2, H264 syntax related algorithm parsing, this is important to understand the H264 video frame. The H264 data definition is made up of a set of bit bits, but a field is not a fixed number of bits, it is escaped by the algorithm to save the value.

STEP3, SPS, pps frame syntax definition 2, H264 introduction

In the H.264/AVC video coding standard, the whole system framework is divided into two levels: Video coding level (VCL) and network abstraction level (NAL). The former is responsible for effectively representing the content of video data, while the latter is responsible for formatting the data and providing header information to ensure that the data is suitable for transmission on various channels and storage media. The nal occupies a byte.

NAL Unit (NALU): The basic syntactic structure of NAL, which contains a byte of header information and a series of bytes from VCL called the original byte sequence payload (RBSP). The data flow is stored on the media: Add the start code before each Nalu: 0x00000001 (or 0x000001), which indicates the starting and ending position of a nalu. Every frame of data we normally have is a NAL unit (except SPS and PPS).

The encoder will separate and complete each nal into a group, because the packet has a head, decoder can easily detect the demarcation of the nal, and then take out the nal to decode. Each nal has a starting code 0x00 00 01 (or 0x00 00 00 01), and the decoder detects each starting code as a nal starting ID, and the current nal ends when the next start code is detected. At the same time, H.264 stipulates that when the 0x000000 is detected, it can also characterize the end of the current nal. So what to do when the data in Nal 0x000001 or 0x000000. H.264 introduced a mechanism to prevent competition, and if the encoder detects that NAL data exists 0x000001 or 0x000000, the encoder inserts a new byte 0x03 before the last byte, so that:

0x000000->0x00000300
0x000001->0x00000301
0x000002->0x00000302
0x000003->0x00000303
When the decoder detects the 0x000003, it discards the 03 and restores the original data (the shelling operation). When decoding, the decoder first reads the NAL data, counts the length of the NAL, and then begins decoding.

The Nalu header consists of a byte, and its syntax is as follows:
+---------------+
|0|1|2|3|4|5|6|7|
+-+-+-+-+-+-+-+-+
| F|  nri| Type |
+---------------+
F:1 a bit.
Forbidden_zero_bit. The H.264 specification stipulates that this one must be 0.
Nri:2 a bit.
NAL_REF_IDC. Taking 00 ~ 11 seems to indicate the importance of this nalu, such as a 00 NALU decoder that can discard it without affecting playback of the image. But normally, I don't care.
This property.
Type:5 a bit.
Nal_unit_type. The type of the Nalu unit. Briefly described below:
0 No definition
11 non-IDR image coding strip (BP frame)
SLICE_LAYER_WITHOUT_PARTITIONING_RBSP ()
2 coded strip data partition block a
SLICE_DATA_PARTITION_A_LAYER_RBSP ()
3 coded strip data partition Block B
SLICE_DATA_PARTITION_B_LAYER_RBSP ()
4 coded strip data partition block C
SLICE_DATA_PARTITION_C_LAYER_RBSP ()
5 IDR Image Coding strip (I frame)
SLICE_LAYER_WITHOUT_PARTITIONING_RBSP ()
6 Auxiliary Enhancement Information (SEI)
SEI_RBSP ()
7 sequence parameter set (SPS frame)
SEQ_PARAMETER_SET_RBSP ()
8 Set of image parameters
PIC_PARAMETER_SET_RBSP (PPS frame)
9 Access Unit Separator
ACCESS_UNIT_DELIMITER_RBSP ()
10 Sequence End
END_OF_SEQ_RBSP ()
11 Stream End
END_OF_STREAM_RBSP ()
12 Populating data
FILLER_DATA_RBSP ()
13 Sequence Parameter Set expansion
SEQ_PARAMETER_SET_EXTENSION_RBSP ()
14...18 Reservation
19 coding strip for an undivided auxiliary coded image
SLICE_LAYER_WITHOUT_PARTITIONING_RBSP ()
20...23 Reservation
Stap-a a single time combination package
Stap-b a single time combination package
MTAP16 multiple-time combination packages
MTAP24 combination of multiple time packages
Fu-a Fragment Unit
Fu-b Partitioned Unit
30-31 No definition

when you encounter 00 00 00 01 67 to indicate the SPS frame

When encountering 00 00 00 01 68 Indicates PPS Frames
3, H264 Grammar correlation algorithm Analysis 1, unsigned exponential Columbus entropy coding 1.1 Coding Process

1, to encode the number plus 1 into the smallest binary sequence (assuming a total of M bit);
2. This binary sequence is supplemented with M-1 0;
3, enjoy. 1.1.1 Sample

Unsigned exponential Columbus entropy coding for 4
1. Convert 4 plus 1 (5) to the smallest binary sequence that is 101 (this is m=3)
2. This binary sequence is preceded by the addition of M-1, that is, two 0
3, the obtained 4 unsigned exponential Columbus entropy coding sequence is 00101 1.2 decoding process

1, get the binary sequence of the beginning of the continuous n 0
2, after reading the value of the n+1 bit, assuming that X
3, X-1 get the decoded value 1.2.1 Example

For example 00101 unsigned exponential Columbus entropy decoding
1, get the beginning of the continuous n 0, at this time n = 2
2, and then read back the value of the n+1 bit, that is, 101, 5
3, 5-1 = 4 to obtain its decoded code value, enjoy! 1.3 Other

Note 0 of the unsigned exponential Columbus Entropy encoded binary sequence of 1 2 signed exponential Columbus Entropy coding 2.1 Coding Process

1. Converts the absolute value of the number to be encoded into the smallest binary sequence (assuming a total of M bits)
2. Add a sign bit 0 after this binary sequence to indicate positive, 1 to negative
3. Add m to 0 before this binary sequence
4, enjoy 2.1.1 Example 1

such as a signed exponential Columbus entropy code for 4
The absolute value of 1 and 4 is converted to the least binary sequence, that is, 100 (at this time M = 3)
2, the following complement sign bit, 0 or 1000
3, before the supplementary m 0, that is 0001000
4, enjoy 2.1.2 Example 2

such as 15 with signed exponential Columbus entropy coding
The absolute value of 1 and-7 is converted to the least binary sequence, that is, 1111 (at this point m = 4)
2, followed by the symbol bit, 1, that is 11111
3, before the supplementary m 0, that is 000011111
4, enjoy 2.2 decoding process

1, get the binary sequence of the beginning of the continuous n 0
2, after reading the value of n digits, assumed to be X
3, get the last 1-bit symbol bit
4, get the decoded code value 2.2.1 Example 1

For example binary sequence 0001000 with signed exponent Columbus entropy decoding
1, get the beginning of the continuous n 0, at this time n = 3
2, and then get n for the numeric value, that is, 100 is 4
3, get the last sign bit, 0, that is positive
4, so the sequence decoding code value of 4 2.2.2 Example 2

For example binary sequence 000011111 with signed exponent Columbus entropy decoding
1, get the beginning of the continuous n 0, at this time n = 4
2, and then get n for the numeric value, that is, 1111 is 15
3, get the last sign bit, 1, that is negative
4, so the sequence of decoding code value of-15

4. SPS Syntax

5. PPS Syntax

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.