tests/codecs (a-m): comments: specs only

This commit is contained in:
4DBug committed 2026-11-01 01:50:19 -05:00
1 parent a80299dce0
commit 5f7f6005f6
24 files changed
+46 -181

No files matched your search

+2 -10
View File
@@ -1,6 +1,5 @@
-- codecs/image/Bcn tests: random BC1..BC7 blocks (every BC7 and BC6H mode, the BC1 3-colour mode, odd sizes) against
-- Pillow's and Godot's (bcdec) decodes; BC6H floats against Godot; the encoders (BC1 / BC3 / BC4 / BC5) within reach
-- of Pillow's encoder PSNR, exact on flat blocks; argument errors; the fuzz no-throw pass. Fixtures: tools/fixtures/bcn.py.
-- codecs/image/Bcn tests: random BC1..BC7 blocks against Pillow's and Godot's (bcdec) decodes, the encoders.
-- Fixtures: tools/fixtures/bcn.py.
local T = require("@tests/T")
local Bcn = require("@rosetta/codecs/image/Bcn")
local Half = require("@rosetta/codecs/image/Half")
@@ -8,7 +7,6 @@ local Fx = require("@tests/gen/bcn")
local t = T.suite("bcn")
-- the largest per-byte difference between two rgba8 buffers (channels: which of r, g, b, a count)
local function maxDiff(a: buffer, b: buffer, n: number, channels: { number }): (number, number)
local worst, at = 0, -1
for i = 0, n - 1 do
@@ -23,7 +21,6 @@ local function maxDiff(a: buffer, b: buffer, n: number, channels: { number }): (
end
local RGBA, RGB, RG, R = { 0, 1, 2, 3 }, { 0, 1, 2 }, { 0, 1 }, { 0 }
-- which channels each reference defines, and the allowed difference to it
local PILLOW: { [string]: { any } } = {
bc1 = { RGBA, 0 },
bc2 = { RGBA, 0 },
@@ -82,7 +79,6 @@ for _, c in Fx.cases do
stats.godot += 1
end
end
-- into a bigger buffer at an offset, from an offset
local big = buffer.create(buffer.len(src) + 5)
buffer.copy(big, 5, src)
local bpp = if Bcn.FLOAT[c.kind] then 16 else 4
@@ -113,7 +109,6 @@ do
end
end
-- encoders
local function psnr(a: buffer, b: buffer, n: number, channels: { number }): number
local se = 0
for i = 0, n - 1 do
@@ -194,7 +189,6 @@ do
end
end
-- Half
do
t:eq(Half.fromFloat(1), 0x3C00, "half 1")
t:eq(Half.fromFloat(-2), 0xC000, "half -2")
@@ -212,7 +206,6 @@ do
t:check(ok, "half round trip of every pattern")
end
-- errors
do
local _, e1 = Bcn.decode("bc9", buffer.create(8), 0, 4, 4)
t:check(e1 and string.find(e1, "unsupported") ~= nil, "unknown kind")
@@ -224,7 +217,6 @@ do
t:check(e4 ~= nil, "short pixels")
end
-- fuzz: random block data of every kind and size
local samples = {}
for _, c in Fx.cases do
table.insert(samples, buffer.fromstring(c.data))