wai-rs: jpegai_pipeline::yuv_to_rgb / rgb_to_yuv — BT.709 colour combine #12

Merged
dcharlot merged 1 commit from feat/jpegai-color into main 2026-07-14 10:45:17 -04:00

2026-07-14

Transaction Science
wai-rs: jpegai_pipeline::yuv_to_rgb / rgb_to_yuv — BT.709 colour combine (float-exact)
The final pixel transform before the output image: BT.709 full-range YUV↔RGB, planes
normalised to [0,1], chroma carrying the +0.5 offset.

  r = y + Kry·(v-½) ; b = y + Kby·(u-½)
  g = y - (Kb·Kby/Kg)·(u-½) - (Kr·Kry/Kg)·(v-½)
  (Kr,Kg,Kb,Kby,Kry = 0.2126, 0.7152, 0.0722, 1.8556, 1.5748)

rgb_to_yuv is the exact inverse (for round-trip / re-encode). Validated against a
BT.709-formula golden (max|Δ| = 1e-7) plus unit tests: greyscale (u=v=½ → r=g=b=y) and
rgb→yuv→rgb round-trip identity to float precision.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-07-14 10:38:43 -04:00