ReviewOS

home-lang/home-os

Build the Home stdlib `audio` / `video` / `image` packages freestanding for aarch64 (no libc, injected allocator, no OS threads, NEON) and expose them to HomeOS through Home bindings

#82
Open chris opened this 9 days ago ·
9 days ago

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); produce docs/media/STDLIB_AUDIT.md with a keep/port/drop verdict.
  • Freestanding target in the packages' build.zig (aarch64-freestanding-none, x86_64-freestanding for 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 .home declarations under libs/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 build links 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

Sign in to comment on this issue.