Code values don't map linearly to brightness. The transfer curve separates SDR from HDR. Gamma, PQ vs HLG, and the CICP tags that keep HDR from looking gray.
Many engineers gloss over this part. Get it right and you'll be well ahead in HDR work.
SDR = Standard Dynamic Range, HDR = High Dynamic Range. 'Dynamic range' here means the span between the darkest and brightest points a screen can represent simultaneously within a single scene. SDR keeps this span narrow (peak brightness around 100 nits), while HDR uses a much wider span, 1,000 to 10,000 nits. In other words, HDR isn't a vague 'better picture quality' but a concrete spec difference: a wider range of light and dark itself.
Say you're taking a photo in a room where the view outside the window is blazing bright and the interior is dark. With normal mode (the SDR equivalent), if you expose for the scenery outside, the interior is crushed to black; if you expose for the interior, the outside blows out to white — you can't have both. HDR mode, by contrast, keeps the detail in both bright and dark areas at the same time. A real camera's HDR mode merges multiple exposures, so it's implemented differently from video HDR, but the goal — 'preserve both the bright and the dark in a single frame' — is exactly the same.
HDR is originally a spec about brightness (dynamic range). In reality, though, HDR content almost always comes bundled with a wider color gamut (BT.2020, WCG) and bit depth of 10 or more, so it's easy to get the impression that 'HDR = more vivid color and better picture quality.' Keep in mind that it's a separate axis from the color gamut (BT.2020), covered later in this chapter, and you won't get confused.
"Is code value 128 half of maximum brightness?" — The answer is no. Between code values and physical brightness there's a nonlinear curve called the transfer function.
Two reasons, one historical and one physiological, overlap.
① was purely a hardware matter and ② is physiology, yet the shapes of the curves were almost the same. Thanks to that, gamma correction became both a 'compatibility device' and a 'perceptually optimal encoding.' It's the luckiest coincidence in video history.
This is the video we've watched for decades. The reference white is about 100 nit (cd/m²), and the curves are the BT.709 OETF / BT.1886 EOTF. The important point is that in SDR, code value 235 (white) isn't 'an absolute brightness of 100 nit' but 'the white that display can produce.' In other words, it's relative.
PQ commands 'this pixel shall glow at exactly 350 nit.' The creator's intent is preserved exactly, but if the display can't produce that brightness, tone mapping is needed. HLG says 'this pixel shall glow at some percentage of your maximum brightness.' It looks decent on whatever display you plug it into, so it suits live broadcasts.
This is the crux. The codec itself doesn't 'compress' HDR. What a codec does is just compress numbers, and metadata tells you how to interpret those numbers. Three codes go inside the bitstream's VUI (Video Usability Information).
colour_primaries : what the color gamut is (1=BT.709, 9=BT.2020)
transfer_characteristics: what the transfer function is (1=BT.709, 16=PQ, 18=HLG)
matrix_coefficients : RGB<->YCbCr coefficients (1=BT.709, 9=BT.2020 NCL)The cause of "the HDR video looks gray" or "the colors look weirdly neon" is mostly a missing or wrong CICP tag. The pixel data is fine, but the player interpreted PQ as gamma 2.4. Checking that the trio is preserved when transcoding is absolute basics. You can check it in ffprobe -show_streams via the three fields color_primaries / color_transfer / color_space. The steps for diagnosing why colors look washed out are covered in Chapter 14.
Standard Dynamic Range. The traditional spec with a narrow light-to-dark span. Reference white about 100 nit.
High Dynamic Range. A spec with a wide light-to-dark span. Highlights stay alive up to 1,000+ nit.
OETF is light → code value (camera); EOTF is code value → light (display).
An HDR transfer function based on absolute brightness. Up to 10,000 nit.
HDR based on relative brightness. Backward compatible with SDR; used for broadcast.
A table that standardizes primaries/transfer/matrix as numbers. ITU-T H.273.
Unit of brightness. SDR reference white ≈100, HDR highlights 1000+.
Rearranging brightness to fit a display with a different range.
What is the most essential difference between PQ and HLG?
When an HDR video plays back hazy with strange saturation, what should you suspect first?