H.264 (MPEG-4 AVC level), DPB and maxdpbmbs

Source: Internet
Author: User
H.264 (MPEG-4 AVC level), DPB and maxdpbmbs details published in February 16, 2012
By keith70

For H.264 (MPEG-4 AVC), level is equally important as profile. However, many articles briefly describe that SD videos generally use 3.1 and HD videos use 4. The specific meaning is unknown. So I did some research.

I. Level Details table

Level is used to constrain resolution, frame rate, and bit rate. For more information, see Appendix A in the H.264 calculator webpage.

Glossary:

Level: level. Max macroblocks: Maximum number of macro blocks. Note: The macro block size is 16x16. Per Second: the maximum number of macro blocks per second ). It can be used to constrain the frame rate. Per frame: the maximum number of macro blocks per frame ). It can be used to constrain resolution. Max video bit rate (kbit/s): Maximum video bit rate. There are differences between different grades (profile. BP: Baseline profile, baseline grade. XP: Extended profile, advanced grade. MP: Main profile, Main grade. Hip: high profile, advanced grade. Hi10p: High 10 profile, advanced 10-bit level. Hi422p: high profile, advanced grade. Hi444pp: High predictive profile, advanced (Experimental ?) Grade. Examples for High Resolution @ Frame Rate (max stored frames): Example: High Resolution @ Frame Rate (maximum number of storage frames ).
Ii. Estimate resolution and Frame Rate

During video suppression, bit rate selection is easy to judge. The relationship between resolution and frame rate and level is not that obvious. So we need to find the calculation method.
First, let's take a look at the level of common video resolutions --
480 P (800x480): If the frame rate is lower than 13.5, 2.2 is used. If the frame rate is between 13.5 and 27, 3 is used, and the frame rate is higher than 27, 3.1 is used.
720 p (1280x720): generally 3.1.
1080 p (1920x1080): generally 4.

We can see that 480 P (800x480) is a little special, so I will take it as an example to explain how to calculate the resolution and frame rate.
Because the macro block size is 16 × 16, we calculate the number of horizontal macro blocks (picwidthinmbs) and the number of vertical macro blocks (frameheightinmbs) based on this information )--
Horizontal macro size = Ceil (Video width/16) = Ceil (800/16) = Ceil (50.0) = 50
Number of vertical macro blocks = Ceil (Video height/16) = Ceil (480/16) = Ceil (30.0) = 30
Note: Ceil (x) is the top rounding function and returns the smallest integer greater than or equal to X.

Then calculate the number of macro blocks per frame (macroblocks per frame )--
Number of macro blocks per frame = number of horizontal macro blocks * Number of vertical macro blocks = 50*30 = 1500

According to the preceding table, the minimum number of 1500 macro blocks per frame is 2.2.
The maximum number of macro blocks per second (max macroblocks per second) allowed by level 2.2 is 20250. 20250/1500 = 13.5. That is, up to 13.5 frames per second are supported.
The maximum number of macros per second allowed by Level 3 is 40500. 40500/1500 = 27. That is, up to 27 frames per second are supported.
Increase the level by 3.1. The maximum number of macro blocks per second is 108000. 108000/1500 = 72. That is, up to 72 frames per second are supported.

When the number of macro blocks exceeds the limit, x264 displays this warning message --
X264 [Warning]: frame MB size (120 × 68)> level limit (5120)

Iii. maximum storage frames, DPB and maxdpbmbs

In the preceding Details table, there is also a mysterious field-Max stored frames ). Where did it come from?

The maximum number of storage frames is related to DPB-DPB: decoded picture buffer, decoding the image cache. During video decoding, You need to cache several recent reference frames. This buffer zone is called DPB. Therefore, the maximum number of storage frames is also the maximum number of reference frames (REF ). Generally, DPB is measured in the unit of the number of macro blocks (dpbmbs). The formula is --
Dpbmbs = REF (refer to the number of frames) * picwidthinmbs (number of horizontal macro blocks) * frameheightinmbs (number of vertical macro blocks)

At different levels, maxdpbmbs (maximum number of macro blocks in the decoded image cache) is different --

LevelMaxDpbMbs13961b3961.19001.22,3761.32,37622,3762.14,7522.28,10038,1003.118,0003.220,480432,7684.132,7684.234,8165110,4005.1184,320

We can roll out the maximum number of reference frames based on maxdpbmbs constraints --
Max_ref = min (floor (maxdpbmbs/(picwidthinmbs * frameheightinmbs), 16)
Note 1: floor (x) is the base rounding function, and returns the largest integer smaller than or equal to X.
Note 2: The maximum number of reference frames (REF) is 16.

Click to open: H.264 Level Calculator (h264 Level Calculator) (JavaScript web edition)

Address: http://www.cnblogs.com/zyl910/archive/2011/12/08/h264_level.html

Reprinted Please note:Reposted from megui Chinese Blog

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.