diff options
author | 2023-07-24 16:04:46 +0530 | |
---|---|---|
committer | 2023-08-02 22:26:19 +0000 | |
commit | 88c57a25cf91b6a69848940a36d9303b929c8837 (patch) | |
tree | 99efa1c0af349059926b1dffef9103ce53019f9e | |
parent | c1d4244a623121acd75ac335a1be671199320f9a (diff) |
ultrahdr: correct offset used during look ups
The offset that is used during look ups, has a bias. This is corrected.
Bug: 294199334
Test: ./libultrahdr_test
Change-Id: Ib8f5fbefd93a6d9afaa5db3f845746becd0fcce1
-rw-r--r-- | libs/ultrahdr/gainmapmath.cpp | 10 | ||||
-rw-r--r-- | libs/ultrahdr/include/ultrahdr/gainmapmath.h | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/libs/ultrahdr/gainmapmath.cpp b/libs/ultrahdr/gainmapmath.cpp index e1c5085b14..ae9c4ca338 100644 --- a/libs/ultrahdr/gainmapmath.cpp +++ b/libs/ultrahdr/gainmapmath.cpp @@ -168,7 +168,7 @@ Color srgbInvOetf(Color e_gamma) { // See IEC 61966-2-1, Equations F.5 and F.6. float srgbInvOetfLUT(float e_gamma) { - uint32_t value = static_cast<uint32_t>(e_gamma * kSrgbInvOETFNumEntries); + uint32_t value = static_cast<uint32_t>(e_gamma * (kSrgbInvOETFNumEntries - 1) + 0.5); //TODO() : Remove once conversion modules have appropriate clamping in place value = CLIP3(value, 0, kSrgbInvOETFNumEntries - 1); return kSrgbInvOETF[value]; @@ -288,7 +288,7 @@ Color hlgOetf(Color e) { } float hlgOetfLUT(float e) { - uint32_t value = static_cast<uint32_t>(e * kHlgOETFNumEntries); + uint32_t value = static_cast<uint32_t>(e * (kHlgOETFNumEntries - 1) + 0.5); //TODO() : Remove once conversion modules have appropriate clamping in place value = CLIP3(value, 0, kHlgOETFNumEntries - 1); @@ -315,7 +315,7 @@ Color hlgInvOetf(Color e_gamma) { } float hlgInvOetfLUT(float e_gamma) { - uint32_t value = static_cast<uint32_t>(e_gamma * kHlgInvOETFNumEntries); + uint32_t value = static_cast<uint32_t>(e_gamma * (kHlgInvOETFNumEntries - 1) + 0.5); //TODO() : Remove once conversion modules have appropriate clamping in place value = CLIP3(value, 0, kHlgInvOETFNumEntries - 1); @@ -344,7 +344,7 @@ Color pqOetf(Color e) { } float pqOetfLUT(float e) { - uint32_t value = static_cast<uint32_t>(e * kPqOETFNumEntries); + uint32_t value = static_cast<uint32_t>(e * (kPqOETFNumEntries - 1) + 0.5); //TODO() : Remove once conversion modules have appropriate clamping in place value = CLIP3(value, 0, kPqOETFNumEntries - 1); @@ -376,7 +376,7 @@ Color pqInvOetf(Color e_gamma) { } float pqInvOetfLUT(float e_gamma) { - uint32_t value = static_cast<uint32_t>(e_gamma * kPqInvOETFNumEntries); + uint32_t value = static_cast<uint32_t>(e_gamma * (kPqInvOETFNumEntries - 1) + 0.5); //TODO() : Remove once conversion modules have appropriate clamping in place value = CLIP3(value, 0, kPqInvOETFNumEntries - 1); diff --git a/libs/ultrahdr/include/ultrahdr/gainmapmath.h b/libs/ultrahdr/include/ultrahdr/gainmapmath.h index 50b4d2fab1..9f1238f718 100644 --- a/libs/ultrahdr/include/ultrahdr/gainmapmath.h +++ b/libs/ultrahdr/include/ultrahdr/gainmapmath.h @@ -172,7 +172,7 @@ struct GainLUT { } float getGainFactor(float gain) { - uint32_t idx = static_cast<uint32_t>(gain * (kGainFactorNumEntries - 1)); + uint32_t idx = static_cast<uint32_t>(gain * (kGainFactorNumEntries - 1) + 0.5); //TODO() : Remove once conversion modules have appropriate clamping in place idx = CLIP3(idx, 0, kGainFactorNumEntries - 1); return mGainTable[idx]; |