LIBJXL
decode.h
Go to the documentation of this file.
1 /* Copyright (c) the JPEG XL Project Authors. All rights reserved.
2  *
3  * Use of this source code is governed by a BSD-style
4  * license that can be found in the LICENSE file.
5  */
6 
13 #ifndef JXL_DECODE_H_
14 #define JXL_DECODE_H_
15 
16 #include <stddef.h>
17 #include <stdint.h>
18 
19 #include "jxl/cms_interface.h"
20 #include "jxl/codestream_header.h"
21 #include "jxl/color_encoding.h"
22 #include "jxl/jxl_export.h"
23 #include "jxl/memory_manager.h"
24 #include "jxl/parallel_runner.h"
25 #include "jxl/types.h"
26 
27 #if defined(__cplusplus) || defined(c_plusplus)
28 extern "C" {
29 #endif
30 
38 JXL_EXPORT uint32_t JxlDecoderVersion(void);
39 
42 typedef enum {
46 
49 
54 
59 } JxlSignature;
60 
76 JXL_EXPORT JxlSignature JxlSignatureCheck(const uint8_t* buf, size_t len);
77 
84 typedef struct JxlDecoderStruct JxlDecoder;
85 
98 JXL_EXPORT JxlDecoder* JxlDecoderCreate(const JxlMemoryManager* memory_manager);
99 
107 JXL_EXPORT void JxlDecoderReset(JxlDecoder* dec);
108 
114 JXL_EXPORT void JxlDecoderDestroy(JxlDecoder* dec);
115 
122 typedef enum {
137 
142 
158 
169 
179 
188 
195 
201 
210 
220 
230 
240 
260  JXL_DEC_FRAME = 0x400,
261 
276 
290 
303 
339  JXL_DEC_BOX = 0x4000,
340 
358 
372 JXL_EXPORT void JxlDecoderRewind(JxlDecoder* dec);
373 
392 JXL_EXPORT void JxlDecoderSkipFrames(JxlDecoder* dec, size_t amount);
393 
407 
420 JXL_EXPORT JxlDecoderStatus
422 
435 JXL_EXPORT JxlDecoderStatus
437  void* parallel_runner_opaque);
438 
454 JXL_EXPORT size_t JxlDecoderSizeHintBasicInfo(const JxlDecoder* dec);
455 
469  int events_wanted);
470 
502 JXL_EXPORT JxlDecoderStatus
504 
515 JXL_EXPORT JxlDecoderStatus
517 
532  JXL_BOOL coalescing);
533 
577 
593  const uint8_t* data,
594  size_t size);
595 
615 JXL_EXPORT size_t JxlDecoderReleaseInput(JxlDecoder* dec);
616 
635 JXL_EXPORT void JxlDecoderCloseInput(JxlDecoder* dec);
636 
649  JxlBasicInfo* info);
650 
664  const JxlDecoder* dec, size_t index, JxlExtraChannelInfo* info);
665 
681  size_t index,
682  char* name,
683  size_t size);
684 
690 typedef enum {
694 
698 
738  const JxlDecoder* dec, const JxlPixelFormat* format,
739  JxlColorProfileTarget target, JxlColorEncoding* color_encoding);
740 
765 JXL_EXPORT JxlDecoderStatus
767  JxlColorProfileTarget target, size_t* size);
768 
787  const JxlDecoder* dec, const JxlPixelFormat* format,
788  JxlColorProfileTarget target, uint8_t* icc_profile, size_t size);
789 
824  JxlDecoder* dec, const JxlColorEncoding* color_encoding);
825 
837  JxlDecoder* dec, float desired_intensity_target);
838 
852  const JxlDecoder* dec, const JxlPixelFormat* format, size_t* size);
853 
870  JxlDecoder* dec, const JxlPixelFormat* format, void* buffer, size_t size);
871 
885  JxlFrameHeader* header);
886 
900  char* name, size_t size);
901 
915  const JxlDecoder* dec, size_t index, JxlBlendInfo* blend_info);
916 
931 JXL_EXPORT JXL_DEPRECATED JxlDecoderStatus JxlDecoderDCOutBufferSize(
932  const JxlDecoder* dec, const JxlPixelFormat* format, size_t* size);
933 
952 JXL_EXPORT JXL_DEPRECATED JxlDecoderStatus JxlDecoderSetDCOutBuffer(
953  JxlDecoder* dec, const JxlPixelFormat* format, void* buffer, size_t size);
954 
971  const JxlDecoder* dec, const JxlPixelFormat* format, size_t* size);
972 
990  JxlDecoder* dec, const JxlPixelFormat* format, void* buffer, size_t size);
991 
1008 typedef void (*JxlImageOutCallback)(void* opaque, size_t x, size_t y,
1009  size_t num_pixels, const void* pixels);
1010 
1023 typedef void* (*JxlImageOutInitCallback)(void* init_opaque, size_t num_threads,
1024  size_t num_pixels_per_thread);
1025 
1042 typedef void (*JxlImageOutRunCallback)(void* run_opaque, size_t thread_id,
1043  size_t x, size_t y, size_t num_pixels,
1044  const void* pixels);
1045 
1053 typedef void (*JxlImageOutDestroyCallback)(void* run_opaque);
1054 
1097 JXL_EXPORT JxlDecoderStatus
1099  JxlImageOutCallback callback, void* opaque);
1100 
1121  JxlDecoder* dec, const JxlPixelFormat* format,
1122  JxlImageOutInitCallback init_callback, JxlImageOutRunCallback run_callback,
1123  JxlImageOutDestroyCallback destroy_callback, void* init_opaque);
1124 
1141  const JxlDecoder* dec, const JxlPixelFormat* format, size_t* size,
1142  uint32_t index);
1143 
1174 JXL_EXPORT JxlDecoderStatus
1176  void* buffer, size_t size, uint32_t index);
1177 
1197  uint8_t* data, size_t size);
1198 
1215 JXL_EXPORT size_t JxlDecoderReleaseJPEGBuffer(JxlDecoder* dec);
1216 
1240  uint8_t* data, size_t size);
1241 
1258 JXL_EXPORT size_t JxlDecoderReleaseBoxBuffer(JxlDecoder* dec);
1259 
1281  JXL_BOOL decompress);
1282 
1349  JxlBoxType type,
1350  JXL_BOOL decompressed);
1351 
1370  uint64_t* size);
1371 
1383 JXL_EXPORT JxlDecoderStatus
1385 
1395 
1413 
1414 #if defined(__cplusplus) || defined(c_plusplus)
1415 }
1416 #endif
1417 
1418 #endif /* JXL_DECODE_H_ */
1419 
Interface to allow the injection of different color management systems (CMSes, also called color mana...
Definitions of structs and enums for the metadata from the JPEG XL codestream headers (signature,...
Color Encoding definitions used by JPEG XL. All CIE units are for the standard 1931 2 degree observer...
JxlParallelRetCode(* JxlParallelRunner)(void *runner_opaque, void *jpegxl_opaque, JxlParallelRunInit init, JxlParallelRunFunction func, uint32_t start_range, uint32_t end_range)
Definition: parallel_runner.h:119
char JxlBoxType[4]
Definition: types.h:116
#define JXL_BOOL
Definition: types.h:31
JxlProgressiveDetail
Definition: types.h:126
JXL_EXPORT size_t JxlDecoderReleaseBoxBuffer(JxlDecoder *dec)
JXL_EXPORT void JxlDecoderSkipFrames(JxlDecoder *dec, size_t amount)
JXL_EXPORT uint32_t JxlDecoderVersion(void)
JXL_EXPORT size_t JxlDecoderReleaseInput(JxlDecoder *dec)
JXL_EXPORT JXL_DEPRECATED JxlDecoderStatus JxlDecoderSetDCOutBuffer(JxlDecoder *dec, const JxlPixelFormat *format, void *buffer, size_t size)
JXL_EXPORT JxlDecoderStatus JxlDecoderPreviewOutBufferSize(const JxlDecoder *dec, const JxlPixelFormat *format, size_t *size)
JXL_EXPORT void JxlDecoderRewind(JxlDecoder *dec)
JXL_EXPORT JxlDecoderStatus JxlDecoderSetMultithreadedImageOutCallback(JxlDecoder *dec, const JxlPixelFormat *format, JxlImageOutInitCallback init_callback, JxlImageOutRunCallback run_callback, JxlImageOutDestroyCallback destroy_callback, void *init_opaque)
JXL_EXPORT JxlDecoderStatus JxlDecoderDefaultPixelFormat(const JxlDecoder *dec, JxlPixelFormat *format)
JXL_EXPORT JxlDecoderStatus JxlDecoderSetDesiredIntensityTarget(JxlDecoder *dec, float desired_intensity_target)
JXL_EXPORT JxlDecoderStatus JxlDecoderSetPreviewOutBuffer(JxlDecoder *dec, const JxlPixelFormat *format, void *buffer, size_t size)
JXL_EXPORT JxlDecoderStatus JxlDecoderGetFrameName(const JxlDecoder *dec, char *name, size_t size)
JXL_EXPORT JxlDecoderStatus JxlDecoderGetExtraChannelName(const JxlDecoder *dec, size_t index, char *name, size_t size)
JXL_EXPORT JxlDecoderStatus JxlDecoderSetCoalescing(JxlDecoder *dec, JXL_BOOL coalescing)
JXL_EXPORT JxlDecoderStatus JxlDecoderSetInput(JxlDecoder *dec, const uint8_t *data, size_t size)
JXL_EXPORT JxlDecoderStatus JxlDecoderGetBoxSizeRaw(const JxlDecoder *dec, uint64_t *size)
JXL_EXPORT void JxlDecoderCloseInput(JxlDecoder *dec)
JXL_EXPORT JxlDecoderStatus JxlDecoderGetFrameHeader(const JxlDecoder *dec, JxlFrameHeader *header)
JXL_EXPORT size_t JxlDecoderSizeHintBasicInfo(const JxlDecoder *dec)
JXL_EXPORT JxlDecoderStatus JxlDecoderSetImageOutBuffer(JxlDecoder *dec, const JxlPixelFormat *format, void *buffer, size_t size)
JXL_EXPORT size_t JxlDecoderGetIntendedDownsamplingRatio(JxlDecoder *dec)
JXL_EXPORT JxlDecoderStatus JxlDecoderImageOutBufferSize(const JxlDecoder *dec, const JxlPixelFormat *format, size_t *size)
JXL_EXPORT JxlDecoderStatus JxlDecoderGetExtraChannelInfo(const JxlDecoder *dec, size_t index, JxlExtraChannelInfo *info)
JXL_EXPORT JxlDecoderStatus JxlDecoderSkipCurrentFrame(JxlDecoder *dec)
JXL_EXPORT JxlDecoderStatus JxlDecoderSetDecompressBoxes(JxlDecoder *dec, JXL_BOOL decompress)
JXL_EXPORT JxlDecoderStatus JxlDecoderGetColorAsICCProfile(const JxlDecoder *dec, const JxlPixelFormat *format, JxlColorProfileTarget target, uint8_t *icc_profile, size_t size)
JXL_EXPORT size_t JxlDecoderReleaseJPEGBuffer(JxlDecoder *dec)
void *(* JxlImageOutInitCallback)(void *init_opaque, size_t num_threads, size_t num_pixels_per_thread)
Definition: decode.h:1023
JxlColorProfileTarget
Definition: decode.h:690
JXL_EXPORT JxlDecoderStatus JxlDecoderExtraChannelBufferSize(const JxlDecoder *dec, const JxlPixelFormat *format, size_t *size, uint32_t index)
JXL_EXPORT JxlDecoderStatus JxlDecoderSetBoxBuffer(JxlDecoder *dec, uint8_t *data, size_t size)
JxlSignature
Definition: decode.h:42
JXL_EXPORT JxlDecoderStatus JxlDecoderSubscribeEvents(JxlDecoder *dec, int events_wanted)
JXL_EXPORT JxlDecoderStatus JxlDecoderSetParallelRunner(JxlDecoder *dec, JxlParallelRunner parallel_runner, void *parallel_runner_opaque)
JXL_EXPORT JxlDecoderStatus JxlDecoderProcessInput(JxlDecoder *dec)
void(* JxlImageOutRunCallback)(void *run_opaque, size_t thread_id, size_t x, size_t y, size_t num_pixels, const void *pixels)
Definition: decode.h:1042
JXL_EXPORT JxlDecoderStatus JxlDecoderSetPreferredColorProfile(JxlDecoder *dec, const JxlColorEncoding *color_encoding)
JXL_EXPORT JxlDecoderStatus JxlDecoderGetICCProfileSize(const JxlDecoder *dec, const JxlPixelFormat *format, JxlColorProfileTarget target, size_t *size)
JXL_EXPORT JxlDecoderStatus JxlDecoderSetImageOutCallback(JxlDecoder *dec, const JxlPixelFormat *format, JxlImageOutCallback callback, void *opaque)
JXL_EXPORT JXL_DEPRECATED JxlDecoderStatus JxlDecoderDCOutBufferSize(const JxlDecoder *dec, const JxlPixelFormat *format, size_t *size)
void(* JxlImageOutCallback)(void *opaque, size_t x, size_t y, size_t num_pixels, const void *pixels)
Definition: decode.h:1008
JXL_EXPORT JxlDecoderStatus JxlDecoderGetBoxType(JxlDecoder *dec, JxlBoxType type, JXL_BOOL decompressed)
JXL_EXPORT JxlDecoderStatus JxlDecoderGetBasicInfo(const JxlDecoder *dec, JxlBasicInfo *info)
JXL_EXPORT JxlDecoderStatus JxlDecoderSetKeepOrientation(JxlDecoder *dec, JXL_BOOL skip_reorientation)
void(* JxlImageOutDestroyCallback)(void *run_opaque)
Definition: decode.h:1053
JXL_EXPORT JxlDecoderStatus JxlDecoderFlushImage(JxlDecoder *dec)
JXL_EXPORT JxlDecoderStatus JxlDecoderGetExtraChannelBlendInfo(const JxlDecoder *dec, size_t index, JxlBlendInfo *blend_info)
JXL_EXPORT JxlDecoderStatus JxlDecoderSetJPEGBuffer(JxlDecoder *dec, uint8_t *data, size_t size)
JXL_EXPORT void JxlDecoderDestroy(JxlDecoder *dec)
JXL_EXPORT JxlSignature JxlSignatureCheck(const uint8_t *buf, size_t len)
JXL_EXPORT JxlDecoderStatus JxlDecoderSetProgressiveDetail(JxlDecoder *dec, JxlProgressiveDetail detail)
JXL_EXPORT JxlDecoder * JxlDecoderCreate(const JxlMemoryManager *memory_manager)
JxlDecoderStatus
Definition: decode.h:122
struct JxlDecoderStruct JxlDecoder
Definition: decode.h:84
JXL_EXPORT JxlDecoderStatus JxlDecoderSetRenderSpotcolors(JxlDecoder *dec, JXL_BOOL render_spotcolors)
JXL_EXPORT JxlDecoderStatus JxlDecoderGetColorAsEncodedProfile(const JxlDecoder *dec, const JxlPixelFormat *format, JxlColorProfileTarget target, JxlColorEncoding *color_encoding)
JXL_EXPORT void JxlDecoderReset(JxlDecoder *dec)
JXL_EXPORT JxlDecoderStatus JxlDecoderSetExtraChannelBuffer(JxlDecoder *dec, const JxlPixelFormat *format, void *buffer, size_t size, uint32_t index)
@ JXL_COLOR_PROFILE_TARGET_DATA
Definition: decode.h:696
@ JXL_COLOR_PROFILE_TARGET_ORIGINAL
Definition: decode.h:693
@ JXL_SIG_NOT_ENOUGH_BYTES
Definition: decode.h:45
@ JXL_SIG_INVALID
Definition: decode.h:48
@ JXL_SIG_CONTAINER
Definition: decode.h:58
@ JXL_SIG_CODESTREAM
Definition: decode.h:53
@ JXL_DEC_JPEG_RECONSTRUCTION
Definition: decode.h:302
@ JXL_DEC_JPEG_NEED_MORE_OUTPUT
Definition: decode.h:194
@ JXL_DEC_BASIC_INFO
Definition: decode.h:209
@ JXL_DEC_EXTENSIONS
Definition: decode.h:219
@ JXL_DEC_FRAME_PROGRESSION
Definition: decode.h:356
@ JXL_DEC_DC_IMAGE
Definition: decode.h:275
@ JXL_DEC_ERROR
Definition: decode.h:141
@ JXL_DEC_NEED_IMAGE_OUT_BUFFER
Definition: decode.h:187
@ JXL_DEC_FULL_IMAGE
Definition: decode.h:289
@ JXL_DEC_COLOR_ENCODING
Definition: decode.h:229
@ JXL_DEC_SUCCESS
Definition: decode.h:136
@ JXL_DEC_PREVIEW_IMAGE
Definition: decode.h:239
@ JXL_DEC_BOX_NEED_MORE_OUTPUT
Definition: decode.h:200
@ JXL_DEC_BOX
Definition: decode.h:339
@ JXL_DEC_NEED_DC_OUT_BUFFER
Definition: decode.h:178
@ JXL_DEC_NEED_MORE_INPUT
Definition: decode.h:157
@ JXL_DEC_NEED_PREVIEW_OUT_BUFFER
Definition: decode.h:168
@ JXL_DEC_FRAME
Definition: decode.h:260
Abstraction functions used by JPEG XL to allocate memory.
Definition: codestream_header.h:106
Definition: codestream_header.h:339
Definition: color_encoding.h:118
Definition: codestream_header.h:274
Definition: codestream_header.h:398
Definition: memory_manager.h:51
Definition: types.h:87
Data types for the JPEG XL API, for both encoding and decoding.