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 
24 #if defined(__cplusplus) || defined(c_plusplus)
25 extern "C" {
26 #endif
27 
35 JXL_EXPORT uint32_t JxlEncoderVersion(void);
36 
43 typedef struct JxlEncoderStruct JxlEncoder;
44 
53 typedef struct JxlEncoderFrameSettingsStruct JxlEncoderFrameSettings;
54 
58 typedef enum {
63 
67 
71 
73 
79 typedef enum {
83 
87 
92 
97 
101 
107 
113 
115 
122 typedef enum {
129 
135 
143 
150 
161 
168 
174 
179 
184 
189 
194 
200 
205 
211 
217 
222 
227 
233 
239 
245 
251 
257 
262 
267 
274 
283 
287 
294 
300 
308 
313 
324 
331 
338 
351 
360 
368 
375 
380 
382 
395 JXL_EXPORT JxlEncoder* JxlEncoderCreate(const JxlMemoryManager* memory_manager);
396 
404 JXL_EXPORT void JxlEncoderReset(JxlEncoder* enc);
405 
411 JXL_EXPORT void JxlEncoderDestroy(JxlEncoder* enc);
412 
422 JXL_EXPORT void JxlEncoderSetCms(JxlEncoder* enc, JxlCmsInterface cms);
423 
436 JXL_EXPORT JxlEncoderStatus
438  void* parallel_runner_opaque);
439 
448 
480  uint8_t** next_out,
481  size_t* avail_out);
482 
516 JXL_EXPORT JxlEncoderStatus
518  const JxlFrameHeader* frame_header);
519 
532  JxlEncoderFrameSettings* frame_settings, size_t index,
533  const JxlBlendInfo* blend_info);
534 
555  JxlEncoderFrameSettings* frame_settings, const char* frame_name);
556 
571  JxlEncoderFrameSettings* frame_settings, const JxlBitDepth* bit_depth);
572 
599 JXL_EXPORT JxlEncoderStatus
601  const uint8_t* buffer, size_t size);
602 
668  const JxlEncoderFrameSettings* frame_settings,
669  const JxlPixelFormat* pixel_format, const void* buffer, size_t size);
670 
706  void* opaque;
707 
725  void* (*get_buffer)(void* opaque, size_t* size);
726 
736  void (*release_buffer)(void* opaque, size_t written_bytes);
737 
748  void (*seek)(void* opaque, uint64_t position);
749 
761  void (*set_finalized_position)(void* opaque, uint64_t finalized_position);
762 };
763 
777  JxlEncoder* enc, struct JxlEncoderOutputProcessor output_processor);
778 
793 
818  const JxlEncoderFrameSettings* frame_settings,
819  const JxlPixelFormat* pixel_format, const void* buffer, size_t size,
820  uint32_t index);
821 
891  const JxlBoxType type,
892  const uint8_t* contents,
893  size_t size,
894  JXL_BOOL compress_box);
895 
908 
924 JXL_EXPORT void JxlEncoderCloseBoxes(JxlEncoder* enc);
925 
938 JXL_EXPORT void JxlEncoderCloseFrames(JxlEncoder* enc);
939 
954 JXL_EXPORT void JxlEncoderCloseInput(JxlEncoder* enc);
955 
969 JXL_EXPORT JxlEncoderStatus
971 
986  const uint8_t* icc_profile,
987  size_t size);
988 
998 JXL_EXPORT void JxlEncoderInitBasicInfo(JxlBasicInfo* info);
999 
1010 JXL_EXPORT void JxlEncoderInitFrameHeader(JxlFrameHeader* frame_header);
1011 
1019 JXL_EXPORT void JxlEncoderInitBlendInfo(JxlBlendInfo* blend_info);
1020 
1037  const JxlBasicInfo* info);
1038 
1056  const int64_t factor,
1057  const int64_t mode);
1058 
1070  JxlExtraChannelInfo* info);
1071 
1083  JxlEncoder* enc, size_t index, const JxlExtraChannelInfo* info);
1084 
1100  size_t index,
1101  const char* name,
1102  size_t size);
1103 
1119  JxlEncoderFrameSettings* frame_settings, JxlEncoderFrameSettingId option,
1120  int64_t value);
1121 
1137  JxlEncoderFrameSettings* frame_settings, JxlEncoderFrameSettingId option,
1138  float value);
1139 
1159  JXL_BOOL use_container);
1160 
1175 JXL_EXPORT JxlEncoderStatus
1177 
1213  int level);
1214 
1235 
1255  JxlEncoderFrameSettings* frame_settings, JXL_BOOL lossless);
1256 
1272  JxlEncoderFrameSettings* frame_settings, float distance);
1273 
1288  JxlEncoderFrameSettings* frame_settings, size_t index, float distance);
1289 
1306  JxlEncoder* enc, const JxlEncoderFrameSettings* source);
1307 
1314 JXL_EXPORT void JxlColorEncodingSetToSRGB(JxlColorEncoding* color_encoding,
1315  JXL_BOOL is_gray);
1316 
1324  JxlColorEncoding* color_encoding, JXL_BOOL is_gray);
1325 
1335 
1352 typedef void (*JxlDebugImageCallback)(void* opaque, const char* label,
1353  size_t xsize, size_t ysize,
1354  const JxlColorEncoding* color,
1355  const uint16_t* pixels);
1356 
1370  JxlEncoderFrameSettings* frame_settings, JxlDebugImageCallback callback,
1371  void* opaque);
1372 
1384 JXL_EXPORT void JxlEncoderCollectStats(JxlEncoderFrameSettings* frame_settings,
1385  JxlEncoderStats* stats);
1386 
1387 #if defined(__cplusplus) || defined(c_plusplus)
1388 }
1389 #endif
1390 
1391 #endif /* JXL_ENCODE_H_ */
1392 
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:144
#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:1352
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:43
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 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:58
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:53
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:79
JxlEncoderFrameSettingId
Definition: encode.h:122
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_ENC_ERROR
Definition: encode.h:66
@ JXL_ENC_NEED_MORE_OUTPUT
Definition: encode.h:70
@ JXL_ENC_SUCCESS
Definition: encode.h:62
@ JXL_ENC_ERR_NOT_SUPPORTED
Definition: encode.h:106
@ JXL_ENC_ERR_JBRD
Definition: encode.h:96
@ JXL_ENC_ERR_API_USAGE
Definition: encode.h:112
@ JXL_ENC_ERR_OOM
Definition: encode.h:91
@ JXL_ENC_ERR_OK
Definition: encode.h:82
@ JXL_ENC_ERR_GENERIC
Definition: encode.h:86
@ JXL_ENC_ERR_BAD_INPUT
Definition: encode.h:100
@ JXL_ENC_FRAME_SETTING_DECODING_SPEED
Definition: encode.h:134
@ JXL_ENC_FRAME_SETTING_JPEG_COMPRESS_BOXES
Definition: encode.h:337
@ JXL_ENC_FRAME_SETTING_MODULAR_GROUP_SIZE
Definition: encode.h:286
@ JXL_ENC_FRAME_SETTING_PROGRESSIVE_DC
Definition: encode.h:244
@ JXL_ENC_FRAME_SETTING_EXTRA_CHANNEL_RESAMPLING
Definition: encode.h:149
@ JXL_ENC_FRAME_SETTING_GROUP_ORDER_CENTER_X
Definition: encode.h:216
@ JXL_ENC_FRAME_SETTING_JPEG_KEEP_XMP
Definition: encode.h:367
@ JXL_ENC_FRAME_SETTING_NOISE
Definition: encode.h:173
@ JXL_ENC_FRAME_SETTING_ALREADY_DOWNSAMPLED
Definition: encode.h:160
@ JXL_ENC_FRAME_SETTING_RESPONSIVE
Definition: encode.h:226
@ JXL_ENC_FRAME_SETTING_JPEG_RECON_CFL
Definition: encode.h:312
@ JXL_ENC_FRAME_SETTING_PATCHES
Definition: encode.h:183
@ JXL_ENC_FRAME_SETTING_JPEG_KEEP_JUMBF
Definition: encode.h:374
@ JXL_ENC_FRAME_SETTING_GROUP_ORDER
Definition: encode.h:210
@ JXL_ENC_FRAME_SETTING_EPF
Definition: encode.h:188
@ JXL_ENC_FRAME_SETTING_CHANNEL_COLORS_GLOBAL_PERCENT
Definition: encode.h:250
@ JXL_ENC_FRAME_SETTING_RESAMPLING
Definition: encode.h:142
@ JXL_ENC_FRAME_SETTING_DOTS
Definition: encode.h:178
@ JXL_ENC_FRAME_SETTING_COLOR_TRANSFORM
Definition: encode.h:273
@ JXL_ENC_FRAME_SETTING_EFFORT
Definition: encode.h:128
@ JXL_ENC_FRAME_SETTING_MODULAR
Definition: encode.h:199
@ JXL_ENC_FRAME_SETTING_MODULAR_COLOR_SPACE
Definition: encode.h:282
@ JXL_ENC_FRAME_SETTING_KEEP_INVISIBLE
Definition: encode.h:204
@ JXL_ENC_FRAME_SETTING_PHOTON_NOISE
Definition: encode.h:167
@ JXL_ENC_FRAME_SETTING_BUFFERING
Definition: encode.h:350
@ JXL_ENC_FRAME_SETTING_BROTLI_EFFORT
Definition: encode.h:330
@ JXL_ENC_FRAME_SETTING_GROUP_ORDER_CENTER_Y
Definition: encode.h:221
@ JXL_ENC_FRAME_SETTING_GABORISH
Definition: encode.h:193
@ JXL_ENC_FRAME_SETTING_QPROGRESSIVE_AC
Definition: encode.h:238
@ JXL_ENC_FRAME_SETTING_MODULAR_NB_PREV_CHANNELS
Definition: encode.h:307
@ JXL_ENC_FRAME_SETTING_JPEG_KEEP_EXIF
Definition: encode.h:359
@ JXL_ENC_FRAME_SETTING_FILL_ENUM
Definition: encode.h:379
@ JXL_ENC_FRAME_SETTING_PROGRESSIVE_AC
Definition: encode.h:232
@ JXL_ENC_FRAME_SETTING_MODULAR_MA_TREE_LEARNING_PERCENT
Definition: encode.h:299
@ JXL_ENC_FRAME_SETTING_LOSSY_PALETTE
Definition: encode.h:266
@ JXL_ENC_FRAME_SETTING_MODULAR_PREDICTOR
Definition: encode.h:293
@ JXL_ENC_FRAME_SETTING_PALETTE_COLORS
Definition: encode.h:261
@ JXL_ENC_FRAME_SETTING_CHANNEL_COLORS_GROUP_PERCENT
Definition: encode.h:256
@ JXL_ENC_FRAME_INDEX_BOX
Definition: encode.h:323
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:131
Definition: codestream_header.h:328
Definition: cms_interface.h:224
Definition: color_encoding.h:116
Definition: encode.h:700
void * opaque
Definition: encode.h:706
void(* seek)(void *opaque, uint64_t position)
Definition: encode.h:748
void(* set_finalized_position)(void *opaque, uint64_t finalized_position)
Definition: encode.h:761
void(* release_buffer)(void *opaque, size_t written_bytes)
Definition: encode.h:736
Definition: codestream_header.h:263
Definition: codestream_header.h:389
Definition: memory_manager.h:51
Definition: types.h:77