Allows to specify various "regions" of the image with masks, and to correct
for hue, saturation and lightness.
Inspired by the existing L*a*b* grid (in turn taken from darktable)
The JSON file is called workingspaces.json, it can be either in the global iccprofiles directory, or in the user's ICC profiles dir (set in preferences).
The format is the following:
{"working_spaces": [
{
"name" : "ACES",
"file" : "/path/to/ACES.icc"
},
{
"name" : "ACEScg",
"matrix" : [0.7184354, 0.16578523, 0.09882643, 0.29728935, 0.66958117, 0.03571544, -0.00647622, 0.01469771, 0.66732561]
}
]}
if "matrix" is present, "file" is ignored. If only "file" is present, the matrix is extracted from the ICC profile. For this, we look only at the R, G, and B matrix columns and the white point set in the profile. Bradford adaptation is used to convert the matrix to D50. Anything else (LUT, TRC, ...) in the profile is ignored.
It is the user's responsibility to ensure that the profile is suitable to be used as a working space.
Also convert most functions in `rt_math.h` to `constexpr` by
implementing `min()` and `max()` natively. `constexpr` indeed has a
positive impact on the generated assembly.
This change allows for an arbitrary number of arguments to `min()` and
`max()` by using recursion on variadic template functions. The
disassembly of GCC 6.3 was carefully checked for regressions, but
nothing was found other than the flipping of arguments (recursion is
now `(((a,b),c),d)` and was `(d,(c,(a,b)))` before).
I also unified the common type `_Tp` to to the even more common `T`.