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

+3 -3
View File
@@ -1,6 +1,6 @@
--!strict
-- music/it: Impulse Tracker modules (IMPM, ITTECH.TXT; also files from OpenMPT / Schism Tracker). Reads into the
-- codecs/Tracker Module and plays through its engine (Module:render() / open() -> an audio Decoder). Supports: up to
-- codecs/audio/Tracker Module and plays through its engine (Module:render() / open() -> an audio Decoder). Supports: up to
-- 64 channels, instrument and sample mode, new and old (pre-2.0) instrument headers, volume / panning / pitch (or
-- filter) envelopes with loops and sustain loops, new note actions and duplicate checks, pitch-pan separation,
-- resonant filters (instrument cutoff / resonance, default Zxx macros), 8 / 16-bit signed or unsigned mono / stereo
@@ -12,7 +12,7 @@
local Err = require("@formats/core/Err")
local Bytes = require("@formats/core/Bytes")
local Types = require("@formats/Types")
local Tracker = require("@formats/codecs/Tracker")
local Tracker = require("@formats/codecs/audio/Tracker")
local Itsex = require("@formats/music/it/Itsex")
-- ------------------------------------------------------------------------------------------------ contract
@@ -21,7 +21,7 @@ local It = {
category = "music",
extensions = { "it" },
mime = { "audio/it", "audio/x-it" },
deps = { "core/Err", "core/Bytes", "Types", "codecs/Tracker" },
deps = { "core/Err", "core/Bytes", "Types", "codecs/audio/Tracker" },
caps = { decode = true, encode = false, render = true, channels = { 1, 64 }, compressedSamples = true },
}
+3 -3
View File
@@ -1,11 +1,11 @@
--!strict
-- music/midi/Render: the tempo map (ticks -> seconds, as python mido computes lengths), the time-ordered event list,
-- and the audio Decoder that plays a Midi through codecs/SoundFont's synth (a SoundFont bank, or the built-in
-- and the audio Decoder that plays a Midi through codecs/audio/SoundFont's synth (a SoundFont bank, or the built-in
-- waveform set). Format 0 / 1: one tempo map from every track's tempo events, tracks merged (ties keep track order).
-- Format 2: each track is its own song with its own tempo map, played one after another.
local Err = require("@formats/core/Err")
local Types = require("@formats/Types")
local SoundFont = require("@formats/codecs/SoundFont")
local SoundFont = require("@formats/codecs/audio/SoundFont")
local Synth = SoundFont.Synth
@@ -162,7 +162,7 @@ end
export type RenderOptions = {
sampleRate: number?, -- default 44100
soundfont: any?, -- a SoundFont (music/sf2 decode, codecs/SoundFont.parse) or SF2 bytes (buffer / string); default the built-in waveforms
soundfont: any?, -- a SoundFont (music/sf2 decode, codecs/audio/SoundFont.parse) or SF2 bytes (buffer / string); default the built-in waveforms
gain: number?, -- linear output gain, default 0.5
tail: number?, -- seconds rendered after the last event (release tails), default 1
maxVoices: number?, -- default 256
+2 -2
View File
@@ -1,6 +1,6 @@
--!strict
-- music/midi: Standard MIDI Files (SMF 1.0: formats 0, 1 and 2; PPQ and SMPTE time; RIFF RMID read). Written from the
-- specification (no third-party code); rendering goes through codecs/SoundFont (a TinySoundFont port).
-- specification (no third-party code); rendering goes through codecs/audio/SoundFont (a TinySoundFont port).
-- Supports: decode to a Types.Midi (absolute ticks; channel events noteOff / noteOn / aftertouch / controller /
-- program / channelPressure / pitchBend with their raw data bytes, sysex / escape with the bytes after the length,
-- meta events with meta = the meta type; meta.tempos / timeSignatures / keySignatures, track names), encode (running
@@ -21,7 +21,7 @@ local Midi = {
category = "music",
extensions = { "mid", "midi", "smf", "kar", "rmi" },
mime = { "audio/midi", "audio/x-midi" },
deps = { "core/Err", "core/Bytes", "codecs/SoundFont", "Types" },
deps = { "core/Err", "core/Bytes", "codecs/audio/SoundFont", "Types" },
caps = { decode = true, encode = true, formats = { 0, 1, 2 }, render = true, streaming = true, rmid = true },
}
+3 -3
View File
@@ -1,7 +1,7 @@
--!strict
-- music/mod: ProTracker / NoiseTracker / StarTrekker MOD modules (the 31-sample "M.K." family: M.K., M!K!, FLT4,
-- 4CHN .. 9CHN, 10CH .. 32CH, xxCN, CD81, OKTA / OCTA, TDZx; 15-sample Soundtracker files when asked for by name or
-- extension). Written from the ProTracker 2.3 documentation. Reads into the codecs/Tracker Module and plays through
-- extension). Written from the ProTracker 2.3 documentation. Reads into the codecs/audio/Tracker Module and plays through
-- its engine (Module:render() / open() -> an audio Decoder). Writes 31-sample MODs (M.K. / xCHN / xxCH) from "mod"
-- modules, and from XM modules that fit (one sample per instrument, effects 0..F, 64-row patterns).
-- Not supported: FLT8's split 4 + 4 channel patterns (read as 8 plain channels), the Amiga hardware low-pass filter
@@ -11,7 +11,7 @@
local Err = require("@formats/core/Err")
local Bytes = require("@formats/core/Bytes")
local Types = require("@formats/Types")
local Tracker = require("@formats/codecs/Tracker")
local Tracker = require("@formats/codecs/audio/Tracker")
-- ------------------------------------------------------------------------------------------------ contract
local Mod = {
@@ -19,7 +19,7 @@ local Mod = {
category = "music",
extensions = { "mod", "m15", "stk", "nst" },
mime = { "audio/x-mod", "audio/mod" },
deps = { "core/Err", "core/Bytes", "Types", "codecs/Tracker" },
deps = { "core/Err", "core/Bytes", "Types", "codecs/audio/Tracker" },
caps = { decode = true, encode = true, render = true, channels = { 1, 32 } },
}
+3 -3
View File
@@ -1,6 +1,6 @@
--!strict
-- music/s3m: Scream Tracker 3 modules (SCRM, ST3 TECH.DOC; also files from Impulse Tracker / OpenMPT / Schism
-- Tracker). Reads into the codecs/Tracker Module and plays through its engine (Module:render() / open() -> an audio
-- Tracker). Reads into the codecs/audio/Tracker Module and plays through its engine (Module:render() / open() -> an audio
-- Decoder). Supports: up to 32 PCM channels, 8 / 16-bit signed or unsigned, mono or stereo samples, loops, the panning
-- table, ST3.00 fast volume slides, every ST3 effect. Notes are stored one octave up (S3M C-4 = note 61 = the C5
-- speed reference, as IT shows S3M files).
@@ -10,7 +10,7 @@
local Err = require("@formats/core/Err")
local Bytes = require("@formats/core/Bytes")
local Types = require("@formats/Types")
local Tracker = require("@formats/codecs/Tracker")
local Tracker = require("@formats/codecs/audio/Tracker")
-- ------------------------------------------------------------------------------------------------ contract
local S3m = {
@@ -18,7 +18,7 @@ local S3m = {
category = "music",
extensions = { "s3m" },
mime = { "audio/s3m", "audio/x-s3m" },
deps = { "core/Err", "core/Bytes", "Types", "codecs/Tracker" },
deps = { "core/Err", "core/Bytes", "Types", "codecs/audio/Tracker" },
caps = { decode = true, encode = false, render = true, channels = { 1, 32 } },
}
+4 -4
View File
@@ -1,5 +1,5 @@
--!strict
-- music/sf2: SoundFont 2 banks (SoundFont 2.04 specification), read-only. A thin wrapper over codecs/SoundFont (the
-- music/sf2: SoundFont 2 banks (SoundFont 2.04 specification), read-only. A thin wrapper over codecs/audio/SoundFont (the
-- parser and the TinySoundFont-port synth music/midi renders with). Supports: INFO, 16-bit samples (+ sm24 24-bit),
-- presets / instruments / sample headers with global zones, generator merging into playable regions.
-- Not supported: writing, SF3 (Ogg Vorbis samples), modulators (read past, not applied).
@@ -8,7 +8,7 @@
-- ------------------------------------------------------------------------------------------------ requires
local Err = require("@formats/core/Err")
local Bytes = require("@formats/core/Bytes")
local SoundFont = require("@formats/codecs/SoundFont")
local SoundFont = require("@formats/codecs/audio/SoundFont")
-- ------------------------------------------------------------------------------------------------ contract
local Sf2 = {
@@ -16,7 +16,7 @@ local Sf2 = {
category = "music",
extensions = { "sf2" },
mime = { "audio/x-soundfont" },
deps = { "core/Err", "core/Bytes", "codecs/SoundFont" },
deps = { "core/Err", "core/Bytes", "codecs/audio/SoundFont" },
caps = { decode = true, encode = false, sm24 = true, sf3 = false },
}
@@ -37,7 +37,7 @@ function Sf2.decode(r: Bytes.Reader, opts: DecodeOptions?): (SoundFont.SoundFont
end
-- ------------------------------------------------------------------------------------------------ extras
-- synth(sf?, sampleRate?, opts?) -> a synth State (codecs/SoundFont.Synth drives it)
-- synth(sf?, sampleRate?, opts?) -> a synth State (codecs/audio/SoundFont.Synth drives it)
Sf2.synth = SoundFont.synth
Sf2.fallback = SoundFont.fallback
+3 -3
View File
@@ -1,6 +1,6 @@
--!strict
-- music/xm: FastTracker 2 Extended Modules (XM 1.04, the "Extended Module: " format; also OpenMPT / MilkyTracker /
-- Skale files). Written from the XM specification and FT2 behaviour notes. Reads into the codecs/Tracker Module and
-- Skale files). Written from the XM specification and FT2 behaviour notes. Reads into the codecs/audio/Tracker Module and
-- plays through its engine (Module:render() / open() -> an audio Decoder): up to 32 channels (more are read), 8 / 16-bit
-- delta samples, multi-sample instruments with volume / panning envelopes, fadeout and auto-vibrato, linear and Amiga
-- frequency tables, every FT2 effect and volume-column command. Writes XM from "xm" modules (byte-identical for files
@@ -11,7 +11,7 @@
local Err = require("@formats/core/Err")
local Bytes = require("@formats/core/Bytes")
local Types = require("@formats/Types")
local Tracker = require("@formats/codecs/Tracker")
local Tracker = require("@formats/codecs/audio/Tracker")
-- ------------------------------------------------------------------------------------------------ contract
local Xm = {
@@ -19,7 +19,7 @@ local Xm = {
category = "music",
extensions = { "xm" },
mime = { "audio/xm", "audio/x-xm" },
deps = { "core/Err", "core/Bytes", "Types", "codecs/Tracker" },
deps = { "core/Err", "core/Bytes", "Types", "codecs/audio/Tracker" },
caps = { decode = true, encode = true, render = true, channels = { 1, 64 } },
}