[Graphic] MPEG-2 compression coding technology principle application (4)

Source: Internet
Author: User

Guo Bin, Professor of the Department of television engineering, Beijing Broadcasting Institute

2. coding of MPEG-2

Coding is one of the core contents of MPEG-2 standard, which involves MPEG-2 video stream layer structure, MPEG-2 frame encoding structure, MPEG-2 class and level, MPEG-2 motion valuation and other technologies.

1. Structure of MPEG-2 video stream Layer


In order to facilitate code processing, random search and editing, a hierarchical structure is defined in syntaxes to represent video encoding data. MPEG-2 specific video stream layer structure 10:
MPEG-2 video streams are divided into image sequence layer (VSL-video sequence layer), image group layer (gopl-group of pictures)
Layer), image layer (pl-picture layer), macro block layer (SL-slice layer), macro block layer (Ml-macroblock
Layer), block layer (BL-block layer) has a total of six parts, each layer has a definite function corresponding to it.

1) image sequence layer (VSL)


VSL is a video packet consisting of a Data header and a series of image groups (GOP). It refers to a continuous image to be processed. Used to define the sequence structure of the entire video. You can use either line-by-line or line-by-line scanning.
. The data header provides the horizontal size, vertical size, aspect ratio, frame rate, bit rate, video cache checker size, quantization matrix, layer-ID, and classification of the image.
Scalable mode provides an important basis for decoding.

2) image group layer (gopl)


Gopl is a group of images in several image groups in the Image Sequence layer. It consists of a Data header and several images and is used to support random access during decoding. Image grouping is intended for Random Access and editing,
It is not a necessary condition for the composition of MPEG-2 structures and can be flexibly selected between groups or not. The data header provides the image encoding type, code table selection, image group header start code, video tape recording time, and control.
Code, closed GOP, and broken link that involve B-frame processing. To provide an access point for the editing data stream, 1st are always I frames.

3) image layer (PL)


PL is composed of a Data header and one frame of image data. It is one of several images on the Image Group layer and contains all the encoding information of one image. MPEG-2 image scanning can be performed either Row-by-row or row-by-row: When
The image is compressed frame by frame. When it is a line break, the image is compressed by field or frame by frame, that is, in scenarios with many movements, the image is compressed by field, frame-by-frame compression is used in scenarios with less motion.


The reason is that the space redundancy removed from the entire frame is much higher than that from individual fields. The basic parts provided by the data header include the start code of the header, the time reference of the Image number, the frame type of the image (I, B, P), and the video delay.
Extended parts include image encoding extension, Image Display extension, image space extension, and image time extension. Among them, the basic part is shared by the MPEG-1 and MPEG-2,
The extension part is dedicated to the MPEG-2.

A video image consists of the brightness sampling value and the color sampling value. The ratio of brightness to the color sample value is determined by the sampling frequency. In the MPEG-2, there are three proportional formats: (OR.

4) Macro Block Bar layer (SL)


Sl is composed of additional data and a series of macro blocks. Its minimum length is 1 macro block.
When the image width, it becomes the largest Macro Block length in the MPEG-2 layer. In order to conceal the error and improve the image quality, image data is divided into several bitwise strings consisting of several macro blocks or macro blocks. Once a Macro Block
If an error occurs, the decoder can skip this macro block to the next macro block so that the next macro block is not affected by any macro block that cannot be corrected due to an error, the more macro blocks in a single string, the better the hiding error performance. Is
The additional data section defines the position of the macro block in the entire image, the default global quantization parameter, and the variable priority switching point (pbp-priority break ).
Point ). Pbp is used to indicate where the data stream is separated. the decoder must switch between the two data streams to ensure that the complete and correct decoding information is read, and that the decoding is complete and correct. Note,
When IDCT-inverse Discrete Cosine transform is used, SL provides the re-synchronization function.

5) Macro Block layer (ML)


ML is one of a series of macro blocks in the Macro Block Bar layer. It consists of additional data, brightness blocks, and color blocks. The brightness is 16x16 pixels, which is called a macro block. Macro Block is the basic unit for Motion Compensation in bit rate compression.
It consists of four 8x8 pixels to eliminate the time redundancy between the P image and the B image. The color block consists of 8x8 pixels, depending on the proportional format of the sampling frequency between the brightness and the color. For example
MPEG-2 has three macro block structures:, sample structure 11. In the figure, is composed of four 8x8 brightness (y) pixel blocks and two 8x8 red blocks.
(CR) consists of a pixel block and 0 8x8 blue (CB) pixel blocks, or 4: 0: 2 is composed of 4 8x8 brightness (y) pixel block, 0 8x8 red (CR) pixel block, and 2 8x8 blue
(Cb) consists of pixel blocks, which are alternating between and. This reduces the vertical decomposition force (similar to) and only contains 1/4 of the color information.
It consists of four 8x8 brightness (y) pixel blocks, two 8x8 red (CR) pixel blocks, and two 8x8 blue (CB) pixel blocks, only 1/2 of the color information is contained. 4: 4 is composed of four
Consists of 8x8 brightness (y) pixel blocks, 4 8x8 red (CR) pixel blocks, and 4 8x8 blue (CB) pixel blocks, is a full-bandwidth ycrcb video. Macro Block layer ml contains the movement of P frames and B frames
Vector (MV-Motion
Vectors ). Additional data includes the following information: describes the macro block address of the macro block in the Macro Block Bar layer, the macro block type of the macro block encoding method and content, the macro block quantization parameters, the differences between the motion vector type and the large
Small, indicating that the field discrete cosine transform (DCT-discrete cosine transform) or the DCT type encoded with the frame DCT.

6) block layer (BL)


BL is an 8x8 pixel block that only contains one type of pixels, that is, a single 8x8 brightness (y) pixel block, or a single 8x8 red (CR) pixel block, or a single 8x8 blue (CB) pixel
Block. It is the smallest unit that provides the DCT coefficient, that is, its function is to transmit the DC component coefficient and the AC Component Coefficient. If you want to perform DCT on the macro block, you must first divide the macro block into pixel blocks before proceeding.

2. frame encoding structure for MPEG-2


In order to obtain high compression ratio and high-quality images with random access under the condition of efficient compression encoding, MPEG defines three image formats: I, P, and B.
Picture, predicted picture, and bidirec tional
Picture), that is, I, P, and B, used to represent the frame sequence of the 1/30 s interval. Because, to meet the random access requirements, only the I image information can be used for intra-frame encoding.
To meet the requirements of high compression ratio and high quality images, I-graph encoding alone is not enough, and the inter-frame encoding involved by P and B is also required, and block matching motion compensation prediction, that is, using the previous frame of the image to predict the current
The causal prediction of the image and the interpolation prediction of the current image using the last frame of the image. This requires the balance between intra-frame encoding and inter-frame encoding, and the balance between causal prediction and interpolation prediction. The balanced result is the high compression ratio of random access,
Uniformity of high-quality images. Figure 12 shows the frame encoding structure of the MPEG-2, where:

1) Intra-frame encoding (ICP)


The I image is the image produced without the reference image encoding as the reference. It is called the intra-frame encoding image (ICP-intra coded ).
Pictures ). Features: the largest data volume, moderate compression within the frame, no motion prediction, self-correlation can be adopted, that is, the adjacent pixels within the frame, the brightness of adjacent lines, and the color signal have gradient space correlation.
Can be used for Static Image Processing and unconditional transmission; images can be randomly entered into the compressed image data sequence for encoding.

2) prediction coding diagram (PCP)


The P chart is an image produced by motion compensation prediction based on the last I or P chart. It is called the prediction coding diagram (PCP-predictive coded ).
Pictures ). A p chart is characterized by a Forward prediction (FP-forward) of a forward I or P chart.
Prediction) results are also the reference images that generate the next P image. high coding efficiency, compared with the I image, can provide a greater compression ratio; the previous P chart is the benchmark for the compensation prediction of the next p chart. If
If the former has an error code, the latter will accumulate and spread the Encoding Error.

3) bidirectional prediction coding diagram (bpcp)


At present, there are two kinds of convergence understandings on Graph B: first, B is an image produced by motion compensation prediction based on both the I Diagram or p Diagram and the p Diagram or I diagram below. It is called a bidirectional prediction coding diagram.
(Bpcp-bidirectional predictive coded
Picture ). The previous graph I or P represents "past information", and the subsequent Graph P or I represents "future information ", because both "past" and "future" information are used
Test. Second, because the moving part of the adjacent frames in the frame sequence has a continuous to temporal correlation, the current image can be viewed as the displacement of the image at a certain time point of the previous image, of course, the displacement direction and amplitude may not be in all aspects of the frame
Similarly, the current image can be predicted by using the I or p Diagram of the previous recent moment and the displacement information representing the movement, which is called Forward prediction (FP ). Prediction Based on the image at a certain time point and the motion vector that reflects the displacement information
The image generated before a certain time point is used to predict the information that does not appear in the previous frame, which is called back-to-back prediction (BP-Backword ).
Prediction ). Graph B is an image generated after both Forward prediction (FP) and backward prediction (BP) are used and their average values are obtained. It is called a bidirectional prediction chart or an average value prediction chart.


As shown in figure 12, a GOP consists of a string of IBP frames starting with I. The length of the GOP is the interval between the first I frame and the second B frame before the next I frame, as shown in figure
In i1b2b3p4b5b6p7b8b9i10, the length from I1 to B9 is the length of GOP. The longer the GOP, the more effective the MPEG-2 encoding, and the more difficult it is to edit and group the data stream. Average,
It consists of up to 12 frames. The output bit rate varies depending on the repeat frequency of the reference frame. The GOP structure varies with the bit rate. For example, when the bit rate is greater than 40 Mbps, the frame repetition mode is only I
Frame and GoP are the shortest, with high efficiency. When the bit rate is 15-40 Mbps, the frame repetition mode is IB, the GOP is short, and the bit rate is less than 15
In Mbps, the frame repetition mode is IBP or ibbp. the GOP is long and has a delay, which affects the access speed. In short, the image quality follows the bitrate of 10-50
The increase in Mbps increases as the Frame repeat mode I-IB-IBBP makes the GOP grow longer. Although the frame duplication method can be IP, IB, IBP, ibbp, or even only I frame
For different applications and bit rates, there are different GOP structures: News compilation, bit rate 18 Mbps, using the GOP structure of IB frames; program allocation, bit rate 20 Mbps, using the GOP knot of ibbp Frames
Structure; archive, bit rate 30 Mbps, adopts the GOP structure of IB frame: post-production, bit rate 50 Mbps, adopts the GOP structure of I frame. Figure 13 shows the relationship between GOP and image quality and its application.
The encoding rule is: I frame @ ML
The MPEG speed is 40-50 Mbps, The ibibib sequence rate is 25-30 Mbps, and the long gopibp sequence rate is 12-18 Mbps.

The system does not encode, transmit, or use B-frame pixels as the prediction benchmark. Only two-way prediction interpolation is used for decoding. For example, B2 and B3 frames between I1 and P4 are established by I1 and P4 Weighted Interpolation. The B-frame pixel block data only carries the "Motion Vector" set for each pixel block ". (To be continued)

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.