diff --git a/src/OpenColorIO/ops/fixedfunction/ACES2/Common.h b/src/OpenColorIO/ops/fixedfunction/ACES2/Common.h index ec3a916fd..174db8baf 100644 --- a/src/OpenColorIO/ops/fixedfunction/ACES2/Common.h +++ b/src/OpenColorIO/ops/fixedfunction/ACES2/Common.h @@ -125,10 +125,10 @@ namespace CAM16 } // Table generation -constexpr float gammaMinimum = 0.0; -constexpr float gammaMaximum = 5.0; -constexpr float gammaSearchStep = 0.4; -constexpr float gammaAccuracy = 1e-5; +constexpr float gammaMinimum = 0.0f; +constexpr float gammaMaximum = 5.0f; +constexpr float gammaSearchStep = 0.4f; +constexpr float gammaAccuracy = 1e-5f; } // namespace ACES2 diff --git a/src/OpenColorIO/ops/fixedfunction/ACES2/Init.cpp b/src/OpenColorIO/ops/fixedfunction/ACES2/Init.cpp index 1b044fa48..1f4b9e813 100644 --- a/src/OpenColorIO/ops/fixedfunction/ACES2/Init.cpp +++ b/src/OpenColorIO/ops/fixedfunction/ACES2/Init.cpp @@ -28,24 +28,24 @@ inline float wrap_to_360(float hue) inline float radians_to_degrees(float radians) { - return radians * 180.f / M_PI; + return radians * 180.f / (float) M_PI; } inline float degrees_to_radians(float degrees) { - return degrees / 180.f * M_PI; + return degrees / 180.f * (float) M_PI; } inline float base_hue_for_position(int i_lo, int table_size) { - const float result = i_lo * 360. / table_size; + const float result = i_lo * 360.f / table_size; return result; } inline int hue_position_in_uniform_table(float hue, int table_size) { - const float wrapped_hue = wrap_to_360( hue); - const int result = (wrapped_hue / 360.f * table_size); + const float wrapped_hue = wrap_to_360(hue); + const int result = int(wrapped_hue / 360.f * (float) table_size); return result; } @@ -74,7 +74,7 @@ inline f2 cuspFromTable(float h, const Table3D >) { high_i = i; } - i = (low_i + high_i) / 2.f; + i = (low_i + high_i) / 2; } lo[0] = gt.table[high_i-1][0]; @@ -106,13 +106,13 @@ inline float reachMFromTable(float h, const Table1D >) float panlrc_forward(float v, float F_L) { float F_L_v = pow(F_L * std::abs(v) / reference_luminance, 0.42f); - float c = (400.f * std::copysign(1., v) * F_L_v) / (27.13f + F_L_v); + float c = (400.f * std::copysign(1.f, v) * F_L_v) / (27.13f + F_L_v); return c; } float panlrc_inverse(float v, float F_L) { - float p = std::copysign(1., v) * reference_luminance / F_L * pow((27.13f * std::abs(v) / (400.f - std::abs(v))), 1.f / 0.42f); + float p = std::copysign(1.f, v) * reference_luminance / F_L * pow((27.13f * std::abs(v) / (400.f - std::abs(v))), 1.f / 0.42f); return p; } @@ -124,7 +124,7 @@ float Hellwig_J_to_Y(float J, const JMhParams ¶ms) float Y_to_Hellwig_J(float Y, const JMhParams ¶ms) { - float F_L_Y = pow(params.F_L * std::abs(Y) / 100., 0.42); + float F_L_Y = pow(params.F_L * std::abs(Y) / 100.f, 0.42f); return std::copysign(1.f, Y) * reference_luminance * pow(((400.f * F_L_Y) / (27.13f + F_L_Y)) / params.A_w_J, surround[1] * params.z); } @@ -174,7 +174,7 @@ f3 Hellwig2022_JMh_to_XYZ(const f3 &JMh, const JMhParams ¶ms) const float hr = degrees_to_radians(h); // Computing achromatic respons A for the stimulus - const float A = params.A_w * pow(J / reference_luminance, 1. / (surround[1] * params.z)); + const float A = params.A_w * pow(J / reference_luminance, 1.f / (surround[1] * params.z)); // Computing opponent colour dimensions a and b const float scale = M / (43.f * surround[2]); @@ -266,7 +266,7 @@ JMhParams init_JMhParams(const Primaries &P) const float A_w = ra * RGB_AW[0] + RGB_AW[1] + ba * RGB_AW[2]; const float F_L_W = pow(F_L, 0.42f); - const float A_w_J = (400. * F_L_W) / (27.13 + F_L_W); + const float A_w_J = (400.f * F_L_W) / (27.13f + F_L_W); p.XYZ_w = XYZ_w; p.F_L = F_L; @@ -328,8 +328,8 @@ Table3D make_gamut_table(const Primaries &P, float peakLuminance) gamutCuspTable.table[gamutCuspTable.base_index + gamutCuspTable.size][2] = gamutCuspTable.table[gamutCuspTable.base_index][2]; // Wrap the hues, to maintain monotonicity. These entries will fall outside [0.0, 360.0] - gamutCuspTable.table[0][2] = gamutCuspTable.table[0][2] - 360.0; - gamutCuspTable.table[gamutCuspTable.size+1][2] = gamutCuspTable.table[gamutCuspTable.size+1][2] + 360.0; + gamutCuspTable.table[0][2] = gamutCuspTable.table[0][2] - 360.f; + gamutCuspTable.table[gamutCuspTable.size+1][2] = gamutCuspTable.table[gamutCuspTable.size+1][2] + 360.f; return gamutCuspTable; } @@ -348,7 +348,7 @@ Table1D make_reach_m_table(const Primaries &P, float peakLuminance) Table1D gamutReachTable{}; for (int i = 0; i < gamutReachTable.size; i++) { - const float hue = i; + const float hue = (float) i; const float search_range = 50.f; float low = 0.; @@ -404,7 +404,7 @@ float get_focus_gain(float J, float cuspJ, float limit_J_max) { // Approximate inverse required above threshold float gain = (limit_J_max - thr) / std::max(0.0001f, (limit_J_max - std::min(limit_J_max, J))); - return pow(log10(gain), 1. / focus_adjust_gain) + 1.f; + return pow(log10(gain), 1.f / focus_adjust_gain) + 1.f; } else { @@ -474,8 +474,8 @@ f3 find_gamut_boundary_intersection(const f3 &JMh_s, const f2 &JM_cusp_in, float slope = (J_max - J_intersect_source) * (J_intersect_source - J_focus) / (J_focus * slope_gain); } - const float M_boundary_lower = J_intersect_cusp * pow(J_intersect_source / J_intersect_cusp, 1. / gamma_bottom) / (JM_cusp[0] / JM_cusp[1] - slope); - const float M_boundary_upper = JM_cusp[1] * (J_max - J_intersect_cusp) * pow((J_max - J_intersect_source) / (J_max - J_intersect_cusp), 1. / gamma_top) / (slope * JM_cusp[1] + J_max - JM_cusp[0]); + const float M_boundary_lower = J_intersect_cusp * pow(J_intersect_source / J_intersect_cusp, 1.f / gamma_bottom) / (JM_cusp[0] / JM_cusp[1] - slope); + const float M_boundary_upper = JM_cusp[1] * (J_max - J_intersect_cusp) * pow((J_max - J_intersect_source) / (J_max - J_intersect_cusp), 1.f / gamma_top) / (slope * JM_cusp[1] + J_max - JM_cusp[0]); const float M_boundary = JM_cusp[1] * smin(M_boundary_lower / JM_cusp[1], M_boundary_upper / JM_cusp[1], s); const float J_boundary = J_intersect_source + slope * M_boundary; @@ -530,7 +530,7 @@ Table1D make_upper_hull_gamma( { gammaTable.table[i] = -1.f; - const float hue = i; + const float hue = (float) i; const f2 JMcusp = cuspFromTable(hue, gamutCuspTable); f3 testJMh[test_count]{}; @@ -598,23 +598,23 @@ ToneScaleParams init_ToneScaleParams(float peakLuminance) // Preset constants that set the desired behavior for the curve const float n = peakLuminance; - const float n_r = 100.0; // normalized white in nits (what 1.0 should be) - const float g = 1.15; // surround / contrast - const float c = 0.18; // anchor for 18% grey - const float c_d = 10.013; // output luminance of 18% grey (in nits) - const float w_g = 0.14; // change in grey between different peak luminance - const float t_1 = 0.04; // shadow toe or flare/glare compensation - const float r_hit_min = 128.; // scene-referred value "hitting the roof" - const float r_hit_max = 896.; // scene-referred value "hitting the roof" + const float n_r = 100.0f; // normalized white in nits (what 1.0 should be) + const float g = 1.15f; // surround / contrast + const float c = 0.18f; // anchor for 18% grey + const float c_d = 10.013f; // output luminance of 18% grey (in nits) + const float w_g = 0.14f; // change in grey between different peak luminance + const float t_1 = 0.04f; // shadow toe or flare/glare compensation + const float r_hit_min = 128.f; // scene-referred value "hitting the roof" + const float r_hit_max = 896.f; // scene-referred value "hitting the roof" // Calculate output constants const float r_hit = r_hit_min + (r_hit_max - r_hit_min) * (log(n/n_r)/log(10000.f/100.f)); const float m_0 = (n / n_r); const float m_1 = 0.5f * (m_0 + sqrt(m_0 * (m_0 + 4.f * t_1))); - const float u = pow((r_hit/m_1)/((r_hit/m_1)+1),g); + const float u = pow((r_hit/m_1)/((r_hit/m_1)+1.f),g); const float m = m_1 / u; const float w_i = log(n/100.f)/log(2.f); - const float c_t = c_d/n_r * (1. + w_i * w_g); + const float c_t = c_d/n_r * (1.f + w_i * w_g); const float g_ip = 0.5f * (c_t + sqrt(c_t * (c_t + 4.f * t_1))); const float g_ipp2 = -(m_1 * pow((g_ip/m),(1.f/g))) / (pow(g_ip/m , 1.f/g)-1.f); const float w_2 = c / g_ipp2; diff --git a/src/OpenColorIO/ops/fixedfunction/ACES2/MatrixLib.h b/src/OpenColorIO/ops/fixedfunction/ACES2/MatrixLib.h index 82784770f..869f90ae1 100644 --- a/src/OpenColorIO/ops/fixedfunction/ACES2/MatrixLib.h +++ b/src/OpenColorIO/ops/fixedfunction/ACES2/MatrixLib.h @@ -16,7 +16,7 @@ using f4 = std::array; using m33f = std::array; -inline constexpr f3 clamp_f3(const f3 &f3, float clampMin, float clampMax) +inline f3 clamp_f3(const f3 &f3, float clampMin, float clampMax) { return { std::max(std::min(f3[0], clampMax), clampMin), @@ -25,12 +25,12 @@ inline constexpr f3 clamp_f3(const f3 &f3, float clampMin, float clampMax) }; } -inline constexpr f3 f3_from_f(float v) +inline f3 f3_from_f(float v) { return f3 {v, v, v}; } -inline constexpr f3 add_f_f3(float v, const f3 &f3) +inline f3 add_f_f3(float v, const f3 &f3) { return { v + f3[0], @@ -39,7 +39,7 @@ inline constexpr f3 add_f_f3(float v, const f3 &f3) }; } -inline constexpr f3 mult_f_f3(float v, const f3 &f3) +inline f3 mult_f_f3(float v, const f3 &f3) { return { v * f3[0], @@ -48,7 +48,7 @@ inline constexpr f3 mult_f_f3(float v, const f3 &f3) }; } -inline constexpr f3 mult_f3_f33(const f3 &f3, const m33f &mat33) +inline f3 mult_f3_f33(const f3 &f3, const m33f &mat33) { return { f3[0] * mat33[0] + f3[1] * mat33[1] + f3[2] * mat33[2], @@ -57,7 +57,7 @@ inline constexpr f3 mult_f3_f33(const f3 &f3, const m33f &mat33) }; } -inline constexpr m33f mult_f33_f33(const m33f &a, const m33f &b) +inline m33f mult_f33_f33(const m33f &a, const m33f &b) { return { a[0] * b[0] + a[1] * b[3] + a[2] * b[6], @@ -74,7 +74,7 @@ inline constexpr m33f mult_f33_f33(const m33f &a, const m33f &b) }; } -inline constexpr m33f scale_f33(const m33f &mat33, const f3 &scale) +inline m33f scale_f33(const m33f &mat33, const f3 &scale) { return { mat33[0] * scale[0], mat33[3], mat33[6], @@ -83,7 +83,7 @@ inline constexpr m33f scale_f33(const m33f &mat33, const f3 &scale) }; } -inline constexpr m33f transpose_f33(const m33f &mat33) +inline m33f transpose_f33(const m33f &mat33) { return { mat33[0], mat33[3], mat33[6], diff --git a/src/OpenColorIO/ops/fixedfunction/FixedFunctionOpCPU.cpp b/src/OpenColorIO/ops/fixedfunction/FixedFunctionOpCPU.cpp index 71275af44..69c9f26a1 100644 --- a/src/OpenColorIO/ops/fixedfunction/FixedFunctionOpCPU.cpp +++ b/src/OpenColorIO/ops/fixedfunction/FixedFunctionOpCPU.cpp @@ -887,12 +887,12 @@ void Renderer_ACES_RGB_TO_JMh_20::apply(const void * inImg, void * outImg, long float panlrc_forward(float v, float F_L) { const float F_L_v = powf(F_L * std::abs(v) / 100.f, 0.42f); - return (400.f * std::copysign(1., v) * F_L_v) / (27.13f + F_L_v); + return (400.f * std::copysign(1.f, v) * F_L_v) / (27.13f + F_L_v); } float panlrc_inverse(float v, float F_L) { - return std::copysign(1., v) * 100.f / F_L * powf((27.13f * std::abs(v) / (400.f - std::abs(v))), 1.f / 0.42f); + return std::copysign(1.f, v) * 100.f / F_L * powf((27.13f * std::abs(v) / (400.f - std::abs(v))), 1.f / 0.42f); } void Renderer_ACES_RGB_TO_JMh_20::fwd(const void * inImg, void * outImg, long numPixels) const @@ -954,6 +954,7 @@ void Renderer_ACES_RGB_TO_JMh_20::inv(const void * inImg, void * outImg, long nu const float PI = 3.14159265358979f; const float h_rad = h * PI / 180.f; + const float scale = M / (43.f * 0.9f); const float A = m_p.A_w * powf(J / 100.f, 1.f / (0.59f * m_p.z)); const float a = scale * cos(h_rad); @@ -1040,7 +1041,7 @@ float wrap_to_360(float hue) int hue_position_in_uniform_table(float hue, int table_size) { const float wrapped_hue = wrap_to_360(hue); - return (wrapped_hue / 360.f * table_size); + return int(wrapped_hue / 360.f * (float) table_size); } int next_position_in_table(int entry, int table_size) @@ -1230,7 +1231,7 @@ f2 cusp_from_table(float h, const ACES2::Table3D >) { i_hi = i; } - i = (i_lo + i_hi) / 2.f; + i = (i_lo + i_hi) / 2; } float lo[3]{}; @@ -1255,7 +1256,7 @@ float hue_dependent_upper_hull_gamma(float h, const ACES2::Table1D >) const int i_lo = hue_position_in_uniform_table(h, gt.size) + gt.base_index; const int i_hi = next_position_in_table(i_lo, gt.size); - const float base_hue = i_lo - gt.base_index; + const float base_hue = (float) (i_lo - gt.base_index); const float t = wrap_to_360(h) - base_hue; @@ -1339,8 +1340,8 @@ f3 find_gamut_boundary_intersection( slope = (J_max - J_intersect_source) * (J_intersect_source - J_focus) / (J_focus * slope_gain); } - const float M_boundary_lower = J_intersect_cusp * pow(J_intersect_source / J_intersect_cusp, 1. / gamma_bottom) / (JM_cusp[0] / JM_cusp[1] - slope); - const float M_boundary_upper = JM_cusp[1] * (J_max - J_intersect_cusp) * pow((J_max - J_intersect_source) / (J_max - J_intersect_cusp), 1. / gamma_top) / (slope * JM_cusp[1] + J_max - JM_cusp[0]); + const float M_boundary_lower = J_intersect_cusp * pow(J_intersect_source / J_intersect_cusp, 1.f / gamma_bottom) / (JM_cusp[0] / JM_cusp[1] - slope); + const float M_boundary_upper = JM_cusp[1] * (J_max - J_intersect_cusp) * pow((J_max - J_intersect_source) / (J_max - J_intersect_cusp), 1.f / gamma_top) / (slope * JM_cusp[1] + J_max - JM_cusp[0]); const float M_boundary = JM_cusp[1] * smin(M_boundary_lower / JM_cusp[1], M_boundary_upper / JM_cusp[1], 0.12f); const float J_boundary = J_intersect_source + slope * M_boundary; @@ -1386,22 +1387,22 @@ float compression_function( float lim, bool invert) { - float s = (lim - thr) * (1.0 - thr) / (lim - 1.0); + float s = (lim - thr) * (1.f - thr) / (lim - 1.f); float nd = (v - thr) / s; float vCompressed; if (invert) { - if (v < thr || lim < 1.0001 || v > thr + s) { + if (v < thr || lim < 1.0001f || v > thr + s) { vCompressed = v; } else { - vCompressed = thr + s * (-nd / (nd - 1)); + vCompressed = thr + s * (-nd / (nd - 1.f)); } } else { - if (v < thr || lim < 1.0001) { + if (v < thr || lim < 1.0001f) { vCompressed = v; } else { - vCompressed = thr + s * nd / (1.0 + nd); + vCompressed = thr + s * nd / (1.f + nd); } }