pub struct HevcConfig {Show 14 fields
pub width: u32,
pub height: u32,
pub coded_width: u32,
pub coded_height: u32,
pub chroma_format_idc: u8,
pub level_idc: u8,
pub full_range: bool,
pub pcm_enabled: bool,
pub qp: i32,
pub max_transform_hierarchy_depth_intra: u32,
pub ctb_log2: u32,
pub min_cb_log2: u32,
pub max_tb_log2: u32,
pub tile_grid: (u32, u32),
}Expand description
Fixed configuration for the minimal PCM encoder. Sizes are luma samples.
Fields§
§width: u32Displayed picture width (any positive value; coded size is padded to a multiple of the CTB size and cropped back via the conformance window).
height: u32Displayed picture height.
coded_width: u32Coded width, padded up to a multiple of CTB_SIZE.
coded_height: u32Coded height, padded up to a multiple of CTB_SIZE.
chroma_format_idc: u8chroma_format_idc: 1 = 4:2:0 (color), 0 = monochrome (4:0:0). The
alpha auxiliary layer of a transparent video is monochrome.
level_idc: u8general_level_idc (level × 30). 180 = 6.0 (roomy default); the
transparent path matches Apple’s reference with 30 (level 1.0).
full_range: boolSignal video_full_range_flag = 1 via a minimal VUI. The alpha auxiliary
layer needs this so its 0..255 luma is read as full-range opacity rather
than expanded from limited [16,235].
pcm_enabled: boolEnable I_PCM in the SPS. The lossless PCM path needs it; the compressed (transform-coded) path disables it.
qp: i32Slice QP: CABAC context init, and (compressed path) the quantization step.
max_transform_hierarchy_depth_intra: u32max_transform_hierarchy_depth_intra: how many times an intra CU’s
transform tree may split. 0 pins one transform block per CU; 1 allows
16x16 to split into four 8x8.
This is not just a transform-size knob. HEVC does intra prediction per transform block from already-reconstructed neighbours, so splitting also shortens the prediction distance — an 8x8 block predicts from the 8x8 next to it rather than from the CTB edge 16 samples away.
ctb_log2: u32log2 of the coding-tree-block edge.
min_cb_log2: u32log2 of the smallest coding block the quadtree may reach. Equal to
HevcConfig::ctb_log2 means no quadtree: one coding unit per CTB.
max_tb_log2: u32log2 of the largest transform block. A coding block bigger than this
has its transform tree split without signalling it.
tile_grid: (u32, u32)Tile columns and rows. (1, 1) means the picture is one tile, which is
to say untiled.
Tiles break intra prediction and reset the entropy coder at their edges, so each one can be coded independently — and therefore concurrently. That costs bitrate in proportion to how much tile boundary the picture gains: measured on photographic content, 2x2 at 8K costs 0.7%, 2x2 at 4K costs 1.0%, and 4x4 at 4K costs 5.1%. Prefer few large tiles.
Implementations§
Source§impl HevcConfig
impl HevcConfig
Sourcepub fn new(width: u32, height: u32) -> Self
pub fn new(width: u32, height: u32) -> Self
Build a 4:2:0 (color) config for a width × height picture, padding the
coded size up to whole CTBs.
Sourcepub fn new_monochrome(width: u32, height: u32) -> Self
pub fn new_monochrome(width: u32, height: u32) -> Self
Build a monochrome (4:0:0) config — used for the alpha auxiliary layer.
Sourcepub fn with_pcm(self, enabled: bool) -> Self
pub fn with_pcm(self, enabled: bool) -> Self
Enable/disable I_PCM in the SPS (disable for the compressed path).
Sourcepub fn with_transform_depth(self, depth: u32) -> Self
pub fn with_transform_depth(self, depth: u32) -> Self
Set max_transform_hierarchy_depth_intra (see the field).
Sourcepub fn with_level(self, level_idc: u8) -> Self
pub fn with_level(self, level_idc: u8) -> Self
Set general_level_idc (level × 30).
Sourcepub fn with_full_range(self, full_range: bool) -> Self
pub fn with_full_range(self, full_range: bool) -> Self
Signal full-range luma/chroma (needed for the alpha auxiliary layer).
Sourcepub fn has_chroma(&self) -> bool
pub fn has_chroma(&self) -> bool
Whether this picture carries chroma planes.
Sourcepub fn sub_wh(&self) -> (u32, u32)
pub fn sub_wh(&self) -> (u32, u32)
(SubWidthC, SubHeightC) — chroma subsampling (1,1 for monochrome; 2,2 for 4:2:0).
Sourcepub fn with_tiles(self, cols: u32, rows: u32) -> Self
pub fn with_tiles(self, cols: u32, rows: u32) -> Self
Split the picture into cols x rows tiles.
The grid is reduced if needed so every tile is at least 256 luma samples wide and 64 tall: the Main profiles’ minimum tile size (Annex A). A narrower tiling decodes in tolerant decoders but the reference decoder rejects it.
Sourcepub fn with_auto_tiles(self) -> Self
pub fn with_auto_tiles(self) -> Self
Tile the picture only if it is large enough for the tiles to be free.
Sourcepub fn ctbs(&self) -> (u32, u32)
pub fn ctbs(&self) -> (u32, u32)
Number of CTBs across / down the coded picture. The last row and column may hang off the edge; the quadtree splits them down to blocks that fit.
Sourcepub fn with_coding_tree(
self,
ctb_log2: u32,
min_cb_log2: u32,
max_tb_log2: u32,
) -> Self
pub fn with_coding_tree( self, ctb_log2: u32, min_cb_log2: u32, max_tb_log2: u32, ) -> Self
Set the coding-tree sizes and re-pad the coded picture to whole minimum coding blocks — which is all HEVC requires, so a bigger CTB costs no extra padding.
Trait Implementations§
Source§impl Clone for HevcConfig
impl Clone for HevcConfig
impl Copy for HevcConfig
Auto Trait Implementations§
impl Forget for HevcConfig
impl Freeze for HevcConfig
impl Move for HevcConfig
impl RefUnwindSafe for HevcConfig
impl Send for HevcConfig
impl Sync for HevcConfig
impl Unpin for HevcConfig
impl UnsafeUnpin for HevcConfig
impl UnwindSafe for HevcConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more