diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-03-13 16:46:50 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-03-13 16:46:50 +0000 |
| commit | 45625f3116a09d3c8415a54bf8d19fdbb3a3aa9b (patch) | |
| tree | 3619eb2ba2d9e754f9122b367f4eeffe56239bf9 /src/xyz_srgb_lut.cc | |
| parent | 6e5411a943ef9b3f23cfb8dd9dcc1a756b55bfbe (diff) | |
Compute LUTs at run-time.dynamic-lut
Diffstat (limited to 'src/xyz_srgb_lut.cc')
| -rw-r--r-- | src/xyz_srgb_lut.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/xyz_srgb_lut.cc b/src/xyz_srgb_lut.cc new file mode 100644 index 00000000..3d207195 --- /dev/null +++ b/src/xyz_srgb_lut.cc @@ -0,0 +1,24 @@ +#include <iostream> +#include <cmath> +#include "xyz_srgb_lut.h" + +using namespace libdcp; + +LUTCache<XYZsRGBLUT> XYZsRGBLUT::cache; + +XYZsRGBLUT::XYZsRGBLUT(int bits, float gamma) + : LUT<int> (bits, gamma) +{ + int const bit_length = pow(2, bits); + + for (int i = 0; i < bit_length; ++i) { + float v = float(i) / (bit_length - 1); + if (v < (0.04045 / 12.92)) { + v *= 12.92; + } else { + v = (1.055 * pow (v, (1 / gamma))) - 0.055; + } + + _lut[i] = int(v * 255); + } +} |
