Skip to content

Commit

Permalink
possible fix for #570: avoid writing NaNs into test images
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>
  • Loading branch information
peterhillman committed Nov 28, 2019
1 parent c02742f commit 01796b2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions OpenEXR/IlmImfTest/testLargeDataWindowOffsets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,19 @@ setupBuffer (const Header& hdr, // header to grab datawindow from
}

const char * write_ptr = writing ? &writingBuffer[0] : &readingBuffer[0];
// fill with random halfs, casting to floats for float channels
// fill with random halfs, casting to floats for float channels - don't write NaN values
size_t chan=0;
for (size_t i=0;i<samples;i++)
{
unsigned short int values = random_int(std::numeric_limits<unsigned short>::max());

half v;
v.setBits(values);
do
{
unsigned short int values = random_int(std::numeric_limits<unsigned short>::max());
v.setBits(values);
}
while ( v.isNan() );

if (pt==NULL || pt[chan]==IMF::HALF)
{
*(half*)write_ptr = half(v);
Expand Down

0 comments on commit 01796b2

Please sign in to comment.