@revizly/sharp-libvips-dev 1.0.53 → 1.0.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,255 @@
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
+
7
+ /** @addtogroup libjxl_color
8
+ * @{
9
+ * @file cms_interface.h
10
+ * @brief Interface to allow the injection of different color management systems
11
+ * (CMSes, also called color management modules, or CMMs) in JPEG XL.
12
+ *
13
+ * A CMS is needed by the JPEG XL encoder and decoder to perform colorspace
14
+ * conversions. This defines an interface that can be implemented for different
15
+ * CMSes and then passed to the library.
16
+ */
17
+
18
+ #ifndef JXL_CMS_INTERFACE_H_
19
+ #define JXL_CMS_INTERFACE_H_
20
+
21
+ #include <jxl/color_encoding.h>
22
+ #include <jxl/types.h>
23
+ #include <stddef.h>
24
+ #include <stdint.h>
25
+
26
+ #ifdef __cplusplus
27
+ extern "C" {
28
+ #endif
29
+
30
+ /** Parses an ICC profile and populates @p c and @p cmyk with the data.
31
+ *
32
+ * @param user_data @ref JxlCmsInterface::set_fields_data passed as-is.
33
+ * @param icc_data the ICC data to parse.
34
+ * @param icc_size how many bytes of icc_data are valid.
35
+ * @param c a @ref JxlColorEncoding to populate if applicable.
36
+ * @param cmyk a boolean to set to whether the colorspace is a CMYK colorspace.
37
+ * @return Whether the relevant fields in @p c were successfully populated.
38
+ */
39
+ typedef JXL_BOOL (*jpegxl_cms_set_fields_from_icc_func)(void* user_data,
40
+ const uint8_t* icc_data,
41
+ size_t icc_size,
42
+ JxlColorEncoding* c,
43
+ JXL_BOOL* cmyk);
44
+
45
+ /** Represents an input or output colorspace to a color transform, as a
46
+ * serialized ICC profile. */
47
+ typedef struct {
48
+ /** The serialized ICC profile. This is guaranteed to be present and valid. */
49
+ struct {
50
+ const uint8_t* data;
51
+ size_t size;
52
+ } icc;
53
+
54
+ /** Structured representation of the colorspace, if applicable. If all fields
55
+ * are different from their "unknown" value, then this is equivalent to the
56
+ * ICC representation of the colorspace. If some are "unknown", those that are
57
+ * not are still valid and can still be used on their own if they are useful.
58
+ */
59
+ JxlColorEncoding color_encoding;
60
+
61
+ /** Number of components per pixel. This can be deduced from the other
62
+ * representations of the colorspace but is provided for convenience and
63
+ * validation. */
64
+ size_t num_channels;
65
+ } JxlColorProfile;
66
+
67
+ /** Allocates and returns the data needed for @p num_threads parallel transforms
68
+ * from the @p input colorspace to @p output, with up to @p pixels_per_thread
69
+ * pixels to transform per call to @ref JxlCmsInterface::run. @p init_data comes
70
+ * directly from the @ref JxlCmsInterface instance. Since @c run only receives
71
+ * the data returned by @c init, a reference to @p init_data should be kept
72
+ * there if access to it is desired in @c run. Likewise for @ref
73
+ * JxlCmsInterface::destroy.
74
+ *
75
+ * The ICC data in @p input and @p output is guaranteed to outlive the @c init /
76
+ * @c run / @c destroy cycle.
77
+ *
78
+ * @param init_data @ref JxlCmsInterface::init_data passed as-is.
79
+ * @param num_threads the maximum number of threads from which
80
+ * @ref JxlCmsInterface::run will be called.
81
+ * @param pixels_per_thread the maximum number of pixels that each call to
82
+ * @ref JxlCmsInterface::run will have to transform.
83
+ * @param input_profile the input colorspace for the transform.
84
+ * @param output_profile the colorspace to which @ref JxlCmsInterface::run
85
+ * should convert the input data.
86
+ * @param intensity_target for colorspaces where luminance is relative
87
+ * (essentially: not PQ), indicates the luminance at which (1, 1, 1) will
88
+ * be displayed. This is useful for conversions between PQ and a relative
89
+ * luminance colorspace, in either direction: @p intensity_target cd/m²
90
+ * in PQ should map to and from (1, 1, 1) in the relative one.\n
91
+ * It is also used for conversions to and from HLG, as it is
92
+ * scene-referred while other colorspaces are assumed to be
93
+ * display-referred. That is, conversions from HLG should apply the OOTF
94
+ * for a peak display luminance of @p intensity_target, and conversions
95
+ * to HLG should undo it. The OOTF is a gamma function applied to the
96
+ * luminance channel (https://www.itu.int/rec/R-REC-BT.2100-2-201807-I
97
+ * page 7), with the gamma value computed as
98
+ * <tt>1.2 * 1.111^log2(intensity_target / 1000)</tt> (footnote 2 page 8
99
+ * of the same document).
100
+ * @return The data needed for the transform, or @c NULL in case of failure.
101
+ * This will be passed to the other functions as @c user_data.
102
+ */
103
+ typedef void* (*jpegxl_cms_init_func)(void* init_data, size_t num_threads,
104
+ size_t pixels_per_thread,
105
+ const JxlColorProfile* input_profile,
106
+ const JxlColorProfile* output_profile,
107
+ float intensity_target);
108
+
109
+ /** Returns a buffer that can be used by callers of the interface to store the
110
+ * input of the conversion or read its result, if they pass it as the input or
111
+ * output of the @c run function.
112
+ * @param user_data the data returned by @c init.
113
+ * @param thread the index of the thread for which to return a buffer.
114
+ * @return A buffer that can be used by the caller for passing to @c run.
115
+ */
116
+ typedef float* (*jpegxl_cms_get_buffer_func)(void* user_data, size_t thread);
117
+
118
+ /** Executes one transform and returns true on success or false on error. It
119
+ * must be possible to call this from different threads with different values
120
+ * for @p thread, all between 0 (inclusive) and the value of @p num_threads
121
+ * passed to @c init (exclusive). It is allowed to implement this by locking
122
+ * such that the transforms are essentially performed sequentially, if such a
123
+ * performance profile is acceptable. @p user_data is the data returned by
124
+ * @c init.
125
+ * The buffers each contain @p num_pixels × @c num_channels interleaved floating
126
+ * point (0..1) samples where @c num_channels is the number of color channels of
127
+ * their respective color profiles. It is guaranteed that the only case in which
128
+ * they might overlap is if the output has fewer channels than the input, in
129
+ * which case the pointers may be identical.
130
+ * For CMYK data, 0 represents the maximum amount of ink while 1 represents no
131
+ * ink.
132
+ * @param user_data the data returned by @c init.
133
+ * @param thread the index of the thread from which the function is being
134
+ * called.
135
+ * @param input_buffer the buffer containing the pixel data to be transformed.
136
+ * @param output_buffer the buffer receiving the transformed pixel data.
137
+ * @param num_pixels the number of pixels to transform from @p input to
138
+ * @p output.
139
+ * @return ::JXL_TRUE on success, ::JXL_FALSE on failure.
140
+ */
141
+ typedef JXL_BOOL (*jpegxl_cms_run_func)(void* user_data, size_t thread,
142
+ const float* input_buffer,
143
+ float* output_buffer,
144
+ size_t num_pixels);
145
+
146
+ /** Performs the necessary clean-up and frees the memory allocated for user
147
+ * data.
148
+ */
149
+ typedef void (*jpegxl_cms_destroy_func)(void*);
150
+
151
+ /**
152
+ * Interface for performing colorspace transforms. The @c init function can be
153
+ * called several times to instantiate several transforms, including before
154
+ * other transforms have been destroyed.
155
+ *
156
+ * The call sequence for a given colorspace transform could look like the
157
+ * following:
158
+ * @dot
159
+ * digraph calls {
160
+ * newrank = true
161
+ * node [shape = box, fontname = monospace]
162
+ * init [label = "user_data <- init(\l\
163
+ * init_data = data,\l\
164
+ * num_threads = 3,\l\
165
+ * pixels_per_thread = 20,\l\
166
+ * input = (sRGB, 3 channels),\l\
167
+ * output = (Display-P3, 3 channels),\l\
168
+ * intensity_target = 255\l\
169
+ * )\l"]
170
+ * subgraph cluster_0 {
171
+ * color = lightgrey
172
+ * label = "thread 1"
173
+ * labeljust = "c"
174
+ * run_1_1 [label = "run(\l\
175
+ * user_data,\l\
176
+ * thread = 1,\l\
177
+ * input = in[0],\l\
178
+ * output = out[0],\l\
179
+ * num_pixels = 20\l\
180
+ * )\l"]
181
+ * run_1_2 [label = "run(\l\
182
+ * user_data,\l\
183
+ * thread = 1,\l\
184
+ * input = in[3],\l\
185
+ * output = out[3],\l\
186
+ * num_pixels = 20\l\
187
+ * )\l"]
188
+ * }
189
+ * subgraph cluster_1 {
190
+ * color = lightgrey
191
+ * label = "thread 2"
192
+ * labeljust = "l"
193
+ * run_2_1 [label = "run(\l\
194
+ * user_data,\l\
195
+ * thread = 2,\l\
196
+ * input = in[1],\l\
197
+ * output = out[1],\l\
198
+ * num_pixels = 20\l\
199
+ * )\l"]
200
+ * run_2_2 [label = "run(\l\
201
+ * user_data,\l\
202
+ * thread = 2,\l\
203
+ * input = in[4],\l\
204
+ * output = out[4],\l\
205
+ * num_pixels = 13\l\
206
+ * )\l"]
207
+ * }
208
+ * subgraph cluster_3 {
209
+ * color = lightgrey
210
+ * label = "thread 3"
211
+ * labeljust = "c"
212
+ * run_3_1 [label = "run(\l\
213
+ * user_data,\l\
214
+ * thread = 3,\l\
215
+ * input = in[2],\l\
216
+ * output = out[2],\l\
217
+ * num_pixels = 20\l\
218
+ * )\l"]
219
+ * }
220
+ * init -> {run_1_1; run_2_1; run_3_1; rank = same}
221
+ * run_1_1 -> run_1_2
222
+ * run_2_1 -> run_2_2
223
+ * {run_1_2; run_2_2, run_3_1} -> "destroy(user_data)"
224
+ * }
225
+ * @enddot
226
+ */
227
+ typedef struct {
228
+ /** CMS-specific data that will be passed to @ref set_fields_from_icc. */
229
+ void* set_fields_data;
230
+ /** Populates a @ref JxlColorEncoding from an ICC profile. */
231
+ jpegxl_cms_set_fields_from_icc_func set_fields_from_icc;
232
+
233
+ /** CMS-specific data that will be passed to @ref init. */
234
+ void* init_data;
235
+ /** Prepares a colorspace transform as described in the documentation of @ref
236
+ * jpegxl_cms_init_func. */
237
+ jpegxl_cms_init_func init;
238
+ /** Returns a buffer that can be used as input to @c run. */
239
+ jpegxl_cms_get_buffer_func get_src_buf;
240
+ /** Returns a buffer that can be used as output from @c run. */
241
+ jpegxl_cms_get_buffer_func get_dst_buf;
242
+ /** Executes the transform on a batch of pixels, per @ref jpegxl_cms_run_func.
243
+ */
244
+ jpegxl_cms_run_func run;
245
+ /** Cleans up the transform. */
246
+ jpegxl_cms_destroy_func destroy;
247
+ } JxlCmsInterface;
248
+
249
+ #ifdef __cplusplus
250
+ }
251
+ #endif
252
+
253
+ #endif /* JXL_CMS_INTERFACE_H_ */
254
+
255
+ /** @} */
@@ -0,0 +1,433 @@
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
+
7
+ /** @addtogroup libjxl_metadata
8
+ * @{
9
+ * @file codestream_header.h
10
+ * @brief Definitions of structs and enums for the metadata from the JPEG XL
11
+ * codestream headers (signature, metadata, preview dimensions, ...), excluding
12
+ * color encoding which is in color_encoding.h.
13
+ */
14
+
15
+ #ifndef JXL_CODESTREAM_HEADER_H_
16
+ #define JXL_CODESTREAM_HEADER_H_
17
+
18
+ #include <jxl/types.h>
19
+ #include <stddef.h>
20
+ #include <stdint.h>
21
+
22
+ #ifdef __cplusplus
23
+ extern "C" {
24
+ #endif
25
+
26
+ /** Image orientation metadata.
27
+ * Values 1..8 match the EXIF definitions.
28
+ * The name indicates the operation to perform to transform from the encoded
29
+ * image to the display image.
30
+ */
31
+ typedef enum {
32
+ JXL_ORIENT_IDENTITY = 1,
33
+ JXL_ORIENT_FLIP_HORIZONTAL = 2,
34
+ JXL_ORIENT_ROTATE_180 = 3,
35
+ JXL_ORIENT_FLIP_VERTICAL = 4,
36
+ JXL_ORIENT_TRANSPOSE = 5,
37
+ JXL_ORIENT_ROTATE_90_CW = 6,
38
+ JXL_ORIENT_ANTI_TRANSPOSE = 7,
39
+ JXL_ORIENT_ROTATE_90_CCW = 8,
40
+ } JxlOrientation;
41
+
42
+ /** Given type of an extra channel.
43
+ */
44
+ typedef enum {
45
+ JXL_CHANNEL_ALPHA,
46
+ JXL_CHANNEL_DEPTH,
47
+ JXL_CHANNEL_SPOT_COLOR,
48
+ JXL_CHANNEL_SELECTION_MASK,
49
+ JXL_CHANNEL_BLACK,
50
+ JXL_CHANNEL_CFA,
51
+ JXL_CHANNEL_THERMAL,
52
+ JXL_CHANNEL_RESERVED0,
53
+ JXL_CHANNEL_RESERVED1,
54
+ JXL_CHANNEL_RESERVED2,
55
+ JXL_CHANNEL_RESERVED3,
56
+ JXL_CHANNEL_RESERVED4,
57
+ JXL_CHANNEL_RESERVED5,
58
+ JXL_CHANNEL_RESERVED6,
59
+ JXL_CHANNEL_RESERVED7,
60
+ JXL_CHANNEL_UNKNOWN,
61
+ JXL_CHANNEL_OPTIONAL
62
+ } JxlExtraChannelType;
63
+
64
+ /** The codestream preview header */
65
+ typedef struct {
66
+ /** Preview width in pixels */
67
+ uint32_t xsize;
68
+
69
+ /** Preview height in pixels */
70
+ uint32_t ysize;
71
+ } JxlPreviewHeader;
72
+
73
+ /** The codestream animation header, optionally present in the beginning of
74
+ * the codestream, and if it is it applies to all animation frames, unlike @ref
75
+ * JxlFrameHeader which applies to an individual frame.
76
+ */
77
+ typedef struct {
78
+ /** Numerator of ticks per second of a single animation frame time unit */
79
+ uint32_t tps_numerator;
80
+
81
+ /** Denominator of ticks per second of a single animation frame time unit */
82
+ uint32_t tps_denominator;
83
+
84
+ /** Amount of animation loops, or 0 to repeat infinitely */
85
+ uint32_t num_loops;
86
+
87
+ /** Whether animation time codes are present at animation frames in the
88
+ * codestream */
89
+ JXL_BOOL have_timecodes;
90
+ } JxlAnimationHeader;
91
+
92
+ /** Basic image information. This information is available from the file
93
+ * signature and first part of the codestream header.
94
+ */
95
+ typedef struct {
96
+ /* TODO(lode): need additional fields for (transcoded) JPEG? For reusable
97
+ * fields orientation must be read from Exif APP1. For has_icc_profile: must
98
+ * look up where ICC profile is guaranteed to be in a JPEG file to be able to
99
+ * indicate this. */
100
+
101
+ /* TODO(lode): make struct packed, and/or make this opaque struct with getter
102
+ * functions (still separate struct from opaque decoder) */
103
+
104
+ /** Whether the codestream is embedded in the container format. If true,
105
+ * metadata information and extensions may be available in addition to the
106
+ * codestream.
107
+ */
108
+ JXL_BOOL have_container;
109
+
110
+ /** Width of the image in pixels, before applying orientation.
111
+ */
112
+ uint32_t xsize;
113
+
114
+ /** Height of the image in pixels, before applying orientation.
115
+ */
116
+ uint32_t ysize;
117
+
118
+ /** Original image color channel bit depth.
119
+ */
120
+ uint32_t bits_per_sample;
121
+
122
+ /** Original image color channel floating point exponent bits, or 0 if they
123
+ * are unsigned integer. For example, if the original data is half-precision
124
+ * (binary16) floating point, bits_per_sample is 16 and
125
+ * exponent_bits_per_sample is 5, and so on for other floating point
126
+ * precisions.
127
+ */
128
+ uint32_t exponent_bits_per_sample;
129
+
130
+ /** Upper bound on the intensity level present in the image in nits. For
131
+ * unsigned integer pixel encodings, this is the brightness of the largest
132
+ * representable value. The image does not necessarily contain a pixel
133
+ * actually this bright. An encoder is allowed to set 255 for SDR images
134
+ * without computing a histogram.
135
+ * Leaving this set to its default of 0 lets libjxl choose a sensible default
136
+ * value based on the color encoding.
137
+ */
138
+ float intensity_target;
139
+
140
+ /** Lower bound on the intensity level present in the image. This may be
141
+ * loose, i.e. lower than the actual darkest pixel. When tone mapping, a
142
+ * decoder will map [min_nits, intensity_target] to the display range.
143
+ */
144
+ float min_nits;
145
+
146
+ /** See the description of @see linear_below.
147
+ */
148
+ JXL_BOOL relative_to_max_display;
149
+
150
+ /** The tone mapping will leave unchanged (linear mapping) any pixels whose
151
+ * brightness is strictly below this. The interpretation depends on
152
+ * relative_to_max_display. If true, this is a ratio [0, 1] of the maximum
153
+ * display brightness [nits], otherwise an absolute brightness [nits].
154
+ */
155
+ float linear_below;
156
+
157
+ /** Whether the data in the codestream is encoded in the original color
158
+ * profile that is attached to the codestream metadata header, or is
159
+ * encoded in an internally supported absolute color space (which the decoder
160
+ * can always convert to linear or non-linear sRGB or to XYB). If the original
161
+ * profile is used, the decoder outputs pixel data in the color space matching
162
+ * that profile, but doesn't convert it to any other color space. If the
163
+ * original profile is not used, the decoder only outputs the data as sRGB
164
+ * (linear if outputting to floating point, nonlinear with standard sRGB
165
+ * transfer function if outputting to unsigned integers) but will not convert
166
+ * it to the original color profile. The decoder also does not convert to
167
+ * the target display color profile. To convert the pixel data produced by
168
+ * the decoder to the original color profile, one of the JxlDecoderGetColor*
169
+ * functions needs to be called with
170
+ * ::JXL_COLOR_PROFILE_TARGET_DATA to get the color profile of the decoder
171
+ * output, and then an external CMS can be used for conversion. Note that for
172
+ * lossy compression, this should be set to false for most use cases, and if
173
+ * needed, the image should be converted to the original color profile after
174
+ * decoding, as described above.
175
+ */
176
+ JXL_BOOL uses_original_profile;
177
+
178
+ /** Indicates a preview image exists near the beginning of the codestream.
179
+ * The preview itself or its dimensions are not included in the basic info.
180
+ */
181
+ JXL_BOOL have_preview;
182
+
183
+ /** Indicates animation frames exist in the codestream. The animation
184
+ * information is not included in the basic info.
185
+ */
186
+ JXL_BOOL have_animation;
187
+
188
+ /** Image orientation, value 1-8 matching the values used by JEITA CP-3451C
189
+ * (Exif version 2.3).
190
+ */
191
+ JxlOrientation orientation;
192
+
193
+ /** Number of color channels encoded in the image, this is either 1 for
194
+ * grayscale data, or 3 for colored data. This count does not include
195
+ * the alpha channel or other extra channels. To check presence of an alpha
196
+ * channel, such as in the case of RGBA color, check alpha_bits != 0.
197
+ * If and only if this is 1, the @ref JxlColorSpace in the @ref
198
+ * JxlColorEncoding is
199
+ * ::JXL_COLOR_SPACE_GRAY.
200
+ */
201
+ uint32_t num_color_channels;
202
+
203
+ /** Number of additional image channels. This includes the main alpha channel,
204
+ * but can also include additional channels such as depth, additional alpha
205
+ * channels, spot colors, and so on. Information about the extra channels
206
+ * can be queried with @ref JxlDecoderGetExtraChannelInfo. The main alpha
207
+ * channel, if it exists, also has its information available in the
208
+ * alpha_bits, alpha_exponent_bits and alpha_premultiplied fields in this @ref
209
+ * JxlBasicInfo.
210
+ */
211
+ uint32_t num_extra_channels;
212
+
213
+ /** Bit depth of the encoded alpha channel, or 0 if there is no alpha channel.
214
+ * If present, matches the alpha_bits value of the JxlExtraChannelInfo
215
+ * associated with this alpha channel.
216
+ */
217
+ uint32_t alpha_bits;
218
+
219
+ /** Alpha channel floating point exponent bits, or 0 if they are unsigned. If
220
+ * present, matches the alpha_bits value of the JxlExtraChannelInfo associated
221
+ * with this alpha channel. integer.
222
+ */
223
+ uint32_t alpha_exponent_bits;
224
+
225
+ /** Whether the alpha channel is premultiplied. Only used if there is a main
226
+ * alpha channel. Matches the alpha_premultiplied value of the
227
+ * JxlExtraChannelInfo associated with this alpha channel.
228
+ */
229
+ JXL_BOOL alpha_premultiplied;
230
+
231
+ /** Dimensions of encoded preview image, only used if have_preview is
232
+ * JXL_TRUE.
233
+ */
234
+ JxlPreviewHeader preview;
235
+
236
+ /** Animation header with global animation properties for all frames, only
237
+ * used if have_animation is JXL_TRUE.
238
+ */
239
+ JxlAnimationHeader animation;
240
+
241
+ /** Intrinsic width of the image.
242
+ * The intrinsic size can be different from the actual size in pixels
243
+ * (as given by xsize and ysize) and it denotes the recommended dimensions
244
+ * for displaying the image, i.e. applications are advised to resample the
245
+ * decoded image to the intrinsic dimensions.
246
+ */
247
+ uint32_t intrinsic_xsize;
248
+
249
+ /** Intrinsic height of the image.
250
+ * The intrinsic size can be different from the actual size in pixels
251
+ * (as given by xsize and ysize) and it denotes the recommended dimensions
252
+ * for displaying the image, i.e. applications are advised to resample the
253
+ * decoded image to the intrinsic dimensions.
254
+ */
255
+ uint32_t intrinsic_ysize;
256
+
257
+ /** Padding for forwards-compatibility, in case more fields are exposed
258
+ * in a future version of the library.
259
+ */
260
+ uint8_t padding[100];
261
+ } JxlBasicInfo;
262
+
263
+ /** Information for a single extra channel.
264
+ */
265
+ typedef struct {
266
+ /** Given type of an extra channel.
267
+ */
268
+ JxlExtraChannelType type;
269
+
270
+ /** Total bits per sample for this channel.
271
+ */
272
+ uint32_t bits_per_sample;
273
+
274
+ /** Floating point exponent bits per channel, or 0 if they are unsigned
275
+ * integer.
276
+ */
277
+ uint32_t exponent_bits_per_sample;
278
+
279
+ /** The exponent the channel is downsampled by on each axis.
280
+ * TODO(lode): expand this comment to match the JPEG XL specification,
281
+ * specify how to upscale, how to round the size computation, and to which
282
+ * extra channels this field applies.
283
+ */
284
+ uint32_t dim_shift;
285
+
286
+ /** Length of the extra channel name in bytes, or 0 if no name.
287
+ * Excludes null termination character.
288
+ */
289
+ uint32_t name_length;
290
+
291
+ /** Whether alpha channel uses premultiplied alpha. Only applicable if
292
+ * type is JXL_CHANNEL_ALPHA.
293
+ */
294
+ JXL_BOOL alpha_premultiplied;
295
+
296
+ /** Spot color of the current spot channel in linear RGBA. Only applicable if
297
+ * type is JXL_CHANNEL_SPOT_COLOR.
298
+ */
299
+ float spot_color[4];
300
+
301
+ /** Only applicable if type is JXL_CHANNEL_CFA.
302
+ * TODO(lode): add comment about the meaning of this field.
303
+ */
304
+ uint32_t cfa_channel;
305
+ } JxlExtraChannelInfo;
306
+
307
+ /* TODO(lode): add API to get the codestream header extensions. */
308
+ /** Extensions in the codestream header. */
309
+ typedef struct {
310
+ /** Extension bits. */
311
+ uint64_t extensions;
312
+ } JxlHeaderExtensions;
313
+
314
+ /** Frame blend modes.
315
+ * When decoding, if coalescing is enabled (default), this can be ignored.
316
+ */
317
+ typedef enum {
318
+ JXL_BLEND_REPLACE = 0,
319
+ JXL_BLEND_ADD = 1,
320
+ JXL_BLEND_BLEND = 2,
321
+ JXL_BLEND_MULADD = 3,
322
+ JXL_BLEND_MUL = 4,
323
+ } JxlBlendMode;
324
+
325
+ /** The information about blending the color channels or a single extra channel.
326
+ * When decoding, if coalescing is enabled (default), this can be ignored and
327
+ * the blend mode is considered to be JXL_BLEND_REPLACE.
328
+ * When encoding, these settings apply to the pixel data given to the encoder.
329
+ */
330
+ typedef struct {
331
+ /** Blend mode.
332
+ */
333
+ JxlBlendMode blendmode;
334
+ /** Reference frame ID to use as the 'bottom' layer (0-3).
335
+ */
336
+ uint32_t source;
337
+ /** Which extra channel to use as the 'alpha' channel for blend modes
338
+ * JXL_BLEND_BLEND and JXL_BLEND_MULADD.
339
+ */
340
+ uint32_t alpha;
341
+ /** Clamp values to [0,1] for the purpose of blending.
342
+ */
343
+ JXL_BOOL clamp;
344
+ } JxlBlendInfo;
345
+
346
+ /** The information about layers.
347
+ * When decoding, if coalescing is enabled (default), this can be ignored.
348
+ * When encoding, these settings apply to the pixel data given to the encoder,
349
+ * the encoder could choose an internal representation that differs.
350
+ */
351
+ typedef struct {
352
+ /** Whether cropping is applied for this frame. When decoding, if false,
353
+ * crop_x0 and crop_y0 are set to zero, and xsize and ysize to the main
354
+ * image dimensions. When encoding and this is false, those fields are
355
+ * ignored. When decoding, if coalescing is enabled (default), this is always
356
+ * false, regardless of the internal encoding in the JPEG XL codestream.
357
+ */
358
+ JXL_BOOL have_crop;
359
+
360
+ /** Horizontal offset of the frame (can be negative).
361
+ */
362
+ int32_t crop_x0;
363
+
364
+ /** Vertical offset of the frame (can be negative).
365
+ */
366
+ int32_t crop_y0;
367
+
368
+ /** Width of the frame (number of columns).
369
+ */
370
+ uint32_t xsize;
371
+
372
+ /** Height of the frame (number of rows).
373
+ */
374
+ uint32_t ysize;
375
+
376
+ /** The blending info for the color channels. Blending info for extra channels
377
+ * has to be retrieved separately using JxlDecoderGetExtraChannelBlendInfo.
378
+ */
379
+ JxlBlendInfo blend_info;
380
+
381
+ /** After blending, save the frame as reference frame with this ID (0-3).
382
+ * Special case: if the frame duration is nonzero, ID 0 means "will not be
383
+ * referenced in the future". This value is not used for the last frame.
384
+ * When encoding, ID 3 is reserved to frames that are generated internally by
385
+ * the encoder, and should not be used by applications.
386
+ */
387
+ uint32_t save_as_reference;
388
+ } JxlLayerInfo;
389
+
390
+ /** The header of one displayed frame or non-coalesced layer. */
391
+ typedef struct {
392
+ /** How long to wait after rendering in ticks. The duration in seconds of a
393
+ * tick is given by tps_numerator and tps_denominator in @ref
394
+ * JxlAnimationHeader.
395
+ */
396
+ uint32_t duration;
397
+
398
+ /** SMPTE timecode of the current frame in form 0xHHMMSSFF, or 0. The bits are
399
+ * interpreted from most-significant to least-significant as hour, minute,
400
+ * second, and frame. If timecode is nonzero, it is strictly larger than that
401
+ * of a previous frame with nonzero duration. These values are only available
402
+ * if have_timecodes in @ref JxlAnimationHeader is ::JXL_TRUE.
403
+ * This value is only used if have_timecodes in @ref JxlAnimationHeader is
404
+ * ::JXL_TRUE.
405
+ */
406
+ uint32_t timecode;
407
+
408
+ /** Length of the frame name in bytes, or 0 if no name.
409
+ * Excludes null termination character. This value is set by the decoder.
410
+ * For the encoder, this value is ignored and @ref JxlEncoderSetFrameName is
411
+ * used instead to set the name and the length.
412
+ */
413
+ uint32_t name_length;
414
+
415
+ /** Indicates this is the last animation frame. This value is set by the
416
+ * decoder to indicate no further frames follow. For the encoder, it is not
417
+ * required to set this value and it is ignored, @ref JxlEncoderCloseFrames is
418
+ * used to indicate the last frame to the encoder instead.
419
+ */
420
+ JXL_BOOL is_last;
421
+
422
+ /** Information about the layer in case of no coalescing.
423
+ */
424
+ JxlLayerInfo layer_info;
425
+ } JxlFrameHeader;
426
+
427
+ #ifdef __cplusplus
428
+ }
429
+ #endif
430
+
431
+ #endif /* JXL_CODESTREAM_HEADER_H_ */
432
+
433
+ /** @}*/