Two stream formats, Annex-B, AVCC (H.264) and HVCC (H.265)

Both the 264 standard and the 265 standard have two code stream formats, the 264 standard is the Annex-B and AVCC code stream formats, and the 265 standard is the Annex-B and HVCC standards.

An Annex-B code stream format
The video encoded package is called Network Abstraction Layer Units, also referred to as NALU, NAL. Each NALU packet can be parsed and processed separately. The first word of each NALU packet. The section contains the NALU type, and the content contained in bit3-bit7 is especially important (bit 0 must be off, and bit 1-2 specifies whether the NALU is referenced by other NALUs). The NALU format is divided into 2 categories, VCL and non-VCL, with a total of 19 different NALU formats. A single NALU packet, or even a VCL NALU packet, does not mean to be a separate frame. One frame of data can be divided into several NALUs. One or more NALUs form an Access Units (AU), and the AU contains A complete frame. It takes a lot of time to split the frame into several independent NALUs.CPUResources, so split frame data is not used often.
1.1 NALU package start code
The data in a NALU package does not contain its size (length) information, so you can't simply connect the NALU package to create a stream, because you don't know where a packet ends, and Where does a package start? The Annex B format uses the start code to solve this problem by prefixing each NALU with two or three 0x00s followed by a 0x01, such as 0x000001 or 0x00000001. The start code of the 4-byte type is in continuous It is very useful in data transmission because it uses byte to align and split stream data. For example, it is very easy to divide stream data by using 31 consecutive bit0 followed by one bit1. If the next bit is 0 (because each NALU starts with bit0), then this is the starting position of a NALU packet data. The 4-byte type start code is usually only used to identify random access points in the stream, such as SPS PPS AUD and IDR, and then a 3-byte type start code is used elsewhere to reduce the amount of data.
1.2 anti-competition byte
The start code works because the 3-byte sequence 0x000000, 0x000001, 0x000002, and 0x000003 (should be all 0x0000**) in non-VCL (original is non-RBSP) It is illegal to modify the NALU package, so when constructing the ANLU package, you must ensure that these numeric sequences are excluded. This is done by inserting anti-contention byte 0x03 into each sequence of this type, then inserting the anti-competition byte. After that, 0x000001 becomes 0x00000301. When decoding, it is important to find and remove anti-competitive bytes. Since anti-competition bytes may appear anywhere in the NALU package, it is generally more convenient in the documentation to assume that they have been removed. Raw Byte Sequence Payload Raw Byte Sequence Load (RBSP) indicates data without anti-competitive bytes. Sequence (package).
1.3 example

 <pre><code>0x0000 | 00 00 00 01 67 64 00 0A AC 72 84 44 26 84 00 00
0x0010 | 03 00 04 00 00 03 00 CA 3C 48 96 11 80 00 00 00
0x0020 | 01 68 E8 43 8F 13 21 30 00 00 01 65 88 81 00 05
0x0030 | 4E 7F 87 DF 61 A5 8B 95 EE A4 E9 38 B7 6A 30 6A
0x0040 | 71 B9 55 60 0B 76 2E B5 0E E4 80 59 27 B8 67 A9
0x0050 | 63 37 5E 82 20 55 FB E4 6A E9 37 35 72 E2 22 91
0x0060 | 9E 4D FF 60 86 CE 7E 42 B7 95 CE 2A E1 26 BE 87
0x0070 | 73 84 26 BA 16 36 F4 E6 9F 17 DA D8 64 75 54 B1
0x0080 | F3 45 0C 0B 3C 74 B3 9D BC EB 53 73 87 C3 0E 62
0x0090 | 47 48 62 CA 59 EB 86 3F 3A FA 86 B5 BF A8 6D 06
0x00A0 | 16 50 82 C4 CE 62 9E 4E E6 4C C7 30 3E DE A1 0B
0x00B0 | D8 83 0B B6 B8 28 BC A9 EB 77 43 FC 7A 17 94 85
0x00C0 | 21 CA 37 6B 30 95 B5 46 77 30 60 B7 12 D6 8C C5
0x00D0 | 54 85 29 D8 69 A9 6F 12 4E 71 DF E3 E2 B1 6B 6B
0x00E0 | BF 9F FB 2E 57 30 A9 69 76 C4 46 A2 DF FA 91 D9
0x00F0 | 50 74 55 1D 49 04 5A 1C D6 86 68 7C B6 61 48 6C
0x0100 | 96 E6 12 4C 27 AD BA C7 51 99 8E D0 F0 ED 8E F6
0x0110 | 65 79 79 A6 12 A1 95 DB C8 AE E3 B6 35 E6 8D BC
0x0120 | 48 A3 7F AF 4A 28 8A 53 E2 7E 68 08 9F 67 77 98
0x0130 | 52 DB 50 84 D6 5E 25 E1 4A 99 58 34 C7 11 D6 43
0x0140 | FF C4 FD 9A 44 16 D1 B2 FB 02 DB A1 89 69 34 C2
0x0150 | 32 55 98 F9 9B B2 31 3F 49 59 0C 06 8C DB A5 B2
0x0160 | 9D 7E 12 2F D0 87 94 44 E4 0A 76 EF 99 2D 91 18
0x0170 | 39 50 3B 29 3B F5 2C 97 73 48 91 83 B0 A6 F3 4B
0x0180 | 70 2F 1C 8F 3B 78 23 C6 AA 86 46 43 1D D7 2A 23
0x0190 | 5E 2C D9 48 0A F5 F5 2C D1 FB 3F F0 4B 78 37 E9
0x01A0 | 45 DD 72 CF 80 35 C3 95 07 F3 D9 06 E5 4A 58 76
0x01B0 | 03 6C 81 20 62 45 65 44 73 BC FE C1 9F 31 E5 DB
0x01C0 | 89 5C 6B 79 D8 68 90 D7 26 A8 A1 88 86 81 DC 9A
0x01D0 | 4F 40 A5 23 C7 DE BE 6F 76 AB 79 16 51 21 67 83
0x01E0 | 2E F3 D6 27 1A 42 C2 94 D1 5D 6C DB 4A 7A E2 CB
0x01F0 | 0B B0 68 0B BE 19 59 00 50 FC C0 BD 9D F5 F5 F8
0x0200 | A8 17 19 D6 B3 E9 74 BA 50 E5 2C 45 7B F9 93 EA
0x0210 | 5A F9 A9 30 B1 6F 5B 36 24 1E 8D 55 57 F4 CC 67
0x0220 | B2 65 6A A9 36 26 D0 06 B8 E2 E3 73 8B D1 C0 1C
0x0230 | 52 15 CA B5 AC 60 3E 36 42 F1 2C BD 99 77 AB A8
0x0240 | A9 A4 8E 9C 8B 84 DE 73 F0 91 29 97 AE DB AF D6
0x0250 | F8 5E 9B 86 B3 B3 03 B3 AC 75 6F A6 11 69 2F 3D
0x0260 | 3A CE FA 53 86 60 95 6C BB C5 4E F3</code>

This is a complete access unit (AU), including 3 NALU packets. As you can see, the data sequence starts with the start code followed by an SPS (SPS starts at 0x67). In SPS, you can see that 2 anti-competition bytes. Data sequences that are not as illegal as these bytes will appear in these locations. You can then see a start code followed by a PPS (PPS starts at 0x68), followed by a final start code followed by an IDR package. This is a complete H.264 stream. If you save this data in hexadecimal format to a file with a .264 extension, you can convert this data into the following image:

1.4 Application
The Annex B format is commonly used for real-time streaming formats, such as transport streams, broadcast over wireless, DVD, and more. In these formats, the SPS and PPS packets are usually repeated periodically, often before each key frame, so that the decoder can establish a random access point, so that an ongoing stream can be added and a play can be played. The stream that is already being transmitted.

 

Two AVCC code stream format
Another way to store H.264 streams is the AVCC format, in which each NALU packet is prefixed with a specified length (NALU packet size) (in Big endian format big endian format), this format of the package is very easy to parse, but this format removes the byte alignment feature in the Annex B format, and the prefix can be 1, 2 or 4 bytes, which makes the AVCC format change To make it even more complicated, the value of the specified prefix byte (1, 2 or 4 bytes) is stored in a header object (the part where the stream starts), which is usually called 'extradata' or 'sequence header'.
2.1 Its basic format is as follows:

bits    
8   version ( always 0x01 )
8   avc profile ( sps[0][1] )
8   avc compatibility ( sps[0][2] )
8   avc level ( sps[0][3] )
6   reserved ( all bits on )
2 NALULengthSizeMinusOne// indicates NAL Size. Is NAL Size-1. If the NAL Size is 4 bytes, the 2 bits are 11.
3   reserved ( all bits on )
5   number of SPS NALUs (usually 1)   repeated once per SPS:
16  SPS size    
N   variable   SPS NALU data
8   number of PPS NALUs (usually 1)   repeated once per PPS
16  PPS size   
N   variable PPS NALU data

The last 2 digits of the 5th byte represent the number of bytes of NAL size. In the AVCC format, each NAL is preceded by a NAL size field. NAL size may be 1 byte, 2 bytes or 4 bytes (4 bytes are more common). The important purpose of parsing extradata is to confirm this value. (And in the Annex-B format, to split NAL, just go to detect 0x000001). . Extradata example:

You will find that SPS and PPS are stored in non-NALU packets (out of band out-of-band), that is, independent of elementary stream data. The storage and transfer of these data is a task of the file container, beyond the scope of this article.
Note: Although the AVCC format does not use the start code, anti-competition bytes are still available.

2.2 Application scenarios
One advantage of the AVCC format is that it can jump to the middle of the stream when you start configuring the decoder. This format is usually used for multimedia data that can be accessed randomly, such as on a hard disk. file. Also because of this feature, MP4 and MKV are usually stored in the AVCC format.

Three HVCC code streams
The HVCC stream format is similar to AVCC.
extradata format:
      

Extradata example:
       

 

--------------------- 
OF: Chucky_Hu
Source: CSDN
Original: https://blog.csdn.net/romantic_energy/article/details/50508332
Copyright Notice: This article is the original article of the blogger, please attach the blog post link!

Intelligent Recommendation

H.265 stream analysis

The H.265 NALU type specifies the following: The type judgment method is the value of the first byte after the delimiter shifted to the right by one bit The first frame: 0x40 >> 1, get 0x20, 32 ...

H.264, JPEG, JPEG2000, Motion JPEG, H.265, MPEG-4 and other image encoding formats

Foreword         ~~~~~~~        Recently when viewing the HiSilicon HI3516a software development manual, some of the video encodin...

H.264 stream structure

The function of H.264 is divided into two layers, namely the video coding layer (VCL) and the network abstraction layer (NAL, Network Abstraction Layer). VCL data is the output of the encoding process...

H.264 stream format

1. Introduction to H.264 encoding format MPEG (Moving Picture Experts Group) and VCEG (Video Coding Experts Group) jointly developed a video compression coding standard with better performance than th...

H.264 code stream

First, experimental requirements 1. Select a .mp4 or .264 file. Open this file in the code stream analyzer software, analyze from several levels: 2. (1) Analyze which main information in the SPS and P...

More Recommendation

H.264 stream structure analysis

Probably written before a general analysis of the top five six H.264 format, is not very detailed, you can roughly see what format. H.264 stream structure analysis At that time I upload Baidu library,...

H.264 code stream analysis

First, experimental requirements 1. Select a .mp4 or .264 file. 2. Open this file in the code stream analyzer software, analyze from several levels: Analysis of which primary information is included i...

Video encoding-H.264 to H.265 transcoding

Background and significance The latest High-Efficiency Video Coding (HEVC) standard achieves significant compression efficiency improvements (50%) compared to the H.264 advanced video coding standard....

A H.265 / HEVC stream analysis tool

After about a month or so of free time, and finally the initial completion of a H.265 / HEVC stream analysis tools. Time includes the usual weekend night, days off and focus on the time. Of course, th...

H.264 stream is packaged as RTP stream

The H264 code stream is packaged into RTP package code as follows: [cpp] view plain copy #include <stdio.h>   #include <stdlib.h>   #include &l...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top