Intel Sandy-bridge h264 encoder GOP setting

Source: Internet
Author: User

Intel Sandy-bridge HW h264 EncoderGOP
(Group of pictures) settings

You can set h264 encoder parameters by referring to the sample code provided by the Intel Media SDK:

 

Intel (r) Media SDK encoding sample
Usage: sample_encode.exe h264 | MPEG2 [Options]-I inputyuvfile-O outputencodedfi
Le-W width-H height
Options:
[-Nv12]-input is in nv12 color format, if not specified yuv420 is expected
[-TFF | BFF]-input stream is interlaced, top | bottom fielf first, if not speci
Fied progressive is expected
[-F framerate]-Video Frame Rate (frames per second)
[-B bitrate]-encoded bit rate (kbits per second)
[-U speed | quality | balanced]-target usage
[-T numthreads]-Number of threads; default value 0
[-Dstw]-destination picture width, invokes VPP resizing
[-Dsomething]-destination picture height, invokes VPP resizing
[-HW]-use platform specific SDK implementation, if not specified software I
Mplementation is used
[-D3d]-work with d3d Surfaces

Including: input format, frame rate, output bit rate, input video stream width and height, and output video stream width and height.
Here, we find that, for example, the parameters of I, B, and P frames are not set, that is, the parameter settings are not developed in the demo.
The following is a brief introduction of frames I, B, and P.
I-frame: it also becomes a key frame. I-frames are completely self-indicated and do not use any other frame information. It accounts for the largest proportion of the three frames and has the highest quality, but the compression efficiency is the lowest.
P-frame: p-frame is a so-called "probe" frame. When a P-frame is created, the encoder can view the redundant image information in the I-frame or p-frame. P-frames are more efficient than I-frames, but not B-frames.
B-frame: B-frame is a bidirectional prediction frame. As you can see in figure 5, this means that when we create B-frame, the encoder can search for redundant image information both forward and backward. This gives B-frame the best efficiency among the three frames.
Note that B-frames are not available when the baseline method is used to produce videos.

Recording shows that the default I, B, and P frames have an interval of 255 between adjacent I frames, and the distribution of B and P frames between two I frames is:
I * p * B... I * p * B...

This type of video is used for real-time compression. For example, if the camera compresses the h264 video in real time, a black screen may occur at the beginning of preview.
I frame is too long to be separated. If the previous I frame is lost, you need to refer to the next I frame for subsequent decode.
(I, B, and P frames of h264 are not studied much. please correct me)
For a 30 FPS video stream, it may take about 10 seconds to display normally.

For this reason, we hope to adjust the I, B, and P structures. View the guide of the Intel Media SDK,
We found that intel provided such a parameter that allowed us to adjust the composition of I, B, and P, specifically gopoptflag:
Gopoptflag
Description
The gopoptflag enumerator itemizes special properties in the GOP (Group of pictures) sequence.
Name/Description
Mfx_gop_closed
B-frames of the first B-interval can never reference the previous GOP
Mfx_gop_strict
The encoder must strictly follow the given GOP structure as defined by parameter goppicsize,
Goprefdist etc in the mfxvideoparam structure. Otherwise, the encoder can adapt the GOP structure
For better efficiency, whose range is constrained by parameter goppicsize and goprefdist etc.
Change history
This enumerator is available since SDK APIs 1.0.

The position of gopoptflag is:
Mfxvideoparam-> mfxinfomfx-> gopoptflag
For more information about the parameters that need to be used, see mfxinfomfx:
Mfx16goppicsize;
Mfx16goprefdist;
Mfx2010gopoptflag;
Mfx2010numrefframe;

Goppicsize
Number of pictures within the current GOP (Group of pictures); If goppicsize = 0, then the GOP size is unspecified.
If goppicsize = 1, only I-frames are used. See example 11 for pseudo-code that demonstrates how SDK uses this parameter.
Goprefdist
Distance between I-or p-key frames; if it is zero, the GOP structure is unspecified. Note:
If goprefdist = 1, there are no B-frames used. See example 11 for pseudo-code that demonstrates how SDK uses this parameter.
Gopoptflag
Ors of the gopoptflag enumerator indicate the additional flags for the GOP specification;
See example 11 for an example of pseudo-code that demonstrates how to use this parameter.
Numrefframe
Number of reference frames; If numrefframe = 0, this parameter is not specified.

Here is an example:
Gopoptflag = mfx_gop_strict
Goppicsize = 10;
Goprefdist = 3;
Numrefframe = 1;
The result is as follows:

The preceding parameter settings are as follows:
Mfxstatus mfxvideoencode_init (mfxsession session, mfxvideoparam * par );
Save it to the mfxvideoparam * par parameter.

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.