ColorWeb-CG icon indicating copy to clipboard operation
ColorWeb-CG copied to clipboard

Common-ize the rec2100-pq/hlg/display-linear conversions

Open ccameron-chromium opened this issue 8 months ago • 1 comments

This issue is to propose that we standardize all conversions to go through the rec2100 reference display (the 1,000 nit one).

This way, for converting to/from any of rec2100-pq, rec2100-hlg, and rec2100-display-linear, we follow the algorithm of:

  • Convert the source color space to reference display luminance
  • Convert from reference display luminance to destination color space (using the inverse function of the one used to convert to reference display luminance).

The conversions to reference display luminance are:

  • rec2100-display-linear:
    • multiply by 203 nits
  • rec2100-pq:
    • apply the PQ EOTF
  • rec2100-hlg:
    • apply the HLG inverse-OETF
    • apply the HLG OOTF for a 1,000 nit display (gamma=1.2)
    • multiply by 1,000 nits.
  • srgb:
    • apply the sRGB to linear transfer function
    • apply the matrix to convert from sRGB primaries to Rec2020 primaries
    • multiply by 203 nits

In this scheme the CSS color of (SDR) 'white' will map to a 75% HLG signal, or 203 nits.

When converting from any of rec2100-display-linear, rec2100-pq, or rec2100-hlg to any other color space (any SDR color space), then a default tone mapping must be performed to map the maximum HDR brightness (which is 1,000 nits by default) to the maximum SDR brightness (which is 203 nits by default), before converting to the SDR color space. To write this out explicitly, the algorithm is:

  • Convert the source color space to reference display luminance
  • Tone map the image so that its maximum luminance is 203 nits
  • Convert from reference display luminance to destination color space
    • Divide by 203 nits
    • Apply the matrix to convert from Rec2020 primaries to the XYZD50 profile connection space
    • Convert to the target SDR color space

I have opinions about the exact contents of the second step (tone mapping down), but I'd want to ensure agreement on the general structure first.

ccameron-chromium avatar Oct 26 '23 20:10 ccameron-chromium