Skip to main content

HevcConfig

Struct HevcConfig 

Source
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: u32

Displayed picture width (any positive value; coded size is padded to a multiple of the CTB size and cropped back via the conformance window).

§height: u32

Displayed picture height.

§coded_width: u32

Coded width, padded up to a multiple of CTB_SIZE.

§coded_height: u32

Coded height, padded up to a multiple of CTB_SIZE.

§chroma_format_idc: u8

chroma_format_idc: 1 = 4:2:0 (color), 0 = monochrome (4:0:0). The alpha auxiliary layer of a transparent video is monochrome.

§level_idc: u8

general_level_idc (level × 30). 180 = 6.0 (roomy default); the transparent path matches Apple’s reference with 30 (level 1.0).

§full_range: bool

Signal 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: bool

Enable I_PCM in the SPS. The lossless PCM path needs it; the compressed (transform-coded) path disables it.

§qp: i32

Slice QP: CABAC context init, and (compressed path) the quantization step.

§max_transform_hierarchy_depth_intra: u32

max_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: u32

log2 of the coding-tree-block edge.

§min_cb_log2: u32

log2 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: u32

log2 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

Source

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.

Source

pub fn new_monochrome(width: u32, height: u32) -> Self

Build a monochrome (4:0:0) config — used for the alpha auxiliary layer.

Source

pub fn with_pcm(self, enabled: bool) -> Self

Enable/disable I_PCM in the SPS (disable for the compressed path).

Source

pub fn with_transform_depth(self, depth: u32) -> Self

Set max_transform_hierarchy_depth_intra (see the field).

Source

pub fn with_level(self, level_idc: u8) -> Self

Set general_level_idc (level × 30).

Source

pub fn with_full_range(self, full_range: bool) -> Self

Signal full-range luma/chroma (needed for the alpha auxiliary layer).

Source

pub fn has_chroma(&self) -> bool

Whether this picture carries chroma planes.

Source

pub fn sub_wh(&self) -> (u32, u32)

(SubWidthC, SubHeightC) — chroma subsampling (1,1 for monochrome; 2,2 for 4:2:0).

Source

pub fn tiles(&self) -> u32

Total tile count.

Source

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.

Source

pub fn with_auto_tiles(self) -> Self

Tile the picture only if it is large enough for the tiles to be free.

Source

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.

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for HevcConfig

Source§

impl Debug for HevcConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.