code wiki / _hdl_build / nx_mp4_mux.nx

nx_mp4_mux.nx

buildroot/runtime/_hdl_build/nx_mp4_mux.nx

7612 B111 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind librarytopic mp4
docsdependenciesstructsconstsfunctions

about

nx_mp4_mux.nx -- SOVEREIGN ISOBMFF (MP4) MUXER. Closes the ffmpeg "remux to MP4 for final output" gap with the Nishi stack: writes a standard, faststart (moov-before-mdat) .mp4 from an elementary video stream + its codec config -- the container a downloader needs so HLS/DASH segments (and later a video+audio pair) play everywhere. We already had the DEMUX side (nx_m4b_book: be32/find_atom atom walker); this is the MUX side it lacked. An MP4 is a tree of boxes [size:u32be][type:4][payload]; sizes are BACKPATCHED after nested content is written (robust vs hand-computed sizes). Single video track here; audio track (mp4a/esds) + interleave = the next rung. license_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_syscalls.nx nx_mp4_mux.nx nx_mp4_mux_gate.nx

imports: nx_syscalls.nx

imported by: nx_mp4_mux_gate.nx

structs

none

consts

none

functions

10func mm_w8(b: *u8, o: i64, v: i64) -> i64 { b[o] = (v & 0xff) as u8; return o + 1 }
called by 1: mp4_mux_video
11func mm_w16(b: *u8, o: i64, v: i64) -> i64 { b[o] = ((v>>8)&0xff) as u8; b[o+1] = (v&0xff) as u8; return o + 2 }
called by 1: mp4_mux_video
12func mm_w32(b: *u8, o: i64, v: i64) -> i64 { b[o] = ((v>>24)&0xff) as u8; b[o+1] = ((v>>16)&0xff) as u8; b[o+2] = ((v>>8)&0xff) as u8; b[o+3] = (v&0xff) as u8; return o + 4 }
13func mm_tag(b: *u8, o: i64, t: *u8) -> i64 { b[o]=t[0]; b[o+1]=t[1]; b[o+2]=t[2]; b[o+3]=t[3]; return o + 4 }
called by 1: mp4_mux_video
14func mm_bytes(b: *u8, o: i64, src: *u8, n: i64) -> i64 { var i: i64=0; while i<n { b[o+i]=src[i]; i=i+1 } return o + n }
called by 1: mp4_mux_video
15func mm_zeros(b: *u8, o: i64, n: i64) -> i64 { var i: i64=0; while i<n { b[o+i]=0 as u8; i=i+1 } return o + n }
called by 1: mp4_mux_video
16func mm_patch(b: *u8, at: i64, endo: i64) -> i64 { mm_w32(b, at, endo - at); return 0 } // box size = end-start
called by 1: mp4_mux_video calls 1: mm_w32
17func mm_matrix(b: *u8, o: i64) -> i64 { // ISO unity matrix
called by 1: mp4_mux_video calls 1: mm_w32
27func mp4_mux_video(out: *u8, w: i64, h: i64, timescale: i64, dur: i64, avcc: *u8, avcc_len: i64, sampdata: *u8, sizes: *i64, nsamps: i64) -> i64