Skip to content

Commit bb30b12

Browse files
committed
wb: minor clean-up in channelmixerrgb (GUI struct field names for clarity), no need to allocate + copy xy in illuminants.h find_illuminant_xy_from_wb_coeffs; no need for 0 check after isnormal
1 parent 460be19 commit bb30b12

2 files changed

Lines changed: 12 additions & 15 deletions

File tree

src/common/illuminants.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ static gboolean get_CAM_to_XYZ(const dt_image_t * img, float(* CAM_to_XYZ)[3])
444444
static inline gboolean _wb_coeffs_invalid(const dt_aligned_pixel_t wb_coeffs, const int num_coeffs)
445445
{
446446
for(int k = 0; k < num_coeffs; k++)
447-
if(!dt_isnormal(wb_coeffs[k]) || wb_coeffs[k] == 0.0f) return TRUE;
447+
if(!dt_isnormal(wb_coeffs[k])) return TRUE;
448448

449449
return FALSE;
450450
}
@@ -463,10 +463,7 @@ static gboolean find_illuminant_xy_from_wb_coeffs(const dt_image_t *img, const d
463463
return FALSE;
464464
}
465465

466-
float x, y;
467-
WB_coeffs_to_illuminant_xy(CAM_to_XYZ, wb_coeffs, &x, &y);
468-
*chroma_x = x;
469-
*chroma_y = y;
466+
WB_coeffs_to_illuminant_xy(CAM_to_XYZ, wb_coeffs, chroma_x, chroma_y);
470467

471468
return TRUE;
472469
}

src/iop/channelmixerrgb.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ typedef struct dt_iop_channelmixer_rgb_gui_data_t
148148
GtkWidget *scale_grey_R, *scale_grey_G, *scale_grey_B;
149149
GtkWidget *normalize_R, *normalize_G, *normalize_B, *normalize_sat, *normalize_light, *normalize_grey;
150150
GtkWidget *color_picker;
151-
float xy[2];
152-
float XYZ[4];
151+
float colorchecker_xy[2];
152+
float ai_wb_XYZ[4];
153153

154154
point_t box[4]; // the current coordinates, possibly non rectangle, of the bounding box for the color checker
155155
point_t ideal_box[4]; // the desired coordinates of the perfect rectangle bounding box for the color checker
@@ -1724,8 +1724,8 @@ static void _extract_color_checker(const float *const restrict in,
17241724
dt_D50_XYZ_to_xyY(illuminant_XYZ, illuminant_xyY);
17251725

17261726
// save the illuminant in GUI struct for commit
1727-
g->xy[0] = illuminant_xyY[0];
1728-
g->xy[1] = illuminant_xyY[1];
1727+
g->colorchecker_xy[0] = illuminant_xyY[0];
1728+
g->colorchecker_xy[1] = illuminant_xyY[1];
17291729

17301730
// and recompute back the LMS to be sure we use the parameters that
17311731
// will be computed later
@@ -2207,7 +2207,7 @@ void process(dt_iop_module_t *self,
22072207
// as scratch space since we will be overwriting it afterwards
22082208
// anyway
22092209
_auto_detect_WB(in, out, data->illuminant_type, roi_in->width, roi_in->height,
2210-
ch, RGB_to_XYZ, g->XYZ);
2210+
ch, RGB_to_XYZ, g->ai_wb_XYZ);
22112211
dt_dev_pixelpipe_cache_invalidate_later(piece->pipe, self->iop_order, "AI RGB: ");
22122212
dt_iop_gui_leave_critical_section(self);
22132213
}
@@ -3002,8 +3002,8 @@ static void _commit_profile_callback(GtkWidget *widget,
30023002

30033003
dt_iop_gui_enter_critical_section(self);
30043004

3005-
p->x = g->xy[0];
3006-
p->y = g->xy[1];
3005+
p->x = g->colorchecker_xy[0];
3006+
p->y = g->colorchecker_xy[1];
30073007
p->illuminant = DT_ILLUMINANT_CUSTOM;
30083008
_check_if_close_to_daylight(p->x, p->y, &p->temperature, NULL, NULL);
30093009

@@ -3063,8 +3063,8 @@ static void _develop_ui_pipe_finished_callback(gpointer instance, dt_iop_module_
30633063
return;
30643064

30653065
dt_iop_gui_enter_critical_section(self);
3066-
p->x = g->XYZ[0];
3067-
p->y = g->XYZ[1];
3066+
p->x = g->ai_wb_XYZ[0];
3067+
p->y = g->ai_wb_XYZ[1];
30683068
dt_iop_gui_leave_critical_section(self);
30693069

30703070
_check_if_close_to_daylight(p->x, p->y,
@@ -4548,7 +4548,7 @@ void gui_init(dt_iop_module_t *self)
45484548
g->delta_E_in = NULL;
45494549
g->delta_E_label_text = NULL;
45504550

4551-
g->XYZ[0] = NAN;
4551+
g->ai_wb_XYZ[0] = NAN;
45524552

45534553
#ifdef AI_ACTIVATED
45544554
DT_CONTROL_SIGNAL_HANDLE(DT_SIGNAL_DEVELOP_UI_PIPE_FINISHED, _develop_ui_pipe_finished_callback);

0 commit comments

Comments
 (0)