An Introduction to Hybrid Log-Gamma HDR Part 2: Format conversion and compositing
Presenter: Andrew Cotton (BBC)
Duration: 11 min
Slides & video
Hello, I'm Andrew Cotton.
I'm the principal technologist at BBC Research and Development.
I'm also one of the developers of the Hybrid Log-Gamma HDR solution and that's what we're gonna be talking about today.
This is the second of my two talks.
In the first talk, I explained how HLG was designed from the outset to target a wide range of different peak luminance HDR displays and could be viewed across a wide range of different environments.
In this talk, we're going to focus on format conversion and image composition.
So we're going to explain how to convert an sRGB signal into an HLG signal, how to go from HLG into sRGB and we're also gonna talk about the backwards compatible nature of the HLG signal which will allow you to deliver a high quality SDR signal on a wide color gamut SDR display, which might negate the need for bespoke format conversion in certain situations.
So let's kick off straight away by looking at direct mapping of sRGB into HLG and you need the processing blocks that you can see on the screen at the minute.
The sRGB signal is fed into a model of the sRGB reference EOTF.
Those linear display light signals then go into a standard color matrix conversion to go from the sRGB BT.79 primaries to the wide color gamut BT.2020 primaries and that signal is then fed into an HLG inverse EOTF to deliver the HLG non linear signal.
Now, there's a slight complication in that the nominal peak white for sRGB is defined as 80 candelas per meter squared, whereas the ITU specify the HDR reference white level, the equivalent for HDR signals at 203 candelas per meter squared for PQ or on a reference 1000 candela per meter squared HLG display that 203 candelas per meter squared corresponds to 58% PQ signal or 75% HLG Well, that's a little trick we can play with HLG because you can't just take that 80 candelas per meter squared and linearly scale it to 203 because that actually changes the subjective appearance of the images but with HLG what we can do is we can adjust the nominal peak luminance of the EOTF such that 80 candelas per meter squared would actually directly correspond to a 75% nonlinear signal.
And if you go through the maths you find that that would correspond to running the HLG EOTF at 302 candelas per meter squared with a gamma of almost 1.0.
One thing to note when you're doing this sort of conversion you need to use the more accurate gamma formula that's specified in footnote two of BT.2100 for HLG because we're less than 400 candelas per meter squared.
So you need to use the more accurate formula in this signal range.
Now there's actually a further simplification we can do with HLG because that display gamma or OOTF gamma rather, is so close to one.
The OOTF effectively becomes a pass through and that's good news because otherwise that OTF needs to be implemented in a 3D lookup table or special processing because that OOTF gamma is applied on the luminance component, not the red, green and blue.
So then if we look at this simplified processing chain and using this case normalized signals in the range zero to one, you take the non-linear sRGB signal you put it into the sRGB EOTF apply the standard color matrix conversion to take it to BT.2020 color primaries.
You then have to apply a scale factor to go from the normalized SDR display light signal range to the normalized HDR display light range.
And then you feed those signals into the HLG inverse EOTF which actually just turns out because of this simplification to be the HLG OETF.
Very simple indeed, as a hardware engineer I think of that as being two 1D LUTs and a multiplier but obviously the way it's implemented will depend on the application.
To go the other way from HLG to sRGB through a down mapper is a little bit more complicated but it's similar building blocks in a slightly different order.
So we take the HLG signal, we run it through an HLG EOTF again at this magic number 302 candelas per meter squared.
We then need to apply another scale factor to go from the normalized HDR display light range to the SDR display light range.
And now we'll end up with signals greater than one that's the highlights.
So we need to compress those highlights to the SDR signal range using what's called a tone mapping operation and that needs to be applied to the luminance component because we've, if we apply that tone mapping to the red, green and blue components individually will end up changing the hue.
We'll change the color.
That's another little trick you can do.
You can calculate that tone mapping scaling factor based on something called max RGB.
I don't have time to discuss max RGB right now but worth looking at because that max RGB scaling can help ensure that your SDR signals after the tone mapping operation exactly match the SDR signal range that you're looking for, If not, you can end up with problems in the blue.
And then we come on to perhaps the most complicated part of the processing and that's the color gamut compression.
How did you get from a wide color gamut 2020 signal to this narrow color gamut 709/sRGB signal and this can be as simple or as complicated as you like.
The simplest solution actually works pretty well.
And that's simply to hard clip the white color gamut signal to the narrow color gamut and that effectively means once you've gone through the matrix conversion to get your RGB signal in the sRGB primaries negative numbers which represent wide color gamut objects you simply clip those to zero.
Actually doesn't work too badly at all!
Some bright saturated objects, you might lose a little bit of texture but it's usually hard to see.
The biggest problem you'll find is that some deep purples will tend to - sorry, some deep blues - will tend to go a little bit purple.
There are lots of ways of preventing that or techniques to improve upon that but they can get quite processor intensive and also there's quite a lot of IPR in that area because it's a very interesting problem which a lot of people are working on.
Just to say however, with HLG you won't necessarily always need this type of complex conversion because you can exploit the backwards compatible nature of the HLG signal.
And we're going to look at that now.
So if we now look at the backwards compatible nature of the HLG signal you will recall from the first talk that the camera OETF for HLG is a standard gamma curve on the lower range and then it's got a log curve spliced onto that to extend the signal range to cover more highlights to extend the dynamic range for the highlights.
If we now take that OETF and feed that into a standard SDR EOTF (and a gamma 2.2 EOTF works best for HLG in this instance), and you look at the overall opto-optical transfer function which is plotted on the graph on the right.
You'll see that on a log-log scale over most of the signal range, you get a one-to-one correspondence you get this direct proportionality and then for the higher luminances in the scene what's happened is they're just slightly compressed to get them into the SDR display signal range.
And you get a very nice looking backwards compatible SDR image on that 2020 color gamut display.
Now, if you don't have a 2020 color gamut display you can actually do a straightforward color conversion to in this example, BT-709 or sRGB.
So you'd take the HLG signal.
You then apply a gamma 2.2 EOTF to give you a linear light signal.
You then apply a standard color matrix conversion here to go from BT.2020 to BT.709.
You could use P3 if you happen to be targeting a wider gamut P3 display and then once you've got that linear display light signal with the new primaries you apply an inverse gamma 2.2 EOTF to give you the nonlinear signal.
There's lots more information on that in these ITU-R reports.
So to summarize, HLG's basis on relative scene light allows for a straightforward conversion to and from sRGB and BT.709 The color volume reduction can be as simple or complex as the application requires but actually in many instances you might just be able to take an HLG backwards compatible picture combine that with some color conversion and exploit the backwards compatible nature of the HLG signal to give you a high quality image on an SDR display.
Thank you very much, indeed for your time.
More information on our project website.