Skip to content

Commit

Permalink
Fixed pfm loader for 3 channel images with big endian encoding
Browse files Browse the repository at this point in the history
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
  • Loading branch information
janherling authored and facebook-github-bot committed Dec 27, 2024
1 parent 7731f8d commit be698d7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion impl/ocean/media/special/ImagePfm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,14 @@ Frame ImagePfm::decodeImage(const void* buffer, const size_t size)
else
{
Frame frame(frameType);
CV::FrameChannels::reverseChannelOrder<uint8_t, 4u>(remainingBuffer, (uint8_t*)(frame.data<void>()), 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<uint8_t, 4u>(remainingBuffer, (uint8_t*)(frame.data<void>()), rowPixels, frame.height(), CV::FrameConverter::CONVERT_NORMAL, sourcePaddingElements, targetPaddingElements);

return frame;
}
Expand Down

0 comments on commit be698d7

Please sign in to comment.