Step 1 — separate brightness from color
The encoder first converts red, green and blue into a different set of three numbers: one for luma (brightness) and two for chroma (color).
This is not compression by itself — it is preparation. Human vision resolves brightness far more finely than color, so once the two are separated the encoder can treat them differently, and spend its bytes where they will be noticed.