CODEC FAMILY: C AND JAVASCRIPT MEMORY PORTS
Generation 26 / Copyright 2026 Joerg Burbach / MIT

The source archive retains codec/shared directory relationships. Every codec
reads and writes memory. Files, exchange formats, audio devices, graphics,
rendering and browser controls belong to the host. C outputs use malloc;
release them with free() or the codec's document/video/song free operation.

C dependency sources, relative to this document:
  RAU:      rau/codecs/rau.c (link -lm where required)
  RFXL:     rfxl/codecs/rfxl.c
  LeXA:     lexa/codecs/lexa.c
  RPMC:     rpmc/codecs/rpmc.c
  FormA:    forma/codecs/forma.c, rfxl/codecs/rfxl.c, shared/packbits.c
  WORM0:    worm0/codecs/worm0.c, lexa/codecs/lexa.c
  RFXLAnim: rfxlanim/codecs/rfxlanim.c, rfxl/codecs/rfxl.c,
            rau/codecs/rau.c, lexa/codecs/lexa.c,
            shared/packbits.c, shared/brieflz-container.c (link -lm)
  PMF0:     pmf0/codecs/pmf0.c, rau/codecs/rau.c,
            lexa/codecs/lexa.c, shared/brieflz-container.c (link -lm)

Example compilation (add your memory-only caller as host.c):
  cc -std=c99 host.c rfxl/codecs/rfxl.c -o host

The JavaScript codec files support both CommonJS and classic browser globals.
Node dependencies use relative require paths. Browser dependencies:
  RAU, RFXL, LeXA: standalone codec scripts.
  RPMC: shared/io.js, rpmc/codecs/rpmc.js.
  FormA: shared/io.js, rfxl/codecs/rfxl.js, forma/codecs/forma.js.
  WORM0: shared/io.js, lexa/codecs/lexa.js, worm0/codecs/worm0.js.
  RFXLAnim: shared/io.js, RFXL, LeXA, shared/brieflz-container.js, RAU,
            rfxlanim/codecs/rfxlanim.js.
  PMF0: shared/io.js, LeXA, shared/brieflz-container.js, RAU, pmf0/codecs/pmf0.js.

Memory APIs:
  RAU: inspect, async encode, decode, decodeWav, encodeWav.
  RFXL: inspect, encode, decode; shared unpack payload decoder.
  RFXLAnim: inspect, encode, decode. Frames are arrays of RGBA Uint8Arrays;
            optional audioChunks are individual frame-aligned RAU streams.
  PMF0: inspect, encode, decode. Frames are arrays of RGBA Uint8Arrays;
        optional audio is one continuous RAU stream.
  RPMC: inspect, encode, decode. Complete numeric sample/instrument metadata
        remains a 1399-byte little-endian block plus UTF-8 name; events remain
        complete 44-byte cells. sample-schema.js defines every numeric offset.
  LeXA: inspect, encodeText, encodeFont, decode, briefLZEncode, briefLZDecode.
  FormA: inspect, encode, decode. Int32 coordinates use millimetres. JavaScript
         exposes scene attributes; C validates and preserves the uncompressed
         SCN attribute stream. Geometry is not duplicated in that stream.
  WORM0: inspect, encode, decode. Generic encoding uses Raw or BriefLZ chunks
         and hashes; embedded family resources retain their encoded bytes.

Port encoders produce valid generation-26 streams but do not replicate the
PureBasic candidate search, effort settings or byte-for-byte output. RFXL
uses raster prediction/BytePack, RFXLAnim uses full RFXL frames, PMF0 uses
spatial RGB residual blocks and explicit colour quantization. Lossless RAU,
RFXL, LeXA, integer FormA, generic WORM0 and PMF0 RGB preserve their documented
input values. PMF0 alpha is omitted. RFXLAnim maps Lossless requests to High.

RFXZ and PMFZ decoding reuse the one BriefLZ implementation. RFXZ encoding is
available through RFXLAnim.encode(..., quality, true). PMFZ group decoding
uses independent 25-frame groups; the port encoder writes PMF0, not PMFZ.
Browser buffers are bounded to 64 MiB. Large decoded animations/videos may
reach that limit well before their compressed input does.

Exchange boundaries:
  PNG uses browser-decoded RGBA, not PNG byte/metadata preservation.
  GIF has variable timing, 256 colours and one-bit transparency; browser import
  resamples to a constant frame rate, and export quantizes to the GIF palette.
  MP4 import/export requires browser WebCodecs support. H.264/AAC export is
  lossy. WAV uses RAU's PCM conversion; it can be saved independently of MP4.
  MOD31/XM 1.04 map to the existing 8-bit tracker sample contract. Unsupported
  extensions are rejected. Extended RPMC state has no equivalent in MOD/XM.
  OBJ has metre coordinates rounded to Int32 millimetres. Scene JSON preserves
  FormA's attribute object. External OBJ material/texture files are not loaded.

Browser hosts are ES modules, served over HTTP(S). Tracker playback requires
HTTPS or localhost and AudioWorklet. Third-party exchange/render libraries
are pinned and locally bundled; see vendor/LICENSES.txt and
vendor/OpenMPT-LICENSE.txt. They are not required by the C memory codecs.

The canonical PureBasic references remain authoritative. The download bundle
sources.zip includes their literal include closure. The source archive
ports.zip includes all port dependencies, not website media or a RapidWeaver
project. The RapidWeaver package is rebuilt separately only by the explicit
--package build and is not part of ports.zip.
