feat: known-good CPU audio + 1080p VAAPI + KMS display wall

Working snapshot before the OpenVINO MetricGAN GPU spike:
thread-capped SpeechBrain DelaySum+MetricGAN on CPU, hop 200 ms,
video hold for A/V sync, Arc VAAPI H.264, headless kmssink wall.
32 tests passing. Do not treat this as a GPU audio path.
This commit is contained in:
root
2026-08-28 07:14:21 +00:00
parent 11776adf52
commit 736eccb932
17 changed files with 1421 additions and 46 deletions
+81
View File
@@ -0,0 +1,81 @@
"""5x4 camera mosaic helpers."""
import numpy as np
from display_grid import (
CameraGrid,
camera_ids,
display_name,
is_camera_identity,
letterbox_bgra,
placeholder,
)
def test_camera_ids():
ids = camera_ids(20)
assert ids[0] == "cam-01" and ids[-1] == "cam-20"
assert len(ids) == 20
def test_is_camera_identity():
assert is_camera_identity("cam-07")
assert is_camera_identity("cam-07", "cam")
assert not is_camera_identity("speaker")
assert not is_camera_identity("display-wall")
def test_display_name():
assert display_name("cam-07") == "CAM-07"
assert display_name("cam-01") == "CAM-01"
def test_letterbox_preserves_canvas_size():
src = np.zeros((720, 1280, 4), dtype=np.uint8)
src[:] = (0, 0, 255, 255)
out = letterbox_bgra(src, 384, 270)
assert out.shape == (270, 384, 4)
assert out.dtype == np.uint8
def test_grid_render_size_and_slots():
g = CameraGrid(width=1920, height=1080, cols=5, rows=4)
assert g.tile_w == (1920 - g.gap * 6) // 5
assert g.tile_h == (1080 - g.gap * 5) // 4
assert g.inner_w < g.tile_w
assert g.inner_h < g.tile_h
assert len(g.identities) == 20
buf = g.render()
assert len(buf) == 1920 * 1080 * 4
frame = np.zeros((720, 1280, 4), dtype=np.uint8)
frame[:] = (255, 0, 0, 255)
g.set_frame("cam-07", frame)
buf2 = g.render()
assert buf2 != buf
g.clear("cam-07")
assert len(g.render()) == len(buf)
def test_empty_tiles_have_name_placeholder():
g = CameraGrid(width=1920, height=1080, cols=5, rows=4)
# Name is drawn in the inner region — not a flat fill.
tile = g._tiles["cam-01"]
assert tile.shape == (g.tile_h, g.tile_w, 4)
assert tile.sum() > 0
inner = tile[g.border : g.border + g.inner_h, g.border : g.border + g.inner_w]
# Center of an empty tile is not uniform (text glyphs).
assert inner.std() > 1.0
def test_gap_separates_tiles():
g = CameraGrid(width=1920, height=1080, cols=5, rows=4, gap=8)
canvas = np.frombuffer(g.render(), dtype=np.uint8).reshape(1080, 1920, 4)
# Pixel in the gutter between col 0 and col 1 is canvas background, not a tile.
x = g.gap + g.tile_w + g.gap // 2
y = g.gap + 4
assert tuple(canvas[y, x]) == (10, 10, 10, 255)
def test_placeholder_draws_text():
img = placeholder(640, 360, ["Screen share", "stub"])
assert img.shape == (360, 640, 4)
assert img.sum() > 0