nx_uxf_remux.nx
buildroot/runtime/nx_uxf_remux.nx
about
nx_uxf_remux.nx -- FM4: the frame-level LOSSLESS REWRAP, extracted from nx_uxf_remux_test so that it has a
CALLABLE ENTRY POINT (2026-09-06).
WHY THIS EXISTS. The remux data-flow was proven byte-identical in June 2026 and the proof lived INSIDE a
test with no function anything could call, so the capability was real and uncomposable at the same time.
The formats board ranked that #1 for exactly that reason. This is the extraction; nx_uxf_remux_gate drives
it and asserts the same five properties the original test asserted.
WHAT IT DOES. Parses one EBML element carrying a frame (the MKV input side) and REWRAPS those exact bytes
into a minimal MP4 of ftyp + mdat + stsz (the MP4 output side). The frame is COPIED, never re-encoded --
that is the whole point, and it is what makes the endpoint-negotiation REMUX plan honest.
HONEST SCOPE, UNCHANGED FROM THE ORIGINAL: one frame, flat structure. A spec-complete PLAYABLE MKV to MP4
needs a real SimpleBlock header decode, multi-frame and multi-track sample tables stts stsc stco, codec
private data in stsd, timestamps and proper moov nesting. That is FM5 and it is not claimed here.
Defensive at the boundary (Rule 12): a malformed vint, a frame running past the input, or an output that
would not fit are each REFUSED BY NAME rather than truncated.
PROVENANCE 2026-09-06: extracted from nx_uxf_remux_test to close formats rung FM4, which ranked first on
that board precisely because a capability with no callable entry point cannot be composed. This comment is
also the probe for a build-cache question: a comment-only edit compiles byte-identical, so if the cache key
of a DEPENDENT gate changes when this file changes, the key covers the import closure.
license_tier: ORIGINAL No hw writes (Rule 26).
dependencies 1 imports · 3 importers
imports: nx_syscalls.nx
imported by: nx_uxf_ebml_gate.nxnx_uxf_mp4box_gate.nxnx_uxf_remux_gate.nx
structs
| none |
consts
| 25 | const UXR_OK: i64 = 0 |
| 26 | const UXR_ERR_VINT: i64 = 0-1 // leading byte is not a legal EBML vint |
| 27 | const UXR_ERR_OVERRUN: i64 = 0-2 // the declared frame runs past the input buffer |
| 28 | const UXR_ERR_CAPACITY: i64 = 0-3 // the rewrapped MP4 would not fit in outcap |
| 30 | const UXR_META_ID: i64 = 0 |
| 31 | const UXR_META_FRAMESIZE: i64 = 1 |
| 32 | const UXR_META_MDAT_OFF: i64 = 2 |
| 33 | const UXR_META_STSZ_OFF: i64 = 3 |
| 34 | const UXR_META_SLOTS: i64 = 4 |
| 37 | const UXR_FIXED_OVERHEAD: i64 = 52 |
| 38 | const UXR_STSZ_SAMPLESIZE_OFF: i64 = 12 // from the stsz box start: 8 header + 4 version-and-flags |
functions
| 41 | func uxr_vint_len(b: i64) -> i64 |
| 52 | func uxr_read_id(buf: *u8, pos: *i64) -> i64 |
| 62 | func uxr_read_size(buf: *u8, pos: *i64) -> i64 |
| 74 | func uxr_w32(out: *u8, off: i64, v: i64) -> i64 { out[off] = ((v >> 24) & 0xff) as u8; out[off + 1] = ((v >> 16) & 0xff) as u8; out[off + 2] = ((v >> 8) & 0xff) as u8; out[off + 3] = (v & 0xff) as u8; return off + 4 } |
| 75 | func uxr_r32(buf: *u8, off: i64) -> i64 { return ((buf[off] as i64) * 16777216) + ((buf[off + 1] as i64) * 65536) + ((buf[off + 2] as i64) * 256) + (buf[off + 3] as i64) } |
| 76 | func uxr_4cc(out: *u8, off: i64, a: i64, b: i64, c: i64, d: i64) -> i64 { out[off] = a as u8; out[off + 1] = b as u8; out[off + 2] = c as u8; out[off + 3] = d as u8; return off + 4 } |
| 77 | func uxr_box_begin(out: *u8, off: i64, a: i64, b: i64, c: i64, d: i64) -> i64 { uxr_w32(out, off, 0); uxr_4cc(out, off + 4, a, b, c, d); return off + 8 } |
| 78 | func uxr_box_end(out: *u8, start: i64, cur: i64) -> i64 { uxr_w32(out, start, cur - start); return cur } |
| 79 | func uxr_copy(out: *u8, off: i64, src: *u8, srcoff: i64, n: i64) -> i64 { var i: i64 = 0; while i < n { out[off + i] = src[srcoff + i]; i = i + 1 } return off + n } called by 1: uxf_remux_frame |
| 82 | func uxr_walk_ok(buf: *u8, n: i64) -> i64 { var off: i64 = 0; while (off + 8) <= n { let sz: i64 = uxr_r32(buf, off); if sz < 8 { return 0 } off = off + sz } if off == n { return 1 } return 0 } |
| 83 | func uxr_bytes_eq(a: *u8, aoff: i64, b: *u8, boff: i64, n: i64) -> i64 { var i: i64 = 0; while i < n { if a[aoff + i] != b[boff + i] { return 0 } i = i + 1 } return 1 } |
| 88 | func uxf_remux_frame(inb: *u8, inlen: i64, out: *u8, outcap: i64, meta: *i64) -> i64 |
| 128 | func uxf_remux_src_off(inb: *u8) -> i64 |