summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoel Gordon <noel@chromium.org>2015-06-25 14:51:14 +1000
committerNoel Gordon <noel@chromium.org>2015-06-25 04:53:10 +0000
commit3f513455252c4ba6149deb67bfeae2a3b67cdc16 (patch)
tree1eb9b371ee4bbeabe49dfdd6be8c8828de9284e4
parent60b840a7a0e0b03cea443a6ed9507e4b73fc956b (diff)
downloadchromium_src-3f513455252c4ba6149deb67bfeae2a3b67cdc16.zip
chromium_src-3f513455252c4ba6149deb67bfeae2a3b67cdc16.tar.gz
chromium_src-3f513455252c4ba6149deb67bfeae2a3b67cdc16.tar.bz2
Merge r334996 to M44 branch 2403
https://crrev.com/9c5cf06617232b00842383ff001c49fe058fc6b4 r334996 lut_inverse_interp16: interpolate degenerate zeros in TRC curves Degenerate TRC have runs of 0's / 1's from the left / right edge of the TRC curve (a curve we want to invert, to be able to use a color profile as a monitor profile). The inverse TRC of degenerate curves is not well-defined in the run of 0's area (infinite slope). Some monitor calibration software in the field produce 0 runs, thus degenerate TRC, and QCMS setting the inverse of the run to 0's area to 0 causes a color cast (burn) effect on web images corrected with the associated color profile: issue 492379 . Fix that by interpolating the (imaginary) inverse in the 0 run area instead of clamping the inverse to 0. Add more assert conditions to the curve inversion algorithm and also check for an inverted binary search range (these two changes from the related Mozilla bug). TBR=kbr@chromium.org BUG=458024,492379 Review URL: https://codereview.chromium.org/1209863003. Cr-Commit-Position: refs/branch-heads/2403@{#400} Cr-Branched-From: f54b8097a9c45ed4ad308133d49f05325d6c5070-refs/heads/master@{#330231}
-rw-r--r--third_party/qcms/README.chromium2
-rw-r--r--third_party/qcms/src/transform_util.c17
2 files changed, 16 insertions, 3 deletions
diff --git a/third_party/qcms/README.chromium b/third_party/qcms/README.chromium
index 3548a0f..01f362b 100644
--- a/third_party/qcms/README.chromium
+++ b/third_party/qcms/README.chromium
@@ -66,6 +66,8 @@ The following changes have been made since qcms was imported:
- https://code.google.com/p/chromium/issues/detail?id=471749
- Limit vcgt table to a maximum of 1024 entries
- https://code.google.com/p/chromium/issues/detail?id=471749
+ - lut_inverse_interp16: interpolate degenerate zeros in TRC curves
+ - https://code.google.com/p/chromium/issues/detail?id=458024
For the Chromium changes, since the import, in a patch format run:
git diff b8456f38 src
diff --git a/third_party/qcms/src/transform_util.c b/third_party/qcms/src/transform_util.c
index 5eeafa2..aa08df0 100644
--- a/third_party/qcms/src/transform_util.c
+++ b/third_party/qcms/src/transform_util.c
@@ -334,8 +334,6 @@ uint16_fract_t lut_inverse_interp16(uint16_t Value, uint16_t LutTable[], int len
if (Value == 0) return 0;
// if (Value == 0xFFFF) return 0xFFFF;
sample = (length-1) * ((double) Value * (1./65535.));
- if (LutTable[sample] == 0)
- return 0;
if (LutTable[sample] == 0xffff)
return 0xffff;
@@ -353,6 +351,13 @@ uint16_fract_t lut_inverse_interp16(uint16_t Value, uint16_t LutTable[], int len
l = 1;
if (r > 0x10000)
r = 0x10000;
+
+ // If the search range is inverted due to degeneracy,
+ // deem LutTable non-invertible in this search range.
+ // Refer to https://bugzil.la/1132467
+
+ if (r <= l)
+ return 0;
}
// Seems not a degenerated case... apply binary search
@@ -376,14 +381,20 @@ uint16_fract_t lut_inverse_interp16(uint16_t Value, uint16_t LutTable[], int len
// Not found, should we interpolate?
-
// Get surrounding nodes
+ assert(x >= 1);
+
val2 = (length-1) * ((double) (x - 1) / 65535.0);
cell0 = (int) floor(val2);
cell1 = (int) ceil(val2);
+ assert(cell0 >= 0);
+ assert(cell1 >= 0);
+ assert(cell0 < length);
+ assert(cell1 < length);
+
if (cell0 == cell1) return (uint16_fract_t) x;
y0 = LutTable[cell0] ;