@img/sharp-libvips-dev-wasm32 1.0.3 → 1.0.5

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 (119) hide show
  1. package/include/aom/aom_decoder.h +1 -1
  2. package/include/aom/aom_encoder.h +7 -1
  3. package/include/aom/aom_image.h +24 -12
  4. package/include/aom/aom_integer.h +3 -3
  5. package/include/aom/aomcx.h +15 -0
  6. package/include/aom/aomdx.h +5 -2
  7. package/include/cgif.h +3 -0
  8. package/include/glib-2.0/gio/gappinfo.h +40 -25
  9. package/include/glib-2.0/gio/gasyncresult.h +1 -1
  10. package/include/glib-2.0/gio/gconverter.h +5 -0
  11. package/include/glib-2.0/gio/gdbusintrospection.h +1 -1
  12. package/include/glib-2.0/gio/gfile.h +16 -0
  13. package/include/glib-2.0/gio/gio-visibility.h +34 -0
  14. package/include/glib-2.0/gio/gsettings.h +8 -0
  15. package/include/glib-2.0/gio/gvfs.h +2 -2
  16. package/include/glib-2.0/glib/gbookmarkfile.h +1 -1
  17. package/include/glib-2.0/glib/giochannel.h +2 -2
  18. package/include/glib-2.0/glib/glib-visibility.h +34 -0
  19. package/include/glib-2.0/glib/gmacros.h +12 -5
  20. package/include/glib-2.0/glib/gmain.h +93 -7
  21. package/include/glib-2.0/glib/gqsort.h +8 -1
  22. package/include/glib-2.0/glib/gstrfuncs.h +0 -12
  23. package/include/glib-2.0/glib/gstrvbuilder.h +3 -0
  24. package/include/glib-2.0/glib/gunicode.h +1 -1
  25. package/include/glib-2.0/glib/gversionmacros.h +9 -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/gtype.h +6 -6
  29. package/include/hwy/abort.h +28 -0
  30. package/include/hwy/aligned_allocator.h +48 -1
  31. package/include/hwy/base.h +235 -34
  32. package/include/hwy/detect_compiler_arch.h +84 -10
  33. package/include/hwy/detect_targets.h +95 -29
  34. package/include/hwy/foreach_target.h +12 -1
  35. package/include/hwy/highway.h +205 -50
  36. package/include/hwy/ops/arm_neon-inl.h +841 -99
  37. package/include/hwy/ops/arm_sve-inl.h +413 -141
  38. package/include/hwy/ops/emu128-inl.h +373 -360
  39. package/include/hwy/ops/generic_ops-inl.h +804 -401
  40. package/include/hwy/ops/inside-inl.h +691 -0
  41. package/include/hwy/ops/ppc_vsx-inl.h +456 -166
  42. package/include/hwy/ops/rvv-inl.h +537 -249
  43. package/include/hwy/ops/scalar-inl.h +169 -79
  44. package/include/hwy/ops/set_macros-inl.h +106 -18
  45. package/include/hwy/ops/shared-inl.h +23 -0
  46. package/include/hwy/ops/wasm_128-inl.h +130 -108
  47. package/include/hwy/ops/x86_128-inl.h +1892 -577
  48. package/include/hwy/ops/x86_256-inl.h +625 -184
  49. package/include/hwy/ops/x86_512-inl.h +733 -131
  50. package/include/hwy/targets.h +22 -21
  51. package/include/hwy/timer-inl.h +3 -3
  52. package/include/hwy/timer.h +5 -1
  53. package/include/libheif/heif.h +170 -15
  54. package/include/libheif/heif_items.h +237 -0
  55. package/include/libheif/heif_properties.h +38 -2
  56. package/include/libheif/heif_regions.h +1 -1
  57. package/include/libheif/heif_version.h +2 -2
  58. package/include/resvg.h +2 -12
  59. package/include/vips/util.h +1 -2
  60. package/include/vips/version.h +4 -4
  61. package/include/webp/decode.h +58 -56
  62. package/include/webp/demux.h +25 -21
  63. package/include/webp/encode.h +44 -39
  64. package/include/webp/mux.h +76 -15
  65. package/include/webp/mux_types.h +2 -1
  66. package/include/webp/sharpyuv/sharpyuv.h +77 -8
  67. package/include/webp/types.h +29 -8
  68. package/include/zconf.h +1 -1
  69. package/include/zlib.h +12 -12
  70. package/lib/glib-2.0/include/glibconfig.h +2 -2
  71. package/lib/libaom.a +0 -0
  72. package/lib/libcgif.a +0 -0
  73. package/lib/libexif.a +0 -0
  74. package/lib/libexpat.a +0 -0
  75. package/lib/libffi.a +0 -0
  76. package/lib/libgio-2.0.a +0 -0
  77. package/lib/libglib-2.0.a +0 -0
  78. package/lib/libgmodule-2.0.a +0 -0
  79. package/lib/libgobject-2.0.a +0 -0
  80. package/lib/libgthread-2.0.a +0 -0
  81. package/lib/libheif.a +0 -0
  82. package/lib/libhwy.a +0 -0
  83. package/lib/libimagequant.a +0 -0
  84. package/lib/libjpeg.a +0 -0
  85. package/lib/liblcms2.a +0 -0
  86. package/lib/libresvg.a +0 -0
  87. package/lib/libsharpyuv.a +0 -0
  88. package/lib/libsharpyuv.la +4 -4
  89. package/lib/libspng.a +0 -0
  90. package/lib/libtiff.a +0 -0
  91. package/lib/libvips-cpp.a +0 -0
  92. package/lib/libvips.a +0 -0
  93. package/lib/libwebp.a +0 -0
  94. package/lib/libwebp.la +2 -2
  95. package/lib/libwebpdemux.a +0 -0
  96. package/lib/libwebpdemux.la +2 -2
  97. package/lib/libwebpmux.a +0 -0
  98. package/lib/libwebpmux.la +4 -4
  99. package/lib/libz.a +0 -0
  100. package/lib/pkgconfig/aom.pc +2 -2
  101. package/lib/pkgconfig/cgif.pc +1 -1
  102. package/lib/pkgconfig/gio-2.0.pc +1 -1
  103. package/lib/pkgconfig/glib-2.0.pc +1 -1
  104. package/lib/pkgconfig/gmodule-2.0.pc +1 -1
  105. package/lib/pkgconfig/gmodule-export-2.0.pc +1 -1
  106. package/lib/pkgconfig/gmodule-no-export-2.0.pc +1 -1
  107. package/lib/pkgconfig/gobject-2.0.pc +1 -1
  108. package/lib/pkgconfig/gthread-2.0.pc +1 -1
  109. package/lib/pkgconfig/libheif.pc +1 -10
  110. package/lib/pkgconfig/libhwy.pc +1 -1
  111. package/lib/pkgconfig/libsharpyuv.pc +1 -1
  112. package/lib/pkgconfig/libwebp.pc +1 -1
  113. package/lib/pkgconfig/libwebpdemux.pc +1 -1
  114. package/lib/pkgconfig/libwebpmux.pc +1 -1
  115. package/lib/pkgconfig/vips-cpp.pc +1 -1
  116. package/lib/pkgconfig/vips.pc +1 -1
  117. package/lib/pkgconfig/zlib.pc +1 -1
  118. package/package.json +1 -1
  119. package/versions.json +10 -10
@@ -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) {
@@ -22,22 +22,37 @@ extern "C" {
22
22
  #else
23
23
  // This explicitly marks library functions and allows for changing the
24
24
  // signature for e.g., Windows DLL builds.
25
- #if defined(__GNUC__) && __GNUC__ >= 4
26
- #define SHARPYUV_EXTERN extern __attribute__((visibility("default")))
27
- #else
28
- #if defined(_MSC_VER) && defined(WEBP_DLL)
25
+ #if defined(_WIN32) && defined(WEBP_DLL)
29
26
  #define SHARPYUV_EXTERN __declspec(dllexport)
27
+ #elif defined(__GNUC__) && __GNUC__ >= 4
28
+ #define SHARPYUV_EXTERN extern __attribute__((visibility("default")))
30
29
  #else
31
30
  #define SHARPYUV_EXTERN extern
32
- #endif /* _MSC_VER && WEBP_DLL */
33
- #endif /* __GNUC__ >= 4 */
31
+ #endif /* defined(_WIN32) && defined(WEBP_DLL) */
34
32
  #endif /* WEBP_EXTERN */
35
33
  #endif /* SHARPYUV_EXTERN */
36
34
 
35
+ #ifndef SHARPYUV_INLINE
36
+ #ifdef WEBP_INLINE
37
+ #define SHARPYUV_INLINE WEBP_INLINE
38
+ #else
39
+ #ifndef _MSC_VER
40
+ #if defined(__cplusplus) || !defined(__STRICT_ANSI__) || \
41
+ (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
42
+ #define SHARPYUV_INLINE inline
43
+ #else
44
+ #define SHARPYUV_INLINE
45
+ #endif
46
+ #else
47
+ #define SHARPYUV_INLINE __forceinline
48
+ #endif /* _MSC_VER */
49
+ #endif /* WEBP_INLINE */
50
+ #endif /* SHARPYUV_INLINE */
51
+
37
52
  // SharpYUV API version following the convention from semver.org
38
53
  #define SHARPYUV_VERSION_MAJOR 0
39
- #define SHARPYUV_VERSION_MINOR 2
40
- #define SHARPYUV_VERSION_PATCH 1
54
+ #define SHARPYUV_VERSION_MINOR 4
55
+ #define SHARPYUV_VERSION_PATCH 0
41
56
  // Version as a uint32_t. The major number is the high 8 bits.
42
57
  // The minor number is the middle 8 bits. The patch number is the low 16 bits.
43
58
  #define SHARPYUV_MAKE_VERSION(MAJOR, MINOR, PATCH) \
@@ -61,6 +76,33 @@ typedef struct {
61
76
  int rgb_to_v[4];
62
77
  } SharpYuvConversionMatrix;
63
78
 
79
+ typedef struct SharpYuvOptions SharpYuvOptions;
80
+
81
+ // Enums for transfer functions, as defined in H.273,
82
+ // https://www.itu.int/rec/T-REC-H.273-202107-I/en
83
+ typedef enum SharpYuvTransferFunctionType {
84
+ // 0 is reserved
85
+ kSharpYuvTransferFunctionBt709 = 1,
86
+ // 2 is unspecified
87
+ // 3 is reserved
88
+ kSharpYuvTransferFunctionBt470M = 4,
89
+ kSharpYuvTransferFunctionBt470Bg = 5,
90
+ kSharpYuvTransferFunctionBt601 = 6,
91
+ kSharpYuvTransferFunctionSmpte240 = 7,
92
+ kSharpYuvTransferFunctionLinear = 8,
93
+ kSharpYuvTransferFunctionLog100 = 9,
94
+ kSharpYuvTransferFunctionLog100_Sqrt10 = 10,
95
+ kSharpYuvTransferFunctionIec61966 = 11,
96
+ kSharpYuvTransferFunctionBt1361 = 12,
97
+ kSharpYuvTransferFunctionSrgb = 13,
98
+ kSharpYuvTransferFunctionBt2020_10Bit = 14,
99
+ kSharpYuvTransferFunctionBt2020_12Bit = 15,
100
+ kSharpYuvTransferFunctionSmpte2084 = 16, // PQ
101
+ kSharpYuvTransferFunctionSmpte428 = 17,
102
+ kSharpYuvTransferFunctionHlg = 18,
103
+ kSharpYuvTransferFunctionNum
104
+ } SharpYuvTransferFunctionType;
105
+
64
106
  // Converts RGB to YUV420 using a downsampling algorithm that minimizes
65
107
  // artefacts caused by chroma subsampling.
66
108
  // This is slower than standard downsampling (averaging of 4 UV values).
@@ -85,6 +127,8 @@ typedef struct {
85
127
  // adjacent pixels on the y, u and v channels. If yuv_bit_depth > 8, they
86
128
  // should be multiples of 2.
87
129
  // width, height: width and height of the image in pixels
130
+ // This function calls SharpYuvConvertWithOptions with a default transfer
131
+ // function of kSharpYuvTransferFunctionSrgb.
88
132
  SHARPYUV_EXTERN int SharpYuvConvert(const void* r_ptr, const void* g_ptr,
89
133
  const void* b_ptr, int rgb_step,
90
134
  int rgb_stride, int rgb_bit_depth,
@@ -93,6 +137,31 @@ SHARPYUV_EXTERN int SharpYuvConvert(const void* r_ptr, const void* g_ptr,
93
137
  int yuv_bit_depth, int width, int height,
94
138
  const SharpYuvConversionMatrix* yuv_matrix);
95
139
 
140
+ struct SharpYuvOptions {
141
+ // This matrix cannot be NULL and can be initialized by
142
+ // SharpYuvComputeConversionMatrix.
143
+ const SharpYuvConversionMatrix* yuv_matrix;
144
+ SharpYuvTransferFunctionType transfer_type;
145
+ };
146
+
147
+ // Internal, version-checked, entry point
148
+ SHARPYUV_EXTERN int SharpYuvOptionsInitInternal(const SharpYuvConversionMatrix*,
149
+ SharpYuvOptions*, int);
150
+
151
+ // Should always be called, to initialize a fresh SharpYuvOptions
152
+ // structure before modification. SharpYuvOptionsInit() must have succeeded
153
+ // before using the 'options' object.
154
+ static SHARPYUV_INLINE int SharpYuvOptionsInit(
155
+ const SharpYuvConversionMatrix* yuv_matrix, SharpYuvOptions* options) {
156
+ return SharpYuvOptionsInitInternal(yuv_matrix, options, SHARPYUV_VERSION);
157
+ }
158
+
159
+ SHARPYUV_EXTERN int SharpYuvConvertWithOptions(
160
+ const void* r_ptr, const void* g_ptr, const void* b_ptr, int rgb_step,
161
+ int rgb_stride, int rgb_bit_depth, void* y_ptr, int y_stride, void* u_ptr,
162
+ int u_stride, void* v_ptr, int v_stride, int yuv_bit_depth, int width,
163
+ int height, const SharpYuvOptions* options);
164
+
96
165
  // TODO(b/194336375): Add YUV444 to YUV420 conversion. Maybe also add 422
97
166
  // support (it's rarely used in practice, especially for images).
98
167
 
@@ -36,18 +36,39 @@ typedef long long int int64_t;
36
36
  #define WEBP_INLINE __forceinline
37
37
  #endif /* _MSC_VER */
38
38
 
39
+ #ifndef WEBP_NODISCARD
40
+ #if defined(WEBP_ENABLE_NODISCARD) && WEBP_ENABLE_NODISCARD
41
+ #if (defined(__cplusplus) && __cplusplus >= 201700L) || \
42
+ (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L)
43
+ #define WEBP_NODISCARD [[nodiscard]]
44
+ #else
45
+ // gcc's __has_attribute does not work for enums.
46
+ #if defined(__clang__) && defined(__has_attribute)
47
+ #if __has_attribute(warn_unused_result)
48
+ #define WEBP_NODISCARD __attribute__((warn_unused_result))
49
+ #else
50
+ #define WEBP_NODISCARD
51
+ #endif /* __has_attribute(warn_unused_result) */
52
+ #else
53
+ #define WEBP_NODISCARD
54
+ #endif /* defined(__clang__) && defined(__has_attribute) */
55
+ #endif /* (defined(__cplusplus) && __cplusplus >= 201700L) ||
56
+ (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) */
57
+ #else
58
+ #define WEBP_NODISCARD
59
+ #endif /* defined(WEBP_ENABLE_NODISCARD) && WEBP_ENABLE_NODISCARD */
60
+ #endif /* WEBP_NODISCARD */
61
+
39
62
  #ifndef WEBP_EXTERN
40
63
  // This explicitly marks library functions and allows for changing the
41
64
  // signature for e.g., Windows DLL builds.
42
- # if defined(__GNUC__) && __GNUC__ >= 4
65
+ # if defined(_WIN32) && defined(WEBP_DLL)
66
+ # define WEBP_EXTERN __declspec(dllexport)
67
+ # elif defined(__GNUC__) && __GNUC__ >= 4
43
68
  # define WEBP_EXTERN extern __attribute__ ((visibility ("default")))
44
69
  # else
45
- # if defined(_MSC_VER) && defined(WEBP_DLL)
46
- # define WEBP_EXTERN __declspec(dllexport)
47
- # else
48
- # define WEBP_EXTERN extern
49
- # endif
50
- # endif /* __GNUC__ >= 4 */
70
+ # define WEBP_EXTERN extern
71
+ # endif /* defined(_WIN32) && defined(WEBP_DLL) */
51
72
  #endif /* WEBP_EXTERN */
52
73
 
53
74
  // Macro to check ABI compatibility (same major revision number)
@@ -60,7 +81,7 @@ extern "C" {
60
81
  // Allocates 'size' bytes of memory. Returns NULL upon error. Memory
61
82
  // must be deallocated by calling WebPFree(). This function is made available
62
83
  // by the core 'libwebp' library.
63
- WEBP_EXTERN void* WebPMalloc(size_t size);
84
+ WEBP_NODISCARD WEBP_EXTERN void* WebPMalloc(size_t size);
64
85
 
65
86
  // Releases memory returned by the WebPDecode*() functions (from decode.h).
66
87
  WEBP_EXTERN void WebPFree(void* ptr);
package/include/zconf.h CHANGED
@@ -1,5 +1,5 @@
1
1
  /* zconf.h -- configuration of the zlib compression library
2
- * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
2
+ * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
3
3
  * For conditions of distribution and use, see copyright notice in zlib.h
4
4
  */
5
5