From be698d70a91baf2edf5cedb78bbb8a9150be6ff1 Mon Sep 17 00:00:00 2001 From: Jan Herling Date: Fri, 27 Dec 2024 13:04:34 -0800 Subject: [PATCH] Fixed pfm loader for 3 channel images with big endian encoding Summary: In case a pfm image contained 3 float channels and was encoded with big endian, we only copied/reversed the first 1/3 pixels of the image. Now, we ensure that we copy/convert all pixels of the image. Differential Revision: D67655414 fbshipit-source-id: c1883a7fcb5dfa58df9d7898391b10a1d527a706 --- impl/ocean/media/special/ImagePfm.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/impl/ocean/media/special/ImagePfm.cpp b/impl/ocean/media/special/ImagePfm.cpp index f5db95691..ee9040393 100644 --- a/impl/ocean/media/special/ImagePfm.cpp +++ b/impl/ocean/media/special/ImagePfm.cpp @@ -54,7 +54,14 @@ Frame ImagePfm::decodeImage(const void* buffer, const size_t size) else { Frame frame(frameType); - CV::FrameChannels::reverseChannelOrder(remainingBuffer, (uint8_t*)(frame.data()), frame.width(), frame.height(), CV::FrameConverter::CONVERT_NORMAL, sourcePaddingElements, frame.paddingElements()); + ocean_assert(frame.paddingElements() == 0u); + + constexpr unsigned int targetPaddingElements = 0u; + + // we need to apply a conversion from big endian to little endian for each float value + const unsigned int rowPixels = frame.width() * frame.channels(); + + CV::FrameChannels::reverseChannelOrder(remainingBuffer, (uint8_t*)(frame.data()), rowPixels, frame.height(), CV::FrameConverter::CONVERT_NORMAL, sourcePaddingElements, targetPaddingElements); return frame; }