Skip to content

Commit

Permalink
add b44ExpLogTable.h and dwaLookups.h as official headers
Browse files Browse the repository at this point in the history
- remove auto-generation of the header tables
- add test to IlmImfTest to validate the headers

Signed-off-by: Cary Phillips <cary@ilm.com>
  • Loading branch information
cary-ilm committed Nov 14, 2019
1 parent 00bf05c commit 36edde9
Show file tree
Hide file tree
Showing 12 changed files with 115,307 additions and 52 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ OpenEXR/IlmImfTest/IlmImfTest
OpenEXR/IlmImfUtilTest/IlmImfUtilTest
OpenEXR/IlmImfFuzzTest/IlmImfFuzzTest
Contrib/DtexToExr/DtexToExr
b44ExpLogTable.h
dwaLookups.h
.deps
*.o
*.lo
Expand Down
29 changes: 2 additions & 27 deletions OpenEXR/IlmImf/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,37 +1,12 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright Contributors to the OpenEXR Project.

add_executable(b44ExpLogTable b44ExpLogTable.cpp)
target_link_libraries(b44ExpLogTable PRIVATE OpenEXR::Config IlmBase::Half IlmBase::IlmThread IlmBase::Iex)
set_target_properties(b44ExpLogTable PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)
# TODO: Old file had logic to skip these if the file already exists
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/b44ExpLogTable.h
COMMAND $<TARGET_FILE:b44ExpLogTable> > ${CMAKE_CURRENT_BINARY_DIR}/b44ExpLogTable.h
DEPENDS b44ExpLogTable
)


add_executable(dwaLookups dwaLookups.cpp)
target_link_libraries(dwaLookups PRIVATE OpenEXR::Config IlmBase::Imath IlmBase::Half IlmBase::IlmThread IlmBase::Iex)
set_target_properties(dwaLookups PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)
# TODO: Old file had logic to skip these if the file already exists
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dwaLookups.h
COMMAND $<TARGET_FILE:dwaLookups> > ${CMAKE_CURRENT_BINARY_DIR}/dwaLookups.h
DEPENDS dwaLookups
)

openexr_define_library(IlmImf
PRIV_EXPORT ILMIMF_EXPORTS
CURDIR ${CMAKE_CURRENT_SOURCE_DIR}
SOURCES
${CMAKE_CURRENT_BINARY_DIR}/b44ExpLogTable.h
${CMAKE_CURRENT_BINARY_DIR}/dwaLookups.h
b44ExpLogTable.h
dwaLookups.h
ImfAttribute.cpp
ImfBoxAttribute.cpp
ImfCRgbaFile.cpp
Expand Down
30 changes: 9 additions & 21 deletions OpenEXR/IlmImf/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,11 @@ libIlmImfinclude_HEADERS = ImfForward.h ImfAttribute.h ImfBoxAttribute.h \
ImfNamespace.h ImfForward.h ImfExport.h \
ImfPartHelper.h \
ImfDeepImageState.h \
ImfDeepImageStateAttribute.h
ImfDeepImageStateAttribute.h \
ImfSystemSpecific.h \
ImfOptimizedPixelReading.h \
b44ExpLogTable.h \
dwaLookups.h

noinst_HEADERS = ImfCompressor.h \
ImfRleCompressor.h \
Expand All @@ -185,33 +189,17 @@ noinst_HEADERS = ImfCompressor.h \
ImfOutputStreamMutex.h \
ImfInputPartData.h \
ImfOutputPartData.h \
ImfScanLineInputFile.h \
ImfSystemSpecific.h \
ImfOptimizedPixelReading.h
ImfOptimizedPixelReading.h \
b44ExpLogTable.h \
dwaLookups.h


EXTRA_DIST = $(noinst_HEADERS) b44ExpLogTable.cpp b44ExpLogTable.h dwaLookups.cpp dwaLookups.h CMakeLists.txt
EXTRA_DIST = $(noinst_HEADERS) CMakeLists.txt


AM_CPPFLAGS = @ILMBASE_CXXFLAGS@ \
-I$(top_builddir) \
-I$(top_srcdir)/config \
$(ILMBASE_CFLAGS) $(ZLIB_CFLAGS)

CLEANFILES = b44ExpLogTable b44ExpLogTable.h dwaLookups dwaLookups.h

b44ExpLogTable_SOURCES = b44ExpLogTable.cpp
b44ExpLogTable_LDADD = @ILMBASE_LDFLAGS@ $(ILMBASE_LIBS)

b44ExpLogTable.h: b44ExpLogTable
./b44ExpLogTable > b44ExpLogTable.h

dwaLookups_SOURCES = dwaLookups.cpp
dwaLookups_LDADD = @ILMBASE_LDFLAGS@ $(ILMBASE_LIBS)

dwaLookups.h: dwaLookups
./dwaLookups > dwaLookups.h

BUILT_SOURCES = b44ExpLogTable.h dwaLookups.h

noinst_PROGRAMS = b44ExpLogTable dwaLookups
16,396 changes: 16,396 additions & 0 deletions OpenEXR/IlmImf/b44ExpLogTable.h

Large diffs are not rendered by default.

98,334 changes: 98,334 additions & 0 deletions OpenEXR/IlmImf/dwaLookups.h

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions OpenEXR/IlmImfTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ add_executable(IlmImfTest
testXdr.cpp
testYca.cpp
testLargeDataWindowOffsets.cpp
testB44ExpLogTable.cpp
testDwaLookups.cpp
random.cpp
)
target_compile_definitions(IlmImfTest PRIVATE ILM_IMF_TEST_IMAGEDIR="${CMAKE_CURRENT_SOURCE_DIR}/")
Expand Down
4 changes: 3 additions & 1 deletion OpenEXR/IlmImfTest/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ IlmImfTest_SOURCES = main.cpp tmpDir.h testAttributes.cpp testChannels.cpp \
testFutureProofing.cpp testFutureProofing.h \
compareDwa.cpp compareDwa.h \
testDwaCompressorSimd.cpp testDwaCompressorSimd.h \
testLargeDataWindowOffsets.cpp testLargeDataWindowOffsets.h \
testLargeDataWindowOffsets.cpp testLargeDataWindowOffsets.h \
testRle.cpp testRle.h \
testB44ExpLogTable.cpp testB44ExpLogTable.h \
testDwaLookups.cpp testDwaLookups.h \
bswap_32.h

AM_CPPFLAGS = -DILM_IMF_TEST_IMAGEDIR=\"$(srcdir)/\"
Expand Down
6 changes: 5 additions & 1 deletion OpenEXR/IlmImfTest/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@
#include "testPartHelper.h"
#include "testDwaCompressorSimd.h"
#include "testRle.h"
#include "testB44ExpLogTable.h"
#include "testDwaLookups.h"

#include "tmpDir.h"
#include "ImathRandom.h"
Expand Down Expand Up @@ -222,7 +224,9 @@ main (int argc, char *argv[])
TEST (testFutureProofing, "core");
TEST (testDwaCompressorSimd, "basic");
TEST (testRle, "core");

TEST (testB44ExpLogTable, "core");
TEST (testDwaLookups, "core");


//#ifdef ENABLE_IMFHUGETEST
// defined via configure with --enable-imfhugetest=yes/no
Expand Down
55 changes: 55 additions & 0 deletions OpenEXR/IlmImfTest/testB44ExpLogTable.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// SPDX-License-Identifier: BSD-3-Clause
// Copyright Contributors to the OpenEXR Project.
//

#include <ImfNamespace.h>
#include <half.h>
#include <math.h>
#include <iostream>
#include <iomanip>
#include <assert.h>

using namespace std;


OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER

extern const unsigned short expTable[];
extern const unsigned short logTable[];

OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT

void
testB44ExpLogTable (const string&)
{
const int iMax = (1 << 16);

for (int i = 0; i < iMax; i++)
{
half h;
h.setBits (i);

if (!h.isFinite())
h = 0;
else if (h >= 8 * log (HALF_MAX))
h = HALF_MAX;
else
h = exp (h / 8);

assert (OPENEXR_IMF_INTERNAL_NAMESPACE::expTable[i] == h.bits());
}

for (int i = 0; i < iMax; i++)
{
half h;
h.setBits (i);

if (!h.isFinite() || h < 0)
h = 0;
else
h = 8 * log (h);

assert (OPENEXR_IMF_INTERNAL_NAMESPACE::logTable[i] == h.bits());
}
}
7 changes: 7 additions & 0 deletions OpenEXR/IlmImfTest/testB44ExpLogTable.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//
// SPDX-License-Identifier: BSD-3-Clause
// Copyright Contributors to the OpenEXR Project.
//

void testB44ExpLogTable (const std::string&);

Loading

0 comments on commit 36edde9

Please sign in to comment.