Skip to main content

AnimatedJxlEncoder

Struct AnimatedJxlEncoder 

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

Animated JPEG-XL encoder.

Builds a multi-frame JPEG-XL codestream by accumulating frames via add_frame and then producing the final codestream with finish.

§Codestream Layout

[signature (2 bytes)] [size_header] [image_metadata with animation]
[frame_header_0] [align] [frame_data_0]
[frame_header_1] [align] [frame_data_1]
...
[frame_header_N] [align] [frame_data_N]   (is_last = true)

§Examples

use oximedia_codec::jpegxl::{AnimatedJxlEncoder, JxlAnimation};

let anim = JxlAnimation::millisecond();
let mut encoder = AnimatedJxlEncoder::new(anim, 8, 8, 3, 8)?;
encoder.add_frame(&frame0_data, 100)?;  // 100ms
encoder.add_frame(&frame1_data, 200)?;  // 200ms
let codestream = encoder.finish()?;

Implementations§

Source§

impl AnimatedJxlEncoder

Source

pub fn new( animation: JxlAnimation, width: u32, height: u32, channels: u8, bit_depth: u8, ) -> CodecResult<Self>

Create a new animated encoder.

§Arguments
  • animation - Animation timing configuration
  • width - Frame width in pixels (shared by all frames)
  • height - Frame height in pixels (shared by all frames)
  • channels - Number of channels (1=gray, 3=RGB, 4=RGBA)
  • bit_depth - Bits per sample (8 or 16)
§Errors

Returns error if dimensions, channels, or bit depth are invalid.

Source

pub fn with_effort(self, effort: u8) -> Self

Set encoding effort (1-9).

Source

pub fn add_frame(&mut self, data: &[u8], duration_ticks: u32) -> CodecResult<()>

Add a frame to the animation.

§Arguments
  • data - Interleaved pixel data for this frame (same layout as JxlEncoder::encode)
  • duration_ticks - Duration of this frame in ticks (relative to animation tick rate)
§Errors

Returns error if the data size is wrong or encoding fails.

Source

pub fn frame_count(&self) -> usize

Number of frames added so far.

Source

pub fn finish_isobmff(self) -> CodecResult<Vec<u8>>

Finalize and wrap the animated codestream in an ISOBMFF container.

Produces a file beginning with a ftyp box (major brand jxl ), followed by a jxll box and a single jxlp box containing the bare codestream with the is_last flag set.

§Errors

Returns error if no frames have been added or encoding fails.

Source

pub fn finish(self) -> CodecResult<Vec<u8>>

Finalize the animated codestream.

Produces the complete multi-frame JPEG-XL bare codestream. The last frame is automatically marked with is_last = true.

§Errors

Returns error if no frames have been added.

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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.