@napi-rs/webcodecs 1.4.2 → 1.5.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.
Files changed (45) hide show
  1. package/LICENSES.md +40 -0
  2. package/README.md +45 -8
  3. package/SOURCE_DISTRIBUTION.md +111 -0
  4. package/THIRD_PARTY_NOTICES.md +87 -0
  5. package/index.d.ts +93 -32
  6. package/index.js +193 -55
  7. package/licenses/aom-LICENSE.txt +27 -0
  8. package/licenses/aom-PATENTS.txt +108 -0
  9. package/licenses/brotli-LICENSE.txt +19 -0
  10. package/licenses/dav1d-COPYING.txt +23 -0
  11. package/licenses/ffmpeg-COPYING.GPLv2.txt +339 -0
  12. package/licenses/ffmpeg-COPYING.GPLv3.txt +674 -0
  13. package/licenses/ffmpeg-COPYING.LGPLv2.1.txt +502 -0
  14. package/licenses/ffmpeg-COPYING.LGPLv3.txt +165 -0
  15. package/licenses/ffmpeg-LICENSE.md.txt +127 -0
  16. package/licenses/highway-LICENSE-BSD3.txt +26 -0
  17. package/licenses/highway-LICENSE.txt +201 -0
  18. package/licenses/lame-COPYING.txt +481 -0
  19. package/licenses/lame-LICENSE.txt +13 -0
  20. package/licenses/lcms2-LICENSE.txt +22 -0
  21. package/licenses/lcms2-windows-LICENSE.txt +22 -0
  22. package/licenses/libjpeg-turbo-CHROMIUM_LICENSE.txt +27 -0
  23. package/licenses/libjpeg-turbo-LICENSE.md.txt +135 -0
  24. package/licenses/libjpeg-turbo-README.ijg.txt +260 -0
  25. package/licenses/libjpeg-turbo-jsimdext.inc.txt +542 -0
  26. package/licenses/libjxl-LICENSE.txt +27 -0
  27. package/licenses/libjxl-PATENTS.txt +22 -0
  28. package/licenses/libvpx-LICENSE.txt +31 -0
  29. package/licenses/libvpx-PATENTS.txt +23 -0
  30. package/licenses/libwebp-COPYING.txt +30 -0
  31. package/licenses/libwebp-PATENTS.txt +23 -0
  32. package/licenses/manifest.json +343 -0
  33. package/licenses/nv-codec-headers-nvEncodeAPI.h.txt +26 -0
  34. package/licenses/ogg-COPYING.txt +28 -0
  35. package/licenses/ogg-windows-COPYING.txt +28 -0
  36. package/licenses/opus-COPYING.txt +44 -0
  37. package/licenses/rav1e-LICENSE.txt +25 -0
  38. package/licenses/rav1e-PATENTS.txt +108 -0
  39. package/licenses/vorbis-COPYING.txt +28 -0
  40. package/licenses/x264-COPYING.txt +340 -0
  41. package/licenses/x264-x264.h.txt +26 -0
  42. package/licenses/x265-COPYING.txt +343 -0
  43. package/licenses/x265-source-x265.h.txt +23 -0
  44. package/licenses/zlib-LICENSE.txt +22 -0
  45. package/package.json +27 -21
package/LICENSES.md ADDED
@@ -0,0 +1,40 @@
1
+ # Licenses and binary distribution
2
+
3
+ The original source code of `@napi-rs/webcodecs` is licensed under the MIT
4
+ license in [LICENSE](LICENSE). That license and its copyright notice remain
5
+ unchanged. It does not replace the licenses of bundled third-party code.
6
+
7
+ ## Native packages
8
+
9
+ The `@napi-rs/webcodecs-*` platform packages contain native addons that statically
10
+ link FFmpeg and codec libraries. The checked-in build recipes enable
11
+ `--enable-gpl`, `--enable-version3`, `--enable-libx264`, and `--enable-libx265`.
12
+ FFmpeg describes this configuration as GPL version 3 or later; see its
13
+ [licensing explanation](licenses/ffmpeg-LICENSE.md.txt) and
14
+ [GPLv3 text](licenses/ffmpeg-COPYING.GPLv3.txt).
15
+
16
+ These addons cannot be described as MIT-only distributions. Distribution of
17
+ the combined GPL-covered work must satisfy GPLv3, including the applicable
18
+ Corresponding Source requirements. The original MIT grant for this project's
19
+ own source remains available; it does not provide an exception to those
20
+ requirements for the combined binaries. The root JavaScript package selects
21
+ these addons through optional dependencies, so installing it normally also
22
+ installs a native package with these obligations.
23
+
24
+ The npm `license` field points here to distinguish the original source license
25
+ from the conditions on the binary distribution. It is not a dual-license offer
26
+ allowing a recipient to select MIT for the bundled native addon.
27
+
28
+ ## Third-party material and source status
29
+
30
+ [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) lists the configured dependencies
31
+ and reference license texts. Preserve their copyright, license, patent, and
32
+ other required notices when redistributing them. See
33
+ [SOURCE_DISTRIBUTION.md](SOURCE_DISTRIBUTION.md) for the source-material gaps
34
+ identified in the 1.4.2 distribution and the work required before the next
35
+ binary release. The repository URL and these notice files alone are not a
36
+ complete Corresponding Source distribution or a written source offer.
37
+
38
+ This notice correction does not certify compliance of existing releases,
39
+ change codec features, or relicense the project's original source. Custom
40
+ builds require an inventory of the libraries actually linked into them.
package/README.md CHANGED
@@ -348,6 +348,33 @@ frame.close()
348
348
 
349
349
  **Note:** Canvas pixel data is copied as RGBA format with sRGB color space.
350
350
 
351
+ ### Native float canvas interop
352
+
353
+ Native canvas providers can retain RGBA16Float images with
354
+ `createVideoFrameFromRGBA16Float(data, init)`. `data` contains tightly packed
355
+ RGBA half-float bit patterns in a `Uint16Array`, with four
356
+ components per coded pixel. The native frame copies the input once; clones share
357
+ immutable storage, and closing one frame leaves its clones usable. Supply the
358
+ image color space in `init.colorSpace`; the default is full-range sRGB.
359
+
360
+ These frames have `format === null`. Public `allocationSize()` throws and
361
+ `copyTo()` rejects with `NotSupportedError`, including requests for an explicit
362
+ eight-bit format. `copyVideoFrameRGBA16Float(frame)` gives native image consumers
363
+ an independent copy of the half-float bits without changing that public contract.
364
+ It returns the whole coded image (`codedWidth * codedHeight * 4` values) and
365
+ ignores `visibleRect`.
366
+ These functions are module exports rather than additions to `VideoFrame.prototype`.
367
+ Native GPU consumers can use `registerVideoFrameCloseObserver(frame, callback)`
368
+ to expire their retained textures synchronously when that frame is explicitly
369
+ closed. Clones have independent observers. Collecting a frame wrapper releases
370
+ its observers while independently retained GPU images remain usable.
371
+
372
+ The FFmpeg encoder cannot consume this opaque image resource. `encode()` queues
373
+ the input normally, then reports a native `OperationError`, rejects pending
374
+ `flush()` calls with the same error, and closes the encoder without output.
375
+ This interop does not implement WebGPU external-texture import or cross-worker
376
+ frame transport.
377
+
351
378
  ## Supported Codecs
352
379
 
353
380
  ### Video
@@ -589,7 +616,9 @@ frame.close()
589
616
 
590
617
  Per WPT `videoFrame-copyTo-rgb.any.js`, RGB-to-YUV conversion throws `NotSupportedError`.
591
618
 
592
- Custom layouts with overflow-inducing values (e.g., `offset: 2³²-2`) throw `TypeError` via checked arithmetic. Rect alignment is validated against the source format during conversion.
619
+ Like Chrome, `copyTo()` accepts an explicit `format` only for RGBA, RGBX, BGRA and BGRX. Any other `format`, even the frame's own, rejects with `NotSupportedError`; leave `format` out to copy in the frame's own format. `allocationSize()` still accepts the frame's own format. Invalid arguments and options make `copyTo()` reject the returned promise (with `TypeError` or `NotSupportedError`) instead of throwing. Only a call on an object that is not a `VideoFrame` still throws.
620
+
621
+ Custom layouts with overflow-inducing values (e.g., `offset: 2³²-2`) throw `TypeError` via checked arithmetic. The copy `rect` is validated against the output format. For YUV-to-RGB conversion, the read origin is then aligned down to the source chroma grid, as Chrome does.
593
622
 
594
623
  ### ImageDecoder Options
595
624
 
@@ -597,15 +626,13 @@ ImageDecoder supports all W3C spec options:
597
626
 
598
627
  | Option | Status | Notes |
599
628
  | ---------------------- | ------ | --------------------------------------------------------------------------------- |
600
- | `desiredWidth/Height` | ✅ | Scales decoded frames to specified dimensions |
601
- | `preferAnimation` | ✅ | When `false`, only decodes first frame for animated formats |
629
+ | `desiredWidth/Height` | ✅ | Like Chrome: scales JPEG only, to M/8 of its size; other formats stay full size |
630
+ | `preferAnimation` | ✅ | `false`: GIF first frame only, AVIF still image; APNG/WebP ignore it, like Chrome |
602
631
  | `colorSpaceConversion` | ✅ | `"default"` extracts color space metadata, `"none"` ignores it (Chromium-aligned) |
603
632
 
604
- **Note:** Per W3C spec, `desiredWidth` and `desiredHeight` must both be specified or both omitted.
633
+ **Note:** `desiredWidth` and `desiredHeight` follow Chrome, not the spec. A missing one, or a 0, is no error: the desired size is then ignored. Chrome decodes a JPEG at M/8 of its size (rounded up), where M = ⌊8 × √(desired area / image area)⌋, or 8 when the desired area is at least the image's. A JPEG scaled this way is BGRX. When even 1/8 is too large (M = 0), `tracks.ready` rejects with `InvalidStateError` and the decoder closes. Like Chrome, libjpeg-turbo scales the JPEG while it decodes it.
605
634
 
606
- ### Platform-Specific Notes
607
-
608
- - **ImageDecoder GIF animation**: FFmpeg may return only the first frame. Use `VideoDecoder` with GIF codec for full animation.
635
+ **Note:** GIF and BMP are not decoded by FFmpeg, but by decoders that follow Chrome: Wuffs' rules for GIF, the `image` crate's for BMP. Every GIF frame is decoded; it lasts its delay (0 too) and starts when the frames before it end. A frame that fails to decode rejects with `RangeError`; once every frame failed, `decode()` rejects with `EncodingError` and the decoder closes.
609
636
 
610
637
  ### Per-Frame Quantizer Control
611
638
 
@@ -694,6 +721,9 @@ For full API documentation, see the [W3C WebCodecs specification](https://w3c.gi
694
721
  - Rust (latest stable)
695
722
  - Node.js 18+
696
723
  - pnpm
724
+ - NASM 2.15.05 or newer, for x86_64 builds (libjpeg-turbo's SIMD code): `brew install nasm`,
725
+ `apt-get install nasm` (Ubuntu 22.04 or Debian 11 and newer) or `choco install nasm` (then
726
+ add `C:\Program Files\NASM` to `PATH`), or set `NASM` to its path
697
727
 
698
728
  The build downloads the pinned FFmpeg 9.0 release by default. If you opt out
699
729
  of that download or set `FFMPEG_DIR`, the supplied FFmpeg headers and libraries
@@ -722,4 +752,11 @@ cargo clippy
722
752
 
723
753
  ## License
724
754
 
725
- MIT
755
+ The original project source is [MIT licensed](LICENSE). The prebuilt native
756
+ addons statically link GPL-enabled FFmpeg, x264, x265, and other libraries;
757
+ their distribution is subject to additional terms, including GPLv3.
758
+
759
+ Read [LICENSES.md](LICENSES.md), [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md),
760
+ and the outstanding [Corresponding Source work](SOURCE_DISTRIBUTION.md) before
761
+ redistributing the prebuilt packages. The MIT source license alone does not
762
+ cover the bundled native binaries.
@@ -0,0 +1,111 @@
1
+ # Corresponding Source: release work still required
2
+
3
+ Status: notice and packaging corrections only. No complete source bundle has
4
+ been reconstructed, verified, or published by this change. Do not treat the
5
+ presence of these files or a passing packaging check as release clearance.
6
+
7
+ ## What was checked for 1.4.2
8
+
9
+ The `v1.4.2` tag resolves to
10
+ `3eb6525afb643baadcbe628f536e30265404d818`, also the root npm package's
11
+ `gitHead`. The registry tarballs for the root and all nine native packages were
12
+ downloaded and checked against their npm SHA-512 integrity values.
13
+
14
+ - The root tarball contains eight files, including the original MIT `LICENSE`.
15
+ - Each native tarball contains only `package.json`, `README.md`, and its `.node`
16
+ binary. All ten manifests advertise `MIT`. The native packages contain no
17
+ license, notice, or Corresponding Source files.
18
+ - x264-identifying strings are present in every native binary. This supports
19
+ the build-recipe evidence but does not identify all linked revisions.
20
+ The final addons did not retain a discoverable FFmpeg configure/license
21
+ string in this inspection; no complete binary dependency attestation has
22
+ been established.
23
+ - `build.rs` pins nine digests for the `ffmpeg-n9.0.2` static-library release.
24
+ That release lists nine binary/install archives and no dedicated third-party
25
+ source archive. Its automatic GitHub repository source snapshot contains the
26
+ wrapper and build scripts, not the downloaded upstream source trees.
27
+ - The macOS arm64 and both Windows static-library archives were downloaded and
28
+ their SHA-256 values verified against the release metadata. Their file lists
29
+ contain headers/libraries but no license, copyright, notice, or source tree.
30
+ Inspection of their `avutil` static libraries confirms `n9.0.2` and the
31
+ `--enable-gpl`, `--enable-version3`, `--enable-libx264`, and
32
+ `--enable-libx265` configure options. The other six static-library archives
33
+ have not been inspected in this audit.
34
+
35
+ References: [npm root metadata](https://registry.npmjs.org/@napi-rs%2fwebcodecs/1.4.2),
36
+ [1.4.2 source](https://github.com/Brooooooklyn/webcodecs-node/tree/3eb6525afb643baadcbe628f536e30265404d818),
37
+ [FFmpeg static-library release](https://github.com/Brooooooklyn/webcodecs-node/releases/tag/ffmpeg-n9.0.2).
38
+
39
+ ## Requirements to implement for the existing GPL build
40
+
41
+ [GPLv3](licenses/ffmpeg-COPYING.GPLv3.txt) sections 1, 4, 5, and 6 cover the
42
+ source and object-code distribution conditions. Section 1 covers the source
43
+ needed to generate, install, run, and modify the work, including the controlling
44
+ scripts; its System Library and general-purpose-tool exclusions require a
45
+ component-specific assessment. Preserve applicable notices and identify changes
46
+ and their dates. Distribution of the combined covered work must satisfy GPLv3
47
+ as a whole while retaining compatible upstream notices, including MIT.
48
+
49
+ For npm/network distribution, section 6(d) provides a route: equivalent access
50
+ to Corresponding Source at no extra charge, with clear directions beside the
51
+ object code. A different source server is permitted under that section, but
52
+ the distributor remains responsible for source availability. A generic link to
53
+ upstream or an unimplemented promise to provide source is insufficient. The
54
+ physical-product written-offer route in section 6(b) is not a generic substitute
55
+ for the npm download route. Installation Information may also be required when
56
+ the section 6 User Product conditions apply.
57
+
58
+ Before another release using this configuration:
59
+
60
+ 1. Recover the actual source inputs for each old binary where available. Record
61
+ package version, target, addon hash, FFmpeg archive hash, build run, source
62
+ commits, tarball hashes, dependency lockfiles, and toolchain versions. Do not
63
+ use today's dependency HEAD as evidence of the 1.4.2 inputs.
64
+ 2. Retain all source trees required for the combined addon, including this
65
+ project's Rust/C/JS sources, third-party code, relevant generated/interface
66
+ inputs, and build/install scripts. Include transitive components unless a
67
+ documented exclusion applies; a directory of static `.a`/`.lib` files and
68
+ headers is not Corresponding Source.
69
+ 3. Capture exact revisions and modifications. Unix x264 is unpinned; most
70
+ dependency clones reuse an existing directory without revision validation.
71
+ LAME's archive has no input checksum. The build script modifies x265 CMake
72
+ policy settings and FFmpeg's generated `config.h` for Zig, emits compiler
73
+ wrappers/toolchain files, and rewrites pkg-config files. Preserve those
74
+ instructions and the actual patches/configuration, with change notices.
75
+ libjpeg-turbo is vendored in `vendor/libjpeg-turbo` as an unmodified copy
76
+ of Chromium's tree; Chromium's changes are listed in its `README.chromium`,
77
+ `CHROMIUM_PIN` records the Chromium revision, and `build.rs` holds the
78
+ compile flags (symbol prefix, 12/16-bit objects, SIMD defines, NASM flags).
79
+ 4. For Windows, retain the pinned vcpkg ports, resolved source archives and
80
+ patches, triplets, feature selections, installed copyright files, and the
81
+ source/build dependencies for the separately downloaded rav1e staticlib.
82
+ Keep the x265 alpha/multilib build instructions as well.
83
+ 5. Recover the release's resolved Cargo dependencies and toolchains where
84
+ possible. For future releases, record lockfiles, immutable source identities,
85
+ build environment and the actual linked library list alongside each binary.
86
+ Byte-for-byte reproducibility is useful verification, not itself the GPL's
87
+ definition of Corresponding Source.
88
+ 6. Assemble the source materials and notices, test rebuilding each target from
89
+ them, and resolve differences. Check upstream embedded subcomponent notices
90
+ and runtime terms; the reference notice inventory is not complete evidence.
91
+ 7. Choose and maintain a version-specific source distribution location. Put
92
+ working links and checksums beside npm binaries and FFmpeg downloads and in
93
+ every platform package; verify access without credentials. Do not invent
94
+ source URLs or publish placeholders. Existing 1.4.2 tarballs cannot be fixed
95
+ by editing the next version's package files alone.
96
+
97
+ ## Maintainer decision
98
+
99
+ The original MIT license is preserved. Choose the future binary distribution
100
+ approach before publishing:
101
+
102
+ - Retain the GPL-enabled codecs and meet the combined-work GPLv3 distribution
103
+ requirements, including complete corresponding-source delivery and notices.
104
+ - Design and rebuild a distribution without GPL components. This requires an
105
+ actual codec/build/dependency review, removing GPL configure options and
106
+ affected code, capability tests, and continued satisfaction of applicable
107
+ LGPL and other dependency terms. It is not an MIT-only shortcut; static
108
+ LGPL linking has its own requirements.
109
+
110
+ This patch makes neither choice and removes no codecs. It provides an
111
+ engineering inventory of the evidence and gaps, not a legal determination.
@@ -0,0 +1,87 @@
1
+ # Third-party notices
2
+
3
+ The native addon uses FFmpeg and the dependencies below. Version entries are
4
+ build-recipe references, not a verified bill of materials for each released
5
+ binary. All platforms receive this combined notice bundle; inclusion of a
6
+ license text does not mean that component is present on every platform.
7
+
8
+ Full reference texts, copyright notices, and patent notices are in `licenses/`.
9
+ [licenses/manifest.json](licenses/manifest.json) records where each text was
10
+ obtained and its SHA-256 digest. A source-file header excerpt is explicitly
11
+ marked there. Those digests identify notice files, not source archives or
12
+ binaries. Original project source remains under [MIT](LICENSE); see
13
+ [LICENSES.md](LICENSES.md) for the combined binary distribution.
14
+
15
+ ## Configured dependencies
16
+
17
+ The Unix versions come from `tools/build-ffmpeg/src/main.rs`. Windows uses
18
+ vcpkg commit `74e6536215718009aae747d86d84b78376bf9e09` plus separately built
19
+ x265 and, on x64, a downloaded rav1e static library. The vcpkg baseline is pinned;
20
+ its port patches and actual resolved build inputs must also be retained.
21
+
22
+ | Component | Build reference | Reference terms and files in `licenses/` |
23
+ | -------------------------- | ------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------- |
24
+ | FFmpeg | `n9.0.2`, all targets | GPL-3.0-or-later for the configured build; `ffmpeg-LICENSE.md.txt`, `ffmpeg-COPYING.*.txt` |
25
+ | x264 | Unix: unpinned shallow clone; Windows: `0.164.3108` / `31e19f92f00c7003fa115047ce50978bc98c3a0d` | GPL-2.0-or-later; `x264-COPYING.txt`, `x264-x264.h.txt` |
26
+ | x265 | `Release_4.1`, multilib with alpha | GPL-2.0-or-later; `x265-COPYING.txt`, `x265-source-x265.h.txt` |
27
+ | libvpx | `v1.15.2` | BSD-3-Clause and patent grant; `libvpx-LICENSE.txt`, `libvpx-PATENTS.txt` |
28
+ | libaom | `v3.13.1`; excluded from Windows x64 recipe | BSD-2-Clause and AOM patent license; `aom-LICENSE.txt`, `aom-PATENTS.txt` |
29
+ | rav1e | `v0.8.1`, Windows x64 prebuilt archive | BSD-2-Clause and patent grant; `rav1e-LICENSE.txt`, `rav1e-PATENTS.txt`; transitive dependencies require inventory |
30
+ | dav1d | Windows vcpkg `1.5.1` | BSD-2-Clause; `dav1d-COPYING.txt` |
31
+ | Opus | `v1.5.2` | BSD-style notice and patent references; `opus-COPYING.txt` |
32
+ | LAME / libmp3lame / mpghip | `3.100` | GNU Library GPL v2 text and upstream guidance; `lame-COPYING.txt`, `lame-LICENSE.txt`; retain component-level headers |
33
+ | libogg | Unix `v1.3.5`; Windows `v1.3.6` | BSD-3-Clause; `ogg-COPYING.txt`, `ogg-windows-COPYING.txt` |
34
+ | libvorbis | `v1.3.7` | BSD-3-Clause; `vorbis-COPYING.txt` |
35
+ | libwebp / libsharpyuv | `v1.6.0` | BSD-3-Clause and patent grant; `libwebp-COPYING.txt`, `libwebp-PATENTS.txt` |
36
+ | zlib | `v1.3.1` | zlib license; `zlib-LICENSE.txt` |
37
+ | JPEG XL / libjxl | `v0.11.1` | BSD-3-Clause and patent grant; `libjxl-LICENSE.txt`, `libjxl-PATENTS.txt` |
38
+ | Highway | `1.3.0` | Apache-2.0 / BSD-3-Clause reference texts; `highway-LICENSE.txt`, `highway-LICENSE-BSD3.txt`; inspect file-level terms |
39
+ | Brotli | `v1.1.1` | MIT; `brotli-LICENSE.txt` |
40
+ | Little CMS 2 | Unix `lcms2.16`; Windows `lcms2.17` | MIT; `lcms2-LICENSE.txt`, `lcms2-windows-LICENSE.txt` |
41
+ | NVIDIA codec headers | Linux recipe `n13.0.19.0`, except armv7 | MIT; `nv-codec-headers-nvEncodeAPI.h.txt` |
42
+ | libjpeg-turbo | `3.1.0` from Chrome `155.0.8059.79` DEPS, in `vendor/libjpeg-turbo`, all targets | IJG License, BSD-3-Clause and zlib; `libjpeg-turbo-LICENSE.md.txt`, `libjpeg-turbo-README.ijg.txt`; see below |
43
+ | Blink JPEG decoder | `jpeg_image_decoder.cc` from Chrome `155.0.8059.79`, rewritten as `src/ffi/jpeg_blink.c` | LGPL-2.1-or-later, MPL-1.1 or GPL-2.0; notice in `src/ffi/jpeg_blink.c`; `ffmpeg-COPYING.LGPLv2.1.txt` |
44
+
45
+ This software is based in part on the work of the Independent JPEG Group.
46
+ FFmpeg's licensing explanation identifies IJG-derived codec files requiring
47
+ this attribution, and so does the IJG License of libjpeg-turbo. The checked-in
48
+ build recipe does not modify FFmpeg's files. `vendor/libjpeg-turbo` is an
49
+ unmodified copy of files from Chromium's libjpeg-turbo tree, and `build.rs`
50
+ compiles it as is. Chromium's own changes to libjpeg-turbo (`jpeglibmangler.h`,
51
+ included from `jpeglib.h`, and the hand-edited `jconfig.h` and `jconfigint.h`)
52
+ are listed in `vendor/libjpeg-turbo/README.chromium`; `CHROMIUM_LICENSE` and
53
+ `simd/nasm/jsimdext.inc` there hold the notices that `jpeglibmangler.h`,
54
+ `jsimd.h`, `jsimddct.h` and most SIMD files refer to (the Neon files hold their
55
+ zlib notice themselves). Byte-for-byte copies are packaged as
56
+ `licenses/libjpeg-turbo-CHROMIUM_LICENSE.txt` and
57
+ `licenses/libjpeg-turbo-jsimdext.inc.txt`. The SIMD code bears the zlib License,
58
+ which `LICENSE.md` says the IJG License subsumes in the built library. Other
59
+ builds must document any changes to these files.
60
+
61
+ `src/ffi/jpeg_blink.c` is a C rewrite of Blink's `jpeg_image_decoder.cc`:
62
+ Copyright (C) 2006 Apple Computer, Inc.; portions Copyright (C) 2001-6
63
+ mozilla.org. A recipient may use it under the LGPL 2.1 or later, the MPL 1.1 or
64
+ the GPL 2.0; its header holds the full notice.
65
+
66
+ ## Inventory still required for release
67
+
68
+ These reference texts are an initial notice inventory. They do not establish
69
+ that every upstream subcomponent notice or actual linked dependency has been
70
+ captured. In particular:
71
+
72
+ - Capture the exact x264 revision for every Unix build; the reference header in
73
+ this bundle is identified by its own commit, not asserted to be the binary's.
74
+ - Preserve vcpkg port patches and installed `share/*/copyright` files, checking
75
+ their contents against the exact source trees and transitive dependencies.
76
+ - Inventory Rust dependencies (including rav1e's), the Rust standard library,
77
+ statically linked C/C++/compiler runtimes, and any platform-specific notices.
78
+ `Cargo.lock` is currently ignored and release toolchains are not all pinned.
79
+ - `build.rs` searches local library paths and may link additional optional
80
+ libraries. These custom builds need their own notice and source inventory.
81
+ - Resolve and publish the matching source materials described in
82
+ [SOURCE_DISTRIBUTION.md](SOURCE_DISTRIBUTION.md).
83
+
84
+ Upstream entry points: [FFmpeg](https://ffmpeg.org/legal.html),
85
+ [x264](https://code.videolan.org/videolan/x264),
86
+ [x265](https://bitbucket.org/multicoreware/x265_git), and
87
+ [vcpkg baseline](https://github.com/microsoft/vcpkg/tree/74e6536215718009aae747d86d84b78376bf9e09/ports).
package/index.d.ts CHANGED
@@ -96,7 +96,7 @@ export interface MuxerVideoTrackConfig {
96
96
  /** Video height */
97
97
  height: number
98
98
  /** Codec description (e.g., avcC for H.264) */
99
- description?: Uint8Array
99
+ description?: AllowSharedBufferSource
100
100
  }
101
101
 
102
102
  /** Audio track config for muxer */
@@ -108,7 +108,7 @@ export interface MuxerAudioTrackConfig {
108
108
  /** Number of channels */
109
109
  numberOfChannels: number
110
110
  /** Codec description */
111
- description?: Uint8Array
111
+ description?: AllowSharedBufferSource
112
112
  }
113
113
 
114
114
  // ============================================================================
@@ -178,6 +178,14 @@ export type TypedArray =
178
178
  | BigInt64Array
179
179
  | BigUint64Array
180
180
 
181
+ /**
182
+ * Which binding artifact the generated loader actually loaded: `'native'` for
183
+ * a native addon, otherwise the `platformArchABI` of the WASI flavor. Every
184
+ * flavor napi-rs can build is listed, because `NAPI_RS_NATIVE_LIBRARY_PATH`
185
+ * can point the loader at a WASI artifact this package does not build itself.
186
+ */
187
+ export declare const __napiBindingTarget: 'native' | 'wasm32-wasi' | 'wasm32-wasip1'
188
+
181
189
  /**
182
190
  * AudioData - represents uncompressed audio data
183
191
  *
@@ -425,13 +433,19 @@ export declare class AudioEncoder {
425
433
  * Used for codedRect and visibleRect properties
426
434
  */
427
435
  export declare class DOMRectReadOnly {
428
- /** Create a new DOMRectReadOnly */
436
+ /**
437
+ * Create a new DOMRectReadOnly
438
+ *
439
+ * Arguments convert like WebIDL `unrestricted double` (ToNumber), as in browsers.
440
+ */
429
441
  constructor(
430
442
  x?: number | undefined | null,
431
443
  y?: number | undefined | null,
432
444
  width?: number | undefined | null,
433
445
  height?: number | undefined | null,
434
446
  )
447
+ /** Create a DOMRectReadOnly from a DOMRectInit dictionary (Geometry Interfaces `fromRect`) */
448
+ static fromRect(other?: DOMRectInit): DOMRectReadOnly
435
449
  /** X coordinate */
436
450
  get x(): number
437
451
  /** Y coordinate */
@@ -440,16 +454,16 @@ export declare class DOMRectReadOnly {
440
454
  get width(): number
441
455
  /** Height */
442
456
  get height(): number
443
- /** Top edge (same as y) */
457
+ /** Top edge: min(y, y + height), NaN if either is NaN */
444
458
  get top(): number
445
- /** Right edge (x + width) */
459
+ /** Right edge: max(x, x + width), NaN if either is NaN */
446
460
  get right(): number
447
- /** Bottom edge (y + height) */
461
+ /** Bottom edge: max(y, y + height), NaN if either is NaN */
448
462
  get bottom(): number
449
- /** Left edge (same as x) */
463
+ /** Left edge: min(x, x + width), NaN if either is NaN */
450
464
  get left(): number
451
465
  /** Convert to JSON (W3C spec uses toJSON) */
452
- toJSON(): DOMRectInit
466
+ toJSON(): DOMRectJSON
453
467
  }
454
468
 
455
469
  /**
@@ -517,7 +531,7 @@ export declare class EncodedVideoChunk {
517
531
  export declare class ImageDecoder {
518
532
  /**
519
533
  * Create a new ImageDecoder
520
- * Supports both Uint8Array and ReadableStream as data source per W3C spec.
534
+ * Supports a BufferSource (copied here) or a ReadableStream as data source per W3C spec.
521
535
  * ReadableStream input is buffered without a fixed size limit.
522
536
  */
523
537
  constructor(init: ImageDecoderInit)
@@ -606,8 +620,8 @@ export declare class MkvDemuxer {
606
620
  /**
607
621
  * Load an MKV from a buffer
608
622
  *
609
- * This method uses zero-copy buffer loading - the Uint8Array data is passed
610
- * directly to the demuxer without an intermediate copy.
623
+ * The bytes are copied when this is called, so the caller may reuse,
624
+ * detach or resize the buffer afterwards.
611
625
  */
612
626
  loadBuffer(data: Uint8Array): Promise<void>
613
627
  get tracks(): Array<DemuxerTrackInfo>
@@ -727,8 +741,8 @@ export declare class Mp4Demuxer {
727
741
  /**
728
742
  * Load an MP4 from a buffer
729
743
  *
730
- * This method uses zero-copy buffer loading - the Uint8Array data is passed
731
- * directly to the demuxer without an intermediate copy.
744
+ * The bytes are copied when this is called, so the caller may reuse,
745
+ * detach or resize the buffer afterwards.
732
746
  */
733
747
  loadBuffer(data: Uint8Array): Promise<void>
734
748
  /** Get all tracks */
@@ -1086,15 +1100,15 @@ export declare class VideoFrame {
1086
1100
  /**
1087
1101
  * Get the coded rect (the region containing valid pixel data)
1088
1102
  * Returns DOMRectReadOnly per W3C WebCodecs spec
1089
- * Throws InvalidStateError if the VideoFrame is closed
1103
+ * Returns null after the resource is closed.
1090
1104
  */
1091
- get codedRect(): DOMRectReadOnly
1105
+ get codedRect(): DOMRectReadOnly | null
1092
1106
  /**
1093
1107
  * Get the visible rect (the region of coded data that should be displayed)
1094
1108
  * Returns DOMRectReadOnly per W3C WebCodecs spec
1095
- * Throws InvalidStateError if the VideoFrame is closed
1109
+ * Returns null after the resource is closed.
1096
1110
  */
1097
- get visibleRect(): DOMRectReadOnly
1111
+ get visibleRect(): DOMRectReadOnly | null
1098
1112
  /**
1099
1113
  * Get the presentation timestamp in microseconds
1100
1114
  * Per W3C spec: "The timestamp getter steps are to return [[timestamp]]"
@@ -1120,9 +1134,15 @@ export declare class VideoFrame {
1120
1134
  * - I420A, I422A, I444A: 4 planes
1121
1135
  */
1122
1136
  get numberOfPlanes(): number
1123
- /** Get the rotation in degrees clockwise (0, 90, 180, 270) - W3C WebCodecs spec */
1137
+ /**
1138
+ * Get the rotation in degrees clockwise (0, 90, 180, 270) - W3C WebCodecs spec
1139
+ * Returns 0 after close (Close VideoFrame resets [[rotation]]).
1140
+ */
1124
1141
  get rotation(): number
1125
- /** Get whether horizontal flip is applied - W3C WebCodecs spec */
1142
+ /**
1143
+ * Get whether horizontal flip is applied - W3C WebCodecs spec
1144
+ * Returns false after close (Close VideoFrame resets [[flip]]).
1145
+ */
1126
1146
  get flip(): boolean
1127
1147
  /**
1128
1148
  * Get the metadata associated with this VideoFrame - W3C WebCodecs spec
@@ -1136,8 +1156,9 @@ export declare class VideoFrame {
1136
1156
  *
1137
1157
  * Returns a Promise that resolves with an array of PlaneLayout objects.
1138
1158
  * Options can specify target format and rect for cropped copy.
1159
+ * Like Chrome, the bytes are written before this call returns.
1139
1160
  */
1140
- copyTo(destination: Uint8Array, options?: VideoFrameCopyToOptions | undefined | null): Promise<Array<PlaneLayout>>
1161
+ copyTo(destination: Uint8Array, options?: VideoFrameCopyToOptions | undefined | null): Promise<PlaneLayout[]>
1141
1162
  /**
1142
1163
  * Clone this VideoFrame
1143
1164
  *
@@ -1150,7 +1171,9 @@ export declare class VideoFrame {
1150
1171
  * Per W3C spec "Close VideoFrame" algorithm:
1151
1172
  * 1. Assign null to frame's [[resource reference]]
1152
1173
  * 2. Assign true to frame's [[Detached]]
1153
- * Note: Metadata (timestamp, duration, etc.) remains accessible after close
1174
+ * Note: timestamp and duration remain accessible after close; rotation becomes 0,
1175
+ * flip false, codedRect and visibleRect null, every colorSpace field becomes null,
1176
+ * and callbacks registered with registerVideoFrameCloseObserver run synchronously.
1154
1177
  */
1155
1178
  close(): void
1156
1179
  }
@@ -1171,8 +1194,8 @@ export declare class WebMDemuxer {
1171
1194
  /**
1172
1195
  * Load a WebM from a buffer
1173
1196
  *
1174
- * This method uses zero-copy buffer loading - the Uint8Array data is passed
1175
- * directly to the demuxer without an intermediate copy.
1197
+ * The bytes are copied when this is called, so the caller may reuse,
1198
+ * detach or resize the buffer afterwards.
1176
1199
  */
1177
1200
  loadBuffer(data: Uint8Array): Promise<void>
1178
1201
  get tracks(): Array<DemuxerTrackInfo>
@@ -1299,7 +1322,7 @@ export interface AudioDecoderConfigJs {
1299
1322
  /** Number of channels */
1300
1323
  numberOfChannels?: number
1301
1324
  /** Codec-specific description */
1302
- description?: Uint8Array
1325
+ description?: AllowSharedBufferSource
1303
1326
  }
1304
1327
 
1305
1328
  /** Decoder configuration output (for passing to decoder) */
@@ -1371,6 +1394,24 @@ export type CodecState = 'unconfigured' | 'configured' | 'closed'
1371
1394
  /** ColorSpaceConversion for ImageDecoder (W3C WebCodecs spec) */
1372
1395
  export type ColorSpaceConversion = 'default' | 'none'
1373
1396
 
1397
+ /**
1398
+ * Native image-consumer interop: copies the half-float bits of an RGBA16Float frame into a new
1399
+ * `Uint16Array`. Returns the whole coded image; `visibleRect` is ignored. Throws a TypeError if
1400
+ * `frame` is not a VideoFrame, InvalidStateError if it is closed, and NotSupportedError if it does
1401
+ * not hold an RGBA16Float image.
1402
+ */
1403
+ export declare function copyVideoFrameRGBA16Float(frame: VideoFrame): Uint16Array
1404
+
1405
+ /** Native canvas-provider interop, separate from the browser VideoFrame interface. */
1406
+ export declare function createVideoFrameFromRGBA16Float(
1407
+ data: Uint16Array,
1408
+ init: Omit<VideoFrameBufferInit, 'format' | 'layout' | 'transfer'> & {
1409
+ rotation?: number
1410
+ flip?: boolean
1411
+ alpha?: 'keep' | 'discard'
1412
+ },
1413
+ ): VideoFrame
1414
+
1374
1415
  /** Audio decoder configuration exposed to JavaScript */
1375
1416
  export interface DemuxerAudioDecoderConfig {
1376
1417
  /** Codec string */
@@ -1423,6 +1464,18 @@ export interface DOMRectInit {
1423
1464
  height?: number
1424
1465
  }
1425
1466
 
1467
+ /** Result of DOMRectReadOnly.toJSON() */
1468
+ export interface DOMRectJSON {
1469
+ x: number
1470
+ y: number
1471
+ width: number
1472
+ height: number
1473
+ top: number
1474
+ right: number
1475
+ bottom: number
1476
+ left: number
1477
+ }
1478
+
1426
1479
  /** Output callback metadata for audio */
1427
1480
  export interface EncodedAudioChunkMetadata {
1428
1481
  /** Decoder configuration for this chunk */
@@ -1535,7 +1588,7 @@ export interface MkvAudioTrackConfig {
1535
1588
  /** Number of audio channels */
1536
1589
  numberOfChannels: number
1537
1590
  /** Codec-specific description data */
1538
- description?: Uint8Array
1591
+ description?: AllowSharedBufferSource
1539
1592
  }
1540
1593
 
1541
1594
  /** MKV muxer options */
@@ -1557,7 +1610,7 @@ export interface MkvVideoTrackConfig {
1557
1610
  /** Frame rate (frames per second) */
1558
1611
  framerate?: number
1559
1612
  /** Codec-specific description data */
1560
- description?: Uint8Array
1613
+ description?: AllowSharedBufferSource
1561
1614
  }
1562
1615
 
1563
1616
  /** Audio track configuration for MP4 muxer */
@@ -1569,7 +1622,7 @@ export interface Mp4AudioTrackConfig {
1569
1622
  /** Number of audio channels */
1570
1623
  numberOfChannels: number
1571
1624
  /** Codec-specific description data (esds for AAC, etc.) */
1572
- description?: Uint8Array
1625
+ description?: AllowSharedBufferSource
1573
1626
  }
1574
1627
 
1575
1628
  /** MP4 muxer options */
@@ -1599,7 +1652,7 @@ export interface Mp4VideoTrackConfig {
1599
1652
  /** Frame rate (frames per second) */
1600
1653
  framerate?: number
1601
1654
  /** Codec-specific description data (avcC/hvcC/av1C from encoder metadata) */
1602
- description?: Uint8Array
1655
+ description?: AllowSharedBufferSource
1603
1656
  /**
1604
1657
  * HEVC sample-entry override. Default picks "hvc1" when the hvcC
1605
1658
  * description is well-formed, single-layer, and complete; "hev1" permits
@@ -1649,6 +1702,12 @@ export interface PlaneLayout {
1649
1702
  stride: number
1650
1703
  }
1651
1704
 
1705
+ /** predefined RGB target color spaces. */
1706
+ export type PredefinedColorSpace = 'srgb' | 'display-p3'
1707
+
1708
+ /** Native image consumers subscribe to explicit close without changing the browser interface. */
1709
+ export declare function registerVideoFrameCloseObserver(frame: VideoFrame, callback: () => void): void
1710
+
1652
1711
  /**
1653
1712
  * Reset all hardware fallback state.
1654
1713
  *
@@ -1696,7 +1755,7 @@ export interface VideoDecoderConfigJs {
1696
1755
  /** Codec string */
1697
1756
  codec?: string
1698
1757
  /** Codec-specific description */
1699
- description?: Uint8Array
1758
+ description?: AllowSharedBufferSource
1700
1759
  /** Coded width */
1701
1760
  codedWidth?: number
1702
1761
  /** Coded height */
@@ -1787,8 +1846,10 @@ export interface VideoEncoderSupport {
1787
1846
  config: VideoEncoderConfig
1788
1847
  }
1789
1848
 
1790
- /** Options for copyTo operation */
1849
+ /** options for copyTo operation. */
1791
1850
  export interface VideoFrameCopyToOptions {
1851
+ /** target RGB color space. */
1852
+ colorSpace?: PredefinedColorSpace
1792
1853
  /** Target pixel format (for format conversion) */
1793
1854
  format?: VideoPixelFormat
1794
1855
  /** Region to copy (not yet implemented) */
@@ -1872,7 +1933,7 @@ export interface WebMAudioTrackConfig {
1872
1933
  /** Number of audio channels */
1873
1934
  numberOfChannels: number
1874
1935
  /** Codec-specific description data */
1875
- description?: Uint8Array
1936
+ description?: AllowSharedBufferSource
1876
1937
  }
1877
1938
 
1878
1939
  /** WebM muxer options */
@@ -1894,7 +1955,7 @@ export interface WebMVideoTrackConfig {
1894
1955
  /** Frame rate (frames per second) */
1895
1956
  framerate?: number
1896
1957
  /** Codec-specific description data */
1897
- description?: Uint8Array
1958
+ description?: AllowSharedBufferSource
1898
1959
  /** Whether the video has alpha channel (VP9 alpha support) */
1899
1960
  alpha?: boolean
1900
1961
  }