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