ws-audio: FLAC encoder (audio/flac/Encode: levels 0-8 like libFLAC presets, fixed + LPC + Rice/Rice2 partition search, wasted bits, stereo decorrelation, MD5, VORBIS_COMMENT, SEEKTABLE, padding; streams from a Decoder) wired into audio/flac encode; core/Md5 (new core module, RFC 1321) + test; fixtures: flac -t + MD5 bit-exact on 76 encodes, sizes within 1.1% of libFLAC; bench lines
This commit is contained in:
1 parent
bdab71df77
commit
c74c93ae11
10 files changed
+1553
-6
No files matched your search
@@ -272,3 +272,45 @@ def pcm_fixtures(ctx, fmt, made, encodes, sig_rate=22050, sig_frames=3000):
|
||||
"maxDiff": max_diff(sig, dec) if dch == ch else 99.0, "ffmpegErrors": errs.decode(errors="replace"),
|
||||
"bytes": len(out), "sameStreamed": out == streamed, "data": out})
|
||||
ctx.emit(fmt + "_enc", results)
|
||||
|
||||
|
||||
def encode_luau_many(ctx, module, jobs, sigmod):
|
||||
"""jobs = [(signal name, opts_lua)] over the emitted module sigmod = { [name] = { rate, channels, frames, data } }
|
||||
-> [bytes]: one Luau run encodes them all (length-prefixed on stdout)"""
|
||||
body = ['job("%s", %s)' % (name, opts) for name, opts in jobs]
|
||||
code = """
|
||||
local Types = require("@formats/Types")
|
||||
local M = require("@formats/%s")
|
||||
local S = require("@tests/gen/%s")
|
||||
local outs = {}
|
||||
local function job(name, opts)
|
||||
local s = S[name]
|
||||
local a = Types.Audio.new(s.rate, s.channels, s.frames)
|
||||
buffer.writestring(a.samples, 0, s.data)
|
||||
local out, err = M.encode(a, opts)
|
||||
if not out then error("encode failed: " .. tostring(err)) end
|
||||
local n = buffer.len(out)
|
||||
table.insert(outs, string.format("%%012d", n) .. buffer.tostring(out))
|
||||
end
|
||||
%s
|
||||
print(table.concat(outs))
|
||||
""" % (module, sigmod, "\n".join(body))
|
||||
raw = luau(ctx, code)
|
||||
res, p = [], 0
|
||||
while p < len(raw):
|
||||
n = int(raw[p:p + 12])
|
||||
res.append(raw[p + 12:p + 12 + n])
|
||||
p += 12 + n
|
||||
return res
|
||||
|
||||
|
||||
def shell_many(ctx, packages, files, script):
|
||||
"""write files {name: bytes} into a temp dir and run `sh -c script` there under nix; returns stdout"""
|
||||
d = tempfile.mkdtemp(prefix="fmt-audio-")
|
||||
try:
|
||||
for name, data in files.items():
|
||||
with open(os.path.join(d, name), "wb") as f:
|
||||
f.write(data)
|
||||
return ctx.nix(packages, ["sh", "-c", "cd '%s' && %s" % (d, script)])
|
||||
finally:
|
||||
shutil.rmtree(d, ignore_errors=True)
|
||||
Reference in new issue
Block a user