Skip to content

Commit 217d52f

Browse files
committed
wb: renamed find_temperature_from_... to find_illuminant_xy_from_...; comment maintenance
1 parent 5217b8c commit 217d52f

2 files changed

Lines changed: 23 additions & 26 deletions

File tree

src/common/illuminants.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,12 @@ static inline void illuminant_CCT_to_RGB(const float t, dt_aligned_pixel_t RGB)
216216
illuminant_xy_to_RGB(x, y, RGB);
217217
}
218218

219-
static inline gboolean find_temperature_from_wb_coeffs(const dt_image_t *img, const dt_aligned_pixel_t wb_coeffs,
219+
// Derive illuminant chromaticity from WB module coefficients
220+
static inline gboolean find_illuminant_xy_from_wb_coeffs(const dt_image_t *img, const dt_aligned_pixel_t wb_coeffs,
220221
float *chroma_x, float *chroma_y);
221222

222223
// Fetch image from pipeline and read EXIF for camera RAW WB coeffs
223-
static inline gboolean find_temperature_from_as_shot_coeffs(const dt_image_t *img, const dt_aligned_pixel_t correction_ratios,
224+
static inline gboolean find_illuminant_xy_from_as_shot_coeffs(const dt_image_t *img, const dt_aligned_pixel_t correction_ratios,
224225
float *chroma_x, float *chroma_y);
225226

226227

@@ -304,7 +305,7 @@ static inline int illuminant_to_xy(const dt_illuminant_t illuminant, /
304305
case DT_ILLUMINANT_CAMERA:
305306
{
306307
// Detect WB from RAW EXIF, correcting with D65/wb_coeff ratios
307-
if(img && find_temperature_from_as_shot_coeffs(img, correction_ratios, &x, &y))
308+
if(img && find_illuminant_xy_from_as_shot_coeffs(img, correction_ratios, &x, &y))
308309
break;
309310

310311
// xy calculation failed
@@ -313,7 +314,7 @@ static inline int illuminant_to_xy(const dt_illuminant_t illuminant, /
313314
case DT_ILLUMINANT_FROM_WB:
314315
{
315316
// Detect WB from user-provided coefficients
316-
if(img && find_temperature_from_wb_coeffs(img, wb_coeffs, &x, &y))
317+
if(img && find_illuminant_xy_from_wb_coeffs(img, wb_coeffs, &x, &y))
317318
break;
318319

319320
// xy calculation failed
@@ -449,7 +450,7 @@ static inline gboolean _wb_coeffs_invalid(const dt_aligned_pixel_t wb_coeffs, co
449450
}
450451

451452
// returns FALSE if failed; TRUE if successful
452-
static gboolean find_temperature_from_wb_coeffs(const dt_image_t *img, const dt_aligned_pixel_t wb_coeffs,
453+
static gboolean find_illuminant_xy_from_wb_coeffs(const dt_image_t *img, const dt_aligned_pixel_t wb_coeffs,
453454
float *chroma_x, float *chroma_y)
454455
{
455456
if(img == NULL || wb_coeffs == NULL) return FALSE;
@@ -471,7 +472,7 @@ static gboolean find_temperature_from_wb_coeffs(const dt_image_t *img, const dt_
471472
}
472473

473474
// returns FALSE if failed; TRUE if successful
474-
static gboolean find_temperature_from_as_shot_coeffs(const dt_image_t *img, const dt_aligned_pixel_t correction_ratios,
475+
static gboolean find_illuminant_xy_from_as_shot_coeffs(const dt_image_t *img, const dt_aligned_pixel_t correction_ratios,
475476
float *chroma_x, float *chroma_y)
476477
{
477478
if(img == NULL) return FALSE;
@@ -491,7 +492,7 @@ static gboolean find_temperature_from_as_shot_coeffs(const dt_image_t *img, cons
491492
for(size_t k = 0; k < 4; k++) WB[k] *= correction_ratios[k];
492493
// for a neutral surface, raw RGB * img->wb_coeffs would produce neutral R=G=B
493494

494-
return find_temperature_from_wb_coeffs(img, WB, chroma_x, chroma_y);
495+
return find_illuminant_xy_from_wb_coeffs(img, WB, chroma_x, chroma_y);
495496
}
496497

497498

src/iop/channelmixerrgb.c

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2231,7 +2231,7 @@ void process(dt_iop_module_t *self,
22312231
dt_aligned_pixel_t correction_ratios;
22322232
_get_d65_correction_ratios(self, correction_ratios);
22332233

2234-
if(find_temperature_from_as_shot_coeffs(&(self->dev->image_storage), correction_ratios, &(x), &(y)))
2234+
if(find_illuminant_xy_from_as_shot_coeffs(&(self->dev->image_storage), correction_ratios, &(x), &(y)))
22352235
{
22362236
// Convert illuminant from xyY to XYZ
22372237
dt_aligned_pixel_t XYZ;
@@ -2244,9 +2244,11 @@ void process(dt_iop_module_t *self,
22442244
}
22452245
else if(data->illuminant_type == DT_ILLUMINANT_FROM_WB)
22462246
{
2247+
// Same logic as above (we depend on the coefficients from white balance,
2248+
// which don't come from the EXIF this time).
22472249
float x, y;
22482250

2249-
if(find_temperature_from_wb_coeffs(&(self->dev->image_storage), self->dev->chroma.wb_coeffs, &(x), &(y)))
2251+
if(find_illuminant_xy_from_wb_coeffs(&(self->dev->image_storage), self->dev->chroma.wb_coeffs, &(x), &(y)))
22502252
{
22512253
// Convert illuminant from xyY to XYZ
22522254
dt_aligned_pixel_t XYZ;
@@ -2357,7 +2359,7 @@ int process_cl(dt_iop_module_t *self,
23572359
dt_aligned_pixel_t correction_ratios;
23582360
_get_d65_correction_ratios(self, correction_ratios);
23592361

2360-
if(find_temperature_from_as_shot_coeffs(&(self->dev->image_storage), correction_ratios, &(x), &(y)))
2362+
if(find_illuminant_xy_from_as_shot_coeffs(&(self->dev->image_storage), correction_ratios, &(x), &(y)))
23612363
{
23622364
// Convert illuminant from xyY to XYZ
23632365
dt_aligned_pixel_t XYZ;
@@ -2370,17 +2372,11 @@ int process_cl(dt_iop_module_t *self,
23702372
}
23712373
else if(d->illuminant_type == DT_ILLUMINANT_FROM_WB)
23722374
{
2373-
// The camera illuminant is a behaviour rather than a preset of
2374-
// values: it uses whatever is in the RAW EXIF. But it depends on
2375-
// what temperature.c is doing and needs to be updated
2376-
// accordingly, to give a consistent result. We initialise the
2377-
// CAT defaults using the temperature coeffs at startup, but if
2378-
// temperature is changed later, we get no notification of the
2379-
// change here, so we can't update the defaults. So we need to
2380-
// re-run the detection at runtime…
2375+
// Same logic as above (we depend on the coefficients from white balance,
2376+
// which don't come from the EXIF this time).
23812377
float x, y;
23822378

2383-
if(find_temperature_from_wb_coeffs(&(self->dev->image_storage), self->dev->chroma.wb_coeffs, &(x), &(y)))
2379+
if(find_illuminant_xy_from_wb_coeffs(&(self->dev->image_storage), self->dev->chroma.wb_coeffs, &(x), &(y)))
23842380
{
23852381
// Convert illuminant from xyY to XYZ
23862382
dt_aligned_pixel_t XYZ;
@@ -3107,7 +3103,7 @@ static void _preview_pipe_finished_callback(gpointer instance, dt_iop_module_t *
31073103
float x = p->x;
31083104
float y = p->y;
31093105

3110-
if(find_temperature_from_wb_coeffs(&(self->dev->image_storage), self->dev->chroma.wb_coeffs, &x, &y))
3106+
if(find_illuminant_xy_from_wb_coeffs(&(self->dev->image_storage), self->dev->chroma.wb_coeffs, &x, &y))
31113107
{
31123108
p->x = x;
31133109
p->y = y;
@@ -3997,7 +3993,7 @@ void reload_defaults(dt_iop_module_t *self)
39973993
dt_aligned_pixel_t correction_ratios;
39983994
if(!_get_d65_correction_ratios(self, correction_ratios))
39993995
{
4000-
if(find_temperature_from_as_shot_coeffs(img, correction_ratios, &(d->x), &(d->y)))
3996+
if(find_illuminant_xy_from_as_shot_coeffs(img, correction_ratios, &(d->x), &(d->y)))
40013997
d->illuminant = DT_ILLUMINANT_CAMERA;
40023998
_check_if_close_to_daylight(d->x, d->y,
40033999
&(d->temperature), &(d->illuminant), &(d->adaptation));
@@ -4093,7 +4089,7 @@ void gui_changed(dt_iop_module_t *self,
40934089
// illuminant is changed.
40944090
dt_aligned_pixel_t correction_ratios;
40954091
_get_d65_correction_ratios(self, correction_ratios);
4096-
find_temperature_from_as_shot_coeffs(&(self->dev->image_storage), correction_ratios,
4092+
find_illuminant_xy_from_as_shot_coeffs(&(self->dev->image_storage), correction_ratios,
40974093
&(p->x), &(p->y));
40984094
_check_if_close_to_daylight(p->x, p->y, &(p->temperature), NULL, &(p->adaptation));
40994095
}
@@ -4103,7 +4099,7 @@ void gui_changed(dt_iop_module_t *self,
41034099
// (x, y) were computed at runtime from the WB module's coefficients
41044100
// and p->x, p->y may hold stale values. Recompute them now so
41054101
// the new illuminant mode starts from the correct chromaticity.
4106-
find_temperature_from_wb_coeffs(&(self->dev->image_storage), self->dev->chroma.wb_coeffs,
4102+
find_illuminant_xy_from_wb_coeffs(&(self->dev->image_storage), self->dev->chroma.wb_coeffs,
41074103
&(p->x), &(p->y));
41084104
_check_if_close_to_daylight(p->x, p->y, &(p->temperature), NULL, &(p->adaptation));
41094105
}
@@ -4120,16 +4116,16 @@ void gui_changed(dt_iop_module_t *self,
41204116
// Get camera WB and update illuminant
41214117
dt_aligned_pixel_t correction_ratios;
41224118
_get_d65_correction_ratios(self, correction_ratios);
4123-
const gboolean found = find_temperature_from_as_shot_coeffs(&(self->dev->image_storage),
4119+
const gboolean found = find_illuminant_xy_from_as_shot_coeffs(&(self->dev->image_storage),
41244120
correction_ratios, &(p->x), &(p->y));
41254121
_check_if_close_to_daylight(p->x, p->y, &(p->temperature), NULL, &(p->adaptation));
41264122

41274123
if(found)
41284124
dt_control_log(_("white balance successfully extracted from raw image"));
41294125
}
4130-
if(p->illuminant == DT_ILLUMINANT_FROM_WB)
4126+
else if(p->illuminant == DT_ILLUMINANT_FROM_WB)
41314127
{
4132-
const gboolean found = find_temperature_from_wb_coeffs(&(self->dev->image_storage),
4128+
const gboolean found = find_illuminant_xy_from_wb_coeffs(&(self->dev->image_storage),
41334129
self->dev->chroma.wb_coeffs, &(p->x), &(p->y));
41344130
_check_if_close_to_daylight(p->x, p->y, &(p->temperature), NULL, &(p->adaptation));
41354131

0 commit comments

Comments
 (0)