tests/audio: comments: specs only

This commit is contained in:
4DBug committed 2026-11-01 01:51:26 -05:00
1 parent 75ddfb4068
commit 0eec255bfb
30 files changed
+66 -244

No files matched your search

+4 -13
View File
@@ -1,8 +1,5 @@
-- audio/flac tests: every fixture from tools/fixtures/flac.py (flac 0-8, 4-32 bits, 1-6 channels, odd rates and block
-- sizes, LPC order 32, wasted bits, every stereo mode, ffmpeg's encoder, Ogg FLAC, ID3v2 in front) decoded bit-exact
-- against `flac -d`; sample-accurate seeking; f32 scaling and output reuse; decode() to an Audio from a sub-range
-- 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.
-- audio/flac tests: tools/fixtures/flac.py's files (flac 0-8, ffmpeg's encoder, Ogg FLAC) bit-exact against `flac -d`.
-- Fixtures: tools/fixtures/flac.py.
local T = require("@tests/T")
local VorbisComment = require("@rosetta/codecs/audio/VorbisComment")
local Flac = require("@rosetta/audio/flac")
@@ -23,7 +20,7 @@ for _, c in Cases do
end
t:eq(Flac.name, "flac", "name")
t:check(Flac.caps.decode and Flac.caps.encode, "caps") -- encode: ws-audio (tests/audio/flac_encode.luau)
t:check(Flac.caps.decode and Flac.caps.encode, "caps")
local seekChecks = 0
for _, fx in Cases do
@@ -53,7 +50,6 @@ for _, fx in Cases do
t:eq(n, fx.frames, name .. ": decoded frames")
t:eq(crc, fx.crc, name .. ": samples identical to flac -d")
t:eq(select(2, dec:position()), fx.frames, name .. ": position at end")
-- f32 scaling, output reuse
dec:seekSample(0)
local reuse = buffer.create(100 * ch * 4)
local f, gotf = dec:read(100, reuse)
@@ -66,7 +62,6 @@ for _, fx in Cases do
end
end
t:eq(bad, 0, name .. ": f32 samples")
-- seeking
local rand = T.rng(99)
local targets = { 0, 1, fx.frames - 1, fx.frames // 2, 4096, 4095, 4097, 1152, 1151 }
for _ = 1, 12 do
@@ -100,7 +95,6 @@ for _, fx in Cases do
end
t:note("%d fixtures bit-exact against flac -d, %d seeks", #Cases, seekChecks)
-- decode() from a sub-range Reader
for _, name in { "s16_l5", "ogg_s16", "id3", "s24_96k" } do
local fx = byName[name]
local big = buffer.create(#fx.data + 13)
@@ -113,7 +107,6 @@ for _, name in { "s16_l5", "ogg_s16", "id3", "s24_96k" } do
t:eq(a.meta.source.bitDepth, fx.bps, name .. ": meta.source")
end
-- tags and pictures
do
local dec = open(byName.s16_noseek.data)
t:check(#dec.pictures == 1 and dec.pictures[1].mime == "image/png" and dec.pictures[1].width == 1, "picture")
@@ -142,7 +135,6 @@ for _, name in { "s16_l5", "varblock", "bs17" } do
t:check(n == fx.frames and crc == fx.crc, name .. ": decode without total length")
end
-- sniff, errors, the api
do
t:eq(Flac.sniff(Bytes.reader(buffer.fromstring("ID3\4\0\0\0\0\0\2xxfLaC"))), 1, "sniff ID3 + fLaC")
t:eq(Flac.sniff(Bytes.reader(buffer.fromstring("ID3\4\0\0\0\0\0\2xx\255\251"))), 0, "sniff ID3 + mp3")
@@ -157,7 +149,7 @@ do
t:check(a and a.frames == fx.frames, "F.audio.load")
local d = F.audio.open(byName.s16_l3.data)
t:check(d and d.frames == byName.s16_l3.frames, "F.audio.open")
local saved, se = F.save(a, nil, { format = "flac" }) -- the encoder (ws-audio)
local saved, se = F.save(a, nil, { format = "flac" })
t:check(saved and F.audio.load(saved).frames == fx.frames, "F.save flac: " .. tostring(se))
end
@@ -178,7 +170,6 @@ do
t:check(total < d.frames and total >= d.frames - 2 * 4096, "one damaged frame dropped: " .. total)
end
-- fuzz
local samples = {}
for _, name in { "s16_l5", "ogg_s16", "id3", "varblock", "s32_rice2", "u8_mono", "bits4" } do
table.insert(samples, byName[name].data)