aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party/skcms/src/Curve.c
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/skcms/src/Curve.c')
-rw-r--r--third_party/skcms/src/Curve.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/third_party/skcms/src/Curve.c b/third_party/skcms/src/Curve.c
index 1e48d65799..f52eb983fe 100644
--- a/third_party/skcms/src/Curve.c
+++ b/third_party/skcms/src/Curve.c
@@ -6,7 +6,9 @@
*/
#include "Curve.h"
+#include "PortableMath.h"
#include "TransferFunction.h"
+#include <assert.h>
float skcms_eval_curve(const skcms_Curve* curve, float x) {
if (curve->table_entries == 0) {
@@ -15,7 +17,10 @@ float skcms_eval_curve(const skcms_Curve* curve, float x) {
// TODO: today we should always hit an entry exactly, but if that changes, lerp?
// (We add half to account for slight int -> float -> int round tripping issues.)
- int ix = (int)( x*(curve->table_entries - 1) + 0.5f );
+ float fx = x*(curve->table_entries - 1);
+ int ix = (int)( fx + 0.5f );
+
+ assert ( fabsf_(fx - (float)ix) < 0.0005 );
if (curve->table_8) {
return curve->table_8[ix] * (1/255.0f);