tests/image: comments: specs only
This commit is contained in:
1 parent
e306d5c1d7
commit
a80299dce0
27 files changed
+32
-199
No files matched your search
+1
-10
@@ -1,7 +1,4 @@
|
||||
-- image/png APNG tests: animated PNGs from ffmpeg's encoder and hand-written ones (every dispose / blend op, sub-rects,
|
||||
-- palette + tRNS, grey, RGB, a hidden default image) decoded into frames and composited, compared with ffmpeg's
|
||||
-- composited canvases (CRC-32); the APNG encoder's round trips; bad sequence numbers / rectangles; the fuzz pass.
|
||||
-- Fixtures: tools/fixtures/apng.py.
|
||||
-- image/png APNG tests against ffmpeg's composited canvases (tools/fixtures/apng.py).
|
||||
local T = require("@tests/T")
|
||||
local Png = require("@rosetta/image/png")
|
||||
local Bytes = require("@rosetta/core/Bytes")
|
||||
@@ -65,7 +62,6 @@ for _, c in Cases do
|
||||
for i, want in c.crcs do
|
||||
t:eq(canvasCrc(canv[i].pixels, c.opaque), want, c.name .. ": composited frame " .. i .. (if c.ffmpeg then " vs ffmpeg" else " vs reference"))
|
||||
end
|
||||
-- round trip through the encoder: the same frames, rectangles, ops, delays, loops and default image
|
||||
local enc, eerr = Png.encode(img)
|
||||
t:check(enc, c.name .. ": encode " .. tostring(eerr))
|
||||
local back, berr = Png.decode(Bytes.reader(enc :: buffer), { checkCrc = true })
|
||||
@@ -82,7 +78,6 @@ for _, c in Cases do
|
||||
end
|
||||
t:note("%d APNGs match the reference canvases and round-trip", #Cases)
|
||||
|
||||
-- encoder: frames built here (sub-rects, delays in seconds), opts.apng, validation
|
||||
do
|
||||
local function solid(w: number, h: number, r: number, g: number, b: number, a: number): Types.Image
|
||||
local im = Types.Image.new(w, h)
|
||||
@@ -112,13 +107,11 @@ do
|
||||
t:eq(buffer.readu8(canv[2].pixels, o + 3), 255, "over: alpha")
|
||||
t:eq(buffer.readu8(canv[2].pixels, o), (128 * 200 + 127 * 10 + 128) * 257 // 65536, "over: red")
|
||||
t:eq(buffer.readu32(canv[3].pixels, o), 0, "background dispose cleared frame 2's rect")
|
||||
-- one frame + opts.apng; a still image stays a PNG
|
||||
local still = solid(4, 4, 1, 2, 3, 255)
|
||||
local plain = decode(Png.encode(still) :: buffer)
|
||||
t:check(plain.frames == nil, "still image: no acTL")
|
||||
local one = decode(Png.encode(still, { apng = true }) :: buffer)
|
||||
t:check(one.frames and #one.frames == 1 and same(one.frames[1].image, still), "opts.apng: a one-frame APNG")
|
||||
-- bad frames
|
||||
local function bad(frames: any, label: string)
|
||||
local im = solid(4, 4, 0, 0, 0, 255)
|
||||
im.frames = frames
|
||||
@@ -132,7 +125,6 @@ do
|
||||
bad({ { image = still }, { image = still, delay = -1 } }, "negative delay")
|
||||
end
|
||||
|
||||
-- crafted bad input: a broken sequence number, a frame outside the canvas
|
||||
do
|
||||
local c = Cases[1]
|
||||
local s = c.data
|
||||
@@ -153,7 +145,6 @@ do
|
||||
t:check(Png.composite({} :: any) == nil, "composite of a non-image")
|
||||
end
|
||||
|
||||
-- fuzz
|
||||
do
|
||||
local samples = {}
|
||||
for _, c in Cases do
|
||||
|
||||
Reference in new issue
Block a user