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

+2 -14
View File
@@ -1,8 +1,5 @@
-- audio/m4a tests: ALAC files from ffmpeg decode bit-exactly (16 / 24-bit, mono / stereo / 5.1, partial frames);
-- AAC-LC files from ffmpeg and fdkaac (stereo / mono / 5.1, 8 - 96 kHz, PNS / intensity / M/S / TNS) against ffmpeg's
-- float decode (SNR, gapless length through the edit list); HE-AAC / HE-AACv2 play their core; our ALAC writer
-- (re-encoded here, compared with the bytes ffmpeg decoded bit-exactly and MP4Box accepted in the fixture step); tags
-- and cover art round trips; streaming reads, seeking; the contract; the fuzz no-throw pass.
-- audio/m4a tests: ALAC from ffmpeg bit-exact; AAC from ffmpeg and fdkaac against ffmpeg's float decode (gapless).
-- our ALAC writer's bytes as ffmpeg decoded them bit-exactly and MP4Box accepted in the fixture step.
-- Fixtures: tools/fixtures/m4a.py.
local T = require("@tests/T")
local M4a = require("@rosetta/audio/m4a")
@@ -22,7 +19,6 @@ local function reader(s: string | buffer): Bytes.Reader
return Bytes.reader(if type(s) == "string" then buffer.fromstring(s) else s)
end
-- the integers of a decoded Audio (exact for <= 24-bit sources), CRC-32 as little-endian int32
local function intCrc(a: any, bits: number): number
local n = a.frames * a.channels
local b = buffer.create(n * 4)
@@ -49,12 +45,10 @@ local function snr(a: any, ref: string): (number, number)
return 10 * math.log10(sig / err), n
end
-- the contract
t:eq(M4a.name, "m4a", "name")
t:eq(M4a.category, "audio", "category")
t:check(M4a.caps.decode and M4a.caps.encode, "caps")
-- ALAC from ffmpeg: bit-exact
for _, c in Alac do
if c.container ~= "m4a" then
continue
@@ -70,7 +64,6 @@ for _, c in Alac do
end
t:note("%d ffmpeg ALAC files decode bit-exactly", #Alac - 1)
-- AAC: against ffmpeg's float decode
local worst = math.huge
for _, c in Aac do
if c.container ~= "m4a" then
@@ -102,7 +95,6 @@ for _, c in He do
t:check(n == 8192 and e > 1, c.name .. ": the core decodes (energy " .. e .. ")")
end
-- our ALAC writer: the bytes ffmpeg validated
do
local byName = {}
for _, o in Ours do
@@ -141,7 +133,6 @@ do
end
end
-- cover art + streaming a decoder into the encoder
do
local a = Signal.audio(44100, 5000, 2, 16, 9)
a.meta.pictures = { { mime = "image/png", data = buffer.fromstring("\137PNG fake") } }
@@ -164,7 +155,6 @@ for _, c in { Aac[1], Alac[1] } do
local whole = M4a.decode(reader(c.data)) :: any
local dec = M4a.open(reader(c.data)) :: any
t:eq(dec.frames, whole.frames, c.name .. ": decoder frames")
-- read in odd chunks
local got, out = 0, buffer.create(whole.frames * whole.channels * 4)
while true do
local b, n = dec:read(777)
@@ -188,7 +178,6 @@ for _, c in { Aac[1], Alac[1] } do
end
end
-- errors
do
local _, e = M4a.decode(reader("\0\0\0\8ftypM4A "))
t:check(e ~= nil, "a lone ftyp: " .. tostring(e))
@@ -197,7 +186,6 @@ do
t:eq(M4a.sniff(reader("hello")), 0, "sniff junk")
end
-- fuzz
do
local samples = {}
for i, c in Alac do