Skip to main content

h264_level

Function h264_level 

Source
pub fn h264_level(width: u32, height: u32, fps: u32, bitrate_bps: u64) -> u32
Expand description

Lowest H.264 level whose Annex-A Table A-1 limits admit a width x height stream at fps carrying up to bitrate_bps (0 where no rate is declared), as level_idc (41 = 4.1, 52 = 5.2, 62 = 6.2).

A frame is charged two ways: MaxFS, its size in macroblocks, and MaxMBPS, that size times the frame rate; a declared rate is charged against MaxBR at the High profile’s factor of 1.25, which every session here encodes with (4:4:4 allows more), since an encoder that validates the level against the rate refuses a CBR target past it. Advertising the lowest fitting level asks the least of a decoder, so clients that gate hardware decode on the level accept the widest range of streams. One shared ladder keeps every backend agreeing on the same geometry; it starts at 4.1 and a caller needing more raises the floor itself. Above 6.2’s limits there is no higher level, so it returns 62 as a best effort.