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
@@ -4,7 +4,7 @@
local T = require("@tests/T")
local F = require("@formats")
local Gzip = require("@formats/archive/gzip")
local Deflate = require("@formats/codecs/Deflate")
local Deflate = require("@formats/codecs/compress/Deflate")
local Bytes = require("@formats/core/Bytes")
local Crc32 = require("@formats/core/Crc32")
local Err = require("@formats/core/Err")
+1 -1
View File
@@ -8,7 +8,7 @@
local T = require("@tests/T")
local Zip = require("@formats/containers/Zip")
local ZipF = require("@formats/archive/zip")
local Deflate = require("@formats/codecs/Deflate")
local Deflate = require("@formats/codecs/compress/Deflate")
local Bytes = require("@formats/core/Bytes")
local Crc32 = require("@formats/core/Crc32")
local Err = require("@formats/core/Err")
+2 -2
View File
@@ -4,7 +4,7 @@
-- Reader; tags and pictures; the length from the last frame; sniff; the api; damaged frames skipped; the fuzz pass.
-- Ported from flac-luau tests/flac.luau. Fixtures: tools/fixtures/flac.py.
local T = require("@tests/T")
local VorbisComment = require("@formats/codecs/VorbisComment")
local VorbisComment = require("@formats/codecs/audio/VorbisComment")
local Flac = require("@formats/audio/flac")
local Bytes = require("@formats/core/Bytes")
local Crc32 = require("@formats/core/Crc32")
@@ -93,7 +93,7 @@ for _, fx in Cases do
t:check(math.abs(pos - fx.frames / 3) <= 1, name .. ": seek seconds")
dec:seek(dec.duration + 5)
t:eq(select(2, dec:read(10)), 0, name .. ": read past the end")
for key, v in fx.tags or {} do -- (tags keys are lower case: codecs/VorbisComment)
for key, v in fx.tags or {} do -- (tags keys are lower case: codecs/audio/VorbisComment)
t:eq(dec.tags[VorbisComment.tagKey(key)], v, name .. ": tag " .. key)
end
t:eq(Flac.sniff(Bytes.reader(buffer.fromstring(fx.data))), 1, name .. ": sniff")
+1 -1
View File
@@ -7,7 +7,7 @@ local Flac = require("@formats/audio/flac")
local Bytes = require("@formats/core/Bytes")
local Err = require("@formats/core/Err")
local Types = require("@formats/Types")
local Pcm = require("@formats/codecs/Pcm")
local Pcm = require("@formats/codecs/audio/Pcm")
local Enc = require("@tests/gen/flac_enc")
local Sigs = require("@tests/gen/flac_enc_sigs")
+2 -2
View File
@@ -8,7 +8,7 @@ local Mp3 = require("@formats/audio/mp3")
local Bytes = require("@formats/core/Bytes")
local Err = require("@formats/core/Err")
local Types = require("@formats/Types")
local Pcm = require("@formats/codecs/Pcm")
local Pcm = require("@formats/codecs/audio/Pcm")
local Enc = require("@tests/gen/mp3_enc")
local Sigs = require("@tests/gen/mp3_enc_sigs")
@@ -121,7 +121,7 @@ do
t:check(empty and buffer.len(empty) > 0, "empty input: one flush frame")
end
-- other input rates are resampled (codecs/Resample) to the next rate up: 44 kHz -> 44.1 kHz, 46 kHz -> 48 kHz,
-- other input rates are resampled (codecs/audio/Resample) to the next rate up: 44 kHz -> 44.1 kHz, 46 kHz -> 48 kHz,
-- layer II 8 kHz -> 16 kHz, opts.sampleRate
do
local function tone(rate: number, f: number): any
+2 -2
View File
@@ -9,11 +9,11 @@ local Opus = require("@formats/audio/opus")
local Packet = require("@formats/audio/opus/Packet")
local Celt = require("@formats/audio/opus/Celt")
local Silk = require("@formats/audio/opus/Silk")
local RD = require("@formats/codecs/RangeCoder/Decoder")
local RD = require("@formats/codecs/entropy/RangeCoder/Decoder")
local Decoder = require("@formats/audio/opus/Decoder")
local Ogg = require("@formats/containers/Ogg")
local Bytes = require("@formats/core/Bytes")
local Pcm = require("@formats/codecs/Pcm")
local Pcm = require("@formats/codecs/audio/Pcm")
local Err = require("@formats/core/Err")
local t = T.suite("opus")
+2 -2
View File
@@ -7,7 +7,7 @@ local Vorbis = require("@formats/audio/vorbis")
local Bytes = require("@formats/core/Bytes")
local Err = require("@formats/core/Err")
local Types = require("@formats/Types")
local Pcm = require("@formats/codecs/Pcm")
local Pcm = require("@formats/codecs/audio/Pcm")
local Ogg = require("@formats/containers/Ogg")
local Cases = require("@tests/gen/vorbis_cases")
@@ -58,7 +58,7 @@ for _, c in Cases do
t:eq(a.frames, c.inputFrames, c.name .. ": frames = the encoder's input")
local ref16 = buffer.fromstring(c.ref16)
local n = c.frames * c.channels
-- oggdec -R keeps the Vorbis channel order; the decoder returns WAVE order (codecs/Pcm)
-- oggdec -R keeps the Vorbis channel order; the decoder returns WAVE order (codecs/audio/Pcm)
local order = Pcm.WAVE_FROM_VORBIS[c.channels]
if c.channels > 2 and order then
local w = buffer.create(buffer.len(ref16))
+1 -1
View File
@@ -8,7 +8,7 @@ local VEnc = require("@formats/audio/vorbis/Encode")
local Bytes = require("@formats/core/Bytes")
local Err = require("@formats/core/Err")
local Types = require("@formats/Types")
local Pcm = require("@formats/codecs/Pcm")
local Pcm = require("@formats/codecs/audio/Pcm")
local Enc = require("@tests/gen/vorbis_enc")
local Sigs = require("@tests/gen/vorbis_enc_sigs")
+2 -2
View File
@@ -1,9 +1,9 @@
-- codecs/Aac tests: AudioSpecificConfig parsing (every fixture's esds, explicit SBR / PS signalling from fdkaac,
-- codecs/audio/Aac tests: AudioSpecificConfig parsing (every fixture's esds, explicit SBR / PS signalling from fdkaac,
-- crafted configs: PCE channel counts, 960-sample frames, Main / LTP object types), ADTS headers, raw frames decoded
-- straight from ADTS against ffmpeg's float decode, the FIL extension hook on HE-AAC (implicit SBR), reset, errors,
-- the fuzz no-throw pass on raw frames. Fixtures: tools/fixtures/m4a.py.
local T = require("@tests/T")
local Aac = require("@formats/codecs/Aac")
local Aac = require("@formats/codecs/audio/Aac")
local IsoBmff = require("@formats/containers/IsoBmff")
local Bytes = require("@formats/core/Bytes")
local Bits = require("@formats/core/Bits")
+2 -2
View File
@@ -1,9 +1,9 @@
-- codecs/Alac tests: encoder -> decoder round trips over silence (zero runs), full-scale noise (uncompressed frames),
-- codecs/audio/Alac tests: encoder -> decoder round trips over silence (zero runs), full-scale noise (uncompressed frames),
-- tones, steps, 1 - 8 channels, 16 / 20 / 24 bits, partial and tiny frames, custom frame lengths; ffmpeg's ALAC
-- packets (through containers/IsoBmff) decode to the source integers; the magic cookie (plain, behind frma / alac atoms,
-- bad versions / depths); errors; the fuzz no-throw pass on packets. Fixtures: tools/fixtures/m4a.py.
local T = require("@tests/T")
local Alac = require("@formats/codecs/Alac")
local Alac = require("@formats/codecs/audio/Alac")
local IsoBmff = require("@formats/containers/IsoBmff")
local Bytes = require("@formats/core/Bytes")
local Crc32 = require("@formats/core/Crc32")
+2 -2
View File
@@ -1,9 +1,9 @@
-- codecs/Brotli tests: every fixture stream (reference encoder: qualities 0..11, windows 10..24, text / font / generic
-- codecs/compress/Brotli tests: every fixture stream (reference encoder: qualities 0..11, windows 10..24, text / font / generic
-- modes, large windows) decodes to its corpus; consumedEnd; offsets inside a bigger buffer; the static dictionary;
-- hand-made streams (empty, metadata, uncompressed); maxBytes; truncated / corrupted / random input returns nil, Err
-- and never throws. Fixtures: tools/fixtures/brotli.py.
local T = require("@tests/T")
local Brotli = require("@formats/codecs/Brotli")
local Brotli = require("@formats/codecs/compress/Brotli")
local Err = require("@formats/core/Err")
local Crc32 = require("@formats/core/Crc32")
local Fx = require("@tests/gen/brotli")
+2 -2
View File
@@ -1,9 +1,9 @@
-- codecs/Bzip2 tests: every fixture stream (Python bz2 = libbzip2, block sizes 1..9, RLE1 run edges, block-boundary
-- codecs/compress/Bzip2 tests: every fixture stream (Python bz2 = libbzip2, block sizes 1..9, RLE1 run edges, block-boundary
-- runs, random / skewed data, concatenated streams with trailing garbage) decodes exactly; offsets / consumedEnd;
-- maxBytes; CRC mismatches are Err.CHECKSUM; truncations are Err.TRUNCATED; the fuzz no-throw pass.
-- Fixtures: tools/fixtures/bzip2.py.
local T = require("@tests/T")
local Bzip2 = require("@formats/codecs/Bzip2")
local Bzip2 = require("@formats/codecs/compress/Bzip2")
local Err = require("@formats/core/Err")
local Fx = require("@tests/gen/bzip2")
+2 -2
View File
@@ -1,9 +1,9 @@
-- codecs/Dct tests: the islow inverse DCT against a double-precision reference (within 1 level per sample, as T.81
-- codecs/image/Dct tests: the islow inverse DCT against a double-precision reference (within 1 level per sample, as T.81
-- annex A accuracy needs), forward DCT + quantiser against the reference transform (round to nearest of v / (8 q)),
-- fdct -> idct round trips at q = 1 within 1 level, edge replication of fdctQuantize, and garbage coefficients never
-- throw (outputs stay clamped). The bit-exact djpeg / cjpeg checks are in tests/image/jpeg.luau.
local T = require("@tests/T")
local Dct = require("@formats/codecs/Dct")
local Dct = require("@formats/codecs/image/Dct")
local t = T.suite("dct")
local rand = T.rng(11)
+2 -2
View File
@@ -1,9 +1,9 @@
-- codecs/Deflate tests: every fixture case (Python zlib, levels 0-9, every strategy, small windows, flushes, gzip
-- codecs/compress/Deflate tests: every fixture case (Python zlib, levels 0-9, every strategy, small windows, flushes, gzip
-- headers, multi-member gzip) decodes; exact-size mode; checksum vectors; the compressor round-trips every corpus at
-- every level (and its zlib / gzip framing); truncated / corrupted / random input returns nil, Err and never throws.
-- Ported from deflate-luau tests/inflate.luau. Fixtures: tools/fixtures/deflate.py.
local T = require("@tests/T")
local Deflate = require("@formats/codecs/Deflate")
local Deflate = require("@formats/codecs/compress/Deflate")
local Err = require("@formats/core/Err")
local Fx = require("@tests/gen/deflate")
+2 -2
View File
@@ -1,11 +1,11 @@
-- codecs/H264 tests: libx264 streams at many settings (Baseline / Main / High, CAVLC / CABAC, B frames, references,
-- codecs/video/H264 tests: libx264 streams at many settings (Baseline / Main / High, CAVLC / CABAC, B frames, references,
-- weighted prediction, 8x8 transforms, scaling matrices, slices, odd sizes with cropping, ...) decoded and compared
-- per frame with ffmpeg's decoder (CRC-32 of the yuv420p planes, bit-exact); the AVCC (avcC + length-prefixed
-- samples) and NAL-at-a-time paths; pts propagation; UNSUPPORTED streams (interlaced, 4:2:2, 4:4:4, 10-bit); error
-- codes; and the fuzz no-throw pass. Fixtures: tools/fixtures/h264.py.
local T = require("@tests/T")
require("@formats/host") -- LuaJIT: the trace limits the api sets (host/init.luau)
local H264 = require("@formats/codecs/H264")
local H264 = require("@formats/codecs/video/H264")
local Crc32 = require("@formats/core/Crc32")
local Err = require("@formats/core/Err")
local Cases = require("@tests/gen/h264_cases")
+2 -2
View File
@@ -1,11 +1,11 @@
-- codecs/H264 conformance: a selection of the ITU-T H.264.1 (JVT) conformance bitstreams (Baseline / Main / Extended
-- codecs/video/H264 conformance: a selection of the ITU-T H.264.1 (JVT) conformance bitstreams (Baseline / Main / Extended
-- without SP / High: CAVLC, CABAC, B frames, weighted prediction, multiple slices, MMCO / long-term references,
-- frame_num gaps, cropping, PCM, 8x8 transforms, scaling matrices, ...) decoded bit-exact against the reference
-- decoder's yuv (JM, shipped in each zip; ffmpeg where there is none), and interlaced / SP / 4:2:2 streams refused
-- with UNSUPPORTED. Fixtures: tools/fixtures/h264_jvt.py (downloaded from itu.int; skipped when unreachable).
local T = require("@tests/T")
require("@formats/host") -- LuaJIT: the trace limits the api sets (host/init.luau)
local H264 = require("@formats/codecs/H264")
local H264 = require("@formats/codecs/video/H264")
local Crc32 = require("@formats/core/Crc32")
local Base64 = require("@formats/core/Base64")
local Err = require("@formats/core/Err")
+3 -3
View File
@@ -1,16 +1,16 @@
-- codecs/Jpeg tests (the Motion-JPEG side; tests/image/jpeg.luau covers the still-image decoder and encoder through
-- codecs/image/Jpeg tests (the Motion-JPEG side; tests/image/jpeg.luau covers the still-image decoder and encoder through
-- image/jpeg): ffmpeg mjpeg frames (4:2:0, 4:2:2, 4:4:4, odd sizes, stripped DHT, AVI1 + junk after EOI) decoded
-- to yuv420p bit-exact with libjpeg-turbo's IDCT planes (TurboJPEG) and to rgba8 bit-exact with djpeg, and within
-- PSNR thresholds of ffmpeg's own decode; an interlaced AVI1 frame (two fields) woven; the yuv420p encoder
-- byte-identical to TurboJPEG's tj3CompressFromYUV8, read back by djpeg (exact) and ffmpeg (PSNR); the API's
-- arguments; the fuzz no-throw pass. Fixtures: tools/fixtures/mjpeg.py.
local T = require("@tests/T")
local Jpeg = require("@formats/codecs/Jpeg")
local Jpeg = require("@formats/codecs/image/Jpeg")
local Crc32 = require("@formats/core/Crc32")
local Err = require("@formats/core/Err")
local Types = require("@formats/Types")
local Base64 = require("@formats/core/Base64")
local Deflate = require("@formats/codecs/Deflate")
local Deflate = require("@formats/codecs/compress/Deflate")
local Fx = require("@tests/gen/mjpeg_cases")
local Enc = require("@tests/gen/mjpeg_enc")
+2 -2
View File
@@ -1,9 +1,9 @@
-- codecs/Json tests: the JSONTestSuite parsing corpus (y_ must parse to Python's value, n_ must fail, i_ must not
-- codecs/text/Json tests: the JSONTestSuite parsing corpus (y_ must parse to Python's value, n_ must fail, i_ must not
-- throw), Python json.dumps output in four styles parsed and reproduced byte for byte (compact sorted, ordered,
-- indent 2, ensure_ascii), events / lines / decodeAt / writer, options, error codes, and the fuzz pass.
-- Fixtures: tools/fixtures/json.py.
local T = require("@tests/T")
local Json = require("@formats/codecs/Json")
local Json = require("@formats/codecs/text/Json")
local Types = require("@formats/Types")
local Err = require("@formats/core/Err")
local Canon = require("@tests/data/Canon")
+2 -2
View File
@@ -1,9 +1,9 @@
-- codecs/Lzma tests: every fixture (liblzma through Python's lzma module and the xz CLI: presets 0-9 and -e, lc / lp /
-- codecs/compress/Lzma tests: every fixture (liblzma through Python's lzma module and the xz CLI: presets 0-9 and -e, lc / lp /
-- pb variants, raw LZMA1 / LZMA2, .lzma files, xz with every check type, BCJ and delta filters, multiple blocks,
-- multiple streams and stream padding) decodes to its corpus; consumed offsets; checksum / size / truncation errors;
-- maxBytes; the fuzz no-throw pass. Fixtures: tools/fixtures/lzma.py.
local T = require("@tests/T")
local Lzma = require("@formats/codecs/Lzma")
local Lzma = require("@formats/codecs/compress/Lzma")
local Err = require("@formats/core/Err")
local Fx = require("@tests/gen/lzma")
+2 -2
View File
@@ -1,8 +1,8 @@
-- codecs/Lzw tests: GIF (LSB) and TIFF (MSB, early change) code streams from Pillow / libtiff decode to their data;
-- codecs/compress/Lzw tests: GIF (LSB) and TIFF (MSB, early change) code streams from Pillow / libtiff decode to their data;
-- our encoder round-trips random and structured data at every GIF minimum code size and through table resets; the
-- output limit, truncated and corrupt streams; the fuzz no-throw pass. Fixtures: tools/fixtures/lzw.py.
local T = require("@tests/T")
local Lzw = require("@formats/codecs/Lzw")
local Lzw = require("@formats/codecs/compress/Lzw")
local Fx = require("@tests/gen/lzw")
local t = T.suite("lzw")
+43
View File
@@ -0,0 +1,43 @@
-- codecs/model/Mat4 tests: compose / decompose round trips (with a mirrored axis), strict decompose refusing shear,
-- quaternion <-> matrix, Euler orders, the affine inverse, row-major conversion, points, the normal matrix.
local T = require("@tests/T")
local Mat4 = require("@formats/codecs/model/Mat4")
local t = T.suite("mat4")
local function near(a: { number }, b: { number }, eps: number?): boolean
for i = 1, #b do
if math.abs(a[i] - b[i]) > (eps or 1e-9) then
return false
end
end
return true
end
local q = Mat4.axisAngle(1, 2, 3, 40)
local m = Mat4.compose({ 1, 2, 3 }, q, { 2, -3, 0.5 })
local tt, rr, ss = Mat4.decompose(m)
local back = Mat4.compose(tt, rr, ss)
t:check(near(back, m, 1e-9), "compose / decompose round trip (negative scale)")
t:check(near(Mat4.quat(Mat4.fromQuat(q)), q, 1e-12) or near(Mat4.quat(Mat4.fromQuat(q)), { -q[1], -q[2], -q[3], -q[4] }, 1e-12), "quat <-> matrix")
local shear = Mat4.identity()
shear[5] = 0.5
t:check(Mat4.decomposeStrict(shear) == nil, "strict decompose refuses shear")
t:check(Mat4.decompose(shear) ~= nil, "lenient decompose always answers")
local inv = Mat4.inverse(m) :: { number }
t:check(near(Mat4.mul(m, inv), Mat4.identity(), 1e-9), "inverse")
t:check(Mat4.inverse(Mat4.scaling(1, 0, 1)) == nil, "singular")
t:check(near(Mat4.fromRows(Mat4.toRows(m)), m), "rows round trip")
local x, y, z = Mat4.point(Mat4.translation(1, 2, 3), 1, 1, 1)
t:check(x == 2 and y == 3 and z == 4, "point")
-- Euler: "xyz" applies X first (R = Rz * Ry * Rx)
local e = Mat4.euler(10, 20, 30)
local manual = Mat4.mul(Mat4.rotation(3, 30), Mat4.mul(Mat4.rotation(2, 20), Mat4.rotation(1, 10)))
t:check(near(e, manual, 1e-12), "euler xyz")
local ex = Mat4.eulerXYZ(Mat4.quat(e))
t:check(near(ex, { 10, 20, 30 }, 1e-9), "eulerXYZ")
-- the normal matrix of a non-uniform scale is the inverse scale
t:check(near(Mat4.normalMatrix(Mat4.scaling(2, 4, 8)), Mat4.scaling(0.5, 0.25, 0.125)), "normal matrix")
local rot = Mat4.fromQuat(q)
t:check(near(Mat4.normalMatrix(rot), rot, 1e-12), "normal matrix of a rotation is the rotation")
t:done()
+2 -2
View File
@@ -1,8 +1,8 @@
-- codecs/Mdct tests: the FFT against a direct DFT for mixed-radix sizes, the forward / inverse MDCT and the DCT-IV
-- codecs/audio/Mdct tests: the FFT against a direct DFT for mixed-radix sizes, the forward / inverse MDCT and the DCT-IV
-- against their O(N^2) definitions (AAC, Vorbis and CELT sizes), perfect reconstruction (TDAC) with the sine, KBD and
-- Vorbis windows, window power complementarity, bad sizes. No fixtures (the definitions are the reference).
local T = require("@tests/T")
local Mdct = require("@formats/codecs/Mdct")
local Mdct = require("@formats/codecs/audio/Mdct")
local t = T.suite("mdct")
local rand = T.rng(7)
+3 -3
View File
@@ -1,4 +1,4 @@
-- codecs/Mpeg1 tests, ported from mpeg1-luau tests/decode.luau and tests/robust.luau. Against ffmpeg
-- codecs/video/Mpeg1 tests, ported from mpeg1-luau tests/decode.luau and tests/robust.luau. Against ffmpeg
-- (tools/fixtures/mpeg1.py): every stream decodes, one access unit at a time, to as many frames as ffmpeg's decode,
-- in display order; each frame's RGBA channel means within 1.5 of ffmpeg's; whole sampled frames within 2 MAE per
-- channel (IDCT and colour rounding) and, as yuv420p (frameImage), within a PSNR floor of ffmpeg -pix_fmt yuv420p;
@@ -7,9 +7,9 @@
-- B-frame reordering, string input, truncated units, bit flips and garbage (never throws, recovers at an
-- I-picture), an oversized sequence header; frameImage; the fuzz no-throw pass.
local T = require("@tests/T")
local Mpeg1 = require("@formats/codecs/Mpeg1")
local Mpeg1 = require("@formats/codecs/video/Mpeg1")
local Base64 = require("@formats/core/Base64")
local Deflate = require("@formats/codecs/Deflate")
local Deflate = require("@formats/codecs/compress/Deflate")
local Types = require("@formats/Types")
local STREAMS = {
+2 -2
View File
@@ -1,8 +1,8 @@
-- codecs/Quantize tests: palette size bounds for every method and colour budget, the exact (lossless) palette at
-- codecs/image/Quantize tests: palette size bounds for every method and colour budget, the exact (lossless) palette at
-- <= maxColors colours, transparency handling, PSNR of quantized images above thresholds, determinism of both
-- methods and of Floyd-Steinberg dithering (the same CRC on both runtimes), bad arguments, and a no-throw pass.
local T = require("@tests/T")
local Quantize = require("@formats/codecs/Quantize")
local Quantize = require("@formats/codecs/image/Quantize")
local Crc32 = require("@formats/core/Crc32")
local t = T.suite("quantize")
+2 -2
View File
@@ -1,9 +1,9 @@
-- codecs/Raster tests: exact coverage of axis-aligned rectangles at fractional positions; areas of circles; random
-- codecs/image/Raster tests: exact coverage of axis-aligned rectangles at fractional positions; areas of circles; random
-- polygons and curves under random transforms against an independent 12 x 12 supersampled winding-number reference
-- (both fill rules); clipping, the stroker (width, caps, joins against analytic areas), fill() compositing and paint
-- functions; malformed paths never throw. Glyph rendering against FreeType is in tests/font/ttf.luau.
local T = require("@tests/T")
local R = require("@formats/codecs/Raster")
local R = require("@formats/codecs/image/Raster")
local Types = require("@formats/Types")
local t = T.suite("raster")
+4 -4
View File
@@ -1,9 +1,9 @@
-- codecs/Resample tests: sines through common rate pairs (44100 <-> 48000, 8000 -> 48000, 48000 -> 22050, an inexact
-- codecs/audio/Resample tests: sines through common rate pairs (44100 <-> 48000, 8000 -> 48000, 48000 -> 22050, an inexact
-- ratio) against the analytic signal, alias rejection when downsampling, output lengths, streaming in odd chunks =
-- the whole-buffer result, multichannel, a Pcm source wrapper, bad arguments, and a no-throw pass over garbage.
local T = require("@tests/T")
local Resample = require("@formats/codecs/Resample")
local Pcm = require("@formats/codecs/Pcm")
local Resample = require("@formats/codecs/audio/Resample")
local Pcm = require("@formats/codecs/audio/Pcm")
local Types = require("@formats/Types")
local t = T.suite("resample")
@@ -92,7 +92,7 @@ do
t:check(snr(got, gf, ch, 48000, { 700, 1900 }, 500) > 80, "stereo accuracy")
end
-- 4. a codecs/Pcm source at a new rate
-- 4. a codecs/audio/Pcm source at a new rate
do
local a = Types.Audio.new(22050, 1, 5000)
a.samples = sine(5000, 1, 22050, { 500 })
+3 -3
View File
@@ -1,10 +1,10 @@
-- codecs/Url + codecs/Text tests: every example of RFC 3986 section 5.4 (normal and abnormal), dot-segment removal,
-- codecs/text/Url + codecs/text/Text tests: every example of RFC 3986 section 5.4 (normal and abnormal), dot-segment removal,
-- splitting, encoding and the location helpers (ported from playlist-luau tests/url.luau); random references against
-- Python's urllib.parse.urljoin; Url.locate / Url.base; Windows-1252 decoding against Python's cp1252 codec; lines,
-- BOM, trim; the fuzz pass. Fixtures: tools/fixtures/playlist.py.
local T = require("@tests/T")
local Url = require("@formats/codecs/Url")
local Text = require("@formats/codecs/Text")
local Url = require("@formats/codecs/text/Url")
local Text = require("@formats/codecs/text/Text")
local Ref = require("@tests/gen/playlist_url")
local Cp = require("@tests/gen/playlist_cp1252")
+2 -2
View File
@@ -1,9 +1,9 @@
-- codecs/Vp8 tests: the VP8 key frames of the WebP fixtures (cwebp at many settings and libvpx through ffmpeg, with
-- codecs/image/Vp8 tests: the VP8 key frames of the WebP fixtures (cwebp at many settings and libvpx through ffmpeg, with
-- 1..8 token partitions) decoded through the codec API: the yuv420p planes against dwebp -yuv, toRgba against
-- dwebp -pam (fancy upsampling) and -nofancy, the decoder object over successive frames, headers, error codes and the
-- fuzz no-throw pass on raw frames. Fixtures: tools/fixtures/webp.py.
local T = require("@tests/T")
local Vp8 = require("@formats/codecs/Vp8")
local Vp8 = require("@formats/codecs/image/Vp8")
local Crc32 = require("@formats/core/Crc32")
local Err = require("@formats/core/Err")
local Cases = require("@tests/gen/webp_cases")
+2 -2
View File
@@ -1,9 +1,9 @@
-- codecs/Vp8L tests: the VP8L bitstreams of the WebP fixtures (cwebp -z 0..9, -exact, near-lossless) decoded through
-- codecs/image/Vp8L tests: the VP8L bitstreams of the WebP fixtures (cwebp -z 0..9, -exact, near-lossless) decoded through
-- the codec API against dwebp, the encoder at every effort on generated images (gradients, noise, palettes of 1..300
-- colours, odd sizes, alpha), headerless alpha streams, error codes, and the fuzz no-throw pass on raw bitstreams.
-- Fixtures: tools/fixtures/webp.py.
local T = require("@tests/T")
local Vp8L = require("@formats/codecs/Vp8L")
local Vp8L = require("@formats/codecs/image/Vp8L")
local Crc32 = require("@formats/core/Crc32")
local Err = require("@formats/core/Err")
local Cases = require("@tests/gen/webp_cases")
+2 -2
View File
@@ -1,11 +1,11 @@
-- codecs/Vp8 video tests: whole IVF streams through one decoder object, every shown frame bit-exact against ffmpeg's
-- codecs/image/Vp8 video tests: whole IVF streams through one decoder object, every shown frame bit-exact against ffmpeg's
-- native vp8 decoder (yuv420p CRC32): the official VP8 test vectors (vp80-00-comprehensive-001..018 and others) and
-- libvpx clips at many settings (alt-ref / hidden frames, golden, token partitions, error resilience, profiles 1-3,
-- sharpness, segmentation, q extremes, short key frame intervals, motion off the frame, odd sizes). Also hidden
-- frames, reset() and inter frames without a key frame, and the fuzz no-throw pass over damaged streams.
-- Fixtures: tools/fixtures/vp8video.py.
local T = require("@tests/T")
local Vp8 = require("@formats/codecs/Vp8")
local Vp8 = require("@formats/codecs/image/Vp8")
local Crc32 = require("@formats/core/Crc32")
local Err = require("@formats/core/Err")
local Cases = require("@tests/gen/vp8video_cases")
+2 -2
View File
@@ -1,9 +1,9 @@
-- codecs/Xml tests: random documents (namespaces, escapes, CDATA, comments, PIs, DOCTYPE entities, UTF-16, Latin-1)
-- codecs/text/Xml tests: random documents (namespaces, escapes, CDATA, comments, PIs, DOCTYPE entities, UTF-16, Latin-1)
-- against Python's ElementTree trees; encode -> decode round trips; well-formedness verdicts against expat
-- (hand-written cases and random mutations); events, helpers, options, error codes; the fuzz pass.
-- Fixtures: tools/fixtures/xml.py.
local T = require("@tests/T")
local Xml = require("@formats/codecs/Xml")
local Xml = require("@formats/codecs/text/Xml")
local Types = require("@formats/Types")
local Err = require("@formats/core/Err")
local Docs = require("@tests/gen/xml_docs")
+2 -2
View File
@@ -1,9 +1,9 @@
-- codecs/Zstd tests: every fixture case (the zstd CLI at levels 1..19, --ultra -22, --fast, --long, small windows,
-- codecs/compress/Zstd tests: every fixture case (the zstd CLI at levels 1..19, --ultra -22, --fast, --long, small windows,
-- with / without checksum and content size, multi-frame and skippable frames, empty input) decodes to its corpus;
-- offsets / consumedEnd; XXH64 vectors; checksum, limit and error codes; truncated / corrupted / random input never
-- throws. Fixtures: tools/fixtures/zstd.py.
local T = require("@tests/T")
local Zstd = require("@formats/codecs/Zstd")
local Zstd = require("@formats/codecs/compress/Zstd")
local Err = require("@formats/core/Err")
local Fx = require("@tests/gen/zstd")
+76
View File
@@ -0,0 +1,76 @@
-- containers/Chunks tests: RIFF (padding, an odd chunk without its pad byte, open-ended data), IFF big-endian, PNG
-- (size first + CRC trailer, truncation), CAF 64-bit sizes, resize hooks, find, and a no-throw pass over garbage.
local T = require("@tests/T")
local Chunks = require("@formats/containers/Chunks")
local t = T.suite("chunks")
local function le32(n: number): string
return string.char(n % 256, (n // 256) % 256, (n // 65536) % 256, (n // 16777216) % 256)
end
local function be32(n: number): string
return string.char((n // 16777216) % 256, (n // 65536) % 256, (n // 256) % 256, n % 256)
end
-- RIFF: an odd chunk with its pad byte, then one without
do
local s = "abcd" .. le32(3) .. "xyz\0" .. "efgh" .. le32(1) .. "Q" .. "ijkl" .. le32(2) .. "12"
local list = Chunks.walk(buffer.fromstring(s), 0, #s, Chunks.RIFF)
t:eq(#list, 3, "riff: three chunks")
t:check(list[1].id == "abcd" and list[1].offset == 8 and list[1].size == 3, "riff: first")
t:check(list[2].id == "efgh" and list[2].size == 1, "riff: an odd chunk")
t:check(list[3].id == "ijkl" and list[3].offset == 29 and list[3].avail == 2, "riff: missing pad byte detected")
t:eq((Chunks.find(list, "efgh") :: any).start, 12, "find")
-- open-ended data with size 0, and a declared size past the end
local o = "fmt " .. le32(2) .. "ab" .. "data" .. le32(0) .. "123456"
local l2 = Chunks.walk(buffer.fromstring(o), 0, #o, { pad = 2, openEnded = { data = true } })
t:check(l2[2].streamed and l2[2].size == 6, "open-ended data")
local tr = "data" .. le32(100) .. "abc"
local l3 = Chunks.walk(buffer.fromstring(tr), 0, #tr, Chunks.RIFF)
t:check(l3[1].truncated and l3[1].avail == 3 and l3[1].size == 100, "truncated chunk keeps what is there")
local l4 = Chunks.walk(buffer.fromstring(o), 0, #o, { pad = 2, resize = function(id: string, n: number)
return if id == "fmt " then 1 else nil
end })
t:eq(l4[1].size, 1, "resize hook")
end
-- IFF (big-endian sizes)
do
local s = "COMM" .. be32(2) .. "ab" .. "SSND" .. be32(3) .. "xyz\0"
local list = Chunks.walk(buffer.fromstring(s), 0, #s, Chunks.IFF)
t:check(#list == 2 and list[2].id == "SSND" and list[2].size == 3, "iff")
end
-- PNG: size, type, data, CRC
do
local s = be32(2) .. "IHDR" .. "ab" .. "CRC!" .. be32(0) .. "IEND" .. "CRC?"
local list = Chunks.walk(buffer.fromstring(s), 0, #s, Chunks.PNG)
t:check(#list == 2 and list[1].id == "IHDR" and list[1].offset == 8 and list[2].id == "IEND" and list[2].start == 14, "png")
local cut = string.sub(s, 1, 12)
local l2 = Chunks.walk(buffer.fromstring(cut), 0, #cut, Chunks.PNG)
t:check(l2[1].truncated, "png: a missing CRC is a truncation")
end
-- CAF: 64-bit big-endian sizes
do
local s = "desc" .. be32(0) .. be32(4) .. "abcd" .. "data" .. be32(0) .. be32(2) .. "xy"
local list = Chunks.walk(buffer.fromstring(s), 0, #s, Chunks.CAF)
t:check(#list == 2 and list[2].offset == 28 and list[2].size == 2, "caf")
end
-- an offset range inside a bigger buffer
do
local s = "junk" .. "abcd" .. le32(1) .. "x\0" .. "tail"
local list = Chunks.walk(buffer.fromstring(s), 4, 14, Chunks.RIFF)
t:check(#list == 1 and list[1].offset == 12, "a sub-range")
end
local samples = { "abcd" .. le32(3) .. "xyz\0efgh" .. le32(1) .. "Q", be32(2) .. "IHDRabCRC!" }
t:fuzz("walk", function(b: buffer)
local n = 0
for _, layout in { Chunks.RIFF, Chunks.IFF, Chunks.PNG, Chunks.CAF } do
n += #Chunks.walk(b, 0, buffer.len(b), layout)
end
return n
end, samples)
t:done()
+2 -2
View File
@@ -1,9 +1,9 @@
-- core/Bits and core/Huffman tests: LSB / MSB readers and writers round-trip random fields of 1..32 bits, align /
-- core/Bits and codecs/entropy/Huffman tests: LSB / MSB readers and writers round-trip random fields of 1..32 bits, align /
-- peek / bytePos, overrun is a sticky error; canonical codes, length-limited code lengths, LSB and MSB decoding tables
-- (with subtables) decode what the writers wrote; invalid code sets are rejected.
local T = require("@tests/T")
local Bits = require("@formats/core/Bits")
local Huffman = require("@formats/core/Huffman")
local Huffman = require("@formats/codecs/entropy/Huffman")
local Err = require("@formats/core/Err")
local t = T.suite("bits")
+1 -1
View File
@@ -4,7 +4,7 @@
local T = require("@tests/T")
local F = require("@formats")
local XmlF = require("@formats/data/xml")
local Xml = require("@formats/codecs/Xml")
local Xml = require("@formats/codecs/text/Xml")
local Bytes = require("@formats/core/Bytes")
local Err = require("@formats/core/Err")
local Docs = require("@tests/gen/xml_docs")
+1 -1
View File
@@ -5,7 +5,7 @@
local T = require("@tests/T")
local F = require("@formats")
local Yaml = require("@formats/data/yaml")
local Json = require("@formats/codecs/Json")
local Json = require("@formats/codecs/text/Json")
local Types = require("@formats/Types")
local Bytes = require("@formats/core/Bytes")
local Err = require("@formats/core/Err")
+2 -2
View File
@@ -1,11 +1,11 @@
-- font/ttf tests (and codecs/TrueType, codecs/Cff): for the imgui-luau TrueType fonts, Source Sans 3 (CFF), a
-- font/ttf tests (and codecs/font/TrueType, codecs/font/Cff): for the imgui-luau TrueType fonts, Source Sans 3 (CFF), a
-- 'kern'-table font and a collection: metrics, names, cmap samples, advances / side bearings, outline control boxes and
-- areas against fontTools; kerning against HarfBuzz (GPOS) and FreeType ('kern'); rasterize() against FreeType's
-- unhinted renders (PSNR); the api; errors; the fuzz pass. Fixtures: tools/fixtures/fonts.py.
local T = require("@tests/T")
local F = require("@formats")
local Ttf = require("@formats/font/ttf")
local Raster = require("@formats/codecs/Raster")
local Raster = require("@formats/codecs/image/Raster")
local Bytes = require("@formats/core/Bytes")
local Err = require("@formats/core/Err")
local Fx = require("@tests/gen/fonts")
+2 -2
View File
@@ -1,10 +1,10 @@
-- music/it tests: generated Impulse Tracker modules (tools/fixtures/it.py) parsed, rendered through codecs/Tracker and
-- music/it tests: generated Impulse Tracker modules (tools/fixtures/it.py) parsed, rendered through codecs/audio/Tracker and
-- compared with openmpt123's render (loudness envelope, band spectrum, stereo balance, song length), the contract,
-- and the fuzz no-throw pass.
local T = require("@tests/T")
local S = require("@tests/music/_similar")
local It = require("@formats/music/it")
local Tracker = require("@formats/codecs/Tracker")
local Tracker = require("@formats/codecs/audio/Tracker")
local Bytes = require("@formats/core/Bytes")
local Cases = require("@tests/gen/it_cases")
+2 -2
View File
@@ -1,10 +1,10 @@
-- music/mod tests: generated ProTracker modules (tools/fixtures/mod.py) parsed, rendered through codecs/Tracker and
-- music/mod tests: generated ProTracker modules (tools/fixtures/mod.py) parsed, rendered through codecs/audio/Tracker and
-- compared with openmpt123's render (loudness envelope, band spectrum, stereo balance, song length), the MOD writer's
-- round trip, the contract, and the fuzz no-throw pass.
local T = require("@tests/T")
local S = require("@tests/music/_similar")
local Mod = require("@formats/music/mod")
local Tracker = require("@formats/codecs/Tracker")
local Tracker = require("@formats/codecs/audio/Tracker")
local Bytes = require("@formats/core/Bytes")
local Cases = require("@tests/gen/mod_cases")
+2 -2
View File
@@ -1,10 +1,10 @@
-- music/s3m tests: generated Scream Tracker 3 modules (tools/fixtures/s3m.py) parsed, rendered through codecs/Tracker and
-- music/s3m tests: generated Scream Tracker 3 modules (tools/fixtures/s3m.py) parsed, rendered through codecs/audio/Tracker and
-- compared with openmpt123's render (loudness envelope, band spectrum, stereo balance, song length), the contract,
-- and the fuzz no-throw pass.
local T = require("@tests/T")
local S = require("@tests/music/_similar")
local S3m = require("@formats/music/s3m")
local Tracker = require("@formats/codecs/Tracker")
local Tracker = require("@formats/codecs/audio/Tracker")
local Bytes = require("@formats/core/Bytes")
local Cases = require("@tests/gen/s3m_cases")
+2 -2
View File
@@ -1,11 +1,11 @@
-- music/sf2 + codecs/SoundFont tests: a self-made SF2 parsed (INFO, presets, sample headers, instruments, generator
-- music/sf2 + codecs/audio/SoundFont tests: a self-made SF2 parsed (INFO, presets, sample headers, instruments, generator
-- merging with preset / instrument global zones, 16-bit and sm24 samples), a test song rendered through it compared
-- with FluidSynth's render (loudness envelope and per-segment band spectra by correlation, pitch peaks), bad files,
-- the built-in fallback waveform set, and the fuzz no-throw pass. Fixtures: tools/fixtures/sf2.py.
local T = require("@tests/T")
local Sf2 = require("@formats/music/sf2")
local Midi = require("@formats/music/midi")
local SoundFont = require("@formats/codecs/SoundFont")
local SoundFont = require("@formats/codecs/audio/SoundFont")
local Bytes = require("@formats/core/Bytes")
local Err = require("@formats/core/Err")
local Fx = require("@tests/gen/sf2_cases")
+2 -2
View File
@@ -1,10 +1,10 @@
-- music/xm tests: generated FastTracker 2 modules (tools/fixtures/xm.py) parsed, rendered through codecs/Tracker and
-- music/xm tests: generated FastTracker 2 modules (tools/fixtures/xm.py) parsed, rendered through codecs/audio/Tracker and
-- compared with openmpt123's render (loudness envelope, band spectrum, stereo balance, song length), the XM writer's
-- round trip, the contract, and the fuzz no-throw pass.
local T = require("@tests/T")
local S = require("@tests/music/_similar")
local Xm = require("@formats/music/xm")
local Tracker = require("@formats/codecs/Tracker")
local Tracker = require("@formats/codecs/audio/Tracker")
local Bytes = require("@formats/core/Bytes")
local Cases = require("@tests/gen/xm_cases")
+2 -2
View File
@@ -1,10 +1,10 @@
-- ops/AudioOps tests: toAudio from a Decoder, gain / gainDb / normalize, peak / RMS of known signals, remix matrices
-- (5.1 -> stereo -> mono, mono -> stereo / 5.1), resample through codecs/Resample, trim, concat and mix with rate /
-- (5.1 -> stereo -> mono, mono -> stereo / 5.1), resample through codecs/audio/Resample, trim, concat and mix with rate /
-- channel conversion, fades, bad arguments (Err.ARG, never a throw), and the F.ops facade.
local T = require("@tests/T")
local AudioOps = require("@formats/ops/AudioOps")
local Types = require("@formats/Types")
local Pcm = require("@formats/codecs/Pcm")
local Pcm = require("@formats/codecs/audio/Pcm")
local Err = require("@formats/core/Err")
local F = require("@formats")
+2 -2
View File
@@ -1,9 +1,9 @@
-- ops/LayerOps + codecs/Blend tests: blend mode formulas on single pixels against hand-computed W3C values, opacity,
-- ops/LayerOps + codecs/image/Blend tests: blend mode formulas on single pixels against hand-computed W3C values, opacity,
-- masks, clipping, isolated vs pass-through groups, hidden layers, frames, leaves, bad arguments. (Whole-document
-- flattening against psd-tools is in tests/layered/psd.luau.)
local T = require("@tests/T")
local LayerOps = require("@formats/ops/LayerOps")
local Blend = require("@formats/codecs/Blend")
local Blend = require("@formats/codecs/image/Blend")
local Types = require("@formats/Types")
local Err = require("@formats/core/Err")
+1 -1
View File
@@ -4,7 +4,7 @@
local F = require("@formats")
local Bytes = require("@formats/core/Bytes")
local Crc32 = require("@formats/core/Crc32")
local Video = require("@formats/codecs/Video")
local Video = require("@formats/codecs/video/Video")
local C = {}