@img/sharp-libvips-dev 0.0.1 → 0.0.2

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 (103) hide show
  1. package/README.md +2 -2
  2. package/cplusplus/VConnection.cpp +54 -54
  3. package/cplusplus/VError.cpp +20 -18
  4. package/cplusplus/VImage.cpp +636 -589
  5. package/cplusplus/VInterpolate.cpp +22 -22
  6. package/cplusplus/VRegion.cpp +4 -4
  7. package/cplusplus/vips-operators.cpp +2326 -2301
  8. package/include/aom/aom_codec.h +10 -6
  9. package/include/aom/aom_decoder.h +1 -1
  10. package/include/aom/aom_encoder.h +9 -2
  11. package/include/aom/aomcx.h +72 -3
  12. package/include/cairo/cairo-ft.h +1 -1
  13. package/include/cairo/cairo-gobject.h +8 -0
  14. package/include/cairo/cairo-svg.h +3 -3
  15. package/include/cairo/cairo-version.h +2 -2
  16. package/include/cairo/cairo.h +91 -24
  17. package/include/harfbuzz/hb-version.h +2 -2
  18. package/include/hwy/aligned_allocator.h +211 -0
  19. package/include/hwy/base.h +1517 -0
  20. package/include/hwy/cache_control.h +108 -0
  21. package/include/hwy/detect_compiler_arch.h +281 -0
  22. package/include/hwy/detect_targets.h +644 -0
  23. package/include/hwy/foreach_target.h +340 -0
  24. package/include/hwy/highway.h +435 -0
  25. package/include/hwy/highway_export.h +74 -0
  26. package/include/hwy/nanobenchmark.h +171 -0
  27. package/include/hwy/ops/arm_neon-inl.h +8913 -0
  28. package/include/hwy/ops/arm_sve-inl.h +5105 -0
  29. package/include/hwy/ops/emu128-inl.h +2811 -0
  30. package/include/hwy/ops/generic_ops-inl.h +4745 -0
  31. package/include/hwy/ops/ppc_vsx-inl.h +5716 -0
  32. package/include/hwy/ops/rvv-inl.h +5070 -0
  33. package/include/hwy/ops/scalar-inl.h +1995 -0
  34. package/include/hwy/ops/set_macros-inl.h +578 -0
  35. package/include/hwy/ops/shared-inl.h +539 -0
  36. package/include/hwy/ops/tuple-inl.h +125 -0
  37. package/include/hwy/ops/wasm_128-inl.h +5917 -0
  38. package/include/hwy/ops/x86_128-inl.h +11173 -0
  39. package/include/hwy/ops/x86_256-inl.h +7529 -0
  40. package/include/hwy/ops/x86_512-inl.h +6849 -0
  41. package/include/hwy/per_target.h +44 -0
  42. package/include/hwy/print-inl.h +62 -0
  43. package/include/hwy/print.h +75 -0
  44. package/include/hwy/robust_statistics.h +148 -0
  45. package/include/hwy/targets.h +338 -0
  46. package/include/hwy/timer-inl.h +200 -0
  47. package/include/hwy/timer.h +55 -0
  48. package/include/jconfig.h +2 -2
  49. package/include/jpeglib.h +3 -2
  50. package/include/libheif/heif.h +443 -377
  51. package/include/libheif/heif_cxx.h +4 -1
  52. package/include/libheif/heif_plugin.h +1 -1
  53. package/include/libheif/heif_properties.h +138 -0
  54. package/include/libheif/heif_regions.h +866 -0
  55. package/include/libheif/heif_version.h +3 -3
  56. package/include/vips/VConnection8.h +43 -49
  57. package/include/vips/VError8.h +27 -24
  58. package/include/vips/VImage8.h +4861 -4597
  59. package/include/vips/VInterpolate8.h +24 -27
  60. package/include/vips/VRegion8.h +32 -33
  61. package/include/vips/arithmetic.h +169 -169
  62. package/include/vips/basic.h +33 -33
  63. package/include/vips/buf.h +56 -54
  64. package/include/vips/colour.h +95 -95
  65. package/include/vips/connection.h +190 -193
  66. package/include/vips/conversion.h +91 -91
  67. package/include/vips/convolution.h +36 -30
  68. package/include/vips/create.h +63 -63
  69. package/include/vips/dbuf.h +35 -37
  70. package/include/vips/debug.h +65 -33
  71. package/include/vips/draw.h +41 -41
  72. package/include/vips/enumtypes.h +54 -51
  73. package/include/vips/error.h +63 -63
  74. package/include/vips/foreign.h +263 -223
  75. package/include/vips/format.h +48 -48
  76. package/include/vips/freqfilt.h +22 -22
  77. package/include/vips/gate.h +55 -47
  78. package/include/vips/generate.h +34 -34
  79. package/include/vips/header.h +111 -101
  80. package/include/vips/histogram.h +28 -28
  81. package/include/vips/image.h +213 -213
  82. package/include/vips/interpolate.h +40 -41
  83. package/include/vips/memory.h +61 -52
  84. package/include/vips/morphology.h +24 -24
  85. package/include/vips/mosaicing.h +32 -33
  86. package/include/vips/object.h +371 -357
  87. package/include/vips/operation.h +68 -67
  88. package/include/vips/private.h +76 -76
  89. package/include/vips/rect.h +26 -26
  90. package/include/vips/region.h +92 -92
  91. package/include/vips/resample.h +38 -38
  92. package/include/vips/sbuf.h +53 -54
  93. package/include/vips/semaphore.h +24 -24
  94. package/include/vips/thread.h +30 -27
  95. package/include/vips/threadpool.h +48 -49
  96. package/include/vips/transform.h +39 -39
  97. package/include/vips/type.h +90 -85
  98. package/include/vips/util.h +274 -229
  99. package/include/vips/vector.h +24 -144
  100. package/include/vips/version.h +9 -9
  101. package/include/vips/vips.h +41 -40
  102. package/package.json +1 -1
  103. package/versions.json +7 -7
@@ -0,0 +1,211 @@
1
+ // Copyright 2020 Google LLC
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+
16
+ #ifndef HIGHWAY_HWY_ALIGNED_ALLOCATOR_H_
17
+ #define HIGHWAY_HWY_ALIGNED_ALLOCATOR_H_
18
+
19
+ // Memory allocator with support for alignment and offsets.
20
+
21
+ #include <memory>
22
+ #include <utility>
23
+
24
+ #include "hwy/base.h"
25
+
26
+ namespace hwy {
27
+
28
+ // Minimum alignment of allocated memory for use in HWY_ASSUME_ALIGNED, which
29
+ // requires a literal. This matches typical L1 cache line sizes, which prevents
30
+ // false sharing.
31
+ #define HWY_ALIGNMENT 64
32
+
33
+ // Pointers to functions equivalent to malloc/free with an opaque void* passed
34
+ // to them.
35
+ using AllocPtr = void* (*)(void* opaque, size_t bytes);
36
+ using FreePtr = void (*)(void* opaque, void* memory);
37
+
38
+ // Returns null or a pointer to at least `payload_size` (which can be zero)
39
+ // bytes of newly allocated memory, aligned to the larger of HWY_ALIGNMENT and
40
+ // the vector size. Calls `alloc` with the passed `opaque` pointer to obtain
41
+ // memory or malloc() if it is null.
42
+ HWY_DLLEXPORT void* AllocateAlignedBytes(size_t payload_size,
43
+ AllocPtr alloc_ptr, void* opaque_ptr);
44
+
45
+ // Frees all memory. No effect if `aligned_pointer` == nullptr, otherwise it
46
+ // must have been returned from a previous call to `AllocateAlignedBytes`.
47
+ // Calls `free_ptr` with the passed `opaque_ptr` pointer to free the memory; if
48
+ // `free_ptr` function is null, uses the default free().
49
+ HWY_DLLEXPORT void FreeAlignedBytes(const void* aligned_pointer,
50
+ FreePtr free_ptr, void* opaque_ptr);
51
+
52
+ // Class that deletes the aligned pointer passed to operator() calling the
53
+ // destructor before freeing the pointer. This is equivalent to the
54
+ // std::default_delete but for aligned objects. For a similar deleter equivalent
55
+ // to free() for aligned memory see AlignedFreer().
56
+ class AlignedDeleter {
57
+ public:
58
+ AlignedDeleter() : free_(nullptr), opaque_ptr_(nullptr) {}
59
+ AlignedDeleter(FreePtr free_ptr, void* opaque_ptr)
60
+ : free_(free_ptr), opaque_ptr_(opaque_ptr) {}
61
+
62
+ template <typename T>
63
+ void operator()(T* aligned_pointer) const {
64
+ return DeleteAlignedArray(aligned_pointer, free_, opaque_ptr_,
65
+ TypedArrayDeleter<T>);
66
+ }
67
+
68
+ private:
69
+ template <typename T>
70
+ static void TypedArrayDeleter(void* ptr, size_t size_in_bytes) {
71
+ size_t elems = size_in_bytes / sizeof(T);
72
+ for (size_t i = 0; i < elems; i++) {
73
+ // Explicitly call the destructor on each element.
74
+ (static_cast<T*>(ptr) + i)->~T();
75
+ }
76
+ }
77
+
78
+ // Function prototype that calls the destructor for each element in a typed
79
+ // array. TypeArrayDeleter<T> would match this prototype.
80
+ using ArrayDeleter = void (*)(void* t_ptr, size_t t_size);
81
+
82
+ HWY_DLLEXPORT static void DeleteAlignedArray(void* aligned_pointer,
83
+ FreePtr free_ptr,
84
+ void* opaque_ptr,
85
+ ArrayDeleter deleter);
86
+
87
+ FreePtr free_;
88
+ void* opaque_ptr_;
89
+ };
90
+
91
+ // Unique pointer to T with custom aligned deleter. This can be a single
92
+ // element U or an array of element if T is a U[]. The custom aligned deleter
93
+ // will call the destructor on U or each element of a U[] in the array case.
94
+ template <typename T>
95
+ using AlignedUniquePtr = std::unique_ptr<T, AlignedDeleter>;
96
+
97
+ // Aligned memory equivalent of make_unique<T> using the custom allocators
98
+ // alloc/free with the passed `opaque` pointer. This function calls the
99
+ // constructor with the passed Args... and calls the destructor of the object
100
+ // when the AlignedUniquePtr is destroyed.
101
+ template <typename T, typename... Args>
102
+ AlignedUniquePtr<T> MakeUniqueAlignedWithAlloc(AllocPtr alloc, FreePtr free,
103
+ void* opaque, Args&&... args) {
104
+ T* ptr = static_cast<T*>(AllocateAlignedBytes(sizeof(T), alloc, opaque));
105
+ return AlignedUniquePtr<T>(new (ptr) T(std::forward<Args>(args)...),
106
+ AlignedDeleter(free, opaque));
107
+ }
108
+
109
+ // Similar to MakeUniqueAlignedWithAlloc but using the default alloc/free
110
+ // functions.
111
+ template <typename T, typename... Args>
112
+ AlignedUniquePtr<T> MakeUniqueAligned(Args&&... args) {
113
+ T* ptr = static_cast<T*>(AllocateAlignedBytes(
114
+ sizeof(T), /*alloc_ptr=*/nullptr, /*opaque_ptr=*/nullptr));
115
+ return AlignedUniquePtr<T>(new (ptr) T(std::forward<Args>(args)...),
116
+ AlignedDeleter());
117
+ }
118
+
119
+ // Helpers for array allocators (avoids overflow)
120
+ namespace detail {
121
+
122
+ // Returns x such that 1u << x == n (if n is a power of two).
123
+ static inline constexpr size_t ShiftCount(size_t n) {
124
+ return (n <= 1) ? 0 : 1 + ShiftCount(n / 2);
125
+ }
126
+
127
+ template <typename T>
128
+ T* AllocateAlignedItems(size_t items, AllocPtr alloc_ptr, void* opaque_ptr) {
129
+ constexpr size_t size = sizeof(T);
130
+
131
+ constexpr bool is_pow2 = (size & (size - 1)) == 0;
132
+ constexpr size_t bits = ShiftCount(size);
133
+ static_assert(!is_pow2 || (1ull << bits) == size, "ShiftCount is incorrect");
134
+
135
+ const size_t bytes = is_pow2 ? items << bits : items * size;
136
+ const size_t check = is_pow2 ? bytes >> bits : bytes / size;
137
+ if (check != items) {
138
+ return nullptr; // overflowed
139
+ }
140
+ return static_cast<T*>(AllocateAlignedBytes(bytes, alloc_ptr, opaque_ptr));
141
+ }
142
+
143
+ } // namespace detail
144
+
145
+ // Aligned memory equivalent of make_unique<T[]> for array types using the
146
+ // custom allocators alloc/free. This function calls the constructor with the
147
+ // passed Args... on every created item. The destructor of each element will be
148
+ // called when the AlignedUniquePtr is destroyed.
149
+ template <typename T, typename... Args>
150
+ AlignedUniquePtr<T[]> MakeUniqueAlignedArrayWithAlloc(
151
+ size_t items, AllocPtr alloc, FreePtr free, void* opaque, Args&&... args) {
152
+ T* ptr = detail::AllocateAlignedItems<T>(items, alloc, opaque);
153
+ if (ptr != nullptr) {
154
+ for (size_t i = 0; i < items; i++) {
155
+ new (ptr + i) T(std::forward<Args>(args)...);
156
+ }
157
+ }
158
+ return AlignedUniquePtr<T[]>(ptr, AlignedDeleter(free, opaque));
159
+ }
160
+
161
+ template <typename T, typename... Args>
162
+ AlignedUniquePtr<T[]> MakeUniqueAlignedArray(size_t items, Args&&... args) {
163
+ return MakeUniqueAlignedArrayWithAlloc<T, Args...>(
164
+ items, nullptr, nullptr, nullptr, std::forward<Args>(args)...);
165
+ }
166
+
167
+ // Custom deleter for std::unique_ptr equivalent to using free() as a deleter
168
+ // but for aligned memory.
169
+ class AlignedFreer {
170
+ public:
171
+ // Pass address of this to ctor to skip deleting externally-owned memory.
172
+ static void DoNothing(void* /*opaque*/, void* /*aligned_pointer*/) {}
173
+
174
+ AlignedFreer() : free_(nullptr), opaque_ptr_(nullptr) {}
175
+ AlignedFreer(FreePtr free_ptr, void* opaque_ptr)
176
+ : free_(free_ptr), opaque_ptr_(opaque_ptr) {}
177
+
178
+ template <typename T>
179
+ void operator()(T* aligned_pointer) const {
180
+ // TODO(deymo): assert that we are using a POD type T.
181
+ FreeAlignedBytes(aligned_pointer, free_, opaque_ptr_);
182
+ }
183
+
184
+ private:
185
+ FreePtr free_;
186
+ void* opaque_ptr_;
187
+ };
188
+
189
+ // Unique pointer to single POD, or (if T is U[]) an array of POD. For non POD
190
+ // data use AlignedUniquePtr.
191
+ template <typename T>
192
+ using AlignedFreeUniquePtr = std::unique_ptr<T, AlignedFreer>;
193
+
194
+ // Allocate an aligned and uninitialized array of POD values as a unique_ptr.
195
+ // Upon destruction of the unique_ptr the aligned array will be freed.
196
+ template <typename T>
197
+ AlignedFreeUniquePtr<T[]> AllocateAligned(const size_t items, AllocPtr alloc,
198
+ FreePtr free, void* opaque) {
199
+ return AlignedFreeUniquePtr<T[]>(
200
+ detail::AllocateAlignedItems<T>(items, alloc, opaque),
201
+ AlignedFreer(free, opaque));
202
+ }
203
+
204
+ // Same as previous AllocateAligned(), using default allocate/free functions.
205
+ template <typename T>
206
+ AlignedFreeUniquePtr<T[]> AllocateAligned(const size_t items) {
207
+ return AllocateAligned<T>(items, nullptr, nullptr, nullptr);
208
+ }
209
+
210
+ } // namespace hwy
211
+ #endif // HIGHWAY_HWY_ALIGNED_ALLOCATOR_H_