# dblur lab — corresponding source and provenance

This entire static demo is provided as editable source. Kernel license: LGPL-2.1-or-later.
Copyright (c) 2020 Paul B Mahol; FFmpeg contributors. JavaScript adaptation and UI changes: 2026-10-16.
No warranty. See [COPYING.LGPLv2.1](vendor/COPYING.LGPLv2.1).

## Fixed upstream sources

- FFmpeg n7.1.1, commit `db69d06eeeab4f46da15030a80d539efb4503ca8`: [upstream](https://github.com/FFmpeg/FFmpeg/blob/db69d06eeeab4f46da15030a80d539efb4503ca8/libavfilter/vf_dblur.c), local [vf_dblur.c](vendor/vf_dblur.c), SHA256 `b8cc9e01f0df7d6736cb83da041d2a729817e3491457a5978f38a2c8658b7fa4`.
- FFmpeg n8.1.1, commit `239f2c733de417201d7ad3b3b8b0d9b63285b2b1`: [upstream](https://github.com/FFmpeg/FFmpeg/blob/239f2c733de417201d7ad3b3b8b0d9b63285b2b1/libavfilter/vf_dblur.c), local [vf_dblur-n8.1.1.c](vendor/vf_dblur-n8.1.1.c), SHA256 `7bbf66229d336441c47e4efdd8467ce973f75d4b3f216e249555723f45b5a35d`.
- Float format introduction: [0aa714244235f55cb31755cbda3714971082ff7d](https://github.com/FFmpeg/FFmpeg/commit/0aa714244235f55cb31755cbda3714971082ff7d). This is NOT the optimization commit.
- Candidate optimization: [PR 25103](https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25103), reported commit `abb08fb2c2319f85bee729a8a54b2b6541758d5a`. Direct patch request returned an HTML bot challenge on 2026-10-16. Patch contents and merge status remain unverified. The demo independently removes the redundant inner loops visible in the fixed upstream sources; it does not claim to contain that candidate commit.
- Credit: [Romain Hedouin's post](https://x.com/RomainHedouin/status/2110797267699638577), [FFmpeg legal](https://ffmpeg.org/legal.html).

## Changes and scope

[kernel.js](kernel.js) ports `set_params` and the directional IIR kernel using explicit float32 rounding. Both variants share all arithmetic. The old copy uses Float32Array.set on each row width times; the new copy uses it once. RGB planes are processed independently; alpha is composited on white before conversion. Browser canvas decoding/resizing and sRGB float samples are not a full FFmpeg color-management pipeline. JavaScript engines may optimize differently from memcpy or a C compiler.

[worker.js](worker.js) runs one warmup per variant, alternates first variant each round, and reports per-component medians and raw samples. Total includes timer/loop overhead, excludes array allocation, parameter preparation, decode, transfer and render. Component medians need not sum to the median total. Cancellation terminates the worker even during synchronous loops. Controls cap work at 1920x1080, radius 64, 9 measured rounds. Image input has a 20MB/40MP bound. No telemetry, external assets, upload API, or server-side processing.

## Reference verification

`npm test` runs 75 cases: dimensions 1x1, 1x7, 7x1, 17x13, 64x48; angles 0,45,135,270,360; radii 0,5,64. Old/new outputs are bit-identical. Native FFmpeg 8.1.1 gyan.dev executable SHA256 `09948d4cdd0650da6ff5a87577469f2a218dc2615ae379f8f734d24c49de0f73`, single filter thread, gbrpf32le raw input/output: maximum absolute error **0** across all cases (tolerance 2e-5). See `evidence/native-reference.json` and `tests/verify.mjs` in the project checkout. This verifies numerical output; no native performance claim is made. The native binary is not distributed with this site, and its build options differ from a minimal LGPL build.

## Reproduce and publish

Node 22+, Python 3, no npm dependencies. `npm start` serves http://127.0.0.1:4173. `npm run build` copies a complete static artifact to dist/. `python evidence/final_script.py` runs local Firefox UI checks (Playwright required). `npm test` requires the specified FFmpeg 8.1.1 executable.

For Cloudflare Pages: create a NEW project (suggested name `dblur-lab-moc26`); build command `npm run build`; output `dist`; no environment variables, bindings or secrets. Do not reuse or overwrite another site's Pages/Worker name. Publication is pending account/access confirmation with the parent task. No authentication, paid service, domain or security change has been made.
