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