Commit 09c67587 authored by Dale Curtis's avatar Dale Curtis Committed by Commit Bot

Document that gfx::ColorSpace assumes an 8-bit range expansion.

For 10-bit and 12-bit formats this results in a relative error of ~2.9%
and ~3.7% respectively. As discussed offline, it's not worth adding a
bit depth to gfx::ColorSpace at this time for this.

Potentially at some point in the future someone will create the
equivalent of the full vs limited range images we have for 8-bit:
https://referencehometheater.com/2014/commentary/rgb-full-vs-limited/

At which point we may need to update our implementation to be more
accurate.

R=ccameron

Change-Id: I0cdc6a9023ec74b53da1620f84f64b531c323634
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1879720Reviewed-by: default avatarccameron <ccameron@chromium.org>
Commit-Queue: Dale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709711}
parent 46788bec
......@@ -880,6 +880,26 @@ void ColorSpace::GetRangeAdjustMatrix(SkMatrix44* matrix) const {
case RangeID::LIMITED:
break;
}
// Note: The values below assume an 8-bit range and aren't entirely correct
// for higher bit depths. They are close enough though (with a relative error
// of ~2.9% for 10-bit and ~3.7% for 12-bit) that it's not worth adding a
// |bit_depth| field to gfx::ColorSpace yet.
//
// The limited ranges are [64,940] and [256, 3760] for 10 and 12 bit content
// respectively. So the final values end up being:
//
// 16 / 255 = 0.06274509803921569
// 64 / 1023 = 0.06256109481915934
// 256 / 4095 = 0.06251526251526252
//
// 235 / 255 = 0.9215686274509803
// 940 / 1023 = 0.9188660801564027
// 3760 / 4095 = 0.9181929181929182
//
// Relative error (same for min/max):
// 10 bit: abs(16/235 - 64/1023)/(64/1023) = 0.0029411764705882222
// 12 bit: abs(16/235 - 256/4095)/(256/4095) = 0.003676470588235281
switch (matrix_) {
case MatrixID::RGB:
case MatrixID::GBR:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment