ws-video2-theora: Theora speed (fused prediction + IDCT add, inlined token decode, table-driven tokens), bench lines, guide section
tools/bench.luau: a ws-video2-theora block (320x240 testsrc2 / mandelbrot, decode and decode + image()). docs/guide/video.md: an Ogg Theora section (tested snippet; inputs from the new tools/fixtures/docs_theora.py) and the formats / writers tables.
This commit is contained in:
1 parent
4dcb005180
commit
1013925a85
6 files changed
+342
-222
No files matched your search
@@ -1078,3 +1078,42 @@ do
|
||||
jitTune(false)
|
||||
end
|
||||
end
|
||||
do
|
||||
-- ------------------------------------------------------------------------------------- ws-video2-theora: fps
|
||||
-- Theora (codecs/video/Theora): 320x240 clips, 50 frames, keyframe every 25: testsrc2 at 600 kbit/s (mostly static:
|
||||
-- few coded blocks) and a mandelbrot zoom at 1200 kbit/s (every block coded, moving); decode alone and decode +
|
||||
-- image() (the yuv420p copy every VideoDecoder frame makes)
|
||||
local Theora = require("@formats/codecs/video/Theora")
|
||||
local Ogg = require("@formats/containers/Ogg")
|
||||
local Base64 = require("@formats/core/Base64")
|
||||
local TB = require("@tests/gen/theora_bench")
|
||||
local function run(tag: string)
|
||||
for _, c in TB do
|
||||
local d = Ogg.open(Base64.decode(c.file) :: buffer)
|
||||
local hdrs, data = {}, {}
|
||||
for p in d:packets(d:find("theora")) do
|
||||
table.insert(if #hdrs < 3 then hdrs else data, Ogg.copy(p))
|
||||
end
|
||||
for _, image in { false, true } do
|
||||
local n = c.width * c.height * 3 // 2 * #data
|
||||
local dt = bench(string.format("theora %s %dx%d%s%s", c.name, c.width, c.height, if image then " +img" else "", tag), 3, n, function()
|
||||
local dec = Theora.new(hdrs) :: any
|
||||
for _, p in data do
|
||||
dec:decode(p)
|
||||
if image then
|
||||
dec:image()
|
||||
end
|
||||
end
|
||||
end)
|
||||
print(string.format("%-8s %-30s %8.1f fps", runtime, " (" .. #data .. " frames)", #data / dt))
|
||||
end
|
||||
end
|
||||
end
|
||||
jitTune(false)
|
||||
run("")
|
||||
if runtime == "luajit" then
|
||||
jitTune(true)
|
||||
run(" (jit tuned)")
|
||||
jitTune(false)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,20 @@
|
||||
# Docs inputs for the Ogg Theora section of docs/guide/video.md (tools/fixtures.py; tools/docs_check.py reads them): a
|
||||
# tiny ffmpeg clip (testsrc 64x48, 10 frames at 10 fps, libtheora + a libvorbis sine track) as Ogg video.
|
||||
# tests/gen/docs_theora.luau { files = { ["clip.ogv"] = bytes }, vars = { ogvBytes = "clip.ogv" } }
|
||||
import importlib.util, os, shutil, subprocess, tempfile
|
||||
|
||||
INPUTS = ["tools/docs_check.py"]
|
||||
|
||||
|
||||
def generate(ctx):
|
||||
spec = importlib.util.spec_from_file_location("docs_theora_check", os.path.join(ctx.root, "tools", "docs_check.py"))
|
||||
dc = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(dc)
|
||||
ffmpeg = shutil.which("ffmpeg") or ctx.nix("ffmpeg-full", ["sh", "-c", "command -v ffmpeg"]).decode().strip()
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
out = os.path.join(d, "clip.ogv")
|
||||
subprocess.run([ffmpeg, "-v", "error", "-y", "-f", "lavfi", "-i", "testsrc=size=64x48:rate=10:duration=1",
|
||||
"-f", "lavfi", "-i", "sine=frequency=440:sample_rate=44100:duration=1", "-c:v", "libtheora",
|
||||
"-q:v", "6", "-g", "5", "-c:a", "libvorbis", "-q:a", "2", out], check=True, capture_output=True)
|
||||
files = {"clip.ogv": open(out, "rb").read()}
|
||||
dc.emit_inputs(ctx, files, {"ogvBytes": "clip.ogv"})
|
||||
@@ -10,7 +10,7 @@
|
||||
# rate, channels }
|
||||
# tests/gen/theora_opus.luau, theora_flac.luau the same with mono Opus / FLAC audio
|
||||
# tests/gen/theora_mkv.luau { file (base64 .mkv), frames }
|
||||
# tests/gen/theora_bench.luau { file (base64 .ogv, 320x240) } for tools/bench.luau
|
||||
# tests/gen/theora_bench.luau { { name, file (base64 .ogv, 320x240), width, height } } for tools/bench.luau
|
||||
import base64, os, shutil, struct, subprocess, tempfile, zlib
|
||||
|
||||
FF = ["-hide_banner", "-loglevel", "error", "-y"]
|
||||
@@ -199,7 +199,10 @@ def generate(ctx):
|
||||
ff(["-i", os.path.join(tmp, "odd.ogv"), "-c", "copy", mkv])
|
||||
ctx.emit("theora_mkv", {"file": b64(open(mkv, "rb").read()), "frames": framecrc(mkv, "yuv420p"),
|
||||
"width": 174, "height": 98})
|
||||
# the bench stream
|
||||
bench = os.path.join(tmp, "bench.ogv")
|
||||
ff(src("testsrc2", 320, 240, 25, 2) + ["-c:v", "libtheora", "-b:v", "600k", "-g", "25", bench])
|
||||
ctx.emit("theora_bench", {"file": b64(open(bench, "rb").read()), "width": 320, "height": 240})
|
||||
# the bench streams: an easy clip (testsrc2, mostly static) and a hard one (a mandelbrot zoom: every block moves)
|
||||
bench = []
|
||||
for kind, rate in (("testsrc2", "600k"), ("mandelbrot", "1200k")):
|
||||
path = os.path.join(tmp, "bench_" + kind + ".ogv")
|
||||
ff(src(kind, 320, 240, 25, 2) + ["-c:v", "libtheora", "-b:v", rate, "-g", "25", path])
|
||||
bench.append({"name": kind, "file": b64(open(path, "rb").read()), "width": 320, "height": 240})
|
||||
ctx.emit("theora_bench", bench)
|
||||
Reference in new issue
Block a user