First, H.264 macroblock
1, what is a macroblock?
First look at the two pictures below, you can generally know which macroblock refers to. The consecutive frame image is divided into a group (GOP) in H264 as a sequence; a sequence of each frame (FRAME); slice); slice is horizontally in the size of 16x16 The vertical scratch is divided into a macroblock; the macroblock is divided into 4 pieces, and each size is 8x8, called a sub-block. There is also a block concept, paying attention to the sub-block: The image first divides the 4x4 size block, which means that the macroblock contains the entire 4x4 block. The H.264 is mainly converted at 4 × 4 pieces when encoding, occasionally 8 × 8 conversion.
2, detailed macroblock
The macroblock is the basic unit of the encoding process, consists of multiple blocks, usually the macroblock size is 16x16 pixels, and the macroblock is based on the type I, B, P macroblock, macroblock type, according to the type of slice, and macroblock types to represent MB_TYPE The same value of MB_TYPE will be different in different types of SLICEs.
MB_TYPE
Whether the value of MB_TYPE is equal to I_PCM, the entire parsing method is divided into two categories: PCM type and non-PCM type. Detailed Type Description Referring to: H.264 Macro Block and Submount Type When this macroblock is i_pcm mode, the macroblock is saved in the form of a macroblock in the form of differential encoding. At this time, there is a few syntax elements: PCM_ALIGNMENT_ZERO_BIT: Fill in the bits, fill in the bits 0 to align by bytes; PCM_SAMPLE_LUMA: 256 Differential pixel values of the brightness component; PCM_SAMPLE_CHROMA: Several color components Differential pixel value, actual quantity Specified by the color format of the code stream. For example, a total of 128 color pixel values for videos of the most commonly used 4: 2: 0 format.
MB_PRED
The grammatical structure of the macroblock predicted, the grammatical structure predicted with the macroblock predicted, the composition structure of a macroblock either uses the structure of the macroblock prediction, or 4 sub-macroblocks are a macroblock. Predictive structure.
SUB_MB_PRED
The syntax structure predicted by the sub-macroblock, the macroblock is a macroblock of 8x8 size, that is, a macroblock has 4 sub-macroblocks, and 4 sub-macroblock predictions in this syntax structure.
CODED_BLOCK_PATTERN
The syntax element is often referred to as CBP, which is used to indicate which of the 4 8 × 8 sub-block encoding in the current macroblock is encoded. It is worth noting that this syntax element exists only when the macroblock is non-I_16x16 mode, because the information about the CBP is embodied in MB_TYPE in the I_16x16 mode.
MB_QP_DELTA
Indicates the quantization parameter offset value of the macroblock layer, the value ranges [-26, 25]. We have already obtained the initial value of the quantization parameters of the entire sequence in the PPS (calculated by the PIC_INIT_QP_MINUS26), got the quantization parameters of the SLICE layer in the SLICE Header, so the quantization parameters of each SLICE first macroblock can pass The following formula is calculated: QP = PIC_INIT_QP_MINUS26 + 26 + SLICE_QP_DELTA + MB_QP_DELTA
Residual
Grammatical structure encoded by pixel residual
Second, H.265 encoding tree unit
1, what is the coding tree unit?
First look at the figure below: The H.264 macroblock and the H.265 macroblock size is fixed, generally 16x16; the encoding unit size of H.265 can be set to 64 × 64, 32 × 32 or 16 × 16.
2, the encoding tree unit details
CTU
CTU (CODING TREE Unit, coding tree unit), each encoded tree unit can be recursively divided, using a quadruple tree structure, divided into sub-regions of 32 × 32, 16 × 16, 8 × 8, the following figure is a 64 × 64 Partition example of the coding tree unit.
CTB
CTB (Coding Tree Block, encoding tree), a coding tree unit (CTU) contains a brightness encoding tree (CTB) and two chroma coding tablets (CTB) at the same location, and some corresponding syntax elements . As shown, according to the CTU size may be 16x16, 32x32, 64x64, the size of the brightness CTB may be 16x16, 32x32, 64x64, and always correspond to the size of the CTU, which is 64x64, the brightness CTB size is 64x64, the chromaticity is 32x32.
CU
Cu (Coding Unit, Coding Unit), each CTU, can further be divided into four squares Cu, one CU can be recursively divided into four small CUs, the maximum depth is 3, as shown below : The Cu block is the basic unit of decision frame, intra, SKIP / MERGE mode. The resolution (long and wide parameters) of the video sequence also transmits in the SPS, requiring long and wide must be an integer multiple of the Mininum Cu size, but may not be the integer multiple of the CTU Size. For the case where the length is not a CTU size integer, the CTU at the image boundary is considered to be divided into and image boundary coincidence, and for the default segmentation at this boundary, it is not necessary to transmit the Split_cu_flags flag.
CB
CB (Coding Block, Code Block), the encoded tree CTB can be directly used as a coded block CB, or further divided into a plurality of small C cb CBs in the form of a quadrush tree, so the size of the CB can vary, In the case where the CTU size is 64x64, a brightness CB is 64x64, that is, one CTB is directly used as a CB, the minimum is 8x8, and the chromaticity Cb is 32x32, the minimum is 4x4. The large CB can make the coding efficiency of the gentle area greatly increase, and small CBs in the detail portion can make complex image prediction more accurate. A brightness CB and two chroma CBs, and some related syntax elements together form an encoding unit (CU). As shown:
PU
The PU (PREDICTION UNIT, Prediction Unit), and the PU specifies all prediction modes of the encoding unit, including all prediction related information, such as intra prediction direction, inter prediction, motion vector prediction, and inter prediction reference Image index marks, etc. The PU is a basic unit for prediction. Different prediction methods, PU's division is shown in the figure below:
PB
The PU (PREDICTION block, predictive block), a prediction unit PU contains a brightness prediction block Pb and two chromaticity prediction block Pb.
Tu
TU (Transform Unit, Transform Unit), a CU can be recursively divided into TUS, Cu as a quit tree, as shown below, as shown below: TU is divided into TUS: TU is made of brightness TB and two chromaticity TB and corresponding syntax elements, TUs are basic units for transform and quantization. CU schedral into TUS, TU's size range depends on the three parameters of Max Tu Size, Min Tu Size, and Max TU Depth, which is transmitted in SPS Level. Max Tu Size is 5 indicates that the maximum TU is 32x32, and the min tu size is 2 indicates that the minimum TU is 4x4. The max depth is 3 indicates that the Cu score is divided into 3 layers (as shown in Figures 10, 11, 12, 13 above). For Intra predition, make sure the PU is greater than or equal to TU (ie TU does not cross multiple intra PUs), and Interperation has no corresponding limit. Also, for a CU, there is a maximum of TRASFORM TREE SYNTAX, so a CU's LUMA CB and Choma CBS have the same TU division. However, in addition to TB divided into 4x4 for 8x8 LUMA CB, 4x4 Choma CBS will not divide 2x2 TB.
TB
Tu (Transform Block, transmends), one transform unit TU includes a brightness transform block TB and two chroma conversion block TB. The HEVC can support the encoding transformation of 4x4 to 32x32, the basic unit is the transform unit (TU). The size of the transform unit depends on the CU mode, and the inside of the CU can allow TUs to span multiple PUs, in the form of a quad tree. The large block of TUs can make energy more concentrated, and the small pieces of TU can retain more details, flexible segmentation.
3, CTU, CU, PU, TU relationship
CTU and CU
A image can be divided into a plurality of non-overlapping CTUs based on the CTU size set by the encoder, and use the cyclic hierarchical structure based on the four-fork tree in the CTU. The encoding unit at the same level has the same segmentation depth. A CTU can be values that a CU is not divided, or it can be divided into multiple CUs.
Cu and Pu, Tu
Each CU contains a prediction unit (PU) associated with it, and I am converting a unit (TU).
For a 2nx2N Cu mode: the optional mode of the intra prediction unit has two 2nx2n and NXN; 8 types of inter prediction modes, four symmetry 2NX2N, NXN, NX2N, 2Nxn, 4 non-symmetrical modes 2nxnu, 2nxnd, NLX2N, NRX2N (where U, D, L indicate the four directions of the left and right), where NLX2N, NRX2N is the ratio of about 3, 3: 1, 2nxnu, 2nxnd is 1: 3, 3: 1 The ratio division. There is also a mode for SKIP mode. It is one of the inter prediction. When the coded motion information is required to have a motion parameter set (using motion synthesis technology), the encoding residual information does not need to be encoded.
Our other product: