Skip to main content

H265Encoder

Struct H265Encoder 

Source
pub struct H265Encoder { /* private fields */ }
Expand description

H.265 registry encoder behind the oxideav_core::Encoder contract. Every input frame becomes one Annex B access unit — a self-contained IDR (VPS + SPS + PPS + IDR_N_LP) in the two intra modes and at inter-mode GOP starts, or a TRAIL_R P slice inside an inter-mode GOP. Three coding modes, selected by the mode codec option:

  • "pcm" (default) — the PCM-only bootstrap: every coding unit a §7.3.8.7 PCM block, bit-exact lossless.
  • "intra" — real CABAC intra coding (§8.4 prediction + forward transform/quant + §7.3.8 syntax) at the qp option’s SliceQpY (0..=51, default 26).
  • "inter" — low-delay IDR, P, P, … coding (§8.5 inter prediction with per-CTU skip / merge / AMVP / intra decisions) at the qp option’s SliceQpY; the gop option sets the IDR period in frames (default 0 = a single leading IDR); the bslices option ("1" / "true") codes the non-IDR frames as low-delay B slices; the amp option switches to the AMP stream configuration (MinCbSizeY == 8, amp_enabled_flag == 1, the four asymmetric PART_2NxnU/2NxnD/nLx2N/nRx2N shapes competing in the inter CU ladder); the pyramid option (a power of two in 2..=16) switches to hierarchical-B coding — dyadic mini-GOPs coded out of display order with per-layer QP offsets — the pyramidstep option (0..=6, default 1) sets the per-layer step of that hierarchical allocation (SliceQpY = base + layer * step, composing with aq’s per-CTB deltas on top); packets then arrive in bursts per mini-GOP (dts trails pts by log2(pyramid) frames) and flush() emits the tail. pyramid excludes the gop / bslices options.

The "intra" and "inter" modes accept the §8.7 in-loop filter options deblock and sao ("1" / "true" to enable): the encoder then signals the filters, elects them per slice / CTB against distortion, and reconstructs through them (the reference path a conforming decoder holds).

The bitrate option (bits per second, optional k / M suffix) switches the "intra" / "inter" modes from constant QP to average-bitrate coding: rate::RateControlCfg semantics, with the fps option ("25" or "30000/1001", default 25) fixing the frame rate the budget is spread over and an explicit qp option seeding the starting QP. fps also sets the packet time base. bufsize (bits; requires bitrate) adds a VBV constraint: no access unit may exceed the modelled decoder buffer (frames are re-encoded at a higher QP when needed) — on the low-delay, intra AND pyramid paths, the last with per-access-unit accounting at each decode instant across the mini-GOP burst.

The aq option (1..=3, "intra" / "inter" modes) enables spatial adaptive quantization: per-CTB QP offsets from luma activity, signalled through §7.3.8.10 cu_qp_delta.

The hrd option ("1" / "true"; requires bitrate, bufsize AND an explicit fps) declares and enforces HRD conformance: the SPS VUI gains a §E.2.2 hrd_parameters( ) delivery schedule (NAL HRD, one CPB at the target rate and VBV size, VBR, fixed picture rate), every IRAP access unit carries a §D.2.2 buffering-period SEI, every access unit a §D.2.3 pic-timing SEI (the pyramid’s pic_dpb_output_delay carries its reorder schedule), and coded sizes are additionally capped by an exact Annex C CPB replay so the emitted stream satisfies the §C.4 conformance conditions. The cbr option (requires hrd) switches the schedule to constant-bit-rate delivery (cbr_flag == 1): back-to-back eq. C-3 arrivals, mid-stream initial delays held to the two-sided eq. C-19 bound, and §7.3.4 filler-data NAL units padding underruns so the CPB cannot overflow (needs a bufsize of at least two frame intervals of the bitrate).

4:2:0 8-bit, dimensions multiples of 16.

Trait Implementations§

Source§

impl Debug for H265Encoder

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Encoder for H265Encoder

Source§

fn codec_id(&self) -> &CodecId

Identifier of the codec this encoder produces.
Source§

fn output_params(&self) -> &CodecParameters

Parameters describing this encoder’s output stream (to feed into a muxer).
Source§

fn send_frame(&mut self, frame: &Frame) -> Result<()>

Feed one uncompressed frame. May or may not produce a packet immediately — call receive_packet in a loop afterwards.
Source§

fn receive_packet(&mut self) -> Result<Packet>

Pull the next encoded packet, if any. Returns Error::NeedMore when the encoder needs another frame (or a flush).
Source§

fn flush(&mut self) -> Result<()>

Signal end of input: drain internal lookahead so the remaining packets become available via receive_packet.
Source§

fn set_execution_context(&mut self, _ctx: &ExecutionContext)

Advisory: announce the runtime environment. Same semantics as Decoder::set_execution_context.

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> 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, 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, <T as TryFrom<U>>::Error>

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.