From 88c57a25cf91b6a69848940a36d9303b929c8837 Mon Sep 17 00:00:00 2001 From: Ram Mohan Date: Mon, 24 Jul 2023 16:04:46 +0530 Subject: 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 --- libs/ultrahdr/gainmapmath.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'libs/ultrahdr/gainmapmath.cpp') 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(e_gamma * kSrgbInvOETFNumEntries); + uint32_t value = static_cast(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(e * kHlgOETFNumEntries); + uint32_t value = static_cast(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(e_gamma * kHlgInvOETFNumEntries); + uint32_t value = static_cast(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(e * kPqOETFNumEntries); + uint32_t value = static_cast(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(e_gamma * kPqInvOETFNumEntries); + uint32_t value = static_cast(e_gamma * (kPqInvOETFNumEntries - 1) + 0.5); //TODO() : Remove once conversion modules have appropriate clamping in place value = CLIP3(value, 0, kPqInvOETFNumEntries - 1); -- cgit v1.2.3-59-g8ed1b