Epic: #113 · Milestone: MC0 — Product & decisions
Why
The OS tree's media code is decorative: kernel/src/media/video_decoder.home (138 lines) has video_decode_h264/h265/vp8/vp9 that each return 1; audio_codec.home (496) parses headers and never decodes a frame; there is no demuxer, no image decoder, no resampler.
The compiler repo already contains a large media stack, written in Zig with Home FFI bindings (src/bindings/home.zig / home_bindings.zig):
Package (~/Code/Home/lang/packages/) | Files / lines | Contents |
|---|---|---|
video/ | 202 / 95,619 | h264, hevc, av1, vp8/9, mpeg2/4, prores decoders+encoders; mp4, mkv, webm, mpegts, avi, mov demux/mux; hls, dash, rtp; srt/ass/vtt/ttml/pgs, cea608/708; seeking, thumbnails, hdr, metadata |
audio/ | 77 / 30,164 | aac, mp3, opus, vorbis decoders; flac, wav, aiff, m4a, ogg…; fft, resampler, eq, limiter, loudness, gapless, crossfade; playlist |
image/ | 66 / 42,557 | png, jpeg, webp, avif, heic, gif, bmp, tiff, jxl, svg…; draw, blend, compose, colorspace |
CLAUDE.md forbids Zig in this repo but explicitly blesses Home's Zig-implemented kernel packages ("Home provides these built-in kernel support modules"). The question is whether audio/video/image get the same status.
Decision (recommended)
Treat packages/{audio,video,image,media} as Home standard library, shipped by the Home toolchain and linked into HomeOS userspace through the existing Home bindings. HomeOS source stays 100 % .home; the OS repo never contains Zig. Conditions:
- They must build freestanding for aarch64 (no libc, no
std.heap.page_allocator, allocator injected, no threads unless via a Home threading shim) — #82. - Truth is measured by conformance corpora in CI, not line counts — #83. The decoder sizes (AAC 446 lines, MP3 624, Opus 430) are far below what conformant decoders usually need, so expect gaps; the corpus tells us which.
- A port-to-Home track is opened under compiler milestone A7 (self-hosting) so the stdlib eventually becomes Home too; not a v1 requirement.
- Hardware decode (HEVC on VideoCore VII) is a kernel driver in Home (#84), not stdlib.
Alternative rejected for v1: rewrite codecs in Home first — months of work before a single frame plays, and the Home compiler's aarch64 backend would be optimising codecs before it can boot a kernel.
Tasks
docs/adr/ADR-MC3-media-stdlib.mdwith the above; amend CLAUDE.md "When to Use Other Languages" to name the stdlib exception precisely (compiler-repo packages only, consumed via bindings, never vendored here).- Record the port-to-Home track as a MASTER_PLAN A7 sub-bullet.