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 #include "jxl/version.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 
382 JXL_EXPORT void JxlDecoderRewind(JxlDecoder* dec);
383 
402 JXL_EXPORT void JxlDecoderSkipFrames(JxlDecoder* dec, size_t amount);
403 
417 
432 JXL_EXPORT JXL_DEPRECATED JxlDecoderStatus
434 
447 JXL_EXPORT JxlDecoderStatus
449  void* parallel_runner_opaque);
450 
466 JXL_EXPORT size_t JxlDecoderSizeHintBasicInfo(const JxlDecoder* dec);
467 
481  int events_wanted);
482 
514 JXL_EXPORT JxlDecoderStatus
515 JxlDecoderSetKeepOrientation(JxlDecoder* dec, JXL_BOOL skip_reorientation);
516 
532 JXL_EXPORT JxlDecoderStatus
534 
545 JXL_EXPORT JxlDecoderStatus
546 JxlDecoderSetRenderSpotcolors(JxlDecoder* dec, JXL_BOOL render_spotcolors);
547 
562  JXL_BOOL coalescing);
563 
607 
623  const uint8_t* data,
624  size_t size);
625 
645 JXL_EXPORT size_t JxlDecoderReleaseInput(JxlDecoder* dec);
646 
665 JXL_EXPORT void JxlDecoderCloseInput(JxlDecoder* dec);
666 
679  JxlBasicInfo* info);
680 
694  const JxlDecoder* dec, size_t index, JxlExtraChannelInfo* info);
695 
711  size_t index,
712  char* name,
713  size_t size);
714 
720 typedef enum {
724 
728 
767  const JxlDecoder* dec, const JxlPixelFormat* unused_format,
768  JxlColorProfileTarget target, JxlColorEncoding* color_encoding);
769 
794  const JxlDecoder* dec, const JxlPixelFormat* unused_format,
795  JxlColorProfileTarget target, size_t* size);
796 
814  const JxlDecoder* dec, const JxlPixelFormat* unused_format,
815  JxlColorProfileTarget target, uint8_t* icc_profile, size_t size);
816 
851  JxlDecoder* dec, const JxlColorEncoding* color_encoding);
852 
864  JxlDecoder* dec, float desired_intensity_target);
865 
879  const JxlDecoder* dec, const JxlPixelFormat* format, size_t* size);
880 
897  JxlDecoder* dec, const JxlPixelFormat* format, void* buffer, size_t size);
898 
912  JxlFrameHeader* header);
913 
927  char* name, size_t size);
928 
942  const JxlDecoder* dec, size_t index, JxlBlendInfo* blend_info);
943 
958 JXL_EXPORT JXL_DEPRECATED JxlDecoderStatus JxlDecoderDCOutBufferSize(
959  const JxlDecoder* dec, const JxlPixelFormat* format, size_t* size);
960 
979 JXL_EXPORT JXL_DEPRECATED JxlDecoderStatus JxlDecoderSetDCOutBuffer(
980  JxlDecoder* dec, const JxlPixelFormat* format, void* buffer, size_t size);
981 
998  const JxlDecoder* dec, const JxlPixelFormat* format, size_t* size);
999 
1017  JxlDecoder* dec, const JxlPixelFormat* format, void* buffer, size_t size);
1018 
1035 typedef void (*JxlImageOutCallback)(void* opaque, size_t x, size_t y,
1036  size_t num_pixels, const void* pixels);
1037 
1050 typedef void* (*JxlImageOutInitCallback)(void* init_opaque, size_t num_threads,
1051  size_t num_pixels_per_thread);
1052 
1069 typedef void (*JxlImageOutRunCallback)(void* run_opaque, size_t thread_id,
1070  size_t x, size_t y, size_t num_pixels,
1071  const void* pixels);
1072 
1080 typedef void (*JxlImageOutDestroyCallback)(void* run_opaque);
1081 
1124 JXL_EXPORT JxlDecoderStatus
1126  JxlImageOutCallback callback, void* opaque);
1127 
1148  JxlDecoder* dec, const JxlPixelFormat* format,
1149  JxlImageOutInitCallback init_callback, JxlImageOutRunCallback run_callback,
1150  JxlImageOutDestroyCallback destroy_callback, void* init_opaque);
1151 
1168  const JxlDecoder* dec, const JxlPixelFormat* format, size_t* size,
1169  uint32_t index);
1170 
1201 JXL_EXPORT JxlDecoderStatus
1203  void* buffer, size_t size, uint32_t index);
1204 
1224  uint8_t* data, size_t size);
1225 
1242 JXL_EXPORT size_t JxlDecoderReleaseJPEGBuffer(JxlDecoder* dec);
1243 
1267  uint8_t* data, size_t size);
1268 
1285 JXL_EXPORT size_t JxlDecoderReleaseBoxBuffer(JxlDecoder* dec);
1286 
1308  JXL_BOOL decompress);
1309 
1376  JxlBoxType type,
1377  JXL_BOOL decompressed);
1378 
1397  uint64_t* size);
1398 
1410 JXL_EXPORT JxlDecoderStatus
1412 
1421 JXL_EXPORT size_t JxlDecoderGetIntendedDownsamplingRatio(JxlDecoder* dec);
1422 
1440 
1441 #if defined(__cplusplus) || defined(c_plusplus)
1442 }
1443 #endif
1444 
1445 #endif /* JXL_DECODE_H_ */
1446 
JXL_EXPORT JxlDecoderStatus JxlDecoderGetBasicInfo(const JxlDecoder *dec, JxlBasicInfo *info)
Definition: decode.h:726
JXL_EXPORT JXL_DEPRECATED JxlDecoderStatus JxlDecoderSetDCOutBuffer(JxlDecoder *dec, const JxlPixelFormat *format, void *buffer, size_t size)
Definition: decode.h:723
JXL_EXPORT size_t JxlDecoderSizeHintBasicInfo(const JxlDecoder *dec)
Definition: decode.h:157
void(* JxlImageOutDestroyCallback)(void *run_opaque)
Definition: decode.h:1080
Definition: decode.h:339
#define JXL_BOOL
Definition: types.h:31
Data types for the JPEG XL API, for both encoding and decoding.
JxlDecoderStatus
Definition: decode.h:122
Definition: color_encoding.h:116
JXL_EXPORT JxlDecoderStatus JxlDecoderSetImageOutCallback(JxlDecoder *dec, const JxlPixelFormat *format, JxlImageOutCallback callback, void *opaque)
Definition: decode.h:141
void(* JxlImageOutCallback)(void *opaque, size_t x, size_t y, size_t num_pixels, const void *pixels)
Definition: decode.h:1035
JxlColorProfileTarget
Definition: decode.h:720
JXL_EXPORT JxlDecoderStatus JxlDecoderGetFrameHeader(const JxlDecoder *dec, JxlFrameHeader *header)
Color Encoding definitions used by JPEG XL. All CIE units are for the standard 1931 2 degree observer...
JXL_EXPORT JxlDecoderStatus JxlDecoderSetCoalescing(JxlDecoder *dec, JXL_BOOL coalescing)
Definition: decode.h:45
Definition: decode.h:302
Definition: decode.h:53
Definition: decode.h:229
JXL_EXPORT JxlDecoderStatus JxlDecoderSetBoxBuffer(JxlDecoder *dec, uint8_t *data, size_t size)
JXL_EXPORT JxlDecoderStatus JxlDecoderSetRenderSpotcolors(JxlDecoder *dec, JXL_BOOL render_spotcolors)
Definition: decode.h:289
Definition: decode.h:178
JXL_EXPORT JxlDecoderStatus JxlDecoderSetPreviewOutBuffer(JxlDecoder *dec, const JxlPixelFormat *format, void *buffer, size_t size)
Definition: decode.h:194
JXL_EXPORT void JxlDecoderCloseInput(JxlDecoder *dec)
JXL_EXPORT JxlDecoderStatus JxlDecoderGetExtraChannelBlendInfo(const JxlDecoder *dec, size_t index, JxlBlendInfo *blend_info)
JXL_EXPORT size_t JxlDecoderGetIntendedDownsamplingRatio(JxlDecoder *dec)
JXL_EXPORT size_t JxlDecoderReleaseBoxBuffer(JxlDecoder *dec)
Definition: codestream_header.h:273
struct JxlDecoderStruct JxlDecoder
Definition: decode.h:84
JXL_EXPORT void JxlDecoderSkipFrames(JxlDecoder *dec, size_t amount)
JXL_EXPORT JxlDecoderStatus JxlDecoderImageOutBufferSize(const JxlDecoder *dec, const JxlPixelFormat *format, size_t *size)
Definition: decode.h:239
Abstraction functions used by JPEG XL to allocate memory.
JXL_EXPORT JxlDecoderStatus JxlDecoderGetICCProfileSize(const JxlDecoder *dec, const JxlPixelFormat *unused_format, JxlColorProfileTarget target, size_t *size)
JXL_EXPORT void JxlDecoderRewind(JxlDecoder *dec)
JXL_EXPORT JxlDecoderStatus JxlDecoderSetDecompressBoxes(JxlDecoder *dec, JXL_BOOL decompress)
JXL_EXPORT JxlSignature JxlSignatureCheck(const uint8_t *buf, size_t len)
Definition: decode.h:209
JXL_EXPORT JxlDecoderStatus JxlDecoderGetColorAsEncodedProfile(const JxlDecoder *dec, const JxlPixelFormat *unused_format, JxlColorProfileTarget target, JxlColorEncoding *color_encoding)
JXL_EXPORT uint32_t JxlDecoderVersion(void)
JxlProgressiveDetail
Definition: types.h:126
Definition: decode.h:48
JXL_EXPORT JxlDecoderStatus JxlDecoderSetPreferredColorProfile(JxlDecoder *dec, const JxlColorEncoding *color_encoding)
JXL_EXPORT JxlDecoderStatus JxlDecoderSetProgressiveDetail(JxlDecoder *dec, JxlProgressiveDetail detail)
JXL_EXPORT JxlDecoderStatus JxlDecoderFlushImage(JxlDecoder *dec)
Definition: codestream_header.h:397
char JxlBoxType[4]
Definition: types.h:116
JXL_EXPORT JxlDecoderStatus JxlDecoderSetParallelRunner(JxlDecoder *dec, JxlParallelRunner parallel_runner, void *parallel_runner_opaque)
JXL_EXPORT JXL_DEPRECATED JxlDecoderStatus JxlDecoderDefaultPixelFormat(const JxlDecoder *dec, JxlPixelFormat *format)
Definition: decode.h:356
JXL_EXPORT JxlDecoderStatus JxlDecoderSetDesiredIntensityTarget(JxlDecoder *dec, float desired_intensity_target)
JXL_EXPORT JxlDecoderStatus JxlDecoderSetExtraChannelBuffer(JxlDecoder *dec, const JxlPixelFormat *format, void *buffer, size_t size, uint32_t index)
Definition: decode.h:200
JXL_EXPORT JxlDecoderStatus JxlDecoderGetColorAsICCProfile(const JxlDecoder *dec, const JxlPixelFormat *unused_format, JxlColorProfileTarget target, uint8_t *icc_profile, size_t size)
Definition: codestream_header.h:338
Definition: codestream_header.h:105
JXL_EXPORT JxlDecoderStatus JxlDecoderSetKeepOrientation(JxlDecoder *dec, JXL_BOOL skip_reorientation)
Definition: memory_manager.h:51
JXL_EXPORT JxlDecoderStatus JxlDecoderSetUnpremultiplyAlpha(JxlDecoder *dec, JXL_BOOL unpremul_alpha)
Definition: decode.h:136
Definition: decode.h:260
Definition: decode.h:58
Definition: decode.h:187
JXL_EXPORT JxlDecoderStatus JxlDecoderProcessInput(JxlDecoder *dec)
JXL_EXPORT JxlDecoderStatus JxlDecoderGetExtraChannelName(const JxlDecoder *dec, size_t index, char *name, size_t size)
JXL_EXPORT size_t JxlDecoderReleaseJPEGBuffer(JxlDecoder *dec)
Definition: types.h:87
Definitions of structs and enums for the metadata from the JPEG XL codestream headers (signature...
JXL_EXPORT JxlDecoderStatus JxlDecoderPreviewOutBufferSize(const JxlDecoder *dec, const JxlPixelFormat *format, size_t *size)
JXL_EXPORT JxlDecoderStatus JxlDecoderGetBoxType(JxlDecoder *dec, JxlBoxType type, JXL_BOOL decompressed)
Definition: decode.h:275
JXL_EXPORT JxlDecoder * JxlDecoderCreate(const JxlMemoryManager *memory_manager)
JXL_EXPORT JxlDecoderStatus JxlDecoderSkipCurrentFrame(JxlDecoder *dec)
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
void *(* JxlImageOutInitCallback)(void *init_opaque, size_t num_threads, size_t num_pixels_per_thread)
Definition: decode.h:1050
JXL_EXPORT void JxlDecoderDestroy(JxlDecoder *dec)
JXL_EXPORT JxlDecoderStatus JxlDecoderSetImageOutBuffer(JxlDecoder *dec, const JxlPixelFormat *format, void *buffer, size_t size)
Definition: decode.h:219
JXL_EXPORT JxlDecoderStatus JxlDecoderSubscribeEvents(JxlDecoder *dec, int events_wanted)
JXL_EXPORT JxlDecoderStatus JxlDecoderExtraChannelBufferSize(const JxlDecoder *dec, const JxlPixelFormat *format, size_t *size, uint32_t index)
JXL_EXPORT JxlDecoderStatus JxlDecoderSetMultithreadedImageOutCallback(JxlDecoder *dec, const JxlPixelFormat *format, JxlImageOutInitCallback init_callback, JxlImageOutRunCallback run_callback, JxlImageOutDestroyCallback destroy_callback, void *init_opaque)
JXL_EXPORT void JxlDecoderReset(JxlDecoder *dec)
JxlSignature
Definition: decode.h:42
JXL_EXPORT JxlDecoderStatus JxlDecoderGetExtraChannelInfo(const JxlDecoder *dec, size_t index, JxlExtraChannelInfo *info)
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:1069
JXL_EXPORT JxlDecoderStatus JxlDecoderSetInput(JxlDecoder *dec, const uint8_t *data, size_t size)
JXL_EXPORT size_t JxlDecoderReleaseInput(JxlDecoder *dec)
Definition: decode.h:168
JXL_EXPORT JxlDecoderStatus JxlDecoderGetBoxSizeRaw(const JxlDecoder *dec, uint64_t *size)
JXL_EXPORT JxlDecoderStatus JxlDecoderGetFrameName(const JxlDecoder *dec, char *name, size_t size)
JXL_EXPORT JxlDecoderStatus JxlDecoderSetJPEGBuffer(JxlDecoder *dec, uint8_t *data, size_t size)
JXL_EXPORT JXL_DEPRECATED JxlDecoderStatus JxlDecoderDCOutBufferSize(const JxlDecoder *dec, const JxlPixelFormat *format, size_t *size)