diff --git a/rtengine/clutstore.cc b/rtengine/clutstore.cc index 533d1e89d..53adcc013 100644 --- a/rtengine/clutstore.cc +++ b/rtengine/clutstore.cc @@ -1,18 +1,22 @@ +#include + #include "clutstore.h" -#include "rt_math.h" + +#include "image16.h" +#include "imagefloat.h" #include "stdimagesource.h" #include "../rtgui/options.h" namespace { -std::unique_ptr loadFile( +std::unique_ptr loadFile( const Glib::ustring& filename, const Glib::ustring& working_color_space, unsigned int& clut_level ) { - std::unique_ptr result; + std::unique_ptr result; rtengine::StdImageSource img_src; @@ -38,17 +42,19 @@ std::unique_ptr loadFile( if (valid) { rtengine::ColorTemp curr_wb = img_src.getWB(); - result = std::unique_ptr(new rtengine::Imagefloat(fw, fh)); + std::unique_ptr img_float = std::unique_ptr(new rtengine::Imagefloat(fw, fh)); const PreviewProps pp(0, 0, fw, fh, 1); rtengine::procparams::ColorManagementParams icm; icm.working = working_color_space; - img_src.getImage(curr_wb, TR_NONE, result.get(), pp, rtengine::procparams::ToneCurveParams(), icm, rtengine::procparams::RAWParams()); + img_src.getImage(curr_wb, TR_NONE, img_float.get(), pp, rtengine::procparams::ToneCurveParams(), icm, rtengine::procparams::RAWParams()); if (!working_color_space.empty()) { - img_src.convertColorSpace(result.get(), icm, curr_wb); + img_src.convertColorSpace(img_float.get(), icm, curr_wb); } + + result = std::unique_ptr(img_float->to16()); } return result; @@ -100,6 +106,8 @@ void rtengine::CLUT::splitClutFilename( rtengine::HaldCLUT::HaldCLUT() : clut_level(0), + flevel_minus_one(0.0f), + flevel_minus_two(0.0f), clut_profile("sRGB") { } @@ -116,6 +124,9 @@ bool rtengine::HaldCLUT::load(const Glib::ustring& filename) if (clut_image) { clut_filename = filename; + clut_level *= clut_level; + flevel_minus_one = static_cast(clut_level - 1) / 65535.0f; + flevel_minus_two = static_cast(clut_level - 2); return true; } @@ -139,10 +150,7 @@ Glib::ustring rtengine::HaldCLUT::getProfile() const void rtengine::HaldCLUT::getRGB(float r, float g, float b, float& out_r, float& out_g, float& out_b) const { - const unsigned int level = clut_level * clut_level; - - const float flevel_minus_one = static_cast(level - 1) / 65535.0f; - const float flevel_minus_two = static_cast(level - 2); + const unsigned int level = clut_level; // This is important const unsigned int red = std::min(flevel_minus_two, r * flevel_minus_one); const unsigned int green = std::min(flevel_minus_two, g * flevel_minus_one); diff --git a/rtengine/clutstore.h b/rtengine/clutstore.h index ce8fd9627..b084c67fe 100644 --- a/rtengine/clutstore.h +++ b/rtengine/clutstore.h @@ -4,12 +4,13 @@ #include -#include "imagefloat.h" #include "cache.h" namespace rtengine { +class Image16; + class CLUT { public: @@ -50,8 +51,10 @@ public: void getRGB(float r, float g, float b, float& out_r, float& out_g, float& out_b) const; private: - std::unique_ptr clut_image; + std::unique_ptr clut_image; unsigned int clut_level; + float flevel_minus_one; + float flevel_minus_two; Glib::ustring clut_filename; Glib::ustring clut_profile; }; diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 2732c567d..d61c79513 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -4337,8 +4337,6 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer //Film Simulations if ( colorLUT ) { - MyTime start, stop; - start.set(); for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { float &sourceR = rtemp[ti * TS + tj]; @@ -4377,8 +4375,6 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer } } - stop.set(); - printf("Film simulation took %dus.\n", stop.etime(start)); }