code wiki / (root) / nx_video_codec.nx

nx_video_codec.nx

buildroot/runtime/nx_video_codec.nx

21138 B522 linesdepth 3pulls 8 transitivereach 1 importersview sourcekind librarytopic video
docsdependenciesstructsconstsfunctions

about

nx_video_codec.nx -- NishiVideo v1: I-frame intra-coded video codec. Composes nx_dct8 + uniform quantisation + nx_video_frame. No P/B frames in v1; one frame stands alone, deterministic, audit-replayable. Pipeline (encode): pixel block (8x8 i64, range 0..255 luma) -> subtract 128 (centre on zero per JPEG convention) -> nx_dct8_forward_2d -> 64 frequency coefficients -> quantise: coeff_q = round(coeff / quant_step) -> pack as 64 int16 LE For a multi-block frame, concatenate per-block payloads. Then nx_vid_build_header + payload. Decode reverses: parse header -> for each block, unpack int16 coefficients -> dequantise (multiply by quant_step) -> IDCT -> add back 128 -> clamp to 0..255 -> output pixel block. Honest verdict vs Jitsi/Discord/Zoom (the codecs they use): WIN_axes: deterministic, audit-replayable (hash chain), patent-clean, refuses BAD_MAGIC frames cleanly (no silent corruption) LOSE_axes: rate-distortion at parity bitrate (no motion compensation in v1; no entropy coding yet; quantisation is uniform not perceptually-weighted) Named improvements queued: nx_motion_compensation, nx_zigzag_scan, nx_rle_coefficients, nx_range_code_coefficients, nx_chroma_subsample, nx_perceptual_quant_table. genealogy_id: nx_dct8_q10 + nx_video_frame_q10 + jpeg_iso_10918 + nx_voice_codec_v1_q10 lineage_id: nishi_video_codec_v1_q10

dependencies 7 imports · 1 importers

nx_syscalls.nx nx_dct8.nx nx_video_frame.nx nx_zigzag.nx nx_rle.nx nx_quant_table.nx nx_deblock.nx nx_video_codec.nx nx_video_codec_v1_adapter.nx

imports: nx_syscalls.nxnx_dct8.nxnx_video_frame.nxnx_zigzag.nxnx_rle.nxnx_quant_table.nxnx_deblock.nx

imported by: nx_video_codec_v1_adapter.nx

structs

69struct VideoCodecState

consts

48const NX_VID_FLAG_ENTROPY: i64 = 128
50const NX_VID_FLAG_DEBLOCK: i64 = 32
53const NX_VID_FLAG_MOTION: i64 = 16
54const NX_VID_MVR: i64 = 7 // motion search range +/-7 px (4-bit dx,dy)
59const NX_VID_FLAG_PERCEPTUAL_QUANT: i64 = 128
61const NX_VC_VID_VERDICT_UNKNOWN: i64 = 0
62const NX_VC_VID_VERDICT_OK: i64 = 1
63const NX_VC_VID_VERDICT_BUF_TOO_SMALL: i64 = 2
64const NX_VC_VID_VERDICT_BAD_PARAMS: i64 = 3
65const NX_VC_VID_VERDICT_FRAME_REJECTED: i64 = 4
66const NX_VC_VID_VERDICT_N: i64 = 5

functions

98func nx_vc_vid_init(
called by 1: nx_video_codec_v1_new calls 1: nx_dct8_init
136func nx_vc_vid_init_entropy(
calls 1: nx_zigzag_init
153func nx_vc_vid_set_perceptual_quant(
calls 1: nx_qt_luma
169func nx_vc_vid_set_deblock(s: *VideoCodecState, enabled: i64) -> i64
180func nx_vc_vid_set_reference(s: *VideoCodecState, ref: *i64) -> i64
189func nx_vc_vid_set_mvr(s: *VideoCodecState, mvr: i64) -> i64
197func nx_vc_vid_set_skip(s: *VideoCodecState, enabled: i64) -> i64
205func _qstep_for(s: *VideoCodecState, idx: i64) -> i64
called by 1: nx_vc_vid_encode
213func _w16(buf: *u8, off: i64, v: i64) -> i64
called by 1: nx_vc_vid_encode
221func _r16(buf: *u8, off: i64) -> i64
called by 1: nx_vc_vid_decode
270func nx_vc_vid_encode(
391func nx_vc_vid_decode(
518func nx_vc_vid_verdict_is_valid(v: i64) -> i64