Introduction and judging method of IBP frame in MPEG4

Source: Internet
Author: User

In MPEG4 video, I-frame, p-frame, B-frame determination

each frame of the MPEG4 is fixed at the beginning: B6, then how do we determine what frame the current frame belongs to? In the next 2bit, we will tell you the answer. Note: 2bit, not Byte, the following is the corresponding relationship between various types of frames and 2bit:

00:i Frame
01:p Frame
10:b Frame

To better illustrate, let's take a few examples, the following is the video encoding for the 16 binary display:

XX B6 10 34 78 97 09 87 06 57 87 ... I-Frame

B6------------CC B3 89 ... P-Frame

XX B6 96 88 99 06 54 34 78 90 98 ... B-Frame

Let's analyze why they are I, P, b frames, respectively.

0x10 = 0001 0000

0x50 = 0101 0000

0x96 = 1001 0100

We look at the red 2bit, and then against the beginning of the frame and 2bit corresponding relationship, is not consistent with it.

Here is a section of C + + code for everyone to refer to:[CPP]View plain copy switch (Buf[i] & (BYTE) 0xc0) {case 0x00://i Frame break;   Case 0x40://p Frame break;   Case 0x80://b Frame break;   Default:break; } From:
Http://www.cnblogs.com/ManMonth/archive/2010/02/09/1666328.html


[Go] i-p-b frame Introduction
Three types of frames
The if--i-frame abbreviation, which is the keyframe. KeyFrames are the first frame that forms a frame group (Gop,group of picture). If all the information for a scene is preserved. The compression ratio is 1:7.
The pf--p-frame abbreviation, the future one-way prediction frame, stores only the difference from the previous uncompressed screen. The compression ratio is 1:20.
Bf--b-frame abbreviation, that is, two-way prediction frame, in addition to the reference before the extracted screen, will also refer to the screen information in the following frame. The compression ratio is 1:50.
There are four predictive modes for b-frame (the correct name is B-VOP in MPEG-4):
A. Forward forward forecast, refer to the previous screen, record the gap with the previous picture. The same as P-frame's prediction method.
B. Backward reverse prediction, refer to the next picture, record and the next picture of the gap.
C. bi-directionally Two-way prediction, referring to the front and back of the two screen, recording is and "two images before and after the average" gap.also called interpolation prediction, the compression rate is the highest.
D. Direct Mode, do not search, recordAction Vector, the action vector is deduced directly from the next P frame. For example, I b P, we can predict that the B-screen action must be between the I and p two screen, so we can directly use P's MV/2 as the action vector of B, this can save the recording MV space.
Compression of the B-frame will be selected from the above several predictive mode of the smallest mode to use.


I,b,p Frame
B-Frameb Frames (b frame)Basic ConceptsB-Frame method is the inter-frame compression algorithm for bidirectional prediction. When a frame is compressed into B-frame, it compresses the frame according to the different points of the adjacent previous frame, the frame and the next frame data, or only the difference between the frame and the front and back frames. Only B-Frame compression is used to achieve a high compression of 200:1.B-Frame modeB-frames have four reference modes in the MPEG-4. If it is the same time reference before and after the picture compression, then the record is and (the front screen pixel value + after the screen pixel value)/2 difference, that is, and "the average of the screen before and after the difference." So the number of differences recorded is the same as the P-frame, only one, no increase.
And because B frame is in the middle of the front and rear screen, with "average before and after", that is, "the middle value of front and rear screen" as the predictive value (predict the pixel value of B frame. If there is an error, then record the difference), so that the predicted value will be compared to the previous screen alone to predict, closer to the current real B-frame values, it is conceivable that so the need to record the difference will be very small or even no record, so you can save a lot of bits, improve the compression ratio.
For example, brightness change I B P 7 8 9
If B is only referring to the previous screen compression, the difference value of 1 must be recorded. If you compress with (I P)/2, the difference is 0, and you do not need to record the difference. (although to record two vectors, but the vector can also be further predictive compression, in general, it will be more than a single reference to the previous screen compression is much smaller) if the screen is not such a change what to do. This is usually the case, and if it's not the case, we don't use B-frames. Even if the change is not so the rule, in another way, B frame can refer to the screen or more than P frame, and how to find, also is the B-frame can find the error of smaller squares to use the probability of large (because you can choose, refer to more objects), so B-frame is higher than the compression rate of P-frame. (And much higher, the gap is very large)
In addition to the compression rate, the effect of B-frames on picture quality ... Yes, because B-frame this reference before and after the characteristics of the screen, is equal to the effect of interpolation (interpolation), socan reduce noise
The B-frame in the MPEG-4 is also very powerful, with the exception of the previous three reference modes and Direct mode, which saves the vector records. Although there are 4MV functions in the MPEG-4, can record four vectors, but the encoder in the compression will be judged, in the end is the use of 4MV pressure out of the results of small, or the use of traditional methods to press out the results of small.
If the result of using the traditional method is small, it is recorded using the traditional method, if the result of using 4MV is small, 4MV is used to record it.
(Ps. 4MV not used in backward predictions)
You can observe the blue Line displayed on the screen when the VirtualDub is compressed, and you will find that the blue line and the blue Line usually have a very short blue line in the middle, resulting in gaps, and the gap is very large, this is sandwiched between P B in play compression power if it is more obvious with DivX 5, because DivX 5 can only use IB PBPBPB ... This is a form B followed by a P, so the blue line on the screen is "a long, short, long, short" arrangement.
Connection and difference between keyframes and transition frames
1. The middle of two keyframes can have no transition frames (such as frame-wise animation), but there must be keyframes before and after the transition frame, because the transition frame is attached to the keyframe;
2. KeyFrames can modify the contents of the frame, but the frame cannot be modified by the transition frame.
3. KeyFrames can contain many types of elements, such as shapes, clips, groups, and many other elements, but the objects in the transition frame can only be clips (movie clips, graphic clips, buttons), or independent shapes. Image (frame) is a frame-coded image that compresses the amount of transmitted data by removing redundant information from the image as much as possible; P-image (frame) is a coded image, also called a predictive frame, that compresses the amount of data transmitted by a sufficiently redundant information that is less than the previously encoded frame in the image sequence; b Image (frame , it also takes into account the time redundancy information between the encoded frames behind the source image sequence to compress the encoded image of the transmitted data, also called the bidirectional prediction frame; Generally, I frame compression efficiency is the lowest, the P frame is higher and the B frame is the highest.

http://blog.csdn.net/ameyume/article/details/6722450


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.