pub unsafe extern "C-unwind" fn JxlEncoderAddImageFrame(
options: *const JxlEncoderFrameSettings,
pixel_format: *const JxlPixelFormat,
buffer: *const c_void,
size: usize,
) -> JxlEncoderStatusExpand description
Sets the buffer to read pixels from for the next image to encode. Must call
JxlEncoderSetBasicInfo before JxlEncoderAddImageFrame.
Currently only some data types for pixel formats are supported:
JxlDataType::Uint8, with range 0..255JxlDataType::Uint16, with range 0..65535JxlDataType::Float16, with nominal range 0..1JxlDataType::Float, with nominal range 0..1
Note: the sample data type in pixel_format is allowed to be different from
what is described in the JxlBasicInfo. The type in pixel_format,
together with an optional JxlBitDepth parameter set by JxlEncoderSetFrameBitDepth
describes the format of the uncompressed pixel buffer. The bits_per_sample and exponent_bits_per_sample
in the JxlBasicInfo describes what will actually be encoded in the JPEG XL
codestream. For example, to encode a 12-bit image, you would set
bits_per_sample to 12, while the input frame buffer can be in the following
formats:
- if pixel format is in
JxlDataType::Uint16with default bit depth setting (i.e.JxlBitDepthType::FromPixelFormat), input sample values are rescaled to 16-bit, i.e. multiplied by 65535/4095; - if pixel format is in
JxlDataType::Uint16withJxlBitDepthType::FromCodestreambit depth setting, input sample values are provided unscaled; - if pixel format is in
JxlDataType::Float, input sample values are rescaled to 0..1, i.e. multiplied by 1.0/4095.0. While it is allowed, it is obviously not recommended to use apixel_formatwith lower precision than what is specified in theJxlBasicInfo.
We support interleaved channels as described by the JxlPixelFormat:
- single-channel data, e.g. grayscale
- single-channel + alpha
- trichromatic, e.g. RGB
- trichromatic + alpha
Extra channels not handled here need to be set by JxlEncoderSetExtraChannelBuffer.
If the image has alpha, and alpha is not passed here, it will implicitly be
set to all-opaque (an alpha value of 1.0 everywhere).
The pixels are assumed to be encoded in the original profile that is set with
JxlEncoderSetColorEncoding or JxlEncoderSetICCProfile. If none of
these functions were used, the pixels are assumed to be nonlinear sRGB for
integer data types (JxlDataType::Uint8, JxlDataType::Uint16), and linear
sRGB for floating point data types (JxlDataType::Float16, JxlDataType::Float).
Sample values in floating-point pixel formats are allowed to be outside the
nominal range, e.g. to represent out-of-sRGB-gamut colors in the
uses_original_profile=false case. They are however not allowed to be NaN or
+-infinity.
If this is the last frame, JxlEncoderCloseInput or JxlEncoderCloseFrames must be called before the next
JxlEncoderProcessOutput call.
§Parameters
frame_settings: set of options and metadata for this frame. Also includes reference to the encoder object.pixel_format: format for pixels. Object owned by the caller and its contents are copied internally.buffer: buffer type to input the pixel data from. Owned by the caller and its contents are copied internally.size: size of buffer in bytes. This size should match what is implied by the frame dimensions and the pixel format.
§Returns
JxlEncoderStatus::Successon successJxlEncoderStatus::Erroron error