ws-h264: tests (bit-exact vs ffmpeg, AVCC, NAL-at-a-time, unsupported, fuzz), bench lines; LuaJIT speedups (no table-allocating if-expressions, arithmetic bit reads, branch-free CABAC decisions, split MC filters)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
4DBugandClaude Opus 5.5 committed 2026-10-31 10:07:39 -05:00
1 parent 7ae481d4ed
commit c848c736ba
12 files changed
+648 -408

No files matched your search

+12 -15
View File
@@ -16,18 +16,12 @@ local Deblock = {}
local BS = table.create(4, 0)
local min, max = math.min, math.max
local function clip3(lo: number, hi: number, v: number): number
if v < lo then
return lo
elseif v > hi then
return hi
end
return v
return min(max(v, lo), hi)
end
local function abs(v: number): number
return if v < 0 then -v else v
end
local abs = math.abs
-- luma(b, o, across, along, qp, aOff, bOff): filters the 16 samples of one luma edge; `across` steps from q0 to q1
-- (1 for vertical edges, the stride for horizontal ones), `along` to the next sample of the edge; BS holds the four
@@ -55,7 +49,7 @@ local function luma(b: buffer, o: number, across: number, along: number, qp: num
local ap = abs(p2 - p0)
local aq = abs(q2 - q0)
if bS < 4 then
local tc = tc0 + (if ap < beta then 1 else 0) + (if aq < beta then 1 else 0)
local tc = tc0 + (((ap < beta) and (1) or (0))) + (((aq < beta) and (1) or (0)))
local delta = clip3(-tc, tc, ((q0 - p0) * 4 + (p1 - q1) + 4) // 8)
writeu8(b, q - across, clip3(0, 255, p0 + delta))
writeu8(b, q, clip3(0, 255, q0 - delta))
@@ -129,8 +123,8 @@ end
local function motionDiffers(pic: any, p: number, q: number): boolean
local uid0, uid1, mv0, mv1 = pic.uid0, pic.uid1, pic.mv0, pic.mv1
local pa, pb, qa, qb = uid0[p], uid1[p], uid0[q], uid1[q]
local np = (if pa >= 0 then 1 else 0) + (if pb >= 0 then 1 else 0)
local nq = (if qa >= 0 then 1 else 0) + (if qb >= 0 then 1 else 0)
local np = (((pa >= 0) and (1) or (0))) + (((pb >= 0) and (1) or (0)))
local nq = (((qa >= 0) and (1) or (0))) + (((qb >= 0) and (1) or (0)))
if np ~= nq then
return true
end
@@ -187,8 +181,11 @@ function Deblock.picture(S: any, pic: any, params: { any })
local co = pic.co + my * 8 * cs + mx * 8
for dir = 0, 1 do
-- dir 0: vertical edges (left neighbour), dir 1: horizontal edges (top neighbour)
local nAddr = if dir == 0 then addr - 1 else addr - mbW
local edgeOk = if dir == 0 then mx > 0 else my > 0
local nAddr = ((dir == 0) and (addr - 1) or (addr - mbW))
local edgeOk = my > 0
if dir == 0 then
edgeOk = mx > 0
end
if edgeOk and idc == 2 and sliceTab[nAddr] ~= sn then
edgeOk = false
end
@@ -221,7 +218,7 @@ function Deblock.picture(S: any, pic: any, params: { any })
end
local bS
if intraP or intraQ then
bS = if e == 0 then 4 else 3
bS = ((e == 0) and (4) or (3))
elseif nzDb[qg] ~= 0 or nzDb[pg] ~= 0 then
bS = 2
elseif motionDiffers(pic, pg, qg) then