nx_colorspace.nx
buildroot/runtime/nx_colorspace.nx
about
nx_colorspace.nx -- sovereign RGB <-> YCbCr (JFIF/BT.601 full-range) + 4:2:0 chroma subsample. The video codec
(nx_vmotion/vtransform/ventropy) is per-plane 8bpp; real video is colour, so the sender converts the browser's
RGB to Y (full res) + Cb,Cr (half res = 4:2:0, since the eye is far less sensitive to chroma) and codes each
plane; the receiver upsamples + converts back. Integer-only (no FPU). The browser only extracts RGB from the
canvas (last mile); ALL colour math is here. license_tier: ORIGINAL
dependencies 0 imports · 1 importers
imports: none
imported by: nx_colorspace_gate.nx
structs
| none |
consts
| none |
functions
| 7 | func cs_clamp(v: i64) -> i64 { if v < 0 { return 0 } if v > 255 { return 255 } return v } |
| 11 | func cs_y(r: i64, g: i64, b: i64) -> i64 { return cs_clamp((77*r + 150*g + 29*b) / 256) } |
| 12 | func cs_cb(r: i64, g: i64, b: i64) -> i64 { return cs_clamp(((0-43)*r - 85*g + 128*b) / 256 + 128) } |
| 13 | func cs_cr(r: i64, g: i64, b: i64) -> i64 { return cs_clamp((128*r - 107*g - 21*b) / 256 + 128) } |
| 15 | func cs_r(y: i64, cb: i64, cr: i64) -> i64 { return cs_clamp(y + (359*(cr-128)) / 256) } |
| 16 | func cs_g(y: i64, cb: i64, cr: i64) -> i64 { return cs_clamp(y - (88*(cb-128)) / 256 - (183*(cr-128)) / 256) } |
| 17 | func cs_b(y: i64, cb: i64, cr: i64) -> i64 { return cs_clamp(y + (454*(cb-128)) / 256) } |
| 20 | func cs_rgb_to_yuv(r: *u8, g: *u8, b: *u8, n: i64, y: *u8, cb: *u8, cr: *u8) -> i64 |
| 31 | func cs_yuv_to_rgb(y: *u8, cb: *u8, cr: *u8, n: i64, r: *u8, g: *u8, b: *u8) -> i64 |
| 43 | func cs_subsample(full: *u8, W: i64, H: i64, half: *u8) -> i64 called by 1: main |
| 60 | func cs_upsample(half: *u8, W: i64, H: i64, full: *u8) -> i64 called by 1: main |