diff --git a/tests/video/_common.luau b/tests/video/_common.luau index cf5c1b4..354eaec 100644 --- a/tests/video/_common.luau +++ b/tests/video/_common.luau @@ -1,6 +1,4 @@ --- tests/video/_common: shared checks for the video container tests (mkv, avi, y4m, mpegts, mpegps, mp4): a demuxer's --- tracks and packets against ffprobe's, decoded frames against ffmpeg's (CRC-32 for bit-exact codecs, PSNR for the --- others), audio through the api's hook against ffmpeg's f32 decode, seeking. Not a test by itself. +-- tests/video/_common: shared checks for the video container tests against ffprobe / ffmpeg. Not a test by itself. local F = require("@rosetta") local Bytes = require("@rosetta/core/Bytes") local Crc32 = require("@rosetta/core/Crc32") @@ -11,7 +9,6 @@ local C = {} -- the codecs whose decode must equal ffmpeg's bit for bit C.EXACT = { vp8 = true, rawvideo = true } --- psnr(a, b, off?, n?) -> dB between two byte strings / buffers (math.huge when equal) function C.psnr(a: buffer, b: buffer, n: number?): number local len = n or math.min(buffer.len(a), buffer.len(b)) local se = 0 @@ -25,7 +22,6 @@ function C.psnr(a: buffer, b: buffer, n: number?): number return 10 * math.log10(255 * 255 * len / se) end --- snr(ours f32 buffer, reference f32 string, n samples) -> dB function C.snr(ours: buffer, ref: string, n: number): number local rb = buffer.fromstring(ref) local sig, err = 0, 0 @@ -41,8 +37,8 @@ function C.snr(ours: buffer, ref: string, n: number): number return 10 * math.log10(sig / err) end --- packets(t, dmx, c, label, opts?): every track's packets against ffprobe's (in order): size, CRC, time, keyframe. --- opts.skipStream(ffprobePacket, track) -> true skips a stream (ffmpeg's parsers re-split some, e.g. MPEG audio in TS) +-- every track's packets against ffprobe's (in order): size, CRC, time, keyframe. +-- opts.skipStream: ffmpeg's parsers re-split some streams, e.g. MPEG audio in TS function C.packets(t: any, dmx: any, c: any, label: string, opts: any?) local o = opts or {} local trackOf = {} -- ffprobe stream index -> our track @@ -85,7 +81,7 @@ function C.packets(t: any, dmx: any, c: any, label: string, opts: any?) t:check(extra == 0, label .. ": no extra packets (" .. extra .. ")") end --- frames(t, v, c, label): every decoded frame against ffmpeg's (CRC for EXACT codecs, else PSNR of the raw ones) +-- CRC for EXACT codecs, else PSNR of the raw frames function C.frames(t: any, v: any, c: any, label: string, minPsnr: number?) if not c.frames then return @@ -152,9 +148,8 @@ function C.audio(t: any, v: any, c: any, label: string, exact: boolean?, minSnr: end local n = got * a.channels t:check(n == want or n * 4 == c.pcmBytes, label .. ": " .. n .. " samples read of " .. want) - -- the whole stream: as long as ffmpeg's decode (priming and end padding trimmed the same way: MP4 edit lists). - -- Not yet for Matroska / WebM, where ffmpeg also cuts the end padding of the last packets (Vorbis, MP2: a few - -- hundred frames) and we do not. + -- the whole stream as long as ffmpeg's decode (priming and end padding trimmed the same way: MP4 edit lists). + -- Not for Matroska / WebM, where ffmpeg also cuts the last packets' end padding (Vorbis, MP2) and we do not. if c.pcmBytes and v.format ~= "mkv" and v.format ~= "webm" then local total = got while true do @@ -184,7 +179,6 @@ function C.audio(t: any, v: any, c: any, label: string, exact: boolean?, minSnr: end end --- seek(t, v, c, label, at): after seek(at) the next frame is the first at or after `at` function C.seek(t: any, v: any, c: any, label: string, at: number) if not (c.frames or c.rgba) or not Video.canDecode(v.codec) then return @@ -208,7 +202,6 @@ function C.seek(t: any, v: any, c: any, label: string, at: number) v:reset() end --- fuzzOpen(Fmt) -> a fuzz function: open, read every packet, decode up to 8 frames, read some audio function C.fuzzOpen(Fmt: any): (buffer) -> any return function(b: buffer): any local v = Fmt.open(Bytes.reader(b), { openAudio = function(d: any, tr: any): any @@ -234,7 +227,6 @@ function C.fuzzOpen(Fmt: any): (buffer) -> any end end --- open(data, opts?) -> VideoDecoder through the api (category video) function C.open(data: string, opts: any?): (any, any) return F.video.open(buffer.fromstring(data), opts) end diff --git a/tests/video/avi.luau b/tests/video/avi.luau index ae3e702..03d0655 100644 --- a/tests/video/avi.luau +++ b/tests/video/avi.luau @@ -1,7 +1,5 @@ --- video/avi tests: AVI files from ffmpeg (MJPEG + PCM s16 / u8 / IMA ADPCM, MPEG-1 + MP2, uncompressed BGR24 / BGRA / --- I420) read through the OpenDML indexes, idx1 alone, and a movi scan: tracks and every packet against ffprobe, --- frames against ffmpeg, audio through the api hook, seeking; our muxer (MJPEG + PCM) read back; a GIF converted to --- AVI. Fixtures: tools/fixtures/avi.py. +-- video/avi tests: AVI files from ffmpeg against ffprobe (packets) and ffmpeg (frames, audio); our muxer read back. +-- Fixtures: tools/fixtures/avi.py. local T = require("@tests/T") local C = require("@tests/video/_common") local F = require("@rosetta") @@ -87,7 +85,6 @@ do end end --- fuzz local samples = {} for _, n in { "mjpeg_pcm.avi", "mjpeg_ima.avi", "idx1_only.avi", "i420.avi" } do local d = byName[n].data diff --git a/tests/video/encode.luau b/tests/video/encode.luau index cbf1fcf..4b948de 100644 --- a/tests/video/encode.luau +++ b/tests/video/encode.luau @@ -1,8 +1,5 @@ --- video writer tests: files our muxers wrote (tools/fixtures/_video_encode.luau: WebM remux, MJPEG Matroska / AVI --- copied and re-encoded from VP8 / MPEG-1, an animated GIF with uneven delays to AVI / Matroska / Y4M, WebM to Y4M) --- were probed by ffprobe and decoded by ffmpeg at fixture time; here our demuxers must see the same packets, our --- decoders the same frames (CRC for VP8 / raw, PSNR for MJPEG) and audio; the writers are rerun and must give the same --- bytes. Fixtures: tools/fixtures/videoenc.py. +-- video writer tests: our muxers' files, probed by ffprobe and decoded by ffmpeg at fixture time, read back. +-- Fixtures: tools/fixtures/videoenc.py (tools/fixtures/_video_encode.luau). local T = require("@tests/T") local C = require("@tests/video/_common") local F = require("@rosetta") @@ -97,7 +94,6 @@ do end end --- the writers are deterministic: the same bytes again do local Mkv = require("@tests/gen/mkv_cases") local remux = byName["remux.webm"] diff --git a/tests/video/fli.luau b/tests/video/fli.luau index 3a15d84..b138e25 100644 --- a/tests/video/fli.luau +++ b/tests/video/fli.luau @@ -1,7 +1,5 @@ --- video/fli tests: FLI (COLOR_64, BRUN, LC, BLACK, COPY, PSTAMP, a ring frame), FLC (prefix chunk, COLOR_256, SS2 with --- line skips and the last-byte opcode, an empty frame), an odd-size FLC, and 15 / 16 / 24-bit FLCs (BRUN, DTA_BRUN, --- DELTA, DTA_LC, COPY, DTA_COPY, BLACK), all encoded by the fixture script: every frame equals ffmpeg's decode --- (CRC-32 of rgba), frame rates, the ring frame option, seeking, errors, the fuzz pass. Fixtures: tools/fixtures/fli.py. +-- video/fli tests: FLI / FLC files encoded by the fixture script; every frame equals ffmpeg's decode (CRC-32 of rgba). +-- Fixtures: tools/fixtures/fli.py. local T = require("@tests/T") local F = require("@rosetta") local Fli = require("@rosetta/video/fli") @@ -59,7 +57,6 @@ for _, c in Fx do end end --- errors do local _, e = Fli.open(reader(string.sub(Fx[1].data, 1, 100))) t:check(e ~= nil and e.code == Err.TRUNCATED, "short header: TRUNCATED") @@ -85,7 +82,7 @@ t:fuzz("open", function(b: buffer) end return v end, samples, { mutations = 12, garbage = 40, keepHeader = 16 }) --- the frame decoder itself (codecs/video/Legacy/Flic, native: no pcall in between) +-- the frame decoder itself (native: no pcall in between) local Flic = require("@rosetta/codecs/video/Legacy").Flic for _, c in { Fx[1], Fx[2], Fx[4], Fx[6] } do local d = Fli.demux(reader(c.data)) diff --git a/tests/video/flv.luau b/tests/video/flv.luau index 75f5c7a..e985608 100644 --- a/tests/video/flv.luau +++ b/tests/video/flv.luau @@ -1,10 +1,5 @@ --- video/flv tests: FLV files from ffmpeg (Sorenson Spark + MP3 / PCM s16 / PCM u8 / ADPCM / Nellymoser / Speex / --- A-law, H.264 with B-frames + AAC, Flash screen video, audio only): tracks and every packet against ffprobe --- (composition times in the pts, keyframes), onMetaData, frames against ffmpeg (Sorenson bit-exact, H.264 PSNR), audio --- through the api hook (PCM and Flash ADPCM mono / stereo exact against ffmpeg's adpcm_swf; Nellymoser / Speex known --- but UNSUPPORTED), seeking; crafted VP6 / enhanced FourCC / encrypted / truncated files; our writer (FLV, MP4, --- Matroska sources) read back by ffprobe and ffmpeg (tools/fixtures/flv.py) and by our demuxer with the source's --- packets; fuzz. Fixtures: tools/fixtures/flv.py. +-- video/flv tests: FLV files from ffmpeg against ffprobe / ffmpeg (Nellymoser, Speex, VP6: known but UNSUPPORTED). +-- Fixtures: tools/fixtures/flv.py. local T = require("@tests/T") local C = require("@tests/video/_common") local F = require("@rosetta") @@ -27,7 +22,6 @@ for _, c in Fx do byName[c.name] = c end --- every frame's CRC against ffmpeg's (codecs we decode bit-exactly), else PSNR local function frames(v: any, c: any, label: string) if v.codec == "flv1" then v:reset() @@ -88,7 +82,6 @@ for _, c in Fx do end end --- details: H.264 config and composition times, metadata, screen video size do local v = assert(C.open(byName["h264_aac.flv"].data)) local vt, at = v.demuxer:track("video"), v.demuxer:track("audio") @@ -110,8 +103,7 @@ do t:check(s.codec == "flashsv" and s.width == 64 and s.height == 48, "screen video: known codec, size from its first packet") end --- crafted files: VP6 (known, UNSUPPORTED, size from its key frame header), an enhanced FourCC tag, encrypted tags, --- truncation, not FLV +-- crafted files: VP6 (known, UNSUPPORTED, size from its key frame header), an enhanced FourCC tag, encrypted tags local function flv(tags: { { any } }): buffer local w = Bytes.writer(256) w:string("FLV") @@ -176,7 +168,6 @@ do t:check(e2 ~= nil and e2.code == F.Err.CORRUPT, "not FLV: CORRUPT") end --- our writer: read back by ffprobe / ffmpeg (fixtures) and by our demuxer, packets equal to the source's local SOURCES = { mp4 = Src.mp4, mkv = Src.mkv, ts = Src.ts } for _, c in Mx do local label = "write " .. c.name @@ -193,7 +184,6 @@ for _, c in Mx do if at then C.audio(t, v, c, label, EXACT_AUDIO[at.codec], 30) end - -- the source's packets, byte for byte local src = assert(C.open(SOURCES[c.source] or byName[c.source].data)) local a, b = src.demuxer, v.demuxer local same = true @@ -226,7 +216,6 @@ for _, c in Mx do end end --- fuzz local samples = {} for _, n in { "sorenson_mp3.flv", "h264_aac.flv", "sorenson_pcm.flv", "screen.flv" } do local d = byName[n].data diff --git a/tests/video/h264.luau b/tests/video/h264.luau index 2e46af4..aa9996c 100644 --- a/tests/video/h264.luau +++ b/tests/video/h264.luau @@ -1,7 +1,5 @@ --- video/h264 tests: H.264 through F.video.open end to end: raw Annex B (.h264, the video/h264 format), MP4 and MKV --- (avcC + length-prefixed samples) and MPEG-TS / AVI (Annex B packets) written by ffmpeg / libx264, frames bit-exact --- against ffmpeg's decode of each file; display-order timestamps; the raw writer (MP4 -> .h264) read back; sniffing; --- the fuzz no-throw pass on the raw demuxer. Fixtures: tools/fixtures/h264.py (h264_containers). +-- video/h264 tests: H.264 by ffmpeg / libx264 in raw Annex B, MP4, MKV, MPEG-TS and AVI, bit-exact against ffmpeg. +-- Fixtures: tools/fixtures/h264.py (h264_containers). local T = require("@tests/T") local F = require("@rosetta") local Fmt = require("@rosetta/video/h264") @@ -50,7 +48,6 @@ for _, c in Cases do end end --- raw format directly: sniff, demux, 25 fps output order do local c = byName["cabac_b.h264"] local r = Bytes.reader(buffer.fromstring(c.data)) @@ -63,7 +60,6 @@ do t:check(#got == #c.frames and math.abs(got[2].pts - 1 / 25) < 1e-9, "raw: pts in output order at 25 fps") end --- writer: the MP4's H.264 track as a raw Annex B stream, decoded again for _, src in { "cabac_b.mp4", "baseline.mkv", "baseline.ts" } do local c = byName[src] local v = F.video.open(c.data) @@ -83,7 +79,6 @@ for _, src in { "cabac_b.mp4", "baseline.mkv", "baseline.ts" } do end end --- fuzz: the raw demuxer + decoder local samples = { byName["baseline.h264"].data, byName["cabac_b.h264"].data } t:fuzz("open + frames", function(b: buffer) local v = Fmt.open(Bytes.reader(b), { maxPixels = 2 ^ 18 }) diff --git a/tests/video/mkv.luau b/tests/video/mkv.luau index 16faa15..b121cef 100644 --- a/tests/video/mkv.luau +++ b/tests/video/mkv.luau @@ -1,8 +1,5 @@ --- video/mkv tests: Matroska / WebM files from ffmpeg and mkvmerge (VP8 + Opus / Vorbis, MJPEG + PCM, MPEG-1 + MP2, --- VP8 + FLAC, srt subtitles, Xiph / EBML / fixed lacing, zlib compression, unknown-size clusters, a truncated file): --- tracks and every packet against ffprobe, frames against ffmpeg (bit-exact VP8, PSNR for MJPEG / MPEG-1), audio --- through the api hook against ffmpeg, seeking, subtitles; our muxer's output (remux and MJPEG) read back. Fixtures: --- tools/fixtures/mkv.py. +-- video/mkv tests: Matroska / WebM files from ffmpeg and mkvmerge against ffprobe / ffmpeg; our muxer read back. +-- Fixtures: tools/fixtures/mkv.py. local T = require("@tests/T") local C = require("@tests/video/_common") local F = require("@rosetta") @@ -13,7 +10,6 @@ local Fx = require("@tests/gen/mkv_cases") local t = T.suite("mkv") --- 1. contract t:eq(Mkv.name, "mkv", "name") t:eq(Mkv.category, "video", "category") t:check(table.find(Mkv.extensions, "webm") ~= nil, "webm extension") @@ -24,7 +20,6 @@ for _, c in Fx do byName[c.name] = c end --- 2. every fixture for _, c in Fx do local label = c.name t:check(Mkv.sniff(Bytes.reader(buffer.fromstring(c.data))) > 0, label .. ": sniff") @@ -68,7 +63,6 @@ for _, c in Fx do end end --- 3. specific files do local v = C.open(byName["vp8_opus.webm"].data) t:eq(v.format, "webm", "webm: format") @@ -98,7 +92,6 @@ do t:eq(F.format("webm").name, "mkv", "format(webm) is mkv") end --- 4. our muxer: remux WebM (VP8 + Opus copied) and read it back packet for packet do local src = byName["vp8_opus.webm"] local v = C.open(src.data) @@ -126,7 +119,6 @@ do t:check(bad == nil and berr ~= nil and berr.code == Err.UNSUPPORTED, "webm refuses MJPEG: " .. tostring(berr)) end --- 5. errors and the fuzz pass local e1 = select(2, Mkv.open(Bytes.reader(buffer.fromstring("\26\69\223\163\128")))) t:check(e1 ~= nil, "empty EBML header fails") local samples = {} diff --git a/tests/video/mp4.luau b/tests/video/mp4.luau index 045a9d6..207f8e2 100644 --- a/tests/video/mp4.luau +++ b/tests/video/mp4.luau @@ -1,7 +1,5 @@ --- video/mp4 tests: MP4 / MOV files from ffmpeg (MJPEG + AAC / PCM / FLAC / MP2, H.264 with B-frames and edit lists + --- AAC, fragmented MP4, MPEG-1 + Opus): tracks and every packet against ffprobe (pts moved by the edit lists, as ffmpeg), --- frames against ffmpeg (PSNR), audio through the api hook (AAC priming dropped), seeking, our MP4 / MOV writer read --- back, the H.264 yield hook and maxSide, fuzz. Fixtures: tools/fixtures/mp4.py. +-- video/mp4 tests: MP4 / MOV files from ffmpeg against ffprobe (pts moved by edit lists, as ffmpeg) and ffmpeg. +-- Fixtures: tools/fixtures/mp4.py. local T = require("@tests/T") local C = require("@tests/video/_common") local F = require("@rosetta") @@ -36,7 +34,6 @@ for _, c in Fx do end end --- our writer: MP4 (MJPEG + AAC copied) and MOV (MJPEG + PCM) read back packet for packet for _, job in { { "mjpeg_aac.mp4", "mp4" }, { "mjpeg_pcm.mov", "mov" }, { "h264_aac.mp4", "mp4" } } do local src = byName[job[1]] local v = C.open(src.data) @@ -76,8 +73,7 @@ for _, job in { { "mjpeg_aac.mp4", "mp4" }, { "mjpeg_pcm.mov", "mov" }, { "h264_ end end --- H.264 with the cooperative yield hook (decoding inside a coroutine that yields at every hook call: the same pictures) --- and maxSide (frames shrunk to the longer side, aspect kept) +-- the yield hook (decoding in a coroutine that yields at every hook call) gives the same pictures do local Crc32 = require("@rosetta/core/Crc32") local data = byName["h264_aac.mp4"].data diff --git a/tests/video/mpeg2.luau b/tests/video/mpeg2.luau index 0e5a7cb..13e43e3 100644 --- a/tests/video/mpeg2.luau +++ b/tests/video/mpeg2.luau @@ -1,7 +1,5 @@ --- MPEG-2 video in the containers (tools/fixtures/mpeg2.py, "mpeg2_containers"): the same elementary stream copied by --- ffmpeg into MPEG-TS (stream type 0x02, and the PMT patched to 0x80, private / DigiCipher II video), MPEG-PS (VOB), --- Matroska (V_MPEG2) and AVI: each opens through F.video.open with codec "mpeg2", its frames equal ffmpeg's --- `-idct int` decode (luma CRC per frame, display order), seeking lands on a frame; the raw .m2v opens too. +-- MPEG-2 video in MPEG-TS (stream types 0x02, 0x80), MPEG-PS, Matroska and AVI against ffmpeg's `-idct int` decode. +-- Fixtures: tools/fixtures/mpeg2.py (mpeg2_containers). local T = require("@tests/T") local F = require("@rosetta") local Base64 = require("@rosetta/core/Base64") @@ -54,7 +52,6 @@ for _, c in CASES do end end --- the elementary stream itself do local v, err = F.video.open(Base64.decode(Prog.file) :: buffer) t:check(v ~= nil and v.codec == "mpeg2", "m2v: opens as mpeg2: " .. tostring(err)) diff --git a/tests/video/mpegps.luau b/tests/video/mpegps.luau index bd6be3b..a3a9f1b 100644 --- a/tests/video/mpegps.luau +++ b/tests/video/mpegps.luau @@ -1,7 +1,5 @@ --- video/mpegps tests: program streams from ffmpeg (MPEG-1 system stream, B-frames, MPEG-2 PS / VOB packs, a raw .m1v --- elementary stream): tracks, picture packets (count and timestamps against ffmpeg's frames), frames against ffmpeg --- (PSNR) once an MPEG-1 decoder is registered, audio through the api hook (SNR), seeking, fuzz. Fixtures: --- tools/fixtures/mpegts.py. +-- video/mpegps tests: program streams from ffmpeg against ffmpeg's frames (timestamps, PSNR) and audio (SNR). +-- Fixtures: tools/fixtures/mpegts.py. local T = require("@tests/T") local C = require("@tests/video/_common") local Ps = require("@rosetta/video/mpegps") @@ -21,7 +19,6 @@ for _, c in Fx do local vt = dmx:track("video") t:check(vt ~= nil and vt.codec == "mpeg1", label .. ": an MPEG-1 video track") t:eq(dmx:count(vt.id), #c.frames, label .. ": one packet per picture") - -- presentation times: one per frame slot local seen, ok = {}, true for k = 1, dmx:count(vt.id) do local pts = dmx:info(vt.id, k) diff --git a/tests/video/mpegts.luau b/tests/video/mpegts.luau index 1b13a71..2b85b67 100644 --- a/tests/video/mpegts.luau +++ b/tests/video/mpegts.luau @@ -1,6 +1,4 @@ --- video/mpegts tests: transport streams from ffmpeg (MPEG-1 + MP2, B-frames, H.264 + AAC, M2TS, garbage before the --- first packet, a truncated file): tracks and the video packets against ffprobe (time, size, CRC, keyframe), frames --- against ffmpeg (PSNR) once an MPEG-1 decoder is registered, audio through the api hook (SNR), seeking, fuzz. +-- video/mpegts tests: transport streams from ffmpeg against ffprobe (video packets) and ffmpeg (frames, audio). -- Fixtures: tools/fixtures/mpegts.py. local T = require("@tests/T") local C = require("@tests/video/_common") diff --git a/tests/video/ogv.luau b/tests/video/ogv.luau index 88dbdeb..89b91ee 100644 --- a/tests/video/ogv.luau +++ b/tests/video/ogv.luau @@ -1,8 +1,5 @@ --- video/ogv tests: Ogg Theora files from ffmpeg (libtheora + libvorbis; tools/fixtures/theora.py): sniffing (Theora --- BOS pages, plain Ogg Vorbis left to the audio formats), tracks, granule times, every frame through F.video.open --- bit-exact with ffmpeg's (Adler-32 of yuv420p, its framecrc), an empty packet (a repeated frame), the Vorbis track --- through the api's audio hook against ffmpeg's decode, tags, seeking, remuxing (ogv -> ogv, mkv -> ogv, ogv -> mkv) --- read back, errors and the fuzz no-throw pass. +-- video/ogv tests: Ogg Theora from ffmpeg (libtheora + libvorbis), bit-exact with its framecrc (Adler-32 of yuv420p). +-- Fixtures: tools/fixtures/theora.py. local T = require("@tests/T") local C = require("@tests/video/_common") local F = require("@rosetta") @@ -27,8 +24,7 @@ local function file(fx: any): buffer return Base64.decode(fx.file) :: buffer end --- every frame of a VideoDecoder against ffmpeg's framecrc (yuv420p, keyed by frame number); frames ffmpeg does not --- show (empty packets) must repeat the previous one +-- frames ffmpeg does not show (empty packets) must repeat the previous one local function frames(v: any, fx: any, label: string, fps: number) local want: { [number]: number } = {} for _, f in fx.frames do @@ -59,7 +55,6 @@ local function frames(v: any, fx: any, label: string, fps: number) return n end --- 1. contract and sniffing t:eq(Ogv.name, "ogv", "name") t:eq(Ogv.category, "video", "category") t:check(table.find(Ogv.extensions, "ogv") ~= nil, "ogv extension") @@ -68,7 +63,6 @@ t:eq(Ogv.sniff(Bytes.reader(file(Q0))), 1, "sniff: Theora") t:eq(Ogv.sniff(Bytes.reader(buffer.fromstring("OggS\0\2" .. string.rep("\0", 40)))), 0, "sniff: an Ogg page without Theora") t:eq(Ogv.sniff(Bytes.reader(buffer.fromstring("RIFF"))), 0, "sniff: not Ogg") --- 2. Theora + Vorbis through the api local v, err = F.video.open(file(AV)) t:check(v ~= nil, "open: " .. tostring(err)) if v then @@ -90,7 +84,6 @@ if v then frames(v, AV, "av", 25) local pcm = Base64.decode(AV.pcm) :: buffer C.audio(t, v, { pcm = buffer.tostring(pcm) }, "av", false, 20) - -- seeking v:seek(0.5) local f = v:nextFrame() t:check(f ~= nil and f.pts >= 0.5 - 1e-6 and f.pts < 0.6, "seek 0.5 -> " .. tostring(f and f.pts)) @@ -103,7 +96,6 @@ if v then end t:eq(Adler32.of(f.image.pixels, nil, nil, 0), want, "the frame after seeking equals ffmpeg's") end - -- remux ogv -> ogv v:reset() local out, rerr = F.save(v, nil, { format = "ogv" }) t:check(out ~= nil, "remux: " .. tostring(rerr)) @@ -116,7 +108,6 @@ if v then C.audio(t, v2, { pcm = buffer.tostring(pcm) }, "remux", false, 20) end end - -- remux ogv -> mkv (V_THEORA) v:reset() local mk, merr = F.save(v, nil, { format = "mkv" }) t:check(mk ~= nil, "to mkv: " .. tostring(merr)) @@ -205,7 +196,6 @@ do t:check(vc ~= nil, "a truncated file opens") end --- 7. fuzz t:fuzz("open", C.fuzzOpen(Ogv), { buffer.tostring(file(Q0)) }, { mutations = 16, garbage = 50 }) t:done() diff --git a/tests/video/smk.luau b/tests/video/smk.luau index 4f1556b..ef97469 100644 --- a/tests/video/smk.luau +++ b/tests/video/smk.luau @@ -1,8 +1,5 @@ --- video/smk tests: Smacker files encoded by the fixture script (SMK2 and SMK4, every block type and run, the trees' --- escape cache, palette updates, a ring frame, ms and 10 us frame times; packed 16-bit stereo / 8-bit mono / 16-bit --- mono / 8-bit stereo audio and raw s16le / u8 tracks): every video frame and every audio track equal ffmpeg's --- decode (CRC-32 of rgba / f32le), audio seeking, errors, and the fuzz pass on the container, the video codec and the --- audio codec. Fixtures: tools/fixtures/smk.py. +-- video/smk tests: Smacker files by the fixture script; video and audio equal ffmpeg's decode (CRC-32 of rgba / f32le). +-- Fixtures: tools/fixtures/smk.py. local T = require("@tests/T") local F = require("@rosetta") local Smk = require("@rosetta/video/smk") @@ -21,7 +18,6 @@ local function reader(s: string): Bytes.Reader return Bytes.reader(buffer.fromstring(s)) end --- every frame of an audio Decoder -> f32 buffer, frames local function drain(dec: any): (buffer, number) local chunks, total = {}, 0 while true do @@ -118,7 +114,6 @@ for _, c in Fx do end end --- errors do local _, e = Smk.open(reader(string.sub(Fx[1].data, 1, 60))) t:check(e ~= nil and e.code == Err.TRUNCATED, "short header: TRUNCATED") @@ -131,7 +126,7 @@ do t:check(e4 ~= nil and e4.code == Err.TRUNCATED, "trees past the end: TRUNCATED") end --- fuzz: the container, the video codec (native, no pcall in between) and the audio codec +-- fuzz: the video codec is native, no pcall in between local samples = {} for _, c in Fx do table.insert(samples, c.data) diff --git a/tests/video/y4m.luau b/tests/video/y4m.luau index f256b03..8902ffd 100644 --- a/tests/video/y4m.luau +++ b/tests/video/y4m.luau @@ -1,7 +1,5 @@ --- video/y4m tests: YUV4MPEG2 streams from ffmpeg (C420jpeg at an odd size, C420mpeg2, C422, C444, Cmono, C420p10) --- against ffmpeg's yuv420p decode (bit-exact for 4:2:0 8-bit, PSNR for the converted layouts), the header fields, --- our writer round trip (and from an rgba frames-backed video), errors and the fuzz pass. Fixtures: --- tools/fixtures/y4m.py. +-- video/y4m tests: YUV4MPEG2 from ffmpeg against its yuv420p decode (bit-exact for 4:2:0 8-bit, else PSNR). +-- Fixtures: tools/fixtures/y4m.py. local T = require("@tests/T") local C = require("@tests/video/_common") local F = require("@rosetta") @@ -47,7 +45,7 @@ for _, c in Fx do end end --- writer: a y4m stream back to y4m is byte-identical in its frames; header as ffmpeg writes it +-- header as ffmpeg writes it do local c = Fx[1] local v = F.video.open(buffer.fromstring(c.data)) @@ -86,7 +84,6 @@ do end end --- errors local function code(s: string): string? local _, e = Y4m.open(Bytes.reader(buffer.fromstring(s))) return e and e.code