pub struct Aviffy { /* private fields */ }
Expand description
Config for the serialization (allows setting advanced image properties).
See Aviffy::new
.
Implementations§
Source§impl Aviffy
impl Aviffy
pub fn new() -> Self
Sourcepub fn premultiplied_alpha(&mut self, is_premultiplied: bool) -> &mut Self
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.
Sourcepub fn matrix_coefficients(
&mut self,
matrix_coefficients: MatrixCoefficients,
) -> &mut Self
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.
Sourcepub fn transfer_characteristics(
&mut self,
transfer_characteristics: TransferCharacteristics,
) -> &mut Self
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.
Sourcepub fn color_primaries(&mut self, color_primaries: ColorPrimaries) -> &mut Self
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.
Sourcepub fn full_color_range(&mut self, full_range: bool) -> &mut Self
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.
Sourcepub 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<()>
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
.