Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Unified Diff: third_party/qcms/src/transform_util.c

Issue 1185163003: lut_inverse_interp16: interpolate degenerate zeros in TRC curves (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/qcms/README.chromium ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/qcms/src/transform_util.c
diff --git a/third_party/qcms/src/transform_util.c b/third_party/qcms/src/transform_util.c
index c1a9d1563b912d65bf833588d1bc19c87e6bb243..34f29f7aad3499963b160abcf36daa070a256380 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] ;
« no previous file with comments | « third_party/qcms/README.chromium ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698