H264 (nal Introduction and I-frame judgment)

Source: Internet
Author: User

1, nal full name Network abstract layer, that is, the net abstraction level.
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 the video data, while the latter is responsible for formatting the data and providing the header information to ensure that the data suitable for the transmission of various channels and storage media. So our usual data per frame is a NAL unit (except SPS and PPS). In the actual H264 data frame, the frame is often preceded by a 00 00 00 01 or 00 00 01 separator, generally the first frame data of the encoder is PPS and SPS, followed by the I-frame ...

Such as:


2, how to determine the frame type (image reference frame or I, p frame, etc.)?

The Nalu type is a powerful tool for judging the type of frame, which is drawn from official documents such as:


We still go to the top figure of the code stream corresponding to the data to layer analysis, 00 00 00 01 After the next byte is the Nalu type, converted to binary data, the order of interpretation from left to right, as follows:
(1) 1th bit forbidden bit, value 1 indicates syntax error
(2) the 2nd to 3rd position is the reference level
(3) 4th to 8th is the NAL unit type

For example, there are 67,68 and 65 after 00000001.

Where the 0x67 binary code is:
0110 0111
4-8 = 00111, decimal 7, reference second Picture: 7 corresponding sequence parameter set SPS

Where the 0x68 binary code is:
0110 1000
4-8 is 01000, to decimal 8, refer to the second Picture: 8 corresponding image parameter set PPS

Where the 0x65 binary code is:
0110 0101
4-8 is 00101, to decimal 5, refer to the second Picture: 5 for the slices in the IDR image (I-frames)

So the algorithm for determining if the I-Frame is: (Nalu type & 0001 1111) = 5 = Nalu type & 31 = 5

such as 0x65 & 31 = 5

H264 (nal Introduction and I-frame judgment)

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.