tests/codecs (a-m): comments: specs only
This commit is contained in:
1 parent
a80299dce0
commit
5f7f6005f6
24 files changed
+46
-181
No files matched your search
+2
-10
@@ -1,7 +1,5 @@
|
||||
-- codecs/audio/Aac tests: AudioSpecificConfig parsing (every fixture's esds, explicit SBR / PS signalling from fdkaac,
|
||||
-- crafted configs: PCE channel counts, 960-sample frames, Main / LTP object types), ADTS headers, raw frames decoded
|
||||
-- straight from ADTS against ffmpeg's float decode, the FIL extension hook on HE-AAC (implicit SBR), reset, errors,
|
||||
-- the fuzz no-throw pass on raw frames. Fixtures: tools/fixtures/m4a.py.
|
||||
-- codecs/audio/Aac tests: AudioSpecificConfig parsing, ADTS headers, raw frames against ffmpeg's float decode, errors.
|
||||
-- Fixtures: tools/fixtures/m4a.py.
|
||||
local T = require("@tests/T")
|
||||
local Aac = require("@rosetta/codecs/audio/Aac")
|
||||
local IsoBmff = require("@rosetta/containers/IsoBmff")
|
||||
@@ -13,7 +11,6 @@ local He = require("@tests/gen/m4a_he")
|
||||
|
||||
local t = T.suite("aac-codec")
|
||||
|
||||
-- ADTS frames of a stream: { offset, size } of the raw blocks
|
||||
local function frames(data: buffer): ({ { number } }, Aac.Adts?)
|
||||
local out, p, first = {}, 0, nil
|
||||
while true do
|
||||
@@ -28,7 +25,6 @@ local function frames(data: buffer): ({ { number } }, Aac.Adts?)
|
||||
return out, first
|
||||
end
|
||||
|
||||
-- ASCs from the M4A fixtures
|
||||
for _, c in Fx do
|
||||
if c.container == "m4a" then
|
||||
local r = Bytes.reader(buffer.fromstring(c.data))
|
||||
@@ -49,7 +45,6 @@ for _, c in He do
|
||||
end
|
||||
end
|
||||
|
||||
-- crafted configs
|
||||
do
|
||||
local asc = Aac.asc(2, 4, 2)
|
||||
local cfg = Aac.config(asc) :: Aac.Config
|
||||
@@ -90,7 +85,6 @@ do
|
||||
t:check(e4 and e4.code == Err.ARG, "decoder of a string")
|
||||
end
|
||||
|
||||
-- ADTS headers + raw frames against ffmpeg
|
||||
for _, c in Fx do
|
||||
if c.container ~= "adts" then
|
||||
continue
|
||||
@@ -148,7 +142,6 @@ for _, c in He do
|
||||
end
|
||||
end
|
||||
|
||||
-- errors
|
||||
do
|
||||
local dec = Aac.decoder(Aac.asc(2, 4, 2)) :: Aac.Decoder
|
||||
local _, e = dec:decode(buffer.fromstring("\x20\x00\x00\x00\x00"))
|
||||
@@ -158,7 +151,6 @@ do
|
||||
t:check(Aac.adts(buffer.fromstring("\255\241"), 0, 2) == nil, "short ADTS header")
|
||||
end
|
||||
|
||||
-- fuzz raw frames (stereo with every tool, mono, 5.1)
|
||||
do
|
||||
local pick = {}
|
||||
for _, c in Fx do
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
-- codecs/audio/Ac3 tests: the codec API under audio/ac3 and the container hook: header fields of every fixture layout,
|
||||
-- the CRC (a syncframe checks to 0), one-frame decodes against the reference (frame by frame, as a container feeds
|
||||
-- them), the block offsets, reset, argument / data errors, and a fuzz pass over single frames (CRC off).
|
||||
-- codecs/audio/Ac3 tests: header fields, the CRC (a syncframe checks to 0), one-frame decodes against the reference.
|
||||
-- Fixtures: tools/fixtures/ac3.py.
|
||||
local T = require("@tests/T")
|
||||
local Ac3 = require("@rosetta/codecs/audio/Ac3")
|
||||
@@ -38,7 +36,6 @@ for _, c in Fx do
|
||||
table.insert(frames, buffer.readstring(b, 0, h.frameSize))
|
||||
end
|
||||
|
||||
-- errors
|
||||
do
|
||||
local d = Ac3.decoder()
|
||||
local _, e = d:decode(buffer.create(10), 20)
|
||||
|
||||
+2
-13
@@ -1,9 +1,5 @@
|
||||
-- codecs/adpcm tests: every decoder kernel of codecs/audio/Adpcm against a reference decoder, bit-exact as s16
|
||||
-- (tools/fixtures/adpcm.py: ADX from ffmpeg and PS-ADPCM / DSP from our Python encoders decoded by vgmstream, Apple
|
||||
-- ima4 from ffmpeg, IMA nibble streams decoded by ffmpeg); ADX coefficients; the encoders (IMA nibbles, IMA WAV
|
||||
-- blocks, MS blocks) decoded back with a signal-to-noise floor; the Decoder layouts (seeking matches a straight
|
||||
-- read); Flash ADPCM by hand; a fuzz pass of random bytes through every kernel (ranges valid, contents random) and
|
||||
-- the layouts.
|
||||
-- codecs/adpcm tests: every kernel of codecs/audio/Adpcm bit-exact as s16 against a reference decoder, the encoders.
|
||||
-- Fixtures: tools/fixtures/adpcm.py (ADX and ima4 from ffmpeg; PS-ADPCM / DSP decoded by vgmstream).
|
||||
local T = require("@tests/T")
|
||||
local Adpcm = require("@rosetta/codecs/audio/Adpcm")
|
||||
local Decoder = require("@rosetta/codecs/audio/Adpcm/Decoder")
|
||||
@@ -12,7 +8,6 @@ local Sig = require("@tests/gen/adpcm_sig")
|
||||
|
||||
local t = T.suite("adpcm codec")
|
||||
|
||||
-- s16le reference vs interleaved f32: the count of differing samples and the first one
|
||||
local function compare(out: buffer, ref: string, count: number): (number, number)
|
||||
local r = buffer.fromstring(ref)
|
||||
local bad, first = 0, -1
|
||||
@@ -27,7 +22,6 @@ local function compare(out: buffer, ref: string, count: number): (number, number
|
||||
return bad, first
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ kernels
|
||||
for _, c in Cases do
|
||||
local src = buffer.fromstring(c.data)
|
||||
local ch, frames = c.ch, c.frames
|
||||
@@ -108,7 +102,6 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ encoders
|
||||
local function snr(x: buffer, y: buffer, count: number): number
|
||||
local sig, err = 0, 0
|
||||
for i = 0, count - 1 do
|
||||
@@ -123,7 +116,6 @@ end
|
||||
do
|
||||
local x = buffer.fromstring(Sig.data)
|
||||
local ch, n = Sig.channels, Sig.frames
|
||||
-- IMA nibbles, both nibble orders
|
||||
for _, hi in { true, false } do
|
||||
local raw = buffer.create((n * ch + 1) // 2)
|
||||
local st = buffer.create(8 * ch)
|
||||
@@ -139,7 +131,6 @@ do
|
||||
t:check(s > 20, string.format("ima encode (hi %s): %.1f dB", tostring(hi), s))
|
||||
t:check(buffer.readi32(st, 0) == buffer.readi32(ds, 0), "ima encoder and decoder end in the same state")
|
||||
end
|
||||
-- IMA WAV and MS blocks
|
||||
for _, kind in { "ima_wav", "ms" } do
|
||||
local ba = 512
|
||||
local spb = Decoder.blockFrames(kind, ba, ch) :: number
|
||||
@@ -174,7 +165,6 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ Decoder layouts
|
||||
local function readAll(dec: any, step: number): buffer
|
||||
local out = buffer.create(dec.frames * dec.channels * 4)
|
||||
local got = 0
|
||||
@@ -224,7 +214,6 @@ do
|
||||
t:eq(dec.frames, 3 * 4 * 28 + 28, "cut interleaved: the whole frames both channels have")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ fuzz
|
||||
local samples = {}
|
||||
for _, c in Cases do
|
||||
table.insert(samples, c.data)
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
-- codecs/audio/Alac tests: encoder -> decoder round trips over silence (zero runs), full-scale noise (uncompressed frames),
|
||||
-- tones, steps, 1 - 8 channels, 16 / 20 / 24 bits, partial and tiny frames, custom frame lengths; ffmpeg's ALAC
|
||||
-- packets (through containers/IsoBmff) decode to the source integers; the magic cookie (plain, behind frma / alac atoms,
|
||||
-- bad versions / depths); errors; the fuzz no-throw pass on packets. Fixtures: tools/fixtures/m4a.py.
|
||||
-- codecs/audio/Alac tests: encoder -> decoder round trips, ffmpeg's ALAC packets, the magic cookie, errors.
|
||||
-- Fixtures: tools/fixtures/m4a.py.
|
||||
local T = require("@tests/T")
|
||||
local Alac = require("@rosetta/codecs/audio/Alac")
|
||||
local IsoBmff = require("@rosetta/containers/IsoBmff")
|
||||
@@ -97,7 +95,6 @@ roundTrip("identical channels", 2, 16, 5000, function(i)
|
||||
return math.floor(math.sin(i * 0.02) * 20000)
|
||||
end)
|
||||
|
||||
-- ffmpeg's packets
|
||||
for _, c in Fx do
|
||||
if c.container == "m4a" then
|
||||
local r = Bytes.reader(buffer.fromstring(c.data))
|
||||
@@ -120,7 +117,6 @@ for _, c in Fx do
|
||||
end
|
||||
end
|
||||
|
||||
-- the cookie behind QuickTime atoms, bad cookies
|
||||
do
|
||||
local enc = Alac.encoder({ sampleRate = 48000, channels = 2 }) :: Alac.Encoder
|
||||
local plain = Alac.cookie(enc.config)
|
||||
@@ -149,7 +145,6 @@ do
|
||||
t:check(e5 and e5.code == Err.CORRUPT, "bad packet: " .. tostring(e5))
|
||||
end
|
||||
|
||||
-- fuzz the packet decoder
|
||||
do
|
||||
local enc = Alac.encoder({ sampleRate = 44100, channels = 2, bitDepth = 16 }) :: Alac.Encoder
|
||||
local src = table.create(2 * 3000, 0)
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
-- codecs/audio/ApeTag tests: APEv2 tags with and without a header, APEv1, multi-value items, binary items, an ID3v1
|
||||
-- tag after the APE tag, a tag inside a sub-range, malformed sizes / counts; the fuzz no-throw pass. The real files
|
||||
-- (wavpack -w, mac -t, ...) are covered by tests/audio/wavpack.luau and tests/audio/ape.luau.
|
||||
-- codecs/audio/ApeTag tests: hand-made APEv1 / APEv2 tags. The real files are in tests/audio/wavpack.luau and ape.luau.
|
||||
local T = require("@tests/T")
|
||||
local ApeTag = require("@rosetta/codecs/audio/ApeTag")
|
||||
|
||||
@@ -9,7 +7,6 @@ local t = T.suite("apetag")
|
||||
local function u32(v: number): string
|
||||
return string.char(v % 256, (v // 256) % 256, (v // 65536) % 256, (v // 16777216) % 256)
|
||||
end
|
||||
-- tag(items, version, header) -> the tag bytes; items = { { key, value, flags? } }
|
||||
local function tag(items: { any }, version: number, header: boolean): string
|
||||
local body = {}
|
||||
for _, it in items do
|
||||
@@ -41,11 +38,9 @@ do
|
||||
t:eq(#info.items, 6, "items")
|
||||
t:eq(info.items[5].kind, "binary", "binary kind")
|
||||
t:eq(info.items[5].value, "f.png\0PNG", "binary value")
|
||||
-- ID3v1 after it
|
||||
local s2 = s .. "TAG" .. string.rep("x", 125)
|
||||
local tags2, info2 = ApeTag.find(buffer.fromstring(s2), 0, #s2)
|
||||
t:check(tags2 and tags2.title == "Hello" and info2.stop == #s, "before ID3v1")
|
||||
-- inside a sub-range
|
||||
local s3 = "zz" .. s .. "yyy"
|
||||
local tags3, info3 = ApeTag.find(buffer.fromstring(s3), 2, 2 + #s)
|
||||
t:check(tags3 and tags3.title == "Hello" and info3.start == 12, "sub-range")
|
||||
|
||||
+2
-10
@@ -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))
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
-- codecs/font/Bitmap tests: 1-bit row pack / unpack round trips (MSB- and LSB-first, padded strides), the Font over a
|
||||
-- strike (glyphIndex / advance / rasterize / default glyph), Bitmap.strike of a bitmap font and of the first outline
|
||||
-- font from tools/fixtures/fonts.py (thresholded rasterization), and argument errors.
|
||||
-- codecs/font/Bitmap tests: 1-bit row pack / unpack, the Font over a strike, Bitmap.strike, argument errors.
|
||||
local T = require("@tests/T")
|
||||
local Bitmap = require("@rosetta/codecs/font/Bitmap")
|
||||
local Ttf = require("@rosetta/font/ttf")
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
-- codecs/compress/Brotli tests: every fixture stream (reference encoder: qualities 0..11, windows 10..24, text / font / generic
|
||||
-- modes, large windows) decodes to its corpus; consumedEnd; offsets inside a bigger buffer; the static dictionary;
|
||||
-- hand-made streams (empty, metadata, uncompressed); maxBytes; truncated / corrupted / random input returns nil, Err
|
||||
-- and never throws. Fixtures: tools/fixtures/brotli.py.
|
||||
-- codecs/compress/Brotli tests: reference encoder streams (qualities 0..11, windows 10..24), hand-made streams.
|
||||
-- Fixtures: tools/fixtures/brotli.py.
|
||||
local T = require("@tests/T")
|
||||
local Brotli = require("@rosetta/codecs/compress/Brotli")
|
||||
local Err = require("@rosetta/core/Err")
|
||||
@@ -10,14 +8,12 @@ local Fx = require("@tests/gen/brotli")
|
||||
|
||||
local t = T.suite("brotli")
|
||||
|
||||
-- the static dictionary
|
||||
do
|
||||
local d = Brotli.dictionary()
|
||||
t:check(d and buffer.len(d) == 122784, "dictionary size")
|
||||
t:eq(buffer.readstring(d :: buffer, 0, 8), "timedown", "dictionary starts with the length-4 words")
|
||||
end
|
||||
|
||||
-- every case
|
||||
local nbytes = 0
|
||||
for _, c in Fx.cases do
|
||||
local want = Fx.corpora[c.corpus]
|
||||
@@ -31,7 +27,6 @@ for _, c in Fx.cases do
|
||||
end
|
||||
t:note("%d fixture streams, %.1f MB decoded", #Fx.cases, nbytes / 1e6)
|
||||
|
||||
-- at an offset inside a bigger buffer, with trailing bytes
|
||||
do
|
||||
local c = Fx.cases[30]
|
||||
local big = buffer.create(#c.data + 13)
|
||||
@@ -41,7 +36,6 @@ do
|
||||
t:check(out and buffer.tostring(out) == Fx.corpora[c.corpus] and e == 5 + #c.data, "at an offset")
|
||||
end
|
||||
|
||||
-- hand-made streams
|
||||
do
|
||||
local bytes = T.bytes
|
||||
-- WBITS 16 (bit 0), ISLAST, ISLASTEMPTY: 0b110 = 6
|
||||
@@ -72,7 +66,6 @@ do
|
||||
t:check(ok and r1 == nil and r2.code == Err.ARG, "a non-buffer argument returns Err.ARG")
|
||||
end
|
||||
|
||||
-- maxBytes
|
||||
do
|
||||
local c
|
||||
for _, x in Fx.cases do
|
||||
@@ -110,7 +103,6 @@ do
|
||||
t:eq(bad, 0, "corrupted streams never decode to the original")
|
||||
end
|
||||
|
||||
-- truncation, corruption and garbage never throw
|
||||
do
|
||||
local samples = {}
|
||||
for i, c in Fx.cases do
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
-- codecs/compress/Bzip2 tests: every fixture stream (Python bz2 = libbzip2, block sizes 1..9, RLE1 run edges, block-boundary
|
||||
-- runs, random / skewed data, concatenated streams with trailing garbage) decodes exactly; offsets / consumedEnd;
|
||||
-- maxBytes; CRC mismatches are Err.CHECKSUM; truncations are Err.TRUNCATED; the fuzz no-throw pass.
|
||||
-- codecs/compress/Bzip2 tests: Python bz2 (libbzip2) streams decode exactly, CRC mismatches, truncations.
|
||||
-- Fixtures: tools/fixtures/bzip2.py.
|
||||
local T = require("@tests/T")
|
||||
local Bzip2 = require("@rosetta/codecs/compress/Bzip2")
|
||||
@@ -33,7 +31,6 @@ local function case(name: string): any
|
||||
error("no case " .. name)
|
||||
end
|
||||
|
||||
-- inside a bigger buffer, at an offset
|
||||
do
|
||||
local c = case("text/l9")
|
||||
local big = buffer.create(#c.data + 20)
|
||||
@@ -44,7 +41,6 @@ do
|
||||
t:eq(consumed, 7 + #c.data, "consumedEnd at an offset")
|
||||
end
|
||||
|
||||
-- maxBytes
|
||||
do
|
||||
local c = case("zeros/l9")
|
||||
local _, e = Bzip2.decompress(c.data, nil, nil, { maxBytes = 1000 })
|
||||
@@ -53,7 +49,6 @@ do
|
||||
t:check(ok ~= nil, "maxBytes = exact size")
|
||||
end
|
||||
|
||||
-- block CRC / stream CRC mismatches
|
||||
do
|
||||
local c = case("text/l9")
|
||||
local b = buffer.fromstring(c.data)
|
||||
@@ -84,7 +79,6 @@ do
|
||||
t:check(e3 and e3.code == Err.ARG, "bad offset")
|
||||
end
|
||||
|
||||
-- fuzz
|
||||
do
|
||||
local samples = {}
|
||||
for i, c in Fx.cases do
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
-- codecs/image/Dct tests: the islow inverse DCT against a double-precision reference (within 1 level per sample, as T.81
|
||||
-- annex A accuracy needs), forward DCT + quantiser against the reference transform (round to nearest of v / (8 q)),
|
||||
-- fdct -> idct round trips at q = 1 within 1 level, edge replication of fdctQuantize, and garbage coefficients never
|
||||
-- throw (outputs stay clamped). The bit-exact djpeg / cjpeg checks are in tests/image/jpeg.luau.
|
||||
-- codecs/image/Dct tests: the islow IDCT against a double-precision reference, the forward DCT + quantiser.
|
||||
-- The bit-exact djpeg / cjpeg checks are in tests/image/jpeg.luau.
|
||||
local T = require("@tests/T")
|
||||
local Dct = require("@rosetta/codecs/image/Dct")
|
||||
|
||||
@@ -62,7 +60,6 @@ do
|
||||
t:note("idct: worst error %d over 300 random blocks", worst)
|
||||
end
|
||||
|
||||
-- forward + quantiser
|
||||
do
|
||||
local worst = 0
|
||||
for _ = 1, 200 do
|
||||
@@ -91,7 +88,6 @@ do
|
||||
end
|
||||
end
|
||||
t:check(worst <= 0.75, "fdct + quantise within rounding of the float reference: " .. worst)
|
||||
-- round trip at q = 1
|
||||
local rt = 0
|
||||
for _ = 1, 100 do
|
||||
local src = buffer.create(64)
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
-- codecs/compress/Deflate tests: every fixture case (Python zlib, levels 0-9, every strategy, small windows, flushes, gzip
|
||||
-- headers, multi-member gzip) decodes; exact-size mode; checksum vectors; the compressor round-trips every corpus at
|
||||
-- every level (and its zlib / gzip framing); truncated / corrupted / random input returns nil, Err and never throws.
|
||||
-- Ported from deflate-luau tests/inflate.luau. Fixtures: tools/fixtures/deflate.py.
|
||||
-- codecs/compress/Deflate tests: Python zlib streams (levels 0-9, every strategy, gzip), the compressor round trips.
|
||||
-- Fixtures: tools/fixtures/deflate.py.
|
||||
local T = require("@tests/T")
|
||||
local Deflate = require("@rosetta/codecs/compress/Deflate")
|
||||
local Err = require("@rosetta/core/Err")
|
||||
@@ -19,7 +17,6 @@ local function decode(kind: string, b: buffer, ...: any): (buffer?, any)
|
||||
end
|
||||
end
|
||||
|
||||
-- checksum vectors
|
||||
t:eq(Deflate.crc32("123456789"), 0xCBF43926, "crc32 check value")
|
||||
t:eq(Deflate.crc32(""), 0, "crc32 empty")
|
||||
t:eq(Deflate.adler32("Wikipedia"), 0x11E60398, "adler32 Wikipedia")
|
||||
@@ -35,7 +32,6 @@ do
|
||||
t:eq(Deflate.crc32(b, 3, 17), Deflate.crc32(string.sub(s, 4, 20)), "crc32 range")
|
||||
end
|
||||
|
||||
-- every case decodes to its corpus
|
||||
local nbytes = 0
|
||||
for _, c in Fx.cases do
|
||||
local want = Fx.corpora[c.corpus]
|
||||
@@ -65,10 +61,8 @@ for _, c in Fx.cases do
|
||||
end
|
||||
t:note("%d fixture streams, %.1f MB decoded", #Fx.cases, nbytes / 1e6)
|
||||
|
||||
-- strings are accepted
|
||||
t:check(buffer.tostring((Deflate.zlib(Fx.cases[25].data))) == Fx.corpora[Fx.cases[25].corpus], "string input")
|
||||
|
||||
-- corrupted checksums
|
||||
do
|
||||
local z
|
||||
for _, c in Fx.cases do
|
||||
@@ -93,7 +87,6 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
-- hand-made streams
|
||||
do
|
||||
local bytes = T.bytes
|
||||
-- stored block "hi" then a fixed block with only end-of-block
|
||||
@@ -148,7 +141,6 @@ do
|
||||
t:check(e and e.code == Err.ARG, "bad level returns Err.ARG")
|
||||
end
|
||||
|
||||
-- truncation, corruption and garbage never throw
|
||||
do
|
||||
local samples = {}
|
||||
local kinds = {}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
-- codecs/model/Draco tests: Google's Draco test data (bitstreams 0.9 - 2.2) and files encoded by draco_encoder 1.5.7
|
||||
-- at every compression level, quantization and as point clouds, decoded and compared byte for byte (points, faces,
|
||||
-- every attribute's values per point, as CRCs) with libdraco's own decoder (tools/fixtures/_draco_dump.cc), kd-tree
|
||||
-- point clouds included; argument errors; the fuzz no-throw pass (which also fails on any internal error the
|
||||
-- decoder's safety net caught). Fixtures: tools/fixtures/draco.py.
|
||||
-- codecs/model/Draco tests: Google's test data and draco_encoder 1.5.7 files against libdraco's decoder.
|
||||
-- Fixtures: tools/fixtures/draco.py (dumps from tools/fixtures/_draco_dump.cc).
|
||||
local T = require("@tests/T")
|
||||
local Draco = require("@rosetta/codecs/model/Draco")
|
||||
local Err = require("@rosetta/core/Err")
|
||||
@@ -50,14 +47,12 @@ for _, c in Cases do
|
||||
end
|
||||
t:note("%d files decoded exactly like libdraco (%d kd-tree point clouds), %d rejected by both", counts.exact, counts.kd, counts.rejected)
|
||||
|
||||
-- the attribute lookup and the header
|
||||
local first = Cases[1]
|
||||
local info = Draco.info(first.data)
|
||||
t:check(info and (info.kind == "mesh" or info.kind == "points"), "info")
|
||||
t:check(Draco.sniff(buffer.fromstring(first.data)), "sniff")
|
||||
t:check(not Draco.sniff(buffer.fromstring("DRAC")), "sniff short")
|
||||
|
||||
-- errors
|
||||
local _, e1 = Draco.decode(buffer.fromstring("NOTDRACO......"))
|
||||
t:check(e1 and e1.code == Err.CORRUPT, "not Draco data: " .. tostring(e1))
|
||||
local _, e2 = Draco.decode(buffer.fromstring("DRACO\9\0\1\1\0\0"))
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
-- codecs/image/Etc tests: random ETC1 / ETC2 (every mode: individual, differential, T, H, planar; RGB A1 opaque and
|
||||
-- transparent; RGBA with EAC alpha) and EAC R11 / RG11 (unsigned, signed, multiplier 0) blocks against Godot 4's
|
||||
-- decode (etcpak); odd sizes; the 16-bit EAC output; errors; the fuzz no-throw pass. Fixtures: tools/fixtures/etc.py.
|
||||
-- codecs/image/Etc tests: random ETC1 / ETC2 / EAC blocks against Godot 4's decode (etcpak), the 16-bit EAC output.
|
||||
-- Fixtures: tools/fixtures/etc.py.
|
||||
local T = require("@tests/T")
|
||||
local Etc = require("@rosetta/codecs/image/Etc")
|
||||
local Fx = require("@tests/gen/etc")
|
||||
@@ -99,7 +98,6 @@ for _, c in Fx do
|
||||
end
|
||||
t:check(ok, c.name .. ": rgba16 ~ rgba8")
|
||||
end
|
||||
-- from / into offsets
|
||||
local big = buffer.create(buffer.len(src) + 3)
|
||||
buffer.copy(big, 3, src)
|
||||
local out = buffer.create(n * 4 + 4)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
-- codecs/compress/Explode tests: PKWARE DCL streams written by StormLib's SCompImplode (tools/fixtures/mpq.py:
|
||||
-- text, noise, a short repeat, zeros) decompress to the source bytes; maxOut stops early; hand-made streams with
|
||||
-- coded literals; bad headers and truncations; the fuzz pass.
|
||||
-- codecs/compress/Explode tests: PKWARE DCL streams from StormLib's SCompImplode, hand-made streams, bad headers.
|
||||
-- Fixtures: tools/fixtures/mpq.py.
|
||||
local T = require("@tests/T")
|
||||
local Explode = require("@rosetta/codecs/compress/Explode")
|
||||
local Crc32 = require("@rosetta/core/Crc32")
|
||||
|
||||
+2
-13
@@ -1,9 +1,5 @@
|
||||
-- codecs/video/H263 tests. Against `ffmpeg -idct int` (tools/fixtures/h263.py): H.263 streams (sub-QCIF .. 4CIF, GOB
|
||||
-- headers, DQUANT, q 1 .. high quantisers), H.263+ PLUSPTYPE streams (custom sizes, sizes that are not a multiple of
|
||||
-- 16, the rounding type, unrestricted vectors with reversible codes, slice structure) and Sorenson Spark streams (standard, 8-bit and
|
||||
-- 16-bit custom sizes, 11-bit escapes, high motion, disposable inter pictures) decode one picture at a time to exactly
|
||||
-- ffmpeg's planes, every frame; header info; frameImage; the registry's decoders (h263, flv1); unsupported options are
|
||||
-- UNSUPPORTED; truncated and corrupted pictures never throw; the fuzz no-throw pass.
|
||||
-- codecs/video/H263 tests: H.263, H.263+ and Sorenson Spark streams bit-exact against `ffmpeg -idct int`.
|
||||
-- Fixtures: tools/fixtures/h263.py.
|
||||
local T = require("@tests/T")
|
||||
local H263 = require("@rosetta/codecs/video/H263")
|
||||
local Video = require("@rosetta/codecs/video/Video")
|
||||
@@ -55,7 +51,6 @@ local function crcs(f: any): (number, number, number)
|
||||
return planeCrc(f.y, f.stride, w, h), planeCrc(f.cb, f.stride // 2, cw, ch), planeCrc(f.cr, f.stride // 2, cw, ch)
|
||||
end
|
||||
|
||||
-- differing luma samples against a reference frame (detail on a mismatch)
|
||||
local function lumaDiff(f: any, ref: buffer): (number, number)
|
||||
local n, first = 0, -1
|
||||
for y = 0, f.height - 1 do
|
||||
@@ -71,7 +66,6 @@ local function lumaDiff(f: any, ref: buffer): (number, number)
|
||||
return n, first
|
||||
end
|
||||
|
||||
-- 1. every stream against ffmpeg, bit-exact
|
||||
local total = 0
|
||||
local disposables = 0
|
||||
for _, fx in STREAMS do
|
||||
@@ -117,7 +111,6 @@ for _, fx in STREAMS do
|
||||
end
|
||||
t:check(disposables > 0, "disposable Sorenson pictures decoded (" .. disposables .. ")")
|
||||
|
||||
-- 2. header info
|
||||
do
|
||||
local fx = STREAMS[8] -- plus_custom
|
||||
local file = b64(fx.file)
|
||||
@@ -136,14 +129,12 @@ do
|
||||
t:check(e ~= nil and e.code == Err.CORRUPT, "no start code: CORRUPT")
|
||||
end
|
||||
|
||||
-- 3. unsupported H.263+ options
|
||||
for name, data in BAD do
|
||||
local dec = H263.new()
|
||||
local f, e = dec:decode(b64(data))
|
||||
t:check(f == nil and e ~= nil and e.code == Err.UNSUPPORTED, name .. ": UNSUPPORTED (" .. tostring(e) .. ")")
|
||||
end
|
||||
|
||||
-- 4. frameImage
|
||||
do
|
||||
local fx = STREAMS[14]
|
||||
local dec = H263.new({ flv = true })
|
||||
@@ -159,7 +150,6 @@ do
|
||||
t:check(dec:decode(42 :: any) == nil, "decode of a non-buffer is nil")
|
||||
end
|
||||
|
||||
-- 5. the registry's decoders
|
||||
do
|
||||
t:check(Video.fromFourcc("H263") == "h263" and Video.fromFourcc("s263") == "h263" and Video.fromFourcc("FLV1") == "flv1", "registry names")
|
||||
t:check(Video.canDecode("h263") and Video.canDecode("flv1"), "registry decoders")
|
||||
@@ -191,7 +181,6 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
-- 6. robustness: truncated and corrupted pictures, garbage (never throws), the fuzz pass
|
||||
do
|
||||
local samples = {}
|
||||
for _, idx in { 1, 6, 8, 10, 11, 13, 16 } do
|
||||
|
||||
+2
-10
@@ -1,8 +1,5 @@
|
||||
-- codecs/video/H264 tests: libx264 streams at many settings (Baseline / Main / High, CAVLC / CABAC, B frames, references,
|
||||
-- weighted prediction, 8x8 transforms, scaling matrices, slices, odd sizes with cropping, ...) decoded and compared
|
||||
-- per frame with ffmpeg's decoder (CRC-32 of the yuv420p planes, bit-exact); the AVCC (avcC + length-prefixed
|
||||
-- samples) and NAL-at-a-time paths; pts propagation; UNSUPPORTED streams (interlaced, 4:2:2, 4:4:4, 10-bit); error
|
||||
-- codes; and the fuzz no-throw pass. Fixtures: tools/fixtures/h264.py.
|
||||
-- codecs/video/H264 tests: libx264 streams at many settings, per frame against ffmpeg (CRC-32 of yuv420p planes).
|
||||
-- Fixtures: tools/fixtures/h264.py.
|
||||
local T = require("@tests/T")
|
||||
require("@rosetta/host") -- LuaJIT: the trace limits the api sets (host/init.luau)
|
||||
local H264 = require("@rosetta/codecs/video/H264")
|
||||
@@ -13,7 +10,6 @@ local Bad = require("@tests/gen/h264_bad")
|
||||
|
||||
local t = T.suite("h264")
|
||||
|
||||
-- 1. every stream, whole, against ffmpeg
|
||||
local nframes = 0
|
||||
for _, c in Cases do
|
||||
local frames, err = H264.decodeAll(c.data)
|
||||
@@ -33,7 +29,6 @@ for _, c in Cases do
|
||||
end
|
||||
t:note("%d streams, %d frames bit-exact with ffmpeg", #Cases, nframes)
|
||||
|
||||
-- 2. AVCC samples, NAL-at-a-time input, pts
|
||||
local function splitAnnexB(s: string): { string }
|
||||
local out = {}
|
||||
local i = 1
|
||||
@@ -107,13 +102,11 @@ for _, c in Cases do
|
||||
end
|
||||
end
|
||||
|
||||
-- 3. unsupported streams
|
||||
for _, c in Bad do
|
||||
local frames, err = H264.decodeAll(c.data)
|
||||
t:check(frames == nil and err and err.code == c.code, c.name .. ": " .. tostring(err))
|
||||
end
|
||||
|
||||
-- 4. error codes
|
||||
do
|
||||
local _, e1 = H264.decodeAll(123 :: any)
|
||||
t:check(e1 and e1.code == Err.ARG, "decode of a number: ARG")
|
||||
@@ -134,7 +127,6 @@ do
|
||||
t:check(ld and #ld == #c.frames and Crc32.of(ld[#ld].image.pixels) == c.frames[#c.frames], "lowDelay on a P-only stream")
|
||||
end
|
||||
|
||||
-- 5. fuzz: streams with damaged bytes / truncations must never throw
|
||||
local samples = {}
|
||||
for _, c in Cases do
|
||||
if #c.data < 20000 and #samples < 14 then
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
-- codecs/video/H264 conformance: a selection of the ITU-T H.264.1 (JVT) conformance bitstreams (Baseline / Main / Extended
|
||||
-- without SP / High: CAVLC, CABAC, B frames, weighted prediction, multiple slices, MMCO / long-term references,
|
||||
-- frame_num gaps, cropping, PCM, 8x8 transforms, scaling matrices, ...) decoded bit-exact against the reference
|
||||
-- decoder's yuv (JM, shipped in each zip; ffmpeg where there is none), and interlaced / SP / 4:2:2 streams refused
|
||||
-- with UNSUPPORTED. Fixtures: tools/fixtures/h264_jvt.py (downloaded from itu.int; skipped when unreachable).
|
||||
-- codecs/video/H264 conformance: ITU-T H.264.1 (JVT) bitstreams bit-exact against the JM yuv (ffmpeg where none).
|
||||
-- Fixtures: tools/fixtures/h264_jvt.py (downloaded from itu.int; skipped when unreachable).
|
||||
local T = require("@tests/T")
|
||||
require("@rosetta/host") -- LuaJIT: the trace limits the api sets (host/init.luau)
|
||||
local H264 = require("@rosetta/codecs/video/H264")
|
||||
|
||||
+6
-14
@@ -1,9 +1,5 @@
|
||||
-- codecs/image/Jpeg tests (the Motion-JPEG side; tests/image/jpeg.luau covers the still-image decoder and encoder through
|
||||
-- image/jpeg): ffmpeg mjpeg frames (4:2:0, 4:2:2, 4:4:4, odd sizes, stripped DHT, AVI1 + junk after EOI) decoded
|
||||
-- to yuv420p bit-exact with libjpeg-turbo's IDCT planes (TurboJPEG) and to rgba8 bit-exact with djpeg, and within
|
||||
-- PSNR thresholds of ffmpeg's own decode; an interlaced AVI1 frame (two fields) woven; the yuv420p encoder
|
||||
-- byte-identical to TurboJPEG's tj3CompressFromYUV8, read back by djpeg (exact) and ffmpeg (PSNR); the API's
|
||||
-- arguments; the fuzz no-throw pass. Fixtures: tools/fixtures/mjpeg.py.
|
||||
-- codecs/image/Jpeg tests (Motion-JPEG; still images are in tests/image/jpeg.luau): ffmpeg mjpeg frames, the encoder.
|
||||
-- Fixtures: tools/fixtures/mjpeg.py.
|
||||
local T = require("@tests/T")
|
||||
local Jpeg = require("@rosetta/codecs/image/Jpeg")
|
||||
local Crc32 = require("@rosetta/core/Crc32")
|
||||
@@ -37,7 +33,6 @@ for _, c in Enc do
|
||||
c.want = b64(c.want)
|
||||
end
|
||||
|
||||
-- PSNR of n bytes of a at ao against b at bo
|
||||
local function psnr(a: buffer, ao: number, b: buffer, bo: number, n: number): number
|
||||
local se = 0
|
||||
for i = 0, n - 1 do
|
||||
@@ -50,7 +45,6 @@ local function psnr(a: buffer, ao: number, b: buffer, bo: number, n: number): nu
|
||||
return 10 * math.log10(255 * 255 * n / se)
|
||||
end
|
||||
|
||||
-- PSNR of the RGB channels of two rgba8 buffers of n pixels
|
||||
local function psnrRgb(a: buffer, b: buffer, n: number): number
|
||||
local se = 0
|
||||
for i = 0, n - 1 do
|
||||
@@ -71,7 +65,7 @@ local function hasDht(s: string): boolean
|
||||
return at ~= nil and sos ~= nil and at < sos
|
||||
end
|
||||
|
||||
-- 1. ffmpeg's frames: yuv420p (TurboJPEG planes) and rgba8 (djpeg) bit-exact, PSNR against ffmpeg's decode
|
||||
-- yuv420p bit-exact with TurboJPEG's planes, rgba8 bit-exact with djpeg, PSNR against ffmpeg's decode
|
||||
do
|
||||
local frames, worstY, worstC, worstRgb = 0, 99, 99, 99
|
||||
for _, s in Fx.streams do
|
||||
@@ -118,7 +112,7 @@ do
|
||||
t:note("%d ffmpeg mjpeg frames bit-exact (yuv420p: TurboJPEG, rgba8: djpeg); worst PSNR against ffmpeg: luma %.1f, chroma %.1f, rgba %.1f dB", frames, worstY, worstC, worstRgb)
|
||||
end
|
||||
|
||||
-- 2. an interlaced frame: two fields (AVI1 polarity 1) woven, field 1 on the even rows
|
||||
-- an interlaced frame: two fields (AVI1 polarity 1) woven, field 1 on the even rows
|
||||
do
|
||||
local F = Fx.fields
|
||||
local b = buffer.fromstring(F.data)
|
||||
@@ -140,7 +134,7 @@ do
|
||||
t:check(Jpeg.info(b).avi1 == 1, "fields: info.avi1")
|
||||
end
|
||||
|
||||
-- 3. the yuv420p encoder: byte-identical with TurboJPEG, read back by djpeg (exact) and ffmpeg (PSNR)
|
||||
-- the yuv420p encoder: byte-identical with TurboJPEG's tj3CompressFromYUV8
|
||||
do
|
||||
local exact = 0
|
||||
for _, c in Enc do
|
||||
@@ -193,7 +187,6 @@ do
|
||||
t:check(sd.meta.text and sd.meta.text.comment == "hello" and sd.meta.dpi and sd.meta.dpi.x == 72, "segments and density")
|
||||
end
|
||||
|
||||
-- 4. the API: ranges, options, fallbacks, errors
|
||||
do
|
||||
local s = Fx.streams[1]
|
||||
local data = s.frames[1].data
|
||||
@@ -237,7 +230,7 @@ do
|
||||
t:note("%d truncated frames, %d decoded partially", cuts, partial)
|
||||
end
|
||||
|
||||
-- 5. speed (a note; tools/bench.luau has the real numbers)
|
||||
-- speed (a note; tools/bench.luau has the real numbers)
|
||||
do
|
||||
local s = Fx.streams[1]
|
||||
local frames = {}
|
||||
@@ -254,7 +247,6 @@ do
|
||||
t:note("%dx%d yuv420p decode: %.0f fps", s.width, s.height, n / (os.clock() - t0))
|
||||
end
|
||||
|
||||
-- 6. fuzz
|
||||
do
|
||||
local samples = {}
|
||||
for k, s in Fx.streams do
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
-- codecs/text/Json tests: the JSONTestSuite parsing corpus (y_ must parse to Python's value, n_ must fail, i_ must not
|
||||
-- throw), Python json.dumps output in four styles parsed and reproduced byte for byte (compact sorted, ordered,
|
||||
-- indent 2, ensure_ascii), events / lines / decodeAt / writer, options, error codes, and the fuzz pass.
|
||||
-- codecs/text/Json tests: the JSONTestSuite corpus, Python json.dumps output reproduced byte for byte, the API.
|
||||
-- Fixtures: tools/fixtures/json.py.
|
||||
local T = require("@tests/T")
|
||||
local Json = require("@rosetta/codecs/text/Json")
|
||||
@@ -47,7 +45,7 @@ local function fromEvents(s: string): (any, any)
|
||||
return top, nil
|
||||
end
|
||||
|
||||
-- 1. JSONTestSuite
|
||||
-- JSONTestSuite: y_ must parse to Python's value, n_ must fail, i_ must not throw
|
||||
local counts = { y = 0, n = 0, i = 0, iok = 0 }
|
||||
for _, c in Suite do
|
||||
local v, err = Json.decode(c.data)
|
||||
@@ -71,7 +69,6 @@ for _, c in Suite do
|
||||
end
|
||||
t:note("JSONTestSuite: %d y_ accepted, %d n_ rejected, %d of %d i_ accepted", counts.y, counts.n, counts.iok, counts.i)
|
||||
|
||||
-- 2. Python's json.dumps output: parse, compare, re-encode byte for byte
|
||||
for i, c in Corpus do
|
||||
local v, err = Json.decode(c.compact)
|
||||
t:check(v ~= nil, "corpus " .. i .. ": " .. tostring(err))
|
||||
@@ -85,7 +82,6 @@ for i, c in Corpus do
|
||||
t:eq(Canon.of(Json.decode(c.pretty)), c.canon, "corpus " .. i .. ": pretty parse")
|
||||
end
|
||||
|
||||
-- 3. options and API
|
||||
do
|
||||
local v = Json.decode('[12345678901234567890, -9007199254740993, 9007199254740991, 1.5e300]', { bigInts = "string" })
|
||||
t:eq(v[1], "12345678901234567890", "bigInts string")
|
||||
@@ -122,7 +118,6 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
-- 4. streaming: lines, decodeAt, writer
|
||||
do
|
||||
local got = {}
|
||||
for _, v in Json.lines('{"a":1}\n[2]\n"x"\n 3 ') do
|
||||
@@ -170,7 +165,6 @@ do
|
||||
t:check(w5:tostring() == nil, "writer: unclosed")
|
||||
end
|
||||
|
||||
-- 5. errors
|
||||
local function code(s: string, opts: any?): string?
|
||||
local _, e = Json.decode(s, opts)
|
||||
return e and e.code
|
||||
@@ -189,7 +183,6 @@ do
|
||||
t:eq(e and e.offset, 6, "error offset")
|
||||
end
|
||||
|
||||
-- 6. fuzz
|
||||
local samples = {}
|
||||
for i = 1, 40 do
|
||||
table.insert(samples, Corpus[i].compact)
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
-- codecs/video/Legacy tests: Cinepak (24-bit, grey, 8-bit palettised, several strips, a 92x68 size), Microsoft Video 1
|
||||
-- (16-bit, 8-bit with an AVI palette), QuickTime RLE (depths 1 / 2 / 4 / 8 with colour tables, default Macintosh
|
||||
-- tables and grey ramps; 16 / 24 / 32-bit and grey from ffmpeg) and QuickTime SMC, in AVI, MOV and MKV: every frame
|
||||
-- equals ffmpeg's decode (CRC-32 of rgba); seeking; the registry entries; the fuzz pass on each codec's packet decoder.
|
||||
-- codecs/video/Legacy tests: Cinepak, MS Video 1, QuickTime RLE and SMC: every frame equals ffmpeg's (CRC-32 of rgba).
|
||||
-- Fixtures: tools/fixtures/legacy.py.
|
||||
local T = require("@tests/T")
|
||||
local F = require("@rosetta")
|
||||
@@ -12,7 +9,6 @@ local Fx = require("@tests/gen/legacy_cases")
|
||||
|
||||
local t = T.suite("legacy")
|
||||
|
||||
-- the registry
|
||||
t:eq(Video.fromFourcc("cvid"), "cinepak", "cvid")
|
||||
t:eq(Video.fromFourcc("CRAM"), "msvideo1", "CRAM")
|
||||
t:eq(Video.fromFourcc("msvc"), "msvideo1", "msvc")
|
||||
@@ -50,7 +46,6 @@ for _, c in Fx do
|
||||
v:seek(0)
|
||||
local f = v:nextFrame()
|
||||
t:check(f ~= nil and Crc32.of(f.image.pixels) == c.frames[1], label .. ": seek(0)")
|
||||
-- packets for the fuzz pass
|
||||
local dmx = v.demuxer
|
||||
local tr = dmx:track("video")
|
||||
if not samples[c.codec] then
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
-- codecs/compress/Lz4 tests: every reference block (python-lz4 fast at accelerations 1 / 4 / 16, HC 4 / 9 / 12)
|
||||
-- decodes to its corpus, with and without the size; our encoder's blocks decode with the reference (fixture verdicts)
|
||||
-- and round trip here; linked blocks through decodeInto's history; error codes; truncated / mutated / random blocks
|
||||
-- never throw. Fixtures: tools/fixtures/lz4.py.
|
||||
-- codecs/compress/Lz4 tests: python-lz4 blocks (fast 1 / 4 / 16, HC 4 / 9 / 12), our encoder, linked blocks.
|
||||
-- Fixtures: tools/fixtures/lz4.py.
|
||||
local T = require("@tests/T")
|
||||
local Lz4 = require("@rosetta/codecs/compress/Lz4")
|
||||
local Err = require("@rosetta/core/Err")
|
||||
@@ -63,7 +61,6 @@ do
|
||||
t:check(b2 ~= nil, "second half")
|
||||
end
|
||||
|
||||
-- errors
|
||||
do
|
||||
local _, e1 = Lz4.decompress("")
|
||||
t:check(e1 and e1.code == Err.TRUNCATED, "empty: " .. tostring(e1))
|
||||
|
||||
+2
-10
@@ -1,7 +1,5 @@
|
||||
-- codecs/compress/Lzma tests: every fixture (liblzma through Python's lzma module and the xz CLI: presets 0-9 and -e, lc / lp /
|
||||
-- pb variants, raw LZMA1 / LZMA2, .lzma files, xz with every check type, BCJ and delta filters, multiple blocks,
|
||||
-- multiple streams and stream padding) decodes to its corpus; consumed offsets; checksum / size / truncation errors;
|
||||
-- maxBytes; the fuzz no-throw pass. Fixtures: tools/fixtures/lzma.py.
|
||||
-- codecs/compress/Lzma tests: liblzma (Python lzma, the xz CLI) .lzma / .xz / raw streams, check and size errors.
|
||||
-- Fixtures: tools/fixtures/lzma.py.
|
||||
local T = require("@tests/T")
|
||||
local Lzma = require("@rosetta/codecs/compress/Lzma")
|
||||
local Err = require("@rosetta/core/Err")
|
||||
@@ -34,7 +32,6 @@ for _, c in Fx.cases do
|
||||
end
|
||||
t:note("%d fixture streams, %.1f MB decoded", #Fx.cases, nbytes / 1e6)
|
||||
|
||||
-- at an offset inside a bigger buffer, with trailing bytes
|
||||
do
|
||||
for _, c in Fx.cases do
|
||||
if c.kind == "xz" and c.name == "text/xz-6" then
|
||||
@@ -47,7 +44,6 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
-- errors
|
||||
do
|
||||
local xz, xzc
|
||||
for _, c in Fx.cases do
|
||||
@@ -60,11 +56,9 @@ do
|
||||
-- the check field: the last bytes before the index; flip a data bit near the end of the block instead
|
||||
local b = buffer.fromstring(xzc.data)
|
||||
local n = buffer.len(b)
|
||||
-- footer magic
|
||||
buffer.writeu8(b, n - 1, 0)
|
||||
local _, e1 = Lzma.xz(b)
|
||||
t:check(e1 and (e1.code == Err.CORRUPT or e1.code == Err.CHECKSUM), "bad footer: " .. tostring(e1))
|
||||
-- the stream header CRC
|
||||
local b2 = buffer.fromstring(xz.data)
|
||||
buffer.writeu8(b2, 8, bit32.bxor(buffer.readu8(b2, 8), 1))
|
||||
local _, e2 = Lzma.xz(b2)
|
||||
@@ -83,7 +77,6 @@ do
|
||||
-- truncations are TRUNCATED or CORRUPT, never a throw
|
||||
local _, e4 = Lzma.xz(buffer.fromstring(string.sub(xzc.data, 1, #xzc.data // 2)))
|
||||
t:check(e4 and e4.code == Err.TRUNCATED, "truncated xz: " .. tostring(e4))
|
||||
-- maxBytes
|
||||
local _, e5 = Lzma.xz(xzc.data, nil, nil, { maxBytes = 1000 })
|
||||
t:check(e5 and e5.code == Err.LIMIT, "maxBytes: " .. tostring(e5))
|
||||
local ok, r1, r2 = pcall(Lzma.xz, 5 :: any)
|
||||
@@ -107,7 +100,6 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
-- fuzz
|
||||
do
|
||||
local samples = {}
|
||||
for i, c in Fx.cases do
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
-- codecs/compress/Lzw tests: GIF (LSB) and TIFF (MSB, early change) code streams from Pillow / libtiff decode to their data;
|
||||
-- our encoder round-trips random and structured data at every GIF minimum code size and through table resets; the
|
||||
-- output limit, truncated and corrupt streams; the fuzz no-throw pass. Fixtures: tools/fixtures/lzw.py.
|
||||
-- codecs/compress/Lzw tests: GIF (LSB) and TIFF (MSB, early change) streams from Pillow / libtiff, the encoder.
|
||||
-- Fixtures: tools/fixtures/lzw.py.
|
||||
local T = require("@tests/T")
|
||||
local Lzw = require("@rosetta/codecs/compress/Lzw")
|
||||
local Fx = require("@tests/gen/lzw")
|
||||
@@ -13,7 +12,6 @@ local function dec(codes: buffer, n: number, variant: string, min: number?): (st
|
||||
return buffer.tostring(out), got, err
|
||||
end
|
||||
|
||||
-- reference streams
|
||||
for _, c in Fx.gif do
|
||||
local s, n, err = dec(buffer.fromstring(c.codes), #c.data, "gif", c.min)
|
||||
t:check(err == nil, "gif " .. c.name .. ": " .. tostring(err))
|
||||
@@ -28,7 +26,6 @@ for _, c in Fx.tiff do
|
||||
end
|
||||
t:note("%d GIF and %d TIFF reference streams decode", #Fx.gif, #Fx.tiff)
|
||||
|
||||
-- round trips
|
||||
local rand = T.rng(3)
|
||||
local function data(n: number, kind: number, max: number): buffer
|
||||
local b = buffer.create(n)
|
||||
@@ -77,7 +74,6 @@ do
|
||||
t:check(buffer.readstring(out, 10, 100) == buffer.readstring(big, 100, 100), "sub-range data")
|
||||
end
|
||||
|
||||
-- limits, truncation, corruption
|
||||
do
|
||||
local d = data(1000, 2, 16)
|
||||
local codes = Lzw.encode(d, 0, 1000, "gif", 4)
|
||||
@@ -94,7 +90,6 @@ do
|
||||
t:check(err4 == "corrupt", "bad min code size")
|
||||
end
|
||||
|
||||
-- fuzz
|
||||
do
|
||||
local samples = {}
|
||||
for i, c in Fx.gif do
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
-- codecs/model/Mat4 tests: compose / decompose round trips (with a mirrored axis), strict decompose refusing shear,
|
||||
-- quaternion <-> matrix, Euler orders, the affine inverse, row-major conversion, points, the normal matrix.
|
||||
-- codecs/model/Mat4 tests: compose / decompose, quaternions, Euler orders, the affine inverse, the normal matrix.
|
||||
local T = require("@tests/T")
|
||||
local Mat4 = require("@rosetta/codecs/model/Mat4")
|
||||
|
||||
|
||||
Reference in new issue
Block a user