@ai-ecoverse/wasm-libheif 0.0.0-stage → 1.23.6-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 (64) hide show
  1. package/LICENSE +1796 -0
  2. package/README.md +104 -2
  3. package/THIRD-PARTY-NOTICES.md +2993 -0
  4. package/bin/heif-dec +1 -0
  5. package/bin/heif-dec.wasm +0 -0
  6. package/bin/heif-info +1 -0
  7. package/bin/heif-info.wasm +0 -0
  8. package/include/dav1d/common.h +96 -0
  9. package/include/dav1d/data.h +117 -0
  10. package/include/dav1d/dav1d.h +329 -0
  11. package/include/dav1d/headers.h +440 -0
  12. package/include/dav1d/picture.h +157 -0
  13. package/include/dav1d/version.h +50 -0
  14. package/include/libde265/de265-version.h +36 -0
  15. package/include/libde265/de265.h +505 -0
  16. package/include/libheif/heif.h +43 -0
  17. package/include/libheif/heif_aux_images.h +182 -0
  18. package/include/libheif/heif_brands.h +385 -0
  19. package/include/libheif/heif_color.h +479 -0
  20. package/include/libheif/heif_components.h +264 -0
  21. package/include/libheif/heif_context.h +346 -0
  22. package/include/libheif/heif_cxx.h +1490 -0
  23. package/include/libheif/heif_decoding.h +219 -0
  24. package/include/libheif/heif_encoding.h +430 -0
  25. package/include/libheif/heif_entity_groups.h +221 -0
  26. package/include/libheif/heif_error.h +318 -0
  27. package/include/libheif/heif_experimental.h +185 -0
  28. package/include/libheif/heif_export.h +49 -0
  29. package/include/libheif/heif_image.h +440 -0
  30. package/include/libheif/heif_image_handle.h +196 -0
  31. package/include/libheif/heif_items.h +328 -0
  32. package/include/libheif/heif_library.h +211 -0
  33. package/include/libheif/heif_metadata.h +136 -0
  34. package/include/libheif/heif_omaf.h +104 -0
  35. package/include/libheif/heif_plugin.h +385 -0
  36. package/include/libheif/heif_properties.h +487 -0
  37. package/include/libheif/heif_regions.h +884 -0
  38. package/include/libheif/heif_security.h +124 -0
  39. package/include/libheif/heif_sequences.h +726 -0
  40. package/include/libheif/heif_tai_timestamps.h +202 -0
  41. package/include/libheif/heif_text.h +161 -0
  42. package/include/libheif/heif_tiling.h +149 -0
  43. package/include/libheif/heif_uncompressed.h +133 -0
  44. package/include/libheif/heif_version.h +38 -0
  45. package/lib/libdav1d.a +0 -0
  46. package/lib/libde265.a +0 -0
  47. package/lib/libheif.a +0 -0
  48. package/lib/pkgconfig/dav1d.pc +11 -0
  49. package/lib/pkgconfig/libde265.pc +11 -0
  50. package/lib/pkgconfig/libheif.pc +11 -0
  51. package/package.json +55 -4
  52. package/share/libheif/relink/heif-dec.a +0 -0
  53. package/share/libheif/relink/heif-info.a +0 -0
  54. package/share/libheif/relink/js/slicc-linkat.js +4 -0
  55. package/share/libheif/relink/js/slicc-uname.js +9 -0
  56. package/share/libheif/relink/js/slicc-writev.js +28 -0
  57. package/share/libheif/relink/ldflags.txt +1 -0
  58. package/share/libheif/relink/libheifio.a +0 -0
  59. package/share/libheif/relink/libjpeg.a +0 -0
  60. package/share/libheif/relink/libpng16.a +0 -0
  61. package/share/libheif/relink/libslicc-gaps.a +0 -0
  62. package/share/libheif/relink/libslicc_cred.a +0 -0
  63. package/share/libheif/relink/libz.a +0 -0
  64. package/share/libheif/relink/relink.sh +20 -0
package/README.md CHANGED
@@ -1,3 +1,105 @@
1
- # Temporary Holding Version
1
+ # `@ai-ecoverse/wasm-libheif`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [libheif](https://github.com/strukturag/libheif) 1.23.6 for
4
+ [slicc](https://github.com/ai-ecoverse/slicc)'s wasm realm: it decodes
5
+ HEIF / HEIC (iPhone photos) and AVIF. It has three commands: `heif-convert`,
6
+ `heif-dec` (the same program under libheif's current name) and `heif-info`.
7
+ It also ships the static libraries and headers, so other homescoop packages
8
+ can link it. `@ai-ecoverse/wasm-imagemagick-heif` does.
9
+
10
+ > **Optional package, HEVC inside.** HEIC images are HEVC (H.265). This
11
+ > package contains an HEVC decoder,
12
+ > [libde265](https://github.com/strukturag/libde265) 1.1.3, and **HEVC is
13
+ > patent-encumbered**: depending on where and how you use it, decoding HEVC
14
+ > may need a patent licence. That's why this package is never part of a base
15
+ > set: install it only if you want it. AVIF is decoded by
16
+ > [dav1d](https://code.videolan.org/videolan/dav1d) 1.5.4 (AV1, royalty-free).
17
+ > There are no encoders (no x265, no aom).
18
+
19
+ ```bash
20
+ pnpm add -g @ai-ecoverse/wasm-libheif
21
+ heif-info IMG_0001.HEIC
22
+ heif-convert IMG_0001.HEIC IMG_0001.png # or .jpg / .jpeg, -q 90 for JPEG quality
23
+ heif-convert --with-aux --no-colons portrait.heic p.png # p.png, p-depth.png, p-urn_com_apple_photo_2020_aux_hdrgainmap.png
24
+ heif-convert --with-exif IMG_0001.HEIC IMG_0001.jpg # IMG_0001.jpg + IMG_0001.exif
25
+ heif-convert photo.avif photo.png
26
+ heif-convert --list-decoders
27
+ ```
28
+
29
+ - **Several images in one file:** `heif-convert multi.heic out.png` writes
30
+ `out-1.png`, `out-2.png`, …, one per top-level image. `--with-aux` adds
31
+ the auxiliary images (an iPhone portrait's depth map and HDR gain map).
32
+ - **Orientation:** the HEIF rotation and mirror (`irot`/`imir`) are applied,
33
+ so the output is upright. An iPhone still taken in portrait comes out
34
+ 3024x4032. Because the pixels are already rotated, the EXIF copied into
35
+ the JPEG/PNG has its Orientation reset to 1. `--with-exif` writes the
36
+ original EXIF, with the camera's Orientation tag, to a `.exif` file next
37
+ to the output.
38
+ - **Output formats:** PNG (8 or 16 bit, with alpha when the image has it),
39
+ JPEG and Y4M. TIFF and WebP output are not built.
40
+ - **Limits:** there are no threads (tiles decode one after another), and no
41
+ plugins (`plugin path: plugins are disabled`). Upstream's Emscripten speed
42
+ shortcut, which turns off HEVC deblocking and SAO, is patched out, so
43
+ pixels match a native libheif. libheif's default security limits apply,
44
+ and `--disable-limits` lifts them.
45
+
46
+ ## Licences
47
+
48
+ | Part | Licence | Where |
49
+ | --- | --- | --- |
50
+ | libheif 1.23.6 (`lib/libheif.a`) | LGPL-3.0-or-later | `LICENSE` |
51
+ | libde265 1.1.3 (`lib/libde265.a`) | LGPL-3.0-or-later | `LICENSE` |
52
+ | dav1d 1.5.4 (`lib/libdav1d.a`) | BSD-2-Clause | `LICENSE` |
53
+ | heif-dec, heif-info, heifio (libheif examples) | MIT | `LICENSE` |
54
+ | zlib, libjpeg-turbo, libpng, Emscripten runtime | see notices | `THIRD-PARTY-NOTICES.md` |
55
+
56
+ `LICENSE` has all four texts, and `THIRD-PARTY-NOTICES.md` has every library
57
+ that `bin/*.wasm` links statically. The sources are the upstream release
58
+ tarballs pinned (with sha256) in
59
+ [`packages/libheif/recipe.yaml`](https://github.com/ai-ecoverse/homescoop/tree/main/packages/libheif/recipe.yaml),
60
+ plus the two patches next to it, and `build.sh` there is the complete build.
61
+
62
+ ## Relinking (LGPL)
63
+
64
+ The programs link libheif and libde265 statically, so the package ships
65
+ everything you need to relink them against your own build of either library:
66
+
67
+ - `lib/libheif.a`, `lib/libde265.a`, `lib/libdav1d.a`, `include/libheif`,
68
+ `include/libde265`, `include/dav1d` and `lib/pkgconfig/*.pc`;
69
+ - `share/libheif/relink/`: the application objects (`heif-dec.a`,
70
+ `heif-info.a`, `libheifio.a`), the other static libraries they use
71
+ (`libpng16.a`, `libjpeg.a`, `libz.a`, `libslicc-gaps.a`,
72
+ `libslicc_cred.a`), the slicc link flags (`ldflags.txt`, with every
73
+ `--js-library` they name in `js/`) and `relink.sh`.
74
+
75
+ With Emscripten 4.0.23 (`emcc` on PATH):
76
+
77
+ ```bash
78
+ cd node_modules/@ai-ecoverse/wasm-libheif
79
+ bash share/libheif/relink/relink.sh /tmp/relinked \
80
+ /path/to/your/libheif.a /path/to/your/libde265.a # defaults: lib/*.a
81
+ cp /tmp/relinked/heif-dec* /tmp/relinked/heif-info* bin/
82
+ ```
83
+
84
+ Build the replacement libraries like `build.sh` does: `emcmake cmake`,
85
+ static, `-fexceptions`, libheif with `-DHOMESCOOP_NO_EMBIND`,
86
+ `-DENABLE_PLUGIN_LOADING=OFF` and `-DENABLE_MULTITHREADING_SUPPORT=OFF`.
87
+ ladder-pr runs this relink on every build and checks the relinked
88
+ `heif-dec` against host libheif (`cert/lib/relink-check.mjs`).
89
+
90
+ To link libheif into your own program:
91
+ `PKG_CONFIG_PATH=$PWD/lib/pkgconfig pkg-config --static --cflags --libs libheif`
92
+ gives `-lheif -lde265 -ldav1d -lz`. Link with `-fexceptions`.
93
+
94
+ ## Tests
95
+
96
+ `packages/libheif/cert` runs under slicc-kernel. It covers real iPhone files
97
+ (an iPhone 13 Pro Max still, and an iPhone 13 Pro portrait with its depth map
98
+ and HDR gain map), libheif's two-image example and an AVIF, odd sizes
99
+ (451x461, 1x1, 1023x769 at 16 bit), a rotated file, and corrupt input. Every
100
+ PNG is compared with Homebrew's libheif 1.23.6 sample by sample. Most outputs
101
+ are bit-identical to the host's. In one, libheif's `example.heic` image 1, 35
102
+ of 3,279,360 samples differ by 1, and the cert allows at most 1 per sample on
103
+ at most 0.01% of samples, with each such sample listed in
104
+ `cert/fixtures/references.json`. Sources and licences of the sample files
105
+ are in `cert/fixtures/fixtures.json`.