Struct Aviffy

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

Config for the serialization (allows setting advanced image properties).

See Aviffy::new.

Implementations§

Source§

impl Aviffy

Source

pub fn new() -> Self

Source

pub fn premultiplied_alpha(&mut self, is_premultiplied: bool) -> &mut Self

Set whether image’s colorspace uses premultiplied alpha, i.e. RGB channels were multiplied by their alpha value, so that transparent areas are all black. Image decoders will be instructed to undo the premultiplication.

Premultiplied alpha images usually compress better and tolerate heavier compression, but may not be supported correctly by less capable AVIF decoders.

This just sets the configuration property. The pixel data must have already been processed before compression.

Source

pub fn matrix_coefficients( &mut self, matrix_coefficients: MatrixCoefficients, ) -> &mut Self

If set, must match the AV1 color payload, and will result in colr box added to AVIF. Defaults to BT.601, because that’s what Safari assumes when colr is missing. Other browsers are smart enough to read this from the AV1 payload instead.

Source

pub fn transfer_characteristics( &mut self, transfer_characteristics: TransferCharacteristics, ) -> &mut Self

If set, must match the AV1 color payload, and will result in colr box added to AVIF. Defaults to sRGB.

Source

pub fn color_primaries(&mut self, color_primaries: ColorPrimaries) -> &mut Self

If set, must match the AV1 color payload, and will result in colr box added to AVIF. Defaults to sRGB/Rec.709.

Source

pub fn full_color_range(&mut self, full_range: bool) -> &mut Self

If set, must match the AV1 color payload, and will result in colr box added to AVIF. Defaults to full.

Source

pub fn write<W: Write>( &self, into_output: W, color_av1_data: &[u8], alpha_av1_data: Option<&[u8]>, width: u32, height: u32, depth_bits: u8, ) -> Result<()>

Makes an AVIF file given encoded AV1 data (create the data with rav1e)

color_av1_data is already-encoded AV1 image data for the color channels (YUV, RGB, etc.). The color image MUST have been encoded without chroma subsampling AKA YUV444 (Cs444 in rav1e) AV1 handles full-res color so effortlessly, you should never need chroma subsampling ever again.

Optional alpha_av1_data is a monochrome image (rav1e calls it “YUV400”/Cs400) representing transparency. Alpha adds a lot of header bloat, so don’t specify it unless it’s necessary.

width/height is image size in pixels. It must of course match the size of encoded image data. depth_bits should be 8, 10 or 12, depending on how the image has been encoded in AV1.

Color and alpha must have the same dimensions and depth.

Data is written (streamed) to into_output.

Source

pub fn to_vec( &self, color_av1_data: &[u8], alpha_av1_data: Option<&[u8]>, width: u32, height: u32, depth_bits: u8, ) -> Vec<u8>

Source

pub fn set_chroma_subsampling( &mut self, subsampled_xy: (bool, bool), ) -> &mut Self

Source

pub fn set_seq_profile(&mut self, seq_profile: u8) -> &mut Self

Auto Trait Implementations§

§

impl Freeze for Aviffy

§

impl RefUnwindSafe for Aviffy

§

impl Send for Aviffy

§

impl Sync for Aviffy

§

impl Unpin for Aviffy

§

impl UnwindSafe for Aviffy

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 = 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.