audio perf: ALAC integer divisions
This commit is contained in:
1 parent
738b881349
commit
a2cd103674
3 files changed
+1337
-840
No files matched your search
+795
-298
File diff suppressed because it is too large.
Load diff
+537
-537
File diff suppressed because it is too large.
Load diff
@@ -78,7 +78,7 @@ local function rice(b: buffer, pos: number, limit: number, out: { number }, n: n
|
||||
if pos > limit then
|
||||
return -1 -- each value reads at most 41 bits past here: inside the 16 padding bytes
|
||||
end
|
||||
local k = 31 - countlz(floor(history / 512) + 3)
|
||||
local k = 31 - countlz(history // 512 + 3)
|
||||
if k > kb then
|
||||
k = kb
|
||||
end
|
||||
@@ -90,14 +90,14 @@ local function rice(b: buffer, pos: number, limit: number, out: { number }, n: n
|
||||
if x > 0xFFFF then
|
||||
history = 0xFFFF
|
||||
else
|
||||
history += x * mult - floor(history * mult / 512)
|
||||
history += x * mult - (history * mult) // 512
|
||||
end
|
||||
if history < 128 and i < n then
|
||||
if pos > limit then
|
||||
return -1
|
||||
end
|
||||
local lg = if history > 0 then 31 - countlz(history) else 0
|
||||
k = 7 - lg + floor((history + 16) / 64)
|
||||
k = 7 - lg + (history + 16) // 64
|
||||
if k > kb then
|
||||
k = kb
|
||||
end
|
||||
@@ -155,7 +155,7 @@ local function predict(err: { number }, out: { number }, n: number, bps: number,
|
||||
for j = 1, order do
|
||||
val += (out[i - j] - d) * coefs[j]
|
||||
end
|
||||
val = floor((val + half) / qd)
|
||||
val = (val + half) // qd -- qd is 2^quant: exact
|
||||
local e = err[i]
|
||||
out[i] = signExtend(val + d + e, bps)
|
||||
if e ~= 0 then
|
||||
@@ -168,7 +168,7 @@ local function predict(err: { number }, out: { number }, n: number, bps: number,
|
||||
local v = d - out[i - j]
|
||||
local sgn = if v > 0 then es elseif v < 0 then -es else 0
|
||||
coefs[j] -= sgn
|
||||
e -= floor(v * sgn / qd) * (order - j + 1)
|
||||
e -= ((v * sgn) // qd) * (order - j + 1)
|
||||
end
|
||||
end
|
||||
i += 1
|
||||
|
||||
Reference in new issue
Block a user