CSS Color HDR Module Level 1

Unofficial Proposal Draft,

This version:
https://drafts.csswg.org/css-color-hdr/
Latest published version:
https://www.w3.org/TR/css-color-hdr/
Issue Tracking:
CSSWG Issues Repository
Inline In Spec
Editor:
Chris Lilley (W3C)
Suggest an Edit for this Spec:
GitHub Editor

Abstract

This module explores additions to CSS Color 4 to enable High Dynamic Range (HDR).

CSS is a language for describing the rendering of structured documents (such as HTML and XML) on screen, on paper, etc.

Status of this document

This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at https://www.w3.org/TR/.

Please send feedback by filing issues in GitHub (preferred), including the spec code “css-color-hdr” in the title, like this: “[css-color-hdr] …summary of comment…”. All issues and comments are archived. Alternately, feedback can be sent to the (archived) public mailing list www-style@w3.org.

This document is governed by the 15 September 2020 W3C Process Document.

This document was produced by a group operating under the W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.

1. Introduction

This section is not normative.

CSS Color 4 adds Wide Color Gamut (WCG) color spaces to the Open Web Platform. By design, these are all Standard Dynamic Range (SDR) color spaces. This specification explores what additions might be suitable to also add High Dynamic Range (HDR).

While WCG specifications have been broadly stable for some decades, HDR standards are less mature and have undergone frequent revision in the last decade.

This specification is a collection of ideas and has no status whatsoever. It is not even an Editors Draft and has not been reviewed or adopted by the CSS Working Group.

1.1. Value Definitions

This specification follows the CSS property definition conventions from [CSS2] using the value definition syntax from [CSS-VALUES-3]. Value types not defined in this specification are defined in CSS Values & Units [CSS-VALUES-3]. Combination with other CSS modules may expand the definitions of these value types.

In addition to the property-specific values listed in their definitions, all properties defined in this specification also accept the CSS-wide keywords as their property value. For readability they have not been repeated explicitly.

2. Predefined color spaces for HDR:

In addition to the SDR color spaces defined by CSS Color 4, the following HDR color spaces are defined for use in the color function CSS Color 4 § 10.1 Specifying profiled colors: the color() function.

Serialization of values in these new color spaces is identical to the description in CSS Color 4 § 4.7 Serializing <color> Values.

2.1. rec2100-pq

The rec2100-pq [Rec_BT.2100] color space accepts three numeric parameters, representing the red, green, and blue channels of the color, with each having a valid range of [0, 1] regardless of the actual bit depth (10 or 12 bits per component).

This is to avoid confusion if [0, 1024] and [0, 4096] encoded values are mixed up. Add examples showing conversion from binary values to the [0, 1] range.

should this specification recommend that the CSS Object Model store these values in the 16-bit half-floating point representation (IEEE standard 754-2008.) from BT.2100 pp. 9-10? (or any wider representation, like float or double)?

should the values accept % as well as number? so 19% as well as 0.19. Probably yes.

The Perceptual Quantizer (PQ) electro-optical transfer function is used [SMPTE-ST-2084],[Rec_BT.2100]. PQ assumes a reference viewing condition where the screen surround is at 5 cd/m².

ITU Reference 2100 is used for HDR 4k and 8k television.

In contrast to SDR color spaces and some HDR color spaces, the PQ values are absolute rather than relative.

add a diagram showing SDR and HDR dynamic ranges on a log scale

It has the following characteristics: (The display primaries are the same as [Rec.2020]):

x y
Red chromaticity 0.708 0.292
Green chromaticity 0.170 0.797
Blue chromaticity 0.131 0.046
White chromaticity 0.3127 0.3290
Transfer function Perceptual Quantizer
White luminance 203 cd/m²
Peak white luminance 10,000 cd/m²
Black luminance 0.001 cd/m²
Image state display-referred
Percentages Allowed for R, G and B

from BT.2100 p.3 "Note 3d – For PQ in a non-reference viewing environment, or for HLG (in any viewing environment), the black level should be adjusted using the PLUGE test signal and procedure specified in Recommendation ITU-R BT.814."

This color represents a blinding white with a luminance of 10,000 cd/m². Such a bright color can only be displayed briefly, on a small area of the screen. Content is typically mastered with a lower peak white, such as 4,000 cd/m².
 color(rec2100-pq 1.0 1.0 1.0);
This color represents a comfortable "diffuse white" This color can be displayed for long periods, or used for subtitles, on any sized area of the screen. Diffuse white is 203 cd/m².
 color(rec2100-pq 0.58 0.58 0.58);

This color represents a mid grey, like a photographer’s "18% reflectance grey" card, at 17 cd/m².

 color(rec2100-pq 0.34 0.34 0.34);

add other examples, including encoding of sRGB red, green, blue and P3 red, green, blue.

Linear-light RGB signals are converted to PQ encoded as follows. An absolute luminance scale is used, so the luminance of diffuse (media) white is required to scale relative luminances. The maximum encodable value (peak, small-area white) in PQ is 10,000 cd/m². Media white is 203 cd/m² [Rpt_BT.2408].

var Er;      // the red, green or blue component, [0, 1] for SDR, [0, 70ish] for HDR
var Yw = 203;  // the absolute luminance of diffuse white, cd/m²
var x = Er * Yw / 10000;   // absolute luminance of peak white is 10,000 cd/m².
const n = 2610 / (2 ** 14);
const m = 2523 / (2 ** 5);
const c1 = 3424 / (2 ** 12);
const c2 = 2413 / (2 ** 7);
const c3 = 2392 / (2 ** 7);
xPQ = (((c1 + (c2 * (x ** n))) / (1 + (c3 * (x ** n)))) ** m);

xPQ is the "gamma-corrected" (OETF-adjusted) signal [0, 1].

PQ encoded values are converted to linear-light as follows:

var xPQ;      // the red, green or blue PQ-encoded component, [0, 1]
const ninv = (2 ** 14) / 2610;
const minv = (2 ** 5) / 2523;
const c1 = 3424 / (2 ** 12);
const c2 = 2413 / (2 ** 7);
const c3 = 2392 / (2 ** 7);
var x = (((Math.max(((xPQ ** minv) - c1), 0) / (c2 - (c3 * (xPQ ** minv)))) ** ninv);
var Yw = 203;      // the absolute luminance of diffuse white, cd/m²
var Ea = x * 10000;   // absolute luminance, [0, 10,000].
var Er = x * 10000 / Yw;   // luminance relative to diffuse white, [0, 70 or so].

2.2. rec2100-hlg

The rec2100-hlg [Rec_BT.2100] color space accepts three numeric parameters, representing the red, green, and blue channels of the color, with each having a valid range of [0, 1] regardless of the actual bit depth (10 or 12 bits per component).

The Hybrid Log-Gamma (HLG) electro-optical transfer function is used [ARIB_STD-B67],[Rec_BT.2100]. HLG can be used with displays of different brightness in a wide range of viewing environments, with user control of the overall brightness level. A value of 0.75 represents "diffuse" or "media" white while an "18% reflectance grey" card has a value of 0.38. [Rec_BT.2390].

It has the following characteristics: (The display primaries are the same as [Rec.2020]):

x y
Red chromaticity 0.708 0.292
Green chromaticity 0.170 0.797
Blue chromaticity 0.131 0.046
White chromaticity 0.3127 0.3290
Transfer function Hybrid log Gamma
White luminance
depends on viewing conditions
Peak white luminance 12 times reference white
Black luminance depends on reference white, see text
Image state scene-referred
Percentages Allowed for R, G and B

add other examples

This color represents a comfortable "diffuse white" This color can be displayed for long periods, or used for subtitles, on any sized area of the screen. Content is typically mastered with a peak white of 1,000 to 4,000 cd/m², so diffuse white will be 203 to 581 cd/m².
 color(rec2100-hlg 0.75 0.75 0.75);

This color represents a mid grey, at 26 to 104 cd/m².

 color(rec2100-hlg 0.38 0.38 0.38);

Linear-light RGB signals are converted to HLG encoded as follows [Rec_BT.2390]:

var E;      // the red, green or blue component, [0, 1]
const a = 0.17883277;
const b = 0.28466892;   // 1 - (4 * a)
const c = 0.55991073;   // 0.5 - a * Math.log(4 *a)
if (E <= 1/12) {
  Edash = Math.sqrt( 3 * E);
}
else {
  Edash = a * Math.log(12 * E - b) + c;
}

Edash is the "gamma-corrected" (OETF-adjusted) signal.

The reverse conversion (HLG encoded to linear light) is as follows [Rec_BT.2390]::

var Edash;      // the red, green or blue encoded component, [0, 1]
const a = 0.17883277;
const b = 0.28466892;   // 1 - (4 * a)
const c = 0.55991073;   // 0.5 - a * Math.log(4 *a)
if (Edash <= 0.5) {
  E = (Edash ** 2) / 3;
}
else {
  E = Math.exp(((Edash - c) / a) + b) / 12;
}

add black level lift Β as defined on same page?

2.3. Jzazbz

The Jzazbz color space [Safdar-PUCS] accepts three numeric parameters, with Jz representing the Lightness (similar to L in Lab) while az and bz represent the redness-greenness and yellowness-blueness opponent-color axes (similar to a and b in Lab).

CIE Lab uses a lightness scale with a [0%, 100%] range, relative to media white, and has been experimentally extended to L=400%. In contrast, the Jz axis in Jzazbz, which has a [0, 1.0] range, uses Perceptual Quantizer encoding, and can represent a dynamic range of more than 13 stops.

It has the following characteristics:

x y
White chromaticity 0.3127 0.3290
Transfer function Perceptual Quantizer
Peak white luminance 10,000 cd/m²
Black luminance 0.001 cd/m²
Image state display-referred
Percentages Allowed for Jz, az and bz

Note that unlike Lab, a D65 whitepoint is used. Thus, for most RGB spaces (which also use a D65 whitepoint) no chromatic adaptation step need be performed.

2.4. JzCzHz

Similar to LCH, which is the polar representation of Lab, JzCzHz is the polar form of Jzazbz. Jz is identical to the value in JzCzHz and represents the Lightness, while Cz represents the Chroma or colorfulness and Hz represents a hue angle, measured from the positive az axis, towards the positive bz axis.

This color represents the sRGB color "lime" in Jzazbz
 color(jzazbz 0.17542 -0.1179 0.1092);

and here is the same color in the polar form

 color(jzczhz 0.17542 0.1614 132.50);

2.4.1. Converting Jzazbz colors to JzCzHz colors

Conversion to JzCzHz is trivial:

  1. Hz = atan2(bz, az) // but convert to degrees!
  2. Cz = sqrt(az^2 + bz^2)
  3. Jz is the same

2.4.2. Converting JzCzHz colors to Jzazbz colors

Conversion to Jzazbz is trivial:

  1. az = Cz cos(H) // convert to radians first!
  2. bz = Cz sin(H) // convert to radians first!
  3. Jz is the same

2.5. ICtCp

The ICtCp color space is defined as Constant Intensity ICTCP signal format in [Rec_BT.2100] and accepts three numeric parameters, with I representing the Intensity (similar to L in Lab, but covering a luminance range up to 10,000 cd/m2) while CT and CP represent the yellowness-blueness (tritanope) and redness-greenness (protanope) opponent-color axes (similar to b and a, respectively, in Lab).

It is based on human visual system LMS cone primaries; the Hunt-Pointer-Estevez (HPE) XYZ to LMS transform is used, normalized to a D65 white point. A crosstalk matrix is then applied, to reduce the gamut hull concavities of BT.2020 RGB, thus reducing interpolation errors. The crosstalk also provides improved lines of constant hue and improved uniformity of Just Noticeable Difference (JND) MacAdam ellipses.

It has the following characteristics:

x y
White chromaticity 0.3127 0.3290
Transfer function Perceptual Quantizer
White luminance 203 cd/m²
Peak white luminance 10,000 cd/m²
Black luminance 0.001 cd/m²
Image state display-referred
Percentages Allowed for I, Ct and Cp

Although [Rec_BT.2100] defines ICTCP by a conversion from linear-light BT.2100 RGB [Rec_BT.2100], this conversion proceeds via LMS and thus, any other color space can also be represented by applying an XYZ to LMS transform.

Note that unlike Lab, a D65 whitepoint is used.

Also unlike Lab, which has primarily been tested with lower-intensity reflective colors, ICTCP has been tested with high-chroma, self-luminous, and high intensity (HDR) colors. This makes it suitable for color difference measurement (deltaE ITP) and for gamut mapping of SDR and HDR colors.

This color represents the sRGB color "lime" in ICtCp
 color(ictcp 0.5393 -0.2643 -0.0625);

3. Compositing SDR and HDR content

Compositing should take place in CIE XYZ, as it is a linear-light space without gamut limitations. Implementations may chose to composite in a linear-light RGB space instead, which will give the same result provided out-of-gamut values (negative, or greater than 100%) are correctly handled and not clipped or gamut mapped until the final transfer to the device color space.

Relative HDR, using the HLG transfer function, must map SDR media white to the same luminance as is used to display the 75% HLG value. [SMPTE-ST-2084]

For further details, see also tables 3 and 4 in ITU Rpt_BT.2408-0 [Rpt_BT.2408]

Absolute HDR, using the PQ transfer function, should map SDR media white to 203 cd/m², the same luminance as is used to display the 58% PQ value. [SMPTE-ST-2084] However, implementations may chose to incorporate a color re-rendering step (OOTF) to account for non-reference viewing conditions.

Do the PQ-based color spaces require tone-mapping (OOTF) for display in different viewing environments?

Privacy and Security Considerations

Make some considerations about privacy and security.

Accessibility Considerations

Some individuals may have a sensitivity to very bright colors, so user agents should provide a mechanism to limit the maximum luminance at user option. The toe and knee procedure in section 5.4.1 Mapping to display with limited brightness range of [Rec_BT.2390] is suggested as suitable.

Conformance

Document conventions

Conformance requirements are expressed with a combination of descriptive assertions and RFC 2119 terminology. The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this document are to be interpreted as described in RFC 2119. However, for readability, these words do not appear in all uppercase letters in this specification.

All of the text of this specification is normative except sections explicitly marked as non-normative, examples, and notes. [RFC2119]

Examples in this specification are introduced with the words “for example” or are set apart from the normative text with class="example", like this:

This is an example of an informative example.

Informative notes begin with the word “Note” and are set apart from the normative text with class="note", like this:

Note, this is an informative note.

Advisements are normative sections styled to evoke special attention and are set apart from other normative text with <strong class="advisement">, like this: UAs MUST provide an accessible alternative.

Conformance classes

Conformance to this specification is defined for three conformance classes:

style sheet
A CSS style sheet.
renderer
A UA that interprets the semantics of a style sheet and renders documents that use them.
authoring tool
A UA that writes a style sheet.

A style sheet is conformant to this specification if all of its statements that use syntax defined in this module are valid according to the generic CSS grammar and the individual grammars of each feature defined in this module.

A renderer is conformant to this specification if, in addition to interpreting the style sheet as defined by the appropriate specifications, it supports all the features defined by this specification by parsing them correctly and rendering the document accordingly. However, the inability of a UA to correctly render a document due to limitations of the device does not make the UA non-conformant. (For example, a UA is not required to render color on a monochrome monitor.)

An authoring tool is conformant to this specification if it writes style sheets that are syntactically correct according to the generic CSS grammar and the individual grammars of each feature in this module, and meet all other conformance requirements of style sheets as described in this module.

Partial implementations

So that authors can exploit the forward-compatible parsing rules to assign fallback values, CSS renderers must treat as invalid (and ignore as appropriate) any at-rules, properties, property values, keywords, and other syntactic constructs for which they have no usable level of support. In particular, user agents must not selectively ignore unsupported component values and honor supported values in a single multi-value property declaration: if any value is considered invalid (as unsupported values must be), CSS requires that the entire declaration be ignored.

Implementations of Unstable and Proprietary Features

To avoid clashes with future stable CSS features, the CSSWG recommends following best practices for the implementation of unstable features and proprietary extensions to CSS.

Non-experimental implementations

Once a specification reaches the Candidate Recommendation stage, non-experimental implementations are possible, and implementors should release an unprefixed implementation of any CR-level feature they can demonstrate to be correctly implemented according to spec.

To establish and maintain the interoperability of CSS across implementations, the CSS Working Group requests that non-experimental CSS renderers submit an implementation report (and, if necessary, the testcases used for that implementation report) to the W3C before releasing an unprefixed implementation of any CSS features. Testcases submitted to W3C are subject to review and correction by the CSS Working Group.

Further information on submitting testcases and implementation reports can be found from on the CSS Working Group’s website at http://www.w3.org/Style/CSS/Test/. Questions should be directed to the public-css-testsuite@w3.org mailing list.

Index

Terms defined by this specification

Terms defined by reference

References

Normative References

[CSS-VALUES-3]
Tab Atkins Jr.; Elika Etemad. CSS Values and Units Module Level 3. 6 June 2019. CR. URL: https://www.w3.org/TR/css-values-3/
[CSS-VALUES-4]
Tab Atkins Jr.; Elika Etemad. CSS Values and Units Module Level 4. 16 October 2021. WD. URL: https://www.w3.org/TR/css-values-4/
[CSS2]
Bert Bos; et al. Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification. 7 June 2011. REC. URL: https://www.w3.org/TR/CSS21/
[Rec.2020]
Recommendation ITU-R BT.2020-2: Parameter values for ultra-high definition television systems for production and international programme exchange . October 2015. URL: http://www.itu.int/rec/R-REC-BT.2020/en
[Rec_BT.2100]
ITU-R BT.2100-2 Image parameter values for high dynamic range television for use in production and international programme exchange. July 2018. URL: https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.2100-2-201807-I!!PDF-E.pdf
[Rec_BT.2390]
ITU-R BT.2390-8 High dynamic range television for production and international programme exchange. February 2020. URL: https://www.itu.int/dms_pub/itu-r/opb/rep/R-REP-BT.2390-8-2020-PDF-E.pdf
[RFC2119]
S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. March 1997. Best Current Practice. URL: https://datatracker.ietf.org/doc/html/rfc2119
[Rpt_BT.2408]
Report ITU-R BT.2408-0 Operational practices in HDR television production. October 2017. URL: https://www.itu.int/dms_pub/itu-r/opb/rep/R-REP-BT.2408-2017-PDF-E.pdf
[Safdar-PUCS]
Safdar, Muhammad; et al. Perceptually uniform color space for image signals including high dynamic range and wide gamut. 26 June 2017. URL: https://www.osapublishing.org/DirectPDFAccess/33630C0F-CFF9-6328-FA6195B4E962F4D7_368272/oe-25-13-15131.pdf?da=1&id=368272&amp;seq=0&amp;mobile=no
[SMPTE-ST-2084]
ST 2084:2014 - SMPTE Standard - High Dynamic Range Electro-Optical Transfer Function of Mastering Reference Displays. 29 August 2014. URL: https://ieeexplore.ieee.org/document/7291452

Informative References

[ARIB_STD-B67]
Essential Parameter Values for the Extended Image Dynamic Range Television (EIDRTV) System for Programme Production. 3 July 2015. URL: https://www.arib.or.jp/english/html/overview/doc/2-STD-B67v1_0.pdf

Issues Index

This is to avoid confusion if [0, 1024] and [0, 4096] encoded values are mixed up. Add examples showing conversion from binary values to the [0, 1] range.
should this specification recommend that the CSS Object Model store these values in the 16-bit half-floating point representation (IEEE standard 754-2008.) from BT.2100 pp. 9-10? (or any wider representation, like float or double)?
should the values accept % as well as number? so 19% as well as 0.19. Probably yes.
add a diagram showing SDR and HDR dynamic ranges on a log scale
from BT.2100 p.3 "Note 3d – For PQ in a non-reference viewing environment, or for HLG (in any viewing environment), the black level should be adjusted using the PLUGE test signal and procedure specified in Recommendation ITU-R BT.814."
add other examples, including encoding of sRGB red, green, blue and P3 red, green, blue.
add other examples
add black level lift Β as defined on same page?
Do the PQ-based color spaces require tone-mapping (OOTF) for display in different viewing environments?
Make some considerations about privacy and security.