Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 AVC / H.264

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 13th November 2008, 17:24   #1  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 6,914
How to calculating max ref for level,....

Wanting to calculate the max number of refs allowed for a specific avc level I searched the forum and then based my calculation on http://forum.doom9.org/showthread.php?t=102048
which gave me
Quote:
/***
* Restrictions:
* MaxMBPS >= width*height*fps. (w&h measured in macroblocks, i.e. pixels/16 round up in each dimension)
* MaxFS >= width*height
* sqrt(MaxFS*8) >= width
* sqrt(MaxFS*8) >= height
* MaxDPB >= (bytes in a frame) * min(16, ref + (pyramid ? 2 : bframes ? 1 : 0))
* MaxBR >= vbv_maxrate.
* MaxCPB >= vbv_bufsize.
* MaxVmvR >= max_mv_range.
* MaxMvsPer2Mb, MinLumaBiPredSize, direct_8x8_inference_flag : are not enforced by x264. The only way to ensure compliance is to disable p4x4 at level>=3.1, or at level>=3 w/ B-frames.
* MinCR : is not enforced by x264. Won't ever be an issue unless you use lossless.
* SliceRate : I don't know what this limits.latexxx once posted the values needed for these factors:
* VALUES FOR LEVEL: http://forum.doom9.org/showthread.php?t=101345
*
* LEGEND:
* MaxDPB = max decoded picture buffer
* MaxMBPS = max macroblocks per second
* MaxFS = max frame size
* MaxBR = max bitrate
* MaxCPB = max vbv buffer
* MaxVmvR = max motion vetor range
***/
so taking
MaxDPB >= (bytes in a frame) * min(16, ref + (pyramid ? 2 : bframes ? 1 : 0))
as basis I rearranged it to
Min(this->maxDPB(level)/bytesPerFrame - bframeModifier, 16)
where:
maxDPB = 12582912 (for Level 4.1)
bytesPerFrame = (pixel width)*(pixel height)*1.5 (since x264 only support 4:2:0 atm) = 1920*1080*1.5
bframeModifier = 0 when no bframes are used, 1 when bframes are enabled and 2 when bframes&pyramid are enabled.

using this I get:

with bframes:
Min(this->maxDPB(level)/bytesPerFrame - bframeModifier, 16)
maxDPB = 12582912
bytesPerFrame = 3110401
maxDPB/bytesPerFrame = 4
bframeModifier = 0
-> maxRef = 4

with bframes:
Min(this->maxDPB(level)/bytesPerFrame - bframeModifier, 16)
maxDPB = 12582912
bytesPerFrame = 3110401
maxDPB/bytesPerFrame = 4
bframeModifier = 1
-> maxRef = 3

with bframes&pyramid:
Min(this->maxDPB(level)/bytesPerFrame - bframeModifier, 16)
maxDPB = 12582912
bytesPerFrame = 3110401
maxDPB/bytesPerFrame = 4
bframeModifier = 2
-> maxRef = 2


Trahald&Co nutzen die Formel:
min( 1024 * MaxDPB/(PicWidthInMbs * FrameHeightInMbs * 384), 16)
1024 * (12288) / (120 * (( 2 – frame_mbs_only_flag ) * PicHeightInMapUnits) * 384)
maxDPB / (Width/16 * ( 2 – frame_mbs_only_flag ) * Height/16 * 384)
wobei frame_mbs_only_flag = 0 heißt man encoded interlaced

But looking at http://forum.doom9.org/showthread.php?t=136258 Trahald uses a different formula.
Quote:
maxDPB / (PicWidth/16 * (( 2 – frame_mbs_only_flag ) * FrameHeight/16) * 384)
maxDPB = 12582912 (for Level 4.1)
and frame_mbs_only_flag = 1 assuming the material is progressive (iiirc frame_mbs_only_flag = 0 means material is interlaced)
1st thing about this formula that I registered was that:
a. it doesn't care about B-Frames
b. it cares about interlacing

Thanks for reading up to here.
Now here's my question/problem:

How does one calculate the maximum number of frames?
(I suspect that the 'real' formula is a mix of the two above. )



Cu Selur
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 00:43.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.