JxlEncoderAddImageFrame

Function JxlEncoderAddImageFrame 

Source
pub unsafe extern "C-unwind" fn JxlEncoderAddImageFrame(
    options: *const JxlEncoderFrameSettings,
    pixel_format: *const JxlPixelFormat,
    buffer: *const c_void,
    size: usize,
) -> JxlEncoderStatus
Expand 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:

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:

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