audio perf: compat math.sign branch-free (WavPack on LuaJIT 1.7-2x), Opus MDCT running indices, SILK FIR12 rows, Vorbis residue / window / overlap-add loops without per-sample branches
This commit is contained in:
1 parent
051aca5b74
commit
59c2438ca1
5 files changed
+165
-122
No files matched your search
+4
-2
@@ -462,9 +462,11 @@ do
|
||||
if x ~= x then return x end
|
||||
return mmin(mmax(x, lo), hi)
|
||||
end
|
||||
-- branch-free for the same reason (a data-dependent sign spawned side traces: WavPack's decorrelation 2x slower);
|
||||
-- x * 1e300 * 1e300 is +-inf or beyond +-1 for every non-zero x, 0 for 0; + 0 turns -0 into 0
|
||||
math.sign = math.sign or function(x)
|
||||
if x > 0 then return 1 elseif x < 0 then return -1 end
|
||||
return 0
|
||||
if x ~= x then return 0 end
|
||||
return mmin(mmax(x * 1e300 * 1e300, -1), 1) + 0
|
||||
end
|
||||
-- Luau rounds half away from zero
|
||||
math.round = math.round or function(x)
|
||||
|
||||
@@ -50,6 +50,9 @@ for shift = 0, 3 do
|
||||
local factors = FACTORS[shift]
|
||||
local bitrev = table.create(n, 0)
|
||||
bitrevTable(bitrev, 0, 0, 1, factors, 1)
|
||||
for i = 1, n do
|
||||
bitrev[i] += 1 -- 1-based targets
|
||||
end
|
||||
local twr, twi = table.create(n, 0), table.create(n, 0)
|
||||
for k = 0, n - 1 do
|
||||
local ph = -2 * pi * k / n
|
||||
@@ -132,6 +135,7 @@ local function bfly4(fr: { number }, fi: { number }, fstride: number, twr: { num
|
||||
end
|
||||
else
|
||||
local m2, m3 = 2 * m, 3 * m
|
||||
local fs2, fs3 = fstride * 2, fstride * 3
|
||||
for i = 0, N - 1 do
|
||||
local p = i * mm + 1
|
||||
local t1, t2, t3 = 1, 1, 1
|
||||
@@ -154,8 +158,8 @@ local function bfly4(fr: { number }, fi: { number }, fstride: number, twr: { num
|
||||
fr[p + m2] = f0r - s3r
|
||||
fi[p + m2] = f0i - s3i
|
||||
t1 += fstride
|
||||
t2 += fstride * 2
|
||||
t3 += fstride * 3
|
||||
t2 += fs2
|
||||
t3 += fs3
|
||||
fr[p] = f0r + s3r
|
||||
fi[p] = f0i + s3i
|
||||
fr[p + m] = s5r + s4i
|
||||
@@ -170,6 +174,7 @@ end
|
||||
|
||||
local function bfly3(fr: { number }, fi: { number }, fstride: number, twr: { number }, twi: { number }, m: number, N: number, mm: number)
|
||||
local m2 = 2 * m
|
||||
local fs2 = fstride * 2
|
||||
local epi3i = twi[fstride * m + 1]
|
||||
for i = 0, N - 1 do
|
||||
local p = i * mm + 1
|
||||
@@ -184,7 +189,7 @@ local function bfly3(fr: { number }, fi: { number }, fstride: number, twr: { num
|
||||
local s3r, s3i = s1r + s2r, s1i + s2i
|
||||
local s0r, s0i = s1r - s2r, s1i - s2i
|
||||
t1 += fstride
|
||||
t2 += fstride * 2
|
||||
t2 += fs2
|
||||
local f0r, f0i = fr[p], fi[p]
|
||||
local fmr, fmi = f0r - s3r * 0.5, f0i - s3i * 0.5
|
||||
s0r *= epi3i
|
||||
@@ -203,23 +208,28 @@ end
|
||||
local function bfly5(fr: { number }, fi: { number }, fstride: number, twr: { number }, twi: { number }, m: number, N: number, mm: number)
|
||||
local yar, yai = twr[fstride * m + 1], twi[fstride * m + 1]
|
||||
local ybr, ybi = twr[fstride * 2 * m + 1], twi[fstride * 2 * m + 1]
|
||||
local fs1, fs2, fs3, fs4 = fstride, 2 * fstride, 3 * fstride, 4 * fstride
|
||||
for i = 0, N - 1 do
|
||||
local p0 = i * mm + 1
|
||||
local p1, p2, p3, p4 = p0 + m, p0 + 2 * m, p0 + 3 * m, p0 + 4 * m
|
||||
for u = 0, m - 1 do
|
||||
local k1, k2, k3, k4 = 1, 1, 1, 1 -- u * fstride * (1 .. 4) + 1
|
||||
for _ = 0, m - 1 do
|
||||
local s0r, s0i = fr[p0], fi[p0]
|
||||
local k = u * fstride
|
||||
local ar, ai = fr[p1], fi[p1]
|
||||
local wr, wi = twr[k + 1], twi[k + 1]
|
||||
local wr, wi = twr[k1], twi[k1]
|
||||
local s1r, s1i = ar * wr - ai * wi, ar * wi + ai * wr
|
||||
ar, ai = fr[p2], fi[p2]
|
||||
wr, wi = twr[2 * k + 1], twi[2 * k + 1]
|
||||
wr, wi = twr[k2], twi[k2]
|
||||
local s2r, s2i = ar * wr - ai * wi, ar * wi + ai * wr
|
||||
ar, ai = fr[p3], fi[p3]
|
||||
wr, wi = twr[3 * k + 1], twi[3 * k + 1]
|
||||
wr, wi = twr[k3], twi[k3]
|
||||
local s3r, s3i = ar * wr - ai * wi, ar * wi + ai * wr
|
||||
ar, ai = fr[p4], fi[p4]
|
||||
wr, wi = twr[4 * k + 1], twi[4 * k + 1]
|
||||
wr, wi = twr[k4], twi[k4]
|
||||
k1 += fs1
|
||||
k2 += fs2
|
||||
k3 += fs3
|
||||
k4 += fs4
|
||||
local s4r, s4i = ar * wr - ai * wi, ar * wi + ai * wr
|
||||
|
||||
local s7r, s7i = s1r + s4r, s1i + s4i
|
||||
@@ -298,24 +308,28 @@ function Mdct.backward(inp: { number }, inBase: number, out: { number }, outBase
|
||||
-- pre-rotate, storing in bit-reversed order (real and imaginary swapped: an FFT is used instead of an IFFT)
|
||||
local xp1 = inBase
|
||||
local xp2 = inBase + stride * (N2 - 1)
|
||||
for i = 0, N4 - 1 do
|
||||
local st2 = 2 * stride
|
||||
for i = 1, N4 do
|
||||
local x1 = inp[xp1]
|
||||
local x2 = inp[xp2]
|
||||
local t0, t1 = trig[2 * i + 1], trig[2 * i + 2]
|
||||
local rev = bitrev[i + 1] + 1
|
||||
local t0, t1 = trig[2 * i - 1], trig[2 * i]
|
||||
local rev = bitrev[i]
|
||||
fi[rev] = x2 * t1 + x1 * t0
|
||||
fr[rev] = x1 * t1 - x2 * t0
|
||||
xp1 += 2 * stride
|
||||
xp2 -= 2 * stride
|
||||
xp1 += st2
|
||||
xp2 -= st2
|
||||
end
|
||||
fftImpl(pl)
|
||||
local h = outBase + (overlap // 2)
|
||||
for k = 0, N4 - 1 do
|
||||
local re = fi[k + 1]
|
||||
local im = fr[k + 1]
|
||||
local t0, t1 = trig[2 * k + 1], trig[2 * k + 2]
|
||||
out[h + 2 * k] = re * t1 + im * t0
|
||||
out[h + N2 - 1 - 2 * k] = re * t0 - im * t1
|
||||
local hb = h + N2 - 1
|
||||
for k = 1, N4 do
|
||||
local re = fi[k]
|
||||
local im = fr[k]
|
||||
local t0, t1 = trig[2 * k - 1], trig[2 * k]
|
||||
out[h] = re * t1 + im * t0
|
||||
out[hb] = re * t0 - im * t1
|
||||
h += 2
|
||||
hb -= 2
|
||||
end
|
||||
-- mirror on both sides for TDAC
|
||||
local xp = outBase + overlap - 1
|
||||
|
||||
@@ -714,21 +714,27 @@ local function up2HQ(S: { number }, out: { number }, oo: number, inp: { number }
|
||||
S[1], S[2], S[3], S[4], S[5], S[6] = s0, s1, s2, s3, s4, s5
|
||||
end
|
||||
|
||||
-- FIR12 per phase ti, in tap order: FIR12[4 ti + 1 .. 4 ti + 4], FIR12[4 (11 - ti) + 4 .. 4 (11 - ti) + 1]
|
||||
local FIR12_ROWS = table.create(12)
|
||||
for ti = 0, 11 do
|
||||
local f0, f1 = ti * 4, (11 - ti) * 4
|
||||
FIR12_ROWS[ti + 1] = { FIR12[f0 + 1], FIR12[f0 + 2], FIR12[f0 + 3], FIR12[f0 + 4], FIR12[f1 + 4], FIR12[f1 + 3], FIR12[f1 + 2], FIR12[f1 + 1] }
|
||||
end
|
||||
|
||||
local function iirFirInterpol(out: { number }, oo: number, buf: { number }, max_index_Q16: number, incr: number): number
|
||||
local rows = FIR12_ROWS
|
||||
local index_Q16 = 0
|
||||
while index_Q16 < max_index_Q16 do
|
||||
local ti = ((index_Q16 % 65536) * 12) // 65536
|
||||
local r = rows[((index_Q16 % 65536) * 12) // 65536 + 1]
|
||||
local b = index_Q16 // 65536 + 1 -- buf is 1-based
|
||||
local f0 = ti * 4
|
||||
local f1 = (11 - ti) * 4
|
||||
local res_Q15 = buf[b] * FIR12[f0 + 1]
|
||||
+ buf[b + 1] * FIR12[f0 + 2]
|
||||
+ buf[b + 2] * FIR12[f0 + 3]
|
||||
+ buf[b + 3] * FIR12[f0 + 4]
|
||||
+ buf[b + 4] * FIR12[f1 + 4]
|
||||
+ buf[b + 5] * FIR12[f1 + 3]
|
||||
+ buf[b + 6] * FIR12[f1 + 2]
|
||||
+ buf[b + 7] * FIR12[f1 + 1]
|
||||
local res_Q15 = buf[b] * r[1]
|
||||
+ buf[b + 1] * r[2]
|
||||
+ buf[b + 2] * r[3]
|
||||
+ buf[b + 3] * r[4]
|
||||
+ buf[b + 4] * r[5]
|
||||
+ buf[b + 5] * r[6]
|
||||
+ buf[b + 6] * r[7]
|
||||
+ buf[b + 7] * r[8]
|
||||
out[oo] = sat16((res_Q15 + 16384) // 32768)
|
||||
oo += 1
|
||||
index_Q16 += incr
|
||||
@@ -1316,52 +1322,35 @@ local function decodeCore(ch: any, ctrl: any, xq: { number }, xo: number, pulses
|
||||
A_Q12_tmp[6], A_Q12_tmp[7], A_Q12_tmp[8], A_Q12_tmp[9], A_Q12_tmp[10]
|
||||
local wide = order == 16
|
||||
local a10, a11, a12, a13, a14, a15 = A_Q12_tmp[11], A_Q12_tmp[12], A_Q12_tmp[13], A_Q12_tmp[14], A_Q12_tmp[15], A_Q12_tmp[16]
|
||||
-- the last 16 sLPC_Q14 values in locals, newest first (s1 = sLPC_Q14[MAX_LPC_ORDER + i - 1] in C)
|
||||
local s1, s2, s3, s4, s5, s6, s7, s8 = sLPC_Q14[16], sLPC_Q14[15], sLPC_Q14[14], sLPC_Q14[13], sLPC_Q14[12], sLPC_Q14[11], sLPC_Q14[10], sLPC_Q14[9]
|
||||
local s9, s10, s11, s12, s13, s14, s15, s16 = sLPC_Q14[8], sLPC_Q14[7], sLPC_Q14[6], sLPC_Q14[5], sLPC_Q14[4], sLPC_Q14[3], sLPC_Q14[2], sLPC_Q14[1]
|
||||
local half = order // 2
|
||||
for i = 1, subfr_length do
|
||||
local pred = half
|
||||
pred += (s1 * a0) // 65536
|
||||
pred += (s2 * a1) // 65536
|
||||
pred += (s3 * a2) // 65536
|
||||
pred += (s4 * a3) // 65536
|
||||
pred += (s5 * a4) // 65536
|
||||
pred += (s6 * a5) // 65536
|
||||
pred += (s7 * a6) // 65536
|
||||
pred += (s8 * a7) // 65536
|
||||
pred += (s9 * a8) // 65536
|
||||
pred += (s10 * a9) // 65536
|
||||
local j = 16 + i -- 1-based index of sLPC_Q14[MAX_LPC_ORDER + i - 1 (C)] + 1
|
||||
local pred = order // 2
|
||||
pred += (sLPC_Q14[j - 1] * a0) // 65536
|
||||
pred += (sLPC_Q14[j - 2] * a1) // 65536
|
||||
pred += (sLPC_Q14[j - 3] * a2) // 65536
|
||||
pred += (sLPC_Q14[j - 4] * a3) // 65536
|
||||
pred += (sLPC_Q14[j - 5] * a4) // 65536
|
||||
pred += (sLPC_Q14[j - 6] * a5) // 65536
|
||||
pred += (sLPC_Q14[j - 7] * a6) // 65536
|
||||
pred += (sLPC_Q14[j - 8] * a7) // 65536
|
||||
pred += (sLPC_Q14[j - 9] * a8) // 65536
|
||||
pred += (sLPC_Q14[j - 10] * a9) // 65536
|
||||
if wide then
|
||||
pred += (s11 * a10) // 65536
|
||||
pred += (s12 * a11) // 65536
|
||||
pred += (s13 * a12) // 65536
|
||||
pred += (s14 * a13) // 65536
|
||||
pred += (s15 * a14) // 65536
|
||||
pred += (s16 * a15) // 65536
|
||||
pred += (sLPC_Q14[j - 11] * a10) // 65536
|
||||
pred += (sLPC_Q14[j - 12] * a11) // 65536
|
||||
pred += (sLPC_Q14[j - 13] * a12) // 65536
|
||||
pred += (sLPC_Q14[j - 14] * a13) // 65536
|
||||
pred += (sLPC_Q14[j - 15] * a14) // 65536
|
||||
pred += (sLPC_Q14[j - 16] * a15) // 65536
|
||||
end
|
||||
pred = i32(pred)
|
||||
local v = addSat32(presArr[presOff + i], lshiftSat32(pred, 4))
|
||||
s16 = s15
|
||||
s15 = s14
|
||||
s14 = s13
|
||||
s13 = s12
|
||||
s12 = s11
|
||||
s11 = s10
|
||||
s10 = s9
|
||||
s9 = s8
|
||||
s8 = s7
|
||||
s7 = s6
|
||||
s6 = s5
|
||||
s5 = s4
|
||||
s4 = s3
|
||||
s3 = s2
|
||||
s2 = s1
|
||||
s1 = v
|
||||
sLPC_Q14[j] = v
|
||||
xq[pxq + i - 1] = sat16((mulww(v, Gain_Q10) + 128) // 256)
|
||||
end
|
||||
sLPC_Q14[16], sLPC_Q14[15], sLPC_Q14[14], sLPC_Q14[13], sLPC_Q14[12], sLPC_Q14[11], sLPC_Q14[10], sLPC_Q14[9] = s1, s2, s3, s4, s5, s6, s7, s8
|
||||
sLPC_Q14[8], sLPC_Q14[7], sLPC_Q14[6], sLPC_Q14[5], sLPC_Q14[4], sLPC_Q14[3], sLPC_Q14[2], sLPC_Q14[1] = s9, s10, s11, s12, s13, s14, s15, s16
|
||||
for i = 1, 16 do
|
||||
sLPC_Q14[i] = sLPC_Q14[subfr_length + i]
|
||||
end
|
||||
pexc += subfr_length
|
||||
pxq += subfr_length
|
||||
end
|
||||
|
||||
@@ -278,12 +278,12 @@ local function partition(br: Codebook.Br, book: Codebook.Book, target: { number
|
||||
return false
|
||||
end
|
||||
local base = e * dims
|
||||
local len = math.min(dims, psize - k)
|
||||
local at = offset + k
|
||||
for i = 0, len - 1 do
|
||||
if at + i < limit then
|
||||
target[at + i + 1] += vq[base + i + 1]
|
||||
end
|
||||
-- the values at + i < limit of the first min(dims, psize - k)
|
||||
local len = math.min(dims, psize - k, limit - at)
|
||||
local d = base - at
|
||||
for t = at + 1, at + len do
|
||||
target[t] += vq[t + d]
|
||||
end
|
||||
k += dims
|
||||
end
|
||||
@@ -517,13 +517,13 @@ function Packet.decode(st: State, b: buffer, off: number, size: number): number
|
||||
for j = 1, leftStart do
|
||||
fr[j] = 0
|
||||
end
|
||||
local L = leftEnd - leftStart
|
||||
for j = 0, L - 1 do
|
||||
fr[leftStart + j + 1] *= lslope[j + 1]
|
||||
for j = 1, leftEnd - leftStart do
|
||||
fr[leftStart + j] *= lslope[j]
|
||||
end
|
||||
local R = rightEnd - rightStart
|
||||
for j = 0, R - 1 do
|
||||
fr[rightStart + j + 1] *= rslope[R - j]
|
||||
local rb = rightStart + R + 1 -- fr[rightStart + j + 1] *= rslope[R - j]
|
||||
for j = 1, R do
|
||||
fr[rb - j] *= rslope[j]
|
||||
end
|
||||
for j = rightEnd + 1, n do
|
||||
fr[j] = 0
|
||||
@@ -539,13 +539,20 @@ function Packet.decode(st: State, b: buffer, off: number, size: number): number
|
||||
local tl = st.tailLen
|
||||
for c = 1, ch do
|
||||
local out, tail, fr = st.out[c], st.tail[c], st.frame[c]
|
||||
for j = 0, count - 1 do
|
||||
local v = if j < tl then tail[j + 1] else 0
|
||||
local fi = j - o
|
||||
if fi >= 0 then
|
||||
v += fr[fi + 1]
|
||||
end
|
||||
out[j + 1] = v
|
||||
-- out[j] = (tail[j] if j <= tl else 0) + (fr[j - o] if j > o), j = 1 .. count
|
||||
local a = math.min(math.max(o, 0), count) -- j <= a: no frame sample
|
||||
local b = math.min(tl, count) -- j <= b: a tail sample
|
||||
for j = 1, math.min(a, b) do
|
||||
out[j] = tail[j]
|
||||
end
|
||||
for j = b + 1, a do
|
||||
out[j] = 0
|
||||
end
|
||||
for j = a + 1, b do
|
||||
out[j] = tail[j] + fr[j - o]
|
||||
end
|
||||
for j = math.max(a, b) + 1, count do
|
||||
out[j] = 0 + fr[j - o]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+64
-33
@@ -39,11 +39,11 @@ local function case(list: any, name: string): any
|
||||
end
|
||||
|
||||
-- decodeBench(label, module path, fixture, case name, runs): Module.decode(reader) on the case's bytes
|
||||
local function decodeBench(label: string, mod: any, data: string, n: number)
|
||||
local function decodeBench(label: string, mod: any, data: () -> string, n: number)
|
||||
if not want(label) then
|
||||
return
|
||||
end
|
||||
local b = buffer.fromstring(data)
|
||||
local b = buffer.fromstring(data())
|
||||
local a = assert(mod.decode(Bytes.reader(b)))
|
||||
local dt = best(n, function()
|
||||
mod.decode(Bytes.reader(b))
|
||||
@@ -51,13 +51,17 @@ local function decodeBench(label: string, mod: any, data: string, n: number)
|
||||
report(label, dt, a.frames / a.sampleRate, a.frames * a.channels * 4)
|
||||
end
|
||||
|
||||
local MC = require("@tests/gen/mp3_cases")
|
||||
local Mp3 = require("@rosetta/audio/mp3")
|
||||
local function mp3Case(name: string): () -> string
|
||||
return function()
|
||||
return case(require("@tests/gen/mp3_cases"), name).data
|
||||
end
|
||||
end
|
||||
for _, name in { "l3_cbr128_js", "l3_vbr_v2_48k", "l2_192_st" } do
|
||||
decodeBench("mp3 " .. name, Mp3, case(MC, name).data, 5)
|
||||
decodeBench("mp3 " .. name, Mp3, mp3Case(name), 5)
|
||||
end
|
||||
if want("mp3 stream") then
|
||||
local b = buffer.fromstring(case(MC, "l3_cbr128_js").data)
|
||||
local b = buffer.fromstring(mp3Case("l3_cbr128_js")())
|
||||
local out = buffer.create(1152 * 2 * 4)
|
||||
local frames, rate = 0, 44100
|
||||
local dt = best(5, function()
|
||||
@@ -77,27 +81,37 @@ end
|
||||
|
||||
local Opus = require("@rosetta/audio/opus")
|
||||
for _, c in {
|
||||
{ "opus celt 128k", require("@tests/gen/opus_celt_st_128").data },
|
||||
{ "opus silk wb", require("@tests/gen/opus_silk_wb_st").data },
|
||||
{ "opus hybrid", require("@tests/gen/opus_hybrid_st").data },
|
||||
{ "opus 48k music (ogg)", case(require("@tests/gen/ogg_cases"), "opus_stereo").data },
|
||||
{ "opus celt 128k", function() return require("@tests/gen/opus_celt_st_128").data end },
|
||||
{ "opus silk wb", function() return require("@tests/gen/opus_silk_wb_st").data end },
|
||||
{ "opus hybrid", function() return require("@tests/gen/opus_hybrid_st").data end },
|
||||
{ "opus 48k music (ogg)", function() return case(require("@tests/gen/ogg_cases"), "opus_stereo").data end },
|
||||
} do
|
||||
decodeBench(c[1], Opus, c[2], 3)
|
||||
end
|
||||
|
||||
local Vorbis = require("@rosetta/audio/vorbis")
|
||||
decodeBench("vorbis q5 (10 s st)", Vorbis, require("@tests/gen/vorbis_bench").data, 3)
|
||||
decodeBench("vorbis q5 (10 s st)", Vorbis, function()
|
||||
return require("@tests/gen/vorbis_bench").data
|
||||
end, 3)
|
||||
|
||||
local M4a = require("@rosetta/audio/m4a")
|
||||
local MA = require("@tests/gen/m4a_aac")
|
||||
decodeBench("aac-lc m4a stereo 128k", M4a, case(MA, "aac_stereo_128k.m4a").data, 3)
|
||||
decodeBench("aac fdk m4a stereo", M4a, case(MA, "fdk_stereo.m4a").data, 3)
|
||||
decodeBench("alac m4a stereo 16", M4a, require("@tests/gen/m4a_alac")[1].data, 3)
|
||||
decodeBench("aac-lc m4a stereo 128k", M4a, function()
|
||||
return case(require("@tests/gen/m4a_aac"), "aac_stereo_128k.m4a").data
|
||||
end, 3)
|
||||
decodeBench("aac fdk m4a stereo", M4a, function()
|
||||
return case(require("@tests/gen/m4a_aac"), "fdk_stereo.m4a").data
|
||||
end, 3)
|
||||
decodeBench("alac m4a stereo 16", M4a, function()
|
||||
return require("@tests/gen/m4a_alac")[1].data
|
||||
end, 3)
|
||||
|
||||
local Flac = require("@rosetta/audio/flac")
|
||||
local FC = require("@tests/gen/flac_cases")
|
||||
decodeBench("flac s16_long", Flac, case(FC, "s16_long").data, 5)
|
||||
decodeBench("flac s24_96k", Flac, case(FC, "s24_96k").data, 5)
|
||||
decodeBench("flac s16_long", Flac, function()
|
||||
return case(require("@tests/gen/flac_cases"), "s16_long").data
|
||||
end, 5)
|
||||
decodeBench("flac s24_96k", Flac, function()
|
||||
return case(require("@tests/gen/flac_cases"), "s24_96k").data
|
||||
end, 5)
|
||||
|
||||
local Wav = require("@rosetta/audio/wav")
|
||||
do
|
||||
@@ -146,20 +160,37 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
local function lossless(label: string, path: any, cases: any, name: string, n: number)
|
||||
if want(label) then
|
||||
decodeBench(label, path, case(cases, name).data, n)
|
||||
end
|
||||
local fixtures: { [string]: () -> any } = {
|
||||
wavpack = function()
|
||||
return require("@tests/gen/wavpack_cases")
|
||||
end,
|
||||
ape = function()
|
||||
return require("@tests/gen/ape_cases")
|
||||
end,
|
||||
tta = function()
|
||||
return require("@tests/gen/tta_cases")
|
||||
end,
|
||||
mpc = function()
|
||||
return require("@tests/gen/mpc_cases")
|
||||
end,
|
||||
ac3 = function()
|
||||
return require("@tests/gen/ac3_cases")
|
||||
end,
|
||||
}
|
||||
local function lossless(label: string, mod: any, fx: string, name: string, n: number)
|
||||
decodeBench(label, mod, function()
|
||||
return case(fixtures[fx](), name).data
|
||||
end, n)
|
||||
end
|
||||
lossless("wavpack s16_long", require("@rosetta/audio/wavpack"), require("@tests/gen/wavpack_cases"), "s16_long", 3)
|
||||
lossless("wavpack s16_hh", require("@rosetta/audio/wavpack"), require("@tests/gen/wavpack_cases"), "s16_hh", 3)
|
||||
lossless("ape s16_long", require("@rosetta/audio/ape"), require("@tests/gen/ape_cases"), "s16_long", 3)
|
||||
lossless("ape s16_long_c4000", require("@rosetta/audio/ape"), require("@tests/gen/ape_cases"), "s16_long_c4000", 3)
|
||||
lossless("tta s16_long", require("@rosetta/audio/tta"), require("@tests/gen/tta_cases"), "s16_long", 3)
|
||||
lossless("mpc sv8 q5 stereo", require("@rosetta/audio/mpc"), require("@tests/gen/mpc_cases"), "sv8_q5_stereo", 3)
|
||||
lossless("mpc sv7 q5 stereo", require("@rosetta/audio/mpc"), require("@tests/gen/mpc_cases"), "sv7_q5_stereo", 3)
|
||||
lossless("ac3 5.1_448", require("@rosetta/audio/ac3"), require("@tests/gen/ac3_cases"), "5.1_448", 3)
|
||||
lossless("ac3 stereo_44k", require("@rosetta/audio/ac3"), require("@tests/gen/ac3_cases"), "stereo_44k", 3)
|
||||
lossless("wavpack s16_long", require("@rosetta/audio/wavpack"), "wavpack", "s16_long", 3)
|
||||
lossless("wavpack s16_hh", require("@rosetta/audio/wavpack"), "wavpack", "s16_hh", 3)
|
||||
lossless("ape s16_long", require("@rosetta/audio/ape"), "ape", "s16_long", 3)
|
||||
lossless("ape s16_long_c4000", require("@rosetta/audio/ape"), "ape", "s16_long_c4000", 3)
|
||||
lossless("tta s16_long", require("@rosetta/audio/tta"), "tta", "s16_long", 3)
|
||||
lossless("mpc sv8 q5 stereo", require("@rosetta/audio/mpc"), "mpc", "sv8_q5_stereo", 3)
|
||||
lossless("mpc sv7 q5 stereo", require("@rosetta/audio/mpc"), "mpc", "sv7_q5_stereo", 3)
|
||||
lossless("ac3 5.1_448", require("@rosetta/audio/ac3"), "ac3", "5.1_448", 3)
|
||||
lossless("ac3 stereo_44k", require("@rosetta/audio/ac3"), "ac3", "stereo_44k", 3)
|
||||
|
||||
-- renders: x RT of stereo 44.1 kHz output (MB/s of f32 stereo)
|
||||
local function render(label: string, n: number, mk: () -> any, maxFrames: number?)
|
||||
@@ -181,7 +212,7 @@ local function render(label: string, n: number, mk: () -> any, maxFrames: number
|
||||
end)
|
||||
report(label, dt, frames / 44100, frames * 8)
|
||||
end
|
||||
do
|
||||
if want("midi render sf2 (test song)") or want("midi render fallback") or want("synth 32 voices x 2 s") then
|
||||
local Midi = require("@rosetta/music/midi")
|
||||
local Sf2 = require("@rosetta/music/sf2")
|
||||
local SF = require("@tests/gen/sf2_cases")
|
||||
@@ -211,7 +242,7 @@ do
|
||||
report("synth 32 voices x 2 s", dt, 2, frames * 8)
|
||||
end
|
||||
end
|
||||
do
|
||||
if want("tracker 32 ch (mod)") or want("tracker 32 ch + NNA, filters (it)") then
|
||||
local Tracker = require("@rosetta/codecs/audio/Tracker")
|
||||
local function song(format: string, filter: boolean): any
|
||||
local m = Tracker.newModule(format, 32)
|
||||
@@ -252,7 +283,7 @@ do
|
||||
return Tracker.render(it)
|
||||
end)
|
||||
end
|
||||
do
|
||||
if want("ahx render karma (4 ch)") or want("hvl render demo (6 ch)") then
|
||||
local Ahx, Hvl = require("@rosetta/music/ahx"), require("@rosetta/music/hvl")
|
||||
local AC, HC = require("@tests/gen/ahx_cases"), require("@tests/gen/hvl_cases")
|
||||
for _, spec in { { Ahx, AC, "karma.ahx", "ahx render karma (4 ch)" }, { Hvl, HC, "demo", "hvl render demo (6 ch)" } } do
|
||||
|
||||
Reference in new issue
Block a user