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
|
||||
-- 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
|
||||
|
||||
Reference in new issue
Block a user