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
impl AnimatedJxlEncoder
Sourcepub fn new(
animation: JxlAnimation,
width: u32,
height: u32,
channels: u8,
bit_depth: u8,
) -> CodecResult<Self>
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 configurationwidth- 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.
Sourcepub fn with_effort(self, effort: u8) -> Self
pub fn with_effort(self, effort: u8) -> Self
Set encoding effort (1-9).
Sourcepub fn frame_count(&self) -> usize
pub fn frame_count(&self) -> usize
Number of frames added so far.
Sourcepub fn finish_isobmff(self) -> CodecResult<Vec<u8>>
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.
Auto Trait Implementations§
impl Freeze for AnimatedJxlEncoder
impl RefUnwindSafe for AnimatedJxlEncoder
impl Send for AnimatedJxlEncoder
impl Sync for AnimatedJxlEncoder
impl Unpin for AnimatedJxlEncoder
impl UnsafeUnpin for AnimatedJxlEncoder
impl UnwindSafe for AnimatedJxlEncoder
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
Mutably borrows from an owned value. Read more
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>
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 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>
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