perf(image): VP8L literal symbols inline, cross-colour identity tiles skipped, T / TR / TL predictors and SWAR addPixels; JPEG IDCT 5x5 path, gray / 4:4:4 colour fast paths; QOI index as tables; TGA rows without per-pixel div/mod; BC7 / BC6H bit reads from a word table; bench_image: bcn / exr
This commit is contained in:
1 parent
9855a7edd6
commit
903e239a0e
7 files changed
+293
-121
No files matched your search
@@ -124,18 +124,18 @@ local function idct8(coef: buffer, off: number, qt: { number }, plane: buffer, o
|
||||
end
|
||||
end
|
||||
|
||||
-- idct8 with every nonzero coefficient in the top-left 4 x 4 (zigzag index <= 9): the same sums without the zero terms
|
||||
local function idct8x4(coef: buffer, off: number, qt: { number }, plane: buffer, out: number, stride: number, p1: number, center: number, maxv: number)
|
||||
-- idct8 with every nonzero coefficient in the top-left 5 x 5 (zigzag index <= 14): the same sums without the zero terms
|
||||
local function idct8x5(coef: buffer, off: number, qt: { number }, plane: buffer, out: number, stride: number, p1: number, center: number, maxv: number)
|
||||
local ws = ws
|
||||
local s1 = 2 ^ (13 - p1)
|
||||
local h1 = s1 / 2
|
||||
local s2 = 2 ^ (16 + p1)
|
||||
local h2 = s2 / 2 + center * s2
|
||||
local dcm = 2 ^ p1
|
||||
for c = 0, 3 do
|
||||
for c = 0, 4 do
|
||||
local o = off + c * 2
|
||||
local c1, c2, c3 = readi16(coef, o + 16), readi16(coef, o + 32), readi16(coef, o + 48)
|
||||
if c1 == 0 and c2 == 0 and c3 == 0 then
|
||||
local c1, c2, c3, c4 = readi16(coef, o + 16), readi16(coef, o + 32), readi16(coef, o + 48), readi16(coef, o + 64)
|
||||
if c1 == 0 and c2 == 0 and c3 == 0 and c4 == 0 then
|
||||
local dc = readi16(coef, o) * qt[c + 1] * dcm
|
||||
ws[c + 1] = dc
|
||||
ws[c + 9] = dc
|
||||
@@ -149,15 +149,18 @@ local function idct8x4(coef: buffer, off: number, qt: { number }, plane: buffer,
|
||||
local z2 = c2 * qt[c + 17]
|
||||
local tmp2 = z2 * 4433
|
||||
local tmp3 = tmp2 + z2 * 6270
|
||||
local tmp0 = readi16(coef, o) * qt[c + 1] * 8192 + h1
|
||||
z2 = readi16(coef, o) * qt[c + 1]
|
||||
local z3 = c4 * qt[c + 33]
|
||||
local tmp0 = (z2 + z3) * 8192 + h1
|
||||
local tmp1 = (z2 - z3) * 8192 + h1
|
||||
local tmp10, tmp13 = tmp0 + tmp3, tmp0 - tmp3
|
||||
local tmp11, tmp12 = tmp0 + tmp2, tmp0 - tmp2
|
||||
local tmp11, tmp12 = tmp1 + tmp2, tmp1 - tmp2
|
||||
local t2 = c3 * qt[c + 25]
|
||||
local t3 = c1 * qt[c + 9]
|
||||
local z5 = (t2 + t3) * 9633
|
||||
local z1 = t3 * -7373
|
||||
z2 = t2 * -20995
|
||||
local z3 = t2 * -16069 + z5
|
||||
z3 = t2 * -16069 + z5
|
||||
local z4 = t3 * -3196 + z5
|
||||
local t0 = z1 + z3
|
||||
local t1 = z2 + z4
|
||||
@@ -177,9 +180,9 @@ local function idct8x4(coef: buffer, off: number, qt: { number }, plane: buffer,
|
||||
local hd = sd / 2 + center * sd
|
||||
for r = 0, 7 do
|
||||
local b = r * 8
|
||||
local w0, w1, w2, w3 = ws[b + 1], ws[b + 2], ws[b + 3], ws[b + 4]
|
||||
local w0, w1, w2, w3, w4 = ws[b + 1], ws[b + 2], ws[b + 3], ws[b + 4], ws[b + 5]
|
||||
local o = (out + r * stride) * 2
|
||||
if w1 == 0 and w2 == 0 and w3 == 0 then
|
||||
if w1 == 0 and w2 == 0 and w3 == 0 and w4 == 0 then
|
||||
local v = clamp((w0 + hd) // sd, 0, maxv) * 65537
|
||||
writeu32(plane, o, v)
|
||||
writeu32(plane, o + 4, v)
|
||||
@@ -188,9 +191,10 @@ local function idct8x4(coef: buffer, off: number, qt: { number }, plane: buffer,
|
||||
else
|
||||
local tmp2 = w2 * 4433
|
||||
local tmp3 = tmp2 + w2 * 6270
|
||||
local tmp0 = w0 * 8192 + h2
|
||||
local tmp0 = (w0 + w4) * 8192 + h2
|
||||
local tmp1 = (w0 - w4) * 8192 + h2
|
||||
local tmp10, tmp13 = tmp0 + tmp3, tmp0 - tmp3
|
||||
local tmp11, tmp12 = tmp0 + tmp2, tmp0 - tmp2
|
||||
local tmp11, tmp12 = tmp1 + tmp2, tmp1 - tmp2
|
||||
local z5 = (w3 + w1) * 9633
|
||||
local z1 = w1 * -7373
|
||||
local z2 = w3 * -20995
|
||||
@@ -347,8 +351,8 @@ function Dct.idctComponent(coef: buffer, q: buffer, bpl: number, bpc: number, si
|
||||
local k = readu8(nz, bi)
|
||||
if k == 0 then
|
||||
idct8dc(coef, off, qt, plane, out, stride, p1, center, maxv)
|
||||
elseif k <= 9 then
|
||||
idct8x4(coef, off, qt, plane, out, stride, p1, center, maxv)
|
||||
elseif k <= 14 then
|
||||
idct8x5(coef, off, qt, plane, out, stride, p1, center, maxv)
|
||||
else
|
||||
idct8(coef, off, qt, plane, out, stride, p1, center, maxv)
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user