diff --git a/src/OpenColorIO/ops/fixedfunction/ACES2/Common.h b/src/OpenColorIO/ops/fixedfunction/ACES2/Common.h index 18f012363..2bfa79c90 100644 --- a/src/OpenColorIO/ops/fixedfunction/ACES2/Common.h +++ b/src/OpenColorIO/ops/fixedfunction/ACES2/Common.h @@ -47,10 +47,11 @@ inline float from_radians(const float v) { return wrap_to_hue_limit(v); }; struct TableBase { - static constexpr unsigned int _TABLE_ADDITION_ENTRIES = 2; - static constexpr unsigned int base_index = 1; + static constexpr unsigned int _TABLE_ADDITION_LOWER_ENTRIES = 1; + static constexpr unsigned int _TABLE_ADDITION_UPPER_ENTRIES = 2; + static constexpr unsigned int base_index = _TABLE_ADDITION_LOWER_ENTRIES; static constexpr unsigned int nominal_size = 360; - static constexpr unsigned int total_size = nominal_size + _TABLE_ADDITION_ENTRIES; + static constexpr unsigned int total_size = nominal_size + _TABLE_ADDITION_LOWER_ENTRIES + _TABLE_ADDITION_UPPER_ENTRIES; static constexpr unsigned int lower_wrap_index = 0; static constexpr unsigned int upper_wrap_index = base_index + nominal_size; diff --git a/src/OpenColorIO/ops/fixedfunction/ACES2/Transform.cpp b/src/OpenColorIO/ops/fixedfunction/ACES2/Transform.cpp index d3bd1771e..889c2a90b 100644 --- a/src/OpenColorIO/ops/fixedfunction/ACES2/Transform.cpp +++ b/src/OpenColorIO/ops/fixedfunction/ACES2/Transform.cpp @@ -730,8 +730,9 @@ void build_hue_table(Table1D &hue_table, const std::array find_display_cusp_for_hue(float hue, const std::array& RGB_corners, const std::array& JMh_corners, @@ -820,12 +821,15 @@ Table3D build_cusp_table(const Table1D& hue_table, const std::array input_32f = { + 0.0f, 0.0f, 0.0f, 1.0f, + 0.742242277f, 0.0931933373f, 0.321542144f, 1.0f // Bug #2220: related to hue angle calculation + // triggering an out of bounds access in the tables + // at exactly 360 degrees + }; + constexpr std::array expected_32f = { + 0.0f, 0.0f, 0.0f, 1.0f, + 0.74736571311951f, -0.0019352473318577f, 0.19451357424259f, 1.0f, // Note: exact output value is not + // significant to the test as the bug + // was in the internal table access logic + }; + + OCIO::FixedFunctionOpData::Params params = { + // Peak luminance + 100.f, + // Rec709 gamut + 0.6400, 0.3300, 0.3000, 0.6000, 0.1500, 0.0600, 0.3127, 0.3290 + }; + + OCIO::ConstFixedFunctionOpDataRcPtr funcData + = std::make_shared(OCIO::FixedFunctionOpData::ACES_OUTPUT_TRANSFORM_20_FWD, + params); + + ApplyFixedFunction(input_32f.data(), expected_32f.data(), test_cases, funcData, 1e-4f, __LINE__); +} + OCIO_ADD_TEST(FixedFunctionOpCPU, aces_ot_20_p3d65_100n_rt) { const int lut_size = 8;