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/codestream_header.h"
20 #include "jxl/color_encoding.h"
21 #include "jxl/jxl_export.h"
22 #include "jxl/memory_manager.h"
23 #include "jxl/parallel_runner.h"
24 #include "jxl/types.h"
25 
26 #if defined(__cplusplus) || defined(c_plusplus)
27 extern "C" {
28 #endif
29 
37 JXL_EXPORT uint32_t JxlDecoderVersion(void);
38 
41 typedef enum {
45 
48 
53 
58 } JxlSignature;
59 
75 JXL_EXPORT JxlSignature JxlSignatureCheck(const uint8_t* buf, size_t len);
76 
83 typedef struct JxlDecoderStruct JxlDecoder;
84 
97 JXL_EXPORT JxlDecoder* JxlDecoderCreate(const JxlMemoryManager* memory_manager);
98 
106 JXL_EXPORT void JxlDecoderReset(JxlDecoder* dec);
107 
113 JXL_EXPORT void JxlDecoderDestroy(JxlDecoder* dec);
114 
121 typedef enum {
136 
141 
157 
168 
178 
187 
194 
200 
209 
219 
229 
239 
259  JXL_DEC_FRAME = 0x400,
260 
275 
289 
302 
338  JXL_DEC_BOX = 0x4000,
339 
357 
381 JXL_EXPORT void JxlDecoderRewind(JxlDecoder* dec);
382 
401 JXL_EXPORT void JxlDecoderSkipFrames(JxlDecoder* dec, size_t amount);
402 
416 
431 JXL_EXPORT JXL_DEPRECATED JxlDecoderStatus
433 
446 JXL_EXPORT JxlDecoderStatus
448  void* parallel_runner_opaque);
449 
465 JXL_EXPORT size_t JxlDecoderSizeHintBasicInfo(const JxlDecoder* dec);
466 
480  int events_wanted);
481 
513 JXL_EXPORT JxlDecoderStatus
515 
531 JXL_EXPORT JxlDecoderStatus
533 
544 JXL_EXPORT JxlDecoderStatus
546 
561  JXL_BOOL coalescing);
562 
606 
622  const uint8_t* data,
623  size_t size);
624 
644 JXL_EXPORT size_t JxlDecoderReleaseInput(JxlDecoder* dec);
645 
664 JXL_EXPORT void JxlDecoderCloseInput(JxlDecoder* dec);
665 
678  JxlBasicInfo* info);
679 
693  const JxlDecoder* dec, size_t index, JxlExtraChannelInfo* info);
694 
710  size_t index,
711  char* name,
712  size_t size);
713 
719 typedef enum {
723 
727 
766  const JxlDecoder* dec, const JxlPixelFormat* unused_format,
767  JxlColorProfileTarget target, JxlColorEncoding* color_encoding);
768 
793  const JxlDecoder* dec, const JxlPixelFormat* unused_format,
794  JxlColorProfileTarget target, size_t* size);
795 
813  const JxlDecoder* dec, const JxlPixelFormat* unused_format,
814  JxlColorProfileTarget target, uint8_t* icc_profile, size_t size);
815 
850  JxlDecoder* dec, const JxlColorEncoding* color_encoding);
851 
863  JxlDecoder* dec, float desired_intensity_target);
864 
878  const JxlDecoder* dec, const JxlPixelFormat* format, size_t* size);
879 
896  JxlDecoder* dec, const JxlPixelFormat* format, void* buffer, size_t size);
897 
911  JxlFrameHeader* header);
912 
926  char* name, size_t size);
927 
941  const JxlDecoder* dec, size_t index, JxlBlendInfo* blend_info);
942 
957 JXL_EXPORT JXL_DEPRECATED JxlDecoderStatus JxlDecoderDCOutBufferSize(
958  const JxlDecoder* dec, const JxlPixelFormat* format, size_t* size);
959 
978 JXL_EXPORT JXL_DEPRECATED JxlDecoderStatus JxlDecoderSetDCOutBuffer(
979  JxlDecoder* dec, const JxlPixelFormat* format, void* buffer, size_t size);
980 
997  const JxlDecoder* dec, const JxlPixelFormat* format, size_t* size);
998 
1016  JxlDecoder* dec, const JxlPixelFormat* format, void* buffer, size_t size);
1017 
1034 typedef void (*JxlImageOutCallback)(void* opaque, size_t x, size_t y,
1035  size_t num_pixels, const void* pixels);
1036 
1049 typedef void* (*JxlImageOutInitCallback)(void* init_opaque, size_t num_threads,
1050  size_t num_pixels_per_thread);
1051 
1068 typedef void (*JxlImageOutRunCallback)(void* run_opaque, size_t thread_id,
1069  size_t x, size_t y, size_t num_pixels,
1070  const void* pixels);
1071 
1079 typedef void (*JxlImageOutDestroyCallback)(void* run_opaque);
1080 
1123 JXL_EXPORT JxlDecoderStatus
1125  JxlImageOutCallback callback, void* opaque);
1126 
1147  JxlDecoder* dec, const JxlPixelFormat* format,
1148  JxlImageOutInitCallback init_callback, JxlImageOutRunCallback run_callback,
1149  JxlImageOutDestroyCallback destroy_callback, void* init_opaque);
1150 
1167  const JxlDecoder* dec, const JxlPixelFormat* format, size_t* size,
1168  uint32_t index);
1169 
1200 JXL_EXPORT JxlDecoderStatus
1202  void* buffer, size_t size, uint32_t index);
1203 
1223  uint8_t* data, size_t size);
1224 
1241 JXL_EXPORT size_t JxlDecoderReleaseJPEGBuffer(JxlDecoder* dec);
1242 
1266  uint8_t* data, size_t size);
1267 
1284 JXL_EXPORT size_t JxlDecoderReleaseBoxBuffer(JxlDecoder* dec);
1285 
1307  JXL_BOOL decompress);
1308 
1375  JxlBoxType type,
1376  JXL_BOOL decompressed);
1377 
1396  uint64_t* size);
1397 
1409 JXL_EXPORT JxlDecoderStatus
1411 
1421 
1439 
1440 #if defined(__cplusplus) || defined(c_plusplus)
1441 }
1442 #endif
1443 
1444 #endif /* JXL_DECODE_H_ */
1445 
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 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 JxlDecoderGetColorAsEncodedProfile(const JxlDecoder *dec, const JxlPixelFormat *unused_format, JxlColorProfileTarget target, JxlColorEncoding *color_encoding)
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 JxlDecoderGetICCProfileSize(const JxlDecoder *dec, const JxlPixelFormat *unused_format, JxlColorProfileTarget target, 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 size_t JxlDecoderReleaseJPEGBuffer(JxlDecoder *dec)
void *(* JxlImageOutInitCallback)(void *init_opaque, size_t num_threads, size_t num_pixels_per_thread)
Definition: decode.h:1049
JxlColorProfileTarget
Definition: decode.h:719
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:41
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:1068
JXL_EXPORT JxlDecoderStatus JxlDecoderSetPreferredColorProfile(JxlDecoder *dec, const JxlColorEncoding *color_encoding)
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:1034
JXL_EXPORT JxlDecoderStatus JxlDecoderGetBoxType(JxlDecoder *dec, JxlBoxType type, JXL_BOOL decompressed)
JXL_EXPORT JxlDecoderStatus JxlDecoderGetBasicInfo(const JxlDecoder *dec, JxlBasicInfo *info)
JXL_EXPORT JxlDecoderStatus JxlDecoderSetUnpremultiplyAlpha(JxlDecoder *dec, JXL_BOOL unpremul_alpha)
JXL_EXPORT JxlDecoderStatus JxlDecoderGetColorAsICCProfile(const JxlDecoder *dec, const JxlPixelFormat *unused_format, JxlColorProfileTarget target, uint8_t *icc_profile, size_t size)
JXL_EXPORT JxlDecoderStatus JxlDecoderSetKeepOrientation(JxlDecoder *dec, JXL_BOOL skip_reorientation)
void(* JxlImageOutDestroyCallback)(void *run_opaque)
Definition: decode.h:1079
JXL_EXPORT JxlDecoderStatus JxlDecoderFlushImage(JxlDecoder *dec)
JXL_EXPORT JXL_DEPRECATED JxlDecoderStatus JxlDecoderDefaultPixelFormat(const JxlDecoder *dec, JxlPixelFormat *format)
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:121
struct JxlDecoderStruct JxlDecoder
Definition: decode.h:83
JXL_EXPORT JxlDecoderStatus JxlDecoderSetRenderSpotcolors(JxlDecoder *dec, JXL_BOOL render_spotcolors)
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:725
@ JXL_COLOR_PROFILE_TARGET_ORIGINAL
Definition: decode.h:722
@ JXL_SIG_NOT_ENOUGH_BYTES
Definition: decode.h:44
@ JXL_SIG_INVALID
Definition: decode.h:47
@ JXL_SIG_CONTAINER
Definition: decode.h:57
@ JXL_SIG_CODESTREAM
Definition: decode.h:52
@ JXL_DEC_JPEG_RECONSTRUCTION
Definition: decode.h:301
@ JXL_DEC_JPEG_NEED_MORE_OUTPUT
Definition: decode.h:193
@ JXL_DEC_BASIC_INFO
Definition: decode.h:208
@ JXL_DEC_EXTENSIONS
Definition: decode.h:218
@ JXL_DEC_FRAME_PROGRESSION
Definition: decode.h:355
@ JXL_DEC_DC_IMAGE
Definition: decode.h:274
@ JXL_DEC_ERROR
Definition: decode.h:140
@ JXL_DEC_NEED_IMAGE_OUT_BUFFER
Definition: decode.h:186
@ JXL_DEC_FULL_IMAGE
Definition: decode.h:288
@ JXL_DEC_COLOR_ENCODING
Definition: decode.h:228
@ JXL_DEC_SUCCESS
Definition: decode.h:135
@ JXL_DEC_PREVIEW_IMAGE
Definition: decode.h:238
@ JXL_DEC_BOX_NEED_MORE_OUTPUT
Definition: decode.h:199
@ JXL_DEC_BOX
Definition: decode.h:338
@ JXL_DEC_NEED_DC_OUT_BUFFER
Definition: decode.h:177
@ JXL_DEC_NEED_MORE_INPUT
Definition: decode.h:156
@ JXL_DEC_NEED_PREVIEW_OUT_BUFFER
Definition: decode.h:167
@ JXL_DEC_FRAME
Definition: decode.h:259
Abstraction functions used by JPEG XL to allocate memory.
Definition: codestream_header.h:105
Definition: codestream_header.h:338
Definition: color_encoding.h:116
Definition: codestream_header.h:273
Definition: codestream_header.h:397
Definition: memory_manager.h:51
Definition: types.h:87
Data types for the JPEG XL API, for both encoding and decoding.