32 lines
1.1 KiB
Luau
32 lines
1.1 KiB
Luau
-- tools/fixtures/_m4a_encode: run by tools/fixtures/m4a.py (luau, from the repo root) so the reference tools can check
|
|
-- our writers: encodes the test signal (tests/audio/_signal) to ALAC M4A (audio/m4a) and ALAC / PCM CAF (audio/caf)
|
|
-- and prints "<name> <hex>" lines. The tests re-encode and compare the CRC with the file ffmpeg validated.
|
|
local Signal = require("@tests/audio/_signal")
|
|
local M4a = require("@formats/audio/m4a")
|
|
local Caf = require("@formats/audio/caf")
|
|
|
|
local function hex(b: buffer): string
|
|
local t = table.create(buffer.len(b))
|
|
for i = 0, buffer.len(b) - 1 do
|
|
t[i + 1] = string.format("%02x", buffer.readu8(b, i))
|
|
end
|
|
return table.concat(t)
|
|
end
|
|
|
|
local Cases = require("@tests/audio/_encode_cases")
|
|
for _, c in Cases do
|
|
local a = Signal.audio(c.rate, c.frames, c.channels, c.bits, c.seed)
|
|
a.tags = c.tags or {}
|
|
local out, err
|
|
if c.container == "caf" then
|
|
out, err = Caf.encode(a, { codec = c.codec, bitDepth = c.bits })
|
|
else
|
|
out, err = M4a.encode(a, { bitDepth = c.bits })
|
|
end
|
|
if not out then
|
|
print(c.name .. " ERROR " .. tostring(err))
|
|
else
|
|
print(c.name .. " " .. hex(out))
|
|
end
|
|
end
|