Epic: #113 · Milestone: MC6 — Media engine
Why
Per ADR #45, the compiler repo's media packages (~168K lines) are the codec source. They currently assume a hosted environment (std.heap, std.Thread, files) and have never been built for aarch64 or freestanding. packages/video/src/codecs/ today holds only config.zig/utils.zig + BUILD_NOTES.md that links libx264/libx265 — so the encoder side depends on third-party libs; decoders must be checked one by one for hidden system deps.
Tasks
- Audit: for each decoder/demuxer/subtitle module, list external deps (
@cImport,linkSystemLibrary,std.fs,std.Thread,std.heap.page_allocator); producedocs/media/STDLIB_AUDIT.mdwith a keep/port/drop verdict. - Freestanding target in the packages'
build.zig(aarch64-freestanding-none,x86_64-freestandingfor CI): allocator interface injected from Home,no_std-style IO callbacks (read/seek from a Home stream), threads replaced by a job API the OS provides, panics → Home error returns. - Home bindings (
src/bindings/home.zig) regenerated as typed.homedeclarations underlibs/media/in this repo (declarations only, no Zig):Demuxer,VideoDecoder,AudioDecoder,ImageDecoder,SubtitleParser. - NEON: enable
-mcpu=cortex-a76, verify hot loops vectorise (IDCT, MC, deblock, colour convert); micro-benchmarks in the compiler repo's CI on an ARM runner. - Link the archives into HomeOS userspace ELF via the Home toolchain (
home buildlinks stdlib archives for the target). - x86 QEMU first: decode a clip inside HomeOS on x86 with the same bindings.
Acceptance
A .home program on x86 QEMU decodes 100 frames of the reference H.264 clip via the bindings; the same program cross-builds for aarch64-freestanding; sizes documented (target: video+audio+image archives ≤ 6 MB).
Size: L · Depends on: #45, #52 (for the ARM half) · Blocks: #83, #85, #78