Start code (startcode) of h264 and MPEG4)

Source: Internet
Author: User

Http://blog.chinaunix.net/space.php? Uid = 20751538 & Do = Blog & id = 165746

1. H.264 when the start code transmits h264 data over the network, a UDP packet is a nalu, And the decoder can conveniently detect the nal demarcation and decoding. However, if the encoding data is stored as a file, the original decoder cannot determine the start position and end position of each nal from the data stream. Therefore, H.264 uses the start code to solve this problem. In H.264 encoding, the start code 0x264 is added before each nal. the decoder detects the start code in the bitstream and the current nal ends. H. 264 the mechanism of preventing competition for emulation prevention is also proposed. After encoding a nal, if two consecutive 0x00 bytes are detected, a 0x03 is inserted. When the decoder detects 0x000003 data in Nal, It discards 0x03 and restores the original data. 0x000000 >>>>>> 0x00000300 0x000001 >>>>>> 0x00000301 0x000002 >>>>>> 0x00000302 0x000003> >>>>> 0x00000303 attach H. 264 algorithm flow for decoding the start code in nalu (;;)
{
If next 24 bits are 0x000001
{
Startcodefound = true
Break;
}
Else
{
Flush 8 bits
} // (;;)
If (true = startcodefound)
{
// Startcode found
// Flush the start code found
Flush 24 bits // Now navigate up to next start code and put the in between stuff

// In The Nal structure.
For (;;)
{
Get next 24 bits & check if it equals to 0x000001
If (false = (next 24 bits = 000001 ))
{
// Search for pattern 0x000000
Check if next 24 bits are 0x000000
If (false = Result)
{
// Copy the byte into the buffer
Copy one byte to The Nal Unit
}
Else
{
Break;
}
}
Else
{
Break;
}
} // (;;)
}
2. The starting code of MPEG4 is VOP. Without the concept of nalu, startcode is still used to divide each frame. The start code of MPEG4 is 0x000001. in addition, many start codes in MPEG4 are also very useful. For example, video_object_sequence_start_code 0x000001b0 indicates the start of a video object sequence, and vo_start_code 0x000001b6 indicates the start of A vop. two digits after 0x000001b6, 00 indicates I frame, 01 indicates
P frame, 10 indicates B frame.

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.