@swf2es/native 0.1.15 → 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 CHANGED
@@ -13,7 +13,8 @@ swf2es's WebAssembly modules, built with the repository's pinned Zig:
13
13
  - `@swf2es/native/audio`: synchronous ADPCM and Nellymoser decoding, in
14
14
  Zig alone.
15
15
  - `@swf2es/native/atf`: Stage3D's ATF textures, read and decoded to what a
16
- 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.
17
18
 
18
19
  The package depends on no other package and uses no DOM or node APIs.
19
20
  `compress`, `mp3`, `audio` and `atf` each compile their own module. What the renderer
@@ -495,10 +496,11 @@ skips (PVRTC's, ETC's), leaves that level and those after it absent, as
495
496
  does a level whose blocks for the desktop are empty (png2atf's `-n`).
496
497
  Nothing of the reserved bytes is read.
497
498
 
498
- jxrlib's decoder and glue (`vendor/jxrlib`, https://github.com/swf2es/jxrlib,
499
+ jxrlib's decoder, glue and encoder (`vendor/jxrlib`, https://github.com/swf2es/jxrlib,
499
500
  a fork of 4creators/jxrlib, Microsoft's release, at tag `v2019.10.9`) are
500
- compiled unchanged, without its encoder, at `-Os`: the module is about
501
- 100 KB, against 150 KB at `-O2` for 3% less time. `src/atf/jxr.c` decodes
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
502
504
  an image in the pixel format its block must have, setting jxrlib's output
503
505
  to the container's pixel format as jxrlib's own decoder does (the
504
506
  codestream may name another, which jxrlib would write by into a buffer
@@ -510,6 +512,18 @@ its allocator over a bump arena that each call resets. The instance is
510
512
  kept between images as compress's is (`src/instance.ts`, the same
511
513
  `MEMORY_KEPT`).
512
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
+
513
527
  jxrlib is not memory safe on corrupt input: AddressSanitizer finds it
514
528
  reading past its tables and writing through null pointers. In the module
515
529
  these stay within its memory, whose stack comes first: a null pointer's