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

Side by Side Diff: third_party/qcms/src/qcms_util.c

Issue 2014023003: Add exact version of qcms used by Chrome for testing and comparison (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « third_party/qcms/src/qcms.h ('k') | third_party/qcms/src/qcmsint.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the Chromium LICENSE file.
4
5 #include "qcmsint.h"
6
7 #include <math.h>
8
9 typedef struct _qcms_coords {
10 float x;
11 float y;
12 } qcms_coords;
13
14 typedef struct _qcms_triangle {
15 qcms_coords verticies[3];
16 } qcms_triangle;
17
18 #define NTSC_1953_GAMUT_SIZE 0.1582
19
20 static qcms_triangle get_profile_triangle(qcms_profile *profile)
21 {
22 float sumRed = s15Fixed16Number_to_float(profile->redColorant.X) +
23 s15Fixed16Number_to_float(profile->redColorant.Y) +
24 s15Fixed16Number_to_float(profile->redColorant.Z);
25 float xRed = s15Fixed16Number_to_float(profile->redColorant.X) / sumRed;
26 float yRed = s15Fixed16Number_to_float(profile->redColorant.Y) / sumRed;
27
28 float sumGreen = s15Fixed16Number_to_float(profile->greenColorant.X) +
29 s15Fixed16Number_to_float(profile->greenColorant.Y) +
30 s15Fixed16Number_to_float(profile->greenColorant.Z);
31 float xGreen = s15Fixed16Number_to_float(profile->greenColorant.X) / sumGree n;
32 float yGreen = s15Fixed16Number_to_float(profile->greenColorant.Y) / sumGree n;
33
34 float sumBlue = s15Fixed16Number_to_float(profile->blueColorant.X) +
35 s15Fixed16Number_to_float(profile->blueColorant.Y) +
36 s15Fixed16Number_to_float(profile->blueColorant.Z);
37 float xBlue = s15Fixed16Number_to_float(profile->blueColorant.X) / sumBlue;
38 float yBlue = s15Fixed16Number_to_float(profile->blueColorant.Y) / sumBlue;
39
40 qcms_triangle triangle = {{{xRed, yRed}, {xGreen, yGreen}, {xBlue, yBlue}}};
41 return triangle;
42 }
43
44 static float get_triangle_area(const qcms_triangle candidate)
45 {
46 float xRed = candidate.verticies[0].x;
47 float yRed = candidate.verticies[0].y;
48 float xGreen = candidate.verticies[1].x;
49 float yGreen = candidate.verticies[1].y;
50 float xBlue = candidate.verticies[2].x;
51 float yBlue = candidate.verticies[2].y;
52
53 float area = fabs((xRed - xBlue) * (yGreen - yBlue) - (xGreen - xBlue) * (yR ed - yBlue)) / 2;
54 return area;
55 }
56
57 static float get_ntsc_gamut_metric_area(const qcms_triangle candidate)
58 {
59 float area = get_triangle_area(candidate);
60 return area * 100 / NTSC_1953_GAMUT_SIZE;
61 }
62
63 float qcms_profile_ntsc_relative_gamut_size(qcms_profile *profile)
64 {
65 qcms_triangle triangle = get_profile_triangle(profile);
66 return get_ntsc_gamut_metric_area(triangle);
67 }
68
69
OLDNEW
« no previous file with comments | « third_party/qcms/src/qcms.h ('k') | third_party/qcms/src/qcmsint.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698