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 
11 #ifndef JXL_DECODE_H_
12 #define JXL_DECODE_H_
13 
14 #include <stddef.h>
15 #include <stdint.h>
16 
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 
24 #if defined(__cplusplus) || defined(c_plusplus)
25 extern "C" {
26 #endif
27 
35 JXL_EXPORT uint32_t JxlDecoderVersion(void);
36 
39 typedef enum {
43 
46 
51 
56 } JxlSignature;
57 
72 JXL_EXPORT JxlSignature JxlSignatureCheck(const uint8_t* buf, size_t len);
73 
80 typedef struct JxlDecoderStruct JxlDecoder;
81 
94 JXL_EXPORT JxlDecoder* JxlDecoderCreate(const JxlMemoryManager* memory_manager);
95 
103 JXL_EXPORT void JxlDecoderReset(JxlDecoder* dec);
104 
110 JXL_EXPORT void JxlDecoderDestroy(JxlDecoder* dec);
111 
118 typedef enum {
123 
128 
139 
147 
157 
164 
172 
177 
183 
190 
197 
209  JXL_DEC_FRAME = 0x400,
210 
223 
231 
242 
254 JXL_EXPORT void JxlDecoderRewind(JxlDecoder* dec);
255 
272 JXL_EXPORT void JxlDecoderSkipFrames(JxlDecoder* dec, size_t amount);
273 
285 JXL_EXPORT JxlDecoderStatus
287 
300 JXL_EXPORT JxlDecoderStatus
302  void* parallel_runner_opaque);
303 
318 JXL_EXPORT size_t JxlDecoderSizeHintBasicInfo(const JxlDecoder* dec);
319 
333  int events_wanted);
334 
366 JXL_EXPORT JxlDecoderStatus
368 
405 
417  const uint8_t* data,
418  size_t size);
419 
437 JXL_EXPORT size_t JxlDecoderReleaseInput(JxlDecoder* dec);
438 
451  JxlBasicInfo* info);
452 
466  const JxlDecoder* dec, size_t index, JxlExtraChannelInfo* info);
467 
483  size_t index,
484  char* name,
485  size_t size);
486 
492 typedef enum {
496 
500 
539  const JxlDecoder* dec, const JxlPixelFormat* format,
540  JxlColorProfileTarget target, JxlColorEncoding* color_encoding);
541 
565 JXL_EXPORT JxlDecoderStatus
567  JxlColorProfileTarget target, size_t* size);
568 
587  const JxlDecoder* dec, const JxlPixelFormat* format,
588  JxlColorProfileTarget target, uint8_t* icc_profile, size_t size);
589 
629  JxlDecoder* dec, const JxlColorEncoding* color_encoding);
630 
643  const JxlDecoder* dec, const JxlPixelFormat* format, size_t* size);
644 
661  JxlDecoder* dec, const JxlPixelFormat* format, void* buffer, size_t size);
662 
676  JxlFrameHeader* header);
677 
692  char* name, size_t size);
693 
708 JXL_EXPORT JXL_DEPRECATED JxlDecoderStatus JxlDecoderDCOutBufferSize(
709  const JxlDecoder* dec, const JxlPixelFormat* format, size_t* size);
710 
729 JXL_EXPORT JXL_DEPRECATED JxlDecoderStatus JxlDecoderSetDCOutBuffer(
730  JxlDecoder* dec, const JxlPixelFormat* format, void* buffer, size_t size);
731 
744  const JxlDecoder* dec, const JxlPixelFormat* format, size_t* size);
745 
763  JxlDecoder* dec, const JxlPixelFormat* format, void* buffer, size_t size);
764 
781 typedef void (*JxlImageOutCallback)(void* opaque, size_t x, size_t y,
782  size_t num_pixels, const void* pixels);
783 
826 JXL_EXPORT JxlDecoderStatus
828  JxlImageOutCallback callback, void* opaque);
829 
844  uint8_t* data, size_t size);
845 
862 JXL_EXPORT size_t JxlDecoderReleaseJPEGBuffer(JxlDecoder* dec);
863 
864 /* TODO(lode): add way to output extra channels */
865 
883 
884 #if defined(__cplusplus) || defined(c_plusplus)
885 }
886 #endif
887 
888 #endif /* JXL_DECODE_H_ */
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...
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 JxlDecoderDefaultPixelFormat(const JxlDecoder *dec, JxlPixelFormat *format)
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 JxlDecoderSetInput(JxlDecoder *dec, const uint8_t *data, size_t size)
JXL_EXPORT JxlDecoderStatus JxlDecoderSetKeepOrientation(JxlDecoder *dec, JXL_BOOL keep_orientation)
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 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 JxlDecoderGetColorAsICCProfile(const JxlDecoder *dec, const JxlPixelFormat *format, JxlColorProfileTarget target, uint8_t *icc_profile, size_t size)
JXL_EXPORT size_t JxlDecoderReleaseJPEGBuffer(JxlDecoder *dec)
JxlColorProfileTarget
Definition: decode.h:492
@ JXL_COLOR_PROFILE_TARGET_DATA
Definition: decode.h:498
@ JXL_COLOR_PROFILE_TARGET_ORIGINAL
Definition: decode.h:495
JxlSignature
Definition: decode.h:39
@ JXL_SIG_NOT_ENOUGH_BYTES
Definition: decode.h:42
@ JXL_SIG_INVALID
Definition: decode.h:45
@ JXL_SIG_CONTAINER
Definition: decode.h:55
@ JXL_SIG_CODESTREAM
Definition: decode.h:50
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)
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:781
JXL_EXPORT JxlDecoderStatus JxlDecoderGetBasicInfo(const JxlDecoder *dec, JxlBasicInfo *info)
JXL_EXPORT JxlDecoderStatus JxlDecoderFlushImage(JxlDecoder *dec)
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 JxlDecoder * JxlDecoderCreate(const JxlMemoryManager *memory_manager)
JxlDecoderStatus
Definition: decode.h:118
@ JXL_DEC_JPEG_RECONSTRUCTION
Definition: decode.h:240
@ JXL_DEC_JPEG_NEED_MORE_OUTPUT
Definition: decode.h:171
@ JXL_DEC_BASIC_INFO
Definition: decode.h:176
@ JXL_DEC_EXTENSIONS
Definition: decode.h:182
@ JXL_DEC_DC_IMAGE
Definition: decode.h:222
@ JXL_DEC_ERROR
Definition: decode.h:127
@ JXL_DEC_NEED_IMAGE_OUT_BUFFER
Definition: decode.h:163
@ JXL_DEC_FULL_IMAGE
Definition: decode.h:230
@ JXL_DEC_COLOR_ENCODING
Definition: decode.h:189
@ JXL_DEC_SUCCESS
Definition: decode.h:122
@ JXL_DEC_PREVIEW_IMAGE
Definition: decode.h:196
@ JXL_DEC_NEED_DC_OUT_BUFFER
Definition: decode.h:156
@ JXL_DEC_NEED_MORE_INPUT
Definition: decode.h:138
@ JXL_DEC_NEED_PREVIEW_OUT_BUFFER
Definition: decode.h:146
@ JXL_DEC_FRAME
Definition: decode.h:209
struct JxlDecoderStruct JxlDecoder
Definition: decode.h:80
JXL_EXPORT JxlDecoderStatus JxlDecoderGetColorAsEncodedProfile(const JxlDecoder *dec, const JxlPixelFormat *format, JxlColorProfileTarget target, JxlColorEncoding *color_encoding)
JXL_EXPORT void JxlDecoderReset(JxlDecoder *dec)
Abstraction functions used by JPEG XL to allocate memory.
JxlParallelRetCode(* JxlParallelRunner)(void *runner_opaque, void *jpegxl_opaque, JxlParallelRunInit init, JxlParallelRunFunction func, uint32_t start_range, uint32_t end_range)
Definition: parallel_runner.h:116
Definition: codestream_header.h:95
Definition: color_encoding.h:101
Definition: codestream_header.h:231
Definition: codestream_header.h:281
Definition: memory_manager.h:48
Definition: types.h:85
Data types for the JPEG XL API, for both encoding and decoding.
#define JXL_BOOL
Definition: types.h:27