ws-video2: MPEG-1 tests bit-exact against ffmpeg -idct int (308 of 312 frames; 4 with concealed macroblocks)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
e0b1f5710d
commit
f90fcbb029
2 files changed
+36
-6
No files matched your search
+11
-4
@@ -4,7 +4,9 @@
|
||||
# tests/gen/mpeg1_<name>.luau { name, width, height, frames, file (base64), units = { { offset, length } },
|
||||
# means = { { r, g, b } } (every frame, display order, ffmpeg's RGBA),
|
||||
# rgba = { { index, pixels } } (two whole RGBA frames, base64 zlib),
|
||||
# yuv = { { index, planes } } (three whole frames as ffmpeg -pix_fmt yuv420p, base64 zlib) }
|
||||
# yuv = { { index, planes } } (three whole frames as ffmpeg -pix_fmt yuv420p, base64 zlib),
|
||||
# exact = { { y, u, v } } (CRC-32 of every frame's planes from `ffmpeg -idct int`, the IDCT
|
||||
# codecs/video/Dsp reproduces: the decode must equal it) }
|
||||
# tests/gen/mpeg1_sizechange.luau { file (base64), parts = { { width, height, frames, last (RGBA, base64 zlib) } } }
|
||||
# tests/gen/mpeg1_bench.luau { { width, height, file (base64), units } }: 320x240 and 640x480 streams (with
|
||||
# B-frames) for tools/bench.luau
|
||||
@@ -122,9 +124,9 @@ def generate(ctx):
|
||||
es = open(path, "rb").read()
|
||||
return (patch_size(es, *size) if size else es), path
|
||||
|
||||
def reference(path, fmt):
|
||||
out = path + "." + fmt
|
||||
ff(["-i", path, "-f", "rawvideo", "-pix_fmt", fmt, out])
|
||||
def reference(path, fmt, idct=None):
|
||||
out = path + "." + fmt + (idct or "")
|
||||
ff((["-idct", idct] if idct else []) + ["-i", path, "-f", "rawvideo", "-pix_fmt", fmt, out])
|
||||
r = subprocess.run([ffprobe, "-v", "error", "-select_streams", "v:0", "-show_entries", "stream=width,height",
|
||||
"-of", "csv=p=0", path], check=True, capture_output=True)
|
||||
w, h = (int(x) for x in r.stdout.decode().strip().split(",")[:2])
|
||||
@@ -134,10 +136,13 @@ def generate(ctx):
|
||||
es, path = encode(name, args, size)
|
||||
rgba, w, h = reference(path, "rgba")
|
||||
yuv, _, _ = reference(path, "yuv420p")
|
||||
exact, _, _ = reference(path, "yuv420p", "int")
|
||||
if size:
|
||||
rgba, yuv = crop(rgba, w, h, size[0], size[1], 4), crop_yuv(yuv, w, h, size[0], size[1])
|
||||
exact = crop_yuv(exact, w, h, size[0], size[1])
|
||||
w, h = size
|
||||
fs, ys = w * h * 4, w * h + 2 * ((w + 1) // 2) * ((h + 1) // 2)
|
||||
c = ((w + 1) // 2) * ((h + 1) // 2)
|
||||
n = len(rgba) // fs
|
||||
means = []
|
||||
for k in range(n):
|
||||
@@ -151,6 +156,8 @@ def generate(ctx):
|
||||
"means": means,
|
||||
"rgba": [{"index": k + 1, "pixels": z64(rgba[k * fs:(k + 1) * fs])} for k in picks],
|
||||
"yuv": [{"index": k + 1, "planes": z64(yuv[k * ys:(k + 1) * ys])} for k in ypicks],
|
||||
"exact": [[zlib.crc32(f[:w * h]), zlib.crc32(f[w * h:w * h + c]), zlib.crc32(f[w * h + c:ys])]
|
||||
for f in (exact[k * ys:(k + 1) * ys] for k in range(n))],
|
||||
})
|
||||
|
||||
# a size change mid-stream: 176x144 then 320x180 (each part decoded by ffmpeg on its own)
|
||||
|
||||
Reference in new issue
Block a user