|
Packit |
0d464f |
//////////////////////////////////////////////////////////////////////////////
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucasfilm
|
|
Packit |
0d464f |
// Entertainment Company Ltd. Portions contributed and copyright held by
|
|
Packit |
0d464f |
// others as indicated. All rights reserved.
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
// Redistribution and use in source and binary forms, with or without
|
|
Packit |
0d464f |
// modification, are permitted provided that the following conditions are
|
|
Packit |
0d464f |
// met:
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
// * Redistributions of source code must retain the above
|
|
Packit |
0d464f |
// copyright notice, this list of conditions and the following
|
|
Packit |
0d464f |
// disclaimer.
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
// * Redistributions in binary form must reproduce the above
|
|
Packit |
0d464f |
// copyright notice, this list of conditions and the following
|
|
Packit |
0d464f |
// disclaimer in the documentation and/or other materials provided with
|
|
Packit |
0d464f |
// the distribution.
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
// * Neither the name of Industrial Light & Magic nor the names of
|
|
Packit |
0d464f |
// any other contributors to this software may be used to endorse or
|
|
Packit |
0d464f |
// promote products derived from this software without specific prior
|
|
Packit |
0d464f |
// written permission.
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
Packit |
0d464f |
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
Packit |
0d464f |
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
Packit |
0d464f |
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
Packit |
0d464f |
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
Packit |
0d464f |
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
Packit |
0d464f |
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
Packit |
0d464f |
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
Packit |
0d464f |
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
Packit |
0d464f |
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
Packit |
0d464f |
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
//////////////////////////////////////////////////////////////////////////////
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
#include "compareFloat.h"
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
using namespace OPENEXR_IMF_NAMESPACE;
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
bool
|
|
Packit |
0d464f |
equivalent (float f1, float f2, Compression comp)
|
|
Packit |
0d464f |
{
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
// Test if a float, f1, is "equivalent" to another float, f2,
|
|
Packit |
0d464f |
// which results from storing f1 in an image file, and reading
|
|
Packit |
0d464f |
// it back:
|
|
Packit |
0d464f |
// If the file was compressed with PXR24_COMPRESSION, then f1
|
|
Packit |
0d464f |
// and f2 must the same as f1 rounded to 24 bits (see class
|
|
Packit |
0d464f |
// ImfPxr24Compressor); otherwise f1 and f2 must be the same.
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
union
|
|
Packit |
0d464f |
{
|
|
Packit |
0d464f |
float f;
|
|
Packit |
0d464f |
unsigned int i;
|
|
Packit |
0d464f |
} u1, u2;
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
u1.f = f1;
|
|
Packit |
0d464f |
u2.f = f2;
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
if (comp == PXR24_COMPRESSION)
|
|
Packit |
0d464f |
return (u2.i >> 8) - (u1.i >> 8) < 2;
|
|
Packit |
0d464f |
else
|
|
Packit |
0d464f |
return u2.i == u1.i;
|
|
Packit |
0d464f |
}
|