Phase 1: V4L2/MJPEG camera path to fullscreen SDL3 output
A small live-video-to-display appliance for the church stream machine, replacing MPV/GStreamer for two fixed jobs. This lands job 1 end to end and scaffolds job 2. Pipeline: V4L2 mmap capture -> TurboJPEG decode to YUV planes -> interleave to packed YUY2 -> SDL3 streaming texture -> borderless fullscreen on a chosen Wayland output. The GPU does the colour conversion, so no CPU matrix multiply and half the upload bandwidth of RGBA. Latency is managed by dropping, never queueing: the driver queue is drained to its newest buffer each wakeup, and a one-deep slot between the input thread and the renderer discards any frame the renderer has not taken. Dependency tree is two crates (sdl3-sys, libc). V4L2 and TurboJPEG are hand-written FFI; the V4L2 struct layouts were taken from the target kernel's headers and are pinned by compile-time assertions. Three hardware behaviours found while validating against the real ATEM: * /dev/video1 is a metadata node with no formats, so MJPEG on /dev/video0 is the only path on this hardware. * The ATEM pads frames with a few bytes before the EOI marker. libjpeg warns, and TurboJPEG returns -1 for a warning as well as a failure, so the first cut rejected ~97% of frames. Warnings are now distinguished from failures via tj3GetErrorCode, with a structural SOI/EOI check to still catch genuinely truncated frames. * On KDE Wayland, SDL reports monitor model names, not connector names. Also fixes sticky libjpeg error state, where one corrupt frame would latch an error and fail every valid frame after it. 87 tests. Verified on the real ATEM: sustained 30.0 fps, 0 undecodable frames, 0 frames dropped before display, ~33% of one core.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Regenerates the JPEG fixtures used by tests/decode.rs.
|
||||
|
||||
Run from the repository root: python3 tests/data/generate.py
|
||||
|
||||
Each fixture is a solid colour so the test can assert exact sample values
|
||||
after decoding. Green is deliberate: it is the colour the ATEM keys on, and a
|
||||
wrong YUV matrix or range shows up here before it shows up on stage.
|
||||
"""
|
||||
from PIL import Image
|
||||
import pathlib
|
||||
|
||||
OUT = pathlib.Path(__file__).parent
|
||||
W, H = 64, 32
|
||||
GREEN = (0, 255, 0)
|
||||
|
||||
# PIL subsampling codes: 0 = 4:4:4, 1 = 4:2:2, 2 = 4:2:0
|
||||
for name, subs in [("green-444.jpg", 0), ("green-422.jpg", 1), ("green-420.jpg", 2)]:
|
||||
Image.new("RGB", (W, H), GREEN).save(OUT / name, "JPEG", quality=95, subsampling=subs)
|
||||
|
||||
Image.new("L", (W, H), 128).save(OUT / "gray.jpg", "JPEG", quality=95)
|
||||
|
||||
for p in sorted(OUT.glob("*.jpg")):
|
||||
print(f"{p.name}: {p.stat().st_size} bytes")
|
||||
Reference in New Issue
Block a user