LIBJXL_DOC
Loading...
Searching...
No Matches
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
12
13#ifndef JXL_ENCODE_H_
14#define JXL_ENCODE_H_
15
16#include <jxl/cms_interface.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/stats.h>
23#include <jxl/types.h>
24#include <jxl/version.h> // TODO(eustas): remove before v1.0
25#include <stddef.h>
26#include <stdint.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
39JXL_EXPORT uint32_t JxlEncoderVersion(void);
40
47typedef struct JxlEncoder JxlEncoder;
48
58
77
119
126typedef enum {
133
139
147
154
165
172
178
183
188
193
198
204
209
215
221
226
231
237
243
249
255
261
266
271
278
287
291
298
304
312
317
328
335
342
357
366
374
381
389
394
399
401
414JXL_EXPORT JxlEncoder* JxlEncoderCreate(const JxlMemoryManager* memory_manager);
415
423JXL_EXPORT void JxlEncoderReset(JxlEncoder* enc);
424
430JXL_EXPORT void JxlEncoderDestroy(JxlEncoder* enc);
431
441JXL_EXPORT void JxlEncoderSetCms(JxlEncoder* enc, JxlCmsInterface cms);
442
455JXL_EXPORT JxlEncoderStatus
457 void* parallel_runner_opaque);
458
467
499 uint8_t** next_out,
500 size_t* avail_out);
501
536JXL_EXPORT JxlEncoderStatus
538 const JxlFrameHeader* frame_header);
539
552 JxlEncoderFrameSettings* frame_settings, size_t index,
553 const JxlBlendInfo* blend_info);
554
576 JxlEncoderFrameSettings* frame_settings, const char* frame_name);
577
594 JxlEncoderFrameSettings* frame_settings, const JxlBitDepth* bit_depth);
595
626JXL_EXPORT JxlEncoderStatus
628 const uint8_t* buffer, size_t size);
629
699 const JxlEncoderFrameSettings* frame_settings,
700 const JxlPixelFormat* pixel_format, const void* buffer, size_t size);
701
737 void* opaque;
738
756 void* (*get_buffer)(void* opaque, size_t* size);
757
767 void (*release_buffer)(void* opaque, size_t written_bytes);
768
779 void (*seek)(void* opaque, uint64_t position);
780
792 void (*set_finalized_position)(void* opaque, uint64_t finalized_position);
793};
794
808 JxlEncoder* enc, struct JxlEncoderOutputProcessor output_processor);
809
824
834 void* opaque;
835
849 JxlPixelFormat* pixel_format);
850
874 const void* (*get_color_channel_data_at)(void* opaque, size_t xpos,
875 size_t ypos, size_t xsize,
876 size_t ysize, size_t* row_offset);
877
891 void (*get_extra_channel_pixel_format)(void* opaque, size_t ec_index,
892 JxlPixelFormat* pixel_format);
893
918 const void* (*get_extra_channel_data_at)(void* opaque, size_t ec_index,
919 size_t xpos, size_t ypos,
920 size_t xsize, size_t ysize,
921 size_t* row_offset);
922
933 void (*release_buffer)(void* opaque, const void* buf);
934};
935
957 const JxlEncoderFrameSettings* frame_settings, JXL_BOOL is_last_frame,
958 struct JxlChunkedFrameInputSource chunked_frame_input);
959
984 const JxlEncoderFrameSettings* frame_settings,
985 const JxlPixelFormat* pixel_format, const void* buffer, size_t size,
986 uint32_t index);
987
1058 const JxlBoxType type,
1059 const uint8_t* contents,
1060 size_t size,
1061 JXL_BOOL compress_box);
1062
1075
1091JXL_EXPORT void JxlEncoderCloseBoxes(JxlEncoder* enc);
1092
1105JXL_EXPORT void JxlEncoderCloseFrames(JxlEncoder* enc);
1106
1121JXL_EXPORT void JxlEncoderCloseInput(JxlEncoder* enc);
1122
1136JXL_EXPORT JxlEncoderStatus
1138
1153 const uint8_t* icc_profile,
1154 size_t size);
1155
1166
1177JXL_EXPORT void JxlEncoderInitFrameHeader(JxlFrameHeader* frame_header);
1178
1186JXL_EXPORT void JxlEncoderInitBlendInfo(JxlBlendInfo* blend_info);
1187
1204 const JxlBasicInfo* info);
1205
1223 int64_t factor,
1224 int64_t mode);
1225
1237 JxlExtraChannelInfo* info);
1238
1250 JxlEncoder* enc, size_t index, const JxlExtraChannelInfo* info);
1251
1268 size_t index,
1269 const char* name,
1270 size_t size);
1271
1288 JxlEncoderFrameSettings* frame_settings, JxlEncoderFrameSettingId option,
1289 int64_t value);
1290
1307 JxlEncoderFrameSettings* frame_settings, JxlEncoderFrameSettingId option,
1308 float value);
1309
1329 JXL_BOOL use_container);
1330
1345JXL_EXPORT JxlEncoderStatus
1347
1383 int level);
1384
1406
1426 JxlEncoderFrameSettings* frame_settings, JXL_BOOL lossless);
1427
1443 JxlEncoderFrameSettings* frame_settings, float distance);
1444
1460 JxlEncoderFrameSettings* frame_settings, size_t index, float distance);
1461
1497JXL_EXPORT float JxlEncoderDistanceFromQuality(float quality);
1498
1517 JxlEncoder* enc, const JxlEncoderFrameSettings* source);
1518
1525JXL_EXPORT void JxlColorEncodingSetToSRGB(JxlColorEncoding* color_encoding,
1526 JXL_BOOL is_gray);
1527
1535 JxlColorEncoding* color_encoding, JXL_BOOL is_gray);
1536
1546
1563typedef void (*JxlDebugImageCallback)(void* opaque, const char* label,
1564 size_t xsize, size_t ysize,
1565 const JxlColorEncoding* color,
1566 const uint16_t* pixels);
1567
1581 JxlEncoderFrameSettings* frame_settings, JxlDebugImageCallback callback,
1582 void* opaque);
1583
1595JXL_EXPORT void JxlEncoderCollectStats(JxlEncoderFrameSettings* frame_settings,
1596 JxlEncoderStats* stats);
1597
1598#ifdef __cplusplus
1599}
1600#endif
1601
1602#endif /* JXL_ENCODE_H_ */
1603
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...
struct JxlMemoryManagerStruct JxlMemoryManager
char JxlBoxType[4]
Definition types.h:146
#define JXL_BOOL
Definition types.h:29
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:1563
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)
JXL_EXPORT JxlEncoderStatus JxlEncoderFrameSettingsSetOption(JxlEncoderFrameSettings *frame_settings, JxlEncoderFrameSettingId option, int64_t value)
JXL_EXPORT JxlEncoder * JxlEncoderCreate(const JxlMemoryManager *memory_manager)
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)
struct JxlEncoderFrameSettings JxlEncoderFrameSettings
Definition encode.h:57
JXL_EXPORT JxlEncoderStatus JxlEncoderFrameSettingsSetFloatOption(JxlEncoderFrameSettings *frame_settings, JxlEncoderFrameSettingId option, float value)
JXL_EXPORT JxlEncoderStatus JxlEncoderUseBoxes(JxlEncoder *enc)
JXL_EXPORT JxlEncoderStatus JxlEncoderSetOutputProcessor(JxlEncoder *enc, struct JxlEncoderOutputProcessor output_processor)
JXL_EXPORT void JxlEncoderInitBasicInfo(JxlBasicInfo *info)
struct JxlEncoderStats JxlEncoderStats
Definition stats.h:29
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:62
JXL_EXPORT JxlEncoderStatus JxlEncoderSetUpsamplingMode(JxlEncoder *enc, int64_t factor, int64_t mode)
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 JxlEncoderFrameSettings * JxlEncoderFrameSettingsCreate(JxlEncoder *enc, const JxlEncoderFrameSettings *source)
struct JxlEncoder JxlEncoder
Definition encode.h:47
JXL_EXPORT JxlEncoderError JxlEncoderGetError(JxlEncoder *enc)
JXL_EXPORT JxlEncoderStatus JxlEncoderSetExtraChannelName(JxlEncoder *enc, size_t index, const char *name, size_t size)
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:83
JxlEncoderFrameSettingId
Definition encode.h:126
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:70
@ JXL_ENC_NEED_MORE_OUTPUT
Definition encode.h:74
@ JXL_ENC_SUCCESS
Definition encode.h:66
@ JXL_ENC_ERR_NOT_SUPPORTED
Definition encode.h:110
@ JXL_ENC_ERR_JBRD
Definition encode.h:100
@ JXL_ENC_ERR_API_USAGE
Definition encode.h:116
@ JXL_ENC_ERR_OOM
Definition encode.h:95
@ JXL_ENC_ERR_OK
Definition encode.h:86
@ JXL_ENC_ERR_GENERIC
Definition encode.h:90
@ JXL_ENC_ERR_BAD_INPUT
Definition encode.h:104
@ JXL_ENC_FRAME_SETTING_DECODING_SPEED
Definition encode.h:138
@ JXL_ENC_FRAME_SETTING_JPEG_COMPRESS_BOXES
Definition encode.h:341
@ JXL_ENC_FRAME_SETTING_MODULAR_GROUP_SIZE
Definition encode.h:290
@ JXL_ENC_FRAME_SETTING_PROGRESSIVE_DC
Definition encode.h:248
@ JXL_ENC_FRAME_SETTING_DISABLE_PERCEPTUAL_HEURISTICS
Definition encode.h:393
@ JXL_ENC_FRAME_SETTING_EXTRA_CHANNEL_RESAMPLING
Definition encode.h:153
@ JXL_ENC_FRAME_SETTING_GROUP_ORDER_CENTER_X
Definition encode.h:220
@ JXL_ENC_FRAME_SETTING_USE_FULL_IMAGE_HEURISTICS
Definition encode.h:388
@ JXL_ENC_FRAME_SETTING_JPEG_KEEP_XMP
Definition encode.h:373
@ JXL_ENC_FRAME_SETTING_NOISE
Definition encode.h:177
@ JXL_ENC_FRAME_SETTING_ALREADY_DOWNSAMPLED
Definition encode.h:164
@ JXL_ENC_FRAME_SETTING_RESPONSIVE
Definition encode.h:230
@ JXL_ENC_FRAME_SETTING_JPEG_RECON_CFL
Definition encode.h:316
@ JXL_ENC_FRAME_SETTING_PATCHES
Definition encode.h:187
@ JXL_ENC_FRAME_SETTING_JPEG_KEEP_JUMBF
Definition encode.h:380
@ JXL_ENC_FRAME_SETTING_GROUP_ORDER
Definition encode.h:214
@ JXL_ENC_FRAME_SETTING_EPF
Definition encode.h:192
@ JXL_ENC_FRAME_SETTING_CHANNEL_COLORS_GLOBAL_PERCENT
Definition encode.h:254
@ JXL_ENC_FRAME_SETTING_RESAMPLING
Definition encode.h:146
@ JXL_ENC_FRAME_SETTING_DOTS
Definition encode.h:182
@ JXL_ENC_FRAME_SETTING_COLOR_TRANSFORM
Definition encode.h:277
@ JXL_ENC_FRAME_SETTING_EFFORT
Definition encode.h:132
@ JXL_ENC_FRAME_SETTING_MODULAR
Definition encode.h:203
@ JXL_ENC_FRAME_SETTING_MODULAR_COLOR_SPACE
Definition encode.h:286
@ JXL_ENC_FRAME_SETTING_KEEP_INVISIBLE
Definition encode.h:208
@ JXL_ENC_FRAME_SETTING_PHOTON_NOISE
Definition encode.h:171
@ JXL_ENC_FRAME_SETTING_BUFFERING
Definition encode.h:356
@ JXL_ENC_FRAME_SETTING_BROTLI_EFFORT
Definition encode.h:334
@ JXL_ENC_FRAME_SETTING_GROUP_ORDER_CENTER_Y
Definition encode.h:225
@ JXL_ENC_FRAME_SETTING_GABORISH
Definition encode.h:197
@ JXL_ENC_FRAME_SETTING_QPROGRESSIVE_AC
Definition encode.h:242
@ JXL_ENC_FRAME_SETTING_MODULAR_NB_PREV_CHANNELS
Definition encode.h:311
@ JXL_ENC_FRAME_SETTING_JPEG_KEEP_EXIF
Definition encode.h:365
@ JXL_ENC_FRAME_SETTING_FILL_ENUM
Definition encode.h:398
@ JXL_ENC_FRAME_SETTING_PROGRESSIVE_AC
Definition encode.h:236
@ JXL_ENC_FRAME_SETTING_MODULAR_MA_TREE_LEARNING_PERCENT
Definition encode.h:303
@ JXL_ENC_FRAME_SETTING_LOSSY_PALETTE
Definition encode.h:270
@ JXL_ENC_FRAME_SETTING_MODULAR_PREDICTOR
Definition encode.h:297
@ JXL_ENC_FRAME_SETTING_PALETTE_COLORS
Definition encode.h:265
@ JXL_ENC_FRAME_SETTING_CHANNEL_COLORS_GROUP_PERCENT
Definition encode.h:260
@ JXL_ENC_FRAME_INDEX_BOX
Definition encode.h:327
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:127
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:330
Definition encode.h:829
void(* release_buffer)(void *opaque, const void *buf)
Definition encode.h:933
void(* get_color_channels_pixel_format)(void *opaque, JxlPixelFormat *pixel_format)
Definition encode.h:848
void(* get_extra_channel_pixel_format)(void *opaque, size_t ec_index, JxlPixelFormat *pixel_format)
Definition encode.h:891
void * opaque
Definition encode.h:834
Definition cms_interface.h:227
Definition color_encoding.h:114
Definition encode.h:731
void * opaque
Definition encode.h:737
void(* seek)(void *opaque, uint64_t position)
Definition encode.h:779
void(* set_finalized_position)(void *opaque, uint64_t finalized_position)
Definition encode.h:792
void(* release_buffer)(void *opaque, size_t written_bytes)
Definition encode.h:767
Definition codestream_header.h:265
Definition codestream_header.h:391
Definition types.h:80
Data types for the JPEG XL API, for both encoding and decoding.