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:
1 parent
9c553b9d1a
commit
434a304315
283 files changed
+1877
-1660
No files matched your search
+21
-21
@@ -3,7 +3,7 @@
|
||||
-- tools/fixtures/opus.py (3 s stereo files; MB/s of f32 output, 48 kHz stereo f32 is 0.384 MB/s of real time),
|
||||
-- tools/fixtures/flac.py; wav encodes / decodes a generated tone; zstd / brotli / bzip2 / lzma (*_bench corpora), fonts
|
||||
-- (glyphs per second), json / xml / yaml, jpeg / gif / tiff / qoi / tga / pnm / hdr and ImageOps.
|
||||
local Deflate = require("@formats/codecs/Deflate")
|
||||
local Deflate = require("@formats/codecs/compress/Deflate")
|
||||
local Crc32 = require("@formats/core/Crc32")
|
||||
local Bytes = require("@formats/core/Bytes")
|
||||
local Png = require("@formats/image/png")
|
||||
@@ -189,7 +189,7 @@ do
|
||||
print(string.format("%-8s %-30s %8.1fx real time", runtime, "", 10 / dt))
|
||||
end
|
||||
do
|
||||
local Json = require("@formats/codecs/Json")
|
||||
local Json = require("@formats/codecs/text/Json")
|
||||
local JB = require("@tests/gen/json_bench")
|
||||
local v = assert(Json.decode(JB.text))
|
||||
assert(Json.encode(v) == JB.compact, "json bench mismatch")
|
||||
@@ -204,7 +204,7 @@ do
|
||||
end)
|
||||
end
|
||||
do
|
||||
local Xml = require("@formats/codecs/Xml")
|
||||
local Xml = require("@formats/codecs/text/Xml")
|
||||
local XB = require("@tests/gen/xml_bench")
|
||||
local doc = assert(Xml.decode(XB.text))
|
||||
bench("xml decode (DOM)", 5, #XB.text, function()
|
||||
@@ -221,7 +221,7 @@ end
|
||||
|
||||
-- ws-arch codecs: zstd, brotli, bzip2, xz / lzma
|
||||
do
|
||||
local Zstd = require("@formats/codecs/Zstd")
|
||||
local Zstd = require("@formats/codecs/compress/Zstd")
|
||||
local ZB = require("@tests/gen/zstd_bench")
|
||||
local z3, z19 = buffer.fromstring(ZB.data3), buffer.fromstring(ZB.data19)
|
||||
local zo = assert(Zstd.decompress(z3))
|
||||
@@ -237,7 +237,7 @@ do
|
||||
end)
|
||||
end
|
||||
do
|
||||
local Brotli = require("@formats/codecs/Brotli")
|
||||
local Brotli = require("@formats/codecs/compress/Brotli")
|
||||
local BB = require("@tests/gen/brotli_bench")
|
||||
local bz = buffer.fromstring(BB.data)
|
||||
local bout = assert(Brotli.decompress(bz))
|
||||
@@ -247,7 +247,7 @@ do
|
||||
end)
|
||||
end
|
||||
do
|
||||
local Bzip2 = require("@formats/codecs/Bzip2")
|
||||
local Bzip2 = require("@formats/codecs/compress/Bzip2")
|
||||
local BZ = require("@tests/gen/bzip2_bench")
|
||||
local bz = buffer.fromstring(BZ.data)
|
||||
bench("bzip2 decompress -9", 3, BZ.size, function()
|
||||
@@ -255,7 +255,7 @@ do
|
||||
end)
|
||||
end
|
||||
do
|
||||
local Lzma = require("@formats/codecs/Lzma")
|
||||
local Lzma = require("@formats/codecs/compress/Lzma")
|
||||
local LB = require("@tests/gen/lzma_bench")
|
||||
local lx, la = buffer.fromstring(LB.xz), buffer.fromstring(LB.alone)
|
||||
local lo = assert(Lzma.xz(lx))
|
||||
@@ -332,7 +332,7 @@ end
|
||||
-- ---------------------------------------------------------------------------------------- ws-imgA: gif + quantize
|
||||
do
|
||||
local Gif = require("@formats/image/gif")
|
||||
local Quantize = require("@formats/codecs/Quantize")
|
||||
local Quantize = require("@formats/codecs/image/Quantize")
|
||||
local Types = require("@formats/Types")
|
||||
local GB = require("@tests/gen/gif_bench")
|
||||
local still = buffer.fromstring(GB.still)
|
||||
@@ -544,8 +544,8 @@ do
|
||||
end)
|
||||
end
|
||||
do
|
||||
-- layered + vector (ws-vec): PSD decode / encode of 8 RGBA layers 1024 x 768, flatten (codecs/Blend), SVG
|
||||
-- rasterize at 512 x 512 (codecs/Raster). No fixtures: the inputs are built here.
|
||||
-- layered + vector (ws-vec): PSD decode / encode of 8 RGBA layers 1024 x 768, flatten (codecs/image/Blend), SVG
|
||||
-- rasterize at 512 x 512 (codecs/image/Raster). No fixtures: the inputs are built here.
|
||||
local Types = require("@formats/Types")
|
||||
local Psd = require("@formats/layered/psd")
|
||||
local LayerOps = require("@formats/ops/LayerOps")
|
||||
@@ -608,7 +608,7 @@ do
|
||||
end)
|
||||
end
|
||||
do
|
||||
local Xml = require("@formats/codecs/Xml")
|
||||
local Xml = require("@formats/codecs/text/Xml")
|
||||
local XB = require("@tests/gen/xml_bench")
|
||||
local doc = assert(Xml.decode(XB.text))
|
||||
bench("xml decode (DOM)", 5, #XB.text, function()
|
||||
@@ -626,8 +626,8 @@ end
|
||||
-- ws-m4a: AAC-LC / ALAC decode and ALAC encode (MB/s of 16-bit PCM equivalent: frames * channels * 2), MDCT
|
||||
do
|
||||
local M4a = require("@formats/audio/m4a")
|
||||
local Alac = require("@formats/codecs/Alac")
|
||||
local Mdct = require("@formats/codecs/Mdct")
|
||||
local Alac = require("@formats/codecs/audio/Alac")
|
||||
local Mdct = require("@formats/codecs/audio/Mdct")
|
||||
local MA = require("@tests/gen/m4a_aac")
|
||||
local ML = require("@tests/gen/m4a_alac")
|
||||
local aac = buffer.fromstring(MA[1].data)
|
||||
@@ -709,7 +709,7 @@ do
|
||||
end
|
||||
-- the synth's per-voice cost: 32 sustained, filtered, looped voices (sf2 saw preset with a mod env) for 2 s
|
||||
do
|
||||
local SoundFont = require("@formats/codecs/SoundFont")
|
||||
local SoundFont = require("@formats/codecs/audio/SoundFont")
|
||||
local Sf2 = require("@formats/music/sf2")
|
||||
local SF = require("@tests/gen/sf2_cases")
|
||||
local sf = assert(Sf2.decode(Bytes.reader(buffer.fromstring(SF.sf2))))
|
||||
@@ -734,7 +734,7 @@ end
|
||||
-- the tracker engine: 32 channels of looped samples (one note each, linear interpolation, volume ramps), and an
|
||||
-- IT-style module with background voices (NNA continue) and resonant filters on every channel
|
||||
do
|
||||
local Tracker = require("@formats/codecs/Tracker")
|
||||
local Tracker = require("@formats/codecs/audio/Tracker")
|
||||
local function song(format: string, filter: boolean): any
|
||||
local m = Tracker.newModule(format, 32)
|
||||
m.order = { 0 }
|
||||
@@ -913,8 +913,8 @@ do
|
||||
end
|
||||
-- ------------------------------------------------------------------------------------------- ws-video-codecs: fps
|
||||
do
|
||||
local Jpeg = require("@formats/codecs/Jpeg")
|
||||
local Mpeg1 = require("@formats/codecs/Mpeg1")
|
||||
local Jpeg = require("@formats/codecs/image/Jpeg")
|
||||
local Mpeg1 = require("@formats/codecs/video/Mpeg1")
|
||||
local Base64 = require("@formats/core/Base64")
|
||||
local Types = require("@formats/Types")
|
||||
local MB = require("@tests/gen/mjpeg_bench")
|
||||
@@ -1023,10 +1023,10 @@ do
|
||||
end
|
||||
-- ------------------------------------------------------------------------------------------- ws-video-vp8: fps
|
||||
do
|
||||
-- VP8 video (codecs/Vp8, tools/fixtures/vp8video.py): whole IVF streams (libvpx, panning testsrc2) through one
|
||||
-- VP8 video (codecs/image/Vp8, tools/fixtures/vp8video.py): whole IVF streams (libvpx, panning testsrc2) through one
|
||||
-- decoder object; frames per second. On LuaJIT the library's host module raises the trace limits (maxtrace=8000,
|
||||
-- see src/Formats/host/init.luau): the second pair of lines runs with them, as the api does.
|
||||
local Vp8 = require("@formats/codecs/Vp8")
|
||||
local Vp8 = require("@formats/codecs/image/Vp8")
|
||||
local VB = require("@tests/gen/vp8video_bench")
|
||||
local function run(tag: string)
|
||||
for _, c in VB do
|
||||
@@ -1056,10 +1056,10 @@ do
|
||||
end
|
||||
end
|
||||
do
|
||||
-- H.264 (codecs/H264): whole Annex B streams, frames per second (decode + the cropped yuv420p output copies). The
|
||||
-- H.264 (codecs/video/H264): whole Annex B streams, frames per second (decode + the cropped yuv420p output copies). The
|
||||
-- testsrc2 clips are easy (mostly static); the mandelbrot zooms move everywhere. LuaJIT runs twice: with its default
|
||||
-- trace limits and with the ones host/init.luau sets (maxtrace=8000, maxmcode=65536).
|
||||
local H264 = require("@formats/codecs/H264")
|
||||
local H264 = require("@formats/codecs/video/H264")
|
||||
local HB = require("@tests/gen/h264_bench")
|
||||
local function run(tag: string)
|
||||
for _, c in HB do
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
# Brotli static data generator (python3 -I tools/brotli_static.py [brotli-source-dir]): writes
|
||||
# src/Formats/codecs/Brotli/Static.luau from the official brotli C sources (MIT; licenses/brotli-LICENSE.txt):
|
||||
# src/Formats/codecs/compress/Brotli/Static.luau from the official brotli C sources (MIT; licenses/brotli-LICENSE.txt):
|
||||
# the 122784-byte RFC 7932 static dictionary (c/common/dictionary_inc.h, stored deflated + base64), the context
|
||||
# lookup table (c/common/context.c) and the 121 word transforms (c/common/transform.c).
|
||||
# Without an argument the source comes from `nix build nixpkgs#brotli.src`.
|
||||
@@ -51,7 +51,7 @@ def main():
|
||||
z = zlib.compress(dictionary, 9)
|
||||
lines = [
|
||||
"--!strict",
|
||||
"-- codecs/Brotli/Static: GENERATED by tools/brotli_static.py from the brotli C sources (MIT, Google; see",
|
||||
"-- codecs/compress/Brotli/Static: GENERATED by tools/brotli_static.py from the brotli C sources (MIT, Google; see",
|
||||
"-- licenses/brotli-LICENSE.txt) - do not edit. The RFC 7932 static dictionary (122784 bytes, deflated, base64),",
|
||||
"-- the context lookup table (Appendix B, 4 modes x 512) and the 121 word transforms (Appendix B).",
|
||||
"return {",
|
||||
|
||||
@@ -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,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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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=()):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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=()):
|
||||
|
||||
@@ -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"]
|
||||
|
||||
|
||||
|
||||
@@ -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"]
|
||||
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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,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? } }
|
||||
|
||||
@@ -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"]
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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,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
|
||||
|
||||
@@ -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 "]
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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=()):
|
||||
|
||||
@@ -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,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.
|
||||
|
||||
+17
-12
@@ -134,19 +134,24 @@ def formats_md(formats):
|
||||
c["folder_category"], lua_strings(c["name"])[0], " ".join("." + e for e in lua_strings(c["extensions"])),
|
||||
"yes" if cd.get("decode") == "true" else "-", "yes" if cd.get("encode") == "true" else "-",
|
||||
other or "", "`%s`" % test if has else "**missing**"))
|
||||
lines += ["", "Codecs (layer 1, shared by formats; not loadable on their own):", ""]
|
||||
lines += ["", "Codecs (layer 3, shared by formats; not loadable on their own), by domain:", ""]
|
||||
cdir = os.path.join(SRC, "codecs")
|
||||
for name in sorted(os.listdir(cdir)) if os.path.isdir(cdir) else []:
|
||||
p = os.path.join(cdir, name)
|
||||
init = os.path.join(p, "init.luau") if os.path.isdir(p) else p
|
||||
if os.path.isfile(init):
|
||||
first = ""
|
||||
with open(init) as f:
|
||||
for line in f:
|
||||
if line.startswith("-- codecs/"):
|
||||
first = line[3:].strip()
|
||||
break
|
||||
lines.append("- %s" % (first or name))
|
||||
for domain in sorted(os.listdir(cdir)) if os.path.isdir(cdir) else []:
|
||||
ddir = os.path.join(cdir, domain)
|
||||
if not os.path.isdir(ddir):
|
||||
continue
|
||||
lines.append("- **%s**" % domain)
|
||||
for name in sorted(os.listdir(ddir)):
|
||||
p = os.path.join(ddir, name)
|
||||
init = os.path.join(p, "init.luau") if os.path.isdir(p) else p
|
||||
if os.path.isfile(init) and init.endswith(".luau"):
|
||||
first = ""
|
||||
with open(init) as f:
|
||||
for line in f:
|
||||
if line.startswith("-- codecs/"):
|
||||
first = line[3:].strip()
|
||||
break
|
||||
lines.append(" - %s" % (first or name))
|
||||
lines.append("")
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
# LAYERS requires go downward: core < Types < host; core, Types < codecs < containers < formats (<category>/<fmt>)
|
||||
# < ops < api (init, Registry). core / codecs / containers / ops may require their own layer; a format
|
||||
# may require its own folder but never another format; only the api requires host.
|
||||
# codecs live in a domain folder: codecs/<domain>/<Name> (CODEC_DOMAINS).
|
||||
# DEPS a format folder's requires outside itself are exactly the contract's deps = { ... }.
|
||||
# CONTRACT a format's init.luau has the one-line fields name (= folder name), category (= folder category),
|
||||
# extensions, mime, deps, caps (with decode / encode matching the functions), function <X>.sniff, at least
|
||||
@@ -199,6 +200,13 @@ for f in files:
|
||||
if tgroup not in ALLOWED[group]:
|
||||
bad(f, i, "LAYERS: %s (%s) may not require %s (%s)" % (mod or "Formats", group, target, tgroup))
|
||||
|
||||
CODEC_DOMAINS = {"compress", "entropy", "image", "audio", "video", "text", "font", "model"}
|
||||
for f in files:
|
||||
mod = mods[f]
|
||||
parts = mod.split("/")
|
||||
if parts[0] == "codecs" and (len(parts) < 3 or parts[1] not in CODEC_DOMAINS):
|
||||
bad(f, 1, "LAYERS: codecs go in a domain folder codecs/<%s>/<Name> (%s)" % ("|".join(sorted(CODEC_DOMAINS)), mod))
|
||||
|
||||
# ---------------------------------------------------------------------------------------------------- DEPS + CONTRACT
|
||||
FIELD = re.compile(r"^\t(name|category|extensions|mime|deps|caps) = (.*),\s*(--.*)?$")
|
||||
folders = sorted({format_folder(m) for m in mods.values() if format_folder(m)})
|
||||
|
||||
@@ -1 +1 @@
|
||||
94
|
||||
93
|
||||
Reference in new issue
Block a user