codecs: JPEG / MPEG-1/2 yield hooks (per MCU row, per slice), banded Mpeg2.toRgba with RGB clamp table; build.py: reserved child names pass (work from the userspace session)

This commit is contained in:
4DBug committed 2026-11-01 01:16:04 -05:00
1 parent 551fd937b9
commit 05eedbc8cf
10 files changed
+246 -14

No files matched your search

+29
View File
@@ -270,4 +270,33 @@ do
end, { Fx.fields.data }, { mutations = 3, garbage = 10 })
end
do -- opts.yield: the cooperative hook runs (scans, IDCT, colour), output unchanged, inside a coroutine, errors ignored
local s = Fx.streams[1]
local f = s.frames[1]
local b = buffer.fromstring(f.data)
local calls = 0
local img = Jpeg.decode(b, 0, nil, { yield = function()
calls += 1
end }) :: Types.Image
t:check(img and calls > 0, "yield hook runs (" .. calls .. " calls)")
t:eq(Crc32.of(img.pixels), f.rgba, "yield: rgba8 unchanged")
local yuv = Jpeg.decode(b, 0, nil, { yuv = true, yield = function() end }) :: Types.Image
t:eq(Crc32.of(yuv.pixels), f.yuv, "yield: yuv420p unchanged")
local resumes = 0
local co = coroutine.create(function()
return Jpeg.decode(b, 0, nil, { yield = coroutine.yield })
end)
local ok, res = coroutine.resume(co)
while ok and coroutine.status(co) == "suspended" do
resumes += 1
ok, res = coroutine.resume(co)
end
t:check(ok and resumes > 1 and res ~= nil, "a decode suspended at the hook resumes")
t:eq(res and Crc32.of((res :: any).pixels), f.rgba, "suspended decode: same pixels")
local e = Jpeg.decode(b, 0, nil, { yield = function()
error("hook error")
end }) :: Types.Image
t:eq(e and Crc32.of(e.pixels), f.rgba, "an erroring hook is ignored")
end
t:done()