@img/sharp-libvips-dev 1.2.0-rc.3 → 1.2.0

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.
Files changed (38) hide show
  1. package/include/fontconfig/fontconfig.h +12 -2
  2. package/include/glib-2.0/girepository/girepository.h +3 -0
  3. package/include/glib-2.0/glib/gmarkup.h +4 -0
  4. package/include/libheif/heif.h +16 -2603
  5. package/include/libheif/heif_aux_images.h +182 -0
  6. package/include/libheif/heif_brands.h +373 -0
  7. package/include/libheif/heif_color.h +357 -0
  8. package/include/libheif/heif_context.h +329 -0
  9. package/include/libheif/heif_cxx.h +6 -6
  10. package/include/libheif/heif_decoding.h +162 -0
  11. package/include/libheif/heif_encoding.h +391 -0
  12. package/include/libheif/heif_entity_groups.h +60 -0
  13. package/include/libheif/heif_error.h +302 -0
  14. package/include/libheif/heif_image.h +352 -0
  15. package/include/libheif/heif_image_handle.h +120 -0
  16. package/include/libheif/heif_items.h +45 -45
  17. package/include/libheif/heif_library.h +216 -0
  18. package/include/libheif/heif_metadata.h +133 -0
  19. package/include/libheif/heif_plugin.h +53 -41
  20. package/include/libheif/heif_properties.h +73 -36
  21. package/include/libheif/heif_regions.h +95 -95
  22. package/include/libheif/heif_security.h +102 -0
  23. package/include/libheif/heif_sequences.h +577 -0
  24. package/include/libheif/heif_tai_timestamps.h +202 -0
  25. package/include/libheif/heif_tiling.h +137 -0
  26. package/include/libheif/heif_uncompressed.h +109 -0
  27. package/include/libheif/heif_version.h +2 -2
  28. package/include/libpng16/png.h +7 -7
  29. package/include/libpng16/pngconf.h +1 -1
  30. package/include/libpng16/pnglibconf.h +1 -1
  31. package/include/pango-1.0/pango/pango-attributes.h +1 -1
  32. package/include/pango-1.0/pango/pango-features.h +2 -2
  33. package/include/png.h +7 -7
  34. package/include/pngconf.h +1 -1
  35. package/include/pnglibconf.h +1 -1
  36. package/include/vips/version.h +4 -4
  37. package/package.json +1 -1
  38. package/versions.json +5 -5
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * HEIF codec.
3
- * Copyright (c) 2017-2023 Dirk Farin <dirk.farin@gmail.com>
3
+ * Copyright (c) 2017-2025 Dirk Farin <dirk.farin@gmail.com>
4
4
  *
5
5
  * This file is part of libheif.
6
6
  *
@@ -21,2608 +21,21 @@
21
21
  #ifndef LIBHEIF_HEIF_H
22
22
  #define LIBHEIF_HEIF_H
23
23
 
24
- #ifdef __cplusplus
25
- extern "C" {
26
- #endif
27
-
28
- /*! \file heif.h
29
- *
30
- * Public API for libheif.
31
- */
32
-
33
- #include <stddef.h>
34
- #include <stdint.h>
35
-
24
+ #include <libheif/heif_library.h>
36
25
  #include <libheif/heif_version.h>
37
-
38
-
39
- // API versions table
40
- //
41
- // release dec.options enc.options heif_reader heif_writer depth.rep col.profile
42
- // ------------------------------------------------------------------------------------------
43
- // 1.0 1 N/A N/A N/A 1 N/A
44
- // 1.1 1 N/A N/A 1 1 N/A
45
- // 1.3 1 1 1 1 1 N/A
46
- // 1.4 1 1 1 1 1 1
47
- // 1.7 2 1 1 1 1 1
48
- // 1.9.2 2 2 1 1 1 1
49
- // 1.10 2 3 1 1 1 1
50
- // 1.11 2 4 1 1 1 1
51
- // 1.13 3 4 1 1 1 1
52
- // 1.14 3 5 1 1 1 1
53
- // 1.15 4 5 1 1 1 1
54
- // 1.16 5 6 1 1 1 1
55
- // 1.18 5 7 1 1 1 1
56
- // 1.19 6 7 2 1 1 1
57
-
58
- #if (defined(_WIN32) || defined __CYGWIN__) && !defined(LIBHEIF_STATIC_BUILD)
59
- #ifdef LIBHEIF_EXPORTS
60
- #define LIBHEIF_API __declspec(dllexport)
61
- #else
62
- #define LIBHEIF_API __declspec(dllimport)
63
- #endif
64
- #elif defined(HAVE_VISIBILITY) && HAVE_VISIBILITY
65
- #ifdef LIBHEIF_EXPORTS
66
- #define LIBHEIF_API __attribute__((__visibility__("default")))
67
- #else
68
- #define LIBHEIF_API
69
- #endif
70
- #else
71
- #define LIBHEIF_API
72
- #endif
73
-
74
- #define heif_fourcc(a, b, c, d) ((uint32_t)((a<<24) | (b<<16) | (c<<8) | d))
75
-
76
-
77
- /* === version numbers === */
78
-
79
- // Version string of linked libheif library.
80
- LIBHEIF_API const char* heif_get_version(void);
81
-
82
- // Numeric version of linked libheif library, encoded as 0xHHMMLL00 = hh.mm.ll, where hh, mm, ll is the decimal representation of HH, MM, LL.
83
- // For example: 0x02150300 is version 2.21.3
84
- LIBHEIF_API uint32_t heif_get_version_number(void);
85
-
86
- // Numeric part "HH" from above. Returned as a decimal number.
87
- LIBHEIF_API int heif_get_version_number_major(void);
88
- // Numeric part "MM" from above. Returned as a decimal number.
89
- LIBHEIF_API int heif_get_version_number_minor(void);
90
- // Numeric part "LL" from above. Returned as a decimal number.
91
- LIBHEIF_API int heif_get_version_number_maintenance(void);
92
-
93
- // Helper macros to check for given versions of libheif at compile time.
94
- #define LIBHEIF_MAKE_VERSION(h, m, l) ((h) << 24 | (m) << 16 | (l) << 8)
95
- #define LIBHEIF_HAVE_VERSION(h, m, l) (LIBHEIF_NUMERIC_VERSION >= LIBHEIF_MAKE_VERSION(h, m, l))
96
-
97
- struct heif_context;
98
- struct heif_image_handle;
99
- struct heif_image;
100
-
101
-
102
- enum heif_error_code
103
- {
104
- // Everything ok, no error occurred.
105
- heif_error_Ok = 0,
106
-
107
- // Input file does not exist.
108
- heif_error_Input_does_not_exist = 1,
109
-
110
- // Error in input file. Corrupted or invalid content.
111
- heif_error_Invalid_input = 2,
112
-
113
- // Input file type is not supported.
114
- heif_error_Unsupported_filetype = 3,
115
-
116
- // Image requires an unsupported decoder feature.
117
- heif_error_Unsupported_feature = 4,
118
-
119
- // Library API has been used in an invalid way.
120
- heif_error_Usage_error = 5,
121
-
122
- // Could not allocate enough memory.
123
- heif_error_Memory_allocation_error = 6,
124
-
125
- // The decoder plugin generated an error
126
- heif_error_Decoder_plugin_error = 7,
127
-
128
- // The encoder plugin generated an error
129
- heif_error_Encoder_plugin_error = 8,
130
-
131
- // Error during encoding or when writing to the output
132
- heif_error_Encoding_error = 9,
133
-
134
- // Application has asked for a color profile type that does not exist
135
- heif_error_Color_profile_does_not_exist = 10,
136
-
137
- // Error loading a dynamic plugin
138
- heif_error_Plugin_loading_error = 11,
139
-
140
- // Operation has been canceled
141
- heif_error_Canceled = 12
142
- };
143
-
144
-
145
- enum heif_suberror_code
146
- {
147
- // no further information available
148
- heif_suberror_Unspecified = 0,
149
-
150
- // --- Invalid_input ---
151
-
152
- // End of data reached unexpectedly.
153
- heif_suberror_End_of_data = 100,
154
-
155
- // Size of box (defined in header) is wrong
156
- heif_suberror_Invalid_box_size = 101,
157
-
158
- // Mandatory 'ftyp' box is missing
159
- heif_suberror_No_ftyp_box = 102,
160
-
161
- heif_suberror_No_idat_box = 103,
162
-
163
- heif_suberror_No_meta_box = 104,
164
-
165
- heif_suberror_No_hdlr_box = 105,
166
-
167
- heif_suberror_No_hvcC_box = 106,
168
-
169
- heif_suberror_No_pitm_box = 107,
170
-
171
- heif_suberror_No_ipco_box = 108,
172
-
173
- heif_suberror_No_ipma_box = 109,
174
-
175
- heif_suberror_No_iloc_box = 110,
176
-
177
- heif_suberror_No_iinf_box = 111,
178
-
179
- heif_suberror_No_iprp_box = 112,
180
-
181
- heif_suberror_No_iref_box = 113,
182
-
183
- heif_suberror_No_pict_handler = 114,
184
-
185
- // An item property referenced in the 'ipma' box is not existing in the 'ipco' container.
186
- heif_suberror_Ipma_box_references_nonexisting_property = 115,
187
-
188
- // No properties have been assigned to an item.
189
- heif_suberror_No_properties_assigned_to_item = 116,
190
-
191
- // Image has no (compressed) data
192
- heif_suberror_No_item_data = 117,
193
-
194
- // Invalid specification of image grid (tiled image)
195
- heif_suberror_Invalid_grid_data = 118,
196
-
197
- // Tile-images in a grid image are missing
198
- heif_suberror_Missing_grid_images = 119,
199
-
200
- heif_suberror_Invalid_clean_aperture = 120,
201
-
202
- // Invalid specification of overlay image
203
- heif_suberror_Invalid_overlay_data = 121,
204
-
205
- // Overlay image completely outside of visible canvas area
206
- heif_suberror_Overlay_image_outside_of_canvas = 122,
207
-
208
- heif_suberror_Auxiliary_image_type_unspecified = 123,
209
-
210
- heif_suberror_No_or_invalid_primary_item = 124,
211
-
212
- heif_suberror_No_infe_box = 125,
213
-
214
- heif_suberror_Unknown_color_profile_type = 126,
215
-
216
- heif_suberror_Wrong_tile_image_chroma_format = 127,
217
-
218
- heif_suberror_Invalid_fractional_number = 128,
219
-
220
- heif_suberror_Invalid_image_size = 129,
221
-
222
- heif_suberror_Invalid_pixi_box = 130,
223
-
224
- heif_suberror_No_av1C_box = 131,
225
-
226
- heif_suberror_Wrong_tile_image_pixel_depth = 132,
227
-
228
- heif_suberror_Unknown_NCLX_color_primaries = 133,
229
-
230
- heif_suberror_Unknown_NCLX_transfer_characteristics = 134,
231
-
232
- heif_suberror_Unknown_NCLX_matrix_coefficients = 135,
233
-
234
- // Invalid specification of region item
235
- heif_suberror_Invalid_region_data = 136,
236
-
237
- // Image has no ispe property
238
- heif_suberror_No_ispe_property = 137,
239
-
240
- heif_suberror_Camera_intrinsic_matrix_undefined = 138,
241
-
242
- heif_suberror_Camera_extrinsic_matrix_undefined = 139,
243
-
244
- // Invalid JPEG 2000 codestream - usually a missing marker
245
- heif_suberror_Invalid_J2K_codestream = 140,
246
-
247
- heif_suberror_No_vvcC_box = 141,
248
-
249
- // icbr is only needed in some situations, this error is for those cases
250
- heif_suberror_No_icbr_box = 142,
251
-
252
- heif_suberror_No_avcC_box = 143,
253
-
254
- // we got a mini box, but could not read it properly
255
- heif_suberror_Invalid_mini_box = 149,
256
-
257
- // Decompressing generic compression or header compression data failed (e.g. bitstream corruption)
258
- heif_suberror_Decompression_invalid_data = 150,
259
-
260
- // --- Memory_allocation_error ---
261
-
262
- // A security limit preventing unreasonable memory allocations was exceeded by the input file.
263
- // Please check whether the file is valid. If it is, contact us so that we could increase the
264
- // security limits further.
265
- heif_suberror_Security_limit_exceeded = 1000,
266
-
267
- // There was an error from the underlying compression / decompression library.
268
- // One possibility is lack of resources (e.g. memory).
269
- heif_suberror_Compression_initialisation_error = 1001,
270
-
271
- // --- Usage_error ---
272
-
273
- // An item ID was used that is not present in the file.
274
- heif_suberror_Nonexisting_item_referenced = 2000, // also used for Invalid_input
275
-
276
- // An API argument was given a NULL pointer, which is not allowed for that function.
277
- heif_suberror_Null_pointer_argument = 2001,
278
-
279
- // Image channel referenced that does not exist in the image
280
- heif_suberror_Nonexisting_image_channel_referenced = 2002,
281
-
282
- // The version of the passed plugin is not supported.
283
- heif_suberror_Unsupported_plugin_version = 2003,
284
-
285
- // The version of the passed writer is not supported.
286
- heif_suberror_Unsupported_writer_version = 2004,
287
-
288
- // The given (encoder) parameter name does not exist.
289
- heif_suberror_Unsupported_parameter = 2005,
290
-
291
- // The value for the given parameter is not in the valid range.
292
- heif_suberror_Invalid_parameter_value = 2006,
293
-
294
- // Error in property specification
295
- heif_suberror_Invalid_property = 2007,
296
-
297
- // Image reference cycle found in iref
298
- heif_suberror_Item_reference_cycle = 2008,
299
-
300
-
301
- // --- Unsupported_feature ---
302
-
303
- // Image was coded with an unsupported compression method.
304
- heif_suberror_Unsupported_codec = 3000,
305
-
306
- // Image is specified in an unknown way, e.g. as tiled grid image (which is supported)
307
- heif_suberror_Unsupported_image_type = 3001,
308
-
309
- heif_suberror_Unsupported_data_version = 3002,
310
-
311
- // The conversion of the source image to the requested chroma / colorspace is not supported.
312
- heif_suberror_Unsupported_color_conversion = 3003,
313
-
314
- heif_suberror_Unsupported_item_construction_method = 3004,
315
-
316
- heif_suberror_Unsupported_header_compression_method = 3005,
317
-
318
- // Generically compressed data used an unsupported compression method
319
- heif_suberror_Unsupported_generic_compression_method = 3006,
320
-
321
- heif_suberror_Unsupported_essential_property = 3007,
322
-
323
- // --- Encoder_plugin_error ---
324
-
325
- heif_suberror_Unsupported_bit_depth = 4000,
326
-
327
-
328
- // --- Encoding_error ---
329
-
330
- heif_suberror_Cannot_write_output_data = 5000,
331
-
332
- heif_suberror_Encoder_initialization = 5001,
333
- heif_suberror_Encoder_encoding = 5002,
334
- heif_suberror_Encoder_cleanup = 5003,
335
-
336
- heif_suberror_Too_many_regions = 5004,
337
-
338
-
339
- // --- Plugin loading error ---
340
-
341
- heif_suberror_Plugin_loading_error = 6000, // a specific plugin file cannot be loaded
342
- heif_suberror_Plugin_is_not_loaded = 6001, // trying to remove a plugin that is not loaded
343
- heif_suberror_Cannot_read_plugin_directory = 6002, // error while scanning the directory for plugins
344
- heif_suberror_No_matching_decoder_installed = 6003 // no decoder found for that compression format
345
- };
346
-
347
-
348
- struct heif_error
349
- {
350
- // main error category
351
- enum heif_error_code code;
352
-
353
- // more detailed error code
354
- enum heif_suberror_code subcode;
355
-
356
- // textual error message (is always defined, you do not have to check for NULL)
357
- const char* message;
358
- };
359
-
360
- // Default success return value. Intended for use in user-supplied callback functions.
361
- LIBHEIF_API extern const struct heif_error heif_error_success;
362
-
363
-
364
- typedef uint32_t heif_item_id;
365
- typedef uint32_t heif_property_id;
366
-
367
-
368
-
369
- // ========================= enum types ======================
370
-
371
- /**
372
- * libheif known compression formats.
373
- */
374
- enum heif_compression_format
375
- {
376
- /**
377
- * Unspecified / undefined compression format.
378
- *
379
- * This is used to mean "no match" or "any decoder" for some parts of the
380
- * API. It does not indicate a specific compression format.
381
- */
382
- heif_compression_undefined = 0,
383
- /**
384
- * HEVC compression, used for HEIC images.
385
- *
386
- * This is equivalent to H.265.
387
- */
388
- heif_compression_HEVC = 1,
389
- /**
390
- * AVC compression. (Currently unused in libheif.)
391
- *
392
- * The compression is defined in ISO/IEC 14496-10. This is equivalent to H.264.
393
- *
394
- * The encapsulation is defined in ISO/IEC 23008-12:2022 Annex E.
395
- */
396
- heif_compression_AVC = 2,
397
- /**
398
- * JPEG compression.
399
- *
400
- * The compression format is defined in ISO/IEC 10918-1. The encapsulation
401
- * of JPEG is specified in ISO/IEC 23008-12:2022 Annex H.
402
- */
403
- heif_compression_JPEG = 3,
404
- /**
405
- * AV1 compression, used for AVIF images.
406
- *
407
- * The compression format is provided at https://aomediacodec.github.io/av1-spec/
408
- *
409
- * The encapsulation is defined in https://aomediacodec.github.io/av1-avif/
410
- */
411
- heif_compression_AV1 = 4,
412
- /**
413
- * VVC compression.
414
- *
415
- * The compression format is defined in ISO/IEC 23090-3. This is equivalent to H.266.
416
- *
417
- * The encapsulation is defined in ISO/IEC 23008-12:2022 Annex L.
418
- */
419
- heif_compression_VVC = 5,
420
- /**
421
- * EVC compression. (Currently unused in libheif.)
422
- *
423
- * The compression format is defined in ISO/IEC 23094-1.
424
- *
425
- * The encapsulation is defined in ISO/IEC 23008-12:2022 Annex M.
426
- */
427
- heif_compression_EVC = 6,
428
- /**
429
- * JPEG 2000 compression.
430
- *
431
- * The encapsulation of JPEG 2000 is specified in ISO/IEC 15444-16:2021.
432
- * The core encoding is defined in ISO/IEC 15444-1, or ITU-T T.800.
433
- */
434
- heif_compression_JPEG2000 = 7,
435
- /**
436
- * Uncompressed encoding.
437
- *
438
- * This is defined in ISO/IEC 23001-17:2024.
439
- */
440
- heif_compression_uncompressed = 8,
441
- /**
442
- * Mask image encoding.
443
- *
444
- * See ISO/IEC 23008-12:2022 Section 6.10.2
445
- */
446
- heif_compression_mask = 9,
447
- /**
448
- * High Throughput JPEG 2000 (HT-J2K) compression.
449
- *
450
- * The encapsulation of HT-J2K is specified in ISO/IEC 15444-16:2021.
451
- * The core encoding is defined in ISO/IEC 15444-15, or ITU-T T.814.
452
- */
453
- heif_compression_HTJ2K = 10
454
- };
455
-
456
- enum heif_chroma
457
- {
458
- heif_chroma_undefined = 99,
459
- heif_chroma_monochrome = 0,
460
- heif_chroma_420 = 1,
461
- heif_chroma_422 = 2,
462
- heif_chroma_444 = 3,
463
- heif_chroma_interleaved_RGB = 10,
464
- heif_chroma_interleaved_RGBA = 11,
465
- heif_chroma_interleaved_RRGGBB_BE = 12, // HDR, big endian.
466
- heif_chroma_interleaved_RRGGBBAA_BE = 13, // HDR, big endian.
467
- heif_chroma_interleaved_RRGGBB_LE = 14, // HDR, little endian.
468
- heif_chroma_interleaved_RRGGBBAA_LE = 15 // HDR, little endian.
469
- };
470
-
471
- // DEPRECATED ENUM NAMES
472
- #define heif_chroma_interleaved_24bit heif_chroma_interleaved_RGB
473
- #define heif_chroma_interleaved_32bit heif_chroma_interleaved_RGBA
474
-
475
-
476
- enum heif_colorspace
477
- {
478
- heif_colorspace_undefined = 99,
479
-
480
- // heif_colorspace_YCbCr should be used with one of these heif_chroma values:
481
- // * heif_chroma_444
482
- // * heif_chroma_422
483
- // * heif_chroma_420
484
- heif_colorspace_YCbCr = 0,
485
-
486
- // heif_colorspace_RGB should be used with one of these heif_chroma values:
487
- // * heif_chroma_444 (for planar RGB)
488
- // * heif_chroma_interleaved_RGB
489
- // * heif_chroma_interleaved_RGBA
490
- // * heif_chroma_interleaved_RRGGBB_BE
491
- // * heif_chroma_interleaved_RRGGBBAA_BE
492
- // * heif_chroma_interleaved_RRGGBB_LE
493
- // * heif_chroma_interleaved_RRGGBBAA_LE
494
- heif_colorspace_RGB = 1,
495
-
496
- // heif_colorspace_monochrome should only be used with heif_chroma = heif_chroma_monochrome
497
- heif_colorspace_monochrome = 2,
498
-
499
- // Indicates that this image has no visual channels.
500
- heif_colorspace_nonvisual = 3
501
- };
502
-
503
- enum heif_channel
504
- {
505
- heif_channel_Y = 0,
506
- heif_channel_Cb = 1,
507
- heif_channel_Cr = 2,
508
- heif_channel_R = 3,
509
- heif_channel_G = 4,
510
- heif_channel_B = 5,
511
- heif_channel_Alpha = 6,
512
- heif_channel_interleaved = 10,
513
- heif_channel_filter_array = 11,
514
- heif_channel_depth = 12,
515
- heif_channel_disparity = 13
516
- };
517
-
518
- enum heif_metadata_compression
519
- {
520
- heif_metadata_compression_off = 0,
521
- heif_metadata_compression_auto = 1,
522
- heif_metadata_compression_unknown = 2, // only used when reading unknown method from input file
523
- heif_metadata_compression_deflate = 3,
524
- heif_metadata_compression_zlib = 4, // do not use for header data
525
- heif_metadata_compression_brotli = 5
526
- };
527
-
528
- // ========================= library initialization ======================
529
-
530
- struct heif_init_params
531
- {
532
- int version;
533
-
534
- // currently no parameters
535
- };
536
-
537
-
538
- /**
539
- * Initialise library.
540
- *
541
- * You should call heif_init() when you start using libheif and heif_deinit() when you are finished.
542
- * These calls are reference counted. Each call to heif_init() should be matched by one call to heif_deinit().
543
- *
544
- * For backwards compatibility, it is not really necessary to call heif_init(), but some library memory objects
545
- * will never be freed if you do not call heif_init()/heif_deinit().
546
- *
547
- * heif_init() will load the external modules installed in the default plugin path. Thus, you need it when you
548
- * want to load external plugins from the default path.
549
- * Codec plugins that are compiled into the library directly (selected by the compile-time parameters of libheif)
550
- * will be available even without heif_init().
551
- *
552
- * Make sure that you do not have one part of your program use heif_init()/heif_deinit() and another part that does
553
- * not use it as the latter may try to use an uninitialized library. If in doubt, enclose everything with init/deinit.
554
- *
555
- * You may pass nullptr to get default parameters. Currently, no parameters are supported.
556
- */
557
- LIBHEIF_API
558
- struct heif_error heif_init(struct heif_init_params*);
559
-
560
- /**
561
- * Deinitialise and clean up library.
562
- *
563
- * You should call heif_init() when you start using libheif and heif_deinit() when you are finished.
564
- * These calls are reference counted. Each call to heif_init() should be matched by one call to heif_deinit().
565
- *
566
- * Note: heif_deinit() must not be called after exit(), for example in a global C++ object's destructor.
567
- * If you do, global variables in libheif might have already been released when heif_deinit() is running,
568
- * leading to a crash.
569
- *
570
- * \sa heif_init()
571
- */
572
- LIBHEIF_API
573
- void heif_deinit(void);
574
-
575
-
576
- // --- Plugins are currently only supported on Unix platforms.
577
-
578
- enum heif_plugin_type
579
- {
580
- heif_plugin_type_encoder,
581
- heif_plugin_type_decoder
582
- };
583
-
584
- struct heif_plugin_info
585
- {
586
- int version; // version of this info struct
587
- enum heif_plugin_type type;
588
- const void* plugin;
589
- void* internal_handle; // for internal use only
590
- };
591
-
592
- LIBHEIF_API
593
- struct heif_error heif_load_plugin(const char* filename, struct heif_plugin_info const** out_plugin);
594
-
595
- LIBHEIF_API
596
- struct heif_error heif_load_plugins(const char* directory,
597
- const struct heif_plugin_info** out_plugins,
598
- int* out_nPluginsLoaded,
599
- int output_array_size);
600
-
601
- LIBHEIF_API
602
- struct heif_error heif_unload_plugin(const struct heif_plugin_info* plugin);
603
-
604
- // Get a NULL terminated array of the plugin directories that are searched by libheif.
605
- // This includes the paths specified in the environment variable LIBHEIF_PLUGIN_PATHS and the built-in path
606
- // (if not overridden by the environment variable).
607
- LIBHEIF_API
608
- const char*const* heif_get_plugin_directories(void);
609
-
610
- LIBHEIF_API
611
- void heif_free_plugin_directories(const char*const*);
612
-
613
-
614
- // ========================= file type check ======================
615
-
616
- enum heif_filetype_result
617
- {
618
- heif_filetype_no,
619
- heif_filetype_yes_supported, // it is heif and can be read by libheif
620
- heif_filetype_yes_unsupported, // it is heif, but cannot be read by libheif
621
- heif_filetype_maybe // not sure whether it is an heif, try detection with more input data
622
- };
623
-
624
- // input data should be at least 12 bytes
625
- LIBHEIF_API
626
- enum heif_filetype_result heif_check_filetype(const uint8_t* data, int len);
627
-
628
- /**
629
- * Check the filetype box content for a supported file type.
630
- *
631
- * <p>The data is assumed to start from the start of the `ftyp` box.
632
- *
633
- * <p>This function checks the compatible brands.
634
- *
635
- * @returns heif_error_ok if a supported brand is found, or other error if not.
636
- */
637
- LIBHEIF_API
638
- struct heif_error heif_has_compatible_filetype(const uint8_t* data, int len);
639
-
640
- LIBHEIF_API
641
- int heif_check_jpeg_filetype(const uint8_t* data, int len);
642
-
643
-
644
- // DEPRECATED, use heif_brand2 and the heif_brand2_* constants below instead
645
- enum heif_brand
646
- {
647
- heif_unknown_brand,
648
- heif_heic, // HEIF image with h265
649
- heif_heix, // 10bit images, or anything that uses h265 with range extension
650
- heif_hevc, heif_hevx, // brands for image sequences
651
- heif_heim, // multiview
652
- heif_heis, // scalable
653
- heif_hevm, // multiview sequence
654
- heif_hevs, // scalable sequence
655
- heif_mif1, // image, any coding algorithm
656
- heif_msf1, // sequence, any coding algorithm
657
- heif_avif, // HEIF image with AV1
658
- heif_avis,
659
- heif_vvic, // VVC image
660
- heif_vvis, // VVC sequence
661
- heif_evbi, // EVC image
662
- heif_evbs, // EVC sequence
663
- heif_j2ki, // JPEG2000 image
664
- heif_j2is, // JPEG2000 image sequence
665
- };
666
-
667
- // input data should be at least 12 bytes
668
- // DEPRECATED, use heif_read_main_brand() instead
669
- LIBHEIF_API
670
- enum heif_brand heif_main_brand(const uint8_t* data, int len);
671
-
672
-
673
- typedef uint32_t heif_brand2;
674
-
675
- /**
676
- * HEVC image (`heic`) brand.
677
- *
678
- * Image conforms to HEVC (H.265) Main or Main Still profile.
679
- *
680
- * See ISO/IEC 23008-12:2022 Section B.4.1.
681
- */
682
- #define heif_brand2_heic heif_fourcc('h','e','i','c')
683
-
684
- /**
685
- * HEVC image (`heix`) brand.
686
- *
687
- * Image conforms to HEVC (H.265) Main 10 profile.
688
- *
689
- * See ISO/IEC 23008-12:2022 Section B.4.1.
690
- */
691
- #define heif_brand2_heix heif_fourcc('h','e','i','x')
692
-
693
- /**
694
- * HEVC image sequence (`hevc`) brand.
695
- *
696
- * Image sequence conforms to HEVC (H.265) Main profile.
697
- *
698
- * See ISO/IEC 23008-12:2022 Section B.4.2.
699
- */
700
- #define heif_brand2_hevc heif_fourcc('h','e','v','c')
701
-
702
- /**
703
- * HEVC image sequence (`hevx`) brand.
704
- *
705
- * Image sequence conforms to HEVC (H.265) Main 10 profile.
706
- *
707
- * See ISO/IEC 23008-12:2022 Section B.4.2.
708
- */
709
- #define heif_brand2_hevx heif_fourcc('h','e','v','x')
710
-
711
- /**
712
- * HEVC layered image (`heim`) brand.
713
- *
714
- * Image layers conform to HEVC (H.265) Main or Multiview Main profile.
715
- *
716
- * See ISO/IEC 23008-12:2022 Section B.4.3.
717
- */
718
- #define heif_brand2_heim heif_fourcc('h','e','i','m')
719
-
720
- /**
721
- * HEVC layered image (`heis`) brand.
722
- *
723
- * Image layers conform to HEVC (H.265) Main, Main 10, Scalable Main
724
- * or Scalable Main 10 profile.
725
- *
726
- * See ISO/IEC 23008-12:2022 Section B.4.3.
727
- */
728
- #define heif_brand2_heis heif_fourcc('h','e','i','s')
729
-
730
- /**
731
- * HEVC layered image sequence (`hevm`) brand.
732
- *
733
- * Image sequence layers conform to HEVC (H.265) Main or Multiview Main profile.
734
- *
735
- * See ISO/IEC 23008-12:2022 Section B.4.4.
736
- */
737
- #define heif_brand2_hevm heif_fourcc('h','e','v','m')
738
-
739
- /**
740
- * HEVC layered image sequence (`hevs`) brand.
741
- *
742
- * Image sequence layers conform to HEVC (H.265) Main, Main 10, Scalable Main
743
- * or Scalable Main 10 profile.
744
- *
745
- * See ISO/IEC 23008-12:2022 Section B.4.4.
746
- */
747
- #define heif_brand2_hevs heif_fourcc('h','e','v','s')
748
-
749
- /**
750
- * AV1 image (`avif`) brand.
751
- *
752
- * See https://aomediacodec.github.io/av1-avif/#image-and-image-collection-brand
753
- */
754
- #define heif_brand2_avif heif_fourcc('a','v','i','f')
755
-
756
- /**
757
- * AV1 image sequence (`avis`) brand.
758
- *
759
- * See https://aomediacodec.github.io/av1-avif/#image-sequence-brand
760
- */
761
- #define heif_brand2_avis heif_fourcc('a','v','i','s') // AVIF sequence
762
-
763
- /**
764
- * HEIF image structural brand (`mif1`).
765
- *
766
- * This does not imply a specific coding algorithm.
767
- *
768
- * See ISO/IEC 23008-12:2022 Section 10.2.2.
769
- */
770
- #define heif_brand2_mif1 heif_fourcc('m','i','f','1')
771
-
772
- /**
773
- * HEIF image structural brand (`mif2`).
774
- *
775
- * This does not imply a specific coding algorithm. `mif2` extends
776
- * the requirements of `mif1` to include the `rref` and `iscl` item
777
- * properties.
778
- *
779
- * See ISO/IEC 23008-12:2022 Section 10.2.3.
780
- */
781
- #define heif_brand2_mif2 heif_fourcc('m','i','f','2')
782
-
783
- /**
784
- * HEIF image structural brand (`mif3`).
785
- *
786
- * This indicates the low-overhead (ftyp+mini) structure.
787
- */
788
- #define heif_brand2_mif3 heif_fourcc('m','i','f','3')
789
-
790
- /**
791
- * HEIF image sequence structural brand (`msf1`).
792
- *
793
- * This does not imply a specific coding algorithm.
794
- *
795
- * See ISO/IEC 23008-12:2022 Section 10.3.1.
796
- */
797
- #define heif_brand2_msf1 heif_fourcc('m','s','f','1')
798
-
799
- /**
800
- * VVC image (`vvic`) brand.
801
- *
802
- * See ISO/IEC 23008-12:2022 Section L.4.1.
803
- */
804
- #define heif_brand2_vvic heif_fourcc('v','v','i','c')
805
-
806
- /**
807
- * VVC image sequence (`vvis`) brand.
808
- *
809
- * See ISO/IEC 23008-12:2022 Section L.4.2.
810
- */
811
- #define heif_brand2_vvis heif_fourcc('v','v','i','s')
812
-
813
- /**
814
- * EVC baseline image (`evbi`) brand.
815
- *
816
- * See ISO/IEC 23008-12:2022 Section M.4.1.
817
- */
818
- #define heif_brand2_evbi heif_fourcc('e','v','b','i')
819
-
820
- /**
821
- * EVC main profile image (`evmi`) brand.
822
- *
823
- * See ISO/IEC 23008-12:2022 Section M.4.2.
824
- */
825
- #define heif_brand2_evmi heif_fourcc('e','v','m','i')
826
-
827
- /**
828
- * EVC baseline image sequence (`evbs`) brand.
829
- *
830
- * See ISO/IEC 23008-12:2022 Section M.4.3.
831
- */
832
- #define heif_brand2_evbs heif_fourcc('e','v','b','s')
833
-
834
- /**
835
- * EVC main profile image sequence (`evms`) brand.
836
- *
837
- * See ISO/IEC 23008-12:2022 Section M.4.4.
838
- */
839
- #define heif_brand2_evms heif_fourcc('e','v','m','s')
840
-
841
- /**
842
- * JPEG image (`jpeg`) brand.
843
- *
844
- * See ISO/IEC 23008-12:2022 Annex H.4
845
- */
846
- #define heif_brand2_jpeg heif_fourcc('j','p','e','g')
847
-
848
- /**
849
- * JPEG image sequence (`jpgs`) brand.
850
- *
851
- * See ISO/IEC 23008-12:2022 Annex H.5
852
- */
853
- #define heif_brand2_jpgs heif_fourcc('j','p','g','s')
854
-
855
- /**
856
- * JPEG 2000 image (`j2ki`) brand.
857
- *
858
- * See ISO/IEC 15444-16:2021 Section 6.5
859
- */
860
- #define heif_brand2_j2ki heif_fourcc('j','2','k','i')
861
-
862
- /**
863
- * JPEG 2000 image sequence (`j2is`) brand.
864
- *
865
- * See ISO/IEC 15444-16:2021 Section 7.6
866
- */
867
- #define heif_brand2_j2is heif_fourcc('j','2','i','s')
868
-
869
- /**
870
- * Multi-image application format (MIAF) brand.
871
- *
872
- * This is HEIF with additional constraints for interoperability.
873
- *
874
- * See ISO/IEC 23000-22.
875
- */
876
- #define heif_brand2_miaf heif_fourcc('m','i','a','f')
877
-
878
- /**
879
- * Single picture file brand.
880
- *
881
- * This is a compatible brand indicating the file contains a single intra-coded picture.
882
- *
883
- * See ISO/IEC 23008-12:2022 Section 10.2.5.
884
- */
885
- #define heif_brand2_1pic heif_fourcc('1','p','i','c')
886
-
887
- // input data should be at least 12 bytes
888
- LIBHEIF_API
889
- heif_brand2 heif_read_main_brand(const uint8_t* data, int len);
890
-
891
- // input data should be at least 16 bytes
892
- LIBHEIF_API
893
- heif_brand2 heif_read_minor_version_brand(const uint8_t* data, int len);
894
-
895
- // 'brand_fourcc' must be 4 character long, but need not be 0-terminated
896
- LIBHEIF_API
897
- heif_brand2 heif_fourcc_to_brand(const char* brand_fourcc);
898
-
899
- // the output buffer must be at least 4 bytes long
900
- LIBHEIF_API
901
- void heif_brand_to_fourcc(heif_brand2 brand, char* out_fourcc);
902
-
903
- // 'brand_fourcc' must be 4 character long, but need not be 0-terminated
904
- // returns 1 if file includes the brand, and 0 if it does not
905
- // returns -1 if the provided data is not sufficient
906
- // (you should input at least as many bytes as indicated in the first 4 bytes of the file, usually ~50 bytes will do)
907
- // returns -2 on other errors
908
- LIBHEIF_API
909
- int heif_has_compatible_brand(const uint8_t* data, int len, const char* brand_fourcc);
910
-
911
- // Returns an array of compatible brands. The array is allocated by this function and has to be freed with 'heif_free_list_of_compatible_brands()'.
912
- // The number of entries is returned in out_size.
913
- LIBHEIF_API
914
- struct heif_error heif_list_compatible_brands(const uint8_t* data, int len, heif_brand2** out_brands, int* out_size);
915
-
916
- LIBHEIF_API
917
- void heif_free_list_of_compatible_brands(heif_brand2* brands_list);
918
-
919
-
920
- // Returns one of these MIME types:
921
- // - image/heic HEIF file using h265 compression
922
- // - image/heif HEIF file using any other compression
923
- // - image/heic-sequence HEIF image sequence using h265 compression
924
- // - image/heif-sequence HEIF image sequence using any other compression
925
- // - image/avif AVIF image
926
- // - image/avif-sequence AVIF sequence
927
- // - image/jpeg JPEG image
928
- // - image/png PNG image
929
- // If the format could not be detected, an empty string is returned.
930
- //
931
- // Provide at least 12 bytes of input. With less input, its format might not
932
- // be detected. You may also provide more input to increase detection accuracy.
933
- //
934
- // Note that JPEG and PNG images cannot be decoded by libheif even though the
935
- // formats are detected by this function.
936
- LIBHEIF_API
937
- const char* heif_get_file_mime_type(const uint8_t* data, int len);
938
-
939
-
940
-
941
- // ========================= heif_context =========================
942
- // A heif_context represents a HEIF file that has been read.
943
- // In the future, you will also be able to add pictures to a heif_context
944
- // and write it into a file again.
945
-
946
-
947
- // Allocate a new context for reading HEIF files.
948
- // Has to be freed again with heif_context_free().
949
- LIBHEIF_API
950
- struct heif_context* heif_context_alloc(void);
951
-
952
- // Free a previously allocated HEIF context. You should not free a context twice.
953
- LIBHEIF_API
954
- void heif_context_free(struct heif_context*);
955
-
956
-
957
-
958
- struct heif_reading_options;
959
-
960
- enum heif_reader_grow_status
961
- {
962
- heif_reader_grow_status_size_reached, // requested size has been reached, we can read until this point
963
- heif_reader_grow_status_timeout, // size has not been reached yet, but it may still grow further (deprecated)
964
- heif_reader_grow_status_size_beyond_eof, // size has not been reached and never will. The file has grown to its full size
965
- heif_reader_grow_status_error // an error has occurred
966
- };
967
-
968
- struct heif_reader_range_request_result
969
- {
970
- enum heif_reader_grow_status status; // should not return 'heif_reader_grow_status_timeout'
971
-
972
- // Indicates up to what position the file has been read.
973
- // If we cannot read the whole file range (status == 'heif_reader_grow_status_size_beyond_eof'), this is the actual end position.
974
- // On the other hand, it may be that the reader was reading more data than requested. In that case, it should indicate the full size here
975
- // and libheif may decide to make use of the additional data (e.g. for filling 'tili' offset tables).
976
- uint64_t range_end;
977
-
978
- // for status == 'heif_reader_grow_status_error'
979
- int reader_error_code; // a reader specific error code
980
- const char* reader_error_msg; // libheif will call heif_reader.release_error_msg on this if it is not NULL
981
- };
982
-
983
-
984
- struct heif_reader
985
- {
986
- // API version supported by this reader
987
- int reader_api_version;
988
-
989
- // --- version 1 functions ---
990
- int64_t (* get_position)(void* userdata);
991
-
992
- // The functions read(), and seek() return 0 on success.
993
- // Generally, libheif will make sure that we do not read past the file size.
994
- int (* read)(void* data,
995
- size_t size,
996
- void* userdata);
997
-
998
- int (* seek)(int64_t position,
999
- void* userdata);
1000
-
1001
- // When calling this function, libheif wants to make sure that it can read the file
1002
- // up to 'target_size'. This is useful when the file is currently downloaded and may
1003
- // grow with time. You may, for example, extract the image sizes even before the actual
1004
- // compressed image data has been completely downloaded.
1005
- //
1006
- // Even if your input files will not grow, you will have to implement at least
1007
- // detection whether the target_size is above the (fixed) file length
1008
- // (in this case, return 'size_beyond_eof').
1009
- enum heif_reader_grow_status (* wait_for_file_size)(int64_t target_size, void* userdata);
1010
-
1011
- // --- version 2 functions ---
1012
-
1013
- // These two functions are for applications that want to stream HEIF files on demand.
1014
- // For example, a large HEIF file that is served over HTTPS and we only want to download
1015
- // it partially to decode individual tiles.
1016
- // If you do not have this use case, you do not have to implement these functions and
1017
- // you can set them to NULL. For simple linear loading, you may use the 'wait_for_file_size'
1018
- // function above instead.
1019
-
1020
- // If this function is defined, libheif will often request a file range before accessing it.
1021
- // The purpose of this function is that libheif will usually read very small chunks of data with the
1022
- // read() callback above. However, it is inefficient to request such a small chunk of data over a network
1023
- // and the network delay will significantly increase the decoding time.
1024
- // Thus, libheif will call request_range() with a larger block of data that should be preloaded and the
1025
- // subsequent read() calls will work within the requested ranges.
1026
- //
1027
- // Note: `end_pos` is one byte after the last position to be read.
1028
- // You should return
1029
- // - 'heif_reader_grow_status_size_reached' if the requested range is available, or
1030
- // - 'heif_reader_grow_status_size_beyond_eof' if the requested range exceeds the file size
1031
- // (the valid part of the range has been read).
1032
- struct heif_reader_range_request_result (*request_range)(uint64_t start_pos, uint64_t end_pos, void* userdata);
1033
-
1034
- // libheif might issue hints when it assumes that a file range might be needed in the future.
1035
- // This may happen, for example, when your are doing selective tile accesses and libheif proposes
1036
- // to preload offset pointer tables.
1037
- // Another difference to request_file_range() is that this call should be non-blocking.
1038
- // If you preload any data, do this in a background thread.
1039
- void (*preload_range_hint)(uint64_t start_pos, uint64_t end_pos, void* userdata);
1040
-
1041
- // If libheif does not need access to a file range anymore, it may call this function to
1042
- // give a hint to the reader that it may release the range from a cache.
1043
- // If you do not maintain a file cache that wants to reduce its size dynamically, you do not
1044
- // need to implement this function.
1045
- void (*release_file_range)(uint64_t start_pos, uint64_t end_pos, void* userdata);
1046
-
1047
- // Release an error message that was returned by heif_reader in an earlier call.
1048
- // If this function is NULL, the error message string will not be released.
1049
- // This is a viable option if you are only returning static strings.
1050
- void (*release_error_msg)(const char* msg);
1051
- };
1052
-
1053
-
1054
- // Read a HEIF file from a named disk file.
1055
- // The heif_reading_options should currently be set to NULL.
1056
- LIBHEIF_API
1057
- struct heif_error heif_context_read_from_file(struct heif_context*, const char* filename,
1058
- const struct heif_reading_options*);
1059
-
1060
- // Read a HEIF file stored completely in memory.
1061
- // The heif_reading_options should currently be set to NULL.
1062
- // DEPRECATED: use heif_context_read_from_memory_without_copy() instead.
1063
- LIBHEIF_API
1064
- struct heif_error heif_context_read_from_memory(struct heif_context*,
1065
- const void* mem, size_t size,
1066
- const struct heif_reading_options*);
1067
-
1068
- // Same as heif_context_read_from_memory() except that the provided memory is not copied.
1069
- // That means, you will have to keep the memory area alive as long as you use the heif_context.
1070
- LIBHEIF_API
1071
- struct heif_error heif_context_read_from_memory_without_copy(struct heif_context*,
1072
- const void* mem, size_t size,
1073
- const struct heif_reading_options*);
1074
-
1075
- LIBHEIF_API
1076
- struct heif_error heif_context_read_from_reader(struct heif_context*,
1077
- const struct heif_reader* reader,
1078
- void* userdata,
1079
- const struct heif_reading_options*);
1080
-
1081
- // Number of top-level images in the HEIF file. This does not include the thumbnails or the
1082
- // tile images that are composed to an image grid. You can get access to the thumbnails via
1083
- // the main image handle.
1084
- LIBHEIF_API
1085
- int heif_context_get_number_of_top_level_images(struct heif_context* ctx);
1086
-
1087
- LIBHEIF_API
1088
- int heif_context_is_top_level_image_ID(struct heif_context* ctx, heif_item_id id);
1089
-
1090
- // Fills in image IDs into the user-supplied int-array 'ID_array', preallocated with 'count' entries.
1091
- // Function returns the total number of IDs filled into the array.
1092
- LIBHEIF_API
1093
- int heif_context_get_list_of_top_level_image_IDs(struct heif_context* ctx,
1094
- heif_item_id* ID_array,
1095
- int count);
1096
-
1097
- LIBHEIF_API
1098
- struct heif_error heif_context_get_primary_image_ID(struct heif_context* ctx, heif_item_id* id);
1099
-
1100
- // Get a handle to the primary image of the HEIF file.
1101
- // This is the image that should be displayed primarily when there are several images in the file.
1102
- LIBHEIF_API
1103
- struct heif_error heif_context_get_primary_image_handle(struct heif_context* ctx,
1104
- struct heif_image_handle**);
1105
-
1106
- // Get the image handle for a known image ID.
1107
- LIBHEIF_API
1108
- struct heif_error heif_context_get_image_handle(struct heif_context* ctx,
1109
- heif_item_id id,
1110
- struct heif_image_handle**);
1111
-
1112
- // Print information about the boxes of a HEIF file to file descriptor.
1113
- // This is for debugging and informational purposes only. You should not rely on
1114
- // the output having a specific format. At best, you should not use this at all.
1115
- LIBHEIF_API
1116
- void heif_context_debug_dump_boxes_to_file(struct heif_context* ctx, int fd);
1117
-
1118
-
1119
- // Set the maximum image size security limit. This function will set the maximum image area (number of pixels)
1120
- // to maximum_width ^ 2. Alternatively to using this function, you can also set the maximum image area
1121
- // in the security limits structure returned by heif_context_get_security_limits().
1122
- LIBHEIF_API
1123
- void heif_context_set_maximum_image_size_limit(struct heif_context* ctx, int maximum_width);
1124
-
1125
- // If the maximum threads number is set to 0, the image tiles are decoded in the main thread.
1126
- // This is different from setting it to 1, which will generate a single background thread to decode the tiles.
1127
- // Note that this setting only affects libheif itself. The codecs itself may still use multi-threaded decoding.
1128
- // You can use it, for example, in cases where you are decoding several images in parallel anyway you thus want
1129
- // to minimize parallelism in each decoder.
1130
- LIBHEIF_API
1131
- void heif_context_set_max_decoding_threads(struct heif_context* ctx, int max_threads);
1132
-
1133
-
1134
- // --- security limits
1135
-
1136
- // If you set a limit to 0, the limit is disabled.
1137
- struct heif_security_limits {
1138
- uint8_t version;
1139
-
1140
- // --- version 1
1141
-
1142
- // Limit on the maximum image size to avoid allocating too much memory.
1143
- // For example, setting this to 32768^2 pixels = 1 Gigapixels results
1144
- // in 1.5 GB memory need for YUV-4:2:0 or 4 GB for RGB32.
1145
- uint64_t max_image_size_pixels;
1146
- uint64_t max_number_of_tiles;
1147
- uint32_t max_bayer_pattern_pixels;
1148
- uint32_t max_items;
1149
-
1150
- uint32_t max_color_profile_size;
1151
- uint64_t max_memory_block_size;
1152
-
1153
- uint32_t max_components;
1154
-
1155
- uint32_t max_iloc_extents_per_item;
1156
- uint32_t max_size_entity_group;
1157
-
1158
- uint32_t max_children_per_box; // for all boxes that are not covered by other limits
1159
- };
1160
-
1161
- // The global security limits are the default for new heif_contexts.
1162
- // These global limits cannot be changed, but you can override the limits for a specific heif_context.
1163
- LIBHEIF_API
1164
- const struct heif_security_limits* heif_get_global_security_limits();
1165
-
1166
- // Returns a set of fully disabled security limits. Use with care and only after user confirmation.
1167
- LIBHEIF_API
1168
- const struct heif_security_limits* heif_get_disabled_security_limits();
1169
-
1170
- // Returns the security limits for a heif_context.
1171
- // By default, the limits are set to the global limits, but you can change them in the returned object.
1172
- LIBHEIF_API
1173
- struct heif_security_limits* heif_context_get_security_limits(const struct heif_context*);
1174
-
1175
- // Overwrites the security limits of a heif_context.
1176
- // This is a convenience function to easily copy limits.
1177
- LIBHEIF_API
1178
- struct heif_error heif_context_set_security_limits(struct heif_context*, const struct heif_security_limits*);
1179
-
1180
-
1181
- // ========================= heif_image_handle =========================
1182
-
1183
- // An heif_image_handle is a handle to a logical image in the HEIF file.
1184
- // To get the actual pixel data, you have to decode the handle to an heif_image.
1185
- // An heif_image_handle also gives you access to the thumbnails and Exif data
1186
- // associated with an image.
1187
-
1188
- // Once you obtained an heif_image_handle, you can already release the heif_context,
1189
- // since it is internally ref-counted.
1190
-
1191
- // Release image handle.
1192
- LIBHEIF_API
1193
- void heif_image_handle_release(const struct heif_image_handle*);
1194
-
1195
- // Check whether the given image_handle is the primary image of the file.
1196
- LIBHEIF_API
1197
- int heif_image_handle_is_primary_image(const struct heif_image_handle* handle);
1198
-
1199
- LIBHEIF_API
1200
- heif_item_id heif_image_handle_get_item_id(const struct heif_image_handle* handle);
1201
-
1202
- // Get the resolution of an image.
1203
- LIBHEIF_API
1204
- int heif_image_handle_get_width(const struct heif_image_handle* handle);
1205
-
1206
- LIBHEIF_API
1207
- int heif_image_handle_get_height(const struct heif_image_handle* handle);
1208
-
1209
- LIBHEIF_API
1210
- int heif_image_handle_has_alpha_channel(const struct heif_image_handle*);
1211
-
1212
- LIBHEIF_API
1213
- int heif_image_handle_is_premultiplied_alpha(const struct heif_image_handle*);
1214
-
1215
- // Returns -1 on error, e.g. if this information is not present in the image.
1216
- // Only defined for images coded in the YCbCr or monochrome colorspace.
1217
- LIBHEIF_API
1218
- int heif_image_handle_get_luma_bits_per_pixel(const struct heif_image_handle*);
1219
-
1220
- // Returns -1 on error, e.g. if this information is not present in the image.
1221
- // Only defined for images coded in the YCbCr colorspace.
1222
- LIBHEIF_API
1223
- int heif_image_handle_get_chroma_bits_per_pixel(const struct heif_image_handle*);
1224
-
1225
- // Return the colorspace that libheif proposes to use for decoding.
1226
- // Usually, these will be either YCbCr or Monochrome, but it may also propose RGB for images
1227
- // encoded with matrix_coefficients=0 or for images coded natively in RGB.
1228
- // It may also return *_undefined if the file misses relevant information to determine this without decoding.
1229
- // These are only proposed values that avoid colorspace conversions as much as possible.
1230
- // You can still request the output in your preferred colorspace, but this may involve an internal conversion.
1231
- LIBHEIF_API
1232
- struct heif_error heif_image_handle_get_preferred_decoding_colorspace(const struct heif_image_handle* image_handle,
1233
- enum heif_colorspace* out_colorspace,
1234
- enum heif_chroma* out_chroma);
1235
-
1236
- // Get the image width from the 'ispe' box. This is the original image size without
1237
- // any transformations applied to it. Do not use this unless you know exactly what
1238
- // you are doing.
1239
- LIBHEIF_API
1240
- int heif_image_handle_get_ispe_width(const struct heif_image_handle* handle);
1241
-
1242
- LIBHEIF_API
1243
- int heif_image_handle_get_ispe_height(const struct heif_image_handle* handle);
1244
-
1245
- // This gets the context associated with the image handle.
1246
- // Note that you have to release the returned context with heif_context_free() in any case.
1247
- //
1248
- // This means: when you have several image-handles that originate from the same file and you get the
1249
- // context of each of them, the returned pointer may be different even though it refers to the same
1250
- // logical context. You have to call heif_context_free() on all those context pointers.
1251
- // After you freed a context pointer, you can still use the context through a different pointer that you
1252
- // might have acquired from elsewhere.
1253
- LIBHEIF_API
1254
- struct heif_context* heif_image_handle_get_context(const struct heif_image_handle* handle);
1255
-
1256
-
1257
- struct heif_image_tiling
1258
- {
1259
- int version;
1260
-
1261
- // --- version 1
1262
-
1263
- uint32_t num_columns;
1264
- uint32_t num_rows;
1265
- uint32_t tile_width;
1266
- uint32_t tile_height;
1267
-
1268
- uint32_t image_width;
1269
- uint32_t image_height;
1270
-
1271
- // Position of the top left tile.
1272
- // Usually, this is (0;0), but if a tiled image is rotated or cropped, it may be that the top left tile should be placed at a negative position.
1273
- // The offsets define this negative shift.
1274
- uint32_t top_offset;
1275
- uint32_t left_offset;
1276
-
1277
- uint8_t number_of_extra_dimensions; // 0 for normal images, 1 for volumetric (3D), ...
1278
- uint32_t extra_dimension_size[8]; // size of extra dimensions (first 8 dimensions)
1279
- };
1280
-
1281
-
1282
- // If 'process_image_transformations' is true, this returns modified sizes.
1283
- // If it is false, the top_offset and left_offset will always be (0;0).
1284
- LIBHEIF_API
1285
- struct heif_error heif_image_handle_get_image_tiling(const struct heif_image_handle* handle, int process_image_transformations, struct heif_image_tiling* out_tiling);
1286
-
1287
-
1288
- // For grid images, return the image item ID of a specific grid tile.
1289
- // If 'process_image_transformations' is true, the tile positions are given in the transformed image coordinate system and
1290
- // are internally mapped to the original image tile positions.
1291
- LIBHEIF_API
1292
- struct heif_error heif_image_handle_get_grid_image_tile_id(const struct heif_image_handle* handle,
1293
- int process_image_transformations,
1294
- uint32_t tile_x, uint32_t tile_y,
1295
- heif_item_id* out_tile_item_id);
1296
-
1297
-
1298
- struct heif_decoding_options;
1299
-
1300
- // The tile position is given in tile indices, not in pixel coordinates.
1301
- // If the image transformations are processed (option->ignore_image_transformations==false), the tile position
1302
- // is given in the transformed coordinates.
1303
- LIBHEIF_API
1304
- struct heif_error heif_image_handle_decode_image_tile(const struct heif_image_handle* in_handle,
1305
- struct heif_image** out_img,
1306
- enum heif_colorspace colorspace,
1307
- enum heif_chroma chroma,
1308
- const struct heif_decoding_options* options,
1309
- uint32_t tile_x, uint32_t tile_y);
1310
-
1311
-
1312
- // ------------------------- entity groups ------------------------
1313
-
1314
- typedef uint32_t heif_entity_group_id;
1315
-
1316
- struct heif_entity_group
1317
- {
1318
- heif_entity_group_id entity_group_id;
1319
- uint32_t entity_group_type; // this is a FourCC constant
1320
- heif_item_id* entities;
1321
- uint32_t num_entities;
1322
- };
1323
-
1324
- // Use 0 for `type_filter` or `item_filter` to disable the filter.
1325
- // Returns an array of heif_entity_group structs with *out_num_groups entries.
1326
- LIBHEIF_API
1327
- struct heif_entity_group* heif_context_get_entity_groups(const struct heif_context*,
1328
- uint32_t type_filter,
1329
- heif_item_id item_filter,
1330
- int* out_num_groups);
1331
-
1332
- // Release an array of entity groups returned by heif_context_get_entity_groups().
1333
- LIBHEIF_API
1334
- void heif_entity_groups_release(struct heif_entity_group*, int num_groups);
1335
-
1336
-
1337
- // ------------------------- depth images -------------------------
1338
-
1339
- LIBHEIF_API
1340
- int heif_image_handle_has_depth_image(const struct heif_image_handle*);
1341
-
1342
- LIBHEIF_API
1343
- int heif_image_handle_get_number_of_depth_images(const struct heif_image_handle* handle);
1344
-
1345
- LIBHEIF_API
1346
- int heif_image_handle_get_list_of_depth_image_IDs(const struct heif_image_handle* handle,
1347
- heif_item_id* ids, int count);
1348
-
1349
- LIBHEIF_API
1350
- struct heif_error heif_image_handle_get_depth_image_handle(const struct heif_image_handle* handle,
1351
- heif_item_id depth_image_id,
1352
- struct heif_image_handle** out_depth_handle);
1353
-
1354
-
1355
- enum heif_depth_representation_type
1356
- {
1357
- heif_depth_representation_type_uniform_inverse_Z = 0,
1358
- heif_depth_representation_type_uniform_disparity = 1,
1359
- heif_depth_representation_type_uniform_Z = 2,
1360
- heif_depth_representation_type_nonuniform_disparity = 3
1361
- };
1362
-
1363
- struct heif_depth_representation_info
1364
- {
1365
- uint8_t version;
1366
-
1367
- // version 1 fields
1368
-
1369
- uint8_t has_z_near;
1370
- uint8_t has_z_far;
1371
- uint8_t has_d_min;
1372
- uint8_t has_d_max;
1373
-
1374
- double z_near;
1375
- double z_far;
1376
- double d_min;
1377
- double d_max;
1378
-
1379
- enum heif_depth_representation_type depth_representation_type;
1380
- uint32_t disparity_reference_view;
1381
-
1382
- uint32_t depth_nonlinear_representation_model_size;
1383
- uint8_t* depth_nonlinear_representation_model;
1384
-
1385
- // version 2 fields below
1386
- };
1387
-
1388
-
1389
- LIBHEIF_API
1390
- void heif_depth_representation_info_free(const struct heif_depth_representation_info* info);
1391
-
1392
- // Returns true when there is depth_representation_info available
1393
- // Note 1: depth_image_id is currently unused because we support only one depth channel per image, but
1394
- // you should still provide the correct ID for future compatibility.
1395
- // Note 2: Because of an API bug before v1.11.0, the function also works when 'handle' is the handle of the depth image.
1396
- // However, you should pass the handle of the main image. Please adapt your code if needed.
1397
- LIBHEIF_API
1398
- int heif_image_handle_get_depth_image_representation_info(const struct heif_image_handle* handle,
1399
- heif_item_id depth_image_id,
1400
- const struct heif_depth_representation_info** out);
1401
-
1402
-
1403
-
1404
- // ------------------------- thumbnails -------------------------
1405
-
1406
- // List the number of thumbnails assigned to this image handle. Usually 0 or 1.
1407
- LIBHEIF_API
1408
- int heif_image_handle_get_number_of_thumbnails(const struct heif_image_handle* handle);
1409
-
1410
- LIBHEIF_API
1411
- int heif_image_handle_get_list_of_thumbnail_IDs(const struct heif_image_handle* handle,
1412
- heif_item_id* ids, int count);
1413
-
1414
- // Get the image handle of a thumbnail image.
1415
- LIBHEIF_API
1416
- struct heif_error heif_image_handle_get_thumbnail(const struct heif_image_handle* main_image_handle,
1417
- heif_item_id thumbnail_id,
1418
- struct heif_image_handle** out_thumbnail_handle);
1419
-
1420
-
1421
- // ------------------------- auxiliary images -------------------------
1422
-
1423
- #define LIBHEIF_AUX_IMAGE_FILTER_OMIT_ALPHA (1UL<<1)
1424
- #define LIBHEIF_AUX_IMAGE_FILTER_OMIT_DEPTH (2UL<<1)
1425
-
1426
- // List the number of auxiliary images assigned to this image handle.
1427
- LIBHEIF_API
1428
- int heif_image_handle_get_number_of_auxiliary_images(const struct heif_image_handle* handle,
1429
- int aux_filter);
1430
-
1431
- LIBHEIF_API
1432
- int heif_image_handle_get_list_of_auxiliary_image_IDs(const struct heif_image_handle* handle,
1433
- int aux_filter,
1434
- heif_item_id* ids, int count);
1435
-
1436
- // You are responsible to deallocate the returned buffer with heif_image_handle_release_auxiliary_type().
1437
- LIBHEIF_API
1438
- struct heif_error heif_image_handle_get_auxiliary_type(const struct heif_image_handle* handle,
1439
- const char** out_type);
1440
-
1441
- LIBHEIF_API
1442
- void heif_image_handle_release_auxiliary_type(const struct heif_image_handle* handle,
1443
- const char** out_type);
1444
-
1445
- // DEPRECATED (because typo in function name). Use heif_image_handle_release_auxiliary_type() instead.
1446
- LIBHEIF_API
1447
- void heif_image_handle_free_auxiliary_types(const struct heif_image_handle* handle,
1448
- const char** out_type);
1449
-
1450
- // Get the image handle of an auxiliary image.
1451
- LIBHEIF_API
1452
- struct heif_error heif_image_handle_get_auxiliary_image_handle(const struct heif_image_handle* main_image_handle,
1453
- heif_item_id auxiliary_id,
1454
- struct heif_image_handle** out_auxiliary_handle);
1455
-
1456
-
1457
- // ------------------------- metadata (Exif / XMP) -------------------------
1458
-
1459
- // How many metadata blocks are attached to an image. If you only want to get EXIF data,
1460
- // set the type_filter to "Exif". Otherwise, set the type_filter to NULL.
1461
- LIBHEIF_API
1462
- int heif_image_handle_get_number_of_metadata_blocks(const struct heif_image_handle* handle,
1463
- const char* type_filter);
1464
-
1465
- // 'type_filter' can be used to get only metadata of specific types, like "Exif".
1466
- // If 'type_filter' is NULL, it will return all types of metadata IDs.
1467
- LIBHEIF_API
1468
- int heif_image_handle_get_list_of_metadata_block_IDs(const struct heif_image_handle* handle,
1469
- const char* type_filter,
1470
- heif_item_id* ids, int count);
1471
-
1472
- // Return a string indicating the type of the metadata, as specified in the HEIF file.
1473
- // Exif data will have the type string "Exif".
1474
- // This string will be valid until the next call to a libheif function.
1475
- // You do not have to free this string.
1476
- LIBHEIF_API
1477
- const char* heif_image_handle_get_metadata_type(const struct heif_image_handle* handle,
1478
- heif_item_id metadata_id);
1479
-
1480
- // For EXIF, the content type is empty.
1481
- // For XMP, the content type is "application/rdf+xml".
1482
- LIBHEIF_API
1483
- const char* heif_image_handle_get_metadata_content_type(const struct heif_image_handle* handle,
1484
- heif_item_id metadata_id);
1485
-
1486
- // Get the size of the raw metadata, as stored in the HEIF file.
1487
- LIBHEIF_API
1488
- size_t heif_image_handle_get_metadata_size(const struct heif_image_handle* handle,
1489
- heif_item_id metadata_id);
1490
-
1491
- // 'out_data' must point to a memory area of the size reported by heif_image_handle_get_metadata_size().
1492
- // The data is returned exactly as stored in the HEIF file.
1493
- // For Exif data, you probably have to skip the first four bytes of the data, since they
1494
- // indicate the offset to the start of the TIFF header of the Exif data.
1495
- LIBHEIF_API
1496
- struct heif_error heif_image_handle_get_metadata(const struct heif_image_handle* handle,
1497
- heif_item_id metadata_id,
1498
- void* out_data);
1499
-
1500
- // Only valid for item type == "uri ", an absolute URI
1501
- LIBHEIF_API
1502
- const char* heif_image_handle_get_metadata_item_uri_type(const struct heif_image_handle* handle,
1503
- heif_item_id metadata_id);
1504
-
1505
- // ------------------------- color profiles -------------------------
1506
-
1507
- enum heif_color_profile_type
1508
- {
1509
- heif_color_profile_type_not_present = 0,
1510
- heif_color_profile_type_nclx = heif_fourcc('n', 'c', 'l', 'x'),
1511
- heif_color_profile_type_rICC = heif_fourcc('r', 'I', 'C', 'C'),
1512
- heif_color_profile_type_prof = heif_fourcc('p', 'r', 'o', 'f')
1513
- };
1514
-
1515
-
1516
- // Returns 'heif_color_profile_type_not_present' if there is no color profile.
1517
- // If there is an ICC profile and an NCLX profile, the ICC profile is returned.
1518
- // TODO: we need a new API for this function as images can contain both NCLX and ICC at the same time.
1519
- // However, you can still use heif_image_handle_get_raw_color_profile() and
1520
- // heif_image_handle_get_nclx_color_profile() to access both profiles.
1521
- LIBHEIF_API
1522
- enum heif_color_profile_type heif_image_handle_get_color_profile_type(const struct heif_image_handle* handle);
1523
-
1524
- LIBHEIF_API
1525
- size_t heif_image_handle_get_raw_color_profile_size(const struct heif_image_handle* handle);
1526
-
1527
- // Returns 'heif_error_Color_profile_does_not_exist' when there is no ICC profile.
1528
- LIBHEIF_API
1529
- struct heif_error heif_image_handle_get_raw_color_profile(const struct heif_image_handle* handle,
1530
- void* out_data);
1531
-
1532
-
1533
- enum heif_color_primaries
1534
- {
1535
- heif_color_primaries_ITU_R_BT_709_5 = 1, // g=0.3;0.6, b=0.15;0.06, r=0.64;0.33, w=0.3127,0.3290
1536
- heif_color_primaries_unspecified = 2,
1537
- heif_color_primaries_ITU_R_BT_470_6_System_M = 4,
1538
- heif_color_primaries_ITU_R_BT_470_6_System_B_G = 5,
1539
- heif_color_primaries_ITU_R_BT_601_6 = 6,
1540
- heif_color_primaries_SMPTE_240M = 7,
1541
- heif_color_primaries_generic_film = 8,
1542
- heif_color_primaries_ITU_R_BT_2020_2_and_2100_0 = 9,
1543
- heif_color_primaries_SMPTE_ST_428_1 = 10,
1544
- heif_color_primaries_SMPTE_RP_431_2 = 11,
1545
- heif_color_primaries_SMPTE_EG_432_1 = 12,
1546
- heif_color_primaries_EBU_Tech_3213_E = 22
1547
- };
1548
-
1549
- enum heif_transfer_characteristics
1550
- {
1551
- heif_transfer_characteristic_ITU_R_BT_709_5 = 1,
1552
- heif_transfer_characteristic_unspecified = 2,
1553
- heif_transfer_characteristic_ITU_R_BT_470_6_System_M = 4,
1554
- heif_transfer_characteristic_ITU_R_BT_470_6_System_B_G = 5,
1555
- heif_transfer_characteristic_ITU_R_BT_601_6 = 6,
1556
- heif_transfer_characteristic_SMPTE_240M = 7,
1557
- heif_transfer_characteristic_linear = 8,
1558
- heif_transfer_characteristic_logarithmic_100 = 9,
1559
- heif_transfer_characteristic_logarithmic_100_sqrt10 = 10,
1560
- heif_transfer_characteristic_IEC_61966_2_4 = 11,
1561
- heif_transfer_characteristic_ITU_R_BT_1361 = 12,
1562
- heif_transfer_characteristic_IEC_61966_2_1 = 13,
1563
- heif_transfer_characteristic_ITU_R_BT_2020_2_10bit = 14,
1564
- heif_transfer_characteristic_ITU_R_BT_2020_2_12bit = 15,
1565
- heif_transfer_characteristic_ITU_R_BT_2100_0_PQ = 16,
1566
- heif_transfer_characteristic_SMPTE_ST_428_1 = 17,
1567
- heif_transfer_characteristic_ITU_R_BT_2100_0_HLG = 18
1568
- };
1569
-
1570
- enum heif_matrix_coefficients
1571
- {
1572
- heif_matrix_coefficients_RGB_GBR = 0,
1573
- heif_matrix_coefficients_ITU_R_BT_709_5 = 1, // TODO: or 709-6 according to h.273
1574
- heif_matrix_coefficients_unspecified = 2,
1575
- heif_matrix_coefficients_US_FCC_T47 = 4,
1576
- heif_matrix_coefficients_ITU_R_BT_470_6_System_B_G = 5,
1577
- heif_matrix_coefficients_ITU_R_BT_601_6 = 6, // TODO: or 601-7 according to h.273
1578
- heif_matrix_coefficients_SMPTE_240M = 7,
1579
- heif_matrix_coefficients_YCgCo = 8,
1580
- heif_matrix_coefficients_ITU_R_BT_2020_2_non_constant_luminance = 9,
1581
- heif_matrix_coefficients_ITU_R_BT_2020_2_constant_luminance = 10,
1582
- heif_matrix_coefficients_SMPTE_ST_2085 = 11,
1583
- heif_matrix_coefficients_chromaticity_derived_non_constant_luminance = 12,
1584
- heif_matrix_coefficients_chromaticity_derived_constant_luminance = 13,
1585
- heif_matrix_coefficients_ICtCp = 14
1586
- };
1587
-
1588
- struct heif_color_profile_nclx
1589
- {
1590
- // === version 1 fields
1591
-
1592
- uint8_t version;
1593
-
1594
- enum heif_color_primaries color_primaries;
1595
- enum heif_transfer_characteristics transfer_characteristics;
1596
- enum heif_matrix_coefficients matrix_coefficients;
1597
- uint8_t full_range_flag;
1598
-
1599
- // --- decoded values (not used when saving nclx)
1600
-
1601
- float color_primary_red_x, color_primary_red_y;
1602
- float color_primary_green_x, color_primary_green_y;
1603
- float color_primary_blue_x, color_primary_blue_y;
1604
- float color_primary_white_x, color_primary_white_y;
1605
- };
1606
-
1607
- LIBHEIF_API
1608
- struct heif_error heif_nclx_color_profile_set_color_primaries(struct heif_color_profile_nclx* nclx, uint16_t cp);
1609
-
1610
- LIBHEIF_API
1611
- struct heif_error heif_nclx_color_profile_set_transfer_characteristics(struct heif_color_profile_nclx* nclx, uint16_t transfer_characteristics);
1612
-
1613
- LIBHEIF_API
1614
- struct heif_error heif_nclx_color_profile_set_matrix_coefficients(struct heif_color_profile_nclx* nclx, uint16_t matrix_coefficients);
1615
-
1616
- // Returns 'heif_error_Color_profile_does_not_exist' when there is no NCLX profile.
1617
- // TODO: This function does currently not return an NCLX profile if it is stored in the image bitstream.
1618
- // Only NCLX profiles stored as colr boxes are returned. This may change in the future.
1619
- LIBHEIF_API
1620
- struct heif_error heif_image_handle_get_nclx_color_profile(const struct heif_image_handle* handle,
1621
- struct heif_color_profile_nclx** out_data);
1622
-
1623
- // Returned color profile has 'version' field set to the maximum allowed.
1624
- // Do not fill values for higher versions as these might be outside the allocated structure size.
1625
- // May return NULL.
1626
- LIBHEIF_API
1627
- struct heif_color_profile_nclx* heif_nclx_color_profile_alloc(void);
1628
-
1629
- LIBHEIF_API
1630
- void heif_nclx_color_profile_free(struct heif_color_profile_nclx* nclx_profile);
1631
-
1632
- // Note: in early versions of HEIF, there could only be one color profile per image. However, this has been changed.
1633
- // This function will now return ICC if one is present and NCLX only if there is no ICC.
1634
- // You may better avoid this function and simply query for NCLX and ICC directly.
1635
- LIBHEIF_API
1636
- enum heif_color_profile_type heif_image_get_color_profile_type(const struct heif_image* image);
1637
-
1638
- // Returns the size of the ICC profile if one is assigned to the image. Otherwise, it returns 0.
1639
- LIBHEIF_API
1640
- size_t heif_image_get_raw_color_profile_size(const struct heif_image* image);
1641
-
1642
- // Returns the ICC profile if one is assigned to the image. Otherwise, it returns an error.
1643
- LIBHEIF_API
1644
- struct heif_error heif_image_get_raw_color_profile(const struct heif_image* image,
1645
- void* out_data);
1646
-
1647
- LIBHEIF_API
1648
- struct heif_error heif_image_get_nclx_color_profile(const struct heif_image* image,
1649
- struct heif_color_profile_nclx** out_data);
1650
-
1651
-
1652
- // ------------------------- intrinsic and extrinsic matrices -------------------------
1653
-
1654
- struct heif_camera_intrinsic_matrix
1655
- {
1656
- double focal_length_x;
1657
- double focal_length_y;
1658
- double principal_point_x;
1659
- double principal_point_y;
1660
- double skew;
1661
- };
1662
-
1663
-
1664
- LIBHEIF_API
1665
- int heif_image_handle_has_camera_intrinsic_matrix(const struct heif_image_handle* handle);
1666
-
1667
- LIBHEIF_API
1668
- struct heif_error heif_image_handle_get_camera_intrinsic_matrix(const struct heif_image_handle* handle,
1669
- struct heif_camera_intrinsic_matrix* out_matrix);
1670
-
1671
-
1672
- struct heif_camera_extrinsic_matrix;
1673
-
1674
- LIBHEIF_API
1675
- int heif_image_handle_has_camera_extrinsic_matrix(const struct heif_image_handle* handle);
1676
-
1677
- LIBHEIF_API
1678
- struct heif_error heif_image_handle_get_camera_extrinsic_matrix(const struct heif_image_handle* handle,
1679
- struct heif_camera_extrinsic_matrix** out_matrix);
1680
-
1681
- LIBHEIF_API
1682
- void heif_camera_extrinsic_matrix_release(struct heif_camera_extrinsic_matrix*);
1683
-
1684
- LIBHEIF_API
1685
- struct heif_error heif_camera_extrinsic_matrix_get_rotation_matrix(const struct heif_camera_extrinsic_matrix*,
1686
- double* out_matrix_row_major);
1687
-
1688
-
1689
-
1690
- // ========================= heif_image =========================
1691
-
1692
- // An heif_image contains a decoded pixel image in various colorspaces, chroma formats,
1693
- // and bit depths.
1694
-
1695
- // Note: when converting images to an interleaved chroma format, the resulting
1696
- // image contains only a single channel of type channel_interleaved with, e.g., 3 bytes per pixel,
1697
- // containing the interleaved R,G,B values.
1698
-
1699
- // Planar RGB images are specified as heif_colorspace_RGB / heif_chroma_444.
1700
-
1701
- enum heif_progress_step
1702
- {
1703
- heif_progress_step_total = 0,
1704
- heif_progress_step_load_tile = 1
1705
- };
1706
-
1707
-
1708
- enum heif_chroma_downsampling_algorithm
1709
- {
1710
- heif_chroma_downsampling_nearest_neighbor = 1,
1711
- heif_chroma_downsampling_average = 2,
1712
-
1713
- // Combine with 'heif_chroma_upsampling_bilinear' for best quality.
1714
- // Makes edges look sharper when using YUV 420 with bilinear chroma upsampling.
1715
- heif_chroma_downsampling_sharp_yuv = 3
1716
- };
1717
-
1718
- enum heif_chroma_upsampling_algorithm
1719
- {
1720
- heif_chroma_upsampling_nearest_neighbor = 1,
1721
- heif_chroma_upsampling_bilinear = 2
1722
- };
1723
-
1724
-
1725
- struct heif_color_conversion_options
1726
- {
1727
- // 'version' must be 1.
1728
- uint8_t version;
1729
-
1730
- // --- version 1 options
1731
-
1732
- enum heif_chroma_downsampling_algorithm preferred_chroma_downsampling_algorithm;
1733
- enum heif_chroma_upsampling_algorithm preferred_chroma_upsampling_algorithm;
1734
-
1735
- // When set to 'false' libheif may also use a different algorithm if the preferred one is not available
1736
- // or using a different algorithm is computationally less complex. Note that currently (v1.17.0) this
1737
- // means that for RGB input it will usually choose nearest-neighbor sampling because this is computationally
1738
- // the simplest.
1739
- // Set this field to 'true' if you want to make sure that the specified algorithm is used even
1740
- // at the cost of slightly higher computation times.
1741
- uint8_t only_use_preferred_chroma_algorithm;
1742
-
1743
- // --- Note that we cannot extend this struct because it is embedded in
1744
- // other structs (heif_decoding_options and heif_encoding_options).
1745
- };
1746
-
1747
- // Assumes that it is a version=1 struct.
1748
- LIBHEIF_API
1749
- void heif_color_conversion_options_set_defaults(struct heif_color_conversion_options*);
1750
-
1751
-
1752
- struct heif_decoding_options
1753
- {
1754
- uint8_t version;
1755
-
1756
- // version 1 options
1757
-
1758
- // Ignore geometric transformations like cropping, rotation, mirroring.
1759
- // Default: false (do not ignore).
1760
- uint8_t ignore_transformations;
1761
-
1762
- // Any of the progress functions may be called from background threads.
1763
- void (* start_progress)(enum heif_progress_step step, int max_progress, void* progress_user_data);
1764
-
1765
- void (* on_progress)(enum heif_progress_step step, int progress, void* progress_user_data);
1766
-
1767
- void (* end_progress)(enum heif_progress_step step, void* progress_user_data);
1768
-
1769
- void* progress_user_data;
1770
-
1771
- // version 2 options
1772
-
1773
- uint8_t convert_hdr_to_8bit;
1774
-
1775
- // version 3 options
1776
-
1777
- // When enabled, an error is returned for invalid input. Otherwise, it will try its best and
1778
- // add decoding warnings to the decoded heif_image. Default is non-strict.
1779
- uint8_t strict_decoding;
1780
-
1781
- // version 4 options
1782
-
1783
- // name_id of the decoder to use for the decoding.
1784
- // If set to NULL (default), the highest priority decoder is chosen.
1785
- // The priority is defined in the plugin.
1786
- const char* decoder_id;
1787
-
1788
- // version 5 options
1789
-
1790
- struct heif_color_conversion_options color_conversion_options;
1791
-
1792
- // version 6 options
1793
-
1794
- int (* cancel_decoding)(void* progress_user_data);
1795
- };
1796
-
1797
-
1798
- // Allocate decoding options and fill with default values.
1799
- // Note: you should always get the decoding options through this function since the
1800
- // option structure may grow in size in future versions.
1801
- LIBHEIF_API
1802
- struct heif_decoding_options* heif_decoding_options_alloc(void);
1803
-
1804
- LIBHEIF_API
1805
- void heif_decoding_options_free(struct heif_decoding_options*);
1806
-
1807
- // Decode an heif_image_handle into the actual pixel image and also carry out
1808
- // all geometric transformations specified in the HEIF file (rotation, cropping, mirroring).
1809
- //
1810
- // If colorspace or chroma is set to heif_colorspace_undefined or heif_chroma_undefined,
1811
- // respectively, the original colorspace is taken.
1812
- // Decoding options may be NULL. If you want to supply options, always use
1813
- // heif_decoding_options_alloc() to get the structure.
1814
- LIBHEIF_API
1815
- struct heif_error heif_decode_image(const struct heif_image_handle* in_handle,
1816
- struct heif_image** out_img,
1817
- enum heif_colorspace colorspace,
1818
- enum heif_chroma chroma,
1819
- const struct heif_decoding_options* options);
1820
-
1821
- // Get the colorspace format of the image.
1822
- LIBHEIF_API
1823
- enum heif_colorspace heif_image_get_colorspace(const struct heif_image*);
1824
-
1825
- // Get the chroma format of the image.
1826
- LIBHEIF_API
1827
- enum heif_chroma heif_image_get_chroma_format(const struct heif_image*);
1828
-
1829
- /**
1830
- * Get the width of a specified image channel.
1831
- *
1832
- * @param img the image to get the width for
1833
- * @param channel the channel to select
1834
- * @return the width of the channel in pixels, or -1 the channel does not exist in the image
1835
- */
1836
- LIBHEIF_API
1837
- int heif_image_get_width(const struct heif_image* img, enum heif_channel channel);
1838
-
1839
- /**
1840
- * Get the height of a specified image channel.
1841
- *
1842
- * @param img the image to get the height for
1843
- * @param channel the channel to select
1844
- * @return the height of the channel in pixels, or -1 the channel does not exist in the image
1845
- */
1846
- LIBHEIF_API
1847
- int heif_image_get_height(const struct heif_image* img, enum heif_channel channel);
1848
-
1849
- /**
1850
- * Get the width of the main channel.
1851
- *
1852
- * This is the Y channel in YCbCr or mono, or any in RGB.
1853
- *
1854
- * @param img the image to get the primary width for
1855
- * @return the width in pixels
1856
- */
1857
- LIBHEIF_API
1858
- int heif_image_get_primary_width(const struct heif_image* img);
1859
-
1860
- /**
1861
- * Get the height of the main channel.
1862
- *
1863
- * This is the Y channel in YCbCr or mono, or any in RGB.
1864
- *
1865
- * @param img the image to get the primary height for
1866
- * @return the height in pixels
1867
- */
1868
- LIBHEIF_API
1869
- int heif_image_get_primary_height(const struct heif_image* img);
1870
-
1871
- LIBHEIF_API
1872
- struct heif_error heif_image_crop(struct heif_image* img,
1873
- int left, int right, int top, int bottom);
1874
-
1875
- // Get the number of bits per pixel in the given image channel. Returns -1 if
1876
- // a non-existing channel was given.
1877
- // Note that the number of bits per pixel may be different for each color channel.
1878
- // This function returns the number of bits used for storage of each pixel.
1879
- // Especially for HDR images, this is probably not what you want. Have a look at
1880
- // heif_image_get_bits_per_pixel_range() instead.
1881
- LIBHEIF_API
1882
- int heif_image_get_bits_per_pixel(const struct heif_image*, enum heif_channel channel);
1883
-
1884
- // Get the number of bits per pixel in the given image channel. This function returns
1885
- // the number of bits used for representing the pixel value, which might be smaller
1886
- // than the number of bits used in memory.
1887
- // For example, in 12bit HDR images, this function returns '12', while still 16 bits
1888
- // are reserved for storage. For interleaved RGBA with 12 bit, this function also returns
1889
- // '12', not '48' or '64' (heif_image_get_bits_per_pixel returns 64 in this case).
1890
- LIBHEIF_API
1891
- int heif_image_get_bits_per_pixel_range(const struct heif_image*, enum heif_channel channel);
1892
-
1893
- LIBHEIF_API
1894
- int heif_image_has_channel(const struct heif_image*, enum heif_channel channel);
1895
-
1896
- // Get a pointer to the actual pixel data.
1897
- // The 'out_stride' is returned as "bytes per line".
1898
- // When out_stride is NULL, no value will be written.
1899
- // Returns NULL if a non-existing channel was given.
1900
- // TODO: it would be better if the 'stride' parameter would be size_t to prevent integer overflows when this value is multiplicated with large y coordinates.
1901
- LIBHEIF_API
1902
- const uint8_t* heif_image_get_plane_readonly(const struct heif_image*,
1903
- enum heif_channel channel,
1904
- int* out_stride);
1905
-
1906
- LIBHEIF_API
1907
- uint8_t* heif_image_get_plane(struct heif_image*,
1908
- enum heif_channel channel,
1909
- int* out_stride);
1910
-
1911
-
1912
-
1913
- struct heif_scaling_options;
1914
-
1915
- // Currently, heif_scaling_options is not defined yet. Pass a NULL pointer.
1916
- LIBHEIF_API
1917
- struct heif_error heif_image_scale_image(const struct heif_image* input,
1918
- struct heif_image** output,
1919
- int width, int height,
1920
- const struct heif_scaling_options* options);
1921
-
1922
- // Extends the image size to match the given size by extending the right and bottom borders.
1923
- // The border areas are filled with zero.
1924
- LIBHEIF_API
1925
- struct heif_error heif_image_extend_to_size_fill_with_zero(struct heif_image* image,
1926
- uint32_t width, uint32_t height);
1927
-
1928
- // The color profile is not attached to the image handle because we might need it
1929
- // for color space transform and encoding.
1930
- LIBHEIF_API
1931
- struct heif_error heif_image_set_raw_color_profile(struct heif_image* image,
1932
- const char* profile_type_fourcc_string,
1933
- const void* profile_data,
1934
- const size_t profile_size);
1935
-
1936
- LIBHEIF_API
1937
- struct heif_error heif_image_set_nclx_color_profile(struct heif_image* image,
1938
- const struct heif_color_profile_nclx* color_profile);
1939
-
1940
-
1941
- // TODO: this function does not make any sense yet, since we currently cannot modify existing HEIF files.
1942
- //LIBHEIF_API
1943
- //void heif_image_remove_color_profile(struct heif_image* image);
1944
-
1945
- // Fills the image decoding warnings into the provided 'out_warnings' array.
1946
- // The size of the array has to be provided in max_output_buffer_entries.
1947
- // If max_output_buffer_entries==0, the number of decoder warnings is returned.
1948
- // The function fills the warnings into the provided buffer, starting with 'first_warning_idx'.
1949
- // It returns the number of warnings filled into the buffer.
1950
- // Note: you can iterate through all warnings by using 'max_output_buffer_entries=1' and iterate 'first_warning_idx'.
1951
- LIBHEIF_API
1952
- int heif_image_get_decoding_warnings(struct heif_image* image,
1953
- int first_warning_idx,
1954
- struct heif_error* out_warnings,
1955
- int max_output_buffer_entries);
1956
-
1957
- // This function is only for decoder plugin implementors.
1958
- LIBHEIF_API
1959
- void heif_image_add_decoding_warning(struct heif_image* image,
1960
- struct heif_error err);
1961
-
1962
- // Release heif_image.
1963
- LIBHEIF_API
1964
- void heif_image_release(const struct heif_image*);
1965
-
1966
-
1967
- // Note: a value of 0 for any of these values indicates that the value is undefined.
1968
- // The unit of these values is Candelas per square meter.
1969
- struct heif_content_light_level
1970
- {
1971
- uint16_t max_content_light_level;
1972
- uint16_t max_pic_average_light_level;
1973
- };
1974
-
1975
- LIBHEIF_API
1976
- int heif_image_has_content_light_level(const struct heif_image*);
1977
-
1978
- LIBHEIF_API
1979
- void heif_image_get_content_light_level(const struct heif_image*, struct heif_content_light_level* out);
1980
-
1981
- // Returns whether the image has 'content light level' information. If 0 is returned, the output is not filled.
1982
- LIBHEIF_API
1983
- int heif_image_handle_get_content_light_level(const struct heif_image_handle*, struct heif_content_light_level* out);
1984
-
1985
- LIBHEIF_API
1986
- void heif_image_set_content_light_level(const struct heif_image*, const struct heif_content_light_level* in);
1987
-
1988
-
1989
- // Note: color coordinates are defined according to the CIE 1931 definition of x as specified in ISO 11664-1 (see also ISO 11664-3 and CIE 15).
1990
- struct heif_mastering_display_colour_volume
1991
- {
1992
- uint16_t display_primaries_x[3];
1993
- uint16_t display_primaries_y[3];
1994
- uint16_t white_point_x;
1995
- uint16_t white_point_y;
1996
- uint32_t max_display_mastering_luminance;
1997
- uint32_t min_display_mastering_luminance;
1998
- };
1999
-
2000
- // The units for max_display_mastering_luminance and min_display_mastering_luminance is Candelas per square meter.
2001
- struct heif_decoded_mastering_display_colour_volume
2002
- {
2003
- float display_primaries_x[3];
2004
- float display_primaries_y[3];
2005
- float white_point_x;
2006
- float white_point_y;
2007
- double max_display_mastering_luminance;
2008
- double min_display_mastering_luminance;
2009
- };
2010
-
2011
- struct heif_ambient_viewing_environment
2012
- {
2013
- uint32_t ambient_illumination;
2014
- uint16_t ambient_light_x;
2015
- uint16_t ambient_light_y;
2016
- };
2017
-
2018
- LIBHEIF_API
2019
- int heif_image_has_mastering_display_colour_volume(const struct heif_image*);
2020
-
2021
- LIBHEIF_API
2022
- void heif_image_get_mastering_display_colour_volume(const struct heif_image*, struct heif_mastering_display_colour_volume* out);
2023
-
2024
- // Returns whether the image has 'mastering display colour volume' information. If 0 is returned, the output is not filled.
2025
- LIBHEIF_API
2026
- int heif_image_handle_get_mastering_display_colour_volume(const struct heif_image_handle*, struct heif_mastering_display_colour_volume* out);
2027
-
2028
- LIBHEIF_API
2029
- void heif_image_set_mastering_display_colour_volume(const struct heif_image*, const struct heif_mastering_display_colour_volume* in);
2030
-
2031
-
2032
- // Converts the internal numeric representation of heif_mastering_display_colour_volume to the
2033
- // normalized values, collected in heif_decoded_mastering_display_colour_volume.
2034
- // Values that are out-of-range are decoded to 0, indicating an undefined value (as specified in ISO/IEC 23008-2).
2035
- LIBHEIF_API
2036
- struct heif_error heif_mastering_display_colour_volume_decode(const struct heif_mastering_display_colour_volume* in,
2037
- struct heif_decoded_mastering_display_colour_volume* out);
2038
-
2039
- LIBHEIF_API
2040
- void heif_image_get_pixel_aspect_ratio(const struct heif_image*, uint32_t* aspect_h, uint32_t* aspect_v);
2041
-
2042
- // Returns whether the image has 'pixel aspect ratio information' information. If 0 is returned, the output is filled with the 1:1 default.
2043
- LIBHEIF_API
2044
- int heif_image_handle_get_pixel_aspect_ratio(const struct heif_image_handle*, uint32_t* aspect_h, uint32_t* aspect_v);
2045
-
2046
- LIBHEIF_API
2047
- void heif_image_set_pixel_aspect_ratio(struct heif_image*, uint32_t aspect_h, uint32_t aspect_v);
2048
-
2049
- // ====================================================================================================
2050
- // Encoding API
2051
-
2052
- LIBHEIF_API
2053
- struct heif_error heif_context_write_to_file(struct heif_context*,
2054
- const char* filename);
2055
-
2056
- struct heif_writer
2057
- {
2058
- // API version supported by this writer
2059
- int writer_api_version;
2060
-
2061
- // --- version 1 functions ---
2062
-
2063
- // On success, the returned heif_error may have a NULL message. It will automatically be replaced with a "Success" string.
2064
- struct heif_error (* write)(struct heif_context* ctx, // TODO: why do we need this parameter?
2065
- const void* data,
2066
- size_t size,
2067
- void* userdata);
2068
- };
2069
-
2070
- LIBHEIF_API
2071
- struct heif_error heif_context_write(struct heif_context*,
2072
- struct heif_writer* writer,
2073
- void* userdata);
2074
-
2075
- // Add a compatible brand that is now added automatically by libheif when encoding images (e.g. some application brands like 'geo1').
2076
- LIBHEIF_API
2077
- void heif_context_add_compatible_brand(struct heif_context* ctx,
2078
- heif_brand2 compatible_brand);
2079
-
2080
- // ----- encoder -----
2081
-
2082
- // The encoder used for actually encoding an image.
2083
- struct heif_encoder;
2084
-
2085
- // A description of the encoder's capabilities and name.
2086
- struct heif_encoder_descriptor;
2087
-
2088
- // A configuration parameter of the encoder. Each encoder implementation may have a different
2089
- // set of parameters. For the most common settings (e.q. quality), special functions to set
2090
- // the parameters are provided.
2091
- struct heif_encoder_parameter;
2092
-
2093
- struct heif_decoder_descriptor;
2094
-
2095
- // Get a list of available decoders. You can filter the encoders by compression format.
2096
- // Use format_filter==heif_compression_undefined to get all available decoders.
2097
- // The returned list of decoders is sorted by their priority (which is a plugin property).
2098
- // The number of decoders is returned, which are not more than 'count' if (out_decoders != nullptr).
2099
- // By setting out_decoders==nullptr, you can query the number of decoders, 'count' is ignored.
2100
- LIBHEIF_API
2101
- int heif_get_decoder_descriptors(enum heif_compression_format format_filter,
2102
- const struct heif_decoder_descriptor** out_decoders,
2103
- int count);
2104
-
2105
- // Return a long, descriptive name of the decoder (including version information).
2106
- LIBHEIF_API
2107
- const char* heif_decoder_descriptor_get_name(const struct heif_decoder_descriptor*);
2108
-
2109
- // Return a short, symbolic name for identifying the decoder.
2110
- // This name should stay constant over different decoder versions.
2111
- // Note: the returned ID may be NULL for old plugins that don't support this yet.
2112
- LIBHEIF_API
2113
- const char* heif_decoder_descriptor_get_id_name(const struct heif_decoder_descriptor*);
2114
-
2115
- // DEPRECATED: use heif_get_encoder_descriptors() instead.
2116
- // Get a list of available encoders. You can filter the encoders by compression format and name.
2117
- // Use format_filter==heif_compression_undefined and name_filter==NULL as wildcards.
2118
- // The returned list of encoders is sorted by their priority (which is a plugin property).
2119
- // The number of encoders is returned, which are not more than 'count' if (out_encoders != nullptr).
2120
- // By setting out_encoders==nullptr, you can query the number of encoders, 'count' is ignored.
2121
- // Note: to get the actual encoder from the descriptors returned here, use heif_context_get_encoder().
2122
- LIBHEIF_API
2123
- int heif_context_get_encoder_descriptors(struct heif_context*, // TODO: why do we need this parameter?
2124
- enum heif_compression_format format_filter,
2125
- const char* name_filter,
2126
- const struct heif_encoder_descriptor** out_encoders,
2127
- int count);
2128
-
2129
- // Get a list of available encoders. You can filter the encoders by compression format and name.
2130
- // Use format_filter==heif_compression_undefined and name_filter==NULL as wildcards.
2131
- // The returned list of encoders is sorted by their priority (which is a plugin property).
2132
- // The number of encoders is returned, which are not more than 'count' if (out_encoders != nullptr).
2133
- // By setting out_encoders==nullptr, you can query the number of encoders, 'count' is ignored.
2134
- // Note: to get the actual encoder from the descriptors returned here, use heif_context_get_encoder().
2135
- LIBHEIF_API
2136
- int heif_get_encoder_descriptors(enum heif_compression_format format_filter,
2137
- const char* name_filter,
2138
- const struct heif_encoder_descriptor** out_encoders,
2139
- int count);
2140
-
2141
- // Return a long, descriptive name of the encoder (including version information).
2142
- LIBHEIF_API
2143
- const char* heif_encoder_descriptor_get_name(const struct heif_encoder_descriptor*);
2144
-
2145
- // Return a short, symbolic name for identifying the encoder.
2146
- // This name should stay constant over different encoder versions.
2147
- LIBHEIF_API
2148
- const char* heif_encoder_descriptor_get_id_name(const struct heif_encoder_descriptor*);
2149
-
2150
- LIBHEIF_API
2151
- enum heif_compression_format
2152
- heif_encoder_descriptor_get_compression_format(const struct heif_encoder_descriptor*);
2153
-
2154
- LIBHEIF_API
2155
- int heif_encoder_descriptor_supports_lossy_compression(const struct heif_encoder_descriptor*);
2156
-
2157
- LIBHEIF_API
2158
- int heif_encoder_descriptor_supports_lossless_compression(const struct heif_encoder_descriptor*);
2159
-
2160
-
2161
- // Get an encoder instance that can be used to actually encode images from a descriptor.
2162
- LIBHEIF_API
2163
- struct heif_error heif_context_get_encoder(struct heif_context* context,
2164
- const struct heif_encoder_descriptor*,
2165
- struct heif_encoder** out_encoder);
2166
-
2167
- // Quick check whether there is a decoder available for the given format.
2168
- // Note that the decoder still may not be able to decode all variants of that format.
2169
- // You will have to query that further (todo) or just try to decode and check the returned error.
2170
- LIBHEIF_API
2171
- int heif_have_decoder_for_format(enum heif_compression_format format);
2172
-
2173
- // Quick check whether there is an enoder available for the given format.
2174
- // Note that the encoder may be limited to a certain subset of features (e.g. only 8 bit, only lossy).
2175
- // You will have to query the specific capabilities further.
2176
- LIBHEIF_API
2177
- int heif_have_encoder_for_format(enum heif_compression_format format);
2178
-
2179
- // Get an encoder for the given compression format. If there are several encoder plugins
2180
- // for this format, the encoder with the highest plugin priority will be returned.
2181
- LIBHEIF_API
2182
- struct heif_error heif_context_get_encoder_for_format(struct heif_context* context,
2183
- enum heif_compression_format format,
2184
- struct heif_encoder**);
2185
-
2186
- // You have to release the encoder after use.
2187
- LIBHEIF_API
2188
- void heif_encoder_release(struct heif_encoder*);
2189
-
2190
- // Get the encoder name from the encoder itself.
2191
- LIBHEIF_API
2192
- const char* heif_encoder_get_name(const struct heif_encoder*);
2193
-
2194
-
2195
- // --- Encoder Parameters ---
2196
-
2197
- // Libheif supports settings parameters through specialized functions and through
2198
- // generic functions by parameter name. Sometimes, the same parameter can be set
2199
- // in both ways.
2200
- // We consider it best practice to use the generic parameter functions only in
2201
- // dynamically generated user interfaces, as no guarantees are made that some specific
2202
- // parameter names are supported by all plugins.
2203
-
2204
-
2205
- // Set a 'quality' factor (0-100). How this is mapped to actual encoding parameters is
2206
- // encoder dependent.
2207
- LIBHEIF_API
2208
- struct heif_error heif_encoder_set_lossy_quality(struct heif_encoder*, int quality);
2209
-
2210
- LIBHEIF_API
2211
- struct heif_error heif_encoder_set_lossless(struct heif_encoder*, int enable);
2212
-
2213
- // level should be between 0 (= none) to 4 (= full)
2214
- LIBHEIF_API
2215
- struct heif_error heif_encoder_set_logging_level(struct heif_encoder*, int level);
2216
-
2217
- // Get a generic list of encoder parameters.
2218
- // Each encoder may define its own, additional set of parameters.
2219
- // You do not have to free the returned list.
2220
- LIBHEIF_API
2221
- const struct heif_encoder_parameter* const* heif_encoder_list_parameters(struct heif_encoder*);
2222
-
2223
- // Return the parameter name.
2224
- LIBHEIF_API
2225
- const char* heif_encoder_parameter_get_name(const struct heif_encoder_parameter*);
2226
-
2227
-
2228
- enum heif_encoder_parameter_type
2229
- {
2230
- heif_encoder_parameter_type_integer = 1,
2231
- heif_encoder_parameter_type_boolean = 2,
2232
- heif_encoder_parameter_type_string = 3
2233
- };
2234
-
2235
- // Return the parameter type.
2236
- LIBHEIF_API
2237
- enum heif_encoder_parameter_type heif_encoder_parameter_get_type(const struct heif_encoder_parameter*);
2238
-
2239
- // DEPRECATED. Use heif_encoder_parameter_get_valid_integer_values() instead.
2240
- LIBHEIF_API
2241
- struct heif_error heif_encoder_parameter_get_valid_integer_range(const struct heif_encoder_parameter*,
2242
- int* have_minimum_maximum,
2243
- int* minimum, int* maximum);
2244
-
2245
- // If integer is limited by a range, have_minimum and/or have_maximum will be != 0 and *minimum, *maximum is set.
2246
- // If integer is limited by a fixed set of values, *num_valid_values will be >0 and *out_integer_array is set.
2247
- LIBHEIF_API
2248
- struct heif_error heif_encoder_parameter_get_valid_integer_values(const struct heif_encoder_parameter*,
2249
- int* have_minimum, int* have_maximum,
2250
- int* minimum, int* maximum,
2251
- int* num_valid_values,
2252
- const int** out_integer_array);
2253
-
2254
- LIBHEIF_API
2255
- struct heif_error heif_encoder_parameter_get_valid_string_values(const struct heif_encoder_parameter*,
2256
- const char* const** out_stringarray);
2257
-
2258
-
2259
- LIBHEIF_API
2260
- struct heif_error heif_encoder_set_parameter_integer(struct heif_encoder*,
2261
- const char* parameter_name,
2262
- int value);
2263
-
2264
- LIBHEIF_API
2265
- struct heif_error heif_encoder_get_parameter_integer(struct heif_encoder*,
2266
- const char* parameter_name,
2267
- int* value);
2268
-
2269
- // TODO: name should be changed to heif_encoder_get_valid_integer_parameter_range
2270
- LIBHEIF_API // DEPRECATED.
2271
- struct heif_error heif_encoder_parameter_integer_valid_range(struct heif_encoder*,
2272
- const char* parameter_name,
2273
- int* have_minimum_maximum,
2274
- int* minimum, int* maximum);
2275
-
2276
- LIBHEIF_API
2277
- struct heif_error heif_encoder_set_parameter_boolean(struct heif_encoder*,
2278
- const char* parameter_name,
2279
- int value);
2280
-
2281
- LIBHEIF_API
2282
- struct heif_error heif_encoder_get_parameter_boolean(struct heif_encoder*,
2283
- const char* parameter_name,
2284
- int* value);
2285
-
2286
- LIBHEIF_API
2287
- struct heif_error heif_encoder_set_parameter_string(struct heif_encoder*,
2288
- const char* parameter_name,
2289
- const char* value);
2290
-
2291
- LIBHEIF_API
2292
- struct heif_error heif_encoder_get_parameter_string(struct heif_encoder*,
2293
- const char* parameter_name,
2294
- char* value, int value_size);
2295
-
2296
- // returns a NULL-terminated list of valid strings or NULL if all values are allowed
2297
- LIBHEIF_API
2298
- struct heif_error heif_encoder_parameter_string_valid_values(struct heif_encoder*,
2299
- const char* parameter_name,
2300
- const char* const** out_stringarray);
2301
-
2302
- LIBHEIF_API
2303
- struct heif_error heif_encoder_parameter_integer_valid_values(struct heif_encoder*,
2304
- const char* parameter_name,
2305
- int* have_minimum, int* have_maximum,
2306
- int* minimum, int* maximum,
2307
- int* num_valid_values,
2308
- const int** out_integer_array);
2309
-
2310
- // Set a parameter of any type to the string value.
2311
- // Integer values are parsed from the string.
2312
- // Boolean values can be "true"/"false"/"1"/"0"
2313
- //
2314
- // x265 encoder specific note:
2315
- // When using the x265 encoder, you may pass any of its parameters by
2316
- // prefixing the parameter name with 'x265:'. Hence, to set the 'ctu' parameter,
2317
- // you will have to set 'x265:ctu' in libheif.
2318
- // Note that there is no checking for valid parameters when using the prefix.
2319
- LIBHEIF_API
2320
- struct heif_error heif_encoder_set_parameter(struct heif_encoder*,
2321
- const char* parameter_name,
2322
- const char* value);
2323
-
2324
- // Get the current value of a parameter of any type as a human readable string.
2325
- // The returned string is compatible with heif_encoder_set_parameter().
2326
- LIBHEIF_API
2327
- struct heif_error heif_encoder_get_parameter(struct heif_encoder*,
2328
- const char* parameter_name,
2329
- char* value_ptr, int value_size);
2330
-
2331
- // Query whether a specific parameter has a default value.
2332
- LIBHEIF_API
2333
- int heif_encoder_has_default(struct heif_encoder*,
2334
- const char* parameter_name);
2335
-
2336
-
2337
- // The orientation values are defined equal to the EXIF Orientation tag.
2338
- enum heif_orientation
2339
- {
2340
- heif_orientation_normal = 1,
2341
- heif_orientation_flip_horizontally = 2,
2342
- heif_orientation_rotate_180 = 3,
2343
- heif_orientation_flip_vertically = 4,
2344
- heif_orientation_rotate_90_cw_then_flip_horizontally = 5,
2345
- heif_orientation_rotate_90_cw = 6,
2346
- heif_orientation_rotate_90_cw_then_flip_vertically = 7,
2347
- heif_orientation_rotate_270_cw = 8
2348
- };
2349
-
2350
-
2351
- struct heif_encoding_options
2352
- {
2353
- uint8_t version;
2354
-
2355
- // version 1 options
2356
-
2357
- uint8_t save_alpha_channel; // default: true
2358
-
2359
- // version 2 options
2360
-
2361
- // DEPRECATED. This option is not required anymore. Its value will be ignored.
2362
- uint8_t macOS_compatibility_workaround;
2363
-
2364
- // version 3 options
2365
-
2366
- uint8_t save_two_colr_boxes_when_ICC_and_nclx_available; // default: false
2367
-
2368
- // version 4 options
2369
-
2370
- // Set this to the NCLX parameters to be used in the output image or set to NULL
2371
- // when the same parameters as in the input image should be used.
2372
- struct heif_color_profile_nclx* output_nclx_profile;
2373
-
2374
- uint8_t macOS_compatibility_workaround_no_nclx_profile;
2375
-
2376
- // version 5 options
2377
-
2378
- // libheif will generate irot/imir boxes to match these orientations
2379
- enum heif_orientation image_orientation;
2380
-
2381
- // version 6 options
2382
-
2383
- struct heif_color_conversion_options color_conversion_options;
2384
-
2385
- // version 7 options
2386
-
2387
- // Set this to true to use compressed form of uncC where possible.
2388
- uint8_t prefer_uncC_short_form;
2389
-
2390
- // TODO: we should add a flag to force MIAF compatible outputs. E.g. this will put restrictions on grid tile sizes and
2391
- // might add a clap box when the grid output size does not match the color subsampling factors.
2392
- // Since some of these constraints have to be known before actually encoding the image, "forcing MIAF compatibility"
2393
- // could also be a flag in the heif_context.
2394
- };
2395
-
2396
- LIBHEIF_API
2397
- struct heif_encoding_options* heif_encoding_options_alloc(void);
2398
-
2399
- LIBHEIF_API
2400
- void heif_encoding_options_free(struct heif_encoding_options*);
2401
-
2402
-
2403
- // Compress the input image.
2404
- // Returns a handle to the coded image in 'out_image_handle' unless out_image_handle = NULL.
2405
- // 'options' should be NULL for now.
2406
- // The first image added to the context is also automatically set the primary image, but
2407
- // you can change the primary image later with heif_context_set_primary_image().
2408
- LIBHEIF_API
2409
- struct heif_error heif_context_encode_image(struct heif_context*,
2410
- const struct heif_image* image,
2411
- struct heif_encoder* encoder,
2412
- const struct heif_encoding_options* options,
2413
- struct heif_image_handle** out_image_handle);
2414
-
2415
- /**
2416
- * @brief Encodes an array of images into a grid.
2417
- *
2418
- * @param ctx The file context
2419
- * @param tiles User allocated array of images that will form the grid.
2420
- * @param rows The number of rows in the grid.
2421
- * @param columns The number of columns in the grid.
2422
- * @param encoder Defines the encoder to use. See heif_context_get_encoder_for_format()
2423
- * @param input_options Optional, may be nullptr.
2424
- * @param out_image_handle Returns a handle to the grid. The caller is responsible for freeing it.
2425
- * @return Returns an error if ctx, tiles, or encoder is nullptr. If rows or columns is 0.
2426
- */
2427
- LIBHEIF_API
2428
- struct heif_error heif_context_encode_grid(struct heif_context* ctx,
2429
- struct heif_image** tiles,
2430
- uint16_t rows,
2431
- uint16_t columns,
2432
- struct heif_encoder* encoder,
2433
- const struct heif_encoding_options* input_options,
2434
- struct heif_image_handle** out_image_handle);
2435
-
2436
- LIBHEIF_API
2437
- struct heif_error heif_context_add_grid_image(struct heif_context* ctx,
2438
- uint32_t image_width,
2439
- uint32_t image_height,
2440
- uint32_t tile_columns,
2441
- uint32_t tile_rows,
2442
- const struct heif_encoding_options* encoding_options,
2443
- struct heif_image_handle** out_grid_image_handle);
2444
-
2445
- LIBHEIF_API
2446
- struct heif_error heif_context_add_image_tile(struct heif_context* ctx,
2447
- struct heif_image_handle* tiled_image,
2448
- uint32_t tile_x, uint32_t tile_y,
2449
- const struct heif_image* image,
2450
- struct heif_encoder* encoder);
2451
-
2452
- // offsets[] should either be NULL (all offsets==0) or an array of size 2*nImages with x;y offset pairs.
2453
- // If background_rgba is NULL, the background is transparent.
2454
- LIBHEIF_API
2455
- struct heif_error heif_context_add_overlay_image(struct heif_context* ctx,
2456
- uint32_t image_width,
2457
- uint32_t image_height,
2458
- uint16_t nImages,
2459
- const heif_item_id* image_ids,
2460
- int32_t* offsets,
2461
- const uint16_t background_rgba[4],
2462
- struct heif_image_handle** out_iovl_image_handle);
2463
-
2464
- LIBHEIF_API
2465
- struct heif_error heif_context_set_primary_image(struct heif_context*,
2466
- struct heif_image_handle* image_handle);
2467
-
2468
- // Encode the 'image' as a scaled down thumbnail image.
2469
- // The image is scaled down to fit into a square area of width 'bbox_size'.
2470
- // If the input image is already so small that it fits into this bounding box, no thumbnail
2471
- // image is encoded and NULL is returned in 'out_thumb_image_handle'.
2472
- // No error is returned in this case.
2473
- // The encoded thumbnail is automatically assigned to the 'master_image_handle'. Hence, you
2474
- // do not have to call heif_context_assign_thumbnail().
2475
- LIBHEIF_API
2476
- struct heif_error heif_context_encode_thumbnail(struct heif_context*,
2477
- const struct heif_image* image,
2478
- const struct heif_image_handle* master_image_handle,
2479
- struct heif_encoder* encoder,
2480
- const struct heif_encoding_options* options,
2481
- int bbox_size,
2482
- struct heif_image_handle** out_thumb_image_handle);
2483
-
2484
- // Assign 'thumbnail_image' as the thumbnail image of 'master_image'.
2485
- LIBHEIF_API
2486
- struct heif_error heif_context_assign_thumbnail(struct heif_context*,
2487
- const struct heif_image_handle* master_image,
2488
- const struct heif_image_handle* thumbnail_image);
2489
-
2490
- // Add EXIF metadata to an image.
2491
- LIBHEIF_API
2492
- struct heif_error heif_context_add_exif_metadata(struct heif_context*,
2493
- const struct heif_image_handle* image_handle,
2494
- const void* data, int size);
2495
-
2496
- // Add XMP metadata to an image.
2497
- LIBHEIF_API
2498
- struct heif_error heif_context_add_XMP_metadata(struct heif_context*,
2499
- const struct heif_image_handle* image_handle,
2500
- const void* data, int size);
2501
-
2502
- // New version of heif_context_add_XMP_metadata() with data compression (experimental).
2503
- LIBHEIF_API
2504
- struct heif_error heif_context_add_XMP_metadata2(struct heif_context*,
2505
- const struct heif_image_handle* image_handle,
2506
- const void* data, int size,
2507
- enum heif_metadata_compression compression);
2508
-
2509
- // Add generic, proprietary metadata to an image. You have to specify an 'item_type' that will
2510
- // identify your metadata. 'content_type' can be an additional type, or it can be NULL.
2511
- // For example, this function can be used to add IPTC metadata (IIM stream, not XMP) to an image.
2512
- // Although not standard, we propose to store IPTC data with item type="iptc", content_type=NULL.
2513
- LIBHEIF_API
2514
- struct heif_error heif_context_add_generic_metadata(struct heif_context* ctx,
2515
- const struct heif_image_handle* image_handle,
2516
- const void* data, int size,
2517
- const char* item_type, const char* content_type);
2518
-
2519
- // Add generic metadata with item_type "uri ". Items with this type do not have a content_type, but
2520
- // an item_uri_type and they have no content_encoding (they are always stored uncompressed).
2521
- LIBHEIF_API
2522
- struct heif_error heif_context_add_generic_uri_metadata(struct heif_context* ctx,
2523
- const struct heif_image_handle* image_handle,
2524
- const void* data, int size,
2525
- const char* item_uri_type,
2526
- heif_item_id* out_item_id);
2527
-
2528
- // --- heif_image allocation
2529
-
2530
- /**
2531
- * Create a new image of the specified resolution and colorspace.
2532
- *
2533
- * <p>This does not allocate memory for the image data. Use {@link heif_image_add_plane} to
2534
- * add the corresponding planes to match the specified {@code colorspace} and {@code chroma}.
2535
- *
2536
- * @param width the width of the image in pixels
2537
- * @param height the height of the image in pixels
2538
- * @param colorspace the colorspace of the image
2539
- * @param chroma the chroma of the image
2540
- * @param out_image pointer to pointer of the resulting image
2541
- * @return whether the creation succeeded or there was an error
2542
- */
2543
- LIBHEIF_API
2544
- struct heif_error heif_image_create(int width, int height,
2545
- enum heif_colorspace colorspace,
2546
- enum heif_chroma chroma,
2547
- struct heif_image** out_image);
2548
-
2549
- /**
2550
- * Add an image plane to the image.
2551
- *
2552
- * <p>The image plane needs to match the colorspace and chroma of the image. Note
2553
- * that this does not need to be a single "planar" format - interleaved pixel channels
2554
- * can also be used if the chroma is interleaved.
2555
- *
2556
- * <p>The indicated bit_depth corresponds to the bit depth per channel. For example,
2557
- * with an interleaved format like RRGGBB where each color is represented by 10 bits,
2558
- * the {@code bit_depth} would be {@code 10} rather than {@code 30}.
2559
- *
2560
- * <p>For backward compatibility, one can also specify 24bits for RGB and 32bits for RGBA,
2561
- * instead of the preferred 8 bits. However, this use is deprecated.
2562
- *
2563
- * @param image the parent image to add the channel plane to
2564
- * @param channel the channel of the plane to add
2565
- * @param width the width of the plane
2566
- * @param height the height of the plane
2567
- * @param bit_depth the bit depth per color channel
2568
- * @return whether the addition succeeded or there was an error
2569
- *
2570
- * @note The width and height are usually the same as the parent image, but can be
2571
- * less for subsampling.
2572
- *
2573
- * @note The specified width can differ from the row stride of the resulting image plane.
2574
- * Always use the result of {@link heif_image_get_plane} or {@link heif_image_get_plane_readonly}
2575
- * to determine row stride.
2576
- */
2577
- LIBHEIF_API
2578
- struct heif_error heif_image_add_plane(struct heif_image* image,
2579
- enum heif_channel channel,
2580
- int width, int height, int bit_depth);
2581
-
2582
- // Signal that the image is premultiplied by the alpha pixel values.
2583
- LIBHEIF_API
2584
- void heif_image_set_premultiplied_alpha(struct heif_image* image,
2585
- int is_premultiplied_alpha);
2586
-
2587
- LIBHEIF_API
2588
- int heif_image_is_premultiplied_alpha(struct heif_image* image);
2589
-
2590
- // This function extends the padding of the image so that it has at least the given physical size.
2591
- // The padding border is filled with the pixels along the right/bottom border.
2592
- // This function may be useful if you want to process the image, but have some external padding requirements.
2593
- // The image size will not be modified if it is already larger/equal than the given physical size.
2594
- // I.e. you cannot assume that after calling this function, the stride will be equal to min_physical_width.
2595
- LIBHEIF_API
2596
- struct heif_error heif_image_extend_padding_to_size(struct heif_image* image, int min_physical_width, int min_physical_height);
2597
-
2598
-
2599
-
2600
- // --- register plugins
2601
-
2602
- struct heif_decoder_plugin;
2603
- struct heif_encoder_plugin;
2604
-
2605
- // DEPRECATED. Use heif_register_decoder_plugin(const struct heif_decoder_plugin*) instead.
2606
- LIBHEIF_API
2607
- struct heif_error heif_register_decoder(struct heif_context* heif, const struct heif_decoder_plugin*);
2608
-
2609
- LIBHEIF_API
2610
- struct heif_error heif_register_decoder_plugin(const struct heif_decoder_plugin*);
2611
-
2612
- LIBHEIF_API
2613
- struct heif_error heif_register_encoder_plugin(const struct heif_encoder_plugin*);
2614
-
2615
- // DEPRECATED, typo in function name
2616
- LIBHEIF_API
2617
- int heif_encoder_descriptor_supportes_lossy_compression(const struct heif_encoder_descriptor*);
2618
-
2619
- // DEPRECATED, typo in function name
2620
- LIBHEIF_API
2621
- int heif_encoder_descriptor_supportes_lossless_compression(const struct heif_encoder_descriptor*);
2622
-
2623
-
2624
- #ifdef __cplusplus
2625
- }
2626
- #endif
26
+ #include <libheif/heif_image.h>
27
+ #include <libheif/heif_color.h>
28
+ #include <libheif/heif_error.h>
29
+ #include <libheif/heif_brands.h>
30
+
31
+ #include <libheif/heif_metadata.h>
32
+ #include <libheif/heif_aux_images.h>
33
+ #include <libheif/heif_entity_groups.h>
34
+ #include <libheif/heif_security.h>
35
+ #include <libheif/heif_encoding.h>
36
+ #include <libheif/heif_decoding.h>
37
+ #include <libheif/heif_context.h>
38
+ #include <libheif/heif_image_handle.h>
39
+ #include <libheif/heif_tiling.h>
2627
40
 
2628
41
  #endif