Skip to content

Commit

Permalink
move dwaLookups.h declarations to the OPENEXR_IMF_INTERNAL_NAMESPACE
Browse files Browse the repository at this point in the history
Also:
- added comments to the new tests
- fixed export headers in Makefile.am

Signed-off-by: Cary Phillips <cary@ilm.com>
  • Loading branch information
cary-ilm committed Nov 14, 2019
1 parent 36edde9 commit d80927b
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 19 deletions.
5 changes: 5 additions & 0 deletions IlmBase/HalfTest/testToFloat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@

using namespace std;

//
// This test uses the code that generates the toFLoat.h header to
// validate the the tabel values are correct.
//

//---------------------------------------------------
// Interpret an unsigned short bit pattern as a half,
// and convert that half to the corresponding float's
Expand Down
6 changes: 4 additions & 2 deletions OpenEXR/IlmImf/ImfDwaCompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,15 @@
#include "half.h"
#include "halfLimits.h"

#include "dwaLookups.h"

#include <vector>
#include <string>
#include <cctype>
#include <cassert>
#include <algorithm>

#include <cstddef>


// Windows specific addition to prevent the indirect import of the redefined min/max macros
#if defined _WIN32 || defined _WIN64
#ifdef NOMINMAX
Expand All @@ -171,6 +172,7 @@

OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER

#include "dwaLookups.h"

namespace {

Expand Down
6 changes: 1 addition & 5 deletions OpenEXR/IlmImf/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,7 @@ libIlmImfinclude_HEADERS = ImfForward.h ImfAttribute.h ImfBoxAttribute.h \
ImfNamespace.h ImfForward.h ImfExport.h \
ImfPartHelper.h \
ImfDeepImageState.h \
ImfDeepImageStateAttribute.h \
ImfSystemSpecific.h \
ImfOptimizedPixelReading.h \
b44ExpLogTable.h \
dwaLookups.h
ImfDeepImageStateAttribute.h

noinst_HEADERS = ImfCompressor.h \
ImfRleCompressor.h \
Expand Down
5 changes: 2 additions & 3 deletions OpenEXR/IlmImf/dwaLookups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ generateLutHeader()
}
}

printf("static unsigned int closestDataOffset[] = {\n");
printf("const unsigned int closestDataOffset[] = {\n");
int offsetIdx = 0;
int offsetPrev = 0;
for (size_t i=0; i<workers.size(); ++i) {
Expand All @@ -543,7 +543,7 @@ generateLutHeader()
printf("};\n\n\n");


printf("static unsigned short closestData[] = {\n");
printf("const unsigned short closestData[] = {\n");
int elementIdx = 0;
for (size_t i=0; i<workers.size(); ++i) {
for (size_t element=0; element<workers[i]->numElements(); ++element) {
Expand All @@ -568,7 +568,6 @@ generateLutHeader()
int
main(int argc, char **argv)
{
printf("#include <cstddef>\n");
printf("\n\n\n");

generateNoop();
Expand Down
3 changes: 0 additions & 3 deletions OpenEXR/IlmImf/dwaLookups.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#include <cstddef>



const unsigned short dwaCompressorNoOp[] =
{
Expand Down
7 changes: 6 additions & 1 deletion OpenEXR/IlmImfTest/testB44ExpLogTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@
#include <iomanip>
#include <assert.h>

using namespace std;
//
// This test uses the code from the program that generate the
// expTable.h and logTable.h headers and validates that the generated
// values match the values from the headers.
//

using namespace std;

OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER

Expand Down
20 changes: 15 additions & 5 deletions OpenEXR/IlmImfTest/testDwaLookups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,24 @@
#include <ImfXdr.h>
#include "ImfNamespace.h"

//
// This test uses the code that generates the dwaLookups.h header to
// validate the the values in the tables are correct.
//

using namespace OPENEXR_IMF_NAMESPACE;
using namespace OPENEXR_IMF_NAMESPACE;

OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER

extern const unsigned short dwaCompressorNoOp[];
extern const unsigned short dwaCompressorToLinear[];
extern const unsigned short dwaCompressorToNonlinear[];
extern const unsigned short closestData[];
extern const unsigned int closestDataOffset[];

OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT

namespace {

class LutHeaderWorker
Expand Down Expand Up @@ -240,7 +250,7 @@ testNoop()
for (int i=0; i<65536; ++i)
{
unsigned short src = (unsigned short)i;
assert (src == dwaCompressorNoOp[i]);
assert (src == OPENEXR_IMF_INTERNAL_NAMESPACE::dwaCompressorNoOp[i]);
}
}

Expand Down Expand Up @@ -313,7 +323,7 @@ testToLinear()

printf("test dwaCompressorToLinear[]\n");
for (int i=0; i<65536; ++i)
assert (toLinear[i] == dwaCompressorToLinear[i]);
assert (toLinear[i] == OPENEXR_IMF_INTERNAL_NAMESPACE::dwaCompressorToLinear[i]);
}


Expand Down Expand Up @@ -363,7 +373,7 @@ testToNonlinear()

printf("test dwaCompressorToNonlinear[]\n");
for (int i=0; i<65536; ++i)
assert (toNonLinear[i] == dwaCompressorToNonLinear[i]);
assert (toNonLinear[i] == OPENEXR_IMF_INTERNAL_NAMESPACE::dwaCompressorToNonLinear[i]);
}

//
Expand Down Expand Up @@ -455,7 +465,7 @@ testLutHeader()
for (size_t i=0; i<workers.size(); ++i) {
for (size_t value=0; value<workers[i]->numValues(); ++value)
{
assert (closestDataOffset[offsetIdx] == workers[i]->offset()[value] + offsetPrev);
assert (OPENEXR_IMF_INTERNAL_NAMESPACE::closestDataOffset[offsetIdx] == workers[i]->offset()[value] + offsetPrev);
offsetIdx++;
}
offsetPrev += workers[i]->offset()[workers[i]->numValues()-1] +
Expand All @@ -467,7 +477,7 @@ testLutHeader()
for (size_t i=0; i<workers.size(); ++i) {
for (size_t element=0; element<workers[i]->numElements(); ++element)
{
assert (closestData[elementIdx] == workers[i]->elements()[element]);
assert (OPENEXR_IMF_INTERNAL_NAMESPACE::closestData[elementIdx] == workers[i]->elements()[element]);
elementIdx++;
}
}
Expand Down

0 comments on commit d80927b

Please sign in to comment.