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 #include "jxl/version.h"
27 
28 #if defined(__cplusplus) || defined(c_plusplus)
29 extern "C" {
30 #endif
31 
39 JXL_EXPORT uint32_t JxlDecoderVersion(void);
40 
43 typedef enum {
47 
50 
55 
60 } JxlSignature;
61 
77 JXL_EXPORT JxlSignature JxlSignatureCheck(const uint8_t* buf, size_t len);
78 
85 typedef struct JxlDecoderStruct JxlDecoder;
86 
99 JXL_EXPORT JxlDecoder* JxlDecoderCreate(const JxlMemoryManager* memory_manager);
100 
108 JXL_EXPORT void JxlDecoderReset(JxlDecoder* dec);
109 
115 JXL_EXPORT void JxlDecoderDestroy(JxlDecoder* dec);
116 
123 typedef enum {
138 
143 
159 
170 
179 
186 
192 
201 
211 
221 
231 
251  JXL_DEC_FRAME = 0x400,
252 
265 
278 
314  JXL_DEC_BOX = 0x4000,
315 
333 
357 JXL_EXPORT void JxlDecoderRewind(JxlDecoder* dec);
358 
377 JXL_EXPORT void JxlDecoderSkipFrames(JxlDecoder* dec, size_t amount);
378 
392 
407 JXL_DEPRECATED JXL_EXPORT JxlDecoderStatus
409 
422 JXL_EXPORT JxlDecoderStatus
424  void* parallel_runner_opaque);
425 
441 JXL_EXPORT size_t JxlDecoderSizeHintBasicInfo(const JxlDecoder* dec);
442 
456  int events_wanted);
457 
489 JXL_EXPORT JxlDecoderStatus
491 
507 JXL_EXPORT JxlDecoderStatus
509 
520 JXL_EXPORT JxlDecoderStatus
522 
537  JXL_BOOL coalescing);
538 
580 
596  const uint8_t* data,
597  size_t size);
598 
618 JXL_EXPORT size_t JxlDecoderReleaseInput(JxlDecoder* dec);
619 
638 JXL_EXPORT void JxlDecoderCloseInput(JxlDecoder* dec);
639 
652  JxlBasicInfo* info);
653 
667  const JxlDecoder* dec, size_t index, JxlExtraChannelInfo* info);
668 
684  size_t index,
685  char* name,
686  size_t size);
687 
693 typedef enum {
697 
701 
752  const JxlDecoder* dec, const JxlPixelFormat* unused_format,
753  JxlColorProfileTarget target, JxlColorEncoding* color_encoding);
754 
779  const JxlDecoder* dec, const JxlPixelFormat* unused_format,
780  JxlColorProfileTarget target, size_t* size);
781 
799  const JxlDecoder* dec, const JxlPixelFormat* unused_format,
800  JxlColorProfileTarget target, uint8_t* icc_profile, size_t size);
801 
813  JxlDecoder* dec, const JxlColorEncoding* color_encoding);
814 
826  JxlDecoder* dec, float desired_intensity_target);
827 
870  JxlDecoder* dec, const JxlColorEncoding* color_encoding,
871  const uint8_t* icc_data, size_t icc_size);
872 
885 JXL_EXPORT void JxlDecoderSetCms(JxlDecoder* dec, JxlCmsInterface cms);
886 // TODO(firsching): add a function JxlDecoderSetDefaultCms() for setting a
887 // default in case libjxl is build with an CMS.
888 
902  const JxlDecoder* dec, const JxlPixelFormat* format, size_t* size);
903 
920  JxlDecoder* dec, const JxlPixelFormat* format, void* buffer, size_t size);
921 
935  JxlFrameHeader* header);
936 
950  char* name, size_t size);
951 
965  const JxlDecoder* dec, size_t index, JxlBlendInfo* blend_info);
966 
983  const JxlDecoder* dec, const JxlPixelFormat* format, size_t* size);
984 
1002  JxlDecoder* dec, const JxlPixelFormat* format, void* buffer, size_t size);
1003 
1020 typedef void (*JxlImageOutCallback)(void* opaque, size_t x, size_t y,
1021  size_t num_pixels, const void* pixels);
1022 
1035 typedef void* (*JxlImageOutInitCallback)(void* init_opaque, size_t num_threads,
1036  size_t num_pixels_per_thread);
1037 
1054 typedef void (*JxlImageOutRunCallback)(void* run_opaque, size_t thread_id,
1055  size_t x, size_t y, size_t num_pixels,
1056  const void* pixels);
1057 
1065 typedef void (*JxlImageOutDestroyCallback)(void* run_opaque);
1066 
1109 JXL_EXPORT JxlDecoderStatus
1111  JxlImageOutCallback callback, void* opaque);
1112 
1133  JxlDecoder* dec, const JxlPixelFormat* format,
1134  JxlImageOutInitCallback init_callback, JxlImageOutRunCallback run_callback,
1135  JxlImageOutDestroyCallback destroy_callback, void* init_opaque);
1136 
1153  const JxlDecoder* dec, const JxlPixelFormat* format, size_t* size,
1154  uint32_t index);
1155 
1186 JXL_EXPORT JxlDecoderStatus
1188  void* buffer, size_t size, uint32_t index);
1189 
1209  uint8_t* data, size_t size);
1210 
1227 JXL_EXPORT size_t JxlDecoderReleaseJPEGBuffer(JxlDecoder* dec);
1228 
1252  uint8_t* data, size_t size);
1253 
1270 JXL_EXPORT size_t JxlDecoderReleaseBoxBuffer(JxlDecoder* dec);
1271 
1293  JXL_BOOL decompress);
1294 
1361  JxlBoxType type,
1362  JXL_BOOL decompressed);
1363 
1382  uint64_t* size);
1383 
1395 JXL_EXPORT JxlDecoderStatus
1397 
1407 
1425 
1438 JXL_EXPORT JxlDecoderStatus
1440 
1441 #if defined(__cplusplus) || defined(c_plusplus)
1442 }
1443 #endif
1444 
1445 #endif /* JXL_DECODE_H_ */
1446 
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:152
#define JXL_BOOL
Definition: types.h:31
JxlProgressiveDetail
Definition: types.h:162
JXL_EXPORT size_t JxlDecoderReleaseBoxBuffer(JxlDecoder *dec)
JXL_EXPORT void JxlDecoderSkipFrames(JxlDecoder *dec, size_t amount)
JXL_EXPORT uint32_t JxlDecoderVersion(void)
JXL_EXPORT JxlDecoderStatus JxlDecoderSetOutputColorProfile(JxlDecoder *dec, const JxlColorEncoding *color_encoding, const uint8_t *icc_data, size_t icc_size)
JXL_EXPORT size_t JxlDecoderReleaseInput(JxlDecoder *dec)
JXL_EXPORT JxlDecoderStatus JxlDecoderPreviewOutBufferSize(const JxlDecoder *dec, const JxlPixelFormat *format, size_t *size)
JXL_EXPORT JxlDecoderStatus JxlDecoderSetImageOutBitDepth(JxlDecoder *dec, const JxlBitDepth *bit_depth)
JXL_EXPORT void JxlDecoderRewind(JxlDecoder *dec)
JXL_DEPRECATED JXL_EXPORT JxlDecoderStatus JxlDecoderDefaultPixelFormat(const JxlDecoder *dec, JxlPixelFormat *format)
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:1035
JxlColorProfileTarget
Definition: decode.h:693
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:43
JXL_EXPORT void JxlDecoderSetCms(JxlDecoder *dec, JxlCmsInterface cms)
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:1054
JXL_EXPORT JxlDecoderStatus JxlDecoderSetPreferredColorProfile(JxlDecoder *dec, const JxlColorEncoding *color_encoding)
JXL_EXPORT JxlDecoderStatus JxlDecoderSetImageOutCallback(JxlDecoder *dec, const JxlPixelFormat *format, JxlImageOutCallback callback, void *opaque)
void(* JxlImageOutCallback)(void *opaque, size_t x, size_t y, size_t num_pixels, const void *pixels)
Definition: decode.h:1020
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:1065
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:123
struct JxlDecoderStruct JxlDecoder
Definition: decode.h:85
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:699
@ JXL_COLOR_PROFILE_TARGET_ORIGINAL
Definition: decode.h:696
@ JXL_SIG_NOT_ENOUGH_BYTES
Definition: decode.h:46
@ JXL_SIG_INVALID
Definition: decode.h:49
@ JXL_SIG_CONTAINER
Definition: decode.h:59
@ JXL_SIG_CODESTREAM
Definition: decode.h:54
@ JXL_DEC_JPEG_RECONSTRUCTION
Definition: decode.h:277
@ JXL_DEC_JPEG_NEED_MORE_OUTPUT
Definition: decode.h:185
@ JXL_DEC_BASIC_INFO
Definition: decode.h:200
@ JXL_DEC_EXTENSIONS
Definition: decode.h:210
@ JXL_DEC_FRAME_PROGRESSION
Definition: decode.h:331
@ JXL_DEC_ERROR
Definition: decode.h:142
@ JXL_DEC_NEED_IMAGE_OUT_BUFFER
Definition: decode.h:178
@ JXL_DEC_FULL_IMAGE
Definition: decode.h:264
@ JXL_DEC_COLOR_ENCODING
Definition: decode.h:220
@ JXL_DEC_SUCCESS
Definition: decode.h:137
@ JXL_DEC_PREVIEW_IMAGE
Definition: decode.h:230
@ JXL_DEC_BOX_NEED_MORE_OUTPUT
Definition: decode.h:191
@ JXL_DEC_BOX
Definition: decode.h:314
@ JXL_DEC_NEED_MORE_INPUT
Definition: decode.h:158
@ JXL_DEC_NEED_PREVIEW_OUT_BUFFER
Definition: decode.h:169
@ JXL_DEC_FRAME
Definition: decode.h:251
Abstraction functions used by JPEG XL to allocate memory.
Definition: codestream_header.h:96
Definition: types.h:139
Definition: codestream_header.h:329
Definition: cms_interface.h:209
Definition: color_encoding.h:116
Definition: codestream_header.h:264
Definition: codestream_header.h:388
Definition: memory_manager.h:51
Definition: types.h:86
Data types for the JPEG XL API, for both encoding and decoding.