Unverified Commit 878af7ad authored by Alexander Alekhin's avatar Alexander Alekhin Committed by GitHub

Merge pull request #14725 from alalek:update_openexr_2.3.0

3rdparty: update OpenEXR 2.3.0 (#14725)

* openexr 2.2.1

* openexr 2.3.0

* openexr: build fixes

* openexr: build dwa tables on-demand
parent d2f9cfcf
......@@ -8,6 +8,10 @@ Paul Schneider <paultschneider@mac.com>
Bill Anderson <wja@ilm.com>
Wojciech Jarosz <wjarosz@ucsd.edu>
Andrew Kunz <akunz@ilm.com>
Piotr Stanczyk <pstanczyk@ilm.com>
Peter Hillman <peterh@weta.co.nz>
Nick Porcino <nick.porcino@gmail.com>
Kimball Thurston
Contributors:
-------------
......@@ -20,6 +24,10 @@ Rodrigo Damazio <rdamazio@lsi.usp.br>
Greg Ward <gward@lmi.net>
Joseph Goldstone <joseph@lp.com>
Loren Carpenter, Pixar Animation Studios
Nicholas Yue <yue.nicholas@gmail.com>
Yunfeng Bai (ILM)
Pascal Jette (Autodesk)
Karl Rasche, DreamWorks Animation <Karl.Rasche@dreamworks.com>
Win32 build system:
-------------------
......
......@@ -5,15 +5,75 @@
project(openexr CXX)
if(UNIX)
if(APPLE)
set(HAVE_POSIX_SEMAPHORES 0) # Unnamed semaphores are not supported: https://github.com/opencv/opencv/issues/9361
if(NOT HAVE_CXX11)
ocv_check_compiler_flag(CXX "-std=c++11" HAVE_STD_CXX11 "${OpenCV_SOURCE_DIR}/cmake/checks/cxx11.cpp")
if(HAVE_STD_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
else()
include(CheckIncludeFile)
check_include_file(semaphore.h HAVE_POSIX_SEMAPHORES)
if(BUILD_OPENEXR)
message(WARNING "OpenCV: builtin OpenEXR requires C++11 support. OpenEXR is disabled.")
endif()
return()
endif()
endif()
set(ILMBASE_VERSION_MAJOR "2")
set(ILMBASE_VERSION_MINOR "3")
set(ILMBASE_VERSION_PATCH "0")
set(ILMBASE_VERSION "${ILMBASE_VERSION_MAJOR}.${ILMBASE_VERSION_MINOR}.${ILMBASE_VERSION_PATCH}")
set(ILMBASE_VERSION_API ${ILMBASE_VERSION_MAJOR}_${ILMBASE_VERSION_MINOR})
set(OPENEXR_VERSION_MAJOR "2")
set(OPENEXR_VERSION_MINOR "3")
set(OPENEXR_VERSION_PATCH "0")
set(OPENEXR_VERSION "${OPENEXR_VERSION_MAJOR}.${OPENEXR_VERSION_MINOR}.${OPENEXR_VERSION_PATCH}")
set(OPENEXR_VERSION_API ${OPENEXR_VERSION_MAJOR}_${OPENEXR_VERSION_MINOR})
set(OPENEXR_VERSION "${OPENEXR_VERSION}" PARENT_SCOPE)
if(WIN32)
set(HAVE_COMPLETE_IOMANIP 1)
set(OPENEXR_IMF_HAVE_COMPLETE_IOMANIP 1)
set(PLATFORM_WINDOWS 1)
elseif(APPLE)
set(HAVE_POSIX_SEMAPHORES 0) # Unnamed semaphores are not supported: https://github.com/opencv/opencv/issues/9361
if(DARWIN)
set(OPENEXR_IMF_HAVE_DARWIN 1)
endif()
elseif(UNIX)
include(CheckIncludeFile)
check_include_file(semaphore.h HAVE_POSIX_SEMAPHORES)
endif()
set(ILMBASE_VERSION_API "opencv")
set(ILMBASE_INTERNAL_NAMESPACE_CUSTOM 1)
set(IMATH_INTERNAL_NAMESPACE "Imath_${ILMBASE_VERSION_API}")
set(IEX_INTERNAL_NAMESPACE "Iex_${ILMBASE_VERSION_API}")
set(ILMTHREAD_INTERNAL_NAMESPACE "IlmThread_${ILMBASE_VERSION_API}")
set(ILMBASE_NAMESPACE_CUSTOM 0)
set(IMATH_NAMESPACE "Imath")
set(IEX_NAMESPACE "Iex")
set(ILMTHREAD_NAMESPACE "IlmThread")
set(ILMBASE_VERSION_STRING "\"${ILMBASE_VERSION}\"" )
set(ILMBASE_PACKAGE_STRING "\"IlmBase ${ILMBASE_VERSION}\"" )
set(OPENEXR_VERSION_API "opencv")
set(OPENEXR_IMF_INTERNAL_NAMESPACE_CUSTOM 1)
set(OPENEXR_IMF_INTERNAL_NAMESPACE "Imf_${ILMBASE_VERSION_API}")
set(OPENEXR_IMF_NAMESPACE_CUSTOM 0)
set(OPENEXR_IMF_NAMESPACE "Imf")
set(OPENEXR_VERSION_STRING "\"${OPENEXR_VERSION}\"" )
set(OPENEXR_PACKAGE_STRING "\"OpenEXR ${OPENEXR_VERSION}\"" )
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/IlmBaseConfig.h.cmakein"
"${CMAKE_CURRENT_BINARY_DIR}/IlmBaseConfig.h" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/OpenEXRConfig.h.cmakein"
......@@ -23,7 +83,8 @@ set(OPENEXR_INCLUDE_PATHS "${CMAKE_CURRENT_SOURCE_DIR}/Half"
"${CMAKE_CURRENT_SOURCE_DIR}/Iex"
"${CMAKE_CURRENT_SOURCE_DIR}/IlmThread"
"${CMAKE_CURRENT_SOURCE_DIR}/Imath"
"${CMAKE_CURRENT_SOURCE_DIR}/IlmImf")
"${CMAKE_CURRENT_SOURCE_DIR}/IlmImf"
"${CMAKE_CURRENT_BINARY_DIR}")
ocv_include_directories("${CMAKE_CURRENT_BINARY_DIR}" ${ZLIB_INCLUDE_DIRS} ${OPENEXR_INCLUDE_PATHS})
......@@ -31,8 +92,6 @@ file(GLOB lib_srcs Half/half.cpp Iex/*.cpp IlmThread/*.cpp Imath/*.cpp IlmImf/*.
file(GLOB lib_hdrs Half/*.h Iex/Iex*.h IlmThread/IlmThread*.h Imath/Imath*.h IlmImf/*.h)
list(APPEND lib_hdrs "${CMAKE_CURRENT_BINARY_DIR}/IlmBaseConfig.h" "${CMAKE_CURRENT_BINARY_DIR}/OpenEXRConfig.h")
ocv_list_filterout(lib_srcs IlmImf/b44ExpLogTable.cpp)
if(WIN32)
ocv_list_filterout(lib_srcs Posix.*cpp)
else()
......@@ -46,6 +105,10 @@ ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow -Wunused -Wsign-compare -Wundef -W
-Wdeprecated-declarations -Wmisleading-indentation -Wdeprecated
-Wsuggest-override -Winconsistent-missing-override
-Wimplicit-fallthrough
-Wtautological-compare # clang
-Wmissing-prototypes # gcc/clang
-Wreorder
-Wunused-result
)
if(CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0)
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wclass-memaccess)
......@@ -82,7 +145,6 @@ if(NOT BUILD_SHARED_LIBS)
ocv_install_target(IlmImf EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
endif()
ocv_install_3rdparty_licenses(openexr LICENSE AUTHORS.ilmbase AUTHORS.openexr fix_msvc2013_errors.patch)
ocv_install_3rdparty_licenses(openexr LICENSE AUTHORS.ilmbase AUTHORS.openexr)
set(OPENEXR_INCLUDE_PATHS ${OPENEXR_INCLUDE_PATHS} PARENT_SCOPE)
set(OPENEXR_VERSION "1.7.1" PARENT_SCOPE)
Version 2.x.x
* Bumped version to track OpenEXR
(Piotr Stanczyk)
Version 2.0.1
* Bumped version to track OpenEXR
(Piotr Stanczyk)
Version 2.0.0
* Bumped version to track OpenEXR
(Piotr Stanczyk)
* Numerous minor fixes, missing includes etc
Version 1.1.0.beta.1
* Added new module PyIlmBase : python bindings for IlmBase
(Nick Rasmussen)
* Added git specific files
(Piotr Stanczyk)
* Minor fixes for newer gcc versions and OS X.
(misc)
* Preparation for OpenEXR v2 release { remove message for final release }
(Piotr Stanczyk)
* Updated the so verison to 10
(Piotr Stanczyk)
* Initial use of the CMake build system
(Nicholas Yue)
Version 1.0.3
* Added support for enabling/disabling large stack optimisations, used in
halfFunction.h.
......
Version 2.0.1
* Temporarily turning off optimisation code path
(Piotr Stanczyk)
* Added additional tests for future optimisation refactoring
(Piotr Stanczyk / Peter Hillman)
* Fixes for StringVectors
(Peter Hillman)
* Additional checks for type mismatches
(Peter Hillman)
* Fix for Composite Deep Scanline
(Brendan Bolles)
Version 2.0.0
* Updated Documentation
(Peter Hillman)
* Updated Namespacing mechanism
(Piotr Stanczyk)
* Fixes for succd & predd
(Peter Hillman)
* Fixes for FPE control registers
(Piotr Stanczyk)
* Additional checks and tests on DeepImages, scanlines and tiles
(Peter Hillman)
* Folded in Autodesk read optimisations for RGB(A) files
(Pascal Jette, Peter Hillman)
* Updated the bootstrap scripts to use libtoolize if glibtoolize isn't available on darwin.
(Nick Rasmussen)
* Numerous minor fixes, missing includes etc
Version 2.0.0.beta.1:
* Please read the separate file for v2 additions and changes.
* Added git specific files
(Piotr Stanczyk)
* Updated the so verison to 20
(Piotr Stanczyk)
* Initial use of the CMake build system
(Nicholas Yue)
Version 1.7.1:
* Updated the .so verison to 7.
* Updated the .so verison to 7.
(Piotr Stanczyk)
Version 1.7.0:
......
......@@ -4,68 +4,68 @@
//
{
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 1024, 2048, 3072, 4096, 5120, 6144, 7168,
8192, 9216, 10240, 11264, 12288, 13312, 14336, 15360,
16384, 17408, 18432, 19456, 20480, 21504, 22528, 23552,
24576, 25600, 26624, 27648, 28672, 29696, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 33792, 34816, 35840, 36864, 37888, 38912, 39936,
40960, 41984, 43008, 44032, 45056, 46080, 47104, 48128,
49152, 50176, 51200, 52224, 53248, 54272, 55296, 56320,
57344, 58368, 59392, 60416, 61440, 62464, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 1024, 2048, 3072, 4096, 5120, 6144, 7168,
8192, 9216, 10240, 11264, 12288, 13312, 14336, 15360,
16384, 17408, 18432, 19456, 20480, 21504, 22528, 23552,
24576, 25600, 26624, 27648, 28672, 29696, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 33792, 34816, 35840, 36864, 37888, 38912, 39936,
40960, 41984, 43008, 44032, 45056, 46080, 47104, 48128,
49152, 50176, 51200, 52224, 53248, 54272, 55296, 56320,
57344, 58368, 59392, 60416, 61440, 62464, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
......@@ -2,9 +2,9 @@
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
//
// All rights reserved.
//
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
......@@ -16,8 +16,8 @@
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
......@@ -53,11 +53,10 @@ using namespace std;
// Lookup tables for half-to-float and float-to-half conversion
//-------------------------------------------------------------
HALF_EXPORT_CONST half::uif half::_toFloat[1 << 16] =
#include "toFloat.h"
HALF_EXPORT_CONST unsigned short half::_eLut[1 << 9] =
#include "eLut.h"
HALF_EXPORT const half::uif half::_toFloat[1 << 16] =
#include "toFloat.h"
HALF_EXPORT const unsigned short half::_eLut[1 << 9] =
#include "eLut.h"
//-----------------------------------------------
// Overflow handler for float-to-half conversion;
......@@ -65,14 +64,14 @@ HALF_EXPORT_CONST unsigned short half::_eLut[1 << 9] =
// which may be trapped by the operating system.
//-----------------------------------------------
float
HALF_EXPORT float
half::overflow ()
{
volatile float f = 1e10;
for (int i = 0; i < 10; i++)
f *= f; // this will overflow before
// the for­loop terminates
for (int i = 0; i < 10; i++)
f *= f; // this will overflow before
// the for­loop terminates
return f;
}
......@@ -82,7 +81,7 @@ half::overflow ()
// zeroes, denormalized numbers and exponent overflows.
//-----------------------------------------------------
short
HALF_EXPORT short
half::convert (int i)
{
//
......@@ -95,9 +94,9 @@ half::convert (int i)
// of float and half (127 versus 15).
//
register int s = (i >> 16) & 0x00008000;
register int e = ((i >> 23) & 0x000000ff) - (127 - 15);
register int m = i & 0x007fffff;
int s = (i >> 16) & 0x00008000;
int e = ((i >> 23) & 0x000000ff) - (127 - 15);
int m = i & 0x007fffff;
//
// Now reassemble s, e and m into a half:
......@@ -105,115 +104,115 @@ half::convert (int i)
if (e <= 0)
{
if (e < -10)
{
//
// E is less than -10. The absolute value of f is
// less than HALF_MIN (f may be a small normalized
// float, a denormalized float or a zero).
//
// We convert f to a half zero with the same sign as f.
//
return s;
}
//
// E is between -10 and 0. F is a normalized float
// whose magnitude is less than HALF_NRM_MIN.
//
// We convert f to a denormalized half.
//
//
// Add an explicit leading 1 to the significand.
//
m = m | 0x00800000;
//
// Round to m to the nearest (10+e)-bit value (with e between
// -10 and 0); in case of a tie, round to the nearest even value.
//
// Rounding may cause the significand to overflow and make
// our number normalized. Because of the way a half's bits
// are laid out, we don't have to treat this case separately;
// the code below will handle it correctly.
//
int t = 14 - e;
int a = (1 << (t - 1)) - 1;
int b = (m >> t) & 1;
m = (m + a + b) >> t;
//
// Assemble the half from s, e (zero) and m.
//
return s | m;
if (e < -10)
{
//
// E is less than -10. The absolute value of f is
// less than HALF_MIN (f may be a small normalized
// float, a denormalized float or a zero).
//
// We convert f to a half zero with the same sign as f.
//
return s;
}
//
// E is between -10 and 0. F is a normalized float
// whose magnitude is less than HALF_NRM_MIN.
//
// We convert f to a denormalized half.
//
//
// Add an explicit leading 1 to the significand.
//
m = m | 0x00800000;
//
// Round to m to the nearest (10+e)-bit value (with e between
// -10 and 0); in case of a tie, round to the nearest even value.
//
// Rounding may cause the significand to overflow and make
// our number normalized. Because of the way a half's bits
// are laid out, we don't have to treat this case separately;
// the code below will handle it correctly.
//
int t = 14 - e;
int a = (1 << (t - 1)) - 1;
int b = (m >> t) & 1;
m = (m + a + b) >> t;
//
// Assemble the half from s, e (zero) and m.
//
return s | m;
}
else if (e == 0xff - (127 - 15))
{
if (m == 0)
{
//
// F is an infinity; convert f to a half
// infinity with the same sign as f.
//
return s | 0x7c00;
}
else
{
//
// F is a NAN; we produce a half NAN that preserves
// the sign bit and the 10 leftmost bits of the
// significand of f, with one exception: If the 10
// leftmost bits are all zero, the NAN would turn
// into an infinity, so we have to set at least one
// bit in the significand.
//
m >>= 13;
return s | 0x7c00 | m | (m == 0);
}
if (m == 0)
{
//
// F is an infinity; convert f to a half
// infinity with the same sign as f.
//
return s | 0x7c00;
}
else
{
//
// F is a NAN; we produce a half NAN that preserves
// the sign bit and the 10 leftmost bits of the
// significand of f, with one exception: If the 10
// leftmost bits are all zero, the NAN would turn
// into an infinity, so we have to set at least one
// bit in the significand.
//
m >>= 13;
return s | 0x7c00 | m | (m == 0);
}
}
else
{
//
// E is greater than zero. F is a normalized float.
// We try to convert f to a normalized half.
//
//
// Round to m to the nearest 10-bit value. In case of
// a tie, round to the nearest even value.
//
m = m + 0x00000fff + ((m >> 13) & 1);
if (m & 0x00800000)
{
m = 0; // overflow in significand,
e += 1; // adjust exponent
}
//
// Handle exponent overflow
//
if (e > 30)
{
overflow (); // Cause a hardware floating point overflow;
return s | 0x7c00; // if this returns, the half becomes an
} // infinity with the same sign as f.
//
// Assemble the half from s, e and m.
//
return s | (e << 10) | (m >> 13);
//
// E is greater than zero. F is a normalized float.
// We try to convert f to a normalized half.
//
//
// Round to m to the nearest 10-bit value. In case of
// a tie, round to the nearest even value.
//
m = m + 0x00000fff + ((m >> 13) & 1);
if (m & 0x00800000)
{
m = 0; // overflow in significand,
e += 1; // adjust exponent
}
//
// Handle exponent overflow
//
if (e > 30)
{
overflow (); // Cause a hardware floating point overflow;
return s | 0x7c00; // if this returns, the half becomes an
} // infinity with the same sign as f.
//
// Assemble the half from s, e and m.
//
return s | (e << 10) | (m >> 13);
}
}
......@@ -222,7 +221,7 @@ half::convert (int i)
// Stream I/O operators
//---------------------
ostream &
HALF_EXPORT ostream &
operator << (ostream &os, half h)
{
os << float (h);
......@@ -230,7 +229,7 @@ operator << (ostream &os, half h)
}
istream &
HALF_EXPORT istream &
operator >> (istream &is, half &h)
{
float f;
......@@ -245,22 +244,22 @@ operator >> (istream &is, half &h)
// floats and halfs, mostly for debugging
//---------------------------------------
void
HALF_EXPORT void
printBits (ostream &os, half h)
{
unsigned short b = h.bits();
for (int i = 15; i >= 0; i--)
{
os << (((b >> i) & 1)? '1': '0');
os << (((b >> i) & 1)? '1': '0');
if (i == 15 || i == 10)
os << ' ';
if (i == 15 || i == 10)
os << ' ';
}
}
void
HALF_EXPORT void
printBits (ostream &os, float f)
{
half::uif x;
......@@ -268,32 +267,32 @@ printBits (ostream &os, float f)
for (int i = 31; i >= 0; i--)
{
os << (((x.i >> i) & 1)? '1': '0');
os << (((x.i >> i) & 1)? '1': '0');
if (i == 31 || i == 23)
os << ' ';
if (i == 31 || i == 23)
os << ' ';
}
}
void
HALF_EXPORT void
printBits (char c[19], half h)
{
unsigned short b = h.bits();
for (int i = 15, j = 0; i >= 0; i--, j++)
{
c[j] = (((b >> i) & 1)? '1': '0');
c[j] = (((b >> i) & 1)? '1': '0');
if (i == 15 || i == 10)
c[++j] = ' ';
if (i == 15 || i == 10)
c[++j] = ' ';
}
c[18] = 0;
}
void
HALF_EXPORT void
printBits (char c[35], float f)
{
half::uif x;
......@@ -301,10 +300,10 @@ printBits (char c[35], float f)
for (int i = 31, j = 0; i >= 0; i--, j++)
{
c[j] = (((x.i >> i) & 1)? '1': '0');
c[j] = (((x.i >> i) & 1)? '1': '0');
if (i == 31 || i == 23)
c[++j] = ' ';
if (i == 31 || i == 23)
c[++j] = ' ';
}
c[34] = 0;
......
......@@ -2,9 +2,9 @@
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
//
// All rights reserved.
//
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
......@@ -16,8 +16,8 @@
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
......@@ -85,21 +85,10 @@
#ifndef _HALF_H_
#define _HALF_H_
#include "halfExport.h" // for definition of HALF_EXPORT
#include <iostream>
#if defined(OPENEXR_DLL)
#if defined(HALF_EXPORTS)
#define HALF_EXPORT __declspec(dllexport)
#else
#define HALF_EXPORT __declspec(dllimport)
#endif
#define HALF_EXPORT_CONST
#else
#define HALF_EXPORT
#define HALF_EXPORT_CONST const
#endif
class HALF_EXPORT half
class half
{
public:
......@@ -208,45 +197,47 @@ class HALF_EXPORT half
// Access to the internal representation
//--------------------------------------
unsigned short bits () const;
void setBits (unsigned short bits);
HALF_EXPORT unsigned short bits () const;
HALF_EXPORT void setBits (unsigned short bits);
public:
union uif
{
unsigned int i;
float f;
unsigned int i;
float f;
};
private:
static short convert (int i);
static float overflow ();
HALF_EXPORT static short convert (int i);
HALF_EXPORT static float overflow ();
unsigned short _h;
unsigned short _h;
static HALF_EXPORT_CONST uif _toFloat[1 << 16];
static HALF_EXPORT_CONST unsigned short _eLut[1 << 9];
HALF_EXPORT static const uif _toFloat[1 << 16];
HALF_EXPORT static const unsigned short _eLut[1 << 9];
};
//-----------
// Stream I/O
//-----------
HALF_EXPORT std::ostream & operator << (std::ostream &os, half h);
HALF_EXPORT std::istream & operator >> (std::istream &is, half &h);
HALF_EXPORT std::ostream & operator << (std::ostream &os, half h);
HALF_EXPORT std::istream & operator >> (std::istream &is, half &h);
//----------
// Debugging
//----------
HALF_EXPORT void printBits (std::ostream &os, half h);
HALF_EXPORT void printBits (std::ostream &os, float f);
HALF_EXPORT void printBits (char c[19], half h);
HALF_EXPORT void printBits (char c[35], float f);
HALF_EXPORT void printBits (std::ostream &os, half h);
HALF_EXPORT void printBits (std::ostream &os, float f);
HALF_EXPORT void printBits (char c[19], half h);
HALF_EXPORT void printBits (char c[35], float f);
//-------------------------------------------------------------------------
......@@ -266,7 +257,7 @@ HALF_EXPORT void printBits (char c[35], float f);
#define HALF_MAX 65504.0f // Largest positive half
#define HALF_EPSILON 0.00097656f // Smallest positive e for which
// half (1.0 + e) != half (1.0)
// half (1.0 + e) != half (1.0)
#else
#define HALF_MIN 5.96046448e-08 // Smallest positive half
......@@ -276,35 +267,39 @@ HALF_EXPORT void printBits (char c[35], float f);
#define HALF_MAX 65504.0 // Largest positive half
#define HALF_EPSILON 0.00097656 // Smallest positive e for which
// half (1.0 + e) != half (1.0)
// half (1.0 + e) != half (1.0)
#endif
#define HALF_MANT_DIG 11 // Number of digits in mantissa
// (significand + hidden leading 1)
// (significand + hidden leading 1)
#define HALF_DIG 2 // Number of base 10 digits that
// can be represented without change
// can be represented without change
#define HALF_DECIMAL_DIG 5 // Number of base-10 digits that are
// necessary to uniquely represent all
// distinct values
#define HALF_RADIX 2 // Base of the exponent
#define HALF_MIN_EXP -13 // Minimum negative integer such that
// HALF_RADIX raised to the power of
// one less than that integer is a
// normalized half
// HALF_RADIX raised to the power of
// one less than that integer is a
// normalized half
#define HALF_MAX_EXP 16 // Maximum positive integer such that
// HALF_RADIX raised to the power of
// one less than that integer is a
// normalized half
// HALF_RADIX raised to the power of
// one less than that integer is a
// normalized half
#define HALF_MIN_10_EXP -4 // Minimum positive integer such
// that 10 raised to that power is
// a normalized half
// that 10 raised to that power is
// a normalized half
#define HALF_MAX_10_EXP 4 // Maximum positive integer such
// that 10 raised to that power is
// a normalized half
// that 10 raised to that power is
// a normalized half
//---------------------------------------------------------------------------
......@@ -317,9 +312,9 @@ HALF_EXPORT void printBits (char c[35], float f);
// floating point number, whose bits are arranged as follows:
//
// 31 (msb)
// |
// |
// | 30 23
// | | |
// | | |
// | | | 22 0 (lsb)
// | | | | |
// X XXXXXXXX XXXXXXXXXXXXXXXXXXXXXXX
......@@ -363,7 +358,7 @@ HALF_EXPORT void printBits (char c[35], float f);
// Here is the bit-layout for a half number, h:
//
// 15 (msb)
// |
// |
// | 14 10
// | | |
// | | | 9 0 (lsb)
......@@ -443,53 +438,53 @@ half::half (float f)
if (f == 0)
{
//
// Common special case - zero.
// Preserve the zero's sign bit.
//
//
// Common special case - zero.
// Preserve the zero's sign bit.
//
_h = (x.i >> 16);
_h = (x.i >> 16);
}
else
{
//
// We extract the combined sign and exponent, e, from our
// floating-point number, f. Then we convert e to the sign
// and exponent of the half number via a table lookup.
//
// For the most common case, where a normalized half is produced,
// the table lookup returns a non-zero value; in this case, all
// we have to do is round f's significand to 10 bits and combine
// the result with e.
//
// For all other cases (overflow, zeroes, denormalized numbers
// resulting from underflow, infinities and NANs), the table
// lookup returns zero, and we call a longer, non-inline function
// to do the float-to-half conversion.
//
register int e = (x.i >> 23) & 0x000001ff;
e = _eLut[e];
if (e)
{
//
// Simple case - round the significand, m, to 10
// bits and combine it with the sign and exponent.
//
register int m = x.i & 0x007fffff;
_h = e + ((m + 0x00000fff + ((m >> 13) & 1)) >> 13);
}
else
{
//
// Difficult case - call a function.
//
_h = convert (x.i);
}
//
// We extract the combined sign and exponent, e, from our
// floating-point number, f. Then we convert e to the sign
// and exponent of the half number via a table lookup.
//
// For the most common case, where a normalized half is produced,
// the table lookup returns a non-zero value; in this case, all
// we have to do is round f's significand to 10 bits and combine
// the result with e.
//
// For all other cases (overflow, zeroes, denormalized numbers
// resulting from underflow, infinities and NANs), the table
// lookup returns zero, and we call a longer, non-inline function
// to do the float-to-half conversion.
//
int e = (x.i >> 23) & 0x000001ff;
e = _eLut[e];
if (e)
{
//
// Simple case - round the significand, m, to 10
// bits and combine it with the sign and exponent.
//
int m = x.i & 0x007fffff;
_h = (unsigned short)(e + ((m + 0x00000fff + ((m >> 13) & 1)) >> 13));
}
else
{
//
// Difficult case - call a function.
//
_h = convert (x.i);
}
}
}
......@@ -517,7 +512,7 @@ half::round (unsigned int n) const
//
if (n >= 10)
return *this;
return *this;
//
// Disassemble h into the sign, s,
......@@ -544,13 +539,13 @@ half::round (unsigned int n) const
if (e >= 0x7c00)
{
//
// Overflow occurred -- truncate instead of rounding.
//
//
// Overflow occurred -- truncate instead of rounding.
//
e = _h;
e >>= 10 - n;
e <<= 10 - n;
e = _h;
e >>= 10 - n;
e <<= 10 - n;
}
//
......@@ -568,7 +563,7 @@ half::round (unsigned int n) const
// Other inline functions
//-----------------------
inline half
inline half
half::operator - () const
{
half h;
......@@ -657,7 +652,7 @@ half::operator /= (float f)
}
inline bool
inline bool
half::isFinite () const
{
unsigned short e = (_h >> 10) & 0x001f;
......@@ -707,7 +702,7 @@ half::isInfinity () const
}
inline bool
inline bool
half::isNegative () const
{
return (_h & 0x8000) != 0;
......
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Copyright (c) 2008, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
......@@ -32,23 +32,20 @@
//
///////////////////////////////////////////////////////////////////////////
#ifndef HALFEXPORT_H
#define HALFEXPORT_H
#if defined(OPENEXR_DLL)
#if defined(HALF_EXPORTS)
#define HALF_EXPORT __declspec(dllexport)
#else
#define HALF_EXPORT __declspec(dllimport)
#endif
#define HALF_EXPORT_CONST
#else
#define HALF_EXPORT
#define HALF_EXPORT_CONST const
#endif
#ifndef INCLUDED_IMATHGLU_H
#define INCLUDED_IMATHGLU_H
#include <GL/gl.h>
#include <GL/glu.h>
#include "ImathVec.h"
inline
void
gluLookAt(const Imath::V3f &pos, const Imath::V3f &interest, const Imath::V3f &up)
{
gluLookAt(pos.x, pos.y, pos.z,
interest.x, interest.y, interest.z,
up.x, up.y, up.z);
}
#endif // #ifndef HALFEXPORT_H
#endif
......@@ -2,9 +2,9 @@
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
//
// All rights reserved.
//
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
......@@ -16,8 +16,8 @@
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
......@@ -85,10 +85,10 @@
#include "half.h"
#include <IlmBaseConfig.h>
#ifndef ILMBASE_HAVE_LARGE_STACK
#include "IlmBaseConfig.h"
#ifndef ILMBASE_HAVE_LARGE_STACK
#include <string.h> // need this for memset
#else
#else
#endif
#include <float.h>
......@@ -105,17 +105,17 @@ class halfFunction
template <class Function>
halfFunction (Function f,
half domainMin = -HALF_MAX,
half domainMax = HALF_MAX,
T defaultValue = 0,
T posInfValue = 0,
T negInfValue = 0,
T nanValue = 0);
half domainMin = -HALF_MAX,
half domainMax = HALF_MAX,
T defaultValue = 0,
T posInfValue = 0,
T negInfValue = 0,
T nanValue = 0);
#ifndef ILMBASE_HAVE_LARGE_STACK
~halfFunction () { delete [] _lut; }
~halfFunction () { delete [] _lut; }
#endif
//-----------
// Evaluation
//-----------
......@@ -123,6 +123,7 @@ class halfFunction
T operator () (half x) const;
private:
#ifdef ILMBASE_HAVE_LARGE_STACK
T _lut[1 << 16];
#else
......@@ -138,31 +139,31 @@ class halfFunction
template <class T>
template <class Function>
halfFunction<T>::halfFunction (Function f,
half domainMin,
half domainMax,
T defaultValue,
T posInfValue,
T negInfValue,
T nanValue)
half domainMin,
half domainMax,
T defaultValue,
T posInfValue,
T negInfValue,
T nanValue)
{
#ifndef ILMBASE_HAVE_LARGE_STACK
_lut = new T[1<<16];
memset (_lut, 0 , (1<<16) * sizeof(T));
#endif
for (int i = 0; i < (1 << 16); i++)
{
half x;
x.setBits (i);
if (x.isNan())
_lut[i] = nanValue;
else if (x.isInfinity())
_lut[i] = x.isNegative()? negInfValue: posInfValue;
else if (x < domainMin || x > domainMax)
_lut[i] = defaultValue;
else
_lut[i] = f (x);
half x;
x.setBits (i);
if (x.isNan())
_lut[i] = nanValue;
else if (x.isInfinity())
_lut[i] = x.isNegative()? negInfValue: posInfValue;
else if (x < domainMin || x > domainMax)
_lut[i] = defaultValue;
else
_lut[i] = f (x);
}
}
......
......@@ -2,9 +2,9 @@
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
//
// All rights reserved.
//
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
......@@ -16,8 +16,8 @@
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
......@@ -94,6 +94,15 @@ class numeric_limits <half>
static const bool traps = true;
static const bool tinyness_before = false;
static const float_round_style round_style = round_to_nearest;
#if __cplusplus >= 201103L
// C++11 additions.
static constexpr int max_digits10 = HALF_DECIMAL_DIG;
static half lowest () {return -HALF_MAX;}
#endif
};
......
......@@ -2,9 +2,9 @@
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
//
// All rights reserved.
//
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
......@@ -16,8 +16,8 @@
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
......
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Copyright (c) 2002-2012, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
//
// All rights reserved.
//
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
......@@ -16,8 +16,8 @@
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
......@@ -40,19 +40,27 @@
//
//---------------------------------------------------------------------
#include "IexExport.h"
#include "IexBaseExc.h"
#include "IexMacros.h"
namespace Iex {
namespace {
#ifdef PLATFORM_WINDOWS
#include <windows.h>
#endif
#include <stdlib.h>
IEX_INTERNAL_NAMESPACE_SOURCE_ENTER
StackTracer currentStackTracer = 0;
namespace {
StackTracer currentStackTracer = 0;
} // namespace
void
void
setStackTracer (StackTracer stackTracer)
{
currentStackTracer = stackTracer;
......@@ -67,7 +75,7 @@ stackTracer ()
BaseExc::BaseExc (const char* s) throw () :
std::string (s? s: ""),
_message (s? s: ""),
_stackTrace (currentStackTracer? currentStackTracer(): "")
{
// empty
......@@ -75,7 +83,7 @@ BaseExc::BaseExc (const char* s) throw () :
BaseExc::BaseExc (const std::string &s) throw () :
std::string (s),
_message (s),
_stackTrace (currentStackTracer? currentStackTracer(): "")
{
// empty
......@@ -83,7 +91,7 @@ BaseExc::BaseExc (const std::string &s) throw () :
BaseExc::BaseExc (std::stringstream &s) throw () :
std::string (s.str()),
_message (s.str()),
_stackTrace (currentStackTracer? currentStackTracer(): "")
{
// empty
......@@ -91,7 +99,7 @@ BaseExc::BaseExc (std::stringstream &s) throw () :
BaseExc::BaseExc (const BaseExc &be) throw () :
std::string (be),
_message (be._message),
_stackTrace (be._stackTrace)
{
// empty
......@@ -107,23 +115,99 @@ BaseExc::~BaseExc () throw ()
const char *
BaseExc::what () const throw ()
{
return c_str();
return _message.c_str();
}
BaseExc &
BaseExc::assign (std::stringstream &s)
{
std::string::assign (s.str());
_message.assign (s.str());
return *this;
}
BaseExc &
BaseExc::append (std::stringstream &s)
{
std::string::append (s.str());
_message.append (s.str());
return *this;
}
const std::string &
BaseExc::message() const
{
return _message;
}
} // namespace Iex
BaseExc &
BaseExc::operator = (std::stringstream &s)
{
return assign (s);
}
BaseExc &
BaseExc::operator += (std::stringstream &s)
{
return append (s);
}
BaseExc &
BaseExc::assign (const char *s)
{
_message.assign(s);
return *this;
}
BaseExc &
BaseExc::operator = (const char *s)
{
return assign(s);
}
BaseExc &
BaseExc::append (const char *s)
{
_message.append(s);
return *this;
}
BaseExc &
BaseExc::operator += (const char *s)
{
return append(s);
}
const std::string &
BaseExc::stackTrace () const
{
return _stackTrace;
}
IEX_INTERNAL_NAMESPACE_SOURCE_EXIT
#ifdef PLATFORM_WINDOWS
#pragma optimize("", off)
void
iex_debugTrap()
{
if (0 != getenv("IEXDEBUGTHROW"))
::DebugBreak();
}
#else
void
iex_debugTrap()
{
// how to in Linux?
if (0 != ::getenv("IEXDEBUGTHROW"))
__builtin_trap();
}
#endif
This diff is collapsed.
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Copyright (c) 2002-2012, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
//
// All rights reserved.
//
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
......@@ -16,8 +16,8 @@
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
......@@ -45,8 +45,7 @@
#include "IexBaseExc.h"
namespace Iex {
IEX_INTERNAL_NAMESPACE_HEADER_ENTER
DEFINE_EXC (EpermExc, ErrnoExc)
DEFINE_EXC (EnoentExc, ErrnoExc)
......@@ -204,7 +203,6 @@ DEFINE_EXC (EcantextentExc, ErrnoExc)
DEFINE_EXC (EinvaltimeExc, ErrnoExc)
DEFINE_EXC (EdestroyedExc, ErrnoExc)
} // namespace Iex
IEX_INTERNAL_NAMESPACE_HEADER_EXIT
#endif
#ifndef IEXEXPORT_H
#define IEXEXPORT_H
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2012, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
#if defined(OPENEXR_DLL)
#if defined(IEX_EXPORTS)
#define IEX_EXPORT __declspec(dllexport)
#else
#define IEX_EXPORT __declspec(dllimport)
#endif
#define IEX_EXPORT_CONST
#else
#define IEX_EXPORT
#define IEX_EXPORT_CONST const
#endif
#endif // #ifndef IEXEXPORT_H
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2012, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_IEXFORWARD_H
#define INCLUDED_IEXFORWARD_H
#include "IexNamespace.h"
IEX_INTERNAL_NAMESPACE_HEADER_ENTER
//
// Base exceptions.
//
class BaseExc;
class ArgExc;
class LogicExc;
class InputExc;
class IoExc;
class MathExc;
class ErrnoExc;
class NoImplExc;
class NullExc;
class TypeExc;
//
// Math exceptions.
//
class OverflowExc;
class UnderflowExc;
class DivzeroExc;
class InexactExc;
class InvalidFpOpExc;
//
// Errno exceptions.
//
class EpermExc;
class EnoentExc;
class EsrchExc;
class EintrExc;
class EioExc;
class EnxioExc;
class E2bigExc;
class EnoexecExc;
class EbadfExc;
class EchildExc;
class EagainExc;
class EnomemExc;
class EaccesExc;
class EfaultExc;
class EnotblkExc;
class EbusyExc;
class EexistExc;
class ExdevExc;
class EnodevExc;
class EnotdirExc;
class EisdirExc;
class EinvalExc;
class EnfileExc;
class EmfileExc;
class EnottyExc;
class EtxtbsyExc;
class EfbigExc;
class EnospcExc;
class EspipeExc;
class ErofsExc;
class EmlinkExc;
class EpipeExc;
class EdomExc;
class ErangeExc;
class EnomsgExc;
class EidrmExc;
class EchrngExc;
class El2nsyncExc;
class El3hltExc;
class El3rstExc;
class ElnrngExc;
class EunatchExc;
class EnocsiExc;
class El2hltExc;
class EdeadlkExc;
class EnolckExc;
class EbadeExc;
class EbadrExc;
class ExfullExc;
class EnoanoExc;
class EbadrqcExc;
class EbadsltExc;
class EdeadlockExc;
class EbfontExc;
class EnostrExc;
class EnodataExc;
class EtimeExc;
class EnosrExc;
class EnonetExc;
class EnopkgExc;
class EremoteExc;
class EnolinkExc;
class EadvExc;
class EsrmntExc;
class EcommExc;
class EprotoExc;
class EmultihopExc;
class EbadmsgExc;
class EnametoolongExc;
class EoverflowExc;
class EnotuniqExc;
class EbadfdExc;
class EremchgExc;
class ElibaccExc;
class ElibbadExc;
class ElibscnExc;
class ElibmaxExc;
class ElibexecExc;
class EilseqExc;
class EnosysExc;
class EloopExc;
class ErestartExc;
class EstrpipeExc;
class EnotemptyExc;
class EusersExc;
class EnotsockExc;
class EdestaddrreqExc;
class EmsgsizeExc;
class EprototypeExc;
class EnoprotooptExc;
class EprotonosupportExc;
class EsocktnosupportExc;
class EopnotsuppExc;
class EpfnosupportExc;
class EafnosupportExc;
class EaddrinuseExc;
class EaddrnotavailExc;
class EnetdownExc;
class EnetunreachExc;
class EnetresetExc;
class EconnabortedExc;
class EconnresetExc;
class EnobufsExc;
class EisconnExc;
class EnotconnExc;
class EshutdownExc;
class EtoomanyrefsExc;
class EtimedoutExc;
class EconnrefusedExc;
class EhostdownExc;
class EhostunreachExc;
class EalreadyExc;
class EinprogressExc;
class EstaleExc;
class EioresidExc;
class EucleanExc;
class EnotnamExc;
class EnavailExc;
class EisnamExc;
class EremoteioExc;
class EinitExc;
class EremdevExc;
class EcanceledExc;
class EnolimfileExc;
class EproclimExc;
class EdisjointExc;
class EnologinExc;
class EloginlimExc;
class EgrouploopExc;
class EnoattachExc;
class EnotsupExc;
class EnoattrExc;
class EdircorruptedExc;
class EdquotExc;
class EnfsremoteExc;
class EcontrollerExc;
class EnotcontrollerExc;
class EenqueuedExc;
class EnotenqueuedExc;
class EjoinedExc;
class EnotjoinedExc;
class EnoprocExc;
class EmustrunExc;
class EnotstoppedExc;
class EclockcpuExc;
class EinvalstateExc;
class EnoexistExc;
class EendofminorExc;
class EbufsizeExc;
class EemptyExc;
class EnointrgroupExc;
class EinvalmodeExc;
class EcantextentExc;
class EinvaltimeExc;
class EdestroyedExc;
IEX_INTERNAL_NAMESPACE_HEADER_EXIT
#endif // INCLUDED_IEXFORWARD_H
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Copyright (c) 2002-2018, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
//
// All rights reserved.
//
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
......@@ -16,8 +16,8 @@
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
......@@ -52,16 +52,22 @@
// Example:
//
// THROW (InputExc, "Syntax error in line " << line ", " << file << ".");
//
//
//----------------------------------------------------------------------------
#define THROW(type, text) \
do \
{ \
std::stringstream s; \
s << text; \
throw type (s); \
} \
#include "IexExport.h"
#include "IexForward.h"
IEX_EXPORT void iex_debugTrap();
#define THROW(type, text) \
do \
{ \
iex_debugTrap(); \
std::stringstream _iex_throw_s; \
_iex_throw_s << text; \
throw type (_iex_throw_s); \
} \
while (0)
......@@ -88,22 +94,22 @@
// }
//----------------------------------------------------------------------------
#define APPEND_EXC(exc, text) \
do \
{ \
std::stringstream s; \
s << text; \
exc.append (s); \
} \
#define APPEND_EXC(exc, text) \
do \
{ \
std::stringstream _iex_append_s; \
_iex_append_s << text; \
exc.append (_iex_append_s); \
} \
while (0)
#define REPLACE_EXC(exc, text) \
do \
{ \
std::stringstream s; \
s << text; \
exc.assign (s); \
} \
#define REPLACE_EXC(exc, text) \
do \
{ \
std::stringstream _iex_replace_s; \
_iex_replace_s << text; \
exc.assign (_iex_replace_s); \
} \
while (0)
......@@ -117,13 +123,13 @@
//
//-------------------------------------------------------------
#define THROW_ERRNO(text) \
do \
{ \
std::stringstream s; \
s << text; \
::Iex::throwErrnoExc (s.str()); \
} \
#define THROW_ERRNO(text) \
do \
{ \
std::stringstream _iex_throw_errno_s; \
_iex_throw_errno_s << text; \
::IEX_NAMESPACE::throwErrnoExc (_iex_throw_errno_s.str()); \
} \
while (0)
......@@ -132,17 +138,33 @@
//
// Example:
//
// ASSERT (ptr != NULL, NullExc, "Null pointer" );
// ASSERT (ptr != 0, NullExc, "Null pointer" );
//
//-------------------------------------------------------------
#define ASSERT(assertion, type, text) \
do \
{ \
if ((assertion) == false) \
THROW (type, text); \
if( bool(assertion) == false ) \
{ \
THROW( type, text ); \
} \
} \
while (0)
//-------------------------------------------------------------
// A macro to throw an IEX_NAMESPACE::LogicExc if an assertion is false,
// with the text composed from the source code file, line number,
// and assertion argument text.
//
// Example:
//
// LOGIC_ASSERT (i < n);
//
//-------------------------------------------------------------
#define LOGIC_ASSERT(assertion) \
ASSERT(assertion, \
IEX_NAMESPACE::LogicExc, \
__FILE__ << "(" << __LINE__ << "): logical assertion failed: " << #assertion )
#endif
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Copyright (c) 2002-2012, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
//
// All rights reserved.
//
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
......@@ -16,8 +16,8 @@
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
......@@ -39,7 +39,7 @@
#include "IexBaseExc.h"
namespace Iex {
IEX_INTERNAL_NAMESPACE_HEADER_ENTER
//---------------------------------------------------------
// Exception classess which correspond to specific floating
......@@ -52,7 +52,6 @@ DEFINE_EXC (DivzeroExc, MathExc) // Division by zero
DEFINE_EXC (InexactExc, MathExc) // Inexact result
DEFINE_EXC (InvalidFpOpExc, MathExc) // Invalid operation
IEX_INTERNAL_NAMESPACE_HEADER_EXIT
} // namespace Iex
#endif
#endif // INCLUDED_IEXMATHEXC_H
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Copyright (c) 2012, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
//
// All rights reserved.
//
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
......@@ -16,8 +16,8 @@
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
......@@ -32,128 +32,81 @@
//
///////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_IEXNAMESPACE_H
#define INCLUDED_IEXNAMESPACE_H
#ifndef INCLUDED_IMATHGL_H
#define INCLUDED_IMATHGL_H
#include <GL/gl.h>
#include "ImathVec.h"
#include "ImathMatrix.h"
#include "IexMathExc.h"
#include "ImathFun.h"
inline void glVertex ( const Imath::V3f &v ) { glVertex3f(v.x,v.y,v.z); }
inline void glVertex ( const Imath::V2f &v ) { glVertex2f(v.x,v.y); }
inline void glNormal ( const Imath::V3f &n ) { glNormal3f(n.x,n.y,n.z); }
inline void glColor ( const Imath::V3f &c ) { glColor3f(c.x,c.y,c.z); }
inline void glTranslate ( const Imath::V3f &t ) { glTranslatef(t.x,t.y,t.z); }
inline void glTexCoord( const Imath::V2f &t )
{
glTexCoord2f(t.x,t.y);
}
inline void glDisableTexture()
{
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D);
glActiveTexture(GL_TEXTURE0);
}
namespace {
const float GL_FLOAT_MAX = 1.8e+19; // sqrt (FLT_MAX)
inline bool
badFloat (float f)
{
return !Imath::finitef (f) || f < - GL_FLOAT_MAX || f > GL_FLOAT_MAX;
}
} // namespace
//
// The purpose of this file is to make it possible to specify an
// IEX_INTERNAL_NAMESPACE as a preprocessor definition and have all of the
// Iex symbols defined within that namespace rather than the standard
// Iex namespace. Those symbols are made available to client code through
// the IEX_NAMESPACE in addition to the IEX_INTERNAL_NAMESPACE.
//
// To ensure source code compatibility, the IEX_NAMESPACE defaults to Iex
// and then "using namespace IEX_INTERNAL_NAMESPACE;" brings all of the
// declarations from the IEX_INTERNAL_NAMESPACE into the IEX_NAMESPACE. This
// means that client code can continue to use syntax like Iex::BaseExc, but
// at link time it will resolve to a mangled symbol based on the
// IEX_INTERNAL_NAMESPACE.
//
// As an example, if one needed to build against a newer version of Iex and
// have it run alongside an older version in the same application, it is now
// possible to use an internal namespace to prevent collisions between the
// older versions of Iex symbols and the newer ones. To do this, the
// following could be defined at build time:
//
// IEX_INTERNAL_NAMESPACE = Iex_v2
//
// This means that declarations inside Iex headers look like this (after the
// preprocessor has done its work):
//
// namespace Iex_v2 {
// ...
// class declarations
// ...
// }
//
// namespace Iex {
// using namespace Iex_v2;
// }
//
inline void
throwBadMatrix (const Imath::M44f& m)
{
if (badFloat (m[0][0]) ||
badFloat (m[0][1]) ||
badFloat (m[0][2]) ||
badFloat (m[0][3]) ||
badFloat (m[1][0]) ||
badFloat (m[1][1]) ||
badFloat (m[1][2]) ||
badFloat (m[1][3]) ||
badFloat (m[2][0]) ||
badFloat (m[2][1]) ||
badFloat (m[2][2]) ||
badFloat (m[2][3]) ||
badFloat (m[3][0]) ||
badFloat (m[3][1]) ||
badFloat (m[3][2]) ||
badFloat (m[3][3]))
throw Iex::OverflowExc ("GL matrix overflow");
}
//
// Open Source version of this file pulls in the IlmBaseConfig.h file
// for the configure time options.
//
#include "IlmBaseConfig.h"
inline void
glMultMatrix( const Imath::M44f& m )
{
throwBadMatrix (m);
glMultMatrixf( (GLfloat*)m[0] );
}
#ifndef IEX_NAMESPACE
#define IEX_NAMESPACE Iex
#endif
inline void
glMultMatrix( const Imath::M44f* m )
{
throwBadMatrix (*m);
glMultMatrixf( (GLfloat*)(*m)[0] );
}
#ifndef IEX_INTERNAL_NAMESPACE
#define IEX_INTERNAL_NAMESPACE IEX_NAMESPACE
#endif
inline void
glLoadMatrix( const Imath::M44f& m )
{
throwBadMatrix (m);
glLoadMatrixf( (GLfloat*)m[0] );
}
//
// We need to be sure that we import the internal namespace into the public one.
// To do this, we use the small bit of code below which initially defines
// IEX_INTERNAL_NAMESPACE (so it can be referenced) and then defines
// IEX_NAMESPACE and pulls the internal symbols into the public namespace.
//
inline void
glLoadMatrix( const Imath::M44f* m )
{
throwBadMatrix (*m);
glLoadMatrixf( (GLfloat*)(*m)[0] );
namespace IEX_INTERNAL_NAMESPACE {}
namespace IEX_NAMESPACE {
using namespace IEX_INTERNAL_NAMESPACE;
}
namespace Imath {
//
// Class objects that push/pop the GL state. These objects assist with
// proper cleanup of the state when exceptions are thrown.
// There are identical pairs of HEADER/SOURCE ENTER/EXIT macros so that
// future extension to the namespace mechanism is possible without changing
// project source code.
//
class GLPushMatrix {
public:
GLPushMatrix () { glPushMatrix(); }
~GLPushMatrix() { glPopMatrix(); }
};
#define IEX_INTERNAL_NAMESPACE_HEADER_ENTER namespace IEX_INTERNAL_NAMESPACE {
#define IEX_INTERNAL_NAMESPACE_HEADER_EXIT }
class GLPushAttrib {
public:
#define IEX_INTERNAL_NAMESPACE_SOURCE_ENTER namespace IEX_INTERNAL_NAMESPACE {
#define IEX_INTERNAL_NAMESPACE_SOURCE_EXIT }
GLPushAttrib (GLbitfield mask) { glPushAttrib (mask); }
~GLPushAttrib() { glPopAttrib(); }
};
class GLBegin {
public:
GLBegin (GLenum mode) { glBegin (mode); }
~GLBegin() { glEnd(); }
};
} // namespace Imath
#endif
#endif // INCLUDED_IEXNAMESPACE_H
This diff is collapsed.
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Copyright (c) 2002-2012, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
//
// All rights reserved.
//
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
......@@ -16,8 +16,8 @@
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
......@@ -44,8 +44,9 @@
//----------------------------------------------------------
#include "IexBaseExc.h"
#include "IexExport.h"
namespace Iex {
IEX_INTERNAL_NAMESPACE_HEADER_ENTER
//--------------------------------------------------------------------------
......@@ -56,7 +57,7 @@ namespace Iex {
// "%T" have been replaced with the output of strerror(oserror()).
//
// Example:
//
//
// If opening file /tmp/output failed with an ENOENT error code,
// calling
//
......@@ -87,10 +88,10 @@ namespace Iex {
//
//--------------------------------------------------------------------------
void throwErrnoExc (const std::string &txt, int errnum);
void throwErrnoExc (const std::string &txt = "%T." /*, int errnum = oserror() */);
IEX_EXPORT void throwErrnoExc(const std::string &txt, int errnum);
IEX_EXPORT void throwErrnoExc(const std::string &txt);
IEX_EXPORT void throwErrnoExc();
} // namespace Iex
IEX_INTERNAL_NAMESPACE_HEADER_EXIT
#endif
#endif // INCLUDED_IEXTHROWERRNOEXC_H
#cmakedefine PLATFORM_WINDOWS
//
// Define and set to 1 if the target system has c++11/14 support
// and you want IlmBase to NOT use it's features
//
#cmakedefine01 ILMBASE_FORCE_CXX03
#if ILMBASE_FORCE_CXX03 == 0
#undef ILMBASE_FORCE_CXX03
#endif
//
// Define and set to 1 if the target system has POSIX thread support
// and you want IlmBase to use it for multithreaded file I/O.
......@@ -13,18 +25,59 @@
#cmakedefine01 HAVE_POSIX_SEMAPHORES
#undef HAVE_UCONTEXT_H
#cmakedefine HAVE_UCONTEXT_H
//
// Dealing with FPEs
//
#cmakedefine01 ILMBASE_HAVE_CONTROL_REGISTER_SUPPORT
//
// Define and set to 1 if the target system has support for large
// stack sizes.
//
#cmakedefine ILMBASE_HAVE_LARGE_STACK
//
// Current (internal) library namepace name and corresponding public
// client namespaces.
//
#define ILMBASE_INTERNAL_NAMESPACE_CUSTOM @ILMBASE_INTERNAL_NAMESPACE_CUSTOM@
#define IMATH_INTERNAL_NAMESPACE @IMATH_INTERNAL_NAMESPACE@
#define IEX_INTERNAL_NAMESPACE @IEX_INTERNAL_NAMESPACE@
#define ILMTHREAD_INTERNAL_NAMESPACE @ILMTHREAD_INTERNAL_NAMESPACE@
#define ILMBASE_NAMESPACE_CUSTOM @ILMBASE_NAMESPACE_CUSTOM@
#define IMATH_NAMESPACE @IMATH_NAMESPACE@
#define IEX_NAMESPACE @IEX_NAMESPACE@
#define ILMTHREAD_NAMESPACE @ILMTHREAD_NAMESPACE@
//
// Define and set to 1 if the target system has support for large
// stack sizes.
//
#undef ILMBASE_HAVE_LARGE_STACK
#cmakedefine ILMBASE_HAVE_LARGE_STACK
//
// Version string for runtime access
// Version information
//
#define ILMBASE_VERSION_STRING "1.0.3"
#define ILMBASE_PACKAGE_STRING "IlmBase 1.0.3"
#define ILMBASE_VERSION_STRING @ILMBASE_VERSION_STRING@
#define ILMBASE_PACKAGE_STRING @ILMBASE_PACKAGE_STRING@
#define ILMBASE_VERSION_MAJOR @ILMBASE_VERSION_MAJOR@
#define ILMBASE_VERSION_MINOR @ILMBASE_VERSION_MINOR@
#define ILMBASE_VERSION_PATCH @ILMBASE_VERSION_PATCH@
// Version as a single hex number, e.g. 0x01000300 == 1.0.3
#define ILMBASE_VERSION_HEX ((ILMBASE_VERSION_MAJOR << 24) | \
(ILMBASE_VERSION_MINOR << 16) | \
(ILMBASE_VERSION_PATCH << 8))
This diff is collapsed.
This diff is collapsed.
......@@ -2,9 +2,9 @@
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
//
// All rights reserved.
//
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
......@@ -16,8 +16,8 @@
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
......@@ -37,6 +37,8 @@
#ifndef INCLUDED_IMF_ARRAY_H
#define INCLUDED_IMF_ARRAY_H
#include "ImfForward.h"
//-------------------------------------------------------------------------
//
// class Array
......@@ -53,24 +55,23 @@
// C () {std::cout << "C::C (" << this << ")\n";};
// virtual ~C () {std::cout << "C::~C (" << this << ")\n";};
// };
//
//
// int
// main ()
// {
// Array <C> a(3);
//
//
// C &b = a[1];
// const C &c = a[1];
// C *d = a + 2;
// const C *e = a;
//
//
// return 0;
// }
//
//-------------------------------------------------------------------------
namespace Imf {
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
template <class T>
class Array
......@@ -81,8 +82,8 @@ class Array
// Constructors and destructors
//-----------------------------
Array () {_data = 0;}
Array (long size) {_data = new T[size];}
Array () {_data = 0; _size = 0;}
Array (long size) {_data = new T[size]; _size = size;}
~Array () {delete [] _data;}
......@@ -110,11 +111,19 @@ class Array
void resizeEraseUnsafe (long size);
//-------------------------------
// Return the size of this array.
//-------------------------------
long size() const {return _size;}
private:
Array (const Array &); // Copying and assignment
Array & operator = (const Array &); // are not implemented
long _size;
T * _data;
};
......@@ -157,11 +166,20 @@ class Array2D
void resizeEraseUnsafe (long sizeX, long sizeY);
//-------------------------------
// Return the size of this array.
//-------------------------------
long height() const {return _sizeX;}
long width() const {return _sizeY;}
private:
Array2D (const Array2D &); // Copying and assignment
Array2D & operator = (const Array2D &); // are not implemented
long _sizeX;
long _sizeY;
T * _data;
};
......@@ -177,6 +195,7 @@ Array<T>::resizeErase (long size)
{
T *tmp = new T[size];
delete [] _data;
_size = size;
_data = tmp;
}
......@@ -187,14 +206,16 @@ Array<T>::resizeEraseUnsafe (long size)
{
delete [] _data;
_data = 0;
_size = 0;
_data = new T[size];
_size = size;
}
template <class T>
inline
Array2D<T>::Array2D ():
_sizeY (0), _data (0)
_sizeX(0), _sizeY (0), _data (0)
{
// emtpy
}
......@@ -203,7 +224,7 @@ Array2D<T>::Array2D ():
template <class T>
inline
Array2D<T>::Array2D (long sizeX, long sizeY):
_sizeY (sizeY), _data (new T[sizeX * sizeY])
_sizeX (sizeX), _sizeY (sizeY), _data (new T[sizeX * sizeY])
{
// emtpy
}
......@@ -218,7 +239,7 @@ Array2D<T>::~Array2D ()
template <class T>
inline T *
inline T *
Array2D<T>::operator [] (long x)
{
return _data + x * _sizeY;
......@@ -239,6 +260,7 @@ Array2D<T>::resizeErase (long sizeX, long sizeY)
{
T *tmp = new T[sizeX * sizeY];
delete [] _data;
_sizeX = sizeX;
_sizeY = sizeY;
_data = tmp;
}
......@@ -250,12 +272,14 @@ Array2D<T>::resizeEraseUnsafe (long sizeX, long sizeY)
{
delete [] _data;
_data = 0;
_sizeX = 0;
_sizeY = 0;
_data = new T[sizeX * sizeY];
_sizeX = sizeX;
_sizeY = sizeY;
}
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
} // namespace Imf
#endif
......@@ -2,9 +2,9 @@
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
//
// All rights reserved.
//
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
......@@ -16,8 +16,8 @@
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
......@@ -46,11 +46,13 @@
#include <string.h>
#include <map>
#include "ImfNamespace.h"
namespace Imf {
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
using IlmThread::Mutex;
using IlmThread::Lock;
using ILMTHREAD_NAMESPACE::Mutex;
using ILMTHREAD_NAMESPACE::Lock;
Attribute::Attribute () {}
......@@ -66,7 +68,7 @@ struct NameCompare: std::binary_function <const char *, const char *, bool>
bool
operator () (const char *x, const char *y) const
{
return strcmp (x, y) < 0;
return strcmp (x, y) < 0;
}
};
......@@ -86,22 +88,28 @@ class LockedTypeMap: public TypeMap
LockedTypeMap &
typeMap ()
{
// c++11 requires thread-safe static variable initialization
#if __cplusplus >= 201103L
static LockedTypeMap tMap;
return tMap;
#else
static Mutex criticalSection;
Lock lock (criticalSection);
static LockedTypeMap* typeMap = 0;
if (typeMap == 0)
typeMap = new LockedTypeMap ();
typeMap = new LockedTypeMap ();
return *typeMap;
#endif
}
} // namespace
bool
bool
Attribute::knownType (const char typeName[])
{
LockedTypeMap& tMap = typeMap();
......@@ -111,17 +119,17 @@ Attribute::knownType (const char typeName[])
}
void
void
Attribute::registerAttributeType (const char typeName[],
Attribute *(*newAttribute)())
Attribute *(*newAttribute)())
{
LockedTypeMap& tMap = typeMap();
Lock lock (tMap.mutex);
if (tMap.find (typeName) != tMap.end())
THROW (Iex::ArgExc, "Cannot register image file attribute "
"type \"" << typeName << "\". "
"The type has already been registered.");
THROW (IEX_NAMESPACE::ArgExc, "Cannot register image file attribute "
"type \"" << typeName << "\". "
"The type has already been registered.");
tMap.insert (TypeMap::value_type (typeName, newAttribute));
}
......@@ -146,11 +154,11 @@ Attribute::newAttribute (const char typeName[])
TypeMap::const_iterator i = tMap.find (typeName);
if (i == tMap.end())
THROW (Iex::ArgExc, "Cannot create image file attribute of "
"unknown type \"" << typeName << "\".");
THROW (IEX_NAMESPACE::ArgExc, "Cannot create image file attribute of "
"unknown type \"" << typeName << "\".");
return (i->second)();
}
} // namespace Imf
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
This diff is collapsed.
......@@ -2,9 +2,9 @@
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
//
// All rights reserved.
//
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
......@@ -16,8 +16,8 @@
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
......@@ -44,13 +44,10 @@
//
//-----------------------------------------------------------------------------
#include "OpenEXRConfig.h"
#if !defined (HAVE_LARGE_STACK)
#include "ImfNamespace.h"
#include <string.h>
#endif
namespace Imf {
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
#if !defined (HAVE_LARGE_STACK)
......@@ -61,15 +58,15 @@ namespace Imf {
{
public:
AutoArray (): _data (new T [size]) { memset(_data, 0, size*sizeof(T)); }
~AutoArray () {delete [] _data;}
operator T * () {return _data;}
operator const T * () const {return _data;}
AutoArray (): _data (new T [size]) { memset(_data, 0, size*sizeof(T)); }
~AutoArray () {delete [] _data;}
operator T * () {return _data;}
operator const T * () const {return _data;}
private:
T *_data;
T *_data;
};
......@@ -81,17 +78,18 @@ namespace Imf {
{
public:
operator T * () {return _data;}
operator const T * () const {return _data;}
operator T * () {return _data;}
operator const T * () const {return _data;}
private:
T _data[size];
T _data[size];
};
#endif
} // namespace Imf
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
#endif
This diff is collapsed.
......@@ -2,9 +2,9 @@
//
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
//
// All rights reserved.
//
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
......@@ -16,8 +16,8 @@
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
......@@ -44,8 +44,9 @@
#include <ImfBoxAttribute.h>
namespace Imf {
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
using namespace OPENEXR_IMF_INTERNAL_NAMESPACE;
template <>
const char *
......@@ -57,7 +58,7 @@ Box2iAttribute::staticTypeName ()
template <>
void
Box2iAttribute::writeValueTo (OStream &os, int) const
Box2iAttribute::writeValueTo (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &os, int version) const
{
Xdr::write <StreamIO> (os, _value.min.x);
Xdr::write <StreamIO> (os, _value.min.y);
......@@ -68,7 +69,7 @@ Box2iAttribute::writeValueTo (OStream &os, int) const
template <>
void
Box2iAttribute::readValueFrom (IStream &is, int, int)
Box2iAttribute::readValueFrom (OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &is, int size, int version)
{
Xdr::read <StreamIO> (is, _value.min.x);
Xdr::read <StreamIO> (is, _value.min.y);
......@@ -87,7 +88,7 @@ Box2fAttribute::staticTypeName ()
template <>
void
Box2fAttribute::writeValueTo (OStream &os, int) const
Box2fAttribute::writeValueTo (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &os, int version) const
{
Xdr::write <StreamIO> (os, _value.min.x);
Xdr::write <StreamIO> (os, _value.min.y);
......@@ -98,7 +99,7 @@ Box2fAttribute::writeValueTo (OStream &os, int) const
template <>
void
Box2fAttribute::readValueFrom (IStream &is, int, int)
Box2fAttribute::readValueFrom (OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &is, int size, int version)
{
Xdr::read <StreamIO> (is, _value.min.x);
Xdr::read <StreamIO> (is, _value.min.y);
......@@ -107,4 +108,4 @@ Box2fAttribute::readValueFrom (IStream &is, int, int)
}
} // namespace Imf
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment