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
35JXL_EXPORT uint32_t JxlDecoderVersion(void);
36
39 typedef enum {
42 JXL_SIG_NOT_ENOUGH_BYTES = 0,
43
45 JXL_SIG_INVALID = 1,
46
50 JXL_SIG_CODESTREAM = 2,
51
55 JXL_SIG_CONTAINER = 3,
56} JxlSignature;
57
72JXL_EXPORT JxlSignature JxlSignatureCheck(const uint8_t* buf, size_t len);
73
80 typedef struct JxlDecoderStruct JxlDecoder;
81
94JXL_EXPORT JxlDecoder* JxlDecoderCreate(const JxlMemoryManager* memory_manager);
95
103JXL_EXPORT void JxlDecoderReset(JxlDecoder* dec);
104
110JXL_EXPORT void JxlDecoderDestroy(JxlDecoder* dec);
111
118 typedef enum {
122 JXL_DEC_SUCCESS = 0,
123
127 JXL_DEC_ERROR = 1,
128
138 JXL_DEC_NEED_MORE_INPUT = 2,
139
146 JXL_DEC_NEED_PREVIEW_OUT_BUFFER = 3,
147
156 JXL_DEC_NEED_DC_OUT_BUFFER = 4,
157
163 JXL_DEC_NEED_IMAGE_OUT_BUFFER = 5,
164
171 JXL_DEC_JPEG_NEED_MORE_OUTPUT = 6,
172
176 JXL_DEC_BASIC_INFO = 0x40,
177
182 JXL_DEC_EXTENSIONS = 0x80,
183
189 JXL_DEC_COLOR_ENCODING = 0x100,
190
196 JXL_DEC_PREVIEW_IMAGE = 0x200,
197
209 JXL_DEC_FRAME = 0x400,
210
222 JXL_DEC_DC_IMAGE = 0x800,
223
230 JXL_DEC_FULL_IMAGE = 0x1000,
231
240 JXL_DEC_JPEG_RECONSTRUCTION = 0x2000,
241} JxlDecoderStatus;
242
254JXL_EXPORT void JxlDecoderRewind(JxlDecoder* dec);
255
272JXL_EXPORT void JxlDecoderSkipFrames(JxlDecoder* dec, size_t amount);
273
285JXL_EXPORT JxlDecoderStatus
286 JxlDecoderDefaultPixelFormat(const JxlDecoder* dec, JxlPixelFormat* format);
287
300JXL_EXPORT JxlDecoderStatus
301 JxlDecoderSetParallelRunner(JxlDecoder* dec, JxlParallelRunner parallel_runner,
302 void* parallel_runner_opaque);
303
318JXL_EXPORT size_t JxlDecoderSizeHintBasicInfo(const JxlDecoder* dec);
319
332JXL_EXPORT JxlDecoderStatus JxlDecoderSubscribeEvents(JxlDecoder* dec,
333 int events_wanted);
334
366JXL_EXPORT JxlDecoderStatus
367 JxlDecoderSetKeepOrientation(JxlDecoder* dec, JXL_BOOL keep_orientation);
368
404JXL_EXPORT JxlDecoderStatus JxlDecoderProcessInput(JxlDecoder* dec);
405
416JXL_EXPORT JxlDecoderStatus JxlDecoderSetInput(JxlDecoder* dec,
417 const uint8_t* data,
418 size_t size);
419
437JXL_EXPORT size_t JxlDecoderReleaseInput(JxlDecoder* dec);
438
450JXL_EXPORT JxlDecoderStatus JxlDecoderGetBasicInfo(const JxlDecoder* dec,
451 JxlBasicInfo* info);
452
465JXL_EXPORT JxlDecoderStatus JxlDecoderGetExtraChannelInfo(
466 const JxlDecoder* dec, size_t index, JxlExtraChannelInfo* info);
467
482JXL_EXPORT JxlDecoderStatus JxlDecoderGetExtraChannelName(const JxlDecoder* dec,
483 size_t index,
484 char* name,
485 size_t size);
486
492 typedef enum {
495 JXL_COLOR_PROFILE_TARGET_ORIGINAL = 0,
496
498 JXL_COLOR_PROFILE_TARGET_DATA = 1,
499} JxlColorProfileTarget;
500
538JXL_EXPORT JxlDecoderStatus JxlDecoderGetColorAsEncodedProfile(
539 const JxlDecoder* dec, const JxlPixelFormat* format,
540 JxlColorProfileTarget target, JxlColorEncoding* color_encoding);
541
565JXL_EXPORT JxlDecoderStatus
566 JxlDecoderGetICCProfileSize(const JxlDecoder* dec, const JxlPixelFormat* format,
567 JxlColorProfileTarget target, size_t* size);
568
586JXL_EXPORT JxlDecoderStatus JxlDecoderGetColorAsICCProfile(
587 const JxlDecoder* dec, const JxlPixelFormat* format,
588 JxlColorProfileTarget target, uint8_t* icc_profile, size_t size);
589
628JXL_EXPORT JxlDecoderStatus JxlDecoderSetPreferredColorProfile(
629 JxlDecoder* dec, const JxlColorEncoding* color_encoding);
630
642JXL_EXPORT JxlDecoderStatus JxlDecoderPreviewOutBufferSize(
643 const JxlDecoder* dec, const JxlPixelFormat* format, size_t* size);
644
660JXL_EXPORT JxlDecoderStatus JxlDecoderSetPreviewOutBuffer(
661 JxlDecoder* dec, const JxlPixelFormat* format, void* buffer, size_t size);
662
675JXL_EXPORT JxlDecoderStatus JxlDecoderGetFrameHeader(const JxlDecoder* dec,
676 JxlFrameHeader* header);
677
691JXL_EXPORT JxlDecoderStatus JxlDecoderGetFrameName(const JxlDecoder* dec,
692 char* name, size_t size);
693
708JXL_EXPORT JXL_DEPRECATED JxlDecoderStatus JxlDecoderDCOutBufferSize(
709 const JxlDecoder* dec, const JxlPixelFormat* format, size_t* size);
710
729JXL_EXPORT JXL_DEPRECATED JxlDecoderStatus JxlDecoderSetDCOutBuffer(
730 JxlDecoder* dec, const JxlPixelFormat* format, void* buffer, size_t size);
731
743JXL_EXPORT JxlDecoderStatus JxlDecoderImageOutBufferSize(
744 const JxlDecoder* dec, const JxlPixelFormat* format, size_t* size);
745
762JXL_EXPORT JxlDecoderStatus JxlDecoderSetImageOutBuffer(
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
826JXL_EXPORT JxlDecoderStatus
827 JxlDecoderSetImageOutCallback(JxlDecoder* dec, const JxlPixelFormat* format,
828 JxlImageOutCallback callback, void* opaque);
829
845JXL_EXPORT JxlDecoderStatus JxlDecoderExtraChannelBufferSize(
846 const JxlDecoder* dec, const JxlPixelFormat* format, size_t* size,
847 uint32_t index);
848
878JXL_EXPORT JxlDecoderStatus
879 JxlDecoderSetExtraChannelBuffer(JxlDecoder* dec, const JxlPixelFormat* format,
880 void* buffer, size_t size, uint32_t index);
881
895JXL_EXPORT JxlDecoderStatus JxlDecoderSetJPEGBuffer(JxlDecoder* dec,
896 uint8_t* data, size_t size);
897
914JXL_EXPORT size_t JxlDecoderReleaseJPEGBuffer(JxlDecoder* dec);
915
932JXL_EXPORT JxlDecoderStatus JxlDecoderFlushImage(JxlDecoder* dec);
933
934#if defined(__cplusplus) || defined(c_plusplus)
935}
936#endif
937
938#endif /* JXL_DECODE_H_ */
codestream_header.h
Definitions of structs and enums for the metadata from the JPEG XL codestream headers (signature,...
color_encoding.h
Color Encoding definitions used by JPEG XL. All CIE units are for the standard 1931 2 degree observer...
JxlDecoderSkipFrames
JXL_EXPORT void JxlDecoderSkipFrames(JxlDecoder *dec, size_t amount)
JxlDecoderVersion
JXL_EXPORT uint32_t JxlDecoderVersion(void)
JxlDecoderReleaseInput
JXL_EXPORT size_t JxlDecoderReleaseInput(JxlDecoder *dec)
JxlDecoderSetDCOutBuffer
JXL_EXPORT JXL_DEPRECATED JxlDecoderStatus JxlDecoderSetDCOutBuffer(JxlDecoder *dec, const JxlPixelFormat *format, void *buffer, size_t size)
JxlDecoderPreviewOutBufferSize
JXL_EXPORT JxlDecoderStatus JxlDecoderPreviewOutBufferSize(const JxlDecoder *dec, const JxlPixelFormat *format, size_t *size)
JxlDecoderRewind
JXL_EXPORT void JxlDecoderRewind(JxlDecoder *dec)
JxlDecoderDefaultPixelFormat
JXL_EXPORT JxlDecoderStatus JxlDecoderDefaultPixelFormat(const JxlDecoder *dec, JxlPixelFormat *format)
JxlDecoderSetPreviewOutBuffer
JXL_EXPORT JxlDecoderStatus JxlDecoderSetPreviewOutBuffer(JxlDecoder *dec, const JxlPixelFormat *format, void *buffer, size_t size)
JxlDecoderGetFrameName
JXL_EXPORT JxlDecoderStatus JxlDecoderGetFrameName(const JxlDecoder *dec, char *name, size_t size)
JxlDecoderGetExtraChannelName
JXL_EXPORT JxlDecoderStatus JxlDecoderGetExtraChannelName(const JxlDecoder *dec, size_t index, char *name, size_t size)
JxlDecoderSetInput
JXL_EXPORT JxlDecoderStatus JxlDecoderSetInput(JxlDecoder *dec, const uint8_t *data, size_t size)
JxlDecoderSetKeepOrientation
JXL_EXPORT JxlDecoderStatus JxlDecoderSetKeepOrientation(JxlDecoder *dec, JXL_BOOL keep_orientation)
JxlDecoderGetFrameHeader
JXL_EXPORT JxlDecoderStatus JxlDecoderGetFrameHeader(const JxlDecoder *dec, JxlFrameHeader *header)
JxlDecoderSizeHintBasicInfo
JXL_EXPORT size_t JxlDecoderSizeHintBasicInfo(const JxlDecoder *dec)
JxlDecoderSetImageOutBuffer
JXL_EXPORT JxlDecoderStatus JxlDecoderSetImageOutBuffer(JxlDecoder *dec, const JxlPixelFormat *format, void *buffer, size_t size)
JxlDecoderImageOutBufferSize
JXL_EXPORT JxlDecoderStatus JxlDecoderImageOutBufferSize(const JxlDecoder *dec, const JxlPixelFormat *format, size_t *size)
JxlDecoderGetExtraChannelInfo
JXL_EXPORT JxlDecoderStatus JxlDecoderGetExtraChannelInfo(const JxlDecoder *dec, size_t index, JxlExtraChannelInfo *info)
JxlDecoderGetColorAsICCProfile
JXL_EXPORT JxlDecoderStatus JxlDecoderGetColorAsICCProfile(const JxlDecoder *dec, const JxlPixelFormat *format, JxlColorProfileTarget target, uint8_t *icc_profile, size_t size)
JxlDecoderCreate
JXL_EXPORT JxlDecoder * JxlDecoderCreate(const JxlMemoryManager *memory_manager)
JxlDecoderReleaseJPEGBuffer
JXL_EXPORT size_t JxlDecoderReleaseJPEGBuffer(JxlDecoder *dec)
JxlColorProfileTarget
JxlColorProfileTarget
Definition: decode.h:492
JXL_COLOR_PROFILE_TARGET_DATA
@ JXL_COLOR_PROFILE_TARGET_DATA
Definition: decode.h:498
JXL_COLOR_PROFILE_TARGET_ORIGINAL
@ JXL_COLOR_PROFILE_TARGET_ORIGINAL
Definition: decode.h:495
JxlDecoderExtraChannelBufferSize
JXL_EXPORT JxlDecoderStatus JxlDecoderExtraChannelBufferSize(const JxlDecoder *dec, const JxlPixelFormat *format, size_t *size, uint32_t index)
JxlSignature
JxlSignature
Definition: decode.h:39
JXL_SIG_NOT_ENOUGH_BYTES
@ JXL_SIG_NOT_ENOUGH_BYTES
Definition: decode.h:42
JXL_SIG_INVALID
@ JXL_SIG_INVALID
Definition: decode.h:45
JXL_SIG_CONTAINER
@ JXL_SIG_CONTAINER
Definition: decode.h:55
JXL_SIG_CODESTREAM
@ JXL_SIG_CODESTREAM
Definition: decode.h:50
JxlDecoderSubscribeEvents
JXL_EXPORT JxlDecoderStatus JxlDecoderSubscribeEvents(JxlDecoder *dec, int events_wanted)
JxlDecoderSetParallelRunner
JXL_EXPORT JxlDecoderStatus JxlDecoderSetParallelRunner(JxlDecoder *dec, JxlParallelRunner parallel_runner, void *parallel_runner_opaque)
JxlDecoderProcessInput
JXL_EXPORT JxlDecoderStatus JxlDecoderProcessInput(JxlDecoder *dec)
JxlDecoderSetPreferredColorProfile
JXL_EXPORT JxlDecoderStatus JxlDecoderSetPreferredColorProfile(JxlDecoder *dec, const JxlColorEncoding *color_encoding)
JxlDecoderGetICCProfileSize
JXL_EXPORT JxlDecoderStatus JxlDecoderGetICCProfileSize(const JxlDecoder *dec, const JxlPixelFormat *format, JxlColorProfileTarget target, size_t *size)
JxlDecoderSetImageOutCallback
JXL_EXPORT JxlDecoderStatus JxlDecoderSetImageOutCallback(JxlDecoder *dec, const JxlPixelFormat *format, JxlImageOutCallback callback, void *opaque)
JxlDecoderDCOutBufferSize
JXL_EXPORT JXL_DEPRECATED JxlDecoderStatus JxlDecoderDCOutBufferSize(const JxlDecoder *dec, const JxlPixelFormat *format, size_t *size)
JxlImageOutCallback
void(* JxlImageOutCallback)(void *opaque, size_t x, size_t y, size_t num_pixels, const void *pixels)
Definition: decode.h:781
JxlDecoderGetBasicInfo
JXL_EXPORT JxlDecoderStatus JxlDecoderGetBasicInfo(const JxlDecoder *dec, JxlBasicInfo *info)
JxlDecoderFlushImage
JXL_EXPORT JxlDecoderStatus JxlDecoderFlushImage(JxlDecoder *dec)
JxlDecoderSetJPEGBuffer
JXL_EXPORT JxlDecoderStatus JxlDecoderSetJPEGBuffer(JxlDecoder *dec, uint8_t *data, size_t size)
JxlDecoderDestroy
JXL_EXPORT void JxlDecoderDestroy(JxlDecoder *dec)
JxlSignatureCheck
JXL_EXPORT JxlSignature JxlSignatureCheck(const uint8_t *buf, size_t len)
JxlDecoderStatus
JxlDecoderStatus
Definition: decode.h:118
JXL_DEC_JPEG_RECONSTRUCTION
@ JXL_DEC_JPEG_RECONSTRUCTION
Definition: decode.h:240
JXL_DEC_JPEG_NEED_MORE_OUTPUT
@ JXL_DEC_JPEG_NEED_MORE_OUTPUT
Definition: decode.h:171
JXL_DEC_BASIC_INFO
@ JXL_DEC_BASIC_INFO
Definition: decode.h:176
JXL_DEC_EXTENSIONS
@ JXL_DEC_EXTENSIONS
Definition: decode.h:182
JXL_DEC_DC_IMAGE
@ JXL_DEC_DC_IMAGE
Definition: decode.h:222
JXL_DEC_ERROR
@ JXL_DEC_ERROR
Definition: decode.h:127
JXL_DEC_NEED_IMAGE_OUT_BUFFER
@ JXL_DEC_NEED_IMAGE_OUT_BUFFER
Definition: decode.h:163
JXL_DEC_FULL_IMAGE
@ JXL_DEC_FULL_IMAGE
Definition: decode.h:230
JXL_DEC_COLOR_ENCODING
@ JXL_DEC_COLOR_ENCODING
Definition: decode.h:189
JXL_DEC_SUCCESS
@ JXL_DEC_SUCCESS
Definition: decode.h:122
JXL_DEC_PREVIEW_IMAGE
@ JXL_DEC_PREVIEW_IMAGE
Definition: decode.h:196
JXL_DEC_NEED_DC_OUT_BUFFER
@ JXL_DEC_NEED_DC_OUT_BUFFER
Definition: decode.h:156
JXL_DEC_NEED_MORE_INPUT
@ JXL_DEC_NEED_MORE_INPUT
Definition: decode.h:138
JXL_DEC_NEED_PREVIEW_OUT_BUFFER
@ JXL_DEC_NEED_PREVIEW_OUT_BUFFER
Definition: decode.h:146
JXL_DEC_FRAME
@ JXL_DEC_FRAME
Definition: decode.h:209
JxlDecoder
struct JxlDecoderStruct JxlDecoder
Definition: decode.h:80
JxlDecoderGetColorAsEncodedProfile
JXL_EXPORT JxlDecoderStatus JxlDecoderGetColorAsEncodedProfile(const JxlDecoder *dec, const JxlPixelFormat *format, JxlColorProfileTarget target, JxlColorEncoding *color_encoding)
JxlDecoderReset
JXL_EXPORT void JxlDecoderReset(JxlDecoder *dec)
JxlDecoderSetExtraChannelBuffer
JXL_EXPORT JxlDecoderStatus JxlDecoderSetExtraChannelBuffer(JxlDecoder *dec, const JxlPixelFormat *format, void *buffer, size_t size, uint32_t index)
memory_manager.h
Abstraction functions used by JPEG XL to allocate memory.
parallel_runner.h
JxlParallelRunner
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
JxlBasicInfo
Definition: codestream_header.h:95
JxlColorEncoding
Definition: color_encoding.h:101
JxlExtraChannelInfo
Definition: codestream_header.h:241
JxlFrameHeader
Definition: codestream_header.h:291
JxlMemoryManagerStruct
Definition: memory_manager.h:48
JxlPixelFormat
Definition: types.h:85
types.h
Data types for the JPEG XL API, for both encoding and decoding.
JXL_BOOL
#define JXL_BOOL
Definition: types.h:27