ws-video: animated WebP through F.video.open checked against Pillow's canvases
This commit is contained in:
1 parent
3dd0b59784
commit
33318c8b73
1 file changed
+33
@@ -64,6 +64,39 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
-- animated WebP through F.video.open: frames-backed, the canvases equal Pillow's (libwebp's WebPAnimDecoder)
|
||||
do
|
||||
local Crc32 = require("@formats/core/Crc32")
|
||||
local Anims = require("@tests/gen/webp_anim")
|
||||
for _, a in Anims do
|
||||
local v = F.video.open(buffer.fromstring(a.data))
|
||||
t:check(v ~= nil and v.codec == "frames" and v.frames == #a.frames, a.name .. ": opens as a " .. #a.frames .. "-frame video")
|
||||
if v then
|
||||
local bad, n, t0 = 0, 0, 0
|
||||
while true do
|
||||
local f = v:nextFrame()
|
||||
if not f then
|
||||
break
|
||||
end
|
||||
n += 1
|
||||
local px = f.image.pixels
|
||||
if a.rgba == false then
|
||||
px = buffer.create(buffer.len(f.image.pixels))
|
||||
buffer.copy(px, 0, f.image.pixels)
|
||||
for i = 3, buffer.len(px) - 1, 4 do
|
||||
buffer.writeu8(px, i, 255)
|
||||
end
|
||||
end
|
||||
if Crc32.of(px) ~= a.frames[n].crc or math.abs(f.pts - t0) > 1e-6 then
|
||||
bad += 1
|
||||
end
|
||||
t0 += a.frames[n].ms / 1000
|
||||
end
|
||||
t:check(n == #a.frames and bad == 0, a.name .. ": video frames equal Pillow's canvases and times (" .. bad .. " differ)")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- the writers are deterministic: the same bytes again
|
||||
do
|
||||
local Mkv = require("@tests/gen/mkv_cases")
|
||||
|
||||
Reference in new issue
Block a user