@img/sharp-libvips-dev-wasm32 1.3.0-rc.6 → 1.3.0-rc.8

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 (153) hide show
  1. package/README.md +23 -23
  2. package/include/aom/aom_codec.h +1 -1
  3. package/include/aom/aom_decoder.h +4 -0
  4. package/include/aom/aom_encoder.h +19 -8
  5. package/include/aom/aom_ext_ratectrl.h +664 -0
  6. package/include/aom/aom_image.h +93 -30
  7. package/include/aom/aom_tpl.h +99 -0
  8. package/include/aom/aomcx.h +89 -16
  9. package/include/aom/aomdx.h +12 -0
  10. package/include/expat.h +14 -2
  11. package/include/expat_config.h +6 -3
  12. package/include/expat_external.h +3 -2
  13. package/include/glib-2.0/gio/gdbusconnection.h +2 -8
  14. package/include/glib-2.0/gio/gio-visibility.h +34 -0
  15. package/include/glib-2.0/gio/gioenums.h +5 -4
  16. package/include/glib-2.0/glib/glib-visibility.h +34 -0
  17. package/include/glib-2.0/glib/gmacros.h +3 -3
  18. package/include/glib-2.0/glib/gmarkup.h +10 -0
  19. package/include/glib-2.0/glib/gmem.h +4 -4
  20. package/include/glib-2.0/glib/gmessages.h +6 -8
  21. package/include/glib-2.0/glib/gsequence.h +2 -2
  22. package/include/glib-2.0/glib/gstrfuncs.h +190 -0
  23. package/include/glib-2.0/glib/gutils.h +9 -0
  24. package/include/glib-2.0/glib/gvarianttype.h +16 -16
  25. package/include/glib-2.0/glib/gversionmacros.h +22 -0
  26. package/include/glib-2.0/gmodule/gmodule-visibility.h +34 -0
  27. package/include/glib-2.0/gobject/gobject-visibility.h +34 -0
  28. package/include/glib-2.0/gobject/gsignal.h +5 -5
  29. package/include/glib-2.0/gobject/gtype.h +14 -14
  30. package/include/hwy/aligned_allocator.h +44 -2
  31. package/include/hwy/auto_tune.h +22 -6
  32. package/include/hwy/base.h +60 -90
  33. package/include/hwy/bit_set.h +410 -0
  34. package/include/hwy/cache_control.h +3 -2
  35. package/include/hwy/detect_compiler_arch.h +134 -14
  36. package/include/hwy/detect_targets.h +82 -36
  37. package/include/hwy/highway.h +15 -0
  38. package/include/hwy/nanobenchmark.h +12 -3
  39. package/include/hwy/ops/arm_neon-inl.h +96 -25
  40. package/include/hwy/ops/arm_sve-inl.h +250 -95
  41. package/include/hwy/ops/emu128-inl.h +12 -7
  42. package/include/hwy/ops/generic_ops-inl.h +271 -131
  43. package/include/hwy/ops/loongarch_lasx-inl.h +31 -9
  44. package/include/hwy/ops/loongarch_lsx-inl.h +33 -12
  45. package/include/hwy/ops/ppc_vsx-inl.h +99 -19
  46. package/include/hwy/ops/rvv-inl.h +239 -130
  47. package/include/hwy/ops/scalar-inl.h +22 -7
  48. package/include/hwy/ops/set_macros-inl.h +163 -107
  49. package/include/hwy/ops/wasm_128-inl.h +13 -22
  50. package/include/hwy/ops/x86_128-inl.h +223 -120
  51. package/include/hwy/ops/x86_256-inl.h +70 -134
  52. package/include/hwy/ops/x86_512-inl.h +130 -134
  53. package/include/hwy/print-inl.h +2 -0
  54. package/include/hwy/profiler.h +355 -264
  55. package/include/hwy/robust_statistics.h +3 -1
  56. package/include/hwy/timer.h +44 -0
  57. package/include/lcms2.h +34 -4
  58. package/include/libexif/exif-utils.h +1 -1
  59. package/include/libheif/heif.h +2 -0
  60. package/include/libheif/heif_color.h +127 -11
  61. package/include/libheif/heif_components.h +264 -0
  62. package/include/libheif/heif_context.h +2 -1
  63. package/include/libheif/heif_cxx.h +10 -10
  64. package/include/libheif/heif_decoding.h +51 -7
  65. package/include/libheif/heif_encoding.h +15 -9
  66. package/include/libheif/heif_error.h +9 -2
  67. package/include/libheif/heif_export.h +48 -0
  68. package/include/libheif/heif_image.h +81 -66
  69. package/include/libheif/heif_image_handle.h +2 -2
  70. package/include/libheif/heif_items.h +1 -1
  71. package/include/libheif/heif_library.h +8 -16
  72. package/include/libheif/heif_omaf.h +104 -0
  73. package/include/libheif/heif_plugin.h +16 -9
  74. package/include/libheif/heif_properties.h +250 -12
  75. package/include/libheif/heif_security.h +16 -4
  76. package/include/libheif/heif_sequences.h +86 -4
  77. package/include/libheif/heif_tiling.h +2 -2
  78. package/include/libheif/heif_uncompressed.h +44 -324
  79. package/include/libheif/heif_version.h +2 -2
  80. package/include/libpng16/png.h +7 -7
  81. package/include/libpng16/pngconf.h +1 -1
  82. package/include/libpng16/pnglibconf.h +1 -1
  83. package/include/png.h +7 -7
  84. package/include/pngconf.h +1 -1
  85. package/include/pnglibconf.h +1 -1
  86. package/include/tiffconf.h +9 -10
  87. package/include/tiffio.h +10 -9
  88. package/include/tiffvers.h +1 -1
  89. package/include/ultrahdr_api.h +5 -11
  90. package/include/vips/version.h +4 -4
  91. package/lib/glib-2.0/include/glibconfig.h +1 -3
  92. package/lib/libaom.a +0 -0
  93. package/lib/libcgif.a +0 -0
  94. package/lib/libexif.a +0 -0
  95. package/lib/libexif.la +1 -1
  96. package/lib/libexpat.a +0 -0
  97. package/lib/libexpat.la +3 -3
  98. package/lib/libffi.a +0 -0
  99. package/lib/libgio-2.0.a +0 -0
  100. package/lib/libglib-2.0.a +0 -0
  101. package/lib/libgmodule-2.0.a +0 -0
  102. package/lib/libgobject-2.0.a +0 -0
  103. package/lib/libgthread-2.0.a +0 -0
  104. package/lib/libheif.a +0 -0
  105. package/lib/libhwy.a +0 -0
  106. package/lib/libimagequant.a +0 -0
  107. package/lib/libjpeg.a +0 -0
  108. package/lib/liblcms2.a +0 -0
  109. package/lib/libpng.a +0 -0
  110. package/lib/libpng.la +2 -2
  111. package/lib/libpng16.a +0 -0
  112. package/lib/libpng16.la +2 -2
  113. package/lib/libresvg.a +0 -0
  114. package/lib/libsharpyuv.a +0 -0
  115. package/lib/libtiff.a +0 -0
  116. package/lib/libuhdr.a +0 -0
  117. package/lib/libvips-cpp.a +0 -0
  118. package/lib/libvips.a +0 -0
  119. package/lib/libwebp.a +0 -0
  120. package/lib/libwebpdecoder.a +0 -0
  121. package/lib/libwebpdemux.a +0 -0
  122. package/lib/libwebpmux.a +0 -0
  123. package/lib/libz.a +0 -0
  124. package/lib/pkgconfig/aom.pc +2 -2
  125. package/lib/pkgconfig/expat.pc +1 -1
  126. package/lib/pkgconfig/gio-2.0.pc +1 -1
  127. package/lib/pkgconfig/glib-2.0.pc +1 -1
  128. package/lib/pkgconfig/gmodule-2.0.pc +1 -1
  129. package/lib/pkgconfig/gmodule-export-2.0.pc +1 -1
  130. package/lib/pkgconfig/gmodule-no-export-2.0.pc +1 -1
  131. package/lib/pkgconfig/gobject-2.0.pc +1 -1
  132. package/lib/pkgconfig/gthread-2.0.pc +1 -1
  133. package/lib/pkgconfig/lcms2.pc +1 -1
  134. package/lib/pkgconfig/libexif.pc +1 -1
  135. package/lib/pkgconfig/libheif.pc +2 -2
  136. package/lib/pkgconfig/libhwy.pc +3 -4
  137. package/lib/pkgconfig/libpng.pc +1 -1
  138. package/lib/pkgconfig/libpng16.pc +1 -1
  139. package/lib/pkgconfig/libsharpyuv.pc +1 -1
  140. package/lib/pkgconfig/libtiff-4.pc +2 -2
  141. package/lib/pkgconfig/libwebp.pc +1 -1
  142. package/lib/pkgconfig/libwebpdecoder.pc +11 -0
  143. package/lib/pkgconfig/libwebpmux.pc +1 -1
  144. package/lib/pkgconfig/vips-cpp.pc +1 -1
  145. package/lib/pkgconfig/vips.pc +1 -1
  146. package/package.json +1 -1
  147. package/versions.json +12 -12
  148. package/include/libheif/heif_uncompressed_types.h +0 -143
  149. package/lib/libsharpyuv.la +0 -41
  150. package/lib/libtiff.la +0 -41
  151. package/lib/libwebp.la +0 -41
  152. package/lib/libwebpdemux.la +0 -41
  153. package/lib/libwebpmux.la +0 -41
@@ -323,8 +323,8 @@ namespace heif {
323
323
 
324
324
  // throws Error
325
325
  void create(int width, int height,
326
- enum heif_colorspace colorspace,
327
- enum heif_chroma chroma);
326
+ heif_colorspace colorspace,
327
+ heif_chroma chroma);
328
328
 
329
329
  // throws Error
330
330
  void add_plane(enum heif_channel channel,
@@ -391,14 +391,14 @@ namespace heif {
391
391
  {
392
392
  public:
393
393
  static std::vector<EncoderDescriptor>
394
- get_encoder_descriptors(enum heif_compression_format format_filter,
394
+ get_encoder_descriptors(heif_compression_format format_filter,
395
395
  const char* name_filter) noexcept;
396
396
 
397
397
  std::string get_name() const noexcept;
398
398
 
399
399
  std::string get_id_name() const noexcept;
400
400
 
401
- enum heif_compression_format get_compression_format() const noexcept;
401
+ heif_compression_format get_compression_format() const noexcept;
402
402
 
403
403
  // DEPRECATED: typo in function name
404
404
  bool supportes_lossy_compression() const noexcept;
@@ -453,7 +453,7 @@ namespace heif {
453
453
  {
454
454
  public:
455
455
  // throws Error
456
- Encoder(enum heif_compression_format format);
456
+ Encoder(heif_compression_format format);
457
457
 
458
458
  // throws Error
459
459
  void set_lossy_quality(int quality);
@@ -859,8 +859,8 @@ namespace heif {
859
859
 
860
860
 
861
861
  inline void Image::create(int width, int height,
862
- enum heif_colorspace colorspace,
863
- enum heif_chroma chroma)
862
+ heif_colorspace colorspace,
863
+ heif_chroma chroma)
864
864
  {
865
865
  heif_image* image;
866
866
  Error err = Error(heif_image_create(width, height, colorspace, chroma, &image));
@@ -1023,7 +1023,7 @@ namespace heif {
1023
1023
 
1024
1024
 
1025
1025
  inline std::vector<EncoderDescriptor>
1026
- EncoderDescriptor::get_encoder_descriptors(enum heif_compression_format format_filter,
1026
+ EncoderDescriptor::get_encoder_descriptors(heif_compression_format format_filter,
1027
1027
  const char* name_filter) noexcept
1028
1028
  {
1029
1029
  int maxDescriptors = 10;
@@ -1066,7 +1066,7 @@ namespace heif {
1066
1066
  return heif_encoder_descriptor_get_id_name(m_descriptor);
1067
1067
  }
1068
1068
 
1069
- inline enum heif_compression_format EncoderDescriptor::get_compression_format() const noexcept
1069
+ inline heif_compression_format EncoderDescriptor::get_compression_format() const noexcept
1070
1070
  {
1071
1071
  return heif_encoder_descriptor_get_compression_format(m_descriptor);
1072
1072
  }
@@ -1103,7 +1103,7 @@ namespace heif {
1103
1103
  }
1104
1104
 
1105
1105
 
1106
- inline Encoder::Encoder(enum heif_compression_format format)
1106
+ inline Encoder::Encoder(heif_compression_format format)
1107
1107
  {
1108
1108
  heif_encoder* encoder;
1109
1109
  Error err = Error(heif_context_get_encoder_for_format(nullptr, format, &encoder));
@@ -39,11 +39,18 @@ extern "C" {
39
39
  LIBHEIF_API
40
40
  void heif_context_set_max_decoding_threads(heif_context* ctx, int max_threads);
41
41
 
42
+ // Returns the current maximum number of background threads used for parallel tile decoding.
43
+ // This reflects either the library default or the value last passed to
44
+ // heif_context_set_max_decoding_threads().
45
+ // If 'ctx' is NULL, the library default is returned.
46
+ LIBHEIF_API
47
+ int heif_context_get_max_decoding_threads(const heif_context* ctx);
48
+
42
49
  // Quick check whether there is a decoder available for the given format.
43
50
  // Note that the decoder still may not be able to decode all variants of that format.
44
51
  // You will have to query that further (todo) or just try to decode and check the returned error.
45
52
  LIBHEIF_API
46
- int heif_have_decoder_for_format(enum heif_compression_format format);
53
+ int heif_have_decoder_for_format(heif_compression_format format);
47
54
 
48
55
 
49
56
  typedef enum heif_progress_step
@@ -64,11 +71,11 @@ typedef struct heif_decoding_options
64
71
  uint8_t ignore_transformations;
65
72
 
66
73
  // Any of the progress functions may be called from background threads.
67
- void (* start_progress)(enum heif_progress_step step, int max_progress, void* progress_user_data);
74
+ void (* start_progress)(heif_progress_step step, int max_progress, void* progress_user_data);
68
75
 
69
- void (* on_progress)(enum heif_progress_step step, int progress, void* progress_user_data);
76
+ void (* on_progress)(heif_progress_step step, int progress, void* progress_user_data);
70
77
 
71
- void (* end_progress)(enum heif_progress_step step, void* progress_user_data);
78
+ void (* end_progress)(heif_progress_step step, void* progress_user_data);
72
79
 
73
80
  void* progress_user_data;
74
81
 
@@ -107,10 +114,47 @@ typedef struct heif_decoding_options
107
114
  // If enabled, it will decode the media timeline, ignoring the sequence tracks edit-list.
108
115
  int ignore_sequence_editlist; // bool
109
116
 
117
+ // Requested NCLX color profile of the decoded output image. If the input
118
+ // image's NCLX differs, libheif will color-convert the pixels accordingly
119
+ // (e.g. YCbCr matrix, primaries, range) so the result matches what is
120
+ // requested here.
121
+ //
122
+ // When set to NULL, the behavior depends on the flag
123
+ // output_image_nclx_profile_passthrough below: by default NULL means
124
+ // "convert to sRGB"; with the passthrough flag enabled, NULL means
125
+ // "keep the input image's NCLX".
110
126
  heif_color_profile_nclx* output_image_nclx_profile;
111
127
 
112
128
  int num_library_threads; // 0 = let libheif decide (TODO, currently ignored)
113
129
  int num_codec_threads; // 0 = use decoder default
130
+
131
+ // version 9 options
132
+
133
+ // If enabled, libheif will attempt to work around known broken-input quirks
134
+ // (e.g. Sony HIF files where the NCLX `colr` box disagrees with the HEVC VUI
135
+ // on the YCbCr range flag). Default: false (strict spec-conformant behavior).
136
+ uint8_t autocorrect_broken_input;
137
+
138
+ // version 10 options
139
+
140
+ // Controls the meaning of output_image_nclx_profile == NULL.
141
+ //
142
+ // When false (default), a NULL output_image_nclx_profile means "convert the
143
+ // decoded image to sRGB" (BT.709 primaries, sRGB transfer, BT.601 matrix,
144
+ // full-range). For HDR inputs (e.g. BT.2100 PQ) this silently discards the
145
+ // original color volume.
146
+ //
147
+ // When true, a NULL output_image_nclx_profile means "keep the input image's
148
+ // NCLX". The decoded image carries the input file's primaries / transfer /
149
+ // matrix / range, and no extra color-space conversion is performed solely
150
+ // because the output NCLX was unspecified. If a YCbCr<->RGB colorspace
151
+ // conversion fires for another reason, the input NCLX is used to drive that
152
+ // conversion (so the result is tagged consistently with the source).
153
+ //
154
+ // Although this flag is off by default to preserve historical behavior, new
155
+ // code that wants to preserve HDR through decode should generally enable it.
156
+ // Setting output_image_nclx_profile to a non-NULL value overrides this flag.
157
+ uint8_t output_image_nclx_profile_passthrough;
114
158
  } heif_decoding_options;
115
159
 
116
160
 
@@ -136,7 +180,7 @@ typedef struct heif_decoder_descriptor heif_decoder_descriptor;
136
180
  // The number of decoders is returned, which are not more than 'count' if (out_decoders != nullptr).
137
181
  // By setting out_decoders==nullptr, you can query the number of decoders, 'count' is ignored.
138
182
  LIBHEIF_API
139
- int heif_get_decoder_descriptors(enum heif_compression_format format_filter,
183
+ int heif_get_decoder_descriptors(heif_compression_format format_filter,
140
184
  const heif_decoder_descriptor** out_decoders,
141
185
  int count);
142
186
 
@@ -161,8 +205,8 @@ const char* heif_decoder_descriptor_get_id_name(const heif_decoder_descriptor*);
161
205
  LIBHEIF_API
162
206
  heif_error heif_decode_image(const heif_image_handle* in_handle,
163
207
  heif_image** out_img,
164
- enum heif_colorspace colorspace,
165
- enum heif_chroma chroma,
208
+ heif_colorspace colorspace,
209
+ heif_chroma chroma,
166
210
  const heif_decoding_options* options);
167
211
 
168
212
  #ifdef __cplusplus
@@ -33,7 +33,11 @@ extern "C" {
33
33
  #include <libheif/heif_context.h>
34
34
  #include <libheif/heif_brands.h>
35
35
  #include <libheif/heif_color.h>
36
- #include <libheif/heif_uncompressed_types.h>
36
+
37
+ // Forward declaration. The full definition lives in heif_uncompressed.h.
38
+ // heif_encoding_options only stores a pointer, so a forward typedef is enough here
39
+ // and avoids a circular include (heif_uncompressed.h pulls in heif.h, which pulls in this header).
40
+ typedef struct heif_unci_image_parameters heif_unci_image_parameters;
37
41
 
38
42
 
39
43
  // ----- encoder -----
@@ -56,7 +60,7 @@ typedef struct heif_encoder_parameter heif_encoder_parameter;
56
60
  // Note that the encoder may be limited to a certain subset of features (e.g. only 8 bit, only lossy).
57
61
  // You will have to query the specific capabilities further.
58
62
  LIBHEIF_API
59
- int heif_have_encoder_for_format(enum heif_compression_format format);
63
+ int heif_have_encoder_for_format(heif_compression_format format);
60
64
 
61
65
  // Get a list of available encoders. You can filter the encoders by compression format and name.
62
66
  // Use format_filter==heif_compression_undefined and name_filter==NULL as wildcards.
@@ -65,7 +69,7 @@ int heif_have_encoder_for_format(enum heif_compression_format format);
65
69
  // By setting out_encoders==nullptr, you can query the number of encoders, 'count' is ignored.
66
70
  // Note: to get the actual encoder from the descriptors returned here, use heif_context_get_encoder().
67
71
  LIBHEIF_API
68
- int heif_get_encoder_descriptors(enum heif_compression_format format_filter,
72
+ int heif_get_encoder_descriptors(heif_compression_format format_filter,
69
73
  const char* name_filter,
70
74
  const heif_encoder_descriptor** out_encoders,
71
75
  int count);
@@ -80,7 +84,7 @@ LIBHEIF_API
80
84
  const char* heif_encoder_descriptor_get_id_name(const heif_encoder_descriptor*);
81
85
 
82
86
  LIBHEIF_API
83
- enum heif_compression_format
87
+ heif_compression_format
84
88
  heif_encoder_descriptor_get_compression_format(const heif_encoder_descriptor*);
85
89
 
86
90
  LIBHEIF_API
@@ -100,7 +104,7 @@ heif_error heif_context_get_encoder(heif_context* context,
100
104
  // for this format, the encoder with the highest plugin priority will be returned.
101
105
  LIBHEIF_API
102
106
  heif_error heif_context_get_encoder_for_format(heif_context* context,
103
- enum heif_compression_format format,
107
+ heif_compression_format format,
104
108
  heif_encoder**);
105
109
 
106
110
  /**
@@ -315,9 +319,11 @@ typedef struct heif_encoding_options
315
319
 
316
320
  // version 8 options
317
321
 
318
- // Set this to enable compression for 'unci' images encoded through heif_context_encode_image().
319
- // Default: heif_unci_compression_off
320
- heif_unci_compression unci_compression;
322
+ // Optional 'unci'-specific encoding parameters (compression method, and future fields
323
+ // such as interleave type and padding).
324
+ //
325
+ // Default: nullptr
326
+ const heif_unci_image_parameters* unci_parameters;
321
327
 
322
328
  // TODO: we should add a flag to force MIAF compatible outputs. E.g. this will put restrictions on grid tile sizes and
323
329
  // might add a clap box when the grid output size does not match the color subsampling factors.
@@ -407,7 +413,7 @@ int heif_encoder_descriptor_supportes_lossless_compression(const heif_encoder_de
407
413
  // Note: to get the actual encoder from the descriptors returned here, use heif_context_get_encoder().
408
414
  LIBHEIF_API
409
415
  int heif_context_get_encoder_descriptors(heif_context*, // TODO: why do we need this parameter?
410
- enum heif_compression_format format_filter,
416
+ heif_compression_format format_filter,
411
417
  const char* name_filter,
412
418
  const heif_encoder_descriptor** out_encoders,
413
419
  int count);
@@ -28,6 +28,8 @@ extern "C" {
28
28
  #include <stddef.h>
29
29
  #include <stdint.h>
30
30
 
31
+ #include <libheif/heif_export.h>
32
+
31
33
 
32
34
  typedef enum heif_error_code
33
35
  {
@@ -191,6 +193,11 @@ typedef enum heif_suberror_code
191
193
 
192
194
  heif_suberror_No_moov_box = 151,
193
195
 
196
+ // The colr (NCLX) box and the codec bitstream VUI/color signalling disagree.
197
+ // Per ISO/IEC 14496-12 and ISO/IEC 23000-22 (MIAF) the colr box takes precedence,
198
+ // but the conflict is reported as a warning.
199
+ heif_suberror_NCLX_colr_VUI_mismatch = 152,
200
+
194
201
  // --- Memory_allocation_error ---
195
202
 
196
203
  // A security limit preventing unreasonable memory allocations was exceeded by the input file.
@@ -284,10 +291,10 @@ typedef enum heif_suberror_code
284
291
  typedef struct heif_error
285
292
  {
286
293
  // main error category
287
- enum heif_error_code code;
294
+ heif_error_code code;
288
295
 
289
296
  // more detailed error code
290
- enum heif_suberror_code subcode;
297
+ heif_suberror_code subcode;
291
298
 
292
299
  // textual error message (is always defined, you do not have to check for NULL)
293
300
  const char* message;
@@ -0,0 +1,48 @@
1
+ /*
2
+ * HEIF codec.
3
+ * Copyright (c) 2017-2026 Dirk Farin <dirk.farin@gmail.com>
4
+ *
5
+ * This file is part of libheif.
6
+ *
7
+ * libheif is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU Lesser General Public License as
9
+ * published by the Free Software Foundation, either version 3 of
10
+ * the License, or (at your option) any later version.
11
+ *
12
+ * libheif is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU Lesser General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public License
18
+ * along with libheif. If not, see <http://www.gnu.org/licenses/>.
19
+ */
20
+
21
+ #ifndef LIBHEIF_HEIF_EXPORT_H
22
+ #define LIBHEIF_HEIF_EXPORT_H
23
+
24
+ // LIBHEIF_API marks the symbols that are exported from the shared library.
25
+ //
26
+ // This macro lives in its own tiny, dependency-free header so that every
27
+ // public header can pull it in without creating include cycles. In particular,
28
+ // heif_library.h and heif_error.h are mutually dependent (heif_library.h needs
29
+ // the heif_error type while heif_error.h needs LIBHEIF_API), so the macro
30
+ // cannot live in either of them if both are to compile standalone.
31
+
32
+ #if (defined(_WIN32) || defined __CYGWIN__) && !defined(LIBHEIF_STATIC_BUILD)
33
+ #ifdef LIBHEIF_EXPORTS
34
+ #define LIBHEIF_API __declspec(dllexport)
35
+ #else
36
+ #define LIBHEIF_API __declspec(dllimport)
37
+ #endif
38
+ #elif defined(HAVE_VISIBILITY) && HAVE_VISIBILITY
39
+ #ifdef LIBHEIF_EXPORTS
40
+ #define LIBHEIF_API __attribute__((__visibility__("default")))
41
+ #else
42
+ #define LIBHEIF_API
43
+ #endif
44
+ #else
45
+ #define LIBHEIF_API
46
+ #endif
47
+
48
+ #endif // LIBHEIF_HEIF_EXPORT_H
@@ -31,10 +31,29 @@ extern "C" {
31
31
  #include <stdint.h>
32
32
 
33
33
 
34
+ // The heif_chroma enum describes pixel layout (planar vs interleaved, and any
35
+ // YUV chroma subsampling). It does NOT describe pixel semantics; the semantic
36
+ // interpretation of the planes comes from heif_colorspace.
37
+ //
38
+ // heif_chroma_planar covers "one or more planar components, no subsampling".
39
+ // It is used for:
40
+ // - heif_colorspace_monochrome (single luma plane)
41
+ // - heif_colorspace_filter_array (single CFA mosaic plane)
42
+ // - heif_colorspace_custom (any number of planar components)
43
+ // For heif_colorspace_RGB the historical name heif_chroma_444 is the
44
+ // canonical form for planar RGB. heif_chroma_planar is accepted as a
45
+ // synonym at the C API boundary and is internally canonicalized to
46
+ // heif_chroma_444 so existing callers and internal code paths keep seeing
47
+ // heif_chroma_444 on read-back. Callers should also accept a returned
48
+ // heif_chroma_planar as a synonym. We might switch to this as the
49
+ // canonical name in the future.
50
+ //
51
+ // The YUV subsampling names (heif_chroma_420 / _422 / _444) are kept for
52
+ // heif_colorspace_YCbCr.
34
53
  typedef enum heif_chroma
35
54
  {
36
55
  heif_chroma_undefined = 99,
37
- heif_chroma_monochrome = 0,
56
+ heif_chroma_planar = 0,
38
57
  heif_chroma_420 = 1,
39
58
  heif_chroma_422 = 2,
40
59
  heif_chroma_444 = 3,
@@ -50,6 +69,11 @@ typedef enum heif_chroma
50
69
  #define heif_chroma_interleaved_24bit heif_chroma_interleaved_RGB
51
70
  #define heif_chroma_interleaved_32bit heif_chroma_interleaved_RGBA
52
71
 
72
+ // Legacy alias for heif_chroma_planar. The name "monochrome" was misleading
73
+ // for non-grayscale planar layouts (filter_array, custom); use
74
+ // heif_chroma_planar in new code.
75
+ #define heif_chroma_monochrome heif_chroma_planar
76
+
53
77
 
54
78
  typedef enum heif_colorspace
55
79
  {
@@ -63,6 +87,8 @@ typedef enum heif_colorspace
63
87
 
64
88
  // heif_colorspace_RGB should be used with one of these heif_chroma values:
65
89
  // * heif_chroma_444 (for planar RGB)
90
+ // * heif_chroma_planar is accepted as a synonym and is internally canonicalized to heif_chroma_444.
91
+ // It is the preferred, future-proof value.
66
92
  // * heif_chroma_interleaved_RGB
67
93
  // * heif_chroma_interleaved_RGBA
68
94
  // * heif_chroma_interleaved_RRGGBB_BE
@@ -71,15 +97,21 @@ typedef enum heif_colorspace
71
97
  // * heif_chroma_interleaved_RRGGBBAA_LE
72
98
  heif_colorspace_RGB = 1,
73
99
 
74
- // heif_colorspace_monochrome should only be used with heif_chroma = heif_chroma_monochrome
100
+ // heif_colorspace_monochrome should only be used with heif_chroma = heif_chroma_planar.
75
101
  heif_colorspace_monochrome = 2,
76
102
 
77
- // Indicates that this image has no visual channels.
78
- heif_colorspace_nonvisual = 3,
103
+ // Indicates that this image has a special, custom arrangement of components.
104
+ // For example, it can have several monochrome channels or just a depth component with no color image.
105
+ // Images of this type are always planar and use heif_chroma_planar.
106
+ heif_colorspace_custom = 3,
79
107
 
108
+ // Images of this type are filter-array (CFA / Bayer) mosaics. The single
109
+ // mosaicked plane is described as heif_chroma_planar.
80
110
  heif_colorspace_filter_array = 4
81
111
  } heif_colorspace;
82
112
 
113
+ #define heif_colorspace_nonvisual heif_colorspace_custom
114
+
83
115
  typedef enum heif_channel
84
116
  {
85
117
  heif_channel_Y = 0,
@@ -96,41 +128,6 @@ typedef enum heif_channel
96
128
  heif_channel_unknown = 65535
97
129
  } heif_channel;
98
130
 
99
- #if HEIF_WITH_OMAF
100
- /**
101
- * OMAF Image projection.
102
- *
103
- * The image projection for most images is flat - it is projected as intended to be shown on
104
- * a flat screen or print. For immersive or omnidirectional media (e.g. VR headsets, or
105
- * equivalent), there are alternatives such as an equirectangular projection or cubemap projection.
106
- *
107
- * See ISO/IEC 23090-2 "Omnidirectional media format" for more information.
108
- */
109
- typedef enum heif_omaf_image_projection
110
- {
111
- /**
112
- * Equirectangular projection.
113
- */
114
- heif_omaf_image_projection_equirectangular = 0x00,
115
-
116
- /**
117
- * Cube map.
118
- */
119
- heif_omaf_image_projection_cube_map = 0x01,
120
-
121
- /* Values 2 through 31 are reserved in ISO/IEC 23090-2:2023 Table 10. */
122
- /**
123
- * Projection is specified, but not recognised.
124
- */
125
- heif_omaf_image_projection_unknown = 0xFE,
126
-
127
- /**
128
- * Flat projection, assumed if no projection information provided.
129
- */
130
- heif_omaf_image_projection_flat = 0xFF,
131
- } heif_omaf_image_projection;
132
- #endif
133
-
134
131
  // An heif_image contains a decoded pixel image in various colorspaces, chroma formats,
135
132
  // and bit depths.
136
133
 
@@ -139,6 +136,9 @@ typedef enum heif_omaf_image_projection
139
136
  // containing the interleaved R,G,B values.
140
137
 
141
138
  // Planar RGB images are specified as heif_colorspace_RGB / heif_chroma_444.
139
+ // heif_chroma_planar is accepted as a synonym and is internally canonicalized
140
+ // to heif_chroma_444 so heif_image_get_chroma_format() always returns
141
+ // heif_chroma_444 for planar RGB.
142
142
 
143
143
  typedef struct heif_image heif_image;
144
144
  typedef struct heif_image_handle heif_image_handle;
@@ -147,11 +147,11 @@ typedef struct heif_security_limits heif_security_limits;
147
147
 
148
148
  // Get the colorspace format of the image.
149
149
  LIBHEIF_API
150
- enum heif_colorspace heif_image_get_colorspace(const heif_image*);
150
+ heif_colorspace heif_image_get_colorspace(const heif_image*);
151
151
 
152
152
  // Get the chroma format of the image.
153
153
  LIBHEIF_API
154
- enum heif_chroma heif_image_get_chroma_format(const heif_image*);
154
+ heif_chroma heif_image_get_chroma_format(const heif_image*);
155
155
 
156
156
  /**
157
157
  * Get the width of a specified image channel.
@@ -161,7 +161,7 @@ enum heif_chroma heif_image_get_chroma_format(const heif_image*);
161
161
  * @return the width of the channel in pixels, or -1 the channel does not exist in the image
162
162
  */
163
163
  LIBHEIF_API
164
- int heif_image_get_width(const heif_image* img, enum heif_channel channel);
164
+ int heif_image_get_width(const heif_image* img, heif_channel channel);
165
165
 
166
166
  /**
167
167
  * Get the height of a specified image channel.
@@ -171,12 +171,13 @@ int heif_image_get_width(const heif_image* img, enum heif_channel channel);
171
171
  * @return the height of the channel in pixels, or -1 the channel does not exist in the image
172
172
  */
173
173
  LIBHEIF_API
174
- int heif_image_get_height(const heif_image* img, enum heif_channel channel);
174
+ int heif_image_get_height(const heif_image* img, heif_channel channel);
175
175
 
176
176
  /**
177
- * Get the width of the main channel.
177
+ * Get the logical width of the image.
178
178
  *
179
- * This is the Y channel in YCbCr or mono, or any in RGB.
179
+ * For well-formed images this equals the size of the main channel (the Y channel
180
+ * in YCbCr or mono, or the RGB channels). Subsampled chroma channels may be smaller.
180
181
  *
181
182
  * @param img the image to get the primary width for
182
183
  * @return the width in pixels
@@ -185,9 +186,10 @@ LIBHEIF_API
185
186
  int heif_image_get_primary_width(const heif_image* img);
186
187
 
187
188
  /**
188
- * Get the height of the main channel.
189
+ * Get the logical height of the image.
189
190
  *
190
- * This is the Y channel in YCbCr or mono, or any in RGB.
191
+ * For well-formed images this equals the size of the main channel (the Y channel
192
+ * in YCbCr or mono, or the RGB channels). Subsampled chroma channels may be smaller.
191
193
  *
192
194
  * @param img the image to get the primary height for
193
195
  * @return the height in pixels
@@ -195,6 +197,27 @@ int heif_image_get_primary_width(const heif_image* img);
195
197
  LIBHEIF_API
196
198
  int heif_image_get_primary_height(const heif_image* img);
197
199
 
200
+ /**
201
+ * Crop the image in place by removing margins from each edge.
202
+ *
203
+ * The four parameters specify the number of pixels to remove from each side,
204
+ * not absolute pixel coordinates. For example, to crop a 100x100 image down
205
+ * to its central 80x80 region, pass `left=10, right=10, top=10, bottom=10`.
206
+ * Passing all zeros leaves the image unchanged.
207
+ *
208
+ * The resulting image has dimensions `(w - left - right) x (h - top - bottom)`,
209
+ * which must be at least 1x1. All four values must be non-negative and the
210
+ * sums `left + right` and `top + bottom` must each be strictly less than the
211
+ * corresponding image dimension; otherwise `heif_error_Usage_error` /
212
+ * `heif_suberror_Invalid_parameter_value` is returned and the image is left
213
+ * unchanged.
214
+ *
215
+ * @param img the image to crop (modified in place on success)
216
+ * @param left number of pixels to remove from the left edge
217
+ * @param right number of pixels to remove from the right edge
218
+ * @param top number of pixels to remove from the top edge
219
+ * @param bottom number of pixels to remove from the bottom edge
220
+ */
198
221
  LIBHEIF_API
199
222
  heif_error heif_image_crop(heif_image* img,
200
223
  int left, int right, int top, int bottom);
@@ -212,7 +235,7 @@ heif_error heif_image_extract_area(const heif_image*,
212
235
  // Especially for HDR images, this is probably not what you want. Have a look at
213
236
  // heif_image_get_bits_per_pixel_range() instead.
214
237
  LIBHEIF_API
215
- int heif_image_get_bits_per_pixel(const heif_image*, enum heif_channel channel);
238
+ int heif_image_get_bits_per_pixel(const heif_image*, heif_channel channel);
216
239
 
217
240
  // Get the number of bits per pixel in the given image channel. This function returns
218
241
  // the number of bits used for representing the pixel value, which might be smaller
@@ -221,10 +244,10 @@ int heif_image_get_bits_per_pixel(const heif_image*, enum heif_channel channel);
221
244
  // are reserved for storage. For interleaved RGBA with 12 bit, this function also returns
222
245
  // '12', not '48' or '64' (heif_image_get_bits_per_pixel returns 64 in this case).
223
246
  LIBHEIF_API
224
- int heif_image_get_bits_per_pixel_range(const heif_image*, enum heif_channel channel);
247
+ int heif_image_get_bits_per_pixel_range(const heif_image*, heif_channel channel);
225
248
 
226
249
  LIBHEIF_API
227
- int heif_image_has_channel(const heif_image*, enum heif_channel channel);
250
+ int heif_image_has_channel(const heif_image*, heif_channel channel);
228
251
 
229
252
  // Get a pointer to the actual pixel data.
230
253
  // The 'out_stride' is returned as "bytes per line".
@@ -233,13 +256,13 @@ int heif_image_has_channel(const heif_image*, enum heif_channel channel);
233
256
  // Deprecated, use the safer version heif_image_get_plane_readonly2() instead.
234
257
  LIBHEIF_API
235
258
  const uint8_t* heif_image_get_plane_readonly(const heif_image*,
236
- enum heif_channel channel,
259
+ heif_channel channel,
237
260
  int* out_stride);
238
261
 
239
262
  // Deprecated, use the safer version heif_image_get_plane2() instead.
240
263
  LIBHEIF_API
241
264
  uint8_t* heif_image_get_plane(heif_image*,
242
- enum heif_channel channel,
265
+ heif_channel channel,
243
266
  int* out_stride);
244
267
 
245
268
  // These are safer variants of the two functions above.
@@ -248,12 +271,12 @@ uint8_t* heif_image_get_plane(heif_image*,
248
271
  // The changed 'stride' parameter type eliminates this common error.
249
272
  LIBHEIF_API
250
273
  const uint8_t* heif_image_get_plane_readonly2(const heif_image*,
251
- enum heif_channel channel,
274
+ heif_channel channel,
252
275
  size_t* out_stride);
253
276
 
254
277
  LIBHEIF_API
255
278
  uint8_t* heif_image_get_plane2(heif_image*,
256
- enum heif_channel channel,
279
+ heif_channel channel,
257
280
  size_t* out_stride);
258
281
 
259
282
 
@@ -302,14 +325,6 @@ void heif_image_set_pixel_aspect_ratio(heif_image*, uint32_t aspect_h, uint32_t
302
325
  LIBHEIF_API
303
326
  void heif_image_handle_set_pixel_aspect_ratio(heif_image_handle*, uint32_t aspect_h, uint32_t aspect_v);
304
327
 
305
- #if HEIF_WITH_OMAF
306
- LIBHEIF_API
307
- heif_omaf_image_projection heif_image_get_omaf_image_projection(const heif_image*);
308
-
309
- LIBHEIF_API
310
- void heif_image_set_omaf_image_projection(const heif_image*, heif_omaf_image_projection image_projection);
311
- #endif
312
-
313
328
  // --- heif_image allocation
314
329
 
315
330
  /**
@@ -327,8 +342,8 @@ void heif_image_set_omaf_image_projection(const heif_image*, heif_omaf_image_pro
327
342
  */
328
343
  LIBHEIF_API
329
344
  heif_error heif_image_create(int width, int height,
330
- enum heif_colorspace colorspace,
331
- enum heif_chroma chroma,
345
+ heif_colorspace colorspace,
346
+ heif_chroma chroma,
332
347
  heif_image** out_image);
333
348
 
334
349
  /**
@@ -361,7 +376,7 @@ heif_error heif_image_create(int width, int height,
361
376
  */
362
377
  LIBHEIF_API
363
378
  heif_error heif_image_add_plane(heif_image* image,
364
- enum heif_channel channel,
379
+ heif_channel channel,
365
380
  int width, int height, int bit_depth);
366
381
 
367
382
  /*
@@ -370,7 +385,7 @@ heif_error heif_image_add_plane(heif_image* image,
370
385
  */
371
386
  LIBHEIF_API
372
387
  heif_error heif_image_add_plane_safe(heif_image* image,
373
- enum heif_channel channel,
388
+ heif_channel channel,
374
389
  int width, int height, int bit_depth,
375
390
  const heif_security_limits* limits);
376
391
 
@@ -91,8 +91,8 @@ int heif_image_handle_get_chroma_bits_per_pixel(const heif_image_handle*);
91
91
  // You can still request the output in your preferred colorspace, but this may involve an internal conversion.
92
92
  LIBHEIF_API
93
93
  heif_error heif_image_handle_get_preferred_decoding_colorspace(const heif_image_handle* image_handle,
94
- enum heif_colorspace* out_colorspace,
95
- enum heif_chroma* out_chroma);
94
+ heif_colorspace* out_colorspace,
95
+ heif_chroma* out_chroma);
96
96
 
97
97
  // Get the image width from the 'ispe' box. This is the original image size without
98
98
  // any transformations applied to it. Do not use this unless you know exactly what
@@ -61,7 +61,7 @@ int heif_context_get_list_of_item_IDs(const heif_context* ctx,
61
61
  * Gets the item type.
62
62
  *
63
63
  * Usually, this is a four character code (e.g. `mime` or `uri `), but it can theoretically be
64
- * any 4-byte number. Thus, the type is returned as an integer. You can use {@link heif_fourcc} to map
64
+ * any 4-byte number. Thus, the type is returned as an integer. You can use #heif_fourcc to map
65
65
  * between the two representations.
66
66
  *
67
67
  * @param ctx the file context