@blazediff/core-wasm 7.0.0 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -11
- package/dist/index.js +1 -1
- package/package.json +3 -3
- package/wasm/blazediff_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
|
|
9
9
|
</div>
|
|
10
10
|
|
|
11
|
-
WebAssembly build of the BlazeDiff Rust algorithm for browsers, edge runtimes, and any wasm host. Same
|
|
11
|
+
WebAssembly build of the BlazeDiff Rust algorithm for browsers, edge runtimes, and any wasm host. Same block-band algorithm as [`@blazediff/core-native`](https://www.npmjs.com/package/@blazediff/core-native), compiled to `wasm32` with `v128` SIMD (`+simd128`). About **6.8x** faster than [pixelmatch](https://github.com/mapbox/pixelmatch) in total time on the same RGBA buffers (5x to 10x on 4K); diff counts agree with pixelmatch to within ~0.05%.
|
|
12
12
|
|
|
13
13
|
**Features:**
|
|
14
14
|
- Same Rust algorithm as `@blazediff/core-native` (YIQ perceptual delta + block-based cold/hot pass)
|
|
15
|
-
- `wasm32` v128 SIMD: 4-lane vectorized cold and hot loops; up to ~
|
|
15
|
+
- `wasm32` v128 SIMD: 4-lane vectorized cold and hot loops; up to ~11x faster than pixelmatch on 4K
|
|
16
16
|
- Same `Image`, `DiffOptions` and `DiffResult` as `@blazediff/core`. Caller decodes images; no PNG/JPEG codecs bundled
|
|
17
17
|
- ~32 KB optimized wasm + ~10 KB JS glue. No native binaries, no postinstall, no platform packages
|
|
18
18
|
- Runs anywhere wasm runs: browsers, Node 18+, Cloudflare Workers, Deno, Bun
|
|
@@ -255,21 +255,21 @@ vs `pixelmatch` on M1 Max, image I/O excluded (pre-decoded RGBA buffers):
|
|
|
255
255
|
|
|
256
256
|
| Fixture | pixelmatch | core-wasm | Improvement |
|
|
257
257
|
|---------------|------------|-----------|-------------|
|
|
258
|
-
| 4k/1
|
|
259
|
-
| 4k/3
|
|
260
|
-
| page/2
|
|
261
|
-
| blazediff/3
|
|
262
|
-
| pixelmatch/1
|
|
258
|
+
| 4k/1 | 346.12ms | 34.73ms | **90.0%** |
|
|
259
|
+
| 4k/3 | 423.70ms | 44.48ms | **89.5%** |
|
|
260
|
+
| page/2 | 529.30ms | 65.49ms | **87.6%** |
|
|
261
|
+
| blazediff/3 | 10.86ms | 5.94ms | **45.3%** |
|
|
262
|
+
| pixelmatch/1 | 0.82ms | 0.10ms | **88.3%** |
|
|
263
263
|
|
|
264
|
-
|
|
264
|
+
About **6.8x** faster in total time across the full fixture set, ~77% per fixture on average (~72% across differing pairs). Counts agree with pixelmatch within ~0.05% (e.g. `4k/1`: 69 932 vs 69 912 of 17 920 000 pixels).
|
|
265
265
|
Full benchmarks in [BENCHMARKS.md](https://github.com/teimurjan/blazediff/blob/main/BENCHMARKS.md).
|
|
266
266
|
|
|
267
267
|
## Algorithm
|
|
268
268
|
|
|
269
|
-
Same
|
|
269
|
+
Same block-band approach as `@blazediff/core-native`, recompiled for wasm. The diff walks one row of blocks at a time. The block size grows with the image area, from 8 to 128 pixels.
|
|
270
270
|
|
|
271
|
-
1. **Cold pass:**
|
|
272
|
-
2. **Hot pass:**
|
|
271
|
+
1. **Cold pass:** a SIMD scan reads the band in pixel-row order and flags each block that holds a pixel over the threshold
|
|
272
|
+
2. **Hot pass:** YIQ perceptual color difference on the flagged blocks only, while the band is still in cache
|
|
273
273
|
3. **SIMD:** `v128` intrinsics (`f32x4_*`, `i32x4_*`) for parallel 4-lane RGBA extraction, alpha blend, YIQ transform, and threshold compare. Baseline simd128 has no native FMA, so weighted sums use `add(mul, c)`
|
|
274
274
|
4. **Anti-aliasing:** Vysniauskas (2009) algorithm to detect AA artifacts
|
|
275
275
|
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {assertImage,assertOptions,assertTargets,windowSide}from'@blazediff/core';export{BlazeDiffError}from'@blazediff/core';import
|
|
1
|
+
import {assertImage,assertOptions,assertTargets,windowSide}from'@blazediff/core';export{BlazeDiffError}from'@blazediff/core';import C,{diffRgba}from'../wasm/blazediff.js';var s;function v(e){return s||(s=C(e===void 0?void 0:{module_or_path:e}).then(()=>{})),s}function u(e){return e&&Uint8Array.from(e)}async function z(e,t,i={}){if(assertImage(e,"a","invalid-image"),assertImage(t,"b","invalid-image"),e.width!==t.width||e.height!==t.height)return {kind:"dimension-mismatch",a:{width:e.width,height:e.height},b:{width:t.width,height:t.height}};let{threshold:g=.1,antialiasing:y=true,metric:l="yiq",mask:m,window:p,output:f,render:r={}}=i,{width:a,height:o}=e,c=a*o;assertOptions(i),assertTargets(i,a,o);let w=r.background??"faded";if(await v(),!f&&p===void 0&&O(e.data,t.data))return {kind:"compared",count:0,percentage:0,identical:true};let A=windowSide(p,a,o),[d,U,b,R,B]=diffRgba(n(e.data),n(t.data),a,o,g,y,l,m&&n(m),A||void 0,r.alpha??.1,u(r.diffColor),u(r.diffColorAlt),u(r.aaColor),w==="transparent",f&&n(f.data));return {kind:"compared",count:d,percentage:c>0?100*d/c:0,identical:d===0,...U===1&&{window:{x:b,y:R,count:B}}}}function O(e,t){let i=globalThis.Buffer;return i!==void 0&&i.compare(n(e),n(t))===0}function n(e){return e instanceof Uint8Array?e:new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}export{z as diff,v as initBlazediff};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blazediff/core-wasm",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "WebAssembly build of blazediff for browsers, edge runtimes, and any wasm host. Same algorithm as @blazediff/core-native.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"homepage": "https://blazediff.dev",
|
|
39
39
|
"license": "MIT",
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@blazediff/core": "2.0.
|
|
41
|
+
"@blazediff/core": "2.0.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/node": "^24.3.0",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"tsup": "8.5.0",
|
|
48
48
|
"typescript": "5.9.2",
|
|
49
49
|
"vitest": "^3.2.4",
|
|
50
|
-
"@blazediff/core-native": "
|
|
50
|
+
"@blazediff/core-native": "8.0.0"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"typecheck": "tsc --noEmit",
|
package/wasm/blazediff_bg.wasm
CHANGED
|
Binary file
|