Index: third_party/qcms/src/qcms_util.c |
diff --git a/third_party/qcms/src/qcms_util.c b/third_party/qcms/src/qcms_util.c |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a9b2fc53e093cb3e2d60631bfff34eb00189fd7f |
--- /dev/null |
+++ b/third_party/qcms/src/qcms_util.c |
@@ -0,0 +1,70 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
Noel Gordon
2016/02/17 10:42:24
Nit: 2015 -> 2016.
radu.velea
2016/02/17 11:31:00
Done.
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the Chromium LICENSE file. |
+ |
+#include "qcmsint.h" |
+ |
+#include <math.h> |
+ |
+typedef struct _qcms_coords { |
+ float x; |
+ float y; |
+} qcms_coords; |
+ |
+typedef struct _qcms_triangle { |
+ qcms_coords verticies[3]; |
+} qcms_triangle; |
+ |
+#define NTSC_1953_GAMUT_SIZE 0.1582 |
+ |
+static qcms_triangle get_profile_triangle(qcms_profile *profile) |
+{ |
+ float sumRed = s15Fixed16Number_to_float(profile->redColorant.X) + |
+ s15Fixed16Number_to_float(profile->redColorant.Y) + |
Noel Gordon
2016/02/17 10:42:24
Make the s15Fixed16Number_to_float line-up.
floa
radu.velea
2016/02/17 11:31:00
Done.
|
+ s15Fixed16Number_to_float(profile->redColorant.Z); |
+ float xRed = s15Fixed16Number_to_float(profile->redColorant.X) / sumRed; |
+ float yRed = s15Fixed16Number_to_float(profile->redColorant.Y) / sumRed; |
+ |
+ float sumGreen = s15Fixed16Number_to_float(profile->greenColorant.X) + |
+ s15Fixed16Number_to_float(profile->greenColorant.Y) + |
+ s15Fixed16Number_to_float(profile->greenColorant.Z); |
+ float xGreen = s15Fixed16Number_to_float(profile->greenColorant.X) / sumGreen; |
+ float yGreen = s15Fixed16Number_to_float(profile->greenColorant.Y) / sumGreen; |
+ |
+ float sumBlue = s15Fixed16Number_to_float(profile->blueColorant.X) + |
+ s15Fixed16Number_to_float(profile->blueColorant.Y) + |
+ s15Fixed16Number_to_float(profile->blueColorant.Z); |
+ float xBlue = s15Fixed16Number_to_float(profile->blueColorant.X) / sumBlue; |
+ float yBlue = s15Fixed16Number_to_float(profile->blueColorant.Y) / sumBlue; |
+ |
+ qcms_triangle triangle = {{{xRed, yRed}, {xGreen, yGreen}, {xBlue, yBlue}}}; |
+ |
Noel Gordon
2016/02/17 10:42:24
Remove this blank line.
radu.velea
2016/02/17 11:31:00
Done.
|
+ return triangle; |
+} |
+ |
+static float get_triangle_area(const qcms_triangle candidate) |
+{ |
+ float xRed = candidate.verticies[0].x; |
+ float yRed = candidate.verticies[0].y; |
+ float xGreen = candidate.verticies[1].x; |
+ float yGreen = candidate.verticies[1].y; |
+ float xBlue = candidate.verticies[2].x; |
+ float yBlue = candidate.verticies[2].y; |
+ float A = fabs((xRed - xBlue) * (yGreen - yBlue) - (xGreen - xBlue) * (yRed - yBlue)) / 2; |
Noel Gordon
2016/02/17 10:42:24
nit: Space before this line.
Also, A -> area.
fl
radu.velea
2016/02/17 11:31:00
Done.
|
+ |
+ return A; |
+} |
+ |
+static float get_ntsc_gamut_metric_area(const qcms_triangle candidate) |
+{ |
+ float A = get_triangle_area(candidate); |
Noel Gordon
2016/02/17 10:42:24
nit: A -> area.
radu.velea
2016/02/17 11:31:00
Done.
|
+ return A * 100 / NTSC_1953_GAMUT_SIZE; |
+} |
+ |
+float qcms_profile_ntsc_relative_gamut_size(qcms_profile *profile) |
+{ |
+ qcms_triangle triangle = get_profile_triangle(profile); |
Noel Gordon
2016/02/17 10:42:24
nit: alignment / spacing.
Compare with this align
radu.velea
2016/02/17 11:31:00
Done.
|
+ return get_ntsc_gamut_metric_area(triangle); |
+} |
+ |
+ |