90#define TWO_SQRT2f 2.8284271247461900976f
114 dest->
Lab[0] = src->
Lab[0];
115 dest->
Lab[1] = src->
Lab[1];
116 dest->
Lab[2] = src->
Lab[2];
142 fprintf(stderr,
"Error: Memory allocation failed for color checker values.\n");
170 float extracted_coords[8] = { 0.f };
171 for(
size_t i = 0; tokens[
i] != NULL;
i++)
173 if(index >= 8)
break;
175 if(g_ascii_isdigit(tokens[
i][0]))
177 extracted_coords[index] = (float)g_ascii_strtod(tokens[
i], NULL);
183 frame_coordinates->
ax = extracted_coords[0];
184 frame_coordinates->
ay = extracted_coords[1];
185 frame_coordinates->
bx = extracted_coords[2];
186 frame_coordinates->
by = extracted_coords[3];
187 frame_coordinates->
cx = extracted_coords[4];
188 frame_coordinates->
cy = extracted_coords[5];
189 frame_coordinates->
dx = extracted_coords[6];
190 frame_coordinates->
dy = extracted_coords[7];
193 frame_coordinates->
width = extracted_coords[2] - extracted_coords[0];
194 frame_coordinates->
height = extracted_coords[5] - extracted_coords[1];
196 return frame_coordinates;
277 if(tokens[
i][0] !=
'\0')
280 const char *
string = tokens[
i];
283 if(g_ascii_isdigit(tokens[
i][0]) || (tokens[
i][0] ==
'-' && g_ascii_isdigit(tokens[
i][1])))
284 value = (float)g_ascii_strtod(tokens[
i], NULL);
288 case 0: box->
key_letter = tokens[
i][0]; index++;
break;
289 case 1: box->
label_x_start = g_strdup(
string); index++;
break;
290 case 2: box->
label_x_end = g_strdup(
string); index++;
break;
291 case 3: box->
label_y_start = g_strdup(
string); index++;
break;
292 case 4: box->
label_y_end = g_strdup(
string); index++;
break;
299 default: fprintf(stderr,
"Unexpected token in cht box extraction: %s\n", tokens[
i]);
320 gchar *result = g_strdup(in);
323 size_t len = strlen(result);
331 for(
int i = (
int)len - 1;
i >= 0;
i--)
334 if(g_ascii_isdigit(result[
i]))
345 else if(g_ascii_isalpha(result[
i]))
347 if(result[
i] ==
'z' || result[
i] ==
'Z')
349 result[
i] = (result[
i] ==
'z') ?
'a' :
'A';
374 const char *start = in;
375 while(*start ==
'0') start++;
391 gboolean result =
FALSE;
394 gchar *current_colum = NULL;
395 gchar *current_row = NULL;
396 gchar *last_label = NULL;
397 GSList *patch_tail = NULL;
402 fprintf(stderr,
"Invalid cht_patch");
408 fprintf(stderr,
"Invalid chart");
423 if(g_strcmp0(start_colum, end_colum) > 0 || g_strcmp0(start_row, end_row) > 0)
427 const float patch_w = cht_patch->
width / 2;
428 const float patch_h = cht_patch->
height / 2;
437 last_label = g_strconcat(last_label_colum ? last_label_colum :
"", last_label_row ? last_label_row :
"", NULL);
441 current_colum = g_strdup(start_colum);
445 const float inv_frame_width = 1.f / (F_box->
width - chart->
guide_size[0]);
446 const float inv_frame_height = 1.f / (F_box->
height - chart->
guide_size[1]);
448 patch_tail = g_slist_last(chart->
patches);
452 while(g_strcmp0(current_colum, colum_last) <= 0)
454 current_row = g_strdup(start_row);
458 while(g_strcmp0(current_row, row_last) <= 0)
464 gchar *label = g_strconcat(label_colum ? label_colum :
"", label_row ? label_row :
"", NULL);
479 int index_x = swap_axes ? index_row : index_colum;
480 float temp_x = (origin_x + (cht_patch->
x_increment * index_x)) * inv_frame_width;
482 int index_y = swap_axes ? index_colum : index_row;
483 float temp_y = (origin_y + (cht_patch->
y_increment * index_y)) * inv_frame_height;
490 GSList *patch_node = g_slist_alloc();
491 patch_node->data = patch;
492 patch_node->next = NULL;
494 patch_tail->next = patch_node;
497 patch_tail = patch_node;
499 const gboolean last_patch_reached = !g_strcmp0(patch->name, last_label);
500 if(last_patch_reached)
goto out;
501 if(!g_strcmp0(current_row,
"_"))
break;
518 current_colum = temp;
529 fprintf(stderr,
"error parsing CHT file, in %s %s:%d\n", __FUNCTION__, __FILE__, lineno);
546 GList *result = NULL;
550 fprintf(stderr,
"Invalid filename for CHT parsing");
555 GIOChannel *fp = g_io_channel_new_file(filename,
"r", NULL);
558 fprintf(stderr,
"Error opening '%s'\n", filename);
563 GString *line = g_string_new(NULL);
568 while(g_io_channel_read_line_string(fp, line, NULL, NULL) == G_IO_STATUS_NORMAL)
575 if(skip_block)
continue;
578 const char *c = line->str;
581 while(*c ==
' ') c++;
582 gchar **line_tokens = g_strsplit(c,
" ", 0);
589 while(g_io_channel_read_line_string(fp, line, NULL, NULL) == G_IO_STATUS_NORMAL)
591 if(line->len == 0)
break;
594 while(*c ==
' ') c++;
596 gchar **box_tokens = g_strsplit(c,
" ", 0);
598 && (!g_strcmp0(box_tokens[0],
"F")
599 || !g_strcmp0(box_tokens[0],
"D")
600 || !g_strcmp0(box_tokens[0],
"X")
601 || !g_strcmp0(box_tokens[0],
"Y")))
603 result = g_list_append(result, box_tokens);
607 g_strfreev(box_tokens);
618 g_strfreev(line_tokens);
627 fprintf(stderr,
"error parsing CHT file, in %s %s:%d\n", __FUNCTION__, __FILE__, lineno);
630 if(line) g_string_free(line,
TRUE);
631 if(fp) g_io_channel_unref(fp);
640 gboolean result =
FALSE;
645 GList *boxes_list = NULL;
647 float chart_radius = -1.f;
651 fprintf(stderr,
"Invalid input to dispatch cht data");
656 for(GList *lines = *boxes; lines; lines = g_list_next(lines))
658 const char **tokens = (
const char **)lines->data;
661 const char letter = tokens[0][0];
671 else if(letter ==
'D' || letter ==
'X' || letter ==
'Y')
676 boxes_list = g_list_append(boxes_list, box);
684 chart_radius = hypotf(F_box->
height, F_box->
width);
686 for(GList *iter = boxes_list; iter; iter = g_list_next(iter))
711 chart_spec->
size[0] = (size_t)chart_spec->
colums;
712 chart_spec->
size[1] = (size_t)chart_spec->
rows;
714 chart_spec->
radius = patch_radius / chart_radius;
720 fprintf(stderr,
"Error dispatching CHT file, in %s %s:%d\n", __FUNCTION__, __FILE__, lineno);
740 fprintf(stderr,
"[_dt_colorchecker_open_cht] Error: Invalid input parameters.\n");
747 fprintf(stderr,
"[_dt_colorchecker_open_cht] Error parsing CHT file '%s'\n", filename);
753 fprintf(stderr,
"[_dt_colorchecker_open_cht] Error dispatching CHT data from '%s'\n", filename);
754 g_list_free_full(boxes, (GDestroyNotify)g_strfreev);
758 chart_spec->
type = g_path_get_basename(filename);
760 g_list_free_full(boxes, (GDestroyNotify)g_strfreev);
771 fprintf(stderr,
"[_dt_colorchecker_IT8_get_material_type] Error: Invalid IT8 handle provided.\n");
776 switch(CGATS_type_value)
807 fprintf(stderr,
"[_dt_colorchecker_get_material_string] Error: Unknown material type.\n");
832 gchar *result = NULL;
836 fprintf(stderr,
"[_dt_colorchecker_get_standard_type] Error: Invalid CGATS type provided.\n");
837 result = g_strdup(
"Unknown Type");
843 result = g_strdup(
"IT8");
845 result = g_strdup(
"CTI3");
849 result = g_strdup(
type);
855 fprintf(stderr,
"[_dt_colorchecker_get_standard_type] Error: Memory allocation failed for standard type string.\n");
873 fprintf(stderr,
"[_dt_CGATS_is_supported] Error: Invalid IT8 handle provided.\n");
877 const char *CGATS_type = cmsIT8GetSheetType(*hIT8);
888 int column_SAMPLE_ID = -1;
895 char **sample_names = NULL;
896 int n_columns = cmsIT8EnumDataFormat(*hIT8, &sample_names);
900 fprintf(stderr,
"[_dt_CGATS_is_supported] Error with the CGATS file, can't get column types\n");
905 for(
int i = 0;
i < n_columns;
i++)
907 if(!g_strcmp0(sample_names[
i],
"SAMPLE_ID") || !g_strcmp0(sample_names[
i],
"SAMPLE_LOC"))
908 column_SAMPLE_ID =
i;
909 else if(!g_strcmp0(sample_names[
i],
"XYZ_X"))
911 else if(!g_strcmp0(sample_names[
i],
"XYZ_Y"))
913 else if(!g_strcmp0(sample_names[
i],
"XYZ_Z"))
915 else if(!g_strcmp0(sample_names[
i],
"LAB_L"))
917 else if(!g_strcmp0(sample_names[
i],
"LAB_A"))
919 else if(!g_strcmp0(sample_names[
i],
"LAB_B"))
923 if(column_SAMPLE_ID == -1)
925 fprintf(stderr,
"[_dt_CGATS_is_supported] Error: can't find the SAMPLE_ID column in the CGATS file.\n");
929 if(column_X + column_Y + column_Z + column_L + column_a + column_b == -1)
931 fprintf(stderr,
"[_dt_CGATS_is_supported] Error: No XYZ or Lab columns found in the CGATS file.\n");
935 uint32_t table_count = cmsIT8TableCount(*hIT8);
938 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",
950 fprintf(stderr,
"[_dt_CGATS_get_author] Error: Invalid IT8 handle provided.\n");
951 return "Unknown Author";
953 const char *author = cmsIT8GetProperty(*hIT8,
"ORIGINATOR");
955 return !
IS_NULL_PTR(author) ? author :
"Unknown Author";
968 fprintf(stderr,
"[_dt_CGATS_get_date] Error: Invalid IT8 handle provided.\n");
969 return "Unknown Date";
973 const char *date = cmsIT8GetProperty(*hIT8,
"PROD_DATE");
982 fprintf(stderr,
"[_dt_CGATS_get_manufacturer] Error: Invalid IT8 handle provided.\n");
983 return "Unknown Manufacturer";
985 const char *manufacturer = cmsIT8GetProperty(*hIT8,
"MANUFACTURER");
986 return !
IS_NULL_PTR(manufacturer) ? manufacturer :
"Unknown Manufacturer";
1000 fprintf(stderr,
"[_dt_get_builtin_colorchecker_name] Error: Unable to get the color checker %d.\n", target_type);
1001 return g_strdup(
"Unknown name");
1003 gchar *
name = g_strdup(color_checker->
name);
1020 fprintf(stderr,
"[_dt_get_builtin_colorchecker_patch_nb] Error: Unable to get the color checker %d.\n", target_type);
1023 const int patch_nb = color_checker->
patches;
1040 fprintf(stderr,
"[_dt_colorchecker_label_build_name] Error: Invalid label provided.\n");
1041 return g_strdup(
"Unknown Color Checker");
1046 ? g_strdup_printf(
" (%s)", label->
material)
1051 : g_strdup(
"Unknown");
1054 gchar *
name = g_strdup_printf(
"%s%s - %s",
type, tmp_material, tmp_description);
1073 gchar *result = NULL;
1074 gchar *basename = NULL;
1076 if(!
IS_NULL_PTR(filename) && g_strcmp0(filename,
"") != 0)
1078 basename = g_path_get_basename(filename);
1079 char *dot = g_strrstr(basename,
".");
1089 fprintf(stderr,
"[_dt_CGATS_get_name] Error: Invalid CGATS handle provided.\n");
1090 result = g_strdup(!
IS_NULL_PTR(basename) ? basename :
"Unnamed CGATS");
1096 const char *
description = cmsIT8GetProperty(*hIT8,
"DESCRIPTOR");
1102 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");
1103 result = (!
IS_NULL_PTR(basename) && g_strcmp0(basename,
"") != 0) ? g_strdup(basename) : g_strdup(
"Unnamed CGATS");
1110 .material = material_str };
1118 result = (!
IS_NULL_PTR(basename) && g_strcmp0(basename,
"") != 0) ? g_strdup(basename) : g_strdup(
"Unnamed CGATS");
1143 if(
IS_NULL_PTR(filepath) || g_strcmp0(filepath,
"") == 0)
1145 fprintf(stderr,
"Error: Invalid file path provided for CHT file.\n");
1152 fprintf(stderr,
"Error: cannot allocate memory for the chart spec.\n");
1158 fprintf(stderr,
"Error: cannot open the cht file '%s'.\n", filepath);
1163 fprintf(stderr,
"Error: no patches found in the cht file '%s'.\n", filepath);
1171static float dE_1976(
const float a,
const float b,
const float c)
1173 return sqrtf(sqf(a) + sqf(b) + sqf(c));
1180 fprintf(stderr,
"[_dt_CGATS_find_whitest_blackest_greyest] Error: Invalid input parameters.\n");
1184 for(
int i = 0;
i < 3;
i++)
1186 float target = 50.f *
i;
1187 float delta_current =
dE_1976(values[bwg[
i]].
Lab[0] - target, values[bwg[
i]].
Lab[1], values[bwg[
i]].
Lab[2]);
1188 float delta_patch =
dE_1976(values[patch].
Lab[0] - target, values[patch].
Lab[1], values[patch].
Lab[2]);
1189 if(delta_patch < delta_current)
1208 fprintf(stderr,
"Error: Invalid input parameters for filling patch values from CGATS file.\n");
1212 int column_SAMPLE_ID = -1;
1219 char **sample_names = NULL;
1220 int n_columns = cmsIT8EnumDataFormat(hIT8, &sample_names);
1225 fprintf(stderr,
"Error: Memory allocation failed for values array.\n");
1229 gboolean use_XYZ =
FALSE;
1232 fprintf(stderr,
"Error with the CGATS file, can't get column types\n");
1236 for(
int i = 0;
i < n_columns;
i++)
1238 if(!g_strcmp0(sample_names[
i],
"SAMPLE_ID") || !g_strcmp0(sample_names[
i],
"SAMPLE_LOC"))
1239 column_SAMPLE_ID =
i;
1240 else if(!g_strcmp0(sample_names[
i],
"XYZ_X"))
1242 else if(!g_strcmp0(sample_names[
i],
"XYZ_Y"))
1244 else if(!g_strcmp0(sample_names[
i],
"XYZ_Z"))
1246 else if(!g_strcmp0(sample_names[
i],
"LAB_L"))
1248 else if(!g_strcmp0(sample_names[
i],
"LAB_A"))
1250 else if(!g_strcmp0(sample_names[
i],
"LAB_B"))
1254 if(column_SAMPLE_ID == -1)
1256 fprintf(stderr,
"Error: can't find the SAMPLE_ID column in the CGATS file.\n");
1260 if(column_X + column_Y + column_Z + column_L + column_a + column_b == -1)
1262 fprintf(stderr,
"Error: No XYZ or Lab columns found in the CGATS file.\n");
1266 int columns[3] = { -1, -1, -1 };
1267 if(column_L != -1 && column_a != -1 && column_b != -1)
1269 columns[0] = cmsIT8FindDataFormat(hIT8,
"LAB_L");
1270 columns[1] = cmsIT8FindDataFormat(hIT8,
"LAB_A");
1271 columns[2] = cmsIT8FindDataFormat(hIT8,
"LAB_B");
1274 else if(column_X != -1 && column_Y != -1 && column_Z != -1)
1277 columns[0] = cmsIT8FindDataFormat(hIT8,
"XYZ_X");
1278 columns[1] = cmsIT8FindDataFormat(hIT8,
"XYZ_Y");
1279 columns[2] = cmsIT8FindDataFormat(hIT8,
"XYZ_Z");
1283 fprintf(stderr,
"Error: can't find XYZ or Lab columns in the CGATS file\n");
1287 for(
size_t patch_iter = 0; patch_iter < num_patches; patch_iter++)
1292 const char *sample_name = cmsIT8GetDataRowCol(hIT8, patch_iter, 0);
1295 fprintf(stderr,
"Error : can't find sample '%" G_GSIZE_FORMAT
"' in CGATS file\n", patch_iter);
1303 fprintf(stderr,
"Error: no patches found in the chart specification.\n");
1310 fprintf(stderr,
"Error: patch %" G_GSIZE_FORMAT
" not found in chart specification.\n", patch_iter);
1316 fprintf(stderr,
"Error: patch %" G_GSIZE_FORMAT
" has no name in chart specification.\n", patch_iter);
1321 const double patchdbl[3] = { cmsIT8GetDataRowColDbl(hIT8, (
int)patch_iter, columns[0]),
1322 cmsIT8GetDataRowColDbl(hIT8, (
int)patch_iter, columns[1]),
1323 cmsIT8GetDataRowColDbl(hIT8, (
int)patch_iter, columns[2]) };
1328 const dt_aligned_pixel_t patch_color = { (float)patchdbl[0] * 0.01, (
float)patchdbl[1] *0.01, (float)patchdbl[2] * 0.01, 0.0f };
1333 values[patch_iter].Lab[0] = (float)patchdbl[0];
1334 values[patch_iter].Lab[1] = (float)patchdbl[1];
1335 values[patch_iter].Lab[2] = (float)patchdbl[2];
1346 for(
size_t i = 0;
i < num_patches;
i++)
1365 if(
IS_NULL_PTR(color_filename) || g_strcmp0(color_filename,
"") == 0)
1367 fprintf(stderr,
"Error: Invalid color filename provided.\n");
1371 if(!g_file_test(color_filename, G_FILE_TEST_IS_REGULAR))
1373 fprintf(stderr,
"Error: the color file '%s' does not exist or is not a regular file.\n", color_filename);
1377 cmsHANDLE hIT8 = cmsIT8LoadFromFile(NULL, color_filename);
1381 fprintf(stderr,
"Ansel cannot load the CGATS file '%s'\n", color_filename);
1388 fprintf(stderr,
"Error: cannot allocate memory for the chart spec.\n");
1392 if(!
IS_NULL_PTR(cht_filename) && g_file_test(cht_filename, G_FILE_TEST_IS_REGULAR))
1396 fprintf(stderr,
"Error: cannot open the cht file '%s'.\n", cht_filename);
1403 const int num_patches_it8 = (
const int)cmsIT8GetPropertyDbl(hIT8,
"NUMBER_OF_SETS");
1407 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",
1412 const size_t num_patches =
MIN(num_patches_it8, chart_spec->
num_patches);
1418 fprintf(stderr,
"Error: cannot allocate memory for the color checker.\n");
1429 checker->
patches = num_patches;
1430 checker->
size[0] = chart_spec->
size[0];
1431 checker->
size[1] = chart_spec->
size[1];
1437 size_t bwg[3] = { 0, 0, 0 };
1441 fprintf(stderr,
"Error: cannot fill the color values from the CGATS file.\n");
1445 checker->
black = bwg[0];
1446 checker->
white = bwg[1];
1455 fprintf(stderr,
"Error creating user ref checker, in %s %s:%d\n", __FUNCTION__, __FILE__, lineno);
1469 if(
IS_NULL_PTR(filename) || g_strcmp0(filename,
"") == 0 ||
IS_NULL_PTR(user_it8_dir) || g_strcmp0(user_it8_dir,
"") == 0)
1471 fprintf(stderr,
"Error: Invalid filename or user IT8 directory provided for making CGATS label.\n");
1475 gchar *filepath = g_build_filename(user_it8_dir, filename, NULL);
1476 if(g_file_test(filepath, G_FILE_TEST_IS_REGULAR))
1478 cmsHANDLE hIT8 = cmsIT8LoadFromFile(NULL, filepath);
1481 const int patch_nb = (int)cmsIT8GetPropertyDbl(hIT8,
"NUMBER_OF_SETS");
1488 result = CGATS_label;
1503 if(
IS_NULL_PTR(filename) || g_strcmp0(filename,
"") == 0 ||
IS_NULL_PTR(user_it8_dir) || g_strcmp0(user_it8_dir,
"") == 0)
1505 fprintf(stderr,
"Error: Invalid filename or user IT8 directory provided for making CHT label.\n");
1511 gchar *filepath = g_build_filename(user_it8_dir, filename, NULL);
1512 if(g_file_test(filepath, G_FILE_TEST_IS_REGULAR))
1514 gchar *basename = g_path_get_basename(filename);
1515 char *dot = g_strrstr(basename,
".");
1547 fprintf(stderr,
"Error: failed to allocate memory for builtin colorchecker label %d\n",
k);
1552 *colorcheckers_label = g_list_append(*colorcheckers_label, builtin_label);
1564 gchar *user_it8_dir = g_build_filename(confdir,
"color",
"checker", NULL);
1566 GDir *dir = g_dir_open(user_it8_dir, 0, NULL);
1569 const char *filename;
1570 while(!
IS_NULL_PTR(filename = g_dir_read_name(dir)))
1572 const char *dot = g_strrstr(filename,
".");
1573 if(!
IS_NULL_PTR(dot) && g_ascii_strcasecmp(dot,
".cht") == 0)
1579 *ref_colorcheckers_files = g_list_append(*ref_colorcheckers_files, CGATS_label);
1597 gchar *user_it8_dir = g_build_filename(confdir,
"color",
"checker", NULL);
1599 GDir *dir = g_dir_open(user_it8_dir, 0, NULL);
1602 const char *filename;
1603 while(!
IS_NULL_PTR(filename = g_dir_read_name(dir)))
1605 const char *dot = g_strrstr(filename,
".");
1606 if(
IS_NULL_PTR(dot) || g_ascii_strcasecmp(dot,
".cht") != 0)
1612 *chts = g_list_append(*chts, cht_label);
const char ** description(struct dt_iop_module_t *self)
static void error(char *msg)
static dt_colorchecker_label_t * dt_colorchecker_label_init(const char *label, const dt_color_checker_targets type, const char *path, const int patch_nb)
static void dt_colorchecker_cleanup(dt_color_checker_t *checker)
dt_colorchecker_material_types
@ COLOR_CHECKER_MATERIAL_TRANSPARENT
@ COLOR_CHECKER_MATERIAL_UNKNOWN
@ COLOR_CHECKER_MATERIAL_OPAQUE
static void dt_colorchecker_patch_cleanup(dt_color_checker_patch *patch)
dt_colorchecker_CGATS_types
static void dt_colorchecker_patch_cleanup_list(void *_patch)
static dt_color_checker_t * dt_get_color_checker(const dt_color_checker_targets target_type, const char *cht_filename, const char *color_filename)
Build a color checker of the given type.
static dt_color_checker_t * dt_colorchecker_init()
static dt_color_checker_patch * dt_colorchecker_patch_array_init(const size_t num_patches)
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.
static const char * colorchecker_material_types[COLOR_CHECKER_MATERIAL_UNKNOWN]
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 const char * CGATS_types[CGATS_TYPE_UNKOWN]
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_alloc_align(size_t size)
Allocate cacheline-aligned memory.
void dt_loc_get_user_config_dir(char *configdir, size_t bufsize)
_lib_location_type_t type
void dt_print(dt_debug_thread_t thread, const char *msg,...) __attribute__((format(printf
Print to stdout when thread is enabled, prefixed with seconds since startup.
float *const restrict const size_t k
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
#define dt_free_align(ptr)
Release memory from dt_alloc_align() and set ptr to NULL.
#define dt_free(ptr)
g_free() ptr and set it to NULL, skipping both if it is already NULL.
#define DT_PATH_MAX
Buffer size for a filesystem path anywhere in Ansel.
DT_ALIGNED_PIXEL float dt_aligned_pixel_t[4]
static const dt_aligned_pixel_simd_t value
unsigned __int64 uint64_t
dt_color_checker_targets type
dt_color_checker_patch * values