From 7b0f5c89c0d3274c2370247541f62244e337be5d Mon Sep 17 00:00:00 2001 From: Aous Naman Date: Fri, 20 Sep 2024 22:06:08 +1000 Subject: [PATCH] Improvement for pfm_in, and a bug fix for handling signed pfm data. --- src/apps/others/ojph_img_io.cpp | 7 ++++--- src/core/transform/ojph_colour.cpp | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/apps/others/ojph_img_io.cpp b/src/apps/others/ojph_img_io.cpp index 7dcdd4b..d3211d7 100644 --- a/src/apps/others/ojph_img_io.cpp +++ b/src/apps/others/ojph_img_io.cpp @@ -660,7 +660,7 @@ namespace ojph { if (shift) for (ui32 i = width; i > 0; --i, sp += num_comps) { - ui32 v = *(ui32*)sp; + si32 v = *(si32*)sp; v >>= shift; *dp++ = *(float*)&v; } @@ -675,8 +675,9 @@ namespace ojph { if (shift) for (ui32 i = width; i > 0; --i, sp += num_comps) { ui32 v = be2le(*(ui32*)sp); - v >>= shift; - *dp++ = *(float*)&v; + si32 u = *(si32*)&v; + u >>= shift; + *dp++ = *(float*)&u; } else for (ui32 i = width; i > 0; --i, sp += num_comps) { diff --git a/src/core/transform/ojph_colour.cpp b/src/core/transform/ojph_colour.cpp index 34161d4..ca96d2d 100644 --- a/src/core/transform/ojph_colour.cpp +++ b/src/core/transform/ojph_colour.cpp @@ -214,7 +214,7 @@ namespace ojph { { for (ui32 i = width; i > 0; --i) { const si32 v = *sp++; - *dp++ = v > 0 ? v : (- v - shift); + *dp++ = v >= 0 ? v : (- v - shift); } }