SkWriteICCProfile: Add tone mapping A2B0 tag
Add the function write_mAB_or_mBA_tag. This function will use only
the CLUT and the B curves. It will not specify M curves, or a matrix.
Add the function write_to_lab_clut which will populate a 3D lookup
table converting to Lab space. Use the function compute_tone_map_gain,
which implements Chrome's (current) tone mapping for display on an
SDR monitor.
Specify the D50 illuminant constants at the top, and refactor
write_xyz_tag to take floats. There were two places where these
constants were hard-coded, and that was going to become three (adding
the conversion to Lab), so this felt appropriate.
Add optimizations to write_para_tag to specify only the exponent if
the the function is linear (the A2B0 tag specifies 6 para curves, and
the B2A0 specifies 3, so this starts adding up).
Include a B2A0 tag because some software (e.g, Preview on macOS) will
ignore the A2B0 tag if there is no B2A0 tag.
Add unittests to verify that PQ and HLG tone mapping produces the
expected results.
Bug: 1366315
Change-Id: If874635654e629b25e41119b9dd41b2d1ddb4a09
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/585278
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Christopher Cameron <ccameron@google.com>
3 files changed