LIBJXL_DOC
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 <jxl/cms_interface.h>
17 #include <jxl/codestream_header.h>
18 #include <jxl/color_encoding.h>
19 #include <jxl/jxl_export.h>
20 #include <jxl/memory_manager.h>
21 #include <jxl/parallel_runner.h>
22 #include <jxl/types.h>
23 #include <jxl/version.h> // TODO(eustas): remove before v1.0
24 #include <stddef.h>
25 #include <stdint.h>
26 
27 #ifdef __cplusplus
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 JxlDecoder 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 
168 
177 
184 
190 
199 
209 
219 
239  JXL_DEC_FRAME = 0x400,
240 
253 
266 
303  JXL_DEC_BOX = 0x4000,
304 
321 
327 
336 typedef enum {
340  kFrames = 0,
344  kDC = 1,
354  kPasses = 3,
366  kGroups = 6,
368 
392 JXL_EXPORT void JxlDecoderRewind(JxlDecoder* dec);
393 
412 JXL_EXPORT void JxlDecoderSkipFrames(JxlDecoder* dec, size_t amount);
413 
427 
440 JXL_EXPORT JxlDecoderStatus
442  void* parallel_runner_opaque);
443 
459 JXL_EXPORT size_t JxlDecoderSizeHintBasicInfo(const JxlDecoder* dec);
460 
474  int events_wanted);
475 
507 JXL_EXPORT JxlDecoderStatus
508 JxlDecoderSetKeepOrientation(JxlDecoder* dec, JXL_BOOL skip_reorientation);
509 
526 JXL_EXPORT JxlDecoderStatus
528 
539 JXL_EXPORT JxlDecoderStatus
540 JxlDecoderSetRenderSpotcolors(JxlDecoder* dec, JXL_BOOL render_spotcolors);
541 
556  JXL_BOOL coalescing);
557 
599 
615  const uint8_t* data,
616  size_t size);
617 
637 JXL_EXPORT size_t JxlDecoderReleaseInput(JxlDecoder* dec);
638 
657 JXL_EXPORT void JxlDecoderCloseInput(JxlDecoder* dec);
658 
671  JxlBasicInfo* info);
672 
686  const JxlDecoder* dec, size_t index, JxlExtraChannelInfo* info);
687 
703  size_t index,
704  char* name,
705  size_t size);
706 
712 typedef enum {
716 
720 
770  const JxlDecoder* dec, JxlColorProfileTarget target,
771  JxlColorEncoding* color_encoding);
772 
796  const JxlDecoder* dec, JxlColorProfileTarget target, size_t* size);
797 
814  const JxlDecoder* dec, JxlColorProfileTarget target, uint8_t* icc_profile,
815  size_t size);
816 
828  JxlDecoder* dec, const JxlColorEncoding* color_encoding);
829 
841  JxlDecoder* dec, float desired_intensity_target);
842 
885  JxlDecoder* dec, const JxlColorEncoding* color_encoding,
886  const uint8_t* icc_data, size_t icc_size);
887 
901  JxlCmsInterface cms);
902 // TODO(firsching): add a function JxlDecoderSetDefaultCms() for setting a
903 // default in case libjxl is build with a CMS.
904 
918  const JxlDecoder* dec, const JxlPixelFormat* format, size_t* size);
919 
939  JxlDecoder* dec, const JxlPixelFormat* format, void* buffer, size_t size);
940 
954  JxlFrameHeader* header);
955 
969  char* name, size_t size);
970 
984  const JxlDecoder* dec, size_t index, JxlBlendInfo* blend_info);
985 
1002  const JxlDecoder* dec, const JxlPixelFormat* format, size_t* size);
1003 
1022  JxlDecoder* dec, const JxlPixelFormat* format, void* buffer, size_t size);
1023 
1040 typedef void (*JxlImageOutCallback)(void* opaque, size_t x, size_t y,
1041  size_t num_pixels, const void* pixels);
1042 
1055 typedef void* (*JxlImageOutInitCallback)(void* init_opaque, size_t num_threads,
1056  size_t num_pixels_per_thread);
1057 
1074 typedef void (*JxlImageOutRunCallback)(void* run_opaque, size_t thread_id,
1075  size_t x, size_t y, size_t num_pixels,
1076  const void* pixels);
1077 
1085 typedef void (*JxlImageOutDestroyCallback)(void* run_opaque);
1086 
1129 JXL_EXPORT JxlDecoderStatus
1131  JxlImageOutCallback callback, void* opaque);
1132 
1153  JxlDecoder* dec, const JxlPixelFormat* format,
1154  JxlImageOutInitCallback init_callback, JxlImageOutRunCallback run_callback,
1155  JxlImageOutDestroyCallback destroy_callback, void* init_opaque);
1156 
1173  const JxlDecoder* dec, const JxlPixelFormat* format, size_t* size,
1174  uint32_t index);
1175 
1206 JXL_EXPORT JxlDecoderStatus
1208  void* buffer, size_t size, uint32_t index);
1209 
1229  uint8_t* data, size_t size);
1230 
1247 JXL_EXPORT size_t JxlDecoderReleaseJPEGBuffer(JxlDecoder* dec);
1248 
1272  uint8_t* data, size_t size);
1273 
1290 JXL_EXPORT size_t JxlDecoderReleaseBoxBuffer(JxlDecoder* dec);
1291 
1313  JXL_BOOL decompress);
1314 
1381  JxlBoxType type,
1382  JXL_BOOL decompressed);
1383 
1394  uint64_t* size);
1395 
1410  uint64_t* size);
1411 
1423 JXL_EXPORT JxlDecoderStatus
1425 
1434 JXL_EXPORT size_t JxlDecoderGetIntendedDownsamplingRatio(JxlDecoder* dec);
1435 
1453 
1466 JXL_EXPORT JxlDecoderStatus
1467 JxlDecoderSetImageOutBitDepth(JxlDecoder* dec, const JxlBitDepth* bit_depth);
1468 
1469 #ifdef __cplusplus
1470 }
1471 #endif
1472 
1473 #endif /* JXL_DECODE_H_ */
1474 
JXL_EXPORT JxlDecoderStatus JxlDecoderGetBasicInfo(const JxlDecoder *dec, JxlBasicInfo *info)
Definition: decode.h:718
Definition: decode.h:715
JXL_EXPORT size_t JxlDecoderSizeHintBasicInfo(const JxlDecoder *dec)
Definition: decode.h:157
void(* JxlImageOutDestroyCallback)(void *run_opaque)
Definition: decode.h:1085
Definition: decode.h:303
Interface to allow the injection of different color management systems (CMSes, also called color mana...
#define JXL_BOOL
Definition: types.h:29
Data types for the JPEG XL API, for both encoding and decoding.
Definition: types.h:133
JxlDecoderStatus
Definition: decode.h:122
Definition: color_encoding.h:114
Definition: cms_interface.h:227
JXL_EXPORT JxlDecoderStatus JxlDecoderSetImageOutCallback(JxlDecoder *dec, const JxlPixelFormat *format, JxlImageOutCallback callback, void *opaque)
Definition: decode.h:366
JXL_EXPORT JxlDecoderStatus JxlDecoderGetColorAsICCProfile(const JxlDecoder *dec, JxlColorProfileTarget target, uint8_t *icc_profile, size_t size)
Definition: decode.h:141
void(* JxlImageOutCallback)(void *opaque, size_t x, size_t y, size_t num_pixels, const void *pixels)
Definition: decode.h:1040
JxlColorProfileTarget
Definition: decode.h:712
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:265
Definition: decode.h:53
Definition: decode.h:208
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:252
JXL_EXPORT JxlDecoderStatus JxlDecoderSetPreviewOutBuffer(JxlDecoder *dec, const JxlPixelFormat *format, void *buffer, size_t size)
Definition: decode.h:183
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:265
JXL_EXPORT void JxlDecoderSkipFrames(JxlDecoder *dec, size_t amount)
Definition: decode.h:358
JXL_EXPORT JxlDecoderStatus JxlDecoderImageOutBufferSize(const JxlDecoder *dec, const JxlPixelFormat *format, size_t *size)
Definition: decode.h:362
JXL_EXPORT JxlDecoderStatus JxlDecoderSetCms(JxlDecoder *dec, JxlCmsInterface cms)
Definition: decode.h:218
Abstraction functions used by JPEG XL to allocate memory.
JXL_EXPORT void JxlDecoderRewind(JxlDecoder *dec)
struct JxlDecoder JxlDecoder
Definition: decode.h:84
JXL_EXPORT JxlDecoderStatus JxlDecoderSetDecompressBoxes(JxlDecoder *dec, JXL_BOOL decompress)
JXL_EXPORT JxlSignature JxlSignatureCheck(const uint8_t *buf, size_t len)
Definition: decode.h:198
JXL_EXPORT uint32_t JxlDecoderVersion(void)
Definition: decode.h:325
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:391
char JxlBoxType[4]
Definition: types.h:146
JXL_EXPORT JxlDecoderStatus JxlDecoderSetParallelRunner(JxlDecoder *dec, JxlParallelRunner parallel_runner, void *parallel_runner_opaque)
Definition: decode.h:344
Definition: decode.h:320
JxlProgressiveDetail
Definition: decode.h:336
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:189
Definition: codestream_header.h:330
JXL_EXPORT JxlDecoderStatus JxlDecoderSetImageOutBitDepth(JxlDecoder *dec, const JxlBitDepth *bit_depth)
Definition: decode.h:349
Definition: decode.h:340
Definition: codestream_header.h:95
JXL_EXPORT JxlDecoderStatus JxlDecoderGetICCProfileSize(const JxlDecoder *dec, JxlColorProfileTarget target, size_t *size)
JXL_EXPORT JxlDecoderStatus JxlDecoderGetBoxSizeContents(const JxlDecoder *dec, uint64_t *size)
JXL_EXPORT JxlDecoderStatus JxlDecoderSetOutputColorProfile(JxlDecoder *dec, const JxlColorEncoding *color_encoding, const uint8_t *icc_data, size_t icc_size)
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:239
Definition: decode.h:58
Definition: decode.h:176
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:80
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:354
JXL_EXPORT JxlDecoder * JxlDecoderCreate(const JxlMemoryManager *memory_manager)
JXL_EXPORT JxlDecoderStatus JxlDecoderSkipCurrentFrame(JxlDecoder *dec)
void *(* JxlImageOutInitCallback)(void *init_opaque, size_t num_threads, size_t num_pixels_per_thread)
Definition: decode.h:1055
JXL_EXPORT void JxlDecoderDestroy(JxlDecoder *dec)
JXL_EXPORT JxlDecoderStatus JxlDecoderSetImageOutBuffer(JxlDecoder *dec, const JxlPixelFormat *format, void *buffer, size_t size)
JXL_EXPORT JxlDecoderStatus JxlDecoderSubscribeEvents(JxlDecoder *dec, int events_wanted)
JxlParallelRetCode(* JxlParallelRunner)(void *runner_opaque, void *jpegxl_opaque, JxlParallelRunInit init, JxlParallelRunFunction func, uint32_t start_range, uint32_t end_range)
Definition: parallel_runner.h:127
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 JxlDecoderGetColorAsEncodedProfile(const JxlDecoder *dec, JxlColorProfileTarget target, JxlColorEncoding *color_encoding)
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:1074
JXL_EXPORT JxlDecoderStatus JxlDecoderSetInput(JxlDecoder *dec, const uint8_t *data, size_t size)
JXL_EXPORT size_t JxlDecoderReleaseInput(JxlDecoder *dec)
Definition: decode.h:167
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)