LIBJXL
encode.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_ENCODE_H_
14 #define JXL_ENCODE_H_
15 
16 #include <jxl/cms_interface.h>
17 #include <jxl/codestream_header.h>
18 #include <jxl/jxl_export.h>
19 #include <jxl/memory_manager.h>
20 #include <jxl/parallel_runner.h>
21 #include <jxl/stats.h>
22 #include <jxl/version.h>
23 #include <stdint.h>
24 
25 #include "jxl/types.h"
26 
27 #if defined(__cplusplus) || defined(c_plusplus)
28 extern "C" {
29 #endif
30 
38 JXL_EXPORT uint32_t JxlEncoderVersion(void);
39 
46 typedef struct JxlEncoderStruct JxlEncoder;
47 
56 typedef struct JxlEncoderFrameSettingsStruct JxlEncoderFrameSettings;
57 
61 typedef enum {
66 
70 
74 
76 
82 typedef enum {
86 
90 
95 
100 
104 
110 
116 
118 
125 typedef enum {
132 
138 
146 
153 
164 
171 
177 
182 
187 
192 
197 
203 
208 
214 
220 
225 
230 
236 
242 
248 
254 
260 
265 
270 
277 
286 
290 
297 
303 
311 
316 
327 
334 
341 
356 
365 
373 
380 
385 
387 
400 JXL_EXPORT JxlEncoder* JxlEncoderCreate(const JxlMemoryManager* memory_manager);
401 
409 JXL_EXPORT void JxlEncoderReset(JxlEncoder* enc);
410 
416 JXL_EXPORT void JxlEncoderDestroy(JxlEncoder* enc);
417 
427 JXL_EXPORT void JxlEncoderSetCms(JxlEncoder* enc, JxlCmsInterface cms);
428 
441 JXL_EXPORT JxlEncoderStatus
443  void* parallel_runner_opaque);
444 
453 
485  uint8_t** next_out,
486  size_t* avail_out);
487 
521 JXL_EXPORT JxlEncoderStatus
523  const JxlFrameHeader* frame_header);
524 
537  JxlEncoderFrameSettings* frame_settings, size_t index,
538  const JxlBlendInfo* blend_info);
539 
560  JxlEncoderFrameSettings* frame_settings, const char* frame_name);
561 
576  JxlEncoderFrameSettings* frame_settings, const JxlBitDepth* bit_depth);
577 
604 JXL_EXPORT JxlEncoderStatus
606  const uint8_t* buffer, size_t size);
607 
673  const JxlEncoderFrameSettings* frame_settings,
674  const JxlPixelFormat* pixel_format, const void* buffer, size_t size);
675 
711  void* opaque;
712 
730  void* (*get_buffer)(void* opaque, size_t* size);
731 
741  void (*release_buffer)(void* opaque, size_t written_bytes);
742 
753  void (*seek)(void* opaque, uint64_t position);
754 
766  void (*set_finalized_position)(void* opaque, uint64_t finalized_position);
767 };
768 
782  JxlEncoder* enc, struct JxlEncoderOutputProcessor output_processor);
783 
798 
808  void* opaque;
809 
823  JxlPixelFormat* pixel_format);
824 
848  const void* (*get_color_channel_data_at)(void* opaque, size_t xpos,
849  size_t ypos, size_t xsize,
850  size_t ysize, size_t* row_offset);
851 
865  void (*get_extra_channel_pixel_format)(void* opaque, size_t ec_index,
866  JxlPixelFormat* pixel_format);
867 
892  const void* (*get_extra_channel_data_at)(void* opaque, size_t ec_index,
893  size_t xpos, size_t ypos,
894  size_t xsize, size_t ysize,
895  size_t* row_offset);
896 
907  void (*release_buffer)(void* opaque, const void* buf);
908 };
909 
931  const JxlEncoderFrameSettings* frame_settings, JXL_BOOL is_last_frame,
932  struct JxlChunkedFrameInputSource chunked_frame_input);
933 
958  const JxlEncoderFrameSettings* frame_settings,
959  const JxlPixelFormat* pixel_format, const void* buffer, size_t size,
960  uint32_t index);
961 
1031  const JxlBoxType type,
1032  const uint8_t* contents,
1033  size_t size,
1034  JXL_BOOL compress_box);
1035 
1048 
1064 JXL_EXPORT void JxlEncoderCloseBoxes(JxlEncoder* enc);
1065 
1078 JXL_EXPORT void JxlEncoderCloseFrames(JxlEncoder* enc);
1079 
1094 JXL_EXPORT void JxlEncoderCloseInput(JxlEncoder* enc);
1095 
1109 JXL_EXPORT JxlEncoderStatus
1111 
1126  const uint8_t* icc_profile,
1127  size_t size);
1128 
1138 JXL_EXPORT void JxlEncoderInitBasicInfo(JxlBasicInfo* info);
1139 
1150 JXL_EXPORT void JxlEncoderInitFrameHeader(JxlFrameHeader* frame_header);
1151 
1159 JXL_EXPORT void JxlEncoderInitBlendInfo(JxlBlendInfo* blend_info);
1160 
1177  const JxlBasicInfo* info);
1178 
1196  const int64_t factor,
1197  const int64_t mode);
1198 
1210  JxlExtraChannelInfo* info);
1211 
1223  JxlEncoder* enc, size_t index, const JxlExtraChannelInfo* info);
1224 
1240  size_t index,
1241  const char* name,
1242  size_t size);
1243 
1259  JxlEncoderFrameSettings* frame_settings, JxlEncoderFrameSettingId option,
1260  int64_t value);
1261 
1277  JxlEncoderFrameSettings* frame_settings, JxlEncoderFrameSettingId option,
1278  float value);
1279 
1299  JXL_BOOL use_container);
1300 
1315 JXL_EXPORT JxlEncoderStatus
1317 
1353  int level);
1354 
1375 
1395  JxlEncoderFrameSettings* frame_settings, JXL_BOOL lossless);
1396 
1412  JxlEncoderFrameSettings* frame_settings, float distance);
1413 
1428  JxlEncoderFrameSettings* frame_settings, size_t index, float distance);
1429 
1466 JXL_EXPORT float JxlEncoderDistanceFromQuality(float quality);
1467 
1484  JxlEncoder* enc, const JxlEncoderFrameSettings* source);
1485 
1492 JXL_EXPORT void JxlColorEncodingSetToSRGB(JxlColorEncoding* color_encoding,
1493  JXL_BOOL is_gray);
1494 
1502  JxlColorEncoding* color_encoding, JXL_BOOL is_gray);
1503 
1513 
1530 typedef void (*JxlDebugImageCallback)(void* opaque, const char* label,
1531  size_t xsize, size_t ysize,
1532  const JxlColorEncoding* color,
1533  const uint16_t* pixels);
1534 
1548  JxlEncoderFrameSettings* frame_settings, JxlDebugImageCallback callback,
1549  void* opaque);
1550 
1562 JXL_EXPORT void JxlEncoderCollectStats(JxlEncoderFrameSettings* frame_settings,
1563  JxlEncoderStats* stats);
1564 
1565 #if defined(__cplusplus) || defined(c_plusplus)
1566 }
1567 #endif
1568 
1569 #endif /* JXL_ENCODE_H_ */
1570 
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,...
char JxlBoxType[4]
Definition: types.h:146
#define JXL_BOOL
Definition: types.h:30
JXL_EXPORT int JxlEncoderGetRequiredCodestreamLevel(const JxlEncoder *enc)
JXL_EXPORT JxlEncoderStatus JxlEncoderSetCodestreamLevel(JxlEncoder *enc, int level)
JXL_EXPORT JxlEncoderStatus JxlEncoderAddJPEGFrame(const JxlEncoderFrameSettings *frame_settings, const uint8_t *buffer, size_t size)
void(* JxlDebugImageCallback)(void *opaque, const char *label, size_t xsize, size_t ysize, const JxlColorEncoding *color, const uint16_t *pixels)
Definition: encode.h:1530
JXL_EXPORT void JxlEncoderInitBlendInfo(JxlBlendInfo *blend_info)
JXL_EXPORT void JxlEncoderCloseInput(JxlEncoder *enc)
JXL_EXPORT JxlEncoderStatus JxlEncoderSetParallelRunner(JxlEncoder *enc, JxlParallelRunner parallel_runner, void *parallel_runner_opaque)
JXL_EXPORT void JxlEncoderCollectStats(JxlEncoderFrameSettings *frame_settings, JxlEncoderStats *stats)
struct JxlEncoderStatsStruct JxlEncoderStats
Definition: stats.h:29
JXL_EXPORT JxlEncoderStatus JxlEncoderFrameSettingsSetOption(JxlEncoderFrameSettings *frame_settings, JxlEncoderFrameSettingId option, int64_t value)
struct JxlEncoderStruct JxlEncoder
Definition: encode.h:46
JXL_EXPORT JxlEncoderStatus JxlEncoderSetExtraChannelBuffer(const JxlEncoderFrameSettings *frame_settings, const JxlPixelFormat *pixel_format, const void *buffer, size_t size, uint32_t index)
JXL_EXPORT JxlEncoderStatus JxlEncoderProcessOutput(JxlEncoder *enc, uint8_t **next_out, size_t *avail_out)
JXL_EXPORT JxlEncoderStatus JxlEncoderUseContainer(JxlEncoder *enc, JXL_BOOL use_container)
JXL_EXPORT void JxlColorEncodingSetToSRGB(JxlColorEncoding *color_encoding, JXL_BOOL is_gray)
JXL_EXPORT void JxlEncoderSetCms(JxlEncoder *enc, JxlCmsInterface cms)
JXL_EXPORT JxlEncoderStatus JxlEncoderSetFrameBitDepth(JxlEncoderFrameSettings *frame_settings, const JxlBitDepth *bit_depth)
JXL_EXPORT void JxlEncoderInitFrameHeader(JxlFrameHeader *frame_header)
JXL_EXPORT float JxlEncoderDistanceFromQuality(float quality)
JXL_EXPORT void JxlEncoderReset(JxlEncoder *enc)
JXL_EXPORT JxlEncoderStatus JxlEncoderSetFrameLossless(JxlEncoderFrameSettings *frame_settings, JXL_BOOL lossless)
JXL_EXPORT JxlEncoderStatus JxlEncoderFrameSettingsSetFloatOption(JxlEncoderFrameSettings *frame_settings, JxlEncoderFrameSettingId option, float value)
JXL_EXPORT JxlEncoderFrameSettings * JxlEncoderFrameSettingsCreate(JxlEncoder *enc, const JxlEncoderFrameSettings *source)
JXL_EXPORT JxlEncoderStatus JxlEncoderUseBoxes(JxlEncoder *enc)
JXL_EXPORT JxlEncoderStatus JxlEncoderSetOutputProcessor(JxlEncoder *enc, struct JxlEncoderOutputProcessor output_processor)
JXL_EXPORT void JxlEncoderInitBasicInfo(JxlBasicInfo *info)
JXL_EXPORT JxlEncoderStatus JxlEncoderSetBasicInfo(JxlEncoder *enc, const JxlBasicInfo *info)
JXL_EXPORT JxlEncoderStatus JxlEncoderSetColorEncoding(JxlEncoder *enc, const JxlColorEncoding *color)
JXL_EXPORT JxlEncoderStatus JxlEncoderSetExtraChannelBlendInfo(JxlEncoderFrameSettings *frame_settings, size_t index, const JxlBlendInfo *blend_info)
JXL_EXPORT void JxlEncoderCloseBoxes(JxlEncoder *enc)
JXL_EXPORT JxlEncoderStatus JxlEncoderSetFrameDistance(JxlEncoderFrameSettings *frame_settings, float distance)
JxlEncoderStatus
Definition: encode.h:61
JXL_EXPORT void JxlEncoderAllowExpertOptions(JxlEncoder *enc)
JXL_EXPORT JxlEncoderStatus JxlEncoderSetFrameHeader(JxlEncoderFrameSettings *frame_settings, const JxlFrameHeader *frame_header)
JXL_EXPORT void JxlColorEncodingSetToLinearSRGB(JxlColorEncoding *color_encoding, JXL_BOOL is_gray)
JXL_EXPORT void JxlEncoderInitExtraChannelInfo(JxlExtraChannelType type, JxlExtraChannelInfo *info)
JXL_EXPORT JxlEncoderStatus JxlEncoderSetExtraChannelDistance(JxlEncoderFrameSettings *frame_settings, size_t index, float distance)
JXL_EXPORT void JxlEncoderCloseFrames(JxlEncoder *enc)
JXL_EXPORT JxlEncoderStatus JxlEncoderAddImageFrame(const JxlEncoderFrameSettings *frame_settings, const JxlPixelFormat *pixel_format, const void *buffer, size_t size)
JXL_EXPORT JxlEncoderStatus JxlEncoderSetICCProfile(JxlEncoder *enc, const uint8_t *icc_profile, size_t size)
JXL_EXPORT JxlEncoderStatus JxlEncoderSetFrameName(JxlEncoderFrameSettings *frame_settings, const char *frame_name)
JXL_EXPORT void JxlEncoderSetDebugImageCallback(JxlEncoderFrameSettings *frame_settings, JxlDebugImageCallback callback, void *opaque)
JXL_EXPORT uint32_t JxlEncoderVersion(void)
JXL_EXPORT JxlEncoder * JxlEncoderCreate(const JxlMemoryManager *memory_manager)
JXL_EXPORT JxlEncoderError JxlEncoderGetError(JxlEncoder *enc)
JXL_EXPORT JxlEncoderStatus JxlEncoderSetExtraChannelName(JxlEncoder *enc, size_t index, const char *name, size_t size)
struct JxlEncoderFrameSettingsStruct JxlEncoderFrameSettings
Definition: encode.h:56
JXL_EXPORT JxlEncoderStatus JxlEncoderAddBox(JxlEncoder *enc, const JxlBoxType type, const uint8_t *contents, size_t size, JXL_BOOL compress_box)
JXL_EXPORT JxlEncoderStatus JxlEncoderFlushInput(JxlEncoder *enc)
JxlEncoderError
Definition: encode.h:82
JxlEncoderFrameSettingId
Definition: encode.h:125
JXL_EXPORT JxlEncoderStatus JxlEncoderSetUpsamplingMode(JxlEncoder *enc, const int64_t factor, const int64_t mode)
JXL_EXPORT void JxlEncoderDestroy(JxlEncoder *enc)
JXL_EXPORT JxlEncoderStatus JxlEncoderSetExtraChannelInfo(JxlEncoder *enc, size_t index, const JxlExtraChannelInfo *info)
JXL_EXPORT JxlEncoderStatus JxlEncoderStoreJPEGMetadata(JxlEncoder *enc, JXL_BOOL store_jpeg_metadata)
JXL_EXPORT JxlEncoderStatus JxlEncoderAddChunkedFrame(const JxlEncoderFrameSettings *frame_settings, JXL_BOOL is_last_frame, struct JxlChunkedFrameInputSource chunked_frame_input)
Adds a frame to the encoder using a chunked input source.
@ JXL_ENC_ERROR
Definition: encode.h:69
@ JXL_ENC_NEED_MORE_OUTPUT
Definition: encode.h:73
@ JXL_ENC_SUCCESS
Definition: encode.h:65
@ JXL_ENC_ERR_NOT_SUPPORTED
Definition: encode.h:109
@ JXL_ENC_ERR_JBRD
Definition: encode.h:99
@ JXL_ENC_ERR_API_USAGE
Definition: encode.h:115
@ JXL_ENC_ERR_OOM
Definition: encode.h:94
@ JXL_ENC_ERR_OK
Definition: encode.h:85
@ JXL_ENC_ERR_GENERIC
Definition: encode.h:89
@ JXL_ENC_ERR_BAD_INPUT
Definition: encode.h:103
@ JXL_ENC_FRAME_SETTING_DECODING_SPEED
Definition: encode.h:137
@ JXL_ENC_FRAME_SETTING_JPEG_COMPRESS_BOXES
Definition: encode.h:340
@ JXL_ENC_FRAME_SETTING_MODULAR_GROUP_SIZE
Definition: encode.h:289
@ JXL_ENC_FRAME_SETTING_PROGRESSIVE_DC
Definition: encode.h:247
@ JXL_ENC_FRAME_SETTING_EXTRA_CHANNEL_RESAMPLING
Definition: encode.h:152
@ JXL_ENC_FRAME_SETTING_GROUP_ORDER_CENTER_X
Definition: encode.h:219
@ JXL_ENC_FRAME_SETTING_JPEG_KEEP_XMP
Definition: encode.h:372
@ JXL_ENC_FRAME_SETTING_NOISE
Definition: encode.h:176
@ JXL_ENC_FRAME_SETTING_ALREADY_DOWNSAMPLED
Definition: encode.h:163
@ JXL_ENC_FRAME_SETTING_RESPONSIVE
Definition: encode.h:229
@ JXL_ENC_FRAME_SETTING_JPEG_RECON_CFL
Definition: encode.h:315
@ JXL_ENC_FRAME_SETTING_PATCHES
Definition: encode.h:186
@ JXL_ENC_FRAME_SETTING_JPEG_KEEP_JUMBF
Definition: encode.h:379
@ JXL_ENC_FRAME_SETTING_GROUP_ORDER
Definition: encode.h:213
@ JXL_ENC_FRAME_SETTING_EPF
Definition: encode.h:191
@ JXL_ENC_FRAME_SETTING_CHANNEL_COLORS_GLOBAL_PERCENT
Definition: encode.h:253
@ JXL_ENC_FRAME_SETTING_RESAMPLING
Definition: encode.h:145
@ JXL_ENC_FRAME_SETTING_DOTS
Definition: encode.h:181
@ JXL_ENC_FRAME_SETTING_COLOR_TRANSFORM
Definition: encode.h:276
@ JXL_ENC_FRAME_SETTING_EFFORT
Definition: encode.h:131
@ JXL_ENC_FRAME_SETTING_MODULAR
Definition: encode.h:202
@ JXL_ENC_FRAME_SETTING_MODULAR_COLOR_SPACE
Definition: encode.h:285
@ JXL_ENC_FRAME_SETTING_KEEP_INVISIBLE
Definition: encode.h:207
@ JXL_ENC_FRAME_SETTING_PHOTON_NOISE
Definition: encode.h:170
@ JXL_ENC_FRAME_SETTING_BUFFERING
Definition: encode.h:355
@ JXL_ENC_FRAME_SETTING_BROTLI_EFFORT
Definition: encode.h:333
@ JXL_ENC_FRAME_SETTING_GROUP_ORDER_CENTER_Y
Definition: encode.h:224
@ JXL_ENC_FRAME_SETTING_GABORISH
Definition: encode.h:196
@ JXL_ENC_FRAME_SETTING_QPROGRESSIVE_AC
Definition: encode.h:241
@ JXL_ENC_FRAME_SETTING_MODULAR_NB_PREV_CHANNELS
Definition: encode.h:310
@ JXL_ENC_FRAME_SETTING_JPEG_KEEP_EXIF
Definition: encode.h:364
@ JXL_ENC_FRAME_SETTING_FILL_ENUM
Definition: encode.h:384
@ JXL_ENC_FRAME_SETTING_PROGRESSIVE_AC
Definition: encode.h:235
@ JXL_ENC_FRAME_SETTING_MODULAR_MA_TREE_LEARNING_PERCENT
Definition: encode.h:302
@ JXL_ENC_FRAME_SETTING_LOSSY_PALETTE
Definition: encode.h:269
@ JXL_ENC_FRAME_SETTING_MODULAR_PREDICTOR
Definition: encode.h:296
@ JXL_ENC_FRAME_SETTING_PALETTE_COLORS
Definition: encode.h:264
@ JXL_ENC_FRAME_SETTING_CHANNEL_COLORS_GROUP_PERCENT
Definition: encode.h:259
@ JXL_ENC_FRAME_INDEX_BOX
Definition: encode.h:326
JxlExtraChannelType
Definition: codestream_header.h:44
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
Abstraction functions used by JPEG XL to allocate memory.
API to collect various statistics from JXL encoder.
Definition: codestream_header.h:95
Definition: types.h:133
Definition: codestream_header.h:328
Definition: encode.h:803
void(* release_buffer)(void *opaque, const void *buf)
Definition: encode.h:907
void(* get_color_channels_pixel_format)(void *opaque, JxlPixelFormat *pixel_format)
Definition: encode.h:822
void(* get_extra_channel_pixel_format)(void *opaque, size_t ec_index, JxlPixelFormat *pixel_format)
Definition: encode.h:865
void * opaque
Definition: encode.h:808
Definition: cms_interface.h:224
Definition: color_encoding.h:116
Definition: encode.h:705
void * opaque
Definition: encode.h:711
void(* seek)(void *opaque, uint64_t position)
Definition: encode.h:753
void(* set_finalized_position)(void *opaque, uint64_t finalized_position)
Definition: encode.h:766
void(* release_buffer)(void *opaque, size_t written_bytes)
Definition: encode.h:741
Definition: codestream_header.h:263
Definition: codestream_header.h:389
Definition: memory_manager.h:51
Definition: types.h:79
Data types for the JPEG XL API, for both encoding and decoding.