Expand description
Decoding API for JPEG XL.
Structs§
- JxlDecoder
- Opaque structure that holds the JPEG XL decoder.
Enums§
- JxlColor
Profile Target - Defines which color profile to get: the profile from the codestream
metadata header, which represents the color profile of the original image,
or the color profile from the pixel data produced by the decoder. Both are
the same if the
JxlBasicInfohasuses_original_profileset. - JxlDecoder
Status - Return value for
JxlDecoderProcessInput. The values fromJxlDecoderStatus::BasicInfoonwards are optional informative events that can be subscribed to, they are never returned if they have not been registered withJxlDecoderSubscribeEvents. - JxlProgressive
Detail - Types of progressive detail. Setting a progressive detail with value N implies all progressive details with smaller or equal value. Currently only the following level of progressive detail is implemented:
- JxlSignature
- The result of
JxlSignatureCheck.
Functions§
- JxlDecoder
Close ⚠Input - Marks the input as finished, indicates that no more
JxlDecoderSetInputwill be called. This function allows the decoder to determine correctly if it should return success, need more input or error in certain cases. For backwards compatibility with a previous version of the API, using this function is optional when not using theJxlDecoderStatus::Boxevent (the decoder is able to determine the end of the image frames without marking the end), but using this function is required when usingJxlDecoderStatus::Boxfor getting metadata box contents. This function does not replaceJxlDecoderReleaseInput, that function should still be called if its return value is needed. - JxlDecoder
Create ⚠ - Creates an instance of
JxlDecoderand initializes it. - JxlDecoder
Destroy ⚠ - Deinitializes and frees
JxlDecoderinstance. - JxlDecoder
Extra ⚠Channel Buffer Size - Returns the minimum size in bytes of an extra channel pixel buffer for the
given format. This is the buffer for
JxlDecoderSetExtraChannelBuffer. Requires the basic image information is available in the decoder. - JxlDecoder
Flush ⚠Image - Outputs progressive step towards the decoded image so far when only partial
input was received. If the flush was successful, the buffer set with
JxlDecoderSetImageOutBufferwill contain partial image data. - JxlDecoder
GetBasic ⚠Info - Outputs the basic image information, such as image dimensions, bit depth and
all other
JxlBasicInfofields, if available. - JxlDecoder
GetBox ⚠Size Contents - Returns the size of the contents of a box, after the
JxlDecoderStatus::Boxevent. This does not include any of the headers of the box. For compressed “brob” boxes, this is the size of the compressed content. Even whenJxlDecoderSetDecompressBoxesis enabled, the return value of function does not change, and the decompressed size is not known before it has already been decompressed and output. - JxlDecoder
GetBox ⚠Size Raw - Returns the size of a box as it appears in the container file, after the
JxlDecoderStatus::Boxevent. This includes all the box headers. - JxlDecoder
GetBox ⚠Type - Outputs the type of the current box, after a
JxlDecoderStatus::Boxevent occurred, as4characters without null termination character. In case of a compressed “brob” box, this will return “brob” if the decompressed argument isJxlBool::False, or the underlying box type if the decompressed argument isJxlBool::True. - JxlDecoder
GetColor ⚠AsEncoded Profile - Outputs the color profile as JPEG XL encoded structured data, if available. This is an alternative to an ICC Profile, which can represent a more limited amount of color spaces, but represents them exactly through enum values.
- JxlDecoder
GetColor ⚠AsICC Profile - Outputs ICC profile if available. The profile is only available if
JxlDecoderGetICCProfileSizereturns success. The output buffer must have at least as many bytes as given byJxlDecoderGetICCProfileSize. - JxlDecoder
GetExtra ⚠Channel Blend Info - Outputs the blend information for the current frame for a specific extra
channel. This function can be called once the
JxlDecoderStatus::Frameevent occurred for the current frame, even if thehave_animationfield in theJxlBasicInfoisJxlBool::False. This information is only useful if coalescing is disabled; otherwise the decoder will have performed blending already. - JxlDecoder
GetExtra ⚠Channel Info - Outputs information for extra channel at the given index. The index must be
smaller than
num_extra_channelsin the associatedJxlBasicInfo. - JxlDecoder
GetExtra ⚠Channel Name - Outputs name for extra channel at the given index in UTF-8. The index must be
smaller than
num_extra_channelsin the associatedJxlBasicInfo. The buffer for name must have at leastname_length + 1bytes allocated, gotten from the associatedJxlExtraChannelInfo. - JxlDecoder
GetFrame ⚠Header - Outputs the information from the frame, such as duration when
have_animation. This function can be called whenJxlDecoderStatus::Frameoccurred for the current frame, even whenhave_animationin theJxlBasicInfoisJxlBool::False. - JxlDecoder
GetFrame ⚠Name - Outputs name for the current frame. The buffer for name must have at least
name_length + 1bytes allocated, gotten from the associatedJxlFrameHeader. - JxlDecoder
GetICC ⚠Profile Size - Outputs the size in bytes of the ICC profile returned by
JxlDecoderGetColorAsICCProfile, if available, or indicates there is none available. In most cases, the image will have an ICC profile available, but if it does not,JxlDecoderGetColorAsEncodedProfilemust be used instead. - JxlDecoder
GetIntended ⚠Downsampling Ratio - Returns the intended downsampling ratio for the progressive frame produced
by
JxlDecoderFlushImageafter the latestJxlDecoderStatus::FrameProgressionevent. - JxlDecoder
Image ⚠OutBuffer Size - Returns the minimum size in bytes of the image output pixel buffer for the
given format. This is the buffer for
JxlDecoderSetImageOutBuffer. Requires that the basic image information is available in the decoder in the case of coalescing enabled (default). In case coalescing is disabled, this can only be called after theJxlDecoderStatus::Frameevent occurs. In that case, it will return the size required to store the possibly cropped frame (which can be larger or smaller than the image dimensions). - JxlDecoder
Preview ⚠OutBuffer Size - Returns the minimum size in bytes of the preview image output pixel buffer
for the given format. This is the buffer for
JxlDecoderSetPreviewOutBuffer. Requires the preview header information is available in the decoder. - JxlDecoder
Process ⚠Input - Decodes JPEG XL file using the available bytes. Requires input has been
set with
JxlDecoderSetInput. AfterJxlDecoderProcessInput, input can optionally be released withJxlDecoderReleaseInputand then set again to next bytes in the stream.JxlDecoderReleaseInputreturns how many bytes are not yet processed, before a next call toJxlDecoderProcessInputall unprocessed bytes must be provided again (the address need not match, but the contents must), and more bytes may be concatenated after the unprocessed bytes. - JxlDecoder
Release ⚠BoxBuffer - Releases buffer which was provided with
JxlDecoderSetBoxBuffer. - JxlDecoder
Release ⚠Input - Releases input which was provided with
JxlDecoderSetInput. BetweenJxlDecoderProcessInputandJxlDecoderReleaseInput, the user may not alter the data in the buffer. CallingJxlDecoderReleaseInputis required whenever any input is already set and new input needs to be added withJxlDecoderSetInput, but is not required beforeJxlDecoderDestroyorJxlDecoderReset. CallingJxlDecoderReleaseInputwhen no input is set is not an error and returns0. - JxlDecoder
ReleaseJPEG ⚠Buffer - Releases buffer which was provided with
JxlDecoderSetJPEGBuffer. - JxlDecoder
Reset ⚠ - Re-initializes a
JxlDecoderinstance, so it can be re-used for decoding another image. All state and settings are reset as if the object was newly created withJxlDecoderCreate, but the memory manager is kept. - JxlDecoder
Rewind ⚠ - Rewinds decoder to the beginning. The same input must be given again from
the beginning of the file and the decoder will emit events from the beginning
again. When rewinding (as opposed to
JxlDecoderReset), the decoder can keep state about the image, which it can use to skip to a requested frame more efficiently withJxlDecoderSkipFrames. Settings such as parallel runner or subscribed events are kept. After rewind,JxlDecoderSubscribeEventscan be used again, and it is feasible to leave out events that were already handled before, such asJxlDecoderStatus::BasicInfoandJxlDecoderStatus::ColorEncoding, since they will provide the same information as before. The difference toJxlDecoderResetis that some state is kept, namely settings set by a call to - JxlDecoder
SetBox ⚠Buffer - Sets output buffer for box output codestream.
- JxlDecoder
SetCms ⚠ - Sets the color management system (CMS) that will be used for color
conversion (if applicable) during decoding. May only be set before starting
decoding and must not be called after
JxlDecoderSetOutputColorProfile. - JxlDecoder
SetCoalescing ⚠ - Enables or disables coalescing of zero-duration frames. By default, frames are returned with coalescing enabled, i.e. all frames have the image dimensions, and are blended if needed. When coalescing is disabled, frames can have arbitrary dimensions, a non-zero crop offset, and blending is not performed. For display, coalescing is recommended. For loading a multi-layer still image as separate layers (as opposed to the merged image), coalescing has to be disabled.
- JxlDecoder
SetDecompress ⚠Boxes - Configures whether to get boxes in raw mode or in decompressed mode. In raw mode, boxes are output as their bytes appear in the container file, which may be decompressed, or compressed if their type is “brob”. In decompressed mode, “brob” boxes are decompressed with Brotli before outputting them. The size of the decompressed stream is not known before the decompression has already finished.
- JxlDecoder
SetDesired ⚠Intensity Target - Requests that the decoder perform tone mapping to the peak display luminance
passed as
desired_intensity_target, if appropriate. - JxlDecoder
SetExtra ⚠Channel Buffer - Sets the buffer to write an extra channel to. This can be set when
the
JxlDecoderStatus::FrameorJxlDecoderStatus::NeedImageOutBufferevent occurs, and applies only for the current frame. The size of the buffer must be at least as large as given byJxlDecoderExtraChannelBufferSize. The buffer follows the format described byJxlPixelFormat, but wherenum_channelsis1. The buffer is owned by the caller. The amount of extra channels is given by thenum_extra_channelsfield in the associatedJxlBasicInfo, and the information of individual extra channels can be queried withJxlDecoderGetExtraChannelInfo. To get multiple extra channels, this function must be called multiple times, once for each wanted index. Not all images have extra channels. The alpha channel is an extra channel and can be gotten as part of the color channels when using an RGBA pixel buffer withJxlDecoderSetImageOutBuffer, but additionally also can be gotten separately as extra channel. The color channels themselves cannot be gotten this way. - JxlDecoder
SetImage ⚠OutBit Depth - Sets the bit depth of the output buffer or callback.
- JxlDecoder
SetImage ⚠OutBuffer - Sets the buffer to write the full resolution image to. This can be set when
the
JxlDecoderStatus::Frameevent occurs, must be set when theJxlDecoderStatus::NeedImageOutBufferevent occurs, and applies only for the current frame. The size of the buffer must be at least as large as given byJxlDecoderImageOutBufferSize. The buffer follows the format described byJxlPixelFormat. The buffer is owned by the caller. - JxlDecoder
SetImage ⚠OutCallback - Sets pixel output callback. This is an alternative to
JxlDecoderSetImageOutBuffer. This can be set when theJxlDecoderStatus::Frameevent occurs, must be set when theJxlDecoderStatus::NeedImageOutBufferevent occurs, and applies only for the current frame. Only one ofJxlDecoderSetImageOutBufferorJxlDecoderSetImageOutCallbackmay be used for the same frame, not both at the same time. - JxlDecoder
SetInput ⚠ - Sets input data for
JxlDecoderProcessInput. The data is owned by the caller and may be used by the decoder untilJxlDecoderReleaseInputis called or the decoder is destroyed or reset, so it must be kept alive until then. Cannot be called ifJxlDecoderSetInputwas already called andJxlDecoderReleaseInputwas not yet called, and cannot be called afterJxlDecoderCloseInputindicating the end of input was called. - JxlDecoder
SetJPEG ⚠Buffer - Sets output buffer for reconstructed JPEG codestream.
- JxlDecoder
SetKeep ⚠Orientation - Enables or disables preserving of as-in-bitstream pixeldata orientation. Some images are encoded with an Orientation tag indicating that the decoder must perform a rotation and/or mirroring to the encoded image data.
- JxlDecoder
SetMultithreaded ⚠Image OutCallback - Similar to
JxlDecoderSetImageOutCallbackexcept that the callback is allowed an initialization phase during which it is informed of how many threads will call it concurrently, and those calls are further informed of which thread they are occurring in. - JxlDecoder
SetOutput ⚠Color Profile - Sets the desired output color profile of the decoded image either from a
color encoding or an ICC profile. Valid calls of this function have either
color_encodingoricc_dataset toNULLandicc_sizemust be0if and only ificc_dataisNULL. - JxlDecoder
SetParallel ⚠Runner - Set the parallel runner for multithreading. May only be set before starting decoding.
- JxlDecoder
SetPreferred ⚠Color Profile - Sets the desired output color profile of the decoded image by calling
JxlDecoderSetOutputColorProfile, passing oncolor_encodingand settingicc_datatoNULL. SeeJxlDecoderSetOutputColorProfilefor details. - JxlDecoder
SetPreview ⚠OutBuffer - Sets the buffer to write the low-resolution preview image
to. The size of the buffer must be at least as large as given by
JxlDecoderPreviewOutBufferSize. The buffer follows the format described byJxlPixelFormat. The preview image dimensions are given by theJxlPreviewHeader. The buffer is owned by the caller. - JxlDecoder
SetProgressive ⚠Detail - Configures at which progressive steps in frame decoding the
JxlDecoderStatus::FrameProgressionevent occurs. The default value for the level of detail if this function is never called isJxlProgressiveDetail::DC. - JxlDecoder
SetRender ⚠Spotcolors - Enables or disables rendering spot colors. By default, spot colors
are rendered, which is OK for viewing the decoded image. If
render_spotcolorsisJxlBool::False, then spot colors are not rendered, and have to be retrieved separately usingJxlDecoderSetExtraChannelBuffer. This is useful for e.g. printing applications. - JxlDecoder
SetUnpremultiply ⚠Alpha - Enables or disables preserving of associated alpha channels. If
unpremul_alphais set toJxlBool::Falsethen for associated alpha channel, the pixel data is returned with premultiplied colors. If it is set toJxlBool::True, the colors will be unpremultiplied based on the alpha channel. This function has no effect if the image does not have an associated alpha channel. - JxlDecoder
Size ⚠Hint Basic Info - Returns a hint indicating how many more bytes the decoder is expected to
need to make
JxlDecoderGetBasicInfoavailable after the nextJxlDecoderProcessInputcall. This is a suggested large enough value for the amount of bytes to provide in the nextJxlDecoderSetInputcall, but it is not guaranteed to be an upper bound nor a lower bound. This number does not include bytes that have already been released from the input. Can be used before the firstJxlDecoderProcessInputcall, and is correct the first time in most cases. If not,JxlDecoderSizeHintBasicInfocan be called again to get an updated hint. - JxlDecoder
Skip ⚠Current Frame - Skips processing the current frame. Can be called after frame processing
already started, signaled by a
JxlDecoderStatus::NeedImageOutBufferevent, but before the correspondingJxlDecoderStatus::FullImageevent. The next signaled event will be anotherJxlDecoderStatus::Frame, orJxlDecoderStatus::Successif there are no more frames. If pixel data is required from the already processed part of the frame,JxlDecoderFlushImagemust be called before this. - JxlDecoder
Skip ⚠Frames - Makes the decoder skip the next
amountframes. It still needs to process the input, but will not output the frame events. It can be more efficient when skipping frames, and even more so when using this afterJxlDecoderRewind. If the decoder is already processing a frame (could have emittedJxlDecoderStatus::Framebut not yetJxlDecoderStatus::FullImage), it starts skipping from the next frame. If the amount is larger than the amount of frames remaining in the image, all remaining frames are skipped. Calling this function multiple times adds the amount to skip to the already existing amount. - JxlDecoder
Subscribe ⚠Events - Select for which informative events, i.e.
JxlDecoderStatus::BasicInfo, etc., the decoder should return with a status. It is not required to subscribe to any events, data can still be requested from the decoder as soon as it is available. By default, the decoder is subscribed to no events (events_wanted == 0), and the decoder will then only return when it cannot continue because it needs more input data or more output buffer. This function may only be called before usingJxlDecoderProcessInput. - JxlDecoder
Version ⚠ - Decoder library version.
- JxlSignature
Check ⚠ - JPEG XL signature identification.
Type Aliases§
- JxlImage
OutCallback - Function type for
JxlDecoderSetImageOutCallback. - JxlImage
OutDestroy Callback - Destruction callback for
JxlDecoderSetMultithreadedImageOutCallback, called after all invocations of theruncallback to perform any appropriate clean-up of therun_opaquedata returned byinit. - JxlImage
OutInit Callback - Initialization callback for
JxlDecoderSetMultithreadedImageOutCallback. - JxlImage
OutRun Callback - Worker callback for
JxlDecoderSetMultithreadedImageOutCallback