Kodi DSPlayer – DirectShow Player for Windows
Part II: HDR to SDR Gamma Compression

Topics Covered:
  • What is HDR to SDR Tone Mapping;
  • Fundamentals of PQ HDR Video;
  • Dynamic Range Compression;
  • Mapping of PQ to Display Brightness;
  • HDR to SDR Tone Mapping Explained.

What is HDR to SDR Tone Mapping?

HDR to SDR tone mapping is a method of mapping PQ (Perceptual Quantizer) HDR source values to match a pure power SDR gamma curve. This is accomplished by using the SDR gamma luminance scale to create PQ HDR luminance values. If any SDR values are missing, dithering is added to offset the difference between the two luminance scales that leads to correct PQ EOTF tracking for any pre-determined gamma value (e.g., pure power 2.20, 2.30, 2.40, etc.). So HDR to SDR does not involve any loss of the original HDR signal, only a change in tone curve or gamma.

When done correctly, HDR to SDR tone mapping produces 1:1 PQ EOTF tracking for any scenes within the brightness capabilities of the display. If the brightness levels of any HDR source or scene rise above the available display peak nits, the SDR gamma curve rescales all PQ source values to fit the brightness of the SDR display curve.

The flexible nature of the SDR gamma curve allows absolute PQ curves brighter than the calibrated SDR display peak nits to be compressed to fit any calibrated peak nits. SDR gamma relies on scene-referred luminance and not display-referred luminance; displayed luminance in SDR is gamma is expressed as a ratio of the source mastering display rather than prescribe that the display produce an exact amount of luminance for each on-screen pixel. So HDR to SDR tone mapping takes any scenes brighter than the calibrated display nits and rescales them linearly with gamma compression to match the identical contrast ratio of the original source values with a lower average brightness for each value. This means the dynamic range of bright HDR sources is compressed in HDR to SDR tone mapping by using the relative SDR gamma scale to remap the average brightness of all source values so that the entire HDR scene is represented within a narrower display range.

The wholesale remapping of HDR to SDR tone mapping makes it both an absolute and relative representation of HDR videos. Scenes within the display nits can be represented with the identical PQ luminance as the director intended. But scenes mastered above the display peak nits are resized with the SDR gamma scale to have a relative representation of each HDR scene at a lower peak brightness.

This dynamic contrast scaling of HDR to SDR tone mapping is ideal for displays that have to constantly adjust the balance between maximizing displayed brightness and compressing high dynamic range by compressing contrast. PQ HDR videos can be mastered at nits levels from 0 nits to 10,000 nits with frame peaks that vary throughout the runtime. For a display such as a projector that simply cannot produce the highest nit levels in PQ HDR videos, there is a constant need to adjust the ratio of contrast and brightness, so bright HDR scenes are not clipped and dimmer HDR scenes are not crushed. The scalable nature of HDR to SDR tone mapping helps to maintain this balance by using the flexible SDR gamma scale as a dynamic contrast slider that can adjust the Average Picture Level (APL) in fine amounts to get just the right amount of contrast and brightness for each scene — with the added ability to adjust the global contrast of the presentation to your liking. This takes the inflexible and rigid nature of the PQ EOTF and remaps it for displays that need frequent and significant adjustments to the PQ curve to handle the varying high dynamic range of HDR content.

Fundamentals of PQ HDR Video

PQ HDR video looks at the video range as having two distinct ranges that can be utilized during content mastering: one range that uses the standard video range you are accustomed to and another extended range that is reserved for very bright detail. These bright details are used to light scenes with improved contrast and create a better sense of a natural and realistically lit world.

HDR Video Ranges:

Lower Range (0-100 nits):

Known as normal diffuse or SDR reference white.

The majority of an HDR image is located here.

Upper Range (100-10,000 nits):

Known as the HDR specular highlights.

These are hot spots in the image used to convey bright detail.

These bright details are meant for specular elements in the image that have a brightness level far above other image elements. This could include specular reflections and light sources with natural peaks as high as 10,000 nits that require greater mastered brightness to convey their depth, shape and texture as well as imply the relative brightness of these specular highlights compared to surrounding objects.

Example of "HDR hot spots" in a heatmap applied to HDR video games.
HDR specular highlights are shown in Orange, Red and Purple:


Click Here for Screen Size Image (Original by EvilBoris @resetera.com)

Image

You would see a similar effect if a heatmap was applied to the color gamut: Most colors would fit within the BT.709 color space, while some highly-saturated colors would extend into DCI-P3.

Dynamic Range Compression

HDR specular highlights must be compressed when the end display has a peak brightness that is less than the source peak brightness. Compression of the fixed PQ luminance scale above 100 nits is handled by a roll-off curve that lowers the distance between each PQ step. After compression is applied, the brightest pixels in the source become mapped to the peak white output of the target display.

If a display clips the highlights, they will all be mapped to white and blown out without visible detail. So it is desirable to start the roll-off low enough on the PQ curve to retain all highlight detail at the expense of making everything above the roll-off point darker. Or trade-off some highlight detail for greater brightness. 

Displays with a low peak brightness that is only marginally above SDR reference white (0-100 nits — such as most HDR projectors) will typically lower the brightness of reference white to provide space to represent the specular highlights. Tone mapping of reference white in HDR videos is generally not recommended because the majority of the source levels are mastered here.

If reference white must be compressed by the display, it is at least desirable to retain the visible space between each PQ value to avoid flattening large portions of the image. The amount 0-100 nits should be lowered in brightness depends on the source peak brightness and the contrast desired for each movie or each movie scene.

The shape of the roll-off curve is determined by a tone mapping operator (TMO) that uses an S-curve to create different levels of compression that preserve various features in the image. Tone mapping curves simply cannot preserve all image detail, so those deemed most visually important are given priority.

Tone mapping compression starts at a static knee point on the PQ curve:

Image

The placement of the knee point where the roll-off point starts is not standardized across all tone mapping operators. BT.2390 used by madVR chooses the knee point based on a formula that uses several input values as described in Report BT.2390 (largely, inputting the target display peak brightness and comparing it to the measured scene or frame peak brightness to determine how early the roll-off must begin to compress each scene peak to fit the target display).

Display Target Nits — Adjusting Dynamic Range Compression

The brightness of the image in HDR to SDR tone mapping is defined by the display target nits that describes the peak nits or peak luminance (cd/m2) of the original PQ source curve. This value tells you how much dynamic range is captured by the SDR gamma curve from the HDR source input. That source curve could be a tone mapped HDR source or scene compressed to a specific nits levels with a BT.2390 tone mapping curve, or the display target nits might represent the entire uncompressed HDR movie scene.

For example, if the display target nits was 100 nits and the display was also calibrated to 100 peak nits, this means the display could represent the dynamic range of any scene mastered to 100 PQ nits, but those HDR scenes with brightness levels above 100 nits would be rolled-off and largely clipped at the top of the display range.

Source Footage vs. 100 nits Display Target Nits:
Image

If instead the display target nits was increased to say 500 nits, more of the source dynamic range could be captured within the display range to preserve more of the high contrast of the original scene without clipping the highlights.

Source Footage vs. 500 nits Display Target Nits:
Image

These 500 PQ nits are compressed to 100 real display nits by compressing the entire display range at a 5:1 ratio, which leads to an increase in contrast and a darkening of the overall image, but adds space at the top of the range for a more gradual roll-off of the bright specular highlights.

Increase contrast (high display target nits) and you sacrifice some brightness — The midtones of the image are compressed to add contrast between the highlights and midtones. Decrease contrast (low display target nits) and you raise brightness — The bulk of compression is applied to the specular highlights with greater brightness allocated to the shadows and midtones.

The display target nits can then be thought of as a dynamic range slider that defines the aggressiveness of the display gamma compression:

Low display target nits:

Brighter Images with Lower Contrast = Lower Perceived Dynamic Range.

High display target nits:

Darker Images with Higher Contrast = Higher Perceived Dynamic Range.

Changes to the display target nits impact the Average Picture Level (APL) — The average brightness of the displayed video levels.

PQ to SDR Gamma Display Mapping — Displayed Luminance

When PQ is converted to SDR gamma, the brightness of each displayed value is determined by a combination of the display target nits and real display peak nits of the target display.

Because the display target nits defines the dynamic range captured by the tone mapping curve, the relative SDR gamma scale will always preserve the original contrast ratio of any display target nits at a ratio of display target nits/real display peak nits. This occurs through linear gamma compression at the display panel that stretches or compresses the source values to fit the calibrated peak nits of the SDR picture mode.

For example,

display target nits = real display peak nits 

This is a 1:1 compression ratio. No additional source compression happens at the display panel.

PQ source values follow the original PQ EOTF — the HDR source luminance is faithfully represented at a 1:1 ratio.

display target nits > real display peak nits

The display target nits is rescaled at the display panel by the relative SDR gamma curve at a compression ratio equal to display target nits/real display peak nits

Example: Linear Gamma Rescaling of 100 display target nits, 200 display target nits, 300 display target nits and 400 display target nits at 100 actual display nits:

100 display target nits / 100 real display nits = 1:1 display gamma compression ratio;
200 display target nits / 100 real display nits = 2:1 display gamma compression ratio;
300 display target nits / 100 real display nits = 3:1 display gamma compression ratio;
400 display target nits / 100 real display nits = 4:1 display compression ratio.

These ratios mean the brightness of each PQ value will be neutral2x darker, 3x darker or 4x darker when displayed. This has the following impact on the APL:

100 display target nits / 100 real display nits (1:1) = 100 nits reference white;
200 display target nits / 100 real display nits (2:1) = 50 nits reference white;
300 display target nits / 100 real display nits (3:1) = 33 nits reference white;
400 display target nits / 100 real display nits (4:1) = 25 nits reference white.

Lowering reference white in each scene creates contrast between the specular highlights and reference white that is necessary to accurately represent the many bright specular highlights found in HDR movies without clipping them on dimmer displays. For instance, if a movie scene contained highlight information with a mastered peak of 1,000 nits and the display could only produce 100 nits, reference white might be lowered to 50 nits in order to place the brighter specular highlights at 100 nits. This would provide just enough contrast between 100 nits and 50 nits to more faithfully represent the intended contrast of the scene. 

As the majority of HDR video is mastered within 0-100 nits, this contrast enhancement has the effect of slightly darkening the overall image. How much compression is required to create the desired HDR effect depends on the mastered peak brightness of each scene in the movie: Higher contrast compression is necessary for very bright scenes, moderate contrast compression is necessary for mid-bright scenes and low contrast compression is suitable for dimmer scenes.
 
So how are these brightness values communicated by madVR to the end display?

Well, since SDR gamma is relative to brightness of the end display, madVR can assume each PQ value will be rescaled by the end display based on its known SDR peak brightness. The SDR gamma scale assumes every display is 100 nits, but this input can be expanded or compressed linearly by the display. When the calibrated brightness of the display can be assumed, tone mapping can then use the SDR gamma luminance scale as a standard PQ scale that sends luminance values that are equal to what each PQ value will be at the displayed brightness.

Example #1: PQ Values Sent to SDR Display Calibrated to 100 peak nits: 

50 nits pixel sent to 100 display nits = 1/2 the total display luminance curve.

Example #2: PQ Values Sent to SDR Display Calibrated to 200 peak nits: 

50 nits pixel sent to 200 display nits = 1/4 of the total display luminance curve. 

In Example #1, madVR sends an RGB value that is 1/2 of the SDR gamma scale. In Example #2, an RGB value that is 1/4 of the SDR gamma scale is sent to the display.

The luminance scale used by HDR to SDR tone mapping is intended to mirror a true PQ HDR mastering monitor that clips at 100 peak nits, 200 peak nits, 300 peak nits, 400 peak nits, etc. As the target display brightness increases closer to 10,000 nits, RGB values sent by madVR will align closer and closer to a true 10,000 nits reference PQ mastering monitor. For example, R100, G100, B100 eventually equals exactly 0.306 PQ nits rather than a fixed ratio of the SDR display nits.

If display target nits = real display peak nits, each PQ value is displayed at the exact desired brightness.

If display target nits > real display peak nits, each PQ value is rendered by the display at lower brightness than originally calculated.

This difference in target nits and display nits has the net effect of shifting all RGB values downwards on the gamma curve. A 50 nits value is displayed at 50 nits at 200 display target nits on a true 200 nits display, but it is only (2:1) 25 nits on a 100 nits display, and (4:1) 12.5 nits on a true 50 nits display. If the display target nits is raised high enough above the actual display nits, black crush will occur in places where the visible steps near black become too low in luminance and too close together to show any visible difference between each value. This will make the entire image very dark!

Rescaling HDR source levels towards black at higher display target nits with the SDR gamma curve is not ideal for maintaining high APLs, but it offers the unique advantage of being able to dynamically tailor displayed contrast to match each movie scene. Each scene in a movie will have a unique frame peak brightness and it may only be necessary to sacrifice some brightness for better contrast if the scene has a high dynamic range that is well above the available display nits.

Contrast adjustments of this nature improve tone mapping flexibility for low peak brightness displays such as projectors that must constantly strike a balance between presenting extended HDR contrast and maintaining a bright and viewable image, all within a very narrow range of available projected brightness.

HDR to SDR Tone Mapping Explained in Images

To compress the PQ HDR luminance scale to fit within the target display brightness, the tone curve must flatten portions of the original PQ scale until the brightest source values are lowered to match the peak white of the target display. PQ values represent fixed luminance and compressing this scale means values at the top of the scale must be stacked on top of the ones below. Lowering the distance between each PQ step has the effect of clipping some detail in the most compressed areas of the roll-off curve where many pixels become mapped to the same PQ value.

Segments of the Absolute 10-bit PQ Luminance Scale up to 1,000 nits:

PQ Value: 0 - Output Luminance: 0 nits
PQ Value: 100 - Output Luminance: 0.306 nits
PQ Value: 200 - Output Luminance: 2.258 nits
PQ Value: 300 - Output Luminance: 9.211 nits
PQ Value: 400 - Output Luminance: 29.386 nits
PQ Value: 500 - Output Luminance: 82.382 nits
PQ Value: 600 - Output Luminance: 214.612 nits
PQ Value: 700 - Output Luminance: 536.845 nits
PQ Value: 769 - Output Luminance: 998.932 nits

Source

You can think of a tone mapping compression like falling blocks in the game Tetris. The lower the display target nits, the lower tone mapping must shift the entire image downwards.

LINK: TETRIS WORLD CHAMPIONSHIP

If you made the PQ steps perfectly linear, where each step was evenly spaced out with equal increases luminance, tone mapping a 1,000 nit source with a standard BT.2390 roll-off to a display capable of 214 actual nits might look something like this:

Tone mapping to 214 real display nits:
Image

You can see the roll-off starts at 100 nits with the remaining space allocated to mapping the brighter source values. Above the knee point, values are adjusted downwards creating some overlap as some source values become the same value. In reality, it is more likely the source values will become increasingly closer to each other rather than the same value (e.g., from five steps difference to two steps difference), but overlapping PQ values will occur when the display is limited in visible brightness steps.

So what happens if the target nits is 214 nits, but the end display is only capable of 100 nits? Well, the same tone curve is applied, but the entire is image is rescaled by the relative SDR gamma curve. The result is each visible step becomes smaller and closer together and the overall image is dimmed.

214 real display nits rescaled to 100 actual nits:
Image

You can see the individual steps of the larger target are maintained 1:1 at a lower brightness, but the difference in luminance between those steps has been reduced by the rescaling of the SDR gamma curve (each step becomes 2.14x darker). The whole image has been shrunk down to a lower brightness by the gamma curve to maintain the original 1:1 contrast ratio of the larger display target nits at a 2.14x lower luminance.

Displaying 214 PQ nits at 100 actual display nits lowers reference white from 100 nits to 47 nits. This creates additional space at the top of the range for a more gradual roll-off of the specular highlights that should lead to less visible highlight clipping. However, the display rescaling is now less accurate in mapping the absolute luminance of the original PQ source values. Contrast is improved compared to 100 display target nits, but the resulting image uses altered proportions (steps) and displays a visibly lower APL.

*The actual representation of brightness by the SDR gamma curve is not perfectly linear. So this example is only hypothetical.

The accordion-like compression of the gamma curve permits very small adjustments between the source luminance steps that are more difficult when using the original fixed PQ EOTF. This rescaling occurs while still maintaining some visible distance between each source value. 

The placement of the fixed knee point where the roll-off begins is determined by the measured frame peak. Increases to the frame peak nits necessitates a lower roll-off point on the tone curve to accommodate the larger number of source values between reference white (100 nits) and the display target nits to provide a more gentle roll-off of the specular highlights that prevents the highlights from being clipped. As the display target nits increases, the knee point is moved up on the tone curve to alleviate compression of 0-100 nits and use the increased space above 100 nits for the highlight roll-off.

Minimum Display Target Nits Where the BT.2390 Knee Point is Placed at Exactly 100 nits:

Frame Peak: 100 nits -> Target Nits: 100 nits
Frame Peak: 200 nits -> Target Nits: 126 nits
Frame Peak: 300 nits -> Target Nits: 144 nits
Frame Peak: 400 nits -> Target Nits: 158 nits
Frame Peak: 500 nits -> Target Nits: 170 nits
Frame Peak: 600 nits -> Target Nits: 180 nits
Frame Peak: 700 nits -> Target Nits: 190 nits
Frame Peak: 800 nits -> Target Nits: 198 nits
Frame Peak: 900 nits -> Target Nits: 206 nits
Frame Peak: 1000 nits -> Target Nits: 214 nits
Frame Peak: 2000 nits -> Target Nits: 270 nits
Frame Peak: 3000 nits -> Target Nits: 310 nits
Frame Peak: 4000 nits -> Target Nits: 343 nits
Frame Peak: 10000 nits -> Target Nits: 479 nits

HDR to SDR Gamma Compression (Continues Below...)
Reply


Messages In This Thread
Lockup on STOP issue resolved! - by MKANET - 2015-04-11, 21:59
RE: Kodi DSPlayer – DirectShow Player for Windows - by Warner306 - 2015-04-16, 23:05
RE: 4G aware patch - by MagikMark - 2015-09-08, 03:27
Alt-F4 no longer quits - by JeffA - 2015-10-31, 20:38
H265 playback - by rew88 - 2017-11-04, 00:41
RE: H265 playback - by ashlar - 2017-11-04, 16:21
RE: H265 playback - by rew88 - 2017-11-05, 01:34
RE: H265 playback - by ashlar - 2017-11-05, 16:48
RE: H265 playback - by rew88 - 2017-11-05, 23:08
RE: H265 playback - by ashlar - 2017-11-06, 12:00
Leia 18 - by terpsarlington - 2017-11-21, 03:51
RE: Leia 18 - by spencerjford - 2017-11-21, 06:24
Display Modes / Refresh Rates - by goofer69 - 2019-09-20, 00:19
RE: Display Modes / Refresh Rates - by ashlar - 2019-09-20, 00:39
RE: Display Modes / Refresh Rates - by ashlar - 2019-09-20, 19:35
DSPlayer 23.810 to 23.976 - by Runakanta - 2018-05-09, 03:24
RE: DSPlayer 23.810 to 23.976 - by Warner306 - 2018-05-10, 01:32
Logout Mark Read Team Forum Stats Members Help
Kodi DSPlayer – DirectShow Player for Windows47