88#define TWO_SQRT2f 2.8284271247461900976f
97 dest->
Lab[0] = src->
Lab[0];
98 dest->
Lab[1] = src->
Lab[1];
99 dest->
Lab[2] = src->
Lab[2];
125 fprintf(stderr,
"Error: Memory allocation failed for color checker values.\n");
153 float extracted_coords[8] = { 0.f };
154 for(
size_t i = 0; tokens[
i] != NULL;
i++)
156 if(index >= 8)
break;
158 if(g_ascii_isdigit(tokens[
i][0]))
160 extracted_coords[index] = (float)g_ascii_strtod(tokens[
i], NULL);
166 frame_coordinates->
ax = extracted_coords[0];
167 frame_coordinates->
ay = extracted_coords[1];
168 frame_coordinates->
bx = extracted_coords[2];
169 frame_coordinates->
by = extracted_coords[3];
170 frame_coordinates->
cx = extracted_coords[4];
171 frame_coordinates->
cy = extracted_coords[5];
172 frame_coordinates->
dx = extracted_coords[6];
173 frame_coordinates->
dy = extracted_coords[7];
176 frame_coordinates->
width = extracted_coords[2] - extracted_coords[0];
177 frame_coordinates->
height = extracted_coords[5] - extracted_coords[1];
179 return frame_coordinates;
258 if(tokens[
i][0] !=
'\0')
261 const char *
string = tokens[
i];
264 if(g_ascii_isdigit(tokens[
i][0]) || (tokens[
i][0] ==
'-' && g_ascii_isdigit(tokens[
i][1])))
265 value = (float)g_ascii_strtod(tokens[
i], NULL);
269 case 0: box->
key_letter = tokens[
i][0]; index++;
break;
270 case 1: box->
label_x_start = g_strdup(
string); index++;
break;
271 case 2: box->
label_x_end = g_strdup(
string); index++;
break;
272 case 3: box->
label_y_start = g_strdup(
string); index++;
break;
273 case 4: box->
label_y_end = g_strdup(
string); index++;
break;
280 default: fprintf(stderr,
"Unexpected token in cht box extraction: %s\n", tokens[
i]);
301 gchar *result = g_strdup(in);
304 size_t len = strlen(result);
312 for(
int i = (
int)len - 1;
i >= 0;
i--)
315 if(g_ascii_isdigit(result[
i]))
326 else if(g_ascii_isalpha(result[
i]))
328 if(result[
i] ==
'z' || result[
i] ==
'Z')
330 result[
i] = (result[
i] ==
'z') ?
'a' :
'A';
355 const char *start = in;
356 while(*start ==
'0') start++;
372 gboolean result =
FALSE;
375 gchar *current_colum = NULL;
376 gchar *current_row = NULL;
377 gchar *last_label = NULL;
378 GSList *patch_tail = NULL;
383 fprintf(stderr,
"Invalid cht_patch");
389 fprintf(stderr,
"Invalid chart");
404 if(g_strcmp0(start_colum, end_colum) > 0 || g_strcmp0(start_row, end_row) > 0)
408 const float patch_w = cht_patch->
width / 2;
409 const float patch_h = cht_patch->
height / 2;
418 last_label = g_strconcat(last_label_colum ? last_label_colum :
"", last_label_row ? last_label_row :
"", NULL);
422 current_colum = g_strdup(start_colum);
426 const float inv_frame_width = 1.f / (F_box->
width - chart->
guide_size[0]);
427 const float inv_frame_height = 1.f / (F_box->
height - chart->
guide_size[1]);
429 patch_tail = g_slist_last(chart->
patches);
433 while(g_strcmp0(current_colum, colum_last) <= 0)
435 current_row = g_strdup(start_row);
439 while(g_strcmp0(current_row, row_last) <= 0)
445 gchar *label = g_strconcat(label_colum ? label_colum :
"", label_row ? label_row :
"", NULL);
460 int index_x = swap_axes ? index_row : index_colum;
461 float temp_x = (origin_x + (cht_patch->
x_increment * index_x)) * inv_frame_width;
463 int index_y = swap_axes ? index_colum : index_row;
464 float temp_y = (origin_y + (cht_patch->
y_increment * index_y)) * inv_frame_height;
471 GSList *patch_node = g_slist_alloc();
472 patch_node->data = patch;
473 patch_node->next = NULL;
475 patch_tail->next = patch_node;
478 patch_tail = patch_node;
480 const gboolean last_patch_reached = !g_strcmp0(patch->name, last_label);
481 if(last_patch_reached)
goto out;
482 if(!g_strcmp0(current_row,
"_"))
break;
499 current_colum = temp;
510 fprintf(stderr,
"error parsing CHT file, in %s %s:%d\n", __FUNCTION__, __FILE__, lineno);
527 GList *result = NULL;
531 fprintf(stderr,
"Invalid filename for CHT parsing");
536 GIOChannel *fp = g_io_channel_new_file(filename,
"r", NULL);
539 fprintf(stderr,
"Error opening '%s'\n", filename);
544 GString *line = g_string_new(NULL);
549 while(g_io_channel_read_line_string(fp, line, NULL, NULL) == G_IO_STATUS_NORMAL)
556 if(skip_block)
continue;
559 const char *c = line->str;
562 while(*c ==
' ') c++;
563 gchar **line_tokens = g_strsplit(c,
" ", 0);
570 while(g_io_channel_read_line_string(fp, line, NULL, NULL) == G_IO_STATUS_NORMAL)
572 if(line->len == 0)
break;
575 while(*c ==
' ') c++;
577 gchar **box_tokens = g_strsplit(c,
" ", 0);
579 && (!g_strcmp0(box_tokens[0],
"F")
580 || !g_strcmp0(box_tokens[0],
"D")
581 || !g_strcmp0(box_tokens[0],
"X")
582 || !g_strcmp0(box_tokens[0],
"Y")))
584 result = g_list_append(result, box_tokens);
588 g_strfreev(box_tokens);
599 g_strfreev(line_tokens);
608 fprintf(stderr,
"error parsing CHT file, in %s %s:%d\n", __FUNCTION__, __FILE__, lineno);
611 if(line) g_string_free(line,
TRUE);
612 if(fp) g_io_channel_unref(fp);
621 gboolean result =
FALSE;
626 GList *boxes_list = NULL;
628 float chart_radius = -1.f;
632 fprintf(stderr,
"Invalid input to dispatch cht data");
637 for(GList *lines = *boxes; lines; lines = g_list_next(lines))
639 const char **tokens = (
const char **)lines->data;
642 const char letter = tokens[0][0];
648 else if(letter ==
'D' || letter ==
'X' || letter ==
'Y')
653 boxes_list = g_list_append(boxes_list, box);
661 chart_radius = hypotf(F_box->
height, F_box->
width);
663 for(GList *iter = boxes_list; iter; iter = g_list_next(iter))
688 chart_spec->
size[0] = (size_t)chart_spec->
colums;
689 chart_spec->
size[1] = (size_t)chart_spec->
rows;
691 chart_spec->
radius = patch_radius / chart_radius;
697 fprintf(stderr,
"Error dispatching CHT file, in %s %s:%d\n", __FUNCTION__, __FILE__, lineno);
717 fprintf(stderr,
"[_dt_colorchecker_open_cht] Error: Invalid input parameters.\n");
724 fprintf(stderr,
"[_dt_colorchecker_open_cht] Error parsing CHT file '%s'\n", filename);
730 fprintf(stderr,
"[_dt_colorchecker_open_cht] Error dispatching CHT data from '%s'\n", filename);
731 g_list_free_full(boxes, (GDestroyNotify)g_strfreev);
735 chart_spec->
type = g_path_get_basename(filename);
737 g_list_free_full(boxes, (GDestroyNotify)g_strfreev);
748 fprintf(stderr,
"[_dt_colorchecker_IT8_get_material_type] Error: Invalid IT8 handle provided.\n");
753 switch(CGATS_type_value)
784 fprintf(stderr,
"[_dt_colorchecker_get_material_string] Error: Unknown material type.\n");
809 gchar *result = NULL;
813 fprintf(stderr,
"[_dt_colorchecker_get_standard_type] Error: Invalid CGATS type provided.\n");
814 result = g_strdup(
"Unknown Type");
820 result = g_strdup(
"IT8");
822 result = g_strdup(
"CTI3");
826 result = g_strdup(
type);
832 fprintf(stderr,
"[_dt_colorchecker_get_standard_type] Error: Memory allocation failed for standard type string.\n");
850 fprintf(stderr,
"[_dt_CGATS_is_supported] Error: Invalid IT8 handle provided.\n");
854 const char *CGATS_type = cmsIT8GetSheetType(*hIT8);
865 int column_SAMPLE_ID = -1;
872 char **sample_names = NULL;
873 int n_columns = cmsIT8EnumDataFormat(*hIT8, &sample_names);
877 fprintf(stderr,
"[_dt_CGATS_is_supported] Error with the CGATS file, can't get column types\n");
882 for(
int i = 0;
i < n_columns;
i++)
884 if(!g_strcmp0(sample_names[
i],
"SAMPLE_ID") || !g_strcmp0(sample_names[
i],
"SAMPLE_LOC"))
885 column_SAMPLE_ID =
i;
886 else if(!g_strcmp0(sample_names[
i],
"XYZ_X"))
888 else if(!g_strcmp0(sample_names[
i],
"XYZ_Y"))
890 else if(!g_strcmp0(sample_names[
i],
"XYZ_Z"))
892 else if(!g_strcmp0(sample_names[
i],
"LAB_L"))
894 else if(!g_strcmp0(sample_names[
i],
"LAB_A"))
896 else if(!g_strcmp0(sample_names[
i],
"LAB_B"))
900 if(column_SAMPLE_ID == -1)
902 fprintf(stderr,
"[_dt_CGATS_is_supported] Error: can't find the SAMPLE_ID column in the CGATS file.\n");
906 if(column_X + column_Y + column_Z + column_L + column_a + column_b == -1)
908 fprintf(stderr,
"[_dt_CGATS_is_supported] Error: No XYZ or Lab columns found in the CGATS file.\n");
912 uint32_t table_count = cmsIT8TableCount(*hIT8);
915 dt_print(
DT_DEBUG_VERBOSE,
"[_dt_CGATS_is_supported] the CGATS file contains %u tables but only one table is supported at the moment.\n",
927 fprintf(stderr,
"[_dt_CGATS_get_author] Error: Invalid IT8 handle provided.\n");
928 return "Unknown Author";
930 const char *author = cmsIT8GetProperty(*hIT8,
"ORIGINATOR");
932 return !
IS_NULL_PTR(author) ? author :
"Unknown Author";
945 fprintf(stderr,
"[_dt_CGATS_get_date] Error: Invalid IT8 handle provided.\n");
946 return "Unknown Date";
950 const char *date = cmsIT8GetProperty(*hIT8,
"PROD_DATE");
959 fprintf(stderr,
"[_dt_CGATS_get_manufacturer] Error: Invalid IT8 handle provided.\n");
960 return "Unknown Manufacturer";
962 const char *manufacturer = cmsIT8GetProperty(*hIT8,
"MANUFACTURER");
963 return !
IS_NULL_PTR(manufacturer) ? manufacturer :
"Unknown Manufacturer";
977 fprintf(stderr,
"[_dt_get_builtin_colorchecker_name] Error: Unable to get the color checker %d.\n", target_type);
978 return g_strdup(
"Unknown name");
980 gchar *
name = g_strdup(color_checker->
name);
997 fprintf(stderr,
"[_dt_get_builtin_colorchecker_patch_nb] Error: Unable to get the color checker %d.\n", target_type);
1000 const int patch_nb = color_checker->
patches;
1017 fprintf(stderr,
"[_dt_colorchecker_label_build_name] Error: Invalid label provided.\n");
1018 return g_strdup(
"Unknown Color Checker");
1023 ? g_strdup_printf(
" (%s)", label->
material)
1028 : g_strdup(
"Unknown");
1031 gchar *
name = g_strdup_printf(
"%s%s - %s",
type, tmp_material, tmp_description);
1050 gchar *result = NULL;
1051 gchar *basename = NULL;
1053 if(!
IS_NULL_PTR(filename) && g_strcmp0(filename,
"") != 0)
1055 basename = g_path_get_basename(filename);
1056 char *dot = g_strrstr(basename,
".");
1066 fprintf(stderr,
"[_dt_CGATS_get_name] Error: Invalid CGATS handle provided.\n");
1067 result = g_strdup(!
IS_NULL_PTR(basename) ? basename :
"Unnamed CGATS");
1073 const char *
description = cmsIT8GetProperty(*hIT8,
"DESCRIPTOR");
1079 dt_print(
DT_DEBUG_VERBOSE,
"[_dt_CGATS_get_name] no useful metadata found in the CGATS file to build a name, using filename instead.\n");
1080 result = (!
IS_NULL_PTR(basename) && g_strcmp0(basename,
"") != 0) ? g_strdup(basename) : g_strdup(
"Unnamed CGATS");
1087 .material = material_str };
1095 result = (!
IS_NULL_PTR(basename) && g_strcmp0(basename,
"") != 0) ? g_strdup(basename) : g_strdup(
"Unnamed CGATS");
1120 if(
IS_NULL_PTR(filepath) || g_strcmp0(filepath,
"") == 0)
1122 fprintf(stderr,
"Error: Invalid file path provided for CHT file.\n");
1129 fprintf(stderr,
"Error: cannot allocate memory for the chart spec.\n");
1135 fprintf(stderr,
"Error: cannot open the cht file '%s'.\n", filepath);
1140 fprintf(stderr,
"Error: no patches found in the cht file '%s'.\n", filepath);
1148static float dE_1976(
const float a,
const float b,
const float c)
1150 return sqrtf(sqf(a) + sqf(b) + sqf(c));
1157 fprintf(stderr,
"[_dt_CGATS_find_whitest_blackest_greyest] Error: Invalid input parameters.\n");
1161 for(
int i = 0;
i < 3;
i++)
1163 float target = 50.f *
i;
1164 float delta_current =
dE_1976(values[bwg[
i]].
Lab[0] - target, values[bwg[
i]].
Lab[1], values[bwg[
i]].
Lab[2]);
1165 float delta_patch =
dE_1976(values[patch].
Lab[0] - target, values[patch].
Lab[1], values[patch].
Lab[2]);
1166 if(delta_patch < delta_current)
1185 fprintf(stderr,
"Error: Invalid input parameters for filling patch values from CGATS file.\n");
1189 int column_SAMPLE_ID = -1;
1196 char **sample_names = NULL;
1197 int n_columns = cmsIT8EnumDataFormat(hIT8, &sample_names);
1202 fprintf(stderr,
"Error: Memory allocation failed for values array.\n");
1206 gboolean use_XYZ =
FALSE;
1209 fprintf(stderr,
"Error with the CGATS file, can't get column types\n");
1213 for(
int i = 0;
i < n_columns;
i++)
1215 if(!g_strcmp0(sample_names[
i],
"SAMPLE_ID") || !g_strcmp0(sample_names[
i],
"SAMPLE_LOC"))
1216 column_SAMPLE_ID =
i;
1217 else if(!g_strcmp0(sample_names[
i],
"XYZ_X"))
1219 else if(!g_strcmp0(sample_names[
i],
"XYZ_Y"))
1221 else if(!g_strcmp0(sample_names[
i],
"XYZ_Z"))
1223 else if(!g_strcmp0(sample_names[
i],
"LAB_L"))
1225 else if(!g_strcmp0(sample_names[
i],
"LAB_A"))
1227 else if(!g_strcmp0(sample_names[
i],
"LAB_B"))
1231 if(column_SAMPLE_ID == -1)
1233 fprintf(stderr,
"Error: can't find the SAMPLE_ID column in the CGATS file.\n");
1237 if(column_X + column_Y + column_Z + column_L + column_a + column_b == -1)
1239 fprintf(stderr,
"Error: No XYZ or Lab columns found in the CGATS file.\n");
1243 int columns[3] = { -1, -1, -1 };
1244 if(column_L != -1 && column_a != -1 && column_b != -1)
1246 columns[0] = cmsIT8FindDataFormat(hIT8,
"LAB_L");
1247 columns[1] = cmsIT8FindDataFormat(hIT8,
"LAB_A");
1248 columns[2] = cmsIT8FindDataFormat(hIT8,
"LAB_B");
1251 else if(column_X != -1 && column_Y != -1 && column_Z != -1)
1254 columns[0] = cmsIT8FindDataFormat(hIT8,
"XYZ_X");
1255 columns[1] = cmsIT8FindDataFormat(hIT8,
"XYZ_Y");
1256 columns[2] = cmsIT8FindDataFormat(hIT8,
"XYZ_Z");
1260 fprintf(stderr,
"Error: can't find XYZ or Lab columns in the CGATS file\n");
1264 for(
size_t patch_iter = 0; patch_iter < num_patches; patch_iter++)
1269 const char *sample_name = cmsIT8GetDataRowCol(hIT8, patch_iter, 0);
1272 fprintf(stderr,
"Error : can't find sample '%" G_GSIZE_FORMAT
"' in CGATS file\n", patch_iter);
1280 fprintf(stderr,
"Error: no patches found in the chart specification.\n");
1287 fprintf(stderr,
"Error: patch %" G_GSIZE_FORMAT
" not found in chart specification.\n", patch_iter);
1293 fprintf(stderr,
"Error: patch %" G_GSIZE_FORMAT
" has no name in chart specification.\n", patch_iter);
1298 const double patchdbl[3] = { cmsIT8GetDataRowColDbl(hIT8, (
int)patch_iter, columns[0]),
1299 cmsIT8GetDataRowColDbl(hIT8, (
int)patch_iter, columns[1]),
1300 cmsIT8GetDataRowColDbl(hIT8, (
int)patch_iter, columns[2]) };
1305 const dt_aligned_pixel_t patch_color = { (float)patchdbl[0] * 0.01, (
float)patchdbl[1] *0.01, (float)patchdbl[2] * 0.01, 0.0f };
1310 values[patch_iter].Lab[0] = (float)patchdbl[0];
1311 values[patch_iter].Lab[1] = (float)patchdbl[1];
1312 values[patch_iter].Lab[2] = (float)patchdbl[2];
1323 for(
size_t i = 0;
i < num_patches;
i++)
1342 if(
IS_NULL_PTR(color_filename) || g_strcmp0(color_filename,
"") == 0)
1344 fprintf(stderr,
"Error: Invalid color filename provided.\n");
1348 if(!g_file_test(color_filename, G_FILE_TEST_IS_REGULAR))
1350 fprintf(stderr,
"Error: the color file '%s' does not exist or is not a regular file.\n", color_filename);
1354 cmsHANDLE hIT8 = cmsIT8LoadFromFile(NULL, color_filename);
1358 fprintf(stderr,
"Ansel cannot load the CGATS file '%s'\n", color_filename);
1365 fprintf(stderr,
"Error: cannot allocate memory for the chart spec.\n");
1369 if(!
IS_NULL_PTR(cht_filename) && g_file_test(cht_filename, G_FILE_TEST_IS_REGULAR))
1373 fprintf(stderr,
"Error: cannot open the cht file '%s'.\n", cht_filename);
1380 const int num_patches_it8 = (
const int)cmsIT8GetPropertyDbl(hIT8,
"NUMBER_OF_SETS");
1384 dt_print(
DT_DEBUG_VERBOSE,
"the number of patches in the CGATS file (%i) does not match the expected number (%i) in the cht file.\n",
1389 const size_t num_patches =
MIN(num_patches_it8, chart_spec->
num_patches);
1395 fprintf(stderr,
"Error: cannot allocate memory for the color checker.\n");
1406 checker->
patches = num_patches;
1407 checker->
size[0] = chart_spec->
size[0];
1408 checker->
size[1] = chart_spec->
size[1];
1414 size_t bwg[3] = { 0, 0, 0 };
1418 fprintf(stderr,
"Error: cannot fill the color values from the CGATS file.\n");
1422 checker->
black = bwg[0];
1423 checker->
white = bwg[1];
1432 fprintf(stderr,
"Error creating user ref checker, in %s %s:%d\n", __FUNCTION__, __FILE__, lineno);
1446 if(
IS_NULL_PTR(filename) || g_strcmp0(filename,
"") == 0 ||
IS_NULL_PTR(user_it8_dir) || g_strcmp0(user_it8_dir,
"") == 0)
1448 fprintf(stderr,
"Error: Invalid filename or user IT8 directory provided for making CGATS label.\n");
1452 gchar *filepath = g_build_filename(user_it8_dir, filename, NULL);
1453 if(g_file_test(filepath, G_FILE_TEST_IS_REGULAR))
1455 cmsHANDLE hIT8 = cmsIT8LoadFromFile(NULL, filepath);
1458 const int patch_nb = (int)cmsIT8GetPropertyDbl(hIT8,
"NUMBER_OF_SETS");
1465 result = CGATS_label;
1480 if(
IS_NULL_PTR(filename) || g_strcmp0(filename,
"") == 0 ||
IS_NULL_PTR(user_it8_dir) || g_strcmp0(user_it8_dir,
"") == 0)
1482 fprintf(stderr,
"Error: Invalid filename or user IT8 directory provided for making CHT label.\n");
1488 gchar *filepath = g_build_filename(user_it8_dir, filename, NULL);
1489 if(g_file_test(filepath, G_FILE_TEST_IS_REGULAR))
1491 gchar *basename = g_path_get_basename(filename);
1492 char *dot = g_strrstr(basename,
".");
1524 fprintf(stderr,
"Error: failed to allocate memory for builtin colorchecker label %d\n",
k);
1529 *colorcheckers_label = g_list_append(*colorcheckers_label, builtin_label);
1541 gchar *user_it8_dir = g_build_filename(confdir,
"color",
"checker", NULL);
1543 GDir *dir = g_dir_open(user_it8_dir, 0, NULL);
1546 const char *filename;
1547 while(!
IS_NULL_PTR(filename = g_dir_read_name(dir)))
1549 const char *dot = g_strrstr(filename,
".");
1550 if(!
IS_NULL_PTR(dot) && g_ascii_strcasecmp(dot,
".cht") == 0)
1556 *ref_colorcheckers_files = g_list_append(*ref_colorcheckers_files, CGATS_label);
1574 gchar *user_it8_dir = g_build_filename(confdir,
"color",
"checker", NULL);
1576 GDir *dir = g_dir_open(user_it8_dir, 0, NULL);
1579 const char *filename;
1580 while(!
IS_NULL_PTR(filename = g_dir_read_name(dir)))
1582 const char *dot = g_strrstr(filename,
".");
1583 if(
IS_NULL_PTR(dot) || g_ascii_strcasecmp(dot,
".cht") != 0)
1589 *chts = g_list_append(*chts, cht_label);
const char ** description(struct dt_iop_module_t *self)
static void error(char *msg)
static const dt_aligned_pixel_simd_t const dt_adaptation_t const float p
dt_colorchecker_material_types
@ COLOR_CHECKER_MATERIAL_TRANSPARENT
@ COLOR_CHECKER_MATERIAL_UNKNOWN
@ COLOR_CHECKER_MATERIAL_OPAQUE
dt_color_checker_t * dt_colorchecker_init()
dt_colorchecker_CGATS_types
void dt_colorchecker_patch_cleanup_list(void *_patch)
void dt_colorchecker_patch_cleanup(dt_color_checker_patch *patch)
const char * colorchecker_material_types[COLOR_CHECKER_MATERIAL_UNKNOWN]
dt_colorchecker_label_t * dt_colorchecker_label_init(const char *label, const dt_color_checker_targets type, const char *path, const int patch_nb)
dt_color_checker_patch * dt_colorchecker_patch_array_init(const size_t num_patches)
static dt_color_checker_t * dt_get_color_checker(const dt_color_checker_targets target_type, GList **colorchecker_label, const char *color_filename)
void dt_colorchecker_cleanup(dt_color_checker_t *checker)
const char * CGATS_types[CGATS_TYPE_UNKOWN]
static dt_aligned_pixel_t Lab
const dt_colormatrix_t dt_aligned_pixel_t out
int dt_colorchecker_find_CGATS_reference_files(GList **ref_colorcheckers_files)
Find all CGAT files in the user config/color/it8 directory.
static int _dt_get_builtin_colorchecker_patch_nb(const dt_color_checker_targets target_type)
Get the number of patches in a built-in colorchecker.
static const char * _dt_CGATS_get_manufacturer(const cmsHANDLE *hIT8)
static char * _increment_string(const gchar *in)
Increments a string alphanumerically.
static const char * _dt_CGATS_get_author(const cmsHANDLE *hIT8)
static float dE_1976(const float a, const float b, const float c)
int dt_colorchecker_find_cht_files(GList **chts)
Find all .cht files in the user config/color/it8 directory.
static dt_color_checker_patch * _dt_colorchecker_CGATS_fill_patch_values(const cmsHANDLE hIT8, size_t *bwg, const dt_colorchecker_chart_spec_t *chart_spec, const size_t num_patches)
fills the patch values from the CGATS file, converts to Lab if needed. The number of patches to be fi...
static const char * _remove_leading_zeros(const char *in)
Removes leading zeros from a string.
static void _dt_cht_box_cleanup(void *data)
static dt_colorchecker_label_t * _dt_colorchecker_cht_make_label(const gchar *filename, const gchar *user_it8_dir)
static void _dt_colorchecker_chart_spec_cleanup(dt_colorchecker_chart_spec_t *chart_spec)
static char * _dt_CGATS_get_name(const cmsHANDLE *hIT8, const char *filename)
Get the name of the colorchecker from the CGATS file. The resulting string must be freed by the calle...
static gchar * _dt_get_builtin_colorchecker_name(const dt_color_checker_targets target_type)
Get the name of a built-in color checker.
static dt_colorchecker_chart_spec_t * _dt_colorchecker_chart_spec_init()
static dt_colorchecker_CGATS_types _dt_CGATS_get_type_value(const char *type)
static cht_box_t * _dt_cht_box_extract(const char **tokens)
static const char * _dt_CGATS_get_date(const cmsHANDLE *hIT8)
Get the production date of the CGATS file.
void dt_colorchecker_copy(dt_color_checker_t *dest, const dt_color_checker_t *src)
Copy the content of a color checker from source to destination.
dt_color_checker_t * dt_colorchecker_user_ref_create(const char *color_filename, const char *cht_filename)
Creates a color checker from a reference file (CGATS format).
static gboolean _dispatch_cht_data(GList **boxes, dt_colorchecker_chart_spec_t *chart_spec)
static gboolean _dt_colorchecker_open_cht(const char *filename, dt_colorchecker_chart_spec_t *chart_spec)
Opens a CHT file and parses its content to fill the chart_spec structure.
static const char * _dt_colorchecker_get_material_string(const dt_colorchecker_material_types material)
Gets the string representation of the material type ("Transparent" or "Opaque") to be used in label n...
static void _dt_CGATS_find_whitest_blackest_greyest(const dt_color_checker_patch *const values, size_t *bwg, const size_t patch)
static GList * _parse_cht(const char *filename)
Parses a CHT file and extracts the boxes data.
static gchar * _dt_colorchecker_get_standard_type(const char *type)
Get the standard type name from a CGATS type.
static void _dt_colorchecker_copy_patch(dt_color_checker_patch *dest, const dt_color_checker_patch *src)
int dt_colorchecker_find_builtin(GList **colorcheckers_label)
Find all builtin colorcheckers.
static dt_colorchecker_material_types _dt_colorchecker_IT8_get_material_type(const cmsHANDLE *hIT8)
static gboolean _dt_cht_generate_patch_list(dt_colorchecker_chart_spec_t *chart, const cht_box_t *cht_patch, const cht_box_F_t *F_box)
Generates a list of patches from the provided cht_patch structure. Patche's positions are calculated ...
static dt_colorchecker_label_t * _dt_colorchecker_user_ref_make_label(const gchar *filename, const gchar *user_it8_dir)
static dt_color_checker_patch * _dt_colorchecker_patch_init()
static int _dt_colorchecker_cht_get_patch_nb(const char *filepath)
Get the number of patches in a CHT file.
static gboolean _dt_CGATS_is_supported(const cmsHANDLE *hIT8)
Test if the file is a CGATS.17 file and if it contains one table of patch only.
static gchar * _dt_colorchecker_label_build_name(const dt_colorchecker_CGATS_label_make_name_t *label)
build a name for the colorchecker. The returned string must be freed by the caller.
static cht_box_F_t * _dt_cht_extract_F(const char **tokens)
Extracts the frame coordinates from the tokens, computes the width and height.
void dt_print(dt_debug_thread_t thread, const char *msg,...)
#define dt_free_align(ptr)
static const dt_aligned_pixel_simd_t value
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
void dt_loc_get_user_config_dir(char *configdir, size_t bufsize)
float *const restrict const size_t k
float dt_aligned_pixel_t[4]
unsigned __int64 uint64_t
dt_color_checker_targets type
dt_color_checker_patch * values