Video typically stores frames using YCbCr, as opposed to RGB. There is a lot of mis-information on YCbCr (informally YUV) and RGB on the internet, so let’s clear it up.
What is YCbCr?
Y represents Luma. This is essentially the black & white component.
Cb is related to blue. Technically, it is proportional to the difference between Y and blue.
Cr is proportional to the difference between Y and red.
Notice that there is no “Cg”. Green can be derived using the existing Y, Cb, and Cr channels.
YCbCr and RGB are not color spaces, but you can represent colors as YCbCr or RGB in each color space.
There are a few widely-used color spaces: SD, HD, and UHD.
- SD is defined in the ITU specification BT.601. Technically, there are two SD color spaces, NTSC (used in the US), and PAL (used in Europe).
- HD is defined in BT.601.
- UHD is defined in BT.2020.
The most common is the BT.709 color space, although the BT.2020 color space is the most recent and gaining popularity. BT.601 is old and was used for currently obsolete TV sets.
There is also an Apple-defined color space called Display P3, which is a combination of BT.709 and yet another color specification called DCI-P3.
Beyond this, there are other rarer color spaces yet.
YCbCr values can be full-range or video-range.
For 8-bit samples, full-range can take on the full range of 0 through 255 of an 8-bit value. Video range is limited to 16 through 254.
The reason video range exists is to transmit a video signal over a wire as a voltage. Values outside of the video range are used to synchronize to the start of a video frame, or the start of a row of pixels, and can also contain metadata. Video can be transmitted using HDMI, an SDI signal in professional equipment, or a MIPI CSI signal from mobile device cameras.
The transfer characteristics or transfer function is the way a voltage is mapped to an integer value, so if you are converting between RGB and YCbCr in memory, you will not need to account for this.
Each of the BT.601, BT.709, and BT.2020 each specify their own transfer functions.
Color primaries are defined by each of the BT specifications. They are two-dimensional coordinates in the CIE color diagram. The three R, G, and B coordinates form a triangle that specifies the gamut, or full set of colors.
Notice that the BT.2020 color space is much larger than BT.709. Because 8-bit color can only represent 256 values per channel, there are larger steps between colors in 8-bit BT.2020. To compensate for this, video using the BT.2020 color space should use at least 10-bit color.
It’s a bit confusing that the BT standards for YCbCr define the color spaces in terms of red, green and blue. These standards define both RGB and YCbCr, as well as how to convert between them.
You may have heard of sRGB. This is RGB defined in terms of BT.709.
The white point, also called reference white, is defined as a 2D coordinate into the CIE 1931 chromaticity diagram, similar to the way color primaries are defined. This is the color displayed when R, G, and B are at their maximum values.
BT.601, BT.709, BT.2020, and Display P3 all share the same white point, D65. In the CIE 1931 chromaticity diagram, this is at point (0.3127, 0.3290).
Human beings do not perceive color or luminance linearly. For a linear increase in our perception, it requires an exponential increase in luminance or color.
If colors were to be represented as the raw signal collected at the sensor, we would see increasing a dark value by amount x and a light value by the same value x, would appear to us as a larger change in the darker value than in the lighter color.
To match the numbers with our perception, we need to apply gamma correction.
You may also see gamma correction referred to as “conceptual non-linear pre-correction”.
What about Apple’s Display P3?
Apple created a new color space, which is a mixture of BT.709 and another standard, DCI-P3. Specifically, it shares the white point and gamma curve of BT.709, but uses the color primaries defined in DCI-P3.
Notice that the Display P3 color space is larger than BT.709 (and hence sRGB), but it is smaller than BT.2020.
Where to go from here
The specs list the color primaries, gamma functions, transfer functions, YCbCr conversion, and white point for each color space.
BT.601 (SD) specification
BT.709 (HD) a.k.a. sRGB
BT.2020 (UHD) specification