ws-audio2: audio/brstm (BRSTM / BCSTM / BFSTM read: DSP ADPCM, PCM16, PCM8, loops)
Bit-exact with vgmstream; forward seeks start from the ADPC / SEEK history. codecs/audio/Adpcm/Decoder.interleaved also lays out block-interleaved PCM (s16be / s16le / s8); snapshots take precedence over a format's history table.
This commit is contained in:
1 parent
fd9175883d
commit
5dfaaf7524
6 files changed
+454
-18
No files matched your search
@@ -0,0 +1,52 @@
|
||||
-- audio/brstm tests: BRSTM / BCSTM / BFSTM files (DSP ADPCM, PCM16, PCM8; big- and little-endian; loops) from our
|
||||
-- Python writer, bit-exact with vgmstream (tools/fixtures/brstm.py) through decode and open with seeks (forward seeks
|
||||
-- start from the ADPC / SEEK history table); errors; the api; the fuzz pass.
|
||||
local T = require("@tests/T")
|
||||
local Brstm = require("@formats/audio/brstm")
|
||||
local Bytes = require("@formats/core/Bytes")
|
||||
local Err = require("@formats/core/Err")
|
||||
local F = require("@formats")
|
||||
local H = require("@tests/audio/_adpcm")
|
||||
local Cases = require("@tests/gen/brstm_cases")
|
||||
|
||||
local t = T.suite("brstm")
|
||||
t:eq(Brstm.name, "brstm", "name")
|
||||
|
||||
local samples = {}
|
||||
for _, c in Cases do
|
||||
table.insert(samples, c.data)
|
||||
t:eq(Brstm.sniff(Bytes.reader(buffer.fromstring(c.data))), 1, c.name .. ": sniff")
|
||||
H.check(t, Brstm, c)
|
||||
t:eq(F.detect(c.data), "brstm", c.name .. ": F.detect")
|
||||
end
|
||||
t:note("%d files bit-exact with vgmstream", #Cases)
|
||||
|
||||
do
|
||||
local base = Cases[1].data
|
||||
local function fails(b: buffer, code: string, label: string)
|
||||
local d, e = Brstm.open(Bytes.reader(b))
|
||||
t:check(d == nil and e and e.code == code, label .. ": " .. tostring(e))
|
||||
end
|
||||
local beta = buffer.fromstring(base)
|
||||
buffer.writeu16(beta, 6, 0x0100) -- bytes 01 00 read big-endian: version 0.1
|
||||
fails(beta, Err.UNSUPPORTED, "version 0.1")
|
||||
fails(buffer.fromstring(string.sub(base, 1, 0x30)), Err.TRUNCATED, "short")
|
||||
fails(buffer.fromstring("RSTM\254\255\1\0" .. string.rep("\0", 100)), Err.CORRUPT, "no HEAD")
|
||||
local a = F.audio.load(Cases[2].data)
|
||||
t:check(a and a.meta.source.loop and a.meta.source.loop.start == Cases[2].loopStart, "F.audio.load keeps the loop")
|
||||
end
|
||||
|
||||
t:fuzz("open + read + seek", function(b: buffer)
|
||||
local dec = Brstm.open(Bytes.reader(b))
|
||||
if dec then
|
||||
dec:read(100000)
|
||||
dec:seek(dec.duration / 2)
|
||||
dec:read(33)
|
||||
end
|
||||
return dec
|
||||
end, samples, { mutations = 8 })
|
||||
t:fuzz("header", function(b: buffer)
|
||||
return Brstm.decode(Bytes.reader(b))
|
||||
end, samples, { mutations = 12, keepHeader = 0, garbage = 50 })
|
||||
|
||||
t:done()
|
||||
Reference in new issue
Block a user