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

Side by Side Diff: third_party/qcms/src/tests/qcms_test_output_trc.c

Issue 1929143003: [qcms] Use a static table in build_output_lut to invert para curves (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/README.chromium ('k') | third_party/qcms/src/transform_util.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the Chromium LICENSE file. 3 // found in the Chromium LICENSE file.
4 4
5 #include "qcms.h" 5 #include "qcms.h"
6 #include "qcms_test_util.h" 6 #include "qcms_test_util.h"
7 7
8 #include <assert.h> 8 #include <assert.h>
9 #include <math.h> 9 #include <math.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 int iterations, 92 int iterations,
93 const char *in_path, 93 const char *in_path,
94 const char *out_path, 94 const char *out_path,
95 const int force_software) 95 const int force_software)
96 { 96 {
97 qcms_profile *profile; 97 qcms_profile *profile;
98 uint16_t *gamma_table_out; 98 uint16_t *gamma_table_out;
99 size_t output_size; 99 size_t output_size;
100 size_t i; 100 size_t i;
101 101
102 printf("Test qcms output gamma curve table integrity.\n");
103
104 if (!in_path) { 102 if (!in_path) {
105 fprintf(stderr, "%s: please provide valid ICC profiles via -i option\n", __FUNCTION__); 103 fprintf(stderr, "%s: please provide valid ICC profiles via -i option\n", __FUNCTION__);
106 return EXIT_FAILURE; 104 return EXIT_FAILURE;
107 } 105 }
108 106
107 printf("Test qcms output gamma curve table integrity.\n");
108
109 // Create profiles and transforms, get table and then free resources to make sure none 109 // Create profiles and transforms, get table and then free resources to make sure none
110 // of the internal tables are initialized by previous calls. 110 // of the internal tables are initialized by previous calls.
111 gamma_table_out = NULL; 111 gamma_table_out = NULL;
112 output_size = 0; 112 output_size = 0;
113 if (get_output_gamma_table(in_path, &gamma_table_out, &output_size) != 0) { 113 if (get_output_gamma_table(in_path, &gamma_table_out, &output_size) != 0) {
114 fprintf(stderr, "Unable to extract output gamma table\n"); 114 fprintf(stderr, "Unable to extract output gamma table\n");
115 return EXIT_FAILURE; 115 return EXIT_FAILURE;
116 } 116 }
117 117
118 printf("Output gamma LUT size = %zu\n", output_size); 118 printf("Output gamma table size = %zu\n", output_size);
119 119
120 profile = qcms_profile_from_path(in_path); 120 profile = qcms_profile_from_path(in_path);
121 if (!profile) { 121 if (!profile) {
122 fprintf(stderr, "Invalid input profile\n"); 122 fprintf(stderr, "Invalid input profile\n");
123 free(gamma_table_out); 123 free(gamma_table_out);
124 return EXIT_FAILURE; 124 return EXIT_FAILURE;
125 } 125 }
126 126
127 // Check only for red curve for now. 127 // Check only for red curve for now.
128 if (profile->redTRC->type == PARAMETRIC_CURVE_TYPE) { 128 if (profile->redTRC->type == PARAMETRIC_CURVE_TYPE) {
(...skipping 26 matching lines...) Expand all
155 155
156 get_input_gamma_table(in_path, &gamma_table_in, &input_size); 156 get_input_gamma_table(in_path, &gamma_table_in, &input_size);
157 if (!gamma_table_in) { 157 if (!gamma_table_in) {
158 fprintf(stderr, "Unable to compute input trc. Aborting\n"); 158 fprintf(stderr, "Unable to compute input trc. Aborting\n");
159 fclose(output_file); 159 fclose(output_file);
160 qcms_profile_release(profile); 160 qcms_profile_release(profile);
161 free(gamma_table_out); 161 free(gamma_table_out);
162 return EXIT_FAILURE; 162 return EXIT_FAILURE;
163 } 163 }
164 164
165 fprintf(output_file, "\nInput curve size: %zu", input_size);
166 fprintf(output_file, "\nOutput curve size: %zu", output_size);
167
165 scale_factor = (float)(output_size - 1) / (input_size - 1); 168 scale_factor = (float)(output_size - 1) / (input_size - 1);
166 169
167 fprintf(output_file, "\nInput curve size: %zu\nOutput curve size: %zu\n" , input_size, output_size);
168 fprintf(output_file, "\n\nInput gamma, Output gamma, LCMS Output gamma, Output gamma error\n"); 170 fprintf(output_file, "\n\nInput gamma, Output gamma, LCMS Output gamma, Output gamma error\n");
169 171
170 for (i = 0; i < input_size; ++i) { 172 for (i = 0; i < input_size; ++i) {
171 float input = gamma_table_in[i * 4] * inverse65535; 173 float input = gamma_table_in[i * 4] * inverse65535;
172 size_t out_index = (size_t)floor(i * scale_factor + 0.5); 174 size_t out_index = (size_t)floor(i * scale_factor + 0.5);
173 float p = out_index / (float)(output_size - 1); 175 float p = out_index / (float)(output_size - 1);
174 float reference = clamp_float(evaluate_parametric_curve(type, profil e->redTRC->parameter, p)); 176 float reference = clamp_float(evaluate_parametric_curve(type, profil e->redTRC->parameter, p));
175 float actual = gamma_table_out[out_index * 4] * inverse65535; 177 float actual = gamma_table_out[out_index * 4] * inverse65535;
176 float difference = fabs(actual - reference); 178 float difference = fabs(actual - reference);
177 179
178 fprintf(output_file, "%.6f, %.6f, %6f, %6f\n", input, actual, refere nce, difference); 180 fprintf(output_file, "%.6f, %.6f, %6f, %6f\n", input, actual, refere nce, difference);
179 } 181 }
180 182
181 fprintf(output_file, "\nNote: the output curves we down sampled by a fac tor of %zu / %zu\n", 183 fprintf(output_file, "\nNote: the output gamma curves are down-sampled b y a factor of %zu / %zu\n",
182 output_size, input_size); 184 output_size, input_size);
183 185
184 fclose(output_file); 186 fclose(output_file);
185 free(gamma_table_in); 187 free(gamma_table_in);
186 } 188 }
187 189
188 qcms_profile_release(profile); 190 qcms_profile_release(profile);
189 free(gamma_table_out); 191 free(gamma_table_out);
190 192
191 return 0; 193 return 0;
192 } 194 }
193 195
194 struct qcms_test_case qcms_test_output_trc_info = { 196 struct qcms_test_case qcms_test_output_trc_info = {
195 "qcms_test_output_trc", 197 "qcms_test_output_trc",
196 qcms_test_output_trc, 198 qcms_test_output_trc,
197 QCMS_TEST_DISABLED 199 QCMS_TEST_DISABLED
198 }; 200 };
OLDNEW
« no previous file with comments | « third_party/qcms/README.chromium ('k') | third_party/qcms/src/transform_util.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698