@swf2es/native 0.1.14 → 0.1.16
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 +27 -5
- package/dist/atf/binary.d.ts +1 -1
- package/dist/atf/binary.d.ts.map +1 -1
- package/dist/atf/binary.js +2 -2
- package/dist/atf/binary.js.map +1 -1
- package/dist/atf/index.d.ts +1 -1
- package/dist/atf/index.d.ts.map +1 -1
- package/dist/atf/index.js +3 -2
- package/dist/atf/index.js.map +1 -1
- package/dist/atf/jxr.d.ts +22 -0
- package/dist/atf/jxr.d.ts.map +1 -1
- package/dist/atf/jxr.js +51 -1
- package/dist/atf/jxr.js.map +1 -1
- package/dist/audio/binary.js +1 -1
- package/dist/compress/binary.d.ts +1 -1
- package/dist/compress/binary.d.ts.map +1 -1
- package/dist/compress/binary.js +2 -2
- package/dist/compress/binary.js.map +1 -1
- package/dist/compress/index.d.ts +10 -0
- package/dist/compress/index.d.ts.map +1 -1
- package/dist/compress/index.js +26 -0
- package/dist/compress/index.js.map +1 -1
- package/dist/mp3/binary.js +1 -1
- package/dist/render/binary.d.ts +1 -1
- package/dist/render/binary.d.ts.map +1 -1
- package/dist/render/binary.js +2 -2
- package/dist/render/binary.js.map +1 -1
- package/dist/render/bitmap-kernel.d.ts +1 -1
- package/dist/render/bitmap-kernel.js +1 -1
- package/dist/render/pixel-ops.d.ts +3 -0
- package/dist/render/pixel-ops.d.ts.map +1 -1
- package/dist/render/pixel-ops.js +4 -1
- package/dist/render/pixel-ops.js.map +1 -1
- package/package.json +1 -1
- package/src/atf/index.ts +11 -2
- package/src/atf/jxr.ts +96 -1
- package/src/compress/index.ts +39 -0
- package/src/render/bitmap-kernel.ts +1 -1
- package/src/render/pixel-ops.ts +6 -1
package/README.md
CHANGED
|
@@ -7,12 +7,14 @@ swf2es's WebAssembly modules, built with the repository's pinned Zig:
|
|
|
7
7
|
tessellation (`Tessellator`), a shape layer's lines built in one call
|
|
8
8
|
(`LineBuilder`), BitmapData's filters and pixel operations (`BitmapKernel`),
|
|
9
9
|
and whole-level DXT1/DXT5 texture encoding (`DxtEncoder`).
|
|
10
|
-
- `@swf2es/native/compress`: synchronous zlib and LZMA
|
|
10
|
+
- `@swf2es/native/compress`: synchronous zlib and LZMA, and the PNG and
|
|
11
|
+
JPEG encoders' passes over a bitmap.
|
|
11
12
|
- `@swf2es/native/mp3`: synchronous MP3 frame decoding with minimp3.
|
|
12
13
|
- `@swf2es/native/audio`: synchronous ADPCM and Nellymoser decoding, in
|
|
13
14
|
Zig alone.
|
|
14
15
|
- `@swf2es/native/atf`: Stage3D's ATF textures, read and decoded to what a
|
|
15
|
-
desktop GPU takes, their JPEG XR images by jxrlib
|
|
16
|
+
desktop GPU takes, their JPEG XR images by jxrlib; and JPEG XR files
|
|
17
|
+
written as Flash's `BitmapData.encode` writes them, by jxrlib's encoder.
|
|
16
18
|
|
|
17
19
|
The package depends on no other package and uses no DOM or node APIs.
|
|
18
20
|
`compress`, `mp3`, `audio` and `atf` each compile their own module. What the renderer
|
|
@@ -239,6 +241,13 @@ Upstream sources stay unchanged.
|
|
|
239
241
|
alpha; with `filter`, given the filter of PNG's five whose output sums
|
|
240
242
|
smallest, libpng's heuristic, sixteen bytes at a time (Wasm SIMD); and
|
|
241
243
|
handed to the deflate.
|
|
244
|
+
- `jpegEncode(pixels, width, height, quality)` makes a JPEG file of a
|
|
245
|
+
bitmap's ARGB pixels, alpha left out, as Flash's encoder does
|
|
246
|
+
(`jpeg.zig`, Zig alone): JFIF, 4:2:0, Annex K's quantization tables
|
|
247
|
+
scaled to the quality as the IJG scales them and its Huffman tables.
|
|
248
|
+
Colours are converted eight pixels at a time and the DCTs run eight and
|
|
249
|
+
sixteen columns at a time (Wasm SIMD); a chroma block is the low half
|
|
250
|
+
of its MCU's 16 by 16 DCT, as libjpeg scales since version 7.
|
|
242
251
|
- `lzmaDecode(stream, size)` decodes an LZMA stream, its 5 property bytes
|
|
243
252
|
first, to `size` bytes or to its end marker.
|
|
244
253
|
- `lzmaEncode(data)` writes `ByteArray`'s LZMA: properties, an 8-byte
|
|
@@ -487,10 +496,11 @@ skips (PVRTC's, ETC's), leaves that level and those after it absent, as
|
|
|
487
496
|
does a level whose blocks for the desktop are empty (png2atf's `-n`).
|
|
488
497
|
Nothing of the reserved bytes is read.
|
|
489
498
|
|
|
490
|
-
jxrlib's decoder and
|
|
499
|
+
jxrlib's decoder, glue and encoder (`vendor/jxrlib`, https://github.com/swf2es/jxrlib,
|
|
491
500
|
a fork of 4creators/jxrlib, Microsoft's release, at tag `v2019.10.9`) are
|
|
492
|
-
compiled unchanged
|
|
493
|
-
|
|
501
|
+
compiled unchanged at `-Os` (the encoder without `strenc_x86.c`, SSE2's):
|
|
502
|
+
the module is about 154 KB, 101 KB of it the decoder's (150 KB at `-O2`
|
|
503
|
+
for 3% less decoding time), and 56 KB gzipped. `src/atf/jxr.c` decodes
|
|
494
504
|
an image in the pixel format its block must have, setting jxrlib's output
|
|
495
505
|
to the container's pixel format as jxrlib's own decoder does (the
|
|
496
506
|
codestream may name another, which jxrlib would write by into a buffer
|
|
@@ -502,6 +512,18 @@ its allocator over a bump arena that each call resets. The instance is
|
|
|
502
512
|
kept between images as compress's is (`src/instance.ts`, the same
|
|
503
513
|
`MEMORY_KEPT`).
|
|
504
514
|
|
|
515
|
+
`jxrEncode(pixels, width, height, { alpha, quantization, subsampling,
|
|
516
|
+
trimFlexBits })` writes the JPEG XR file Flash's `BitmapData.encode`
|
|
517
|
+
writes for the same pixels, byte for byte (docs/architecture/bitmaps.md
|
|
518
|
+
has what Flash chooses). jxrlib's encoder writes the codestream, its rows
|
|
519
|
+
copied in 16 at a time; `jxr.c` then rewrites its headers as Flash's
|
|
520
|
+
(one quantizer index for all channels, the size always in 16 bits), pads
|
|
521
|
+
it as Flash does and wraps it in Flash's container of five tags. The
|
|
522
|
+
output grows in place at the top of the arena, so a file costs its own
|
|
523
|
+
size and the encoder's few rows of macroblocks. A 4800 by 2475 picture
|
|
524
|
+
encodes in about 150 ms at Flash's default quantization, 20, and 235 ms
|
|
525
|
+
lossless (`jpegEncode` takes 70 at quality 80); with alpha, 205 ms.
|
|
526
|
+
|
|
505
527
|
jxrlib is not memory safe on corrupt input: AddressSanitizer finds it
|
|
506
528
|
reading past its tables and writing through null pointers. In the module
|
|
507
529
|
these stay within its memory, whose stack comes first: a null pointer's
|