ws-audio2: audio/brstm variant() names bcstm / bfstm for F.detect
This commit is contained in:
1 parent
5e64334e85
commit
3f6823cbe5
2 files changed
+9
-1
No files matched your search
@@ -44,6 +44,12 @@ function Brstm.sniff(r: Bytes.Reader): number
|
||||
return if bom == "\254\255" or bom == "\255\254" then 1 else 0
|
||||
end
|
||||
|
||||
-- variant(r) -> "brstm" / "bcstm" / "bfstm": the flavour, for F.detect
|
||||
function Brstm.variant(r: Bytes.Reader): string?
|
||||
local m = r:peek(4)
|
||||
return if m == "RSTM" then "brstm" elseif m == "CSTM" then "bcstm" elseif m == "FSTM" then "bfstm" else nil
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ decode
|
||||
function Brstm.decode(r: Bytes.Reader, opts: DecodeOptions?): (Types.Audio?, Err.Err?)
|
||||
local dec, err = Brstm.open(r)
|
||||
|
||||
@@ -17,7 +17,9 @@ 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")
|
||||
local flavour = ({ RSTM = "brstm", CSTM = "bcstm", FSTM = "bfstm" })[string.sub(c.data, 1, 4)]
|
||||
t:eq(F.detect(c.data), flavour, c.name .. ": F.detect names the flavour")
|
||||
t:check(F.format(flavour) ~= nil or F.format("brstm") ~= nil, c.name .. ": the flavour resolves")
|
||||
end
|
||||
t:note("%d files bit-exact with vgmstream", #Cases)
|
||||
|
||||
|
||||
Reference in new issue
Block a user