ws-cleanup: codecs/ grouped by domain; containers/Chunks, codecs/audio/Stream, codecs/image/Pixels, codecs/model/Mat4

C2, the hierarchy (tools/move.py, every reference rewritten mechanically):
- codecs/compress: Deflate Lzma Zstd Brotli Bzip2 Lzw; codecs/entropy: Huffman (from core) RangeCoder;
  codecs/image: Jpeg Dct Vp8 Vp8L Yuv Quantize Raster Blend Pixels; codecs/audio: Mdct Aac Alac Pcm Resample
  VorbisComment Tracker SoundFont Stream; codecs/video: H264 Mpeg1 Video; codecs/text: Json Xml Text Url;
  codecs/font: TrueType Cff; codecs/model: MeshFlatten Mat4. containers/ stays flat; core/ keeps Bytes Bits Err
  Crc32 Adler32 Base64 Md5 Input Sniff.
- LAYERS lint: codecs must sit in a domain folder; gen_registry lists codecs by domain (docs/FORMATS.md).
- Checked: build.py both targets, rojo build of build/roblox, the full suite on both runtimes.

C3, generic code out of format folders:
- containers/Chunks (new): the chunked-file walker (RIFF / RIFX / IFF / PNG / CAF layouts: endianness, size first,
  trailer, padding, lenient missing pad, open-ended ids, size hooks). containers/Riff walks with it (RF64 ds64
  through the resize hook); image/png, audio/aiff and audio/caf list their chunk handlers over it.
- codecs/audio/Stream (new): Stream.packets, the packet-decoder Decoder (read / seek with pre-roll / position,
  priming and end trimming) that aac, caf and m4a each carried (~70 lines each).
- codecs/image/Pixels: image/bmp/Pixels promoted (+ rgb555); image/ico's DIB decoder uses its row loops instead of
  its own (the AND mask / alpha rule stay ICO's).
- codecs/model/Mat4 (new): matrices / quaternions / TRS shared by FBX (Xform keeps only the FBX transform model),
  Collada (Math keeps only <lookat> / <skew>) and USD (its matrix helpers and general 4x4 inverse); Mat4.mul is
  Types.Scene.mul. The Collada normal matrix is now the inverse transpose (it was the inverse; same result for the
  fixtures' bind shapes).
- README rewritten (install for Rojo and LÖVE / LuaJIT, quick start per category, F.* and F.ops, host notes:
  FORMATS_NO_JIT_TUNE, paths, layout); docs/STYLE.md: the codec domains, "what belongs in a format folder" with the
  shared building blocks and the DUP rule, conventions (WAVE order, lower-case tags, loops, the api hooks
  decodeImage / encodeImage / openAudio / plugins / resolve, the codecs/video/Video registry), Err.from, the type
  baseline. New tests: tests/containers/chunks, tests/codecs/mat4. Type baseline 93.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
4DBugandClaude Opus 5.5 committed 2026-10-31 12:25:03 -05:00
1 parent 9c553b9d1a
commit 434a304315
283 files changed
+1877 -1660

No files matched your search

+1 -1
View File
@@ -9,7 +9,7 @@
# lib3mf / assimp / trimesh: { name, case, lib3mf, assimp, trimesh }
import importlib.util, json, os, subprocess, sys
INPUTS = ["src/Formats/model/3mf", "src/Formats/codecs/Xml", "src/Formats/containers/Zip",
INPUTS = ["src/Formats/model/3mf", "src/Formats/codecs/text/Xml", "src/Formats/containers/Zip",
"tools/fixtures/_3mf_reference.py", "tools/fixtures/_3mf_encode.luau", "tools/fixtures/_model_ref.py"]
MAX_SIZE = 500_000
+1 -1
View File
@@ -1,7 +1,7 @@
# 7z fixtures (tools/fixtures.py): a small tree (text, x86 machine code, runs, an empty file, empty and nested
# directories, UTF-16 names with accents and a surrogate pair) archived by 7-Zip 2x (nix _7zz) with many method chains:
# LZMA / LZMA2 / copy / Deflate, solid and non-solid, BCJ / ARM64 / delta filters, plain and compressed headers; plus
# BZip2 archives (codecs/Bzip2), archives whose methods are not supported (PPMd, BCJ2, AES) and an empty archive.
# BZip2 archives (codecs/compress/Bzip2), archives whose methods are not supported (PPMd, BCJ2, AES) and an empty archive.
# tests/gen/7z.luau { files = { { name, dir, data?, mtime } }, cases = { { name, data, unsupported? } } }
import os, random, subprocess, sys, tempfile
+2 -2
View File
@@ -219,11 +219,11 @@ def emit_signal(ctx, name, samples, rate, ch):
def encode_luau(ctx, module, sigmod, opts_lua="nil", source="audio"):
"""encode the emitted signal module `sigmod` with require("@formats/<module>").encode(audio, opts) in Luau; returns
the encoded bytes. source = "decoder" feeds a streaming Decoder (codecs/Pcm.audioDecoder) instead of the Audio."""
the encoded bytes. source = "decoder" feeds a streaming Decoder (codecs/audio/Pcm.audioDecoder) instead of the Audio."""
code = """
local S = require("@tests/gen/%s")
local Types = require("@formats/Types")
local Pcm = require("@formats/codecs/Pcm")
local Pcm = require("@formats/codecs/audio/Pcm")
local M = require("@formats/%s")
local a = Types.Audio.new(S.rate, S.channels, S.frames)
buffer.writestring(a.samples, 0, S.data)
+1 -1
View File
@@ -10,7 +10,7 @@ _spec = importlib.util.spec_from_file_location("_audio", os.path.join(os.path.di
A = importlib.util.module_from_spec(_spec)
_spec.loader.exec_module(A)
INPUTS = ["src/Formats/audio/aiff", "src/Formats/codecs/Pcm"]
INPUTS = ["src/Formats/audio/aiff", "src/Formats/codecs/audio/Pcm"]
def ff(codec, src="{in}", extra=()):
+1 -1
View File
@@ -8,7 +8,7 @@
# rendered by LibreSprite, with our flatten of the same frames
import json, os, shutil, struct, subprocess, tempfile, zlib
INPUTS = ["src/Formats/layered/aseprite", "src/Formats/codecs/Blend.luau", "tools/fixtures/_ours.luau"]
INPUTS = ["src/Formats/layered/aseprite", "src/Formats/codecs/image/Blend.luau", "tools/fixtures/_ours.luau"]
def s(text):
+1 -1
View File
@@ -10,7 +10,7 @@ _spec = importlib.util.spec_from_file_location("_audio", os.path.join(os.path.di
A = importlib.util.module_from_spec(_spec)
_spec.loader.exec_module(A)
INPUTS = ["src/Formats/audio/au", "src/Formats/codecs/Pcm"]
INPUTS = ["src/Formats/audio/au", "src/Formats/codecs/audio/Pcm"]
def ff(codec, src="{in}", extra=()):
+1 -1
View File
@@ -8,7 +8,7 @@
# { name, case, assimp }
import importlib.util, os, re, subprocess
INPUTS = ["src/Formats/model/dae", "src/Formats/codecs/Xml", "tools/fixtures/_model_ref.py", "tools/fixtures/_dae_encode.luau",
INPUTS = ["src/Formats/model/dae", "src/Formats/codecs/text/Xml", "tools/fixtures/_model_ref.py", "tools/fixtures/_dae_encode.luau",
"tests/fixtures/gltf"]
+1 -1
View File
@@ -10,7 +10,7 @@
# tests/gen/fbx_gltf.luau glTF sample models (tests/fixtures/gltf) for the writer round trips: { name, data, files }
import importlib.util, json, os, shutil, subprocess
INPUTS = ["src/Formats/model/fbx", "tests/fixtures/gltf", "src/Formats/codecs/Deflate", "tools/fixtures/_model_ref.py",
INPUTS = ["src/Formats/model/fbx", "tests/fixtures/gltf", "src/Formats/codecs/compress/Deflate", "tools/fixtures/_model_ref.py",
"tools/fixtures/_fbx_blender.py", "tools/fixtures/_fbx_blender_stats.py", "tools/fixtures/_fbx_encode.luau"]
+1 -1
View File
@@ -10,7 +10,7 @@ _spec = importlib.util.spec_from_file_location("_audio", os.path.join(os.path.di
A = importlib.util.module_from_spec(_spec)
_spec.loader.exec_module(A)
INPUTS = ["src/Formats/audio/flac", "src/Formats/codecs/Pcm", "src/Formats/core/Md5.luau"]
INPUTS = ["src/Formats/audio/flac", "src/Formats/codecs/audio/Pcm", "src/Formats/core/Md5.luau"]
def pcm_bytes(samples, bits):
+1 -1
View File
@@ -8,7 +8,7 @@
# by assimp and trimesh: { name, case, assimp, trimesh }
import importlib.util, json, os, struct
INPUTS = ["tests/fixtures/gltf", "src/Formats/model/gltf", "src/Formats/codecs/Json", "src/Formats/core/Base64",
INPUTS = ["tests/fixtures/gltf", "src/Formats/model/gltf", "src/Formats/codecs/text/Json", "src/Formats/core/Base64",
"tools/fixtures/_model_ref.py", "tools/fixtures/_gltf_encode.luau"]
+1 -1
View File
@@ -1,4 +1,4 @@
# codecs/Json + data/json fixtures: the JSONTestSuite parsing corpus (nst/JSONTestSuite, pinned tarball through nix)
# codecs/text/Json + data/json fixtures: the JSONTestSuite parsing corpus (nst/JSONTestSuite, pinned tarball through nix)
# with Python's json verdicts and canonical values, plus a random corpus written by Python's json.dumps in several
# styles (compact sorted, insertion order, indent 2, ensure_ascii) that the tests must parse and reproduce exactly.
# tests/gen/json_suite.luau { { name, expect = "y" | "n" | "i", data, canon? } }
+1 -1
View File
@@ -16,7 +16,7 @@ _sig = importlib.util.module_from_spec(_spec)
_spec.loader.exec_module(_sig)
signal, pack, wav = _sig.signal, _sig.pack, _sig.wav
INPUTS = ["src/Formats/audio/m4a", "src/Formats/audio/caf", "src/Formats/codecs/Alac", "src/Formats/containers/IsoBmff",
INPUTS = ["src/Formats/audio/m4a", "src/Formats/audio/caf", "src/Formats/codecs/audio/Alac", "src/Formats/containers/IsoBmff",
"tests/audio/_signal.luau", "tests/audio/_encode_cases.luau", "tools/fixtures/_m4a_encode.luau",
"tools/fixtures/_m4a_signal.py"]
PKGS = ["ffmpeg", "fdk-aac-encoder", "gpac"]
+4 -4
View File
@@ -1,6 +1,6 @@
# Motion-JPEG fixtures for codecs/Jpeg (tools/fixtures.py): ffmpeg's mjpeg encoder (testsrc2 / mandelbrot sources,
# Motion-JPEG fixtures for codecs/image/Jpeg (tools/fixtures.py): ffmpeg's mjpeg encoder (testsrc2 / mandelbrot sources,
# yuvj420p / yuvj422p / yuvj444p, odd sizes) split into its JPEG frames, and references for each frame:
# yuv CRC-32 of the yuv420p planes codecs/Jpeg must produce with { yuv = true }: libjpeg-turbo's own IDCT planes
# yuv CRC-32 of the yuv420p planes codecs/image/Jpeg must produce with { yuv = true }: libjpeg-turbo's own IDCT planes
# (TurboJPEG tj3DecompressToYUV8 through ctypes, the islow IDCT), cropped, 4:2:2 chroma row pairs averaged
# ((a + b + 1) >> 1), 4:4:4 chroma 2 x 2 averaged ((a + b + c + d + 2) >> 2): bit-exact
# rgba CRC-32 of djpeg -dct int (bit-exact)
@@ -14,7 +14,7 @@
# tests/gen/mjpeg_enc.luau yuv420p sources and what tj3CompressFromYUV8 writes for them at a quality (our
# encoder must write the same bytes), with djpeg's CRC and ffmpeg's PSNR of that file
# tests/gen/mjpeg_bench.luau 320x240 and 640x480 frames (4:2:0, 4:2:2) and yuv420p sources
# Binary fields are base64 (JPEG data) or base64 of zlib data (raw planes / pixels, inflated with codecs/Deflate):
# Binary fields are base64 (JPEG data) or base64 of zlib data (raw planes / pixels, inflated with codecs/compress/Deflate):
# Luau string literals of binary data cost ~3.7 bytes per byte, base64 1.33.
import base64, ctypes, math, os, shutil, subprocess, tempfile, zlib
@@ -73,7 +73,7 @@ class TurboJpeg:
return w, h, ss, (raw[:pw * ph], pw), (raw[pw * ph:pw * ph + cw * ch], cw, ch), (raw[pw * ph + cw * ch:], cw, ch)
def yuv420(self, jpeg):
"""what codecs/Jpeg { yuv = true } must produce for this frame"""
"""what codecs/image/Jpeg { yuv = true } must produce for this frame"""
w, h, ss, (Y, pw), cb, cr = self.planes(jpeg)
out = bytearray()
for y in range(h):
+1 -1
View File
@@ -11,7 +11,7 @@ _spec = importlib.util.spec_from_file_location("_audio", os.path.join(os.path.di
A = importlib.util.module_from_spec(_spec)
_spec.loader.exec_module(A)
INPUTS = ["src/Formats/audio/mp3", "src/Formats/codecs/Pcm"]
INPUTS = ["src/Formats/audio/mp3", "src/Formats/codecs/audio/Pcm"]
def generate(ctx):
+2 -2
View File
@@ -1,4 +1,4 @@
# MPEG-1 video fixtures for codecs/Mpeg1 (tools/fixtures.py), ported from mpeg1-luau tools/fixtures.py: elementary
# MPEG-1 video fixtures for codecs/video/Mpeg1 (tools/fixtures.py), ported from mpeg1-luau tools/fixtures.py: elementary
# streams made by ffmpeg's mpeg1video encoder (testsrc2 / mandelbrot, several bit rates, odd sizes, custom matrices,
# B-frames, a size change), their access units, and ffmpeg's own decode of each as references:
# tests/gen/mpeg1_<name>.luau { name, width, height, frames, file (base64), units = { { offset, length } },
@@ -9,7 +9,7 @@
# tests/gen/mpeg1_bench.luau { { width, height, file (base64), units } }: 320x240 and 640x480 streams (with
# B-frames) for tools/bench.luau
# Binary fields are base64 (file, units' data) or base64 of zlib data (frames: the test inflates them with
# codecs/Deflate): Luau string literals of binary data cost ~3.7 bytes per byte, base64 1.33. With short streams and
# codecs/compress/Deflate): Luau string literals of binary data cost ~3.7 bytes per byte, base64 1.33. With short streams and
# few whole frames the set stays near 10 MB.
import base64, os, shutil, subprocess, tempfile, zlib
+1 -1
View File
@@ -5,7 +5,7 @@
# ffmpeg (decoded), ffmpegFrames, comments (opusinfo's user comments) } }
import os, re, shutil, subprocess, tempfile, zlib
INPUTS = ["src/Formats/audio/opus", "src/Formats/codecs/Mdct", "src/Formats/containers/Ogg",
INPUTS = ["src/Formats/audio/opus", "src/Formats/codecs/audio/Mdct", "src/Formats/containers/Ogg",
"tests/audio/_opus_cases.luau", "tools/fixtures/_opus_encode.luau"]
+1 -1
View File
@@ -1,4 +1,4 @@
# Playlist fixtures (tools/fixtures.py): playlist/m3u, playlist/pls, playlist/xspf, codecs/Url, codecs/Text.
# Playlist fixtures (tools/fixtures.py): playlist/m3u, playlist/pls, playlist/xspf, codecs/text/Url, codecs/text/Text.
# tests/gen/playlist_url.luau random relative references resolved by Python's urllib.parse.urljoin (RFC 3986)
# tests/gen/playlist_cp1252.luau every Windows-1252 byte decoded by Python's cp1252 codec (undefined bytes: U+FFFD)
# tests/gen/playlist_cases.luau playlists written here (M3U8 with EXTINF, PLS via configparser-style lines, XSPF via
+1 -1
View File
@@ -8,7 +8,7 @@
# luau) read by psd-tools, compared with the layers and the flattened image we wrote.
import json, os, random, shutil, struct, subprocess, tempfile, zlib
INPUTS = ["src/Formats/layered/psd", "src/Formats/codecs/Blend.luau", "src/Formats/ops/LayerOps.luau", "tools/fixtures/_ours.luau"]
INPUTS = ["src/Formats/layered/psd", "src/Formats/codecs/image/Blend.luau", "src/Formats/ops/LayerOps.luau", "tools/fixtures/_ours.luau"]
BLEND = ["norm", "diss", "dark", "mul ", "idiv", "lbrn", "dkCl", "lite", "scrn", "div ", "lddg", "lgCl", "over", "sLit",
"hLit", "vLit", "lLit", "pLit", "hMix", "diff", "smud", "fsub", "fdiv", "hue ", "sat ", "colr", "lum "]
+2 -2
View File
@@ -13,8 +13,8 @@ V = importlib.util.module_from_spec(_spec)
_spec.loader.exec_module(V)
INPUTS = ["tools/fixtures/_video.py", "tools/fixtures/_video_encode.luau", "tools/fixtures/mkv.py", "tools/fixtures/avi.py", "tools/fixtures/mp4.py",
"src/Formats/video", "src/Formats/codecs/Video", "src/Formats/containers/Ebml", "src/Formats/containers/Avi", "src/Formats/containers/IsoBmff",
"src/Formats/codecs/Jpeg", "src/Formats/codecs/Vp8"]
"src/Formats/video", "src/Formats/codecs/video/Video", "src/Formats/containers/Ebml", "src/Formats/containers/Avi", "src/Formats/containers/IsoBmff",
"src/Formats/codecs/image/Jpeg", "src/Formats/codecs/image/Vp8"]
GIF = r"""
import io, sys
+1 -1
View File
@@ -10,7 +10,7 @@ _spec = importlib.util.spec_from_file_location("_audio", os.path.join(os.path.di
A = importlib.util.module_from_spec(_spec)
_spec.loader.exec_module(A)
INPUTS = ["src/Formats/audio/voc", "src/Formats/codecs/Pcm"]
INPUTS = ["src/Formats/audio/voc", "src/Formats/codecs/audio/Pcm"]
def ff(codec, src="{in}", extra=()):
+1 -1
View File
@@ -10,7 +10,7 @@
# tests/gen/webp_bench.luau bigger lossy / lossless files for tools/bench.luau
import json, os, random, shutil, struct, subprocess, tempfile, zlib
INPUTS = ["tools/fixtures/_webp_encode.luau", "src/Formats/codecs/Vp8L", "src/Formats/image/webp"]
INPUTS = ["tools/fixtures/_webp_encode.luau", "src/Formats/codecs/image/Vp8L", "src/Formats/image/webp"]
TOOLS = ["libwebp", "imagemagick", "ffmpeg"]
+1 -1
View File
@@ -1,4 +1,4 @@
# codecs/Xml + data/xml fixtures: random documents (namespaces, attributes with every escape, CDATA, comments, PIs,
# codecs/text/Xml + data/xml fixtures: random documents (namespaces, attributes with every escape, CDATA, comments, PIs,
# entities from an internal DOCTYPE, mixed content) written by hand, then parsed by Python's xml.etree (expat) for the
# reference tree; the same documents re-encoded as UTF-16 and Latin-1; and well-formedness cases (hand-written plus
# random mutations) with expat's verdict.