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