tests/codecs (m-z): comments: specs only
This commit is contained in:
1 parent
98b4ce533e
commit
a6732d45f2
23 files changed
+46
-177
No files matched your search
+6
-18
@@ -1,10 +1,5 @@
|
||||
-- codecs/video/Mpeg2 tests. Against `ffmpeg -idct int` (tools/fixtures/mpeg2.py): every stream (progressive and
|
||||
-- interlaced frame pictures with field prediction and field DCT, top / bottom field first, 4:2:2, the alternate scan,
|
||||
-- Table B-15, the non-linear quantiser scale, DC precision 9..11, custom luma / chroma matrices, f_code > 1, an odd
|
||||
-- size, B-frames, dual prime, field pictures, concealment vectors) decodes one access unit at a time to exactly ffmpeg's planes, every frame, in display
|
||||
-- order; the same stream written in random pieces gives the same frames; frame flags (mpeg2, chroma, progressive,
|
||||
-- topFieldFirst); frameImage (4:2:2 -> yuv420p, rgba8); the registry's VideoCodecDecoder; truncated and corrupted
|
||||
-- streams never throw; the fuzz no-throw pass.
|
||||
-- codecs/video/Mpeg2 tests: every stream decodes to exactly `ffmpeg -idct int`'s planes, every frame, display order.
|
||||
-- Fixtures: tools/fixtures/mpeg2.py.
|
||||
local T = require("@tests/T")
|
||||
local Mpeg2 = require("@rosetta/codecs/video/Mpeg2")
|
||||
local Video = require("@rosetta/codecs/video/Video")
|
||||
@@ -35,7 +30,6 @@ local function b64(s: string): buffer
|
||||
return Base64.decode(s) :: buffer
|
||||
end
|
||||
|
||||
-- CRC-32 of a plane cropped to w x h from a buffer with stride
|
||||
local function planeCrc(b: buffer, stride: number, w: number, h: number): number
|
||||
local row = buffer.create(w * h)
|
||||
for y = 0, h - 1 do
|
||||
@@ -44,7 +38,6 @@ local function planeCrc(b: buffer, stride: number, w: number, h: number): number
|
||||
return Crc32.of(row)
|
||||
end
|
||||
|
||||
-- the cropped planes of a frame, as ffmpeg writes them (w x h luma, ceil(w / 2) x (h or ceil(h / 2)) chroma)
|
||||
local function crcs(f: any): (number, number, number)
|
||||
local w, h = f.width, f.height
|
||||
local cw = (w + 1) // 2
|
||||
@@ -53,7 +46,6 @@ local function crcs(f: any): (number, number, number)
|
||||
return planeCrc(f.y, f.codedWidth, w, h), planeCrc(f.cb, chw, cw, ch), planeCrc(f.cr, chw, cw, ch)
|
||||
end
|
||||
|
||||
-- differing samples between a frame's luma and a reference yuv frame (debug 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
|
||||
@@ -103,9 +95,8 @@ local function decodeUnits(fx: any, file: buffer): { any }
|
||||
return out
|
||||
end
|
||||
|
||||
-- 1. every stream against ffmpeg, bit-exact. ffmpeg's encoder sometimes ends a B-picture slice before the row's last
|
||||
-- macroblock (invalid MPEG-2); both decoders conceal the gap, ffmpeg with its error-resilience guesses and deblocking.
|
||||
-- Frames with concealed macroblocks compare every 16-line luma band but those and their neighbours.
|
||||
-- ffmpeg's encoder sometimes ends a B-picture slice before the row's last macroblock (invalid MPEG-2); both decoders
|
||||
-- conceal the gap differently, so frames with concealed macroblocks skip those 16-line luma bands and their neighbours.
|
||||
local total, concealedFrames = 0, 0
|
||||
for _, fx in STREAMS do
|
||||
local name = fx.name
|
||||
@@ -154,7 +145,6 @@ for _, fx in STREAMS do
|
||||
if fx.chroma == 2 then "4:2:2" else "4:2:0", #got, #got / dt)
|
||||
end
|
||||
|
||||
-- 2. interlace flags
|
||||
do
|
||||
local got = decodeUnits(STREAMS[2], b64(STREAMS[2].file))
|
||||
t:check(got[1][4].progressive == false and got[1][4].topFieldFirst == true, "tff: interlaced, top field first")
|
||||
@@ -164,7 +154,7 @@ do
|
||||
t:check(got[1][4].progressive == true, "prog: progressive")
|
||||
end
|
||||
|
||||
-- 3. the same stream written in random pieces (decodeFrame) gives the same frames as unit by unit
|
||||
-- the same stream written in random pieces (decodeFrame) gives the same frames as unit by unit
|
||||
for _, idx in { 2, 9, 12 } do
|
||||
local fx = STREAMS[idx]
|
||||
local file = b64(fx.file)
|
||||
@@ -200,7 +190,6 @@ for _, idx in { 2, 9, 12 } do
|
||||
t:check(ok and k == fx.frames, string.format("%s: random pieces give the same %d frames (%d)", fx.name, fx.frames, k))
|
||||
end
|
||||
|
||||
-- 4. frameImage: yuv420p (4:2:2 converted), rgba8
|
||||
do
|
||||
local fx = STREAMS[9]
|
||||
local dec = Mpeg2.new({ reorder = false, rgba = true })
|
||||
@@ -222,7 +211,7 @@ do
|
||||
t:check(Mpeg2.frameImage({} :: any) == nil, "frameImage of a non-frame is nil")
|
||||
end
|
||||
|
||||
-- 5. the registry's decoder (packets = access units), display order with pts
|
||||
-- the registry's decoder (packets = access units), display order with pts
|
||||
do
|
||||
t:check(Video.fromFourcc("mpg2") == "mpeg2" and Video.fromMatroska("V_MPEG2") == "mpeg2", "registry names")
|
||||
t:check(Video.canDecode("mpeg2") and Video.canDecode("mpeg1"), "registry decoders")
|
||||
@@ -256,7 +245,6 @@ do
|
||||
t:check(order, "registry decoder: frames in display order, equal to the codec's")
|
||||
end
|
||||
|
||||
-- 6. robustness: truncated units, bit flips, garbage (never throws), and the fuzz pass
|
||||
do
|
||||
local samples = {}
|
||||
for _, idx in { 1, 2, 9, 11 } do
|
||||
|
||||
Reference in new issue
Block a user