Skip to main content

Module encode

Module encode 

Source
Expand description

Encoding API for JPEG XL.

Structs§

JxlChunkedFrameInputSource
This struct provides callback functions to pass pixel data in a streaming manner instead of requiring the entire frame data in memory at once.
JxlEncoder
Opaque structure that holds the JPEG XL encoder.
JxlEncoderFrameSettings
Settings and metadata for a single image frame. This includes encoder options for a frame such as compression quality and speed.
JxlEncoderOutputProcessor
The JxlEncoderOutputProcessor structure provides an interface for the encoder’s output processing. Users of the library, who want to do streaming encoding, should implement the required callbacks for buffering, writing, seeking (if supported), and setting a finalized position during the encoding process.

Enums§

JxlEncoderError
Error conditions: API usage errors have the 0x80 bit set to 1 Other errors have the 0x80 bit set to 0
JxlEncoderFrameSettingId
Id of encoder options for a frame. This includes options such as setting encoding effort/speed or overriding the use of certain coding tools, for this frame. This does not include non-frame related encoder options such as for boxes.
JxlEncoderStatus
Return value for multiple encoder functions.

Functions§

JxlColorEncodingSetToLinearSRGB⚠
Sets a color encoding to be linear sRGB.
JxlColorEncodingSetToSRGB⚠
Sets a color encoding to be sRGB.
JxlEncoderAddBox⚠
Adds a metadata box to the file format. JxlEncoderProcessOutput must be used to effectively write the box to the output. JxlEncoderUseBoxes must be enabled before using this function.
JxlEncoderAddChunkedFrame⚠
Adds a frame to the encoder using a chunked input source.
JxlEncoderAddImageFrame⚠
Sets the buffer to read pixels from for the next image to encode. Must call JxlEncoderSetBasicInfo before JxlEncoderAddImageFrame.
JxlEncoderAddJPEGFrame⚠
Sets the buffer to read JPEG encoded bytes from for the next frame to encode.
JxlEncoderAllowExpertOptions⚠
Enables usage of expert options.
JxlEncoderCloseBoxes⚠
Declares that no further boxes will be added with JxlEncoderAddBox. This function must be called after the last box is added so the encoder knows the stream will be finished. It is not necessary to use this function if JxlEncoderUseBoxes is not used. Further frames may still be added.
JxlEncoderCloseFrames⚠
Declares that no frames will be added and JxlEncoderAddImageFrame and JxlEncoderAddJPEGFrame won’t be called anymore. Further metadata boxes may still be added. This function or JxlEncoderCloseInput must be called after adding the last frame and the next call to JxlEncoderProcessOutput, or the frame won’t be properly marked as last.
JxlEncoderCloseInput⚠
Closes any input to the encoder, equivalent to calling JxlEncoderCloseFrames as well as calling JxlEncoderCloseBoxes if needed. No further input of any kind may be given to the encoder, but further JxlEncoderProcessOutput calls should be done to create the final output.
JxlEncoderCollectStats⚠
Sets the given stats object for gathering various statistics during encoding.
JxlEncoderCreate⚠
Creates an instance of JxlEncoder and initializes it.
JxlEncoderDestroy⚠
Deinitializes and frees a JxlEncoder instance.
JxlEncoderDistanceFromQuality⚠
Maps JPEG-style quality factor to distance.
JxlEncoderFlushInput⚠
Flushes any buffered input in the encoder, ensuring that all available input data has been processed and written to the output.
JxlEncoderFrameSettingsCreate⚠
Create a new set of encoder options, with all values initially copied from the source options, or set to default if source is NULL.
JxlEncoderFrameSettingsSetFloatOption⚠
Sets a frame-specific option of float type to the encoder options. The JxlEncoderFrameSettingId argument determines which option is set.
JxlEncoderFrameSettingsSetOption⚠
Sets a frame-specific option of integer type to the encoder options. The JxlEncoderFrameSettingId argument determines which option is set.
JxlEncoderGetError⚠
Get the (last) error code in case JxlEncoderStatus::Error was returned.
JxlEncoderGetRequiredCodestreamLevel⚠
Returns the codestream level required to support the currently configured settings and basic info. This function can only be used at the beginning, before encoding starts, but after setting basic info.
JxlEncoderInitBasicInfo⚠
Initializes a JxlBasicInfo struct to default values. For forwards-compatibility, this function has to be called before values are assigned to the struct fields. The default values correspond to an 8-bit RGB image, no alpha or any other extra channels.
JxlEncoderInitBlendInfo⚠
Initializes a JxlBlendInfo struct to default values. For forwards-compatibility, this function has to be called before values are assigned to the struct fields.
JxlEncoderInitExtraChannelInfo⚠
Initializes a JxlExtraChannelInfo struct to default values. For forwards-compatibility, this function has to be called before values are assigned to the struct fields. The default values correspond to an 8-bit channel of the provided type.
JxlEncoderInitFrameHeader⚠
Initializes a JxlFrameHeader struct to default values. For forwards-compatibility, this function has to be called before values are assigned to the struct fields. The default values correspond to a frame with no animation duration and the ‘replace’ blend mode. After using this function, animation duration must be set, and for composite still, blend settings must be set.
JxlEncoderProcessOutput⚠
Encodes a JPEG XL file using the available bytes. *avail_out indicates how many output bytes are available, and *next_out points to the input bytes. *avail_out will be decremented by the amount of bytes that have been processed by the encoder and *next_out will be incremented by the same amount, so *next_out will now point at the amount of *avail_out unprocessed bytes.
JxlEncoderReset⚠
Re-initializes a JxlEncoder instance, so it can be re-used for encoding another image. All state and settings are reset as if the object was newly created with JxlEncoderCreate, but the memory manager is kept.
JxlEncoderSetBasicInfo⚠
Sets the global metadata of the image encoded by this encoder.
JxlEncoderSetCms⚠
Sets the color management system (CMS) that will be used for color conversion (if applicable) during encoding. May only be set before starting encoding. If left unset, the default CMS implementation will be used.
JxlEncoderSetCodestreamLevel⚠
Sets the feature level of the JPEG XL codestream. Valid values are 5 and 10, or -1 (to choose automatically). Using the minimum required level, or level 5 in most cases, is recommended for compatibility with all decoders.
JxlEncoderSetColorEncoding⚠
Sets the original color encoding of the image encoded by this encoder. This is an alternative to JxlEncoderSetICCProfile and only one of these two must be used. This one sets the color encoding as a JxlColorEncoding, while the other sets it as ICC binary data. Must be called after JxlEncoderSetBasicInfo.
JxlEncoderSetDebugImageCallback⚠
Sets the given debug image callback that will be used by the encoder to output various debug images during encoding.
JxlEncoderSetExtraChannelBlendInfo⚠
Sets blend info of an extra channel. The blend info of extra channels is set separately from that of the color channels, the color channels are set with JxlEncoderSetFrameHeader.
JxlEncoderSetExtraChannelBuffer⚠
Sets the buffer to read pixels from for an extra channel at a given index. The index must be smaller than the num_extra_channels in the associated JxlBasicInfo. Must call JxlEncoderSetExtraChannelInfo before JxlEncoderSetExtraChannelBuffer.
JxlEncoderSetExtraChannelDistance⚠
Sets the distance level for lossy compression of extra channels. The distance is as in JxlEncoderSetFrameDistance (lower = higher quality). If not set, or if set to the special value -1, the distance that was set with JxlEncoderSetFrameDistance will be used.
JxlEncoderSetExtraChannelInfo⚠
Sets information for the extra channel at the given index. The index must be smaller than num_extra_channels in the associated JxlBasicInfo.
JxlEncoderSetExtraChannelName⚠
Sets the name for the extra channel at the given index in UTF-8. The index must be smaller than the num_extra_channels in the associated JxlBasicInfo.
JxlEncoderSetFrameBitDepth⚠
Sets the bit depth of the input buffer.
JxlEncoderSetFrameDistance⚠
Sets the distance level for lossy compression: target max butteraugli distance, lower = higher quality. Range: 0 .. 25. 0.0 = mathematically lossless (however, use JxlEncoderSetFrameLossless instead to use true lossless, as setting distance to 0 alone is not the only requirement). 1.0 = visually lossless. Recommended range: 0.5 .. 3.0. Default value: 1.0.
JxlEncoderSetFrameHeader⚠
Sets the frame information for this frame to the encoder. This includes animation information such as frame duration to store in the frame header. The frame header fields represent the frame as passed to the encoder, but not necessarily the exact values as they will be encoded file format: the encoder could change crop and blending options of a frame for more efficient encoding or introduce additional internal frames. Animation duration and time code information is not altered since those are immutable metadata of the frame.
JxlEncoderSetFrameLossless⚠
Enables lossless encoding.
JxlEncoderSetFrameName⚠
Sets the name of the animation frame. This function is optional, frames are not required to have a name. This setting is a part of the frame header, and the same principles as for JxlEncoderSetFrameHeader apply. The name_length field of JxlFrameHeader is ignored by the encoder, this function determines the name length instead as the length in bytes of the C string.
JxlEncoderSetICCProfile⚠
Sets the original color encoding of the image encoded by this encoder as an ICC color profile. This is an alternative to JxlEncoderSetColorEncoding and only one of these two must be used. This one sets the color encoding as ICC binary data, while the other defines it as a JxlColorEncoding. Must be called after JxlEncoderSetBasicInfo.
JxlEncoderSetOutputProcessor⚠
Sets the output processor for the encoder. This processor determines how the encoder will handle buffering, writing, seeking (if supported), and setting a finalized position during the encoding process.
JxlEncoderSetParallelRunner⚠
Set the parallel runner for multithreading. May only be set before starting encoding.
JxlEncoderSetUpsamplingMode⚠
Sets the upsampling method the decoder will use in case there are frames with JxlEncoderFrameSettingsSetOption set. This is useful in combination with the JxlEncoderFrameSettingsSetOption option, to control the type of upsampling that will be used.
JxlEncoderStoreJPEGMetadata⚠
Configure the encoder to store JPEG reconstruction metadata in the JPEG XL container.
JxlEncoderUseBoxes⚠
Indicates the intention to add metadata boxes. This allows JxlEncoderAddBox to be used. When using this function, then it is required to use JxlEncoderCloseBoxes at the end.
JxlEncoderUseContainer⚠
Forces the encoder to use the box-based container format (BMFF) even when not necessary.
JxlEncoderVersion⚠
Encoder library version.

Type Aliases§

JxlDebugImageCallback
Function type for JxlEncoderSetDebugImageCallback.