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
@@ -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
|
||||
|
||||
Reference in new issue
Block a user