Files
4DBug 51b08575c4 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.
2026-10-31 12:25:03 -05:00

67 lines
3.5 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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
# xml.etree.ElementTree) with the entries they hold: { url, title?, duration? }
import random, urllib.parse, xml.etree.ElementTree as ET
BASES = ["http://a/b/c/d;p?q", "https://host.example/lists/m.m3u8", "http://h/x/", "https://cdn.example/a/b/c/list.pls",
"http://a"]
SEGS = ["g", "h", "..", ".", "music", "a b", "x.mp3", "s;p", "%41", "ü"]
def ref(rng):
parts = [rng.choice(SEGS) for _ in range(rng.randrange(1, 5))]
r = "/".join(parts)
k = rng.randrange(6)
if k == 0:
r = "/" + r
elif k == 1:
r = "./" + r
if rng.random() < 0.2:
r += "?y=" + rng.choice(SEGS)
if rng.random() < 0.15:
r += "#" + rng.choice(["s", "f/../x"])
return r
def generate(ctx):
rng = random.Random(8)
cases = []
for _ in range(400):
base = rng.choice(BASES)
r = ref(rng)
if " " in r or "ü" in r or (base == "http://a" and r.startswith(".")):
continue # raw spaces / UTF-8 are encoded first by the playlist code; urljoin keeps a leading "." here
cases.append([r, base, urllib.parse.urljoin(base, r)])
ctx.emit("playlist_url", cases)
ctx.emit("playlist_cp1252", [[b, bytes([b]).decode("cp1252", errors="replace")] for b in range(0x80, 0x100)])
out = []
for n in range(12):
ents = []
for i in range(rng.randrange(1, 9)):
e = {"url": "http://media.example/%d/track%d.mp3" % (n, i)}
if rng.random() < 0.8:
e["title"] = rng.choice(["Song %d" % i, "Björk – Jóga", "A, B & C", "x <y> \"z\""])
if rng.random() < 0.7:
e["duration"] = rng.randrange(1, 600)
ents.append(e)
m3u = "#EXTM3U\n" + "".join(("#EXTINF:%d,%s\n" % (e.get("duration", -1), e.get("title", "")) if ("title" in e or "duration" in e) else "") + e["url"] + "\n" for e in ents)
pls = "[playlist]\n" + "".join("File%d=%s\n" % (i + 1, e["url"]) + ("Title%d=%s\n" % (i + 1, e["title"]) if "title" in e else "") + ("Length%d=%d\n" % (i + 1, e.get("duration", -1))) for i, e in enumerate(ents)) + "NumberOfEntries=%d\nVersion=2\n" % len(ents)
root = ET.Element("playlist", {"version": "1", "xmlns": "http://xspf.org/ns/0/"})
ET.SubElement(root, "title").text = "List %d" % n
tl = ET.SubElement(root, "trackList")
for e in ents:
t = ET.SubElement(tl, "track")
ET.SubElement(t, "location").text = e["url"]
if "title" in e:
ET.SubElement(t, "title").text = e["title"]
if "duration" in e:
ET.SubElement(t, "duration").text = str(e["duration"] * 1000)
xspf = ET.tostring(root, encoding="UTF-8", xml_declaration=True)
expect = [{k: v for k, v in e.items()} for e in ents]
# M3U loses a title when there is no EXTINF text; PLS keeps only what it wrote
out.append({"name": "list%d" % n, "m3u": m3u, "pls": pls, "xspf": xspf, "title": "List %d" % n, "entries": expect})
ctx.emit("playlist_cases", out)