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

This commit is contained in:
4DBug committed 2026-11-01 01:50:53 -05:00
1 parent 98b4ce533e
commit a6732d45f2
23 files changed
+46 -177

No files matched your search

+5 -15
View File
@@ -1,12 +1,5 @@
-- codecs/video/Mpeg1 tests, ported from mpeg1-luau tests/decode.luau and tests/robust.luau. Every frame bit-exact with
-- `ffmpeg -idct int` (the IDCT codecs/video/Dsp reproduces; frames with concealed macroblocks excepted). Against ffmpeg
-- (tools/fixtures/mpeg1.py): every stream decodes, one access unit at a time, to as many frames as ffmpeg's decode,
-- in display order; each frame's RGBA channel means within 1.5 of ffmpeg's; whole sampled frames within 2 MAE per
-- channel (IDCT and colour rounding) and, as yuv420p (frameImage), within a PSNR floor of ffmpeg -pix_fmt yuv420p;
-- the same stream written in random pieces through write() / decodeFrame() gives identical frames; a size change.
-- Robustness / API: bad arguments, pictures before the first sequence header, reset(), rgba = false, tags through
-- B-frame reordering, string input, truncated units, bit flips and garbage (never throws, recovers at an
-- I-picture), an oversized sequence header; frameImage; the fuzz no-throw pass.
-- codecs/video/Mpeg1 tests: every frame bit-exact with `ffmpeg -idct int` (concealed macroblocks excepted), the API.
-- Fixtures: tools/fixtures/mpeg1.py.
local T = require("@tests/T")
local Mpeg1 = require("@rosetta/codecs/video/Mpeg1")
local Base64 = require("@rosetta/core/Base64")
@@ -43,7 +36,6 @@ local function z64(s: string): buffer
return Deflate.zlib(b64(s)) :: buffer
end
-- mean absolute error per channel (r, g, b) between two RGBA8 buffers of n pixels, and the largest difference
local function mae(a: buffer, b: buffer, n: number): (number, number, number, number)
local sr, sg, sb, mx = 0, 0, 0, 0
for i = 0, n - 1 do
@@ -86,7 +78,6 @@ local MAE_LIMIT = 2
local totalExact, totalConcealed = 0, 0
local MEAN_LIMIT = 1.5
-- 1. every stream against ffmpeg
local worst, worstY, worstC = 0, 99, 99
for _, fx in STREAMS do
local name = fx.name
@@ -211,7 +202,7 @@ end
t:note("worst sampled-frame MAE %.3f (limit %d); worst yuv420p PSNR luma %.1f, chroma %.1f dB", worst, MAE_LIMIT, worstY, worstC)
t:note("%d frames bit-exact with ffmpeg -idct int, %d with concealed macroblocks (ffmpeg error concealment)", totalExact, totalConcealed)
-- 2. a size change mid-stream
-- a size change mid-stream
do
local file = b64(SizeChange.file)
local dec = Mpeg1.new()
@@ -235,7 +226,6 @@ do
end
end
-- 3. robustness and the API
local function slice(b: buffer, from: number, n: number): buffer
local out = buffer.create(n)
buffer.copy(out, 0, b, from, n)
@@ -254,7 +244,7 @@ do
t:eq(#ref, #main.units, "reference decode")
end
do -- bad arguments
do
local dec = Mpeg1.new()
t:check(dec:decode((nil :: any)) == nil, "decode(nil)")
t:check(dec:decode((42 :: any)) == nil, "decode(number)")
@@ -488,7 +478,7 @@ do -- a hostile sequence header: a huge size is rejected
t:eq(dec.width, 0, "oversized sequence header rejected")
end
-- 4. the fuzz pass: whole elementary streams (cut, mutated, garbage) through one decoder each
-- the fuzz pass: whole elementary streams (cut, mutated, garbage) through one decoder each
do
local samples = {}
for _, k in { 1, 9 } do