@img/sharp-libvips-dev 1.0.1 → 1.0.3

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 (169) hide show
  1. package/README.md +1 -2
  2. package/include/aom/aom_decoder.h +1 -1
  3. package/include/aom/aom_encoder.h +7 -1
  4. package/include/aom/aom_image.h +24 -12
  5. package/include/aom/aom_integer.h +3 -3
  6. package/include/aom/aomcx.h +15 -0
  7. package/include/aom/aomdx.h +5 -2
  8. package/include/archive.h +7 -5
  9. package/include/archive_entry.h +5 -3
  10. package/include/cgif.h +3 -0
  11. package/include/expat.h +21 -10
  12. package/include/expat_config.h +11 -5
  13. package/include/ffi.h +12 -25
  14. package/include/freetype2/freetype/config/ftoption.h +2 -2
  15. package/include/fribidi/fribidi-config.h +2 -2
  16. package/include/fribidi/fribidi-unicode-version.h +3 -3
  17. package/include/gio-unix-2.0/gio/gfiledescriptorbased.h +3 -2
  18. package/include/glib-2.0/gio/gappinfo.h +40 -25
  19. package/include/glib-2.0/gio/gapplication.h +6 -0
  20. package/include/glib-2.0/gio/gasyncresult.h +1 -1
  21. package/include/glib-2.0/gio/gconverter.h +5 -0
  22. package/include/glib-2.0/gio/gdbusintrospection.h +1 -1
  23. package/include/glib-2.0/gio/gfile.h +16 -0
  24. package/include/glib-2.0/gio/gio-visibility.h +34 -0
  25. package/include/glib-2.0/gio/giotypes.h +0 -1
  26. package/include/glib-2.0/gio/gsettings.h +8 -0
  27. package/include/glib-2.0/gio/gvfs.h +2 -2
  28. package/include/glib-2.0/girepository/gi-visibility.h +34 -0
  29. package/include/glib-2.0/girepository/giarginfo.h +23 -6
  30. package/include/glib-2.0/girepository/gibaseinfo.h +44 -18
  31. package/include/glib-2.0/girepository/gicallableinfo.h +26 -16
  32. package/include/glib-2.0/girepository/gicallbackinfo.h +17 -2
  33. package/include/glib-2.0/girepository/giconstantinfo.h +19 -4
  34. package/include/glib-2.0/girepository/gienuminfo.h +20 -21
  35. package/include/glib-2.0/girepository/gifieldinfo.h +22 -7
  36. package/include/glib-2.0/girepository/giflagsinfo.h +60 -0
  37. package/include/glib-2.0/girepository/gifunctioninfo.h +22 -7
  38. package/include/glib-2.0/girepository/giinterfaceinfo.h +33 -18
  39. package/include/glib-2.0/girepository/giobjectinfo.h +41 -26
  40. package/include/glib-2.0/girepository/gipropertyinfo.h +18 -3
  41. package/include/glib-2.0/girepository/giregisteredtypeinfo.h +22 -11
  42. package/include/glib-2.0/girepository/girepository-autocleanups.h +56 -0
  43. package/include/glib-2.0/girepository/girepository.h +53 -62
  44. package/include/glib-2.0/girepository/girffi.h +8 -7
  45. package/include/glib-2.0/girepository/gisignalinfo.h +18 -3
  46. package/include/glib-2.0/girepository/gistructinfo.h +26 -11
  47. package/include/glib-2.0/girepository/gitypeinfo.h +29 -16
  48. package/include/glib-2.0/girepository/gitypelib.h +9 -13
  49. package/include/glib-2.0/girepository/gitypes.h +52 -104
  50. package/include/glib-2.0/girepository/giunioninfo.h +28 -12
  51. package/include/glib-2.0/girepository/giunresolvedinfo.h +17 -2
  52. package/include/glib-2.0/girepository/givalueinfo.h +65 -0
  53. package/include/glib-2.0/girepository/givfuncinfo.h +23 -8
  54. package/include/glib-2.0/glib/deprecated/gthread.h +9 -5
  55. package/include/glib-2.0/glib/gbitlock.h +31 -0
  56. package/include/glib-2.0/glib/gbookmarkfile.h +1 -1
  57. package/include/glib-2.0/glib/giochannel.h +2 -2
  58. package/include/glib-2.0/glib/glib-visibility.h +34 -0
  59. package/include/glib-2.0/glib/gmacros.h +12 -5
  60. package/include/glib-2.0/glib/gmain.h +93 -7
  61. package/include/glib-2.0/glib/gmessages.h +8 -0
  62. package/include/glib-2.0/glib/gqsort.h +8 -1
  63. package/include/glib-2.0/glib/gslice.h +2 -0
  64. package/include/glib-2.0/glib/gstrfuncs.h +24 -30
  65. package/include/glib-2.0/glib/gstrvbuilder.h +3 -0
  66. package/include/glib-2.0/glib/gthread.h +191 -3
  67. package/include/glib-2.0/glib/gunicode.h +1 -1
  68. package/include/glib-2.0/glib/gversionmacros.h +9 -0
  69. package/include/glib-2.0/glib-unix.h +7 -1
  70. package/include/glib-2.0/gmodule/gmodule-visibility.h +34 -0
  71. package/include/glib-2.0/gobject/genums.h +6 -6
  72. package/include/glib-2.0/gobject/glib-types.h +11 -0
  73. package/include/glib-2.0/gobject/gobject-visibility.h +34 -0
  74. package/include/glib-2.0/gobject/gsignal.h +16 -6
  75. package/include/glib-2.0/gobject/gtype.h +6 -6
  76. package/include/harfbuzz/hb-buffer.h +6 -0
  77. package/include/harfbuzz/hb-common.h +6 -9
  78. package/include/harfbuzz/hb-cplusplus.hh +8 -11
  79. package/include/harfbuzz/hb-subset.h +17 -4
  80. package/include/harfbuzz/hb-version.h +3 -3
  81. package/include/hwy/abort.h +28 -0
  82. package/include/hwy/aligned_allocator.h +218 -6
  83. package/include/hwy/base.h +1935 -512
  84. package/include/hwy/cache_control.h +24 -6
  85. package/include/hwy/detect_compiler_arch.h +105 -10
  86. package/include/hwy/detect_targets.h +146 -37
  87. package/include/hwy/foreach_target.h +36 -1
  88. package/include/hwy/highway.h +222 -50
  89. package/include/hwy/ops/arm_neon-inl.h +2055 -894
  90. package/include/hwy/ops/arm_sve-inl.h +1476 -348
  91. package/include/hwy/ops/emu128-inl.h +711 -623
  92. package/include/hwy/ops/generic_ops-inl.h +4431 -2157
  93. package/include/hwy/ops/inside-inl.h +691 -0
  94. package/include/hwy/ops/ppc_vsx-inl.h +2186 -673
  95. package/include/hwy/ops/rvv-inl.h +1556 -536
  96. package/include/hwy/ops/scalar-inl.h +353 -233
  97. package/include/hwy/ops/set_macros-inl.h +171 -23
  98. package/include/hwy/ops/shared-inl.h +198 -56
  99. package/include/hwy/ops/wasm_128-inl.h +283 -244
  100. package/include/hwy/ops/x86_128-inl.h +3673 -1357
  101. package/include/hwy/ops/x86_256-inl.h +1737 -663
  102. package/include/hwy/ops/x86_512-inl.h +1697 -500
  103. package/include/hwy/per_target.h +4 -0
  104. package/include/hwy/profiler.h +648 -0
  105. package/include/hwy/robust_statistics.h +2 -2
  106. package/include/hwy/targets.h +40 -32
  107. package/include/hwy/timer-inl.h +3 -3
  108. package/include/hwy/timer.h +16 -1
  109. package/include/libheif/heif.h +170 -15
  110. package/include/libheif/heif_items.h +237 -0
  111. package/include/libheif/heif_properties.h +38 -2
  112. package/include/libheif/heif_regions.h +1 -1
  113. package/include/libheif/heif_version.h +2 -2
  114. package/include/libpng16/png.h +32 -29
  115. package/include/libpng16/pngconf.h +2 -2
  116. package/include/libpng16/pnglibconf.h +8 -3
  117. package/include/librsvg-2.0/librsvg/rsvg-cairo.h +1 -1
  118. package/include/librsvg-2.0/librsvg/rsvg-features.h +3 -4
  119. package/include/librsvg-2.0/librsvg/rsvg-pixbuf.h +235 -0
  120. package/include/librsvg-2.0/librsvg/rsvg-version.h +3 -3
  121. package/include/librsvg-2.0/librsvg/rsvg.h +55 -176
  122. package/include/libxml2/libxml/HTMLparser.h +12 -19
  123. package/include/libxml2/libxml/c14n.h +1 -12
  124. package/include/libxml2/libxml/debugXML.h +1 -1
  125. package/include/libxml2/libxml/encoding.h +9 -0
  126. package/include/libxml2/libxml/entities.h +12 -1
  127. package/include/libxml2/libxml/hash.h +19 -0
  128. package/include/libxml2/libxml/list.h +2 -2
  129. package/include/libxml2/libxml/nanohttp.h +17 -0
  130. package/include/libxml2/libxml/parser.h +73 -58
  131. package/include/libxml2/libxml/parserInternals.h +9 -1
  132. package/include/libxml2/libxml/pattern.h +6 -0
  133. package/include/libxml2/libxml/tree.h +32 -12
  134. package/include/libxml2/libxml/uri.h +11 -0
  135. package/include/libxml2/libxml/valid.h +29 -2
  136. package/include/libxml2/libxml/xinclude.h +7 -0
  137. package/include/libxml2/libxml/xmlIO.h +21 -5
  138. package/include/libxml2/libxml/xmlerror.h +14 -0
  139. package/include/libxml2/libxml/xmlexports.h +111 -15
  140. package/include/libxml2/libxml/xmlmemory.h +8 -45
  141. package/include/libxml2/libxml/xmlreader.h +2 -0
  142. package/include/libxml2/libxml/xmlsave.h +5 -0
  143. package/include/libxml2/libxml/xmlunicode.h +165 -1
  144. package/include/libxml2/libxml/xmlversion.h +15 -179
  145. package/include/libxml2/libxml/xmlwriter.h +1 -0
  146. package/include/libxml2/libxml/xpath.h +4 -0
  147. package/include/pango-1.0/pango/pango-features.h +2 -2
  148. package/include/pango-1.0/pango/pango-fontmap.h +7 -0
  149. package/include/pango-1.0/pango/pango-item.h +4 -2
  150. package/include/pango-1.0/pango/pango-version-macros.h +25 -0
  151. package/include/pango-1.0/pango/pangofc-font.h +2 -1
  152. package/include/pixman-1/pixman-version.h +2 -2
  153. package/include/png.h +32 -29
  154. package/include/pngconf.h +2 -2
  155. package/include/pnglibconf.h +8 -3
  156. package/include/vips/connection.h +9 -3
  157. package/include/vips/util.h +1 -11
  158. package/include/vips/version.h +4 -4
  159. package/include/webp/decode.h +58 -56
  160. package/include/webp/demux.h +25 -21
  161. package/include/webp/encode.h +44 -39
  162. package/include/webp/mux.h +76 -15
  163. package/include/webp/mux_types.h +2 -1
  164. package/include/webp/sharpyuv/sharpyuv.h +77 -8
  165. package/include/webp/types.h +29 -8
  166. package/include/zconf.h +1 -1
  167. package/include/zlib.h +12 -12
  168. package/package.json +1 -1
  169. package/versions.json +18 -19
@@ -50,6 +50,7 @@
50
50
 
51
51
  #include "./decode.h" // for WEBP_CSP_MODE
52
52
  #include "./mux_types.h"
53
+ #include "./types.h"
53
54
 
54
55
  #ifdef __cplusplus
55
56
  extern "C" {
@@ -85,13 +86,13 @@ typedef enum WebPDemuxState {
85
86
  } WebPDemuxState;
86
87
 
87
88
  // Internal, version-checked, entry point
88
- WEBP_EXTERN WebPDemuxer* WebPDemuxInternal(
89
+ WEBP_NODISCARD WEBP_EXTERN WebPDemuxer* WebPDemuxInternal(
89
90
  const WebPData*, int, WebPDemuxState*, int);
90
91
 
91
92
  // Parses the full WebP file given by 'data'. For single images the WebP file
92
93
  // header alone or the file header and the chunk header may be absent.
93
94
  // Returns a WebPDemuxer object on successful parse, NULL otherwise.
94
- static WEBP_INLINE WebPDemuxer* WebPDemux(const WebPData* data) {
95
+ WEBP_NODISCARD static WEBP_INLINE WebPDemuxer* WebPDemux(const WebPData* data) {
95
96
  return WebPDemuxInternal(data, 0, NULL, WEBP_DEMUX_ABI_VERSION);
96
97
  }
97
98
 
@@ -103,7 +104,7 @@ static WEBP_INLINE WebPDemuxer* WebPDemux(const WebPData* data) {
103
104
  // If this data is volatile, the demuxer object should be deleted (by calling
104
105
  // WebPDemuxDelete()) and WebPDemuxPartial() called again on the new data.
105
106
  // This is usually an inexpensive operation.
106
- static WEBP_INLINE WebPDemuxer* WebPDemuxPartial(
107
+ WEBP_NODISCARD static WEBP_INLINE WebPDemuxer* WebPDemuxPartial(
107
108
  const WebPData* data, WebPDemuxState* state) {
108
109
  return WebPDemuxInternal(data, 1, state, WEBP_DEMUX_ABI_VERSION);
109
110
  }
@@ -164,14 +165,14 @@ struct WebPIterator {
164
165
  // Returns false if 'dmux' is NULL or frame 'frame_number' is not present.
165
166
  // Call WebPDemuxReleaseIterator() when use of the iterator is complete.
166
167
  // NOTE: 'dmux' must persist for the lifetime of 'iter'.
167
- WEBP_EXTERN int WebPDemuxGetFrame(
168
+ WEBP_NODISCARD WEBP_EXTERN int WebPDemuxGetFrame(
168
169
  const WebPDemuxer* dmux, int frame_number, WebPIterator* iter);
169
170
 
170
171
  // Sets 'iter->fragment' to point to the next ('iter->frame_num' + 1) or
171
172
  // previous ('iter->frame_num' - 1) frame. These functions do not loop.
172
173
  // Returns true on success, false otherwise.
173
- WEBP_EXTERN int WebPDemuxNextFrame(WebPIterator* iter);
174
- WEBP_EXTERN int WebPDemuxPrevFrame(WebPIterator* iter);
174
+ WEBP_NODISCARD WEBP_EXTERN int WebPDemuxNextFrame(WebPIterator* iter);
175
+ WEBP_NODISCARD WEBP_EXTERN int WebPDemuxPrevFrame(WebPIterator* iter);
175
176
 
176
177
  // Releases any memory associated with 'iter'.
177
178
  // Must be called before any subsequent calls to WebPDemuxGetChunk() on the same
@@ -202,15 +203,16 @@ struct WebPChunkIterator {
202
203
  // payloads are accessed through WebPDemuxGetFrame() and related functions.
203
204
  // Call WebPDemuxReleaseChunkIterator() when use of the iterator is complete.
204
205
  // NOTE: 'dmux' must persist for the lifetime of the iterator.
205
- WEBP_EXTERN int WebPDemuxGetChunk(const WebPDemuxer* dmux,
206
- const char fourcc[4], int chunk_number,
207
- WebPChunkIterator* iter);
206
+ WEBP_NODISCARD WEBP_EXTERN int WebPDemuxGetChunk(const WebPDemuxer* dmux,
207
+ const char fourcc[4],
208
+ int chunk_number,
209
+ WebPChunkIterator* iter);
208
210
 
209
211
  // Sets 'iter->chunk' to point to the next ('iter->chunk_num' + 1) or previous
210
212
  // ('iter->chunk_num' - 1) chunk. These functions do not loop.
211
213
  // Returns true on success, false otherwise.
212
- WEBP_EXTERN int WebPDemuxNextChunk(WebPChunkIterator* iter);
213
- WEBP_EXTERN int WebPDemuxPrevChunk(WebPChunkIterator* iter);
214
+ WEBP_NODISCARD WEBP_EXTERN int WebPDemuxNextChunk(WebPChunkIterator* iter);
215
+ WEBP_NODISCARD WEBP_EXTERN int WebPDemuxPrevChunk(WebPChunkIterator* iter);
214
216
 
215
217
  // Releases any memory associated with 'iter'.
216
218
  // Must be called before destroying the associated WebPDemuxer with
@@ -257,21 +259,21 @@ struct WebPAnimDecoderOptions {
257
259
  };
258
260
 
259
261
  // Internal, version-checked, entry point.
260
- WEBP_EXTERN int WebPAnimDecoderOptionsInitInternal(
262
+ WEBP_NODISCARD WEBP_EXTERN int WebPAnimDecoderOptionsInitInternal(
261
263
  WebPAnimDecoderOptions*, int);
262
264
 
263
265
  // Should always be called, to initialize a fresh WebPAnimDecoderOptions
264
266
  // structure before modification. Returns false in case of version mismatch.
265
267
  // WebPAnimDecoderOptionsInit() must have succeeded before using the
266
268
  // 'dec_options' object.
267
- static WEBP_INLINE int WebPAnimDecoderOptionsInit(
269
+ WEBP_NODISCARD static WEBP_INLINE int WebPAnimDecoderOptionsInit(
268
270
  WebPAnimDecoderOptions* dec_options) {
269
271
  return WebPAnimDecoderOptionsInitInternal(dec_options,
270
272
  WEBP_DEMUX_ABI_VERSION);
271
273
  }
272
274
 
273
275
  // Internal, version-checked, entry point.
274
- WEBP_EXTERN WebPAnimDecoder* WebPAnimDecoderNewInternal(
276
+ WEBP_NODISCARD WEBP_EXTERN WebPAnimDecoder* WebPAnimDecoderNewInternal(
275
277
  const WebPData*, const WebPAnimDecoderOptions*, int);
276
278
 
277
279
  // Creates and initializes a WebPAnimDecoder object.
@@ -284,7 +286,7 @@ WEBP_EXTERN WebPAnimDecoder* WebPAnimDecoderNewInternal(
284
286
  // Returns:
285
287
  // A pointer to the newly created WebPAnimDecoder object, or NULL in case of
286
288
  // parsing error, invalid option or memory error.
287
- static WEBP_INLINE WebPAnimDecoder* WebPAnimDecoderNew(
289
+ WEBP_NODISCARD static WEBP_INLINE WebPAnimDecoder* WebPAnimDecoderNew(
288
290
  const WebPData* webp_data, const WebPAnimDecoderOptions* dec_options) {
289
291
  return WebPAnimDecoderNewInternal(webp_data, dec_options,
290
292
  WEBP_DEMUX_ABI_VERSION);
@@ -306,8 +308,8 @@ struct WebPAnimInfo {
306
308
  // info - (out) global information fetched from the animation.
307
309
  // Returns:
308
310
  // True on success.
309
- WEBP_EXTERN int WebPAnimDecoderGetInfo(const WebPAnimDecoder* dec,
310
- WebPAnimInfo* info);
311
+ WEBP_NODISCARD WEBP_EXTERN int WebPAnimDecoderGetInfo(
312
+ const WebPAnimDecoder* dec, WebPAnimInfo* info);
311
313
 
312
314
  // Fetch the next frame from 'dec' based on options supplied to
313
315
  // WebPAnimDecoderNew(). This will be a fully reconstructed canvas of size
@@ -321,8 +323,9 @@ WEBP_EXTERN int WebPAnimDecoderGetInfo(const WebPAnimDecoder* dec,
321
323
  // Returns:
322
324
  // False if any of the arguments are NULL, or if there is a parsing or
323
325
  // decoding error, or if there are no more frames. Otherwise, returns true.
324
- WEBP_EXTERN int WebPAnimDecoderGetNext(WebPAnimDecoder* dec,
325
- uint8_t** buf, int* timestamp);
326
+ WEBP_NODISCARD WEBP_EXTERN int WebPAnimDecoderGetNext(WebPAnimDecoder* dec,
327
+ uint8_t** buf,
328
+ int* timestamp);
326
329
 
327
330
  // Check if there are more frames left to decode.
328
331
  // Parameters:
@@ -330,7 +333,8 @@ WEBP_EXTERN int WebPAnimDecoderGetNext(WebPAnimDecoder* dec,
330
333
  // Returns:
331
334
  // True if 'dec' is not NULL and some frames are yet to be decoded.
332
335
  // Otherwise, returns false.
333
- WEBP_EXTERN int WebPAnimDecoderHasMoreFrames(const WebPAnimDecoder* dec);
336
+ WEBP_NODISCARD WEBP_EXTERN int WebPAnimDecoderHasMoreFrames(
337
+ const WebPAnimDecoder* dec);
334
338
 
335
339
  // Resets the WebPAnimDecoder object, so that next call to
336
340
  // WebPAnimDecoderGetNext() will restart decoding from 1st frame. This would be
@@ -348,7 +352,7 @@ WEBP_EXTERN void WebPAnimDecoderReset(WebPAnimDecoder* dec);
348
352
  //
349
353
  // Parameters:
350
354
  // dec - (in) decoder instance from which the demuxer object is to be fetched.
351
- WEBP_EXTERN const WebPDemuxer* WebPAnimDecoderGetDemuxer(
355
+ WEBP_NODISCARD WEBP_EXTERN const WebPDemuxer* WebPAnimDecoderGetDemuxer(
352
356
  const WebPAnimDecoder* dec);
353
357
 
354
358
  // Deletes the WebPAnimDecoder object.
@@ -164,13 +164,14 @@ typedef enum WebPPreset {
164
164
  } WebPPreset;
165
165
 
166
166
  // Internal, version-checked, entry point
167
- WEBP_EXTERN int WebPConfigInitInternal(WebPConfig*, WebPPreset, float, int);
167
+ WEBP_NODISCARD WEBP_EXTERN int WebPConfigInitInternal(WebPConfig*, WebPPreset,
168
+ float, int);
168
169
 
169
170
  // Should always be called, to initialize a fresh WebPConfig structure before
170
171
  // modification. Returns false in case of version mismatch. WebPConfigInit()
171
172
  // must have succeeded before using the 'config' object.
172
173
  // Note that the default values are lossless=0 and quality=75.
173
- static WEBP_INLINE int WebPConfigInit(WebPConfig* config) {
174
+ WEBP_NODISCARD static WEBP_INLINE int WebPConfigInit(WebPConfig* config) {
174
175
  return WebPConfigInitInternal(config, WEBP_PRESET_DEFAULT, 75.f,
175
176
  WEBP_ENCODER_ABI_VERSION);
176
177
  }
@@ -179,8 +180,9 @@ static WEBP_INLINE int WebPConfigInit(WebPConfig* config) {
179
180
  // set of parameters (referred to by 'preset') and a given quality factor.
180
181
  // This function can be called as a replacement to WebPConfigInit(). Will
181
182
  // return false in case of error.
182
- static WEBP_INLINE int WebPConfigPreset(WebPConfig* config,
183
- WebPPreset preset, float quality) {
183
+ WEBP_NODISCARD static WEBP_INLINE int WebPConfigPreset(WebPConfig* config,
184
+ WebPPreset preset,
185
+ float quality) {
184
186
  return WebPConfigInitInternal(config, preset, quality,
185
187
  WEBP_ENCODER_ABI_VERSION);
186
188
  }
@@ -191,11 +193,12 @@ static WEBP_INLINE int WebPConfigPreset(WebPConfig* config,
191
193
  // speed and final compressed size.
192
194
  // This function will overwrite several fields from config: 'method', 'quality'
193
195
  // and 'lossless'. Returns false in case of parameter error.
194
- WEBP_EXTERN int WebPConfigLosslessPreset(WebPConfig* config, int level);
196
+ WEBP_NODISCARD WEBP_EXTERN int WebPConfigLosslessPreset(WebPConfig* config,
197
+ int level);
195
198
 
196
199
  // Returns true if 'config' is non-NULL and all configuration parameters are
197
200
  // within their valid ranges.
198
- WEBP_EXTERN int WebPValidateConfig(const WebPConfig* config);
201
+ WEBP_NODISCARD WEBP_EXTERN int WebPValidateConfig(const WebPConfig* config);
199
202
 
200
203
  //------------------------------------------------------------------------------
201
204
  // Input / Output
@@ -255,8 +258,8 @@ WEBP_EXTERN void WebPMemoryWriterClear(WebPMemoryWriter* writer);
255
258
  // The custom writer to be used with WebPMemoryWriter as custom_ptr. Upon
256
259
  // completion, writer.mem and writer.size will hold the coded data.
257
260
  // writer.mem must be freed by calling WebPMemoryWriterClear.
258
- WEBP_EXTERN int WebPMemoryWrite(const uint8_t* data, size_t data_size,
259
- const WebPPicture* picture);
261
+ WEBP_NODISCARD WEBP_EXTERN int WebPMemoryWrite(
262
+ const uint8_t* data, size_t data_size, const WebPPicture* picture);
260
263
 
261
264
  // Progress hook, called from time to time to report progress. It can return
262
265
  // false to request an abort of the encoding process, or true otherwise if
@@ -364,13 +367,13 @@ struct WebPPicture {
364
367
  };
365
368
 
366
369
  // Internal, version-checked, entry point
367
- WEBP_EXTERN int WebPPictureInitInternal(WebPPicture*, int);
370
+ WEBP_NODISCARD WEBP_EXTERN int WebPPictureInitInternal(WebPPicture*, int);
368
371
 
369
372
  // Should always be called, to initialize the structure. Returns false in case
370
373
  // of version mismatch. WebPPictureInit() must have succeeded before using the
371
374
  // 'picture' object.
372
375
  // Note that, by default, use_argb is false and colorspace is WEBP_YUV420.
373
- static WEBP_INLINE int WebPPictureInit(WebPPicture* picture) {
376
+ WEBP_NODISCARD static WEBP_INLINE int WebPPictureInit(WebPPicture* picture) {
374
377
  return WebPPictureInitInternal(picture, WEBP_ENCODER_ABI_VERSION);
375
378
  }
376
379
 
@@ -381,7 +384,7 @@ static WEBP_INLINE int WebPPictureInit(WebPPicture* picture) {
381
384
  // Allocate y/u/v buffers as per colorspace/width/height specification.
382
385
  // Note! This function will free the previous buffer if needed.
383
386
  // Returns false in case of memory error.
384
- WEBP_EXTERN int WebPPictureAlloc(WebPPicture* picture);
387
+ WEBP_NODISCARD WEBP_EXTERN int WebPPictureAlloc(WebPPicture* picture);
385
388
 
386
389
  // Release the memory allocated by WebPPictureAlloc() or WebPPictureImport*().
387
390
  // Note that this function does _not_ free the memory used by the 'picture'
@@ -394,7 +397,8 @@ WEBP_EXTERN void WebPPictureFree(WebPPicture* picture);
394
397
  // will fully own the copied pixels (this is not a view). The 'dst' picture need
395
398
  // not be initialized as its content is overwritten.
396
399
  // Returns false in case of memory allocation error.
397
- WEBP_EXTERN int WebPPictureCopy(const WebPPicture* src, WebPPicture* dst);
400
+ WEBP_NODISCARD WEBP_EXTERN int WebPPictureCopy(const WebPPicture* src,
401
+ WebPPicture* dst);
398
402
 
399
403
  // Compute the single distortion for packed planes of samples.
400
404
  // 'src' will be compared to 'ref', and the raw distortion stored into
@@ -403,19 +407,18 @@ WEBP_EXTERN int WebPPictureCopy(const WebPPicture* src, WebPPicture* dst);
403
407
  // 'x_step' is the horizontal stride (in bytes) between samples.
404
408
  // 'src/ref_stride' is the byte distance between rows.
405
409
  // Returns false in case of error (bad parameter, memory allocation error, ...).
406
- WEBP_EXTERN int WebPPlaneDistortion(const uint8_t* src, size_t src_stride,
407
- const uint8_t* ref, size_t ref_stride,
408
- int width, int height,
409
- size_t x_step,
410
- int type, // 0 = PSNR, 1 = SSIM, 2 = LSIM
411
- float* distortion, float* result);
410
+ WEBP_NODISCARD WEBP_EXTERN int WebPPlaneDistortion(
411
+ const uint8_t* src, size_t src_stride,
412
+ const uint8_t* ref, size_t ref_stride, int width, int height, size_t x_step,
413
+ int type, // 0 = PSNR, 1 = SSIM, 2 = LSIM
414
+ float* distortion, float* result);
412
415
 
413
416
  // Compute PSNR, SSIM or LSIM distortion metric between two pictures. Results
414
417
  // are in dB, stored in result[] in the B/G/R/A/All order. The distortion is
415
418
  // always performed using ARGB samples. Hence if the input is YUV(A), the
416
419
  // picture will be internally converted to ARGB (just for the measurement).
417
420
  // Warning: this function is rather CPU-intensive.
418
- WEBP_EXTERN int WebPPictureDistortion(
421
+ WEBP_NODISCARD WEBP_EXTERN int WebPPictureDistortion(
419
422
  const WebPPicture* src, const WebPPicture* ref,
420
423
  int metric_type, // 0 = PSNR, 1 = SSIM, 2 = LSIM
421
424
  float result[5]);
@@ -428,8 +431,8 @@ WEBP_EXTERN int WebPPictureDistortion(
428
431
  // must be fully be comprised inside the 'src' source picture. If the source
429
432
  // picture uses the YUV420 colorspace, the top and left coordinates will be
430
433
  // snapped to even values.
431
- WEBP_EXTERN int WebPPictureCrop(WebPPicture* picture,
432
- int left, int top, int width, int height);
434
+ WEBP_NODISCARD WEBP_EXTERN int WebPPictureCrop(
435
+ WebPPicture* picture, int left, int top, int width, int height);
433
436
 
434
437
  // Extracts a view from 'src' picture into 'dst'. The rectangle for the view
435
438
  // is defined by the top-left corner pixel coordinates (left, top) as well
@@ -442,9 +445,9 @@ WEBP_EXTERN int WebPPictureCrop(WebPPicture* picture,
442
445
  // with WebPPictureInit() if it is different from 'src', since its content will
443
446
  // be overwritten.
444
447
  // Returns false in case of invalid parameters.
445
- WEBP_EXTERN int WebPPictureView(const WebPPicture* src,
446
- int left, int top, int width, int height,
447
- WebPPicture* dst);
448
+ WEBP_NODISCARD WEBP_EXTERN int WebPPictureView(
449
+ const WebPPicture* src, int left, int top, int width, int height,
450
+ WebPPicture* dst);
448
451
 
449
452
  // Returns true if the 'picture' is actually a view and therefore does
450
453
  // not own the memory for pixels.
@@ -455,29 +458,30 @@ WEBP_EXTERN int WebPPictureIsView(const WebPPicture* picture);
455
458
  // dimension will be calculated preserving the aspect ratio.
456
459
  // No gamma correction is applied.
457
460
  // Returns false in case of error (invalid parameter or insufficient memory).
458
- WEBP_EXTERN int WebPPictureRescale(WebPPicture* picture, int width, int height);
461
+ WEBP_NODISCARD WEBP_EXTERN int WebPPictureRescale(WebPPicture* picture,
462
+ int width, int height);
459
463
 
460
464
  // Colorspace conversion function to import RGB samples.
461
465
  // Previous buffer will be free'd, if any.
462
466
  // *rgb buffer should have a size of at least height * rgb_stride.
463
467
  // Returns false in case of memory error.
464
- WEBP_EXTERN int WebPPictureImportRGB(
468
+ WEBP_NODISCARD WEBP_EXTERN int WebPPictureImportRGB(
465
469
  WebPPicture* picture, const uint8_t* rgb, int rgb_stride);
466
470
  // Same, but for RGBA buffer.
467
- WEBP_EXTERN int WebPPictureImportRGBA(
471
+ WEBP_NODISCARD WEBP_EXTERN int WebPPictureImportRGBA(
468
472
  WebPPicture* picture, const uint8_t* rgba, int rgba_stride);
469
473
  // Same, but for RGBA buffer. Imports the RGB direct from the 32-bit format
470
474
  // input buffer ignoring the alpha channel. Avoids needing to copy the data
471
475
  // to a temporary 24-bit RGB buffer to import the RGB only.
472
- WEBP_EXTERN int WebPPictureImportRGBX(
476
+ WEBP_NODISCARD WEBP_EXTERN int WebPPictureImportRGBX(
473
477
  WebPPicture* picture, const uint8_t* rgbx, int rgbx_stride);
474
478
 
475
479
  // Variants of the above, but taking BGR(A|X) input.
476
- WEBP_EXTERN int WebPPictureImportBGR(
480
+ WEBP_NODISCARD WEBP_EXTERN int WebPPictureImportBGR(
477
481
  WebPPicture* picture, const uint8_t* bgr, int bgr_stride);
478
- WEBP_EXTERN int WebPPictureImportBGRA(
482
+ WEBP_NODISCARD WEBP_EXTERN int WebPPictureImportBGRA(
479
483
  WebPPicture* picture, const uint8_t* bgra, int bgra_stride);
480
- WEBP_EXTERN int WebPPictureImportBGRX(
484
+ WEBP_NODISCARD WEBP_EXTERN int WebPPictureImportBGRX(
481
485
  WebPPicture* picture, const uint8_t* bgrx, int bgrx_stride);
482
486
 
483
487
  // Converts picture->argb data to the YUV420A format. The 'colorspace'
@@ -486,24 +490,24 @@ WEBP_EXTERN int WebPPictureImportBGRX(
486
490
  // non-opaque transparent values is detected, and 'colorspace' will be
487
491
  // adjusted accordingly. Note that this method is lossy.
488
492
  // Returns false in case of error.
489
- WEBP_EXTERN int WebPPictureARGBToYUVA(WebPPicture* picture,
490
- WebPEncCSP /*colorspace = WEBP_YUV420*/);
493
+ WEBP_NODISCARD WEBP_EXTERN int WebPPictureARGBToYUVA(
494
+ WebPPicture* picture, WebPEncCSP /*colorspace = WEBP_YUV420*/);
491
495
 
492
496
  // Same as WebPPictureARGBToYUVA(), but the conversion is done using
493
497
  // pseudo-random dithering with a strength 'dithering' between
494
498
  // 0.0 (no dithering) and 1.0 (maximum dithering). This is useful
495
499
  // for photographic picture.
496
- WEBP_EXTERN int WebPPictureARGBToYUVADithered(
500
+ WEBP_NODISCARD WEBP_EXTERN int WebPPictureARGBToYUVADithered(
497
501
  WebPPicture* picture, WebPEncCSP colorspace, float dithering);
498
502
 
499
- // Performs 'sharp' RGBA->YUVA420 downsampling and colorspace conversion.
503
+ // Performs 'sharp' RGBA->YUVA420 downsampling and colorspace conversion
500
504
  // Downsampling is handled with extra care in case of color clipping. This
501
505
  // method is roughly 2x slower than WebPPictureARGBToYUVA() but produces better
502
506
  // and sharper YUV representation.
503
507
  // Returns false in case of error.
504
- WEBP_EXTERN int WebPPictureSharpARGBToYUVA(WebPPicture* picture);
508
+ WEBP_NODISCARD WEBP_EXTERN int WebPPictureSharpARGBToYUVA(WebPPicture* picture);
505
509
  // kept for backward compatibility:
506
- WEBP_EXTERN int WebPPictureSmartARGBToYUVA(WebPPicture* picture);
510
+ WEBP_NODISCARD WEBP_EXTERN int WebPPictureSmartARGBToYUVA(WebPPicture* picture);
507
511
 
508
512
  // Converts picture->yuv to picture->argb and sets picture->use_argb to true.
509
513
  // The input format must be YUV_420 or YUV_420A. The conversion from YUV420 to
@@ -511,7 +515,7 @@ WEBP_EXTERN int WebPPictureSmartARGBToYUVA(WebPPicture* picture);
511
515
  // Note that the use of this colorspace is discouraged if one has access to the
512
516
  // raw ARGB samples, since using YUV420 is comparatively lossy.
513
517
  // Returns false in case of error.
514
- WEBP_EXTERN int WebPPictureYUVAToARGB(WebPPicture* picture);
518
+ WEBP_NODISCARD WEBP_EXTERN int WebPPictureYUVAToARGB(WebPPicture* picture);
515
519
 
516
520
  // Helper function: given a width x height plane of RGBA or YUV(A) samples
517
521
  // clean-up or smoothen the YUV or RGB samples under fully transparent area,
@@ -541,7 +545,8 @@ WEBP_EXTERN void WebPBlendAlpha(WebPPicture* picture, uint32_t background_rgb);
541
545
  // the former for lossy encoding, and the latter for lossless encoding
542
546
  // (when config.lossless is true). Automatic conversion from one format to
543
547
  // another is provided but they both incur some loss.
544
- WEBP_EXTERN int WebPEncode(const WebPConfig* config, WebPPicture* picture);
548
+ WEBP_NODISCARD WEBP_EXTERN int WebPEncode(const WebPConfig* config,
549
+ WebPPicture* picture);
545
550
 
546
551
  //------------------------------------------------------------------------------
547
552
 
@@ -16,12 +16,13 @@
16
16
  #define WEBP_WEBP_MUX_H_
17
17
 
18
18
  #include "./mux_types.h"
19
+ #include "./types.h"
19
20
 
20
21
  #ifdef __cplusplus
21
22
  extern "C" {
22
23
  #endif
23
24
 
24
- #define WEBP_MUX_ABI_VERSION 0x0108 // MAJOR(8b) + MINOR(8b)
25
+ #define WEBP_MUX_ABI_VERSION 0x0109 // MAJOR(8b) + MINOR(8b)
25
26
 
26
27
  //------------------------------------------------------------------------------
27
28
  // Mux API
@@ -70,7 +71,7 @@ typedef struct WebPMuxAnimParams WebPMuxAnimParams;
70
71
  typedef struct WebPAnimEncoderOptions WebPAnimEncoderOptions;
71
72
 
72
73
  // Error codes
73
- typedef enum WebPMuxError {
74
+ typedef enum WEBP_NODISCARD WebPMuxError {
74
75
  WEBP_MUX_OK = 1,
75
76
  WEBP_MUX_NOT_FOUND = 0,
76
77
  WEBP_MUX_INVALID_ARGUMENT = -1,
@@ -104,13 +105,13 @@ WEBP_EXTERN int WebPGetMuxVersion(void);
104
105
  // Life of a Mux object
105
106
 
106
107
  // Internal, version-checked, entry point
107
- WEBP_EXTERN WebPMux* WebPNewInternal(int);
108
+ WEBP_NODISCARD WEBP_EXTERN WebPMux* WebPNewInternal(int);
108
109
 
109
110
  // Creates an empty mux object.
110
111
  // Returns:
111
112
  // A pointer to the newly created empty mux object.
112
113
  // Or NULL in case of memory error.
113
- static WEBP_INLINE WebPMux* WebPMuxNew(void) {
114
+ WEBP_NODISCARD static WEBP_INLINE WebPMux* WebPMuxNew(void) {
114
115
  return WebPNewInternal(WEBP_MUX_ABI_VERSION);
115
116
  }
116
117
 
@@ -123,18 +124,21 @@ WEBP_EXTERN void WebPMuxDelete(WebPMux* mux);
123
124
  // Mux creation.
124
125
 
125
126
  // Internal, version-checked, entry point
126
- WEBP_EXTERN WebPMux* WebPMuxCreateInternal(const WebPData*, int, int);
127
+ WEBP_NODISCARD WEBP_EXTERN WebPMux* WebPMuxCreateInternal(const WebPData*, int,
128
+ int);
127
129
 
128
130
  // Creates a mux object from raw data given in WebP RIFF format.
129
131
  // Parameters:
130
132
  // bitstream - (in) the bitstream data in WebP RIFF format
131
133
  // copy_data - (in) value 1 indicates given data WILL be copied to the mux
132
- // object and value 0 indicates data will NOT be copied.
134
+ // object and value 0 indicates data will NOT be copied. If the
135
+ // data is not copied, it must exist for the lifetime of the
136
+ // mux object.
133
137
  // Returns:
134
138
  // A pointer to the mux object created from given data - on success.
135
139
  // NULL - In case of invalid data or memory error.
136
- static WEBP_INLINE WebPMux* WebPMuxCreate(const WebPData* bitstream,
137
- int copy_data) {
140
+ WEBP_NODISCARD static WEBP_INLINE WebPMux* WebPMuxCreate(
141
+ const WebPData* bitstream, int copy_data) {
138
142
  return WebPMuxCreateInternal(bitstream, copy_data, WEBP_MUX_ABI_VERSION);
139
143
  }
140
144
 
@@ -154,7 +158,9 @@ static WEBP_INLINE WebPMux* WebPMuxCreate(const WebPData* bitstream,
154
158
  // e.g., "ICCP", "XMP ", "EXIF" etc.
155
159
  // chunk_data - (in) the chunk data to be added
156
160
  // copy_data - (in) value 1 indicates given data WILL be copied to the mux
157
- // object and value 0 indicates data will NOT be copied.
161
+ // object and value 0 indicates data will NOT be copied. If the
162
+ // data is not copied, it must exist until a call to
163
+ // WebPMuxAssemble() is made.
158
164
  // Returns:
159
165
  // WEBP_MUX_INVALID_ARGUMENT - if mux, fourcc or chunk_data is NULL
160
166
  // or if fourcc corresponds to an image chunk.
@@ -217,7 +223,9 @@ struct WebPMuxFrameInfo {
217
223
  // bitstream - (in) can be a raw VP8/VP8L bitstream or a single-image
218
224
  // WebP file (non-animated)
219
225
  // copy_data - (in) value 1 indicates given data WILL be copied to the mux
220
- // object and value 0 indicates data will NOT be copied.
226
+ // object and value 0 indicates data will NOT be copied. If the
227
+ // data is not copied, it must exist until a call to
228
+ // WebPMuxAssemble() is made.
221
229
  // Returns:
222
230
  // WEBP_MUX_INVALID_ARGUMENT - if mux is NULL or bitstream is NULL.
223
231
  // WEBP_MUX_MEMORY_ERROR - on memory allocation error.
@@ -235,7 +243,9 @@ WEBP_EXTERN WebPMuxError WebPMuxSetImage(
235
243
  // mux - (in/out) object to which the frame is to be added
236
244
  // frame - (in) frame data.
237
245
  // copy_data - (in) value 1 indicates given data WILL be copied to the mux
238
- // object and value 0 indicates data will NOT be copied.
246
+ // object and value 0 indicates data will NOT be copied. If the
247
+ // data is not copied, it must exist until a call to
248
+ // WebPMuxAssemble() is made.
239
249
  // Returns:
240
250
  // WEBP_MUX_INVALID_ARGUMENT - if mux or frame is NULL
241
251
  // or if content of 'frame' is invalid.
@@ -449,7 +459,7 @@ WEBP_EXTERN int WebPAnimEncoderOptionsInitInternal(
449
459
  // structure before modification. Returns false in case of version mismatch.
450
460
  // WebPAnimEncoderOptionsInit() must have succeeded before using the
451
461
  // 'enc_options' object.
452
- static WEBP_INLINE int WebPAnimEncoderOptionsInit(
462
+ WEBP_NODISCARD static WEBP_INLINE int WebPAnimEncoderOptionsInit(
453
463
  WebPAnimEncoderOptions* enc_options) {
454
464
  return WebPAnimEncoderOptionsInitInternal(enc_options, WEBP_MUX_ABI_VERSION);
455
465
  }
@@ -490,7 +500,7 @@ static WEBP_INLINE WebPAnimEncoder* WebPAnimEncoderNew(
490
500
  // Returns:
491
501
  // On error, returns false and frame->error_code is set appropriately.
492
502
  // Otherwise, returns true.
493
- WEBP_EXTERN int WebPAnimEncoderAdd(
503
+ WEBP_NODISCARD WEBP_EXTERN int WebPAnimEncoderAdd(
494
504
  WebPAnimEncoder* enc, struct WebPPicture* frame, int timestamp_ms,
495
505
  const struct WebPConfig* config);
496
506
 
@@ -503,8 +513,8 @@ WEBP_EXTERN int WebPAnimEncoderAdd(
503
513
  // webp_data - (out) generated WebP bitstream.
504
514
  // Returns:
505
515
  // True on success.
506
- WEBP_EXTERN int WebPAnimEncoderAssemble(WebPAnimEncoder* enc,
507
- WebPData* webp_data);
516
+ WEBP_NODISCARD WEBP_EXTERN int WebPAnimEncoderAssemble(WebPAnimEncoder* enc,
517
+ WebPData* webp_data);
508
518
 
509
519
  // Get error string corresponding to the most recent call using 'enc'. The
510
520
  // returned string is owned by 'enc' and is valid only until the next call to
@@ -521,6 +531,57 @@ WEBP_EXTERN const char* WebPAnimEncoderGetError(WebPAnimEncoder* enc);
521
531
  // enc - (in/out) object to be deleted
522
532
  WEBP_EXTERN void WebPAnimEncoderDelete(WebPAnimEncoder* enc);
523
533
 
534
+ //------------------------------------------------------------------------------
535
+ // Non-image chunks.
536
+
537
+ // Note: Only non-image related chunks should be managed through chunk APIs.
538
+ // (Image related chunks are: "ANMF", "VP8 ", "VP8L" and "ALPH").
539
+
540
+ // Adds a chunk with id 'fourcc' and data 'chunk_data' in the enc object.
541
+ // Any existing chunk(s) with the same id will be removed.
542
+ // Parameters:
543
+ // enc - (in/out) object to which the chunk is to be added
544
+ // fourcc - (in) a character array containing the fourcc of the given chunk;
545
+ // e.g., "ICCP", "XMP ", "EXIF", etc.
546
+ // chunk_data - (in) the chunk data to be added
547
+ // copy_data - (in) value 1 indicates given data WILL be copied to the enc
548
+ // object and value 0 indicates data will NOT be copied. If the
549
+ // data is not copied, it must exist until a call to
550
+ // WebPAnimEncoderAssemble() is made.
551
+ // Returns:
552
+ // WEBP_MUX_INVALID_ARGUMENT - if enc, fourcc or chunk_data is NULL.
553
+ // WEBP_MUX_MEMORY_ERROR - on memory allocation error.
554
+ // WEBP_MUX_OK - on success.
555
+ WEBP_EXTERN WebPMuxError WebPAnimEncoderSetChunk(
556
+ WebPAnimEncoder* enc, const char fourcc[4], const WebPData* chunk_data,
557
+ int copy_data);
558
+
559
+ // Gets a reference to the data of the chunk with id 'fourcc' in the enc object.
560
+ // The caller should NOT free the returned data.
561
+ // Parameters:
562
+ // enc - (in) object from which the chunk data is to be fetched
563
+ // fourcc - (in) a character array containing the fourcc of the chunk;
564
+ // e.g., "ICCP", "XMP ", "EXIF", etc.
565
+ // chunk_data - (out) returned chunk data
566
+ // Returns:
567
+ // WEBP_MUX_INVALID_ARGUMENT - if enc, fourcc or chunk_data is NULL.
568
+ // WEBP_MUX_NOT_FOUND - If enc does not contain a chunk with the given id.
569
+ // WEBP_MUX_OK - on success.
570
+ WEBP_EXTERN WebPMuxError WebPAnimEncoderGetChunk(
571
+ const WebPAnimEncoder* enc, const char fourcc[4], WebPData* chunk_data);
572
+
573
+ // Deletes the chunk with the given 'fourcc' from the enc object.
574
+ // Parameters:
575
+ // enc - (in/out) object from which the chunk is to be deleted
576
+ // fourcc - (in) a character array containing the fourcc of the chunk;
577
+ // e.g., "ICCP", "XMP ", "EXIF", etc.
578
+ // Returns:
579
+ // WEBP_MUX_INVALID_ARGUMENT - if enc or fourcc is NULL.
580
+ // WEBP_MUX_NOT_FOUND - If enc does not contain a chunk with the given fourcc.
581
+ // WEBP_MUX_OK - on success.
582
+ WEBP_EXTERN WebPMuxError WebPAnimEncoderDeleteChunk(
583
+ WebPAnimEncoder* enc, const char fourcc[4]);
584
+
524
585
  //------------------------------------------------------------------------------
525
586
 
526
587
  #ifdef __cplusplus
@@ -79,7 +79,8 @@ static WEBP_INLINE void WebPDataClear(WebPData* webp_data) {
79
79
 
80
80
  // Allocates necessary storage for 'dst' and copies the contents of 'src'.
81
81
  // Returns true on success.
82
- static WEBP_INLINE int WebPDataCopy(const WebPData* src, WebPData* dst) {
82
+ WEBP_NODISCARD static WEBP_INLINE int WebPDataCopy(const WebPData* src,
83
+ WebPData* dst) {
83
84
  if (src == NULL || dst == NULL) return 0;
84
85
  WebPDataInit(dst);
85
86
  if (src->bytes != NULL && src->size != 0) {