Skip to content

Commit 5b5a61f

Browse files
committed
iop-order: fix lut3d order (after colorin).
Take the opportunity to set a clean state as discussed on #3075 with Aurélien Pierre. For #3062.
1 parent d8c468a commit 5b5a61f

File tree

1 file changed

+130
-5
lines changed

1 file changed

+130
-5
lines changed

src/common/iop_order.c

Lines changed: 130 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include <stdlib.h>
3232
#include <string.h>
3333

34-
#define DT_IOP_ORDER_VERSION 4
34+
#define DT_IOP_ORDER_VERSION 5
3535

3636
#define DT_IOP_ORDER_INFO FALSE // used while debugging
3737
#define DT_ONTHEFLY_INFO FALSE // while debugging on-the-fly conversion
@@ -189,6 +189,131 @@ static int _ioppr_legacy_iop_order_step(GList **_iop_order_list, GList *history_
189189
if(!dont_move) _rewrite_order(*_iop_order_list);
190190
new_version = 4;
191191
}
192+
else if(old_version == 4)
193+
{
194+
if(!dont_move)
195+
{
196+
// The following is a flattened list from original code. The goal is to have a clean starting point for
197+
// future modifications.
198+
const dt_iop_order_entry_t iop_v5[] = {
199+
{ 1.0, "rawprepare"},
200+
{ 2.0, "invert"},
201+
{ 3.0, "temperature"},
202+
{ 4.0, "highlights"},
203+
{ 5.0, "cacorrect"},
204+
{ 6.0, "hotpixels"},
205+
{ 7.0, "rawdenoise"},
206+
{ 8.0, "demosaic"},
207+
{ 9.0, "denoiseprofile"},
208+
{ 10.0, "bilateral"},
209+
{ 11.0, "rotatepixels"},
210+
{ 12.0, "scalepixels"},
211+
{ 13.0, "lens"},
212+
{ 14.0, "hazeremoval"},
213+
{ 15.0, "ashift"},
214+
{ 16.0, "flip"},
215+
{ 17.0, "clipping"},
216+
{ 18.0, "liquify"},
217+
{ 19.0, "spots"},
218+
{ 20.0, "retouch"},
219+
{ 21.0, "exposure"},
220+
{ 22.0, "mask_manager"},
221+
{ 23.0, "tonemap"},
222+
{ 24.0, "toneequal"},
223+
{ 25.0, "graduatednd"},
224+
{ 26.0, "profile_gamma"},
225+
{ 27.0, "equalizer"},
226+
{ 28.0, "colorin"},
227+
228+
{ 29.0, "nlmeans"}, // signal processing (denoising)
229+
// -> needs a signal as scene-referred as possible (even if it works in Lab)
230+
{ 30.0, "colorchecker"}, // calibration to "neutral" exchange colour space
231+
// -> improve colour calibration of colorin and reproductibility
232+
// of further edits (styles etc.)
233+
{ 31.0, "defringe"}, // desaturate fringes in Lab, so needs properly calibrated colours
234+
// in order for chromaticity to be meaningful,
235+
{ 32.0, "atrous"}, // frequential operation, needs a signal as scene-referred as possible to avoid halos
236+
{ 33.0, "lowpass"}, // same
237+
{ 34.0, "highpass"}, // same
238+
{ 35.0, "sharpen"}, // same, worst than atrous in same use-case, less control overall
239+
{ 36.0, "lut3d"}, // apply a creative style or film emulation, possibly non-linear,
240+
// so better move it after frequential ops that need L2 Hilbert spaces
241+
// of square summable functions
242+
{ 37.0, "colortransfer"}, // probably better if source and destination colours are neutralized in the same
243+
// colour exchange space, hence after colorin and colorcheckr,
244+
// but apply after frequential ops in case it does non-linear witchcraft,
245+
// just to be safe
246+
{ 59.0, "colormapping"}, // same
247+
{ 38.0, "channelmixer"}, // does exactly the same thing as colorin, aka RGB to RGB matrix conversion,
248+
// but coefs are user-defined instead of calibrated and read from ICC profile.
249+
// Really versatile yet under-used module, doing linear ops,
250+
// very good in scene-referred workflow
251+
{ 39.0, "basicadj"}, // module mixing view/model/control at once, usage should be discouraged
252+
{ 40.0, "colorbalance"}, // scene-referred color manipulation
253+
{ 41.0, "rgbcurve"}, // really versatile way to edit colour in scene-referred and display-referred workflow
254+
{ 42.0, "rgblevels"}, // same
255+
{ 43.0, "basecurve"}, // conversion from scene-referred to display referred, reverse-engineered
256+
// on camera JPEG default look
257+
{ 44.0, "filmic"}, // same, but different (parametric) approach
258+
{ 45.0, "filmicrgb"}, // same, upgraded
259+
{ 46.0, "colisa"}, // edit contrast while damaging colour
260+
{ 47.0, "tonecurve"}, // same
261+
{ 48.0, "levels"}, // same
262+
{ 49.0, "shadhi"}, // same
263+
{ 50.0, "zonesystem"}, // same
264+
{ 51.0, "globaltonemap"}, // same
265+
{ 52.0, "relight"}, // flatten local contrast while pretending do add lightness
266+
{ 53.0, "bilat"}, // improve clarity/local contrast after all the bad things we have done
267+
// to it with tonemapping
268+
{ 54.0, "colorcorrection"}, // now that the colours have been damaged by contrast manipulations,
269+
// try to recover them - global adjustment of white balance for shadows and highlights
270+
{ 55.0, "colorcontrast"}, // adjust chrominance globally
271+
{ 56.0, "velvia"}, // same
272+
{ 57.0, "vibrance"}, // same, but more subtle
273+
{ 58.0, "colorzones"}, // same, but locally
274+
{ 60.0, "bloom"}, // creative module
275+
{ 61.0, "colorize"}, // creative module
276+
{ 62.0, "lowlight"}, // creative module
277+
{ 63.0, "monochrome"}, // creative module
278+
{ 64.0, "grain"}, // creative module
279+
{ 65.0, "soften"}, // creative module
280+
{ 66.0, "splittoning"}, // creative module
281+
{ 67.0, "vignette"}, // creative module
282+
{ 68.0, "colorreconstruct"},// try to salvage blown areas before ICC intents in LittleCMS2 do things with them.
283+
284+
{ 69.0, "colorout"},
285+
{ 70.0, "clahe"},
286+
{ 71.0, "finalscale"},
287+
{ 72.0, "overexposed"},
288+
{ 73.0, "rawoverexposed"},
289+
{ 74.0, "dither"},
290+
{ 75.0, "borders"},
291+
{ 76.0, "watermark"},
292+
{ 77.0, "gamma"},
293+
};
294+
295+
if(g_list_length(*_iop_order_list) != 77)
296+
{
297+
fprintf(stderr, "_ioppr_legacy_iop_order_step list should have 77 entries found %d\n",
298+
g_list_length(*_iop_order_list));
299+
return 4;
300+
}
301+
302+
// note that we cannot delete the *_iop_order_list and recreate it
303+
304+
GList *l = *_iop_order_list;
305+
int i = 0;
306+
while(l)
307+
{
308+
dt_iop_order_entry_t *entry = (dt_iop_order_entry_t *)l->data;
309+
entry->iop_order = iop_v5[i].iop_order;
310+
g_strlcpy(entry->operation, iop_v5[i].operation, sizeof(entry->operation));
311+
i++;
312+
l = g_list_next(l);
313+
}
314+
}
315+
new_version = 5;
316+
}
192317
// each new version MUST be written as the following (_rewrite_order IS VERY important)
193318

194319
// If a new module is to be added, it must be added in the current
@@ -1413,7 +1538,7 @@ static void _ioppr_check_rules(GList *iop_list, const int imgid, const char *msg
14131538
}
14141539

14151540
// how is on-the-fly conversion done
1416-
// Currently a hack to support v3 history to later
1541+
// Currently a hack to support v3/v4 history to later
14171542
// returns the history version of imgid
14181543
int dt_ioppr_convert_onthefly(const int imgid)
14191544
{
@@ -1433,11 +1558,11 @@ int dt_ioppr_convert_onthefly(const int imgid)
14331558
// already latest
14341559
if (my_iop_order_version == DT_IOP_ORDER_VERSION) return my_iop_order_version;
14351560

1436-
// ??? we handle only iop-version 3 (which has been broken) and move
1437-
// it to new v4. this routine will be reused later when dt will
1561+
// ??? we handle only iop-version 3/4 (which has been broken) and move
1562+
// it to new v5. this routine will be reused later when dt will
14381563
// propose in GUI a possibility to migrate old edits to a new
14391564
// version of iop-order.
1440-
if (my_iop_order_version != 3) return my_iop_order_version; // this keeps other edit as they are
1565+
if (my_iop_order_version < 3) return my_iop_order_version; // this keeps other edit as they are
14411566

14421567
// ************** from here on we deal only with the v3 history problems; although *******************************
14431568

0 commit comments

Comments
 (0)