From 84f58b85aef7a7844f0d3bfb1301e778eb22e42c Mon Sep 17 00:00:00 2001 From: Kimball Thurston Date: Sun, 17 Mar 2024 12:57:01 +1300 Subject: [PATCH] Run clang-format Signed-off-by: Kimball Thurston --- Contrib/DtexToExr/DtexToExr.cpp | 45 +- Contrib/DtexToExr/PxBaseDeepHelper.h | 10 +- Contrib/DtexToExr/PxDeepUtils.cpp | 20 +- Contrib/DtexToExr/PxDeepUtils.h | 5 +- src/bin/exr2aces/main.cpp | 61 +- src/bin/exrcheck/main.cpp | 57 +- src/bin/exrenvmap/main.cpp | 226 +- src/bin/exrheader/main.cpp | 31 +- src/bin/exrinfo/main.c | 46 +- src/bin/exrmakepreview/main.cpp | 77 +- src/bin/exrmaketiled/Image.h | 4 +- src/bin/exrmaketiled/main.cpp | 162 +- src/bin/exrmultipart/exrmultipart.cpp | 191 +- src/bin/exrmultiview/Image.h | 4 +- src/bin/exrmultiview/main.cpp | 92 +- src/bin/exrmultiview/makeMultiView.cpp | 5 +- src/bin/exrstdattr/main.cpp | 392 ++-- src/examples/deepExamples.cpp | 78 +- src/examples/deepTiledExamples.cpp | 144 +- src/examples/deepidexample.cpp | 18 +- src/examples/generalInterfaceExamples.cpp | 64 +- src/examples/main.cpp | 2 +- src/examples/multipartExamples.cpp | 449 ++-- src/examples/multipartExamples.h | 1 - src/lib/Iex/IexBaseExc.h | 24 +- src/lib/Iex/IexExport.h | 4 +- src/lib/Iex/IexMathFloatExc.h | 4 +- src/lib/Iex/IexMathFpu.cpp | 26 +- src/lib/IlmThread/IlmThread.h | 6 +- src/lib/IlmThread/IlmThreadExport.h | 4 +- src/lib/IlmThread/IlmThreadMutex.h | 4 +- src/lib/IlmThread/IlmThreadPool.cpp | 2 +- src/lib/IlmThread/IlmThreadPool.h | 16 +- src/lib/IlmThread/IlmThreadSemaphore.h | 9 +- src/lib/IlmThread/IlmThreadSemaphoreOSX.cpp | 2 +- src/lib/IlmThread/IlmThreadSemaphorePosix.cpp | 6 +- src/lib/IlmThread/IlmThreadSemaphoreWin32.cpp | 9 +- src/lib/OpenEXR/ImfAcesFile.cpp | 8 +- src/lib/OpenEXR/ImfAcesFile.h | 8 +- src/lib/OpenEXR/ImfArray.h | 8 +- src/lib/OpenEXR/ImfAttribute.h | 2 +- src/lib/OpenEXR/ImfAutoArray.h | 4 +- src/lib/OpenEXR/ImfCompositeDeepScanLine.cpp | 42 +- src/lib/OpenEXR/ImfCompositeDeepScanLine.h | 10 +- src/lib/OpenEXR/ImfCompressionAttribute.cpp | 5 +- src/lib/OpenEXR/ImfDeepScanLineInputFile.cpp | 30 +- src/lib/OpenEXR/ImfDeepScanLineInputFile.h | 4 +- src/lib/OpenEXR/ImfDeepScanLineOutputFile.cpp | 4 +- src/lib/OpenEXR/ImfDeepScanLineOutputFile.h | 4 +- src/lib/OpenEXR/ImfDeepTiledInputFile.cpp | 6 +- src/lib/OpenEXR/ImfDeepTiledInputFile.h | 4 +- src/lib/OpenEXR/ImfDeepTiledOutputFile.cpp | 8 +- src/lib/OpenEXR/ImfDeepTiledOutputFile.h | 4 +- src/lib/OpenEXR/ImfDwaCompressor.cpp | 57 +- src/lib/OpenEXR/ImfDwaCompressorSimd.h | 122 +- src/lib/OpenEXR/ImfEnvmap.cpp | 15 +- src/lib/OpenEXR/ImfExport.h | 4 +- src/lib/OpenEXR/ImfFastHuf.cpp | 17 +- src/lib/OpenEXR/ImfFastHuf.h | 4 +- src/lib/OpenEXR/ImfGenericOutputFile.cpp | 5 +- src/lib/OpenEXR/ImfHeader.cpp | 14 +- src/lib/OpenEXR/ImfHeader.h | 1 - src/lib/OpenEXR/ImfHuf.cpp | 15 +- src/lib/OpenEXR/ImfIDManifest.cpp | 52 +- src/lib/OpenEXR/ImfIDManifestAttribute.cpp | 7 +- src/lib/OpenEXR/ImfIO.h | 8 +- src/lib/OpenEXR/ImfInputFile.cpp | 53 +- src/lib/OpenEXR/ImfInputFile.h | 4 +- src/lib/OpenEXR/ImfMisc.cpp | 128 +- src/lib/OpenEXR/ImfMisc.h | 2 +- src/lib/OpenEXR/ImfMultiPartInputFile.cpp | 8 +- src/lib/OpenEXR/ImfMultiPartInputFile.h | 4 +- src/lib/OpenEXR/ImfMultiPartOutputFile.cpp | 4 +- src/lib/OpenEXR/ImfMultiPartOutputFile.h | 4 +- src/lib/OpenEXR/ImfName.h | 4 +- src/lib/OpenEXR/ImfOutputFile.cpp | 4 +- src/lib/OpenEXR/ImfOutputFile.h | 4 +- src/lib/OpenEXR/ImfPartHelper.h | 10 +- src/lib/OpenEXR/ImfPxr24Compressor.cpp | 38 +- src/lib/OpenEXR/ImfRgbaFile.cpp | 18 +- src/lib/OpenEXR/ImfRgbaFile.h | 8 +- src/lib/OpenEXR/ImfScanLineInputFile.cpp | 20 +- src/lib/OpenEXR/ImfScanLineInputFile.h | 4 +- src/lib/OpenEXR/ImfSimd.h | 1 - src/lib/OpenEXR/ImfStandardAttributes.cpp | 3 +- src/lib/OpenEXR/ImfStandardAttributes.h | 45 +- src/lib/OpenEXR/ImfStdIO.h | 24 +- src/lib/OpenEXR/ImfSystemSpecific.cpp | 17 +- src/lib/OpenEXR/ImfTileOffsets.cpp | 5 +- src/lib/OpenEXR/ImfTiledInputFile.cpp | 8 +- src/lib/OpenEXR/ImfTiledInputFile.h | 4 +- src/lib/OpenEXR/ImfTiledOutputFile.cpp | 8 +- src/lib/OpenEXR/ImfTiledOutputFile.h | 4 +- src/lib/OpenEXR/ImfTiledRgbaFile.cpp | 30 +- src/lib/OpenEXR/ImfTiledRgbaFile.h | 8 +- src/lib/OpenEXR/ImfZip.cpp | 57 +- src/lib/OpenEXR/ImfZip.h | 4 +- src/lib/OpenEXR/dwaLookups.cpp | 4 +- src/lib/OpenEXRCore/attributes.c | 27 +- src/lib/OpenEXRCore/chunk.c | 40 +- src/lib/OpenEXRCore/coding.c | 22 +- src/lib/OpenEXRCore/context.c | 39 +- src/lib/OpenEXRCore/debug.c | 2 +- src/lib/OpenEXRCore/decoding.c | 48 +- src/lib/OpenEXRCore/internal_b44.c | 96 +- src/lib/OpenEXRCore/internal_cpuid.h | 25 +- src/lib/OpenEXRCore/internal_dwa_compressor.h | 20 +- src/lib/OpenEXRCore/internal_dwa_decoder.h | 27 +- src/lib/OpenEXRCore/internal_file.h | 15 +- src/lib/OpenEXRCore/internal_huf.c | 7 +- .../OpenEXRCore/internal_posix_file_impl.h | 4 +- src/lib/OpenEXRCore/internal_structs.c | 34 +- src/lib/OpenEXRCore/internal_structs.h | 37 +- src/lib/OpenEXRCore/openexr_attr.h | 2 +- src/lib/OpenEXRCore/parse_header.c | 101 +- src/lib/OpenEXRCore/part.c | 5 +- src/lib/OpenEXRCore/part_attr.c | 113 +- src/lib/OpenEXRCore/unpack.c | 4 +- src/lib/OpenEXRCore/validation.c | 6 +- src/lib/OpenEXRCore/write_header.c | 6 +- src/lib/OpenEXRUtil/ImfCheckFile.cpp | 187 +- src/lib/OpenEXRUtil/ImfCheckFile.h | 8 +- src/lib/OpenEXRUtil/ImfDeepImageChannel.h | 8 +- src/lib/OpenEXRUtil/ImfFlatImageChannel.h | 8 +- src/lib/OpenEXRUtil/ImfImage.cpp | 5 +- src/lib/OpenEXRUtil/ImfImageChannel.h | 4 +- src/lib/OpenEXRUtil/ImfSampleCountChannel.h | 4 +- src/lib/OpenEXRUtil/ImfUtilExport.h | 4 +- src/test/IexTest/mathFuncs.cpp | 2 +- src/test/IexTest/mathFuncs.h | 1 - src/test/IexTest/testBaseExc.cpp | 362 ++-- src/test/IexTest/testMathExc.cpp | 82 +- src/test/IexTest/testMathExc.h | 3 +- src/test/OpenEXRCoreTest/base_units.cpp | 31 +- src/test/OpenEXRCoreTest/buffer.cpp | 24 +- src/test/OpenEXRCoreTest/compression.cpp | 62 +- src/test/OpenEXRCoreTest/deep.cpp | 30 +- src/test/OpenEXRCoreTest/general_attr.cpp | 4 +- src/test/OpenEXRCoreTest/performance.cpp | 2 +- src/test/OpenEXRCoreTest/read.cpp | 2 +- src/test/OpenEXRFuzzTest/main.cpp | 5 +- .../OpenEXRFuzzTest/testFuzzDeepScanLines.cpp | 67 +- .../OpenEXRFuzzTest/testFuzzDeepTiles.cpp | 4 +- src/test/OpenEXRTest/compareDwa.cpp | 10 +- src/test/OpenEXRTest/testAttributes.cpp | 2 +- .../OpenEXRTest/testCompositeDeepScanLine.cpp | 36 +- src/test/OpenEXRTest/testCopyDeepScanLine.cpp | 46 +- src/test/OpenEXRTest/testCopyDeepTiled.cpp | 14 +- .../OpenEXRTest/testDeepScanLineBasic.cpp | 89 +- src/test/OpenEXRTest/testDeepScanLineHuge.cpp | 32 +- src/test/OpenEXRTest/testDeepTiledBasic.cpp | 35 +- .../OpenEXRTest/testDwaCompressorSimd.cpp | 29 +- src/test/OpenEXRTest/testExistingStreams.cpp | 119 +- src/test/OpenEXRTest/testFutureProofing.cpp | 5 +- src/test/OpenEXRTest/testHeader.cpp | 61 +- src/test/OpenEXRTest/testHuf.cpp | 9 +- src/test/OpenEXRTest/testIDManifest.cpp | 24 +- .../testLargeDataWindowOffsets.cpp | 20 +- src/test/OpenEXRTest/testMultiPartApi.cpp | 5 +- .../OpenEXRTest/testMultiPartThreading.cpp | 5 +- .../testOptimizedInterleavePatterns.cpp | 43 +- src/test/OpenEXRTest/testRgba.cpp | 5 +- .../OpenEXRTest/testSharedFrameBuffer.cpp | 5 +- .../OpenEXRTest/testStandardAttributes.cpp | 2 +- src/wrappers/python/OpenEXR.cpp | 1847 ++++++++++------- 165 files changed, 3719 insertions(+), 3624 deletions(-) diff --git a/Contrib/DtexToExr/DtexToExr.cpp b/Contrib/DtexToExr/DtexToExr.cpp index ce3578bb73..a1fd5c74e8 100644 --- a/Contrib/DtexToExr/DtexToExr.cpp +++ b/Contrib/DtexToExr/DtexToExr.cpp @@ -110,10 +110,7 @@ ConvertDtexFile ( PXDU_THROW ( "error (" << dtexOpenError << " opening file: " << i_fileName); } - else - { - PXDU_THROW ("missing file: " << i_fileName); - } + else { PXDU_THROW ("missing file: " << i_fileName); } } // Just handling the first image in the Dtex file for now. @@ -438,34 +435,13 @@ ParseArguments ( } o_exrFileName = arg; } - else if (arg == "--deepOpacity") - { - o_params.deepOpacity = true; - } - else if (arg == "--deepAlpha") - { - o_params.deepOpacity = false; - } - else if (arg == "--discrete") - { - o_params.discrete = true; - } - else if (arg == "--continuous") - { - o_params.discrete = false; - } - else if (arg == "--full") - { - o_full = true; - } - else if (arg == "--half") - { - o_full = false; - } - else if (arg == "--multRgb") - { - o_params.multiplyColorByAlpha = true; - } + else if (arg == "--deepOpacity") { o_params.deepOpacity = true; } + else if (arg == "--deepAlpha") { o_params.deepOpacity = false; } + else if (arg == "--discrete") { o_params.discrete = true; } + else if (arg == "--continuous") { o_params.discrete = false; } + else if (arg == "--full") { o_full = true; } + else if (arg == "--half") { o_full = false; } + else if (arg == "--multRgb") { o_params.multiplyColorByAlpha = true; } else if (arg == "--sideways") { if (argi <= argc - 1) @@ -493,10 +469,7 @@ ParseArguments ( "Invalid parameter for --sideways: " << argv[argi + 1]); } } - else - { - o_params.sideways = true; - } + else { o_params.sideways = true; } } else if (arg == "--compressionError") { diff --git a/Contrib/DtexToExr/PxBaseDeepHelper.h b/Contrib/DtexToExr/PxBaseDeepHelper.h index bd25704599..19a7141738 100644 --- a/Contrib/DtexToExr/PxBaseDeepHelper.h +++ b/Contrib/DtexToExr/PxBaseDeepHelper.h @@ -135,14 +135,8 @@ struct Span bool operator< (const Span& i_other) const { if (in < i_other.in) { return true; } - else if (in == i_other.in) - { - return index < i_other.index; - } - else - { - return false; - } + else if (in == i_other.in) { return index < i_other.index; } + else { return false; } } }; diff --git a/Contrib/DtexToExr/PxDeepUtils.cpp b/Contrib/DtexToExr/PxDeepUtils.cpp index 9c6b8b9c83..2297fa42f7 100644 --- a/Contrib/DtexToExr/PxDeepUtils.cpp +++ b/Contrib/DtexToExr/PxDeepUtils.cpp @@ -44,10 +44,7 @@ DensityFromVizDz (double i_viz, double i_dz) { double d = -log (i_viz) / i_dz; if (!isfinite (d)) { return PXDU_DENSITY_OF_VIZ_0; } - else - { - return d; - } + else { return d; } } } @@ -77,10 +74,7 @@ DensityTimesDzFromViz (double i_viz) { double d = -log (i_viz); if (!isfinite (d)) { return PXDU_DENSITY_OF_VIZ_0 * PXDU_DZ_OF_VIZ_0; } - else - { - return d; - } + else { return d; } } } @@ -115,19 +109,13 @@ DzFromVizDensity (double i_viz, double i_density) // This whole part is hacky at best. double dz = -log (i_viz) / PXDU_MIN_NON_ZERO_DENSITY; if (!isfinite (dz)) { return PXDU_MAX_DZ; } - else - { - return dz; - } + else { return dz; } } else { double dz = -log (i_viz) / i_density; if (!isfinite (dz)) { return PXDU_MAX_DZ; } - else - { - return dz; - } + else { return dz; } } } diff --git a/Contrib/DtexToExr/PxDeepUtils.h b/Contrib/DtexToExr/PxDeepUtils.h index 1c23ba7075..aba327e3af 100644 --- a/Contrib/DtexToExr/PxDeepUtils.h +++ b/Contrib/DtexToExr/PxDeepUtils.h @@ -287,10 +287,7 @@ inline T ZeroNAN (T i_f) { if (!isfinite (i_f)) { return (T) 0; } - else - { - return i_f; - } + else { return i_f; } } //-***************************************************************************** diff --git a/src/bin/exr2aces/main.cpp b/src/bin/exr2aces/main.cpp index 7e082424c3..e9a075af0e 100644 --- a/src/bin/exr2aces/main.cpp +++ b/src/bin/exr2aces/main.cpp @@ -35,33 +35,34 @@ usageMessage (ostream& stream, const char* program_name, bool verbose = false) stream << "Usage: " << program_name << " [options] infile outfile" << endl; if (verbose) - stream << "\n" - "Read an OpenEXR file from infile and save the contents\n" - "in ACES image file outfile.\n" - "\n" - "The ACES image file format is a subset of the OpenEXR file\n" - "format. ACES image files are restricted as follows:\n" - "\n" - " * Images are stored as scanlines; tiles are not allowed.\n" - " * Images contain three color channels, either:\n" - " R, G, B (red, green, blue)\n" - " or:\n" - " Y, RY, BY (luminance, sub-sampled chroma)\n" - " * Images may optionally contain an alpha channel.\n" - " * Only three compression types are allowed:\n" - " NO_COMPRESSION (file is not compressed)\n" - " PIZ_COMPRESSION (lossless)\n" - " B44A_COMPRESSION (lossy)\n" - " * The \"chromaticities\" header attribute must specify\n" - " the ACES RGB primaries and white point.\n" - "\n" - "Options:\n" - " -v, --verbose verbose mode\n" - " -h, --help print this message\n" - " --version print version information\n" - "\n" - "Report bugs via https://github.com/AcademySoftwareFoundation/openexr/issues or email security@openexr.com\n" - ""; + stream + << "\n" + "Read an OpenEXR file from infile and save the contents\n" + "in ACES image file outfile.\n" + "\n" + "The ACES image file format is a subset of the OpenEXR file\n" + "format. ACES image files are restricted as follows:\n" + "\n" + " * Images are stored as scanlines; tiles are not allowed.\n" + " * Images contain three color channels, either:\n" + " R, G, B (red, green, blue)\n" + " or:\n" + " Y, RY, BY (luminance, sub-sampled chroma)\n" + " * Images may optionally contain an alpha channel.\n" + " * Only three compression types are allowed:\n" + " NO_COMPRESSION (file is not compressed)\n" + " PIZ_COMPRESSION (lossless)\n" + " B44A_COMPRESSION (lossy)\n" + " * The \"chromaticities\" header attribute must specify\n" + " the ACES RGB primaries and white point.\n" + "\n" + "Options:\n" + " -v, --verbose verbose mode\n" + " -h, --help print this message\n" + " --version print version information\n" + "\n" + "Report bugs via https://github.com/AcademySoftwareFoundation/openexr/issues or email security@openexr.com\n" + ""; } void @@ -154,10 +155,10 @@ main (int argc, char** argv) } else if (!strcmp (argv[i], "--version")) { - const char* libraryVersion = getLibraryVersion(); - + const char* libraryVersion = getLibraryVersion (); + cout << "exr2aces (OpenEXR) " << OPENEXR_VERSION_STRING; - if (strcmp(libraryVersion, OPENEXR_VERSION_STRING)) + if (strcmp (libraryVersion, OPENEXR_VERSION_STRING)) cout << "(OpenEXR version " << libraryVersion << ")"; cout << " https://openexr.com" << endl; cout << "Copyright (c) Contributors to the OpenEXR Project" << endl; diff --git a/src/bin/exrcheck/main.cpp b/src/bin/exrcheck/main.cpp index 5143102660..00f2125681 100644 --- a/src/bin/exrcheck/main.cpp +++ b/src/bin/exrcheck/main.cpp @@ -24,22 +24,24 @@ using namespace std; void usageMessage (ostream& stream, const char* program_name, bool verbose = false) { - stream << "Usage: " << program_name << " [options] imagefile [imagefile ...]\n"; + stream << "Usage: " << program_name + << " [options] imagefile [imagefile ...]\n"; if (verbose) - stream << "\n" - "Read exr files to validate their contents and the correct behavior of the software.\n" - "\n" - "Options:\n" - " -m avoid excessive memory allocation (some files will not be fully checked)\n" - " -t avoid spending excessive time (some files will not be fully checked)\n" - " -s use stream API instead of file API\n" - " -c add core library checks\n" - " -h, --help print this message\n" - " --version print version information\n" - "\n" - "Report bugs via https://github.com/AcademySoftwareFoundation/openexr/issues or email security@openexr.com\n" - ""; + stream + << "\n" + "Read exr files to validate their contents and the correct behavior of the software.\n" + "\n" + "Options:\n" + " -m avoid excessive memory allocation (some files will not be fully checked)\n" + " -t avoid spending excessive time (some files will not be fully checked)\n" + " -s use stream API instead of file API\n" + " -c add core library checks\n" + " -h, --help print this message\n" + " --version print version information\n" + "\n" + "Report bugs via https://github.com/AcademySoftwareFoundation/openexr/issues or email security@openexr.com\n" + ""; } bool @@ -126,26 +128,16 @@ main (int argc, char** argv) // Header::setMaxTileSize(); reduceMemory = true; - - } - else if (!strcmp (argv[i], "-t")) - { - reduceTime = true; - } - else if (!strcmp (argv[i], "-s")) - { - useStream = true; - } - else if (!strcmp (argv[i], "-c")) - { - enableCoreCheck = true; } + else if (!strcmp (argv[i], "-t")) { reduceTime = true; } + else if (!strcmp (argv[i], "-s")) { useStream = true; } + else if (!strcmp (argv[i], "-c")) { enableCoreCheck = true; } else if (!strcmp (argv[i], "--version")) { - const char* libraryVersion = getLibraryVersion(); - + const char* libraryVersion = getLibraryVersion (); + cout << "exrcheck (OpenEXR) " << OPENEXR_VERSION_STRING; - if (strcmp(libraryVersion, OPENEXR_VERSION_STRING)) + if (strcmp (libraryVersion, OPENEXR_VERSION_STRING)) cout << "(OpenEXR version " << libraryVersion << ")"; cout << " https://openexr.com" << endl; cout << "Copyright (c) Contributors to the OpenEXR Project" << endl; @@ -176,10 +168,7 @@ main (int argc, char** argv) cout << "bad\n"; badFileFound = true; } - else - { - cout << "OK\n"; - } + else { cout << "OK\n"; } } } diff --git a/src/bin/exrenvmap/main.cpp b/src/bin/exrenvmap/main.cpp index dda54dc4a2..a624321f22 100644 --- a/src/bin/exrenvmap/main.cpp +++ b/src/bin/exrenvmap/main.cpp @@ -41,98 +41,101 @@ usageMessage (ostream& stream, const char* program_name, bool verbose = false) if (verbose) { std::string compressionNames; - getCompressionNamesString("/", compressionNames); - - stream << "\n" - "Convert an OpenEXR latitude-longitude environment map\n" - "into a cube-face environment map or vice versa.\n" - "Reads an environment map image from infile, converts\n" - "it, and stores the result in outfile.\n" - "\n" - "If the input file name contains a '%' character, then an\n" - "input cube-face environment map is assembled from six\n" - "square sub-images that represent the six faces of the cube.\n" - "The names of the six image files are generated by replacing\n" - "the % with +X, -X, +Y, -Y, +Z and -Z respectively.\n" - "\n" - "If the output file name contains a '%' character and\n" - "the program has been instructed to produce a cube-face\n" - "environment map, then the output image is split into six\n" - "square sub-images that are saved in six separate output\n" - "files. The names of the files are generated by replacing\n" - "the % with +X, -X, +Y, -Y, +Z and -Z respectively.\n" - "\n" - "Options:\n" - "\n" - " -o produces a ONE_LEVEL output file (default)\n" - "\n" - " -m produces a MIPMAP_LEVELS output file (-m has\n" - " no effect if the output image is split into\n" - " multiple files)\n" - "\n" - " -c the output file will be a cube-face environment\n" - " map (default)\n" - "\n" - " -l the output file will be a latitude-longitude\n" - " environment map\n" - "\n" - " -ci the input file is interpreted as a cube-face\n" - " environment map, regardless of its envmap\n" - " attribute\n" - "\n" - " -li the input file is interpreted as a latitude-\n" - " longitude environment map, regardless of its\n" - " envmap attribute (-li has no effect if the\n" - " input image is assembled from multiple files)\n" - "\n" - " -w x sets the width of the output image to x pixels\n" - " (default is 256). The height of the output image\n" - " will be x*6 pixels for a cube-face map, or x/2\n" - " pixels for a latitude-longitude map.\n" - "\n" - " -f r n sets the antialiasing filter radius to r\n" - " (default is 1.0) and the sampling rate to\n" - " n by n (default is 5 by 5). Increasing r\n" - " makes the output image blurrier; decreasing r\n" - " makes the image sharper but may cause aliasing.\n" - " Increasing n improves antialiasing, but\n" - " generating the output image takes longer.\n" - "\n" - " -b blurs the environment map image by applying a\n" - " 180-degree-wide filter kernel such that point-\n" - " sampling the blurred image at a location that\n" - " corresponds to 3D direction N returns the color\n" - " that a white diffuse reflector with surface\n" - " normal N would have if it was illuminated using\n" - " the original non-blurred image.\n" - " Generating the blurred image can be fairly slow.\n" - "\n" - " -t x y sets the output file's tile size to x by y pixels\n" - " (default is 64 by 64)\n" - "\n" - " -p t b if the input image is a latitude-longitude map,\n" - " pad the image at the top and bottom with t*h\n" - " and b*h extra scan lines, where h is the height\n" - " of the input image. This is useful for images\n" - " from 360-degree panoramic scans that cover\n" - " less than 180 degrees vertically.\n" - "\n" - " -d sets level size rounding to ROUND_DOWN (default)\n" - "\n" - " -u sets level size rounding to ROUND_UP\n" - "\n" - " -z x sets the data compression method to x\n" - " (" << compressionNames.c_str() << ",\n" - " default is zip)\n" - "\n" - " -v verbose mode\n" - "\n" - " -h, --help print this message\n" - "\n" - " --version print version information\n" - "\n" - "Report bugs via https://github.com/AcademySoftwareFoundation/openexr/issues or email security@openexr.com\n" - ""; + getCompressionNamesString ("/", compressionNames); + + stream + << "\n" + "Convert an OpenEXR latitude-longitude environment map\n" + "into a cube-face environment map or vice versa.\n" + "Reads an environment map image from infile, converts\n" + "it, and stores the result in outfile.\n" + "\n" + "If the input file name contains a '%' character, then an\n" + "input cube-face environment map is assembled from six\n" + "square sub-images that represent the six faces of the cube.\n" + "The names of the six image files are generated by replacing\n" + "the % with +X, -X, +Y, -Y, +Z and -Z respectively.\n" + "\n" + "If the output file name contains a '%' character and\n" + "the program has been instructed to produce a cube-face\n" + "environment map, then the output image is split into six\n" + "square sub-images that are saved in six separate output\n" + "files. The names of the files are generated by replacing\n" + "the % with +X, -X, +Y, -Y, +Z and -Z respectively.\n" + "\n" + "Options:\n" + "\n" + " -o produces a ONE_LEVEL output file (default)\n" + "\n" + " -m produces a MIPMAP_LEVELS output file (-m has\n" + " no effect if the output image is split into\n" + " multiple files)\n" + "\n" + " -c the output file will be a cube-face environment\n" + " map (default)\n" + "\n" + " -l the output file will be a latitude-longitude\n" + " environment map\n" + "\n" + " -ci the input file is interpreted as a cube-face\n" + " environment map, regardless of its envmap\n" + " attribute\n" + "\n" + " -li the input file is interpreted as a latitude-\n" + " longitude environment map, regardless of its\n" + " envmap attribute (-li has no effect if the\n" + " input image is assembled from multiple files)\n" + "\n" + " -w x sets the width of the output image to x pixels\n" + " (default is 256). The height of the output image\n" + " will be x*6 pixels for a cube-face map, or x/2\n" + " pixels for a latitude-longitude map.\n" + "\n" + " -f r n sets the antialiasing filter radius to r\n" + " (default is 1.0) and the sampling rate to\n" + " n by n (default is 5 by 5). Increasing r\n" + " makes the output image blurrier; decreasing r\n" + " makes the image sharper but may cause aliasing.\n" + " Increasing n improves antialiasing, but\n" + " generating the output image takes longer.\n" + "\n" + " -b blurs the environment map image by applying a\n" + " 180-degree-wide filter kernel such that point-\n" + " sampling the blurred image at a location that\n" + " corresponds to 3D direction N returns the color\n" + " that a white diffuse reflector with surface\n" + " normal N would have if it was illuminated using\n" + " the original non-blurred image.\n" + " Generating the blurred image can be fairly slow.\n" + "\n" + " -t x y sets the output file's tile size to x by y pixels\n" + " (default is 64 by 64)\n" + "\n" + " -p t b if the input image is a latitude-longitude map,\n" + " pad the image at the top and bottom with t*h\n" + " and b*h extra scan lines, where h is the height\n" + " of the input image. This is useful for images\n" + " from 360-degree panoramic scans that cover\n" + " less than 180 degrees vertically.\n" + "\n" + " -d sets level size rounding to ROUND_DOWN (default)\n" + "\n" + " -u sets level size rounding to ROUND_UP\n" + "\n" + " -z x sets the data compression method to x\n" + " (" + << compressionNames.c_str () + << ",\n" + " default is zip)\n" + "\n" + " -v verbose mode\n" + "\n" + " -h, --help print this message\n" + "\n" + " --version print version information\n" + "\n" + "Report bugs via https://github.com/AcademySoftwareFoundation/openexr/issues or email security@openexr.com\n" + ""; } } @@ -145,7 +148,7 @@ getCompression (const string& str) { std::stringstream e; e << "Unknown compression method \"" << str << "\""; - throw invalid_argument(e.str().c_str()); + throw invalid_argument (e.str ().c_str ()); } return c; @@ -250,12 +253,13 @@ main (int argc, char** argv) // if (i > argc - 2) - throw invalid_argument("Missing width for -w argument"); + throw invalid_argument ("Missing width for -w argument"); mapWidth = strtol (argv[i + 1], 0, 0); if (mapWidth <= 0) - throw invalid_argument("Output image width must be greater than zero"); + throw invalid_argument ( + "Output image width must be greater than zero"); i += 2; } @@ -266,16 +270,19 @@ main (int argc, char** argv) // if (i > argc - 3) - throw invalid_argument("Missing filter radius with -f option"); + throw invalid_argument ( + "Missing filter radius with -f option"); filterRadius = strtod (argv[i + 1], 0); numSamples = strtol (argv[i + 2], 0, 0); if (filterRadius < 0) - throw invalid_argument("Filter radius must not be less than zero"); + throw invalid_argument ( + "Filter radius must not be less than zero"); if (numSamples <= 0) - throw invalid_argument("Sampling rate must be greater than zero"); + throw invalid_argument ( + "Sampling rate must be greater than zero"); i += 3; } @@ -295,13 +302,14 @@ main (int argc, char** argv) // if (i > argc - 3) - throw invalid_argument("missing tile size with -t option"); + throw invalid_argument ("missing tile size with -t option"); tileWidth = strtol (argv[i + 1], 0, 0); tileHeight = strtol (argv[i + 2], 0, 0); if (tileWidth <= 0 || tileHeight <= 0) - throw invalid_argument("Tile size must be greater than zero"); + throw invalid_argument ( + "Tile size must be greater than zero"); i += 3; } @@ -312,13 +320,15 @@ main (int argc, char** argv) // if (i > argc - 3) - throw invalid_argument("missing padding value with -p option"); + throw invalid_argument ( + "missing padding value with -p option"); padTop = strtod (argv[i + 1], 0); padBottom = strtod (argv[i + 2], 0); if (padTop < 0 || padBottom < 0) - throw invalid_argument("Padding must not be less than zero"); + throw invalid_argument ( + "Padding must not be less than zero"); i += 3; } @@ -347,7 +357,8 @@ main (int argc, char** argv) // if (i > argc - 2) - throw invalid_argument("Missing compression method with -z option"); + throw invalid_argument ( + "Missing compression method with -z option"); compression = getCompression (argv[i + 1]); i += 2; @@ -372,13 +383,14 @@ main (int argc, char** argv) } else if (!strcmp (argv[i], "--version")) { - const char* libraryVersion = getLibraryVersion(); - + const char* libraryVersion = getLibraryVersion (); + cout << "exrenvmap (OpenEXR) " << OPENEXR_VERSION_STRING; - if (strcmp(libraryVersion, OPENEXR_VERSION_STRING)) + if (strcmp (libraryVersion, OPENEXR_VERSION_STRING)) cout << "(OpenEXR version " << libraryVersion << ")"; cout << " https://openexr.com" << endl; - cout << "Copyright (c) Contributors to the OpenEXR Project" << endl; + cout << "Copyright (c) Contributors to the OpenEXR Project" + << endl; cout << "License BSD-3-Clause" << endl; return 0; } diff --git a/src/bin/exrheader/main.cpp b/src/bin/exrheader/main.cpp index 46df4020df..98e5694ccd 100644 --- a/src/bin/exrheader/main.cpp +++ b/src/bin/exrheader/main.cpp @@ -44,8 +44,8 @@ void printCompression (Compression c) { std::string desc; - getCompressionDescriptionFromId(c, desc); - cout << desc.c_str(); + getCompressionDescriptionFromId (c, desc); + cout << desc.c_str (); } void @@ -442,15 +442,16 @@ usageMessage (ostream& stream, const char* program_name, bool verbose = false) stream << "Usage: " << program_name << " imagefile [imagefile ...]\n"; if (verbose) - stream << "\n" - "Read exr files and print the values of header attributes.\n" - "\n" - "Options:\n" - " -h, --help print this message\n" - " --version print version information\n" - "\n" - "Report bugs via https://github.com/AcademySoftwareFoundation/openexr/issues or email security@openexr.com\n" - ""; + stream + << "\n" + "Read exr files and print the values of header attributes.\n" + "\n" + "Options:\n" + " -h, --help print this message\n" + " --version print version information\n" + "\n" + "Report bugs via https://github.com/AcademySoftwareFoundation/openexr/issues or email security@openexr.com\n" + ""; } int @@ -464,17 +465,17 @@ main (int argc, char** argv) for (int i = 1; i < argc; ++i) { - if (!strcmp (argv[i], "-h") || !strcmp(argv[1], "--help")) + if (!strcmp (argv[i], "-h") || !strcmp (argv[1], "--help")) { usageMessage (cout, "exrheader", true); return 0; } else if (!strcmp (argv[i], "--version")) { - const char* libraryVersion = getLibraryVersion(); - + const char* libraryVersion = getLibraryVersion (); + cout << "exrheader (OpenEXR) " << OPENEXR_VERSION_STRING; - if (strcmp(libraryVersion, OPENEXR_VERSION_STRING)) + if (strcmp (libraryVersion, OPENEXR_VERSION_STRING)) cout << "(OpenEXR version " << libraryVersion << ")"; cout << " https://openexr.com" << endl; cout << "Copyright (c) Contributors to the OpenEXR Project" << endl; diff --git a/src/bin/exrinfo/main.c b/src/bin/exrinfo/main.c index 895487949b..f28b02ab9f 100644 --- a/src/bin/exrinfo/main.c +++ b/src/bin/exrinfo/main.c @@ -20,23 +20,26 @@ static void usage (FILE* stream, const char* argv0, int verbose) { - fprintf (stream, - "Usage: %s [-v|--verbose] [-a|--all-metadata] [-s|--strict] [ ...]\n\n", - argv0); + fprintf ( + stream, + "Usage: %s [-v|--verbose] [-a|--all-metadata] [-s|--strict] [ ...]\n\n", + argv0); if (verbose) - fprintf(stream, "\n" - "Read exr files and print values of header attributes\n" - "\n" - "Options:\n" - " -s, --strict strict mode\n" - " -a, --all-metadata print all metadata\n" - " -v, --verbose verbose mode\n" - " -h, --help print this message\n" - " --version print version information\n" - "\n" - "Report bugs via https://github.com/AcademySoftwareFoundation/openexr/issues or email security@openexr.com\n" - ""); + fprintf ( + stream, + "\n" + "Read exr files and print values of header attributes\n" + "\n" + "Options:\n" + " -s, --strict strict mode\n" + " -a, --all-metadata print all metadata\n" + " -v, --verbose verbose mode\n" + " -h, --help print this message\n" + " --version print version information\n" + "\n" + "Report bugs via https://github.com/AcademySoftwareFoundation/openexr/issues or email security@openexr.com\n" + ""); } static void @@ -154,9 +157,11 @@ main (int argc, const char* argv[]) } else if (!strcmp (argv[a], "--version")) { - printf("exrinfo (OpenEXR) %s https://openexr.com\n", OPENEXR_VERSION_STRING); - printf("Copyright (c) Contributors to the OpenEXR Project\n"); - printf("License BSD-3-Clause\n"); + printf ( + "exrinfo (OpenEXR) %s https://openexr.com\n", + OPENEXR_VERSION_STRING); + printf ("Copyright (c) Contributors to the OpenEXR Project\n"); + printf ("License BSD-3-Clause\n"); return 0; } else if (!strcmp (argv[a], "-v") || !strcmp (argv[a], "--verbose")) @@ -180,10 +185,7 @@ main (int argc, const char* argv[]) usage (stderr, argv[0], 0); return 1; } - else - { - rv += process_file (argv[a], verbose, allmeta, strict); - } + else { rv += process_file (argv[a], verbose, allmeta, strict); } } return rv; diff --git a/src/bin/exrmakepreview/main.cpp b/src/bin/exrmakepreview/main.cpp index d78c140f68..91a949cd05 100644 --- a/src/bin/exrmakepreview/main.cpp +++ b/src/bin/exrmakepreview/main.cpp @@ -29,29 +29,30 @@ usageMessage (ostream& stream, const char* program_name, bool verbose = false) stream << "Usage: " << program_name << " [options] infile outfile" << endl; if (verbose) - stream << "\n" - "Read an OpenEXR image from infile, generate a preview\n" - "image, add it to the image's header, and save the result\n" - "in outfile. Infile and outfile must not refer to the same\n" - "file (the program cannot edit an image file \"in place\").\n" - "\n" - "Options:\n" - "\n" - " -w x sets the width of the preview image to x pixels\n" - " (default is 100)\n" - "\n" - " -e s adjusts the preview image's exposure by s f-stops\n" - " (default is 0). Positive values make the image\n" - " brighter, negative values make it darker.\n" - "\n" - " -v verbose mode\n" - "\n" - " -h, --help print this message\n" - "\n" - " --version print version information\n" - "\n" - "Report bugs via https://github.com/AcademySoftwareFoundation/openexr/issues or email security@openexr.com\n" - ""; + stream + << "\n" + "Read an OpenEXR image from infile, generate a preview\n" + "image, add it to the image's header, and save the result\n" + "in outfile. Infile and outfile must not refer to the same\n" + "file (the program cannot edit an image file \"in place\").\n" + "\n" + "Options:\n" + "\n" + " -w x sets the width of the preview image to x pixels\n" + " (default is 100)\n" + "\n" + " -e s adjusts the preview image's exposure by s f-stops\n" + " (default is 0). Positive values make the image\n" + " brighter, negative values make it darker.\n" + "\n" + " -v verbose mode\n" + "\n" + " -h, --help print this message\n" + "\n" + " --version print version information\n" + "\n" + "Report bugs via https://github.com/AcademySoftwareFoundation/openexr/issues or email security@openexr.com\n" + ""; } int @@ -72,7 +73,6 @@ main (int argc, char** argv) usageMessage (cerr, argv[0], false); return -1; } - try { @@ -87,12 +87,13 @@ main (int argc, char** argv) // if (i > argc - 2) - throw invalid_argument("Missing width for -w argument"); + throw invalid_argument ("Missing width for -w argument"); previewWidth = strtol (argv[i + 1], 0, 0); if (previewWidth <= 0) - throw invalid_argument("preview width must be greater than zero"); - + throw invalid_argument ( + "preview width must be greater than zero"); + i += 2; } else if (!strcmp (argv[i], "-e")) @@ -102,10 +103,10 @@ main (int argc, char** argv) // if (i > argc - 2) - throw invalid_argument("missing exposure for -e argument"); + throw invalid_argument ("missing exposure for -e argument"); + + exposure = strtod (argv[i + 1], 0); - exposure = strtod (argv[i + 1], 0); - i += 2; } else if (!strcmp (argv[i], "-v")) @@ -128,13 +129,14 @@ main (int argc, char** argv) } else if (!strcmp (argv[i], "--version")) { - const char* libraryVersion = getLibraryVersion(); - + const char* libraryVersion = getLibraryVersion (); + cout << "exrmakepreview (OpenEXR) " << OPENEXR_VERSION_STRING; - if (strcmp(libraryVersion, OPENEXR_VERSION_STRING)) + if (strcmp (libraryVersion, OPENEXR_VERSION_STRING)) cout << "(OpenEXR version " << libraryVersion << ")"; cout << " https://openexr.com" << endl; - cout << "Copyright (c) Contributors to the OpenEXR Project" << endl; + cout << "Copyright (c) Contributors to the OpenEXR Project" + << endl; cout << "License BSD-3-Clause" << endl; return 0; } @@ -160,10 +162,11 @@ main (int argc, char** argv) } if (!strcmp (inFile, outFile)) - throw invalid_argument("Input and output cannot be the same file"); + throw invalid_argument ("Input and output cannot be the same file"); - if (previewWidth <= 0) - throw invalid_argument("Preview image width must be greater than zero"); + if (previewWidth <= 0) + throw invalid_argument ( + "Preview image width must be greater than zero"); // // Load inFile, add a preview image, and save the result in outFile. diff --git a/src/bin/exrmaketiled/Image.h b/src/bin/exrmaketiled/Image.h index d634de69c2..396a556c4a 100644 --- a/src/bin/exrmaketiled/Image.h +++ b/src/bin/exrmaketiled/Image.h @@ -74,10 +74,10 @@ class Image Image (const IMATH_NAMESPACE::Box2i& dataWindow); ~Image (); - Image (const Image& other) = delete; + Image (const Image& other) = delete; Image& operator= (const Image& other) = delete; Image (Image&& other) = delete; - Image& operator= (Image&& other) = delete; + Image& operator= (Image&& other) = delete; const IMATH_NAMESPACE::Box2i& dataWindow () const; void resize (const IMATH_NAMESPACE::Box2i& dataWindow); diff --git a/src/bin/exrmaketiled/main.cpp b/src/bin/exrmaketiled/main.cpp index ac6020a0ce..7f0e369c5a 100644 --- a/src/bin/exrmaketiled/main.cpp +++ b/src/bin/exrmaketiled/main.cpp @@ -38,57 +38,60 @@ usageMessage (ostream& stream, const char* program_name, bool verbose = false) if (verbose) { std::string compressionNames; - getCompressionNamesString("/", compressionNames); - - stream << "\n" - "Read an OpenEXR image from infile, produce a tiled\n" - "version of the image, and save the result in outfile.\n" - "\n" - "Options:\n" - "\n" - " -o produces a ONE_LEVEL image (default)\n" - "\n" - " -m produces a MIPMAP_LEVELS multiresolution image\n" - "\n" - " -r produces a RIPMAP_LEVELS multiresolution image\n" - "\n" - " -f c when a MIPMAP_LEVELS or RIPMAP_LEVELS image\n" - " is produced, image channel c will be resampled\n" - " without low-pass filtering. This option can\n" - " be specified multiple times to disable low-pass\n" - " filtering for multiple channels.\n" - "\n" - " -e x y when a MIPMAP_LEVELS or RIPMAP_LEVELS image\n" - " is produced, low-pass filtering takes samples\n" - " outside the image's data window. This requires\n" - " extrapolating the image. Option -e specifies\n" - " how the image is extrapolated horizontally and\n" - " vertically (black/clamp/periodic/mirror, default\n" - " is clamp).\n" - "\n" - " -t x y sets the tile size in the output image to\n" - " x by y pixels (default is 64 by 64)\n" - "\n" - " -d sets level size rounding to ROUND_DOWN (default)\n" - "\n" - " -u sets level size rounding to ROUND_UP\n" - "\n" - " -z x sets the data compression method to x\n" - " (" << compressionNames.c_str() << ",\n" - " default is zip)\n" - "\n" - " -v verbose mode\n" - "\n" - " -h, --help print this message\n" - "\n" - " --version print version information\n" - "\n" - "Multipart Options:\n" - "\n" - " -p i part number, default is 0\n" - "\n" - "Report bugs via https://github.com/AcademySoftwareFoundation/openexr/issues or email security@openexr.com\n" - ""; + getCompressionNamesString ("/", compressionNames); + + stream + << "\n" + "Read an OpenEXR image from infile, produce a tiled\n" + "version of the image, and save the result in outfile.\n" + "\n" + "Options:\n" + "\n" + " -o produces a ONE_LEVEL image (default)\n" + "\n" + " -m produces a MIPMAP_LEVELS multiresolution image\n" + "\n" + " -r produces a RIPMAP_LEVELS multiresolution image\n" + "\n" + " -f c when a MIPMAP_LEVELS or RIPMAP_LEVELS image\n" + " is produced, image channel c will be resampled\n" + " without low-pass filtering. This option can\n" + " be specified multiple times to disable low-pass\n" + " filtering for multiple channels.\n" + "\n" + " -e x y when a MIPMAP_LEVELS or RIPMAP_LEVELS image\n" + " is produced, low-pass filtering takes samples\n" + " outside the image's data window. This requires\n" + " extrapolating the image. Option -e specifies\n" + " how the image is extrapolated horizontally and\n" + " vertically (black/clamp/periodic/mirror, default\n" + " is clamp).\n" + "\n" + " -t x y sets the tile size in the output image to\n" + " x by y pixels (default is 64 by 64)\n" + "\n" + " -d sets level size rounding to ROUND_DOWN (default)\n" + "\n" + " -u sets level size rounding to ROUND_UP\n" + "\n" + " -z x sets the data compression method to x\n" + " (" + << compressionNames.c_str () + << ",\n" + " default is zip)\n" + "\n" + " -v verbose mode\n" + "\n" + " -h, --help print this message\n" + "\n" + " --version print version information\n" + "\n" + "Multipart Options:\n" + "\n" + " -p i part number, default is 0\n" + "\n" + "Report bugs via https://github.com/AcademySoftwareFoundation/openexr/issues or email security@openexr.com\n" + ""; } } @@ -101,7 +104,7 @@ getCompression (const string& str) { std::stringstream e; e << "Unknown compression method \"" << str << "\""; - throw invalid_argument(e.str()); + throw invalid_argument (e.str ()); } return c; @@ -113,23 +116,14 @@ getExtrapolation (const string& str) Extrapolation e; if (str == "black" || str == "BLACK") { e = BLACK; } - else if (str == "clamp" || str == "CLAMP") - { - e = CLAMP; - } - else if (str == "periodic" || str == "PERIODIC") - { - e = PERIODIC; - } - else if (str == "mirror" || str == "MIRROR") - { - e = MIRROR; - } + else if (str == "clamp" || str == "CLAMP") { e = CLAMP; } + else if (str == "periodic" || str == "PERIODIC") { e = PERIODIC; } + else if (str == "mirror" || str == "MIRROR") { e = MIRROR; } else { std::stringstream e; e << "Unknown extrapolation method \"" << str << "\""; - throw invalid_argument(e.str()); + throw invalid_argument (e.str ()); } return e; @@ -139,7 +133,7 @@ void getPartNum (int argc, char** argv, int& i, int* j) { if (i > argc - 2) - throw invalid_argument("Missing part num with -p option"); + throw invalid_argument ("Missing part num with -p option"); *j = strtol (argv[i + 1], 0, 0); cout << "part number: " << *j << endl; @@ -214,7 +208,8 @@ main (int argc, char** argv) // if (i > argc - 2) - throw invalid_argument("missing filter value with -f option"); + throw invalid_argument ( + "missing filter value with -f option"); doNotFilter.insert (argv[i + 1]); i += 2; @@ -226,7 +221,8 @@ main (int argc, char** argv) // if (i > argc - 3) - throw invalid_argument("missing extrapolation values with -e option"); + throw invalid_argument ( + "missing extrapolation values with -e option"); extX = getExtrapolation (argv[i + 1]); extY = getExtrapolation (argv[i + 2]); @@ -239,13 +235,14 @@ main (int argc, char** argv) // if (i > argc - 3) - throw invalid_argument("missing tile size with -t option"); + throw invalid_argument ("missing tile size with -t option"); tileSizeX = strtol (argv[i + 1], 0, 0); tileSizeY = strtol (argv[i + 2], 0, 0); if (tileSizeX <= 0 || tileSizeY <= 0) - throw invalid_argument("Tile size must be greater than zero"); + throw invalid_argument ( + "Tile size must be greater than zero"); i += 3; } @@ -274,7 +271,8 @@ main (int argc, char** argv) // if (i > argc - 2) - throw invalid_argument("Missing compression value with -z option"); + throw invalid_argument ( + "Missing compression value with -z option"); compression = getCompression (argv[i + 1]); i += 2; @@ -303,13 +301,14 @@ main (int argc, char** argv) } else if (!strcmp (argv[i], "--version")) { - const char* libraryVersion = getLibraryVersion(); - + const char* libraryVersion = getLibraryVersion (); + cout << "exrmaketiled (OpenEXR) " << OPENEXR_VERSION_STRING; - if (strcmp(libraryVersion, OPENEXR_VERSION_STRING)) + if (strcmp (libraryVersion, OPENEXR_VERSION_STRING)) cout << "(OpenEXR version " << libraryVersion << ")"; cout << " https://openexr.com" << endl; - cout << "Copyright (c) Contributors to the OpenEXR Project" << endl; + cout << "Copyright (c) Contributors to the OpenEXR Project" + << endl; cout << "License BSD-3-Clause" << endl; return 0; } @@ -318,12 +317,12 @@ main (int argc, char** argv) // // Image file name // - + if (inFile == 0) inFile = argv[i]; else outFile = argv[i]; - + i += 1; } } @@ -335,7 +334,7 @@ main (int argc, char** argv) } if (!strcmp (inFile, outFile)) - throw invalid_argument("Input and output cannot be the same file"); + throw invalid_argument ("Input and output cannot be the same file"); // // Load inFile, and save a tiled version in outFile. @@ -351,15 +350,14 @@ main (int argc, char** argv) if (partnum < 0 || partnum >= parts) { std::stringstream e; - e << "You asked for part " << partnum << " in " - << inFile + e << "You asked for part " << partnum << " in " << inFile << ", which only has " << parts << " parts"; - throw invalid_argument(e.str()); + throw invalid_argument (e.str ()); } Header h = input.header (partnum); if (h.type () == DEEPTILE || h.type () == DEEPSCANLINE) - throw invalid_argument("Cannot make tile for deep data"); + throw invalid_argument ("Cannot make tile for deep data"); } makeTiled ( diff --git a/src/bin/exrmultipart/exrmultipart.cpp b/src/bin/exrmultipart/exrmultipart.cpp index f641a1e9d8..a657d40a72 100644 --- a/src/bin/exrmultipart/exrmultipart.cpp +++ b/src/bin/exrmultipart/exrmultipart.cpp @@ -154,10 +154,7 @@ parse_filename ( file_name = file_name.substr (0, doublecolon); force_part_name = true; } - else - { - parse_partname (part_name); - } + else { parse_partname (part_name); } size_t colon = file_name.rfind (':'); if (colon == string::npos) @@ -172,10 +169,7 @@ parse_filename ( part_num = atoi (num.c_str ()); file_name = file_name.substr (0, colon); } - else - { - throw invalid_argument("part number must be a number"); - } + else { throw invalid_argument ("part number must be a number"); } } } @@ -192,12 +186,10 @@ make_unique_names (vector
& headers) if (!h.hasName ()) { // We should not be here, we have populated all headers with names. - throw invalid_argument("Software Error: header does not have a valid name"); - } - else - { - base_name = h.name (); + throw invalid_argument ( + "Software Error: header does not have a valid name"); } + else { base_name = h.name (); } // check name has already been used, if so add a _ to it if (names.find (base_name) != names.end ()) @@ -223,7 +215,8 @@ filename_check (vector names, const char* aname) string bname (aname); for (size_t i = 0; i < names.size (); i++) if (bname.compare (names[i]) == 0) - throw invalid_argument("input and output file names cannot be the same"); + throw invalid_argument ( + "input and output file names cannot be the same"); } void @@ -234,13 +227,14 @@ convert ( bool override) { if (in.size () != 1) - throw invalid_argument("can only convert one file at once - use 'combine' mode for multiple files"); + throw invalid_argument ( + "can only convert one file at once - use 'combine' mode for multiple files"); MultiPartInputFile infile (in[0]); - - if (infile.parts () != 1) - throw invalid_argument("can only convert single part EXRs to multipart EXR-2.0 files: use 'split' mode instead"); + if (infile.parts () != 1) + throw invalid_argument ( + "can only convert single part EXRs to multipart EXR-2.0 files: use 'split' mode instead"); vector input_channels; @@ -257,7 +251,7 @@ convert ( vector output_channels = input_channels; // remap channels to multiple output parts int parts = SplitChannels ( - output_channels.begin (), output_channels.end (), true, hero); + output_channels.begin (), output_channels.end (), true, hero); vector
output_headers (parts); vector output_framebuffers (parts); @@ -294,10 +288,9 @@ convert ( ++channel_count; } - Box2i dataWindow = infile.header (0).dataWindow (); - int pixel_count = - (dataWindow.size ().y + 1) * (dataWindow.size ().x + 1); - int pixel_width = dataWindow.size ().x + 1; + Box2i dataWindow = infile.header (0).dataWindow (); + int pixel_count = (dataWindow.size ().y + 1) * (dataWindow.size ().x + 1); + int pixel_width = dataWindow.size ().x + 1; // offset in pixels between base of array and 0,0 int pixel_base = dataWindow.min.y * pixel_width + dataWindow.min.x; @@ -326,24 +319,29 @@ convert ( if (chan.channel ().type == HALF) { samplesize = sizeof (half); } channelstore[i].resize (samplesize * pixel_count); - output_framebuffers[part].insert (output_channels[i].name, - Slice (chan.channel ().type, - &channelstore[i][0] - pixel_base * samplesize, - samplesize, - pixel_width * samplesize)); - - input_framebuffer.insert (input_channels[i].internal_name, - Slice (chan.channel ().type, - &channelstore[i][0] - pixel_base * samplesize, - samplesize, - pixel_width * samplesize)); + output_framebuffers[part].insert ( + output_channels[i].name, + Slice ( + chan.channel ().type, + &channelstore[i][0] - pixel_base * samplesize, + samplesize, + pixel_width * samplesize)); + + input_framebuffer.insert ( + input_channels[i].internal_name, + Slice ( + chan.channel ().type, + &channelstore[i][0] - pixel_base * samplesize, + samplesize, + pixel_width * samplesize)); } // // create output file // - MultiPartOutputFile outfile (outname, &output_headers[0], output_headers.size ()); - + MultiPartOutputFile outfile ( + outname, &output_headers[0], output_headers.size ()); + InputPart inpart (infile, 0); // @@ -430,11 +428,9 @@ combine ( if (partnum >= infile->parts ()) { std::stringstream e; - e << "You asked for part " << partnum << " in " - << in[i] - << ", which only has " << infile->parts () - << " parts"; - throw invalid_argument(e.str()); + e << "You asked for part " << partnum << " in " << in[i] + << ", which only has " << infile->parts () << " parts"; + throw invalid_argument (e.str ()); } //copy header from required part of input to our header array inputs.push_back (infile); @@ -510,7 +506,7 @@ void separate (vector in, const char* out, bool override) { if (in.size () > 1) - throw invalid_argument("-separate only take one input file"); + throw invalid_argument ("-separate only take one input file"); // // parse the multipart input @@ -586,32 +582,38 @@ separate (vector in, const char* out, bool override) void usageMessage (ostream& stream, const char* program_name, bool verbose = false) { - stream << "Usage: " << program_name << "-combine -i input.exr[:partnum][::partname] [input2.exr[:partnum]][::partname] [...] -o outfile.exr [options]\n"; - stream << " or: exrmultipart -separate -i infile.exr -o outfileBaseName [options]\n"; - stream << " or: exrmultipart -convert -i infile.exr -o outfile.exr [options]\n"; + stream + << "Usage: " << program_name + << "-combine -i input.exr[:partnum][::partname] [input2.exr[:partnum]][::partname] [...] -o outfile.exr [options]\n"; + stream + << " or: exrmultipart -separate -i infile.exr -o outfileBaseName [options]\n"; + stream + << " or: exrmultipart -convert -i infile.exr -o outfile.exr [options]\n"; if (verbose) - stream << "\n" - "Combine or split multipart data\n" - "\n" - "Options:\n" - " -override [0/1] 0 = do not override conflicting shared " - " attributes [default]\n" - " 1 = override conflicting shared attributes\n" - " -view name (after specifying -i) assign following inputs to view 'name'\n" - " -h, --help print this message\n" - "\n" - " --version print version information\n" - "\n" - "Report bugs via https://github.com/AcademySoftwareFoundation/openexr/issues or email security@openexr.com\n" - ""; + stream + << "\n" + "Combine or split multipart data\n" + "\n" + "Options:\n" + " -override [0/1] 0 = do not override conflicting shared " + " attributes [default]\n" + " 1 = override conflicting shared attributes\n" + " -view name (after specifying -i) assign following inputs to view 'name'\n" + " -h, --help print this message\n" + "\n" + " --version print version information\n" + "\n" + "Report bugs via https://github.com/AcademySoftwareFoundation/openexr/issues or email security@openexr.com\n" + ""; } int main (int argc, char* argv[]) { - try { - + try + { + vector inFiles; vector views; const char* view = 0; @@ -619,11 +621,12 @@ main (int argc, char* argv[]) bool override = false; int i = 1; - int mode = 0; // 0-do not read input, 1-infiles, 2-outfile, 3-override, 4-view + int mode = + 0; // 0-do not read input, 1-infiles, 2-outfile, 3-override, 4-view while (i < argc) { - if (!strcmp (argv[i], "-h") || !strcmp (argv[i], "--help")) + if (!strcmp (argv[i], "-h") || !strcmp (argv[i], "--help")) { usageMessage (cout, "exrmultipart", true); return 0; @@ -631,33 +634,24 @@ main (int argc, char* argv[]) if (!strcmp (argv[i], "--version")) { - const char* libraryVersion = getLibraryVersion(); - + const char* libraryVersion = getLibraryVersion (); + cout << "exrmultipart (OpenEXR) " << OPENEXR_VERSION_STRING; - if (strcmp(libraryVersion, OPENEXR_VERSION_STRING)) + if (strcmp (libraryVersion, OPENEXR_VERSION_STRING)) cout << "(OpenEXR version " << libraryVersion << ")"; cout << " https://openexr.com" << endl; - cout << "Copyright (c) Contributors to the OpenEXR Project" << endl; + cout << "Copyright (c) Contributors to the OpenEXR Project" + << endl; cout << "License BSD-3-Clause" << endl; return 0; } - if (!strcmp (argv[i], "-i")) - { - mode = 1; - } - else if (!strcmp (argv[i], "-o")) - { - mode = 2; - } - else if (!strcmp (argv[i], "-override")) - { - mode = 3; - } + if (!strcmp (argv[i], "-i")) { mode = 1; } + else if (!strcmp (argv[i], "-o")) { mode = 2; } + else if (!strcmp (argv[i], "-override")) { mode = 3; } else if (!strcmp (argv[i], "-view")) { - if (mode != 1) - throw invalid_argument("-view requires -i"); + if (mode != 1) throw invalid_argument ("-view requires -i"); mode = 4; } @@ -665,16 +659,16 @@ main (int argc, char* argv[]) { switch (mode) { - case 1: - inFiles.push_back (argv[i]); - views.push_back (view); - break; - case 2: outFile = argv[i]; break; - case 3: override = atoi (argv[i]); break; - case 4: - view = argv[i]; - mode = 1; - break; + case 1: + inFiles.push_back (argv[i]); + views.push_back (view); + break; + case 2: outFile = argv[i]; break; + case 3: override = atoi (argv[i]); break; + case 4: + view = argv[i]; + mode = 1; + break; } } i++; @@ -683,7 +677,7 @@ main (int argc, char* argv[]) // check input and output files found or not if (inFiles.size () == 0) { - usageMessage(cerr, argv[0], false); + usageMessage (cerr, argv[0], false); return 1; } @@ -691,13 +685,11 @@ main (int argc, char* argv[]) for (size_t i = 0; i < inFiles.size (); i++) { cout << " " << inFiles[i]; - if (views[i]) - cout << " in view " << views[i]; + if (views[i]) cout << " in view " << views[i]; cout << endl; } - if (!outFile) - throw invalid_argument("No output file specified"); + if (!outFile) throw invalid_argument ("No output file specified"); cout << "output:\n " << outFile << endl; cout << "override:" << override << "\n" << endl; @@ -717,16 +709,13 @@ main (int argc, char* argv[]) cout << "-convert input to EXR2 multipart" << endl; convert (inFiles, views, outFile, override); } - else - { - usageMessage (cerr, argv[0], false); - } + else { usageMessage (cerr, argv[0], false); } } catch (const exception& e) { cerr << argv[0] << ": " << e.what () << endl; return 1; } - + return 0; } diff --git a/src/bin/exrmultiview/Image.h b/src/bin/exrmultiview/Image.h index c739fe96a8..7a0bbf2700 100644 --- a/src/bin/exrmultiview/Image.h +++ b/src/bin/exrmultiview/Image.h @@ -77,10 +77,10 @@ class Image Image (const IMATH_NAMESPACE::Box2i& dataWindow); ~Image (); - Image (const Image& other) = delete; + Image (const Image& other) = delete; Image& operator= (const Image& other) = delete; Image (Image&& other) = delete; - Image& operator= (Image&& other) = delete; + Image& operator= (Image&& other) = delete; const IMATH_NAMESPACE::Box2i& dataWindow () const; void resize (const IMATH_NAMESPACE::Box2i& dataWindow); diff --git a/src/bin/exrmultiview/main.cpp b/src/bin/exrmultiview/main.cpp index c537a1d5c2..65e2125531 100644 --- a/src/bin/exrmultiview/main.cpp +++ b/src/bin/exrmultiview/main.cpp @@ -32,40 +32,45 @@ namespace void usageMessage (ostream& stream, const char* program_name, bool verbose = false) { - stream << "Usage: " << program_name << " [options] viewname1 infile1 viewname2 infile2 ... outfile" << endl; + stream << "Usage: " << program_name + << " [options] viewname1 infile1 viewname2 infile2 ... outfile" + << endl; if (verbose) { std::string compressionNames; - getCompressionNamesString("/", compressionNames); - - stream << "\n" - "Combine two or more single-view OpenEXR image files into\n" - "a single multi-view image file. On the command line,\n" - "each single-view input image is specified together with\n" - "a corresponding view name. The first view on the command\n" - "line becomes the default view. Example:\n" - "\n" - " exrmultiview left imgL.exr right imgR.exr imgLR.exr\n" - "\n" - "Here, imgL.exr and imgR.exr become the left and right\n" - "views in output file imgLR.exr. The left view becomes\n" - "the default view.\n" - "\n" - "Options:\n" - "\n" - " -z x sets the data compression method to x\n" - " (" << compressionNames.c_str() << ",\n" - " default is piz)\n" - "\n" - " -v verbose mode\n" - "\n" - " -h, --help print this message\n" - "\n" - " --version print version information\n" - "\n" - "Report bugs via https://github.com/AcademySoftwareFoundation/openexr/issues or email security@openexr.com\n" - ""; + getCompressionNamesString ("/", compressionNames); + + stream + << "\n" + "Combine two or more single-view OpenEXR image files into\n" + "a single multi-view image file. On the command line,\n" + "each single-view input image is specified together with\n" + "a corresponding view name. The first view on the command\n" + "line becomes the default view. Example:\n" + "\n" + " exrmultiview left imgL.exr right imgR.exr imgLR.exr\n" + "\n" + "Here, imgL.exr and imgR.exr become the left and right\n" + "views in output file imgLR.exr. The left view becomes\n" + "the default view.\n" + "\n" + "Options:\n" + "\n" + " -z x sets the data compression method to x\n" + " (" + << compressionNames.c_str () + << ",\n" + " default is piz)\n" + "\n" + " -v verbose mode\n" + "\n" + " -h, --help print this message\n" + "\n" + " --version print version information\n" + "\n" + "Report bugs via https://github.com/AcademySoftwareFoundation/openexr/issues or email security@openexr.com\n" + ""; } } @@ -78,7 +83,7 @@ getCompression (const string& str) { std::stringstream e; e << "Unknown compression method \"" << str << "\""; - throw invalid_argument(e.str()); + throw invalid_argument (e.str ()); } return c; @@ -105,8 +110,9 @@ main (int argc, char** argv) return -1; } - try { - + try + { + int i = 1; while (i < argc) @@ -118,7 +124,8 @@ main (int argc, char** argv) // if (i > argc - 2) - throw invalid_argument("Missing compression value with -z option"); + throw invalid_argument ( + "Missing compression value with -z option"); compression = getCompression (argv[i + 1]); i += 2; @@ -138,18 +145,19 @@ main (int argc, char** argv) // Print help message // - usageMessage (cout, "exrmultiview" , true); + usageMessage (cout, "exrmultiview", true); return 0; } else if (!strcmp (argv[i], "--version")) { - const char* libraryVersion = getLibraryVersion(); - + const char* libraryVersion = getLibraryVersion (); + cout << "exrmultiview (OpenEXR) " << OPENEXR_VERSION_STRING; - if (strcmp(libraryVersion, OPENEXR_VERSION_STRING)) + if (strcmp (libraryVersion, OPENEXR_VERSION_STRING)) cout << "(OpenEXR version " << libraryVersion << ")"; cout << " https://openexr.com" << endl; - cout << "Copyright (c) Contributors to the OpenEXR Project" << endl; + cout << "Copyright (c) Contributors to the OpenEXR Project" + << endl; cout << "License BSD-3-Clause" << endl; return 0; } @@ -166,7 +174,8 @@ main (int argc, char** argv) // if (outFile) - throw invalid_argument("improper output file specified"); + throw invalid_argument ( + "improper output file specified"); outFile = argv[i]; i += 1; @@ -188,13 +197,12 @@ main (int argc, char** argv) throw invalid_argument ("Must specify at least two views"); if (outFile == 0) - throw invalid_argument("Must specify an output file"); + throw invalid_argument ("Must specify an output file"); // // Load inFiles, and save a combined multi-view image in outFile. // - makeMultiView (views, inFiles, outFile, compression, verbose); } catch (const exception& e) diff --git a/src/bin/exrmultiview/makeMultiView.cpp b/src/bin/exrmultiview/makeMultiView.cpp index 838fd82b82..46d7a4d1e6 100644 --- a/src/bin/exrmultiview/makeMultiView.cpp +++ b/src/bin/exrmultiview/makeMultiView.cpp @@ -71,10 +71,7 @@ makeMultiView ( header = in.header (); if (i == 0) { d = header.dataWindow (); } - else - { - d.extendBy (header.dataWindow ()); - } + else { d.extendBy (header.dataWindow ()); } } image.resize (d); diff --git a/src/bin/exrstdattr/main.cpp b/src/bin/exrstdattr/main.cpp index 636c9a940a..23e4cabeb4 100644 --- a/src/bin/exrstdattr/main.cpp +++ b/src/bin/exrstdattr/main.cpp @@ -50,166 +50,167 @@ usageMessage (ostream& stream, const char* program_name, bool verbose = false) stream << "Usage: " << program_name << " [commands] infile outfile" << endl; if (verbose) - stream << "\n" - "Read OpenEXR image file infile, set the values of one\n" - "or more attributes in the headers of the file, and save\n" - "the result in outfile. Infile and outfile must not refer\n" - "to the same file (the program cannot edit an image file " - "\"in place\").\n" - "\n" - "Command for selecting headers:\n" - "\n" - " -part i\n" - " If i is greater than or equal to zero, and less\n" - " than the number of parts in the input file, then\n" - " the header for part i becomes \"current.\" If i\n" - " is \"any\" or -1, then all headers become current.\n" - " Subsequent attribute setting commands affect only\n" - " the current header or headers. All headers are\n" - " current before the first -part command.\n" - "\n" - " For example, the command sequence\n" - "\n" - " -focus 3 -part 2 -aperture 8 -expTime 0.01 " - "-part any -owner luke\n" - "\n" - " sets the focus and owner attributes in all\n" - " headers, as well as the aperture and expTime\n" - " attributes in the header of part 2.\n" - "\n" - "Commands for setting attribute values:\n" - "\n" - " -chromaticities f f f f f f f f\n" - " CIE xy chromaticities for the red, green\n" - " and blue primaries, and for the white point\n" - " (8 floats)\n" - "\n" - " -whiteLuminance f\n" - " white luminance, in candelas per square meter\n" - " (float, >= 0.0)\n" - "\n" - " -adoptedNeutral f f\n" - " CIE xy coordinates that should be considered\n" - " \"neutral\" during color rendering. Pixels in\n" - " the image file whose xy coordinates match the\n" - " adoptedNeutral value should be mapped to neutral\n" - " values on the display. (2 floats)\n" - "\n" - " -renderingTransform s\n" - " name of the CTL rendering transform for this\n" - " image (string). This attribute is deprecated.\n" - "\n" - " -lookModTransform s\n" - " name of the CTL look modification transform for\n" - " this image (string). This attribute is deprecated.\n" - "\n" - " -xDensity f\n" - " horizontal output density, in pixels per inch\n" - " (float, >= 0.0)\n" - "\n" - " -owner s\n" - " name of the owner of the image (string)\n" - "\n" - " -comments s\n" - " additional information about the image (string)\n" - "\n" - " -capDate s\n" - " date when the image was created or\n" - " captured, in local time (string,\n" - " formatted as YYYY:MM:DD hh:mm:ss)\n" - "\n" - " -utcOffset f\n" - " offset of local time at capDate from UTC, in\n" - " seconds (float, UTC == local time + x)\n" - "\n" - " -longitude f\n" - " -latitude f\n" - " -altitude f\n" - " location where the image was recorded, in\n" - " degrees east of Greenwich and north of the\n" - " equator, and in meters above sea level\n" - " (float)\n" - "\n" - " -focus f\n" - " the camera's focus distance, in meters\n" - " (float, > 0, or \"infinity\")\n" - "\n" - " -expTime f\n" - " exposure time, in seconds (float, >= 0)\n" - "\n" - " -aperture f\n" - " lens apterture, in f-stops (float, >= 0)\n" - "\n" - " -isoSpeed f\n" - " effective speed of the film or image\n" - " sensor that was used to record the image\n" - " (float, >= 0)\n" - "\n" - " -envmap s\n" - " indicates that the image is an environment map\n" - " (string, LATLONG or CUBE)\n" - "\n" - " -framesPerSecond i i\n" - " playback frame rate expressed as a ratio of two\n" - " integers, n and d (the frame rate is n/d frames\n" - " per second)\n" - "\n" - " -keyCode i i i i i i i\n" - " key code that uniquely identifies a motion\n" - " picture film frame using 7 integers:\n" - " * film manufacturer code (0 - 99)\n" - " * film type code (0 - 99)\n" - " * prefix to identify film roll (0 - 999999)\n" - " * count, increments once every perfsPerCount\n" - " perforations (0 - 9999)\n" - " * offset of frame, in perforations from\n" - " zero-frame reference mark (0 - 119)\n" - " * number of perforations per frame (1 - 15)\n" - " * number of perforations per count (20 - 120)\n" - "\n" - " -timeCode i i\n" - " SMPTE time and control code, specified as a pair\n" - " of 8-digit base-16 integers. The first number\n" - " contains the time address and flags (drop frame,\n" - " color frame, field/phase, bgf0, bgf1, bgf2).\n" - " The second number contains the user data and\n" - " control codes.\n" - "\n" - " -wrapmodes s\n" - " if the image is used as a texture map, specifies\n" - " how the image should be extrapolated outside the\n" - " zero-to-one texture coordinate range\n" - " (string, e.g. \"clamp\" or \"periodic,clamp\")\n" - "\n" - " -pixelAspectRatio f\n" - " width divided by height of a pixel\n" - " (float, >= 0)\n" - "\n" - " -screenWindowWidth f\n" - " width of the screen window (float, >= 0)\n" - "\n" - " -screenWindowCenter f f\n" - " center of the screen window (2 floats)\n" - "\n" - " -string s s\n" - " custom string attribute\n" - " (2 strings, attribute name and value)\n" - "\n" - " -float s f\n" - " custom float attribute (string + float,\n" - " attribute name and value)\n" - "\n" - " -int s i\n" - " custom integer attribute (string + integer,\n" - " attribute name and value)\n" - "\n" - "Other options:\n" - "\n" - " -h, --help print this message\n" - " --version print version information\n" - "\n" - "Report bugs via https://github.com/AcademySoftwareFoundation/openexr/issues or email security@openexr.com\n" - ""; + stream + << "\n" + "Read OpenEXR image file infile, set the values of one\n" + "or more attributes in the headers of the file, and save\n" + "the result in outfile. Infile and outfile must not refer\n" + "to the same file (the program cannot edit an image file " + "\"in place\").\n" + "\n" + "Command for selecting headers:\n" + "\n" + " -part i\n" + " If i is greater than or equal to zero, and less\n" + " than the number of parts in the input file, then\n" + " the header for part i becomes \"current.\" If i\n" + " is \"any\" or -1, then all headers become current.\n" + " Subsequent attribute setting commands affect only\n" + " the current header or headers. All headers are\n" + " current before the first -part command.\n" + "\n" + " For example, the command sequence\n" + "\n" + " -focus 3 -part 2 -aperture 8 -expTime 0.01 " + "-part any -owner luke\n" + "\n" + " sets the focus and owner attributes in all\n" + " headers, as well as the aperture and expTime\n" + " attributes in the header of part 2.\n" + "\n" + "Commands for setting attribute values:\n" + "\n" + " -chromaticities f f f f f f f f\n" + " CIE xy chromaticities for the red, green\n" + " and blue primaries, and for the white point\n" + " (8 floats)\n" + "\n" + " -whiteLuminance f\n" + " white luminance, in candelas per square meter\n" + " (float, >= 0.0)\n" + "\n" + " -adoptedNeutral f f\n" + " CIE xy coordinates that should be considered\n" + " \"neutral\" during color rendering. Pixels in\n" + " the image file whose xy coordinates match the\n" + " adoptedNeutral value should be mapped to neutral\n" + " values on the display. (2 floats)\n" + "\n" + " -renderingTransform s\n" + " name of the CTL rendering transform for this\n" + " image (string). This attribute is deprecated.\n" + "\n" + " -lookModTransform s\n" + " name of the CTL look modification transform for\n" + " this image (string). This attribute is deprecated.\n" + "\n" + " -xDensity f\n" + " horizontal output density, in pixels per inch\n" + " (float, >= 0.0)\n" + "\n" + " -owner s\n" + " name of the owner of the image (string)\n" + "\n" + " -comments s\n" + " additional information about the image (string)\n" + "\n" + " -capDate s\n" + " date when the image was created or\n" + " captured, in local time (string,\n" + " formatted as YYYY:MM:DD hh:mm:ss)\n" + "\n" + " -utcOffset f\n" + " offset of local time at capDate from UTC, in\n" + " seconds (float, UTC == local time + x)\n" + "\n" + " -longitude f\n" + " -latitude f\n" + " -altitude f\n" + " location where the image was recorded, in\n" + " degrees east of Greenwich and north of the\n" + " equator, and in meters above sea level\n" + " (float)\n" + "\n" + " -focus f\n" + " the camera's focus distance, in meters\n" + " (float, > 0, or \"infinity\")\n" + "\n" + " -expTime f\n" + " exposure time, in seconds (float, >= 0)\n" + "\n" + " -aperture f\n" + " lens apterture, in f-stops (float, >= 0)\n" + "\n" + " -isoSpeed f\n" + " effective speed of the film or image\n" + " sensor that was used to record the image\n" + " (float, >= 0)\n" + "\n" + " -envmap s\n" + " indicates that the image is an environment map\n" + " (string, LATLONG or CUBE)\n" + "\n" + " -framesPerSecond i i\n" + " playback frame rate expressed as a ratio of two\n" + " integers, n and d (the frame rate is n/d frames\n" + " per second)\n" + "\n" + " -keyCode i i i i i i i\n" + " key code that uniquely identifies a motion\n" + " picture film frame using 7 integers:\n" + " * film manufacturer code (0 - 99)\n" + " * film type code (0 - 99)\n" + " * prefix to identify film roll (0 - 999999)\n" + " * count, increments once every perfsPerCount\n" + " perforations (0 - 9999)\n" + " * offset of frame, in perforations from\n" + " zero-frame reference mark (0 - 119)\n" + " * number of perforations per frame (1 - 15)\n" + " * number of perforations per count (20 - 120)\n" + "\n" + " -timeCode i i\n" + " SMPTE time and control code, specified as a pair\n" + " of 8-digit base-16 integers. The first number\n" + " contains the time address and flags (drop frame,\n" + " color frame, field/phase, bgf0, bgf1, bgf2).\n" + " The second number contains the user data and\n" + " control codes.\n" + "\n" + " -wrapmodes s\n" + " if the image is used as a texture map, specifies\n" + " how the image should be extrapolated outside the\n" + " zero-to-one texture coordinate range\n" + " (string, e.g. \"clamp\" or \"periodic,clamp\")\n" + "\n" + " -pixelAspectRatio f\n" + " width divided by height of a pixel\n" + " (float, >= 0)\n" + "\n" + " -screenWindowWidth f\n" + " width of the screen window (float, >= 0)\n" + "\n" + " -screenWindowCenter f f\n" + " center of the screen window (2 floats)\n" + "\n" + " -string s s\n" + " custom string attribute\n" + " (2 strings, attribute name and value)\n" + "\n" + " -float s f\n" + " custom float attribute (string + float,\n" + " attribute name and value)\n" + "\n" + " -int s i\n" + " custom integer attribute (string + integer,\n" + " attribute name and value)\n" + "\n" + "Other options:\n" + "\n" + " -h, --help print this message\n" + " --version print version information\n" + "\n" + "Report bugs via https://github.com/AcademySoftwareFoundation/openexr/issues or email security@openexr.com\n" + ""; } struct SetAttr @@ -233,7 +234,7 @@ isNonNegative (const char attrName[], float f) std::stringstream e; e << "The value for the " << attrName << " attribute must not be less than zero"; - throw invalid_argument(e.str()); + throw invalid_argument (e.str ()); } } @@ -245,7 +246,7 @@ isPositive (const char attrName[], float f) std::stringstream e; e << "The value for the " << attrName << " attribute must be greater than zero"; - throw invalid_argument(e.str()); + throw invalid_argument (e.str ()); } } @@ -255,7 +256,7 @@ notValidDate (const char attrName[]) std::stringstream e; e << "The value for the " << attrName << " attribute is not a valid date of the form \"YYYY:MM:DD yy:mm:ss\""; - throw invalid_argument(e.str()); + throw invalid_argument (e.str ()); } int @@ -326,8 +327,7 @@ getFloat ( SetAttrVector& attrs, void (*check) (const char attrName[], float f) = 0) { - if (i > argc - 2) - throw invalid_argument("Expected a float"); + if (i > argc - 2) throw invalid_argument ("Expected a float"); float f = static_cast (strtod (argv[i + 1], 0)); @@ -347,8 +347,8 @@ getPosFloatOrInf ( SetAttrVector& attrs) { if (i > argc - 2) - throw invalid_argument("Expected a positive float (or \"infinity\")"); - + throw invalid_argument ("Expected a positive float (or \"infinity\")"); + float f; if (!strcmp (argv[i + 1], "inf") || !strcmp (argv[i + 1], "infinity")) @@ -364,7 +364,7 @@ getPosFloatOrInf ( std::stringstream e; e << "The value for the " << attrName << " attribute must be greater than zero, or \"infinity\""; - throw invalid_argument(e.str()); + throw invalid_argument (e.str ()); } } @@ -382,8 +382,7 @@ getV2f ( SetAttrVector& attrs, void (*check) (const char attrName[], const V2f& v) = 0) { - if (i > argc - 3) - throw invalid_argument ("Expected two floats"); + if (i > argc - 3) throw invalid_argument ("Expected two floats"); V2f v ( static_cast (strtod (argv[i + 1], 0)), @@ -405,8 +404,7 @@ getRational ( SetAttrVector& attrs, void (*check) (const char attrName[], const Rational& r) = 0) { - if (i > argc - 3) - throw invalid_argument("Expected a rational"); + if (i > argc - 3) throw invalid_argument ("Expected a rational"); Rational r (strtol (argv[i + 1], 0, 0), strtol (argv[i + 2], 0, 0)); @@ -426,8 +424,7 @@ getString ( SetAttrVector& attrs, void (*check) (const char attrName[], const char str[]) = 0) { - if (i > argc - 2) - throw invalid_argument("Expected a string"); + if (i > argc - 2) throw invalid_argument ("Expected a string"); const char* str = argv[i + 1]; @@ -440,8 +437,7 @@ getString ( void getNameAndString (int argc, char** argv, int& i, int part, SetAttrVector& attrs) { - if (i > argc - 3) - throw invalid_argument("Expected a name and string"); + if (i > argc - 3) throw invalid_argument ("Expected a name and string"); const char* attrName = argv[i + 1]; const char* str = argv[i + 2]; @@ -452,8 +448,7 @@ getNameAndString (int argc, char** argv, int& i, int part, SetAttrVector& attrs) void getNameAndFloat (int argc, char** argv, int& i, int part, SetAttrVector& attrs) { - if (i > argc - 3) - throw invalid_argument("Expected a name and a float"); + if (i > argc - 3) throw invalid_argument ("Expected a name and a float"); const char* attrName = argv[i + 1]; float f = static_cast (strtod (argv[i + 2], 0)); @@ -464,8 +459,7 @@ getNameAndFloat (int argc, char** argv, int& i, int part, SetAttrVector& attrs) void getNameAndInt (int argc, char** argv, int& i, int part, SetAttrVector& attrs) { - if (i > argc - 3) - throw invalid_argument("Expected a name and an integer"); + if (i > argc - 3) throw invalid_argument ("Expected a name and an integer"); const char* attrName = argv[i + 1]; int j = strtol (argv[i + 2], 0, 0); @@ -482,10 +476,10 @@ getChromaticities ( int part, SetAttrVector& attrs) { - if (i > argc - 9) - throw invalid_argument("Expected 8 chromaticity values"); + if (i > argc - 9) throw invalid_argument ("Expected 8 chromaticity values"); - ChromaticitiesAttribute* a = new ChromaticitiesAttribute(Chromaticities()); + ChromaticitiesAttribute* a = + new ChromaticitiesAttribute (Chromaticities ()); attrs.push_back (SetAttr (attrName, part, a)); a->value ().red.x = static_cast (strtod (argv[i + 1], 0)); @@ -508,8 +502,7 @@ getEnvmap ( int part, SetAttrVector& attrs) { - if (i > argc - 2) - throw invalid_argument("Expected an env map"); + if (i > argc - 2) throw invalid_argument ("Expected an env map"); char* str = argv[i + 1]; Envmap type; @@ -527,7 +520,7 @@ getEnvmap ( std::stringstream e; e << "The value for the " << attrName << " attribute must be either LATLONG or CUBE"; - throw invalid_argument(e.str()); + throw invalid_argument (e.str ()); } attrs.push_back (SetAttr (attrName, part, new EnvmapAttribute (type))); @@ -543,8 +536,7 @@ getKeyCode ( int part, SetAttrVector& attrs) { - if (i > argc - 8) - throw invalid_argument("Expected a key code"); + if (i > argc - 8) throw invalid_argument ("Expected a key code"); KeyCodeAttribute* a = new KeyCodeAttribute; attrs.push_back (SetAttr (attrName, part, a)); @@ -568,8 +560,7 @@ getTimeCode ( int part, SetAttrVector& attrs) { - if (i > argc - 3) - throw invalid_argument("Expected a time code"); + if (i > argc - 3) throw invalid_argument ("Expected a time code"); TimeCodeAttribute* a = new TimeCodeAttribute; attrs.push_back (SetAttr (attrName, part, a)); @@ -583,7 +574,7 @@ void getPart (const char attrName[], int argc, char** argv, int& i, int& part) { if (i > argc - 2) - throw invalid_argument("Expected a part number (or \"any\")"); + throw invalid_argument ("Expected a part number (or \"any\")"); if (!strcmp (argv[i + 1], "any")) part = -1; @@ -742,13 +733,14 @@ main (int argc, char** argv) } else if (!strcmp (argv[i], "--version")) { - const char* libraryVersion = getLibraryVersion(); - + const char* libraryVersion = getLibraryVersion (); + cout << "exrstdattr (OpenEXR) " << OPENEXR_VERSION_STRING; - if (strcmp(libraryVersion, OPENEXR_VERSION_STRING)) + if (strcmp (libraryVersion, OPENEXR_VERSION_STRING)) cout << "(OpenEXR version " << libraryVersion << ")"; cout << " https://openexr.com" << endl; - cout << "Copyright (c) Contributors to the OpenEXR Project" << endl; + cout << "Copyright (c) Contributors to the OpenEXR Project" + << endl; cout << "License BSD-3-Clause" << endl; return 0; @@ -764,13 +756,11 @@ main (int argc, char** argv) } } - if (inFileName == 0) - throw invalid_argument("Missing input filename"); - if (outFileName == 0) - throw invalid_argument("Missing input filename"); + if (inFileName == 0) throw invalid_argument ("Missing input filename"); + if (outFileName == 0) throw invalid_argument ("Missing input filename"); if (!strcmp (inFileName, outFileName)) - throw invalid_argument("Input and output cannot be the same file"); + throw invalid_argument ("Input and output cannot be the same file"); // // Load the headers from the input file @@ -849,7 +839,7 @@ main (int argc, char** argv) } } - for (size_t i=0; i testDataZ; -Array2D testDataA; +Array2D testDataA; -void getPixelSampleData( - int i, - int j, - Array2D& dataZ, - Array2D& dataA) +void +getPixelSampleData (int i, int j, Array2D& dataZ, Array2D& dataA) { // Dummy code creating deep data from a flat image dataZ[i][j][0] = testDataZ[i][j]; @@ -160,7 +161,7 @@ writeDeepScanlineFile ( // - describe the memory layout of the A and Z pixels // - store the pixels in the file // - + int height = dataWindow.max.y - dataWindow.min.y + 1; int width = dataWindow.max.x - dataWindow.min.x + 1; @@ -177,7 +178,8 @@ writeDeepScanlineFile ( frameBuffer.insertSampleCountSlice (Slice ( UINT, - (char*) (&sampleCount[0][0] - dataWindow.min.x - dataWindow.min.y * width), + (char*) (&sampleCount[0][0] - dataWindow.min.x - + dataWindow.min.y * width), sizeof (unsigned int) * 1, // xS sizeof (unsigned int) * width)); // yStride @@ -186,7 +188,8 @@ writeDeepScanlineFile ( "Z", DeepSlice ( FLOAT, - (char*) (&dataZ[0][0] - dataWindow.min.x - dataWindow.min.y * width), + (char*) (&dataZ[0][0] - dataWindow.min.x - + dataWindow.min.y * width), sizeof (float*) * 1, // xStride for pointer sizeof (float*) * width, // yStride for pointer array @@ -196,7 +199,8 @@ writeDeepScanlineFile ( "A", DeepSlice ( HALF, - (char*) (&dataA[0][0] - dataWindow.min.x - dataWindow.min.y * width), + (char*) (&dataA[0][0] - dataWindow.min.x - + dataWindow.min.y * width), sizeof (half*) * 1, // xStride for pointer array sizeof (half*) * width, // yStride for pointer array sizeof (half) * 1)); // stride for A data sample @@ -211,7 +215,7 @@ writeDeepScanlineFile ( dataZ[i][j] = new float[sampleCount[i][j]]; dataA[i][j] = new half[sampleCount[i][j]]; // Generate data for dataZ and dataA. - getPixelSampleData(i, j, dataZ, dataA); + getPixelSampleData (i, j, dataZ, dataA); } file.writePixels (1); @@ -227,30 +231,32 @@ writeDeepScanlineFile ( } } - -void deepExamples() +void +deepExamples () { int w = 800; int h = 600; - + Box2i window; - window.min.setValue(0, 0); - window.max.setValue(w - 1, h - 1); - - Array2D dataZ; - dataZ.resizeErase(h, w); - - Array2D dataA; - dataA.resizeErase(h, w); - + window.min.setValue (0, 0); + window.max.setValue (w - 1, h - 1); + + Array2D dataZ; + dataZ.resizeErase (h, w); + + Array2D dataA; + dataA.resizeErase (h, w); + Array2D sampleCount; - sampleCount.resizeErase(h, w); - + sampleCount.resizeErase (h, w); + // Create an image to be used as a source for deep data - testDataA.resizeErase(h, w); - testDataZ.resizeErase(h, w); - drawImage2(testDataA, testDataZ, w, h); - - writeDeepScanlineFile("test.deep.exr", window, window, dataZ, dataA, sampleCount); - readDeepScanlineFile ("test.deep.exr", window, window, dataZ, dataA, sampleCount); + testDataA.resizeErase (h, w); + testDataZ.resizeErase (h, w); + drawImage2 (testDataA, testDataZ, w, h); + + writeDeepScanlineFile ( + "test.deep.exr", window, window, dataZ, dataA, sampleCount); + readDeepScanlineFile ( + "test.deep.exr", window, window, dataZ, dataA, sampleCount); } diff --git a/src/examples/deepTiledExamples.cpp b/src/examples/deepTiledExamples.cpp index d6ec256361..acf04d0520 100644 --- a/src/examples/deepTiledExamples.cpp +++ b/src/examples/deepTiledExamples.cpp @@ -28,17 +28,12 @@ using namespace IMF; using namespace std; using namespace IMATH_NAMESPACE; - // defined in deepExamples.cpp extern Array2D testDataZ; -extern Array2D testDataA; -extern unsigned int getPixelSampleCount (int i, int j); -extern void getPixelSampleData( - int i, - int j, - Array2D& dataZ, - Array2D& dataA); - +extern Array2D testDataA; +extern unsigned int getPixelSampleCount (int i, int j); +extern void getPixelSampleData ( + int i, int j, Array2D& dataZ, Array2D& dataA); void readDeepTiledFile ( @@ -62,49 +57,52 @@ readDeepTiledFile ( // - allocate the memory requred to store the samples // - read the pixels from the file // - + DeepTiledInputFile file (filename); - + int width = dataWindow.max.x - dataWindow.min.x + 1; int height = dataWindow.max.y - dataWindow.min.y + 1; - + sampleCount.resizeErase (height, width); dataZ.resizeErase (height, width); dataA.resizeErase (height, width); - + DeepFrameBuffer frameBuffer; - + frameBuffer.insertSampleCountSlice (Slice ( UINT, - (char*) (&sampleCount[0][0] - dataWindow.min.x - dataWindow.min.y * width), + (char*) (&sampleCount[0][0] - dataWindow.min.x - + dataWindow.min.y * width), sizeof (unsigned int) * 1, // xStride sizeof (unsigned int) * width)); // yStride - + frameBuffer.insert ( "Z", DeepSlice ( FLOAT, - (char*) (&dataZ[0][0] - dataWindow.min.x - dataWindow.min.y * width), + (char*) (&dataZ[0][0] - dataWindow.min.x - + dataWindow.min.y * width), sizeof (float*) * 1, // xStride for pointer array sizeof (float*) * width, // yStride for pointer array sizeof (float) * 1)); // stride for samples - + frameBuffer.insert ( "A", DeepSlice ( HALF, - (char*) (&dataA[0][0] - dataWindow.min.x - dataWindow.min.y * width), + (char*) (&dataA[0][0] - dataWindow.min.x - + dataWindow.min.y * width), sizeof (half*) * 1, // xStride for pointer array sizeof (half*) * width, // yStride for pointer array sizeof (half) * 1)); // stride for samples - + file.setFrameBuffer (frameBuffer); - + int numXTiles = file.numXTiles (0); int numYTiles = file.numYTiles (0); - + file.readPixelSampleCounts (0, numXTiles - 1, 0, numYTiles - 1); - + for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) @@ -113,11 +111,11 @@ readDeepTiledFile ( dataA[i][j] = new half[sampleCount[i][j]]; } } - + file.readTiles (0, numXTiles - 1, 0, numYTiles - 1); - + // (after read data is processed, data must be freed:) - + for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) @@ -128,31 +126,32 @@ readDeepTiledFile ( } } -void getSampleDataForTile ( - int i, - int j, - int tileSizeX, - int tileSizeY, - Array2D& sampleCount, - Array2D& dataZ, - Array2D& dataA) +void +getSampleDataForTile ( + int i, + int j, + int tileSizeX, + int tileSizeY, + Array2D& sampleCount, + Array2D& dataZ, + Array2D& dataA) { for (int k = 0; k < tileSizeY; k++) { int y = j * tileSizeY + k; - if (y >= sampleCount.height()) break; - + if (y >= sampleCount.height ()) break; + for (int l = 0; l < tileSizeX; l++) { int x = i * tileSizeX + l; - if (x >= sampleCount.width()) break; - - sampleCount[y][x] = getPixelSampleCount(y, x); - + if (x >= sampleCount.width ()) break; + + sampleCount[y][x] = getPixelSampleCount (y, x); + dataZ[y][x] = new float[sampleCount[y][x]]; - dataA[y][x] = new half [sampleCount[y][x]]; - - getPixelSampleData(y, x, dataZ, dataA); + dataA[y][x] = new half[sampleCount[y][x]]; + + getPixelSampleData (y, x, dataZ, dataA); } } } @@ -175,7 +174,7 @@ writeDeepTiledFile ( // - describe the memory layout of the A and Z pixels // - store the pixels in the file // - + int height = dataWindow.max.y - dataWindow.min.y + 1; int width = dataWindow.max.x - dataWindow.min.x + 1; @@ -203,7 +202,8 @@ writeDeepTiledFile ( frameBuffer.insertSampleCountSlice (Slice ( UINT, - (char*) (&sampleCount[0][0] - dataWindow.min.x - dataWindow.min.y * width), + (char*) (&sampleCount[0][0] - dataWindow.min.x - + dataWindow.min.y * width), sizeof (unsigned int) * 1, // xStride sizeof (unsigned int) * width)); // yStride @@ -211,7 +211,8 @@ writeDeepTiledFile ( "Z", DeepSlice ( FLOAT, - (char*) (&dataZ[0][0] - dataWindow.min.x - dataWindow.min.y * width), + (char*) (&dataZ[0][0] - dataWindow.min.x - + dataWindow.min.y * width), sizeof (float*) * 1, // xStride for pointer array sizeof (float*) * width, // yStride for pointer array sizeof (float) * 1)); // stride for samples @@ -220,7 +221,8 @@ writeDeepTiledFile ( "A", DeepSlice ( HALF, - (char*) (&dataA[0][0] - dataWindow.min.x - dataWindow.min.y * width), + (char*) (&dataA[0][0] - dataWindow.min.x - + dataWindow.min.y * width), sizeof (half*) * 1, // xStride for pointer array sizeof (half*) * width, // yStride for pointer array sizeof (half) * 1)); // stride for samples @@ -232,11 +234,12 @@ writeDeepTiledFile ( for (int i = 0; i < file.numXTiles (0); i++) { // Generate data for sampleCount, dataZ and dataA. - getSampleDataForTile (i, j, tileSizeX, tileSizeY, sampleCount, dataZ, dataA); + getSampleDataForTile ( + i, j, tileSizeX, tileSizeY, sampleCount, dataZ, dataA); file.writeTile (i, j, 0); } } - + for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) @@ -247,32 +250,35 @@ writeDeepTiledFile ( } } -void deepTiledExamples() +void +deepTiledExamples () { int w = 800; int h = 600; - + int tileSizeX = 64; int tileSizeY = 64; - + Box2i window; - window.min.setValue(0, 0); - window.max.setValue(w - 1, h - 1); - - Array2D dataZ; - dataZ.resizeErase(h, w); - - Array2D dataA; - dataA.resizeErase(h, w); - + window.min.setValue (0, 0); + window.max.setValue (w - 1, h - 1); + + Array2D dataZ; + dataZ.resizeErase (h, w); + + Array2D dataA; + dataA.resizeErase (h, w); + Array2D sampleCount; - sampleCount.resizeErase(h, w); - + sampleCount.resizeErase (h, w); + // Create an image to be used as a source for deep data - testDataA.resizeErase(h, w); - testDataZ.resizeErase(h, w); - drawImage2(testDataA, testDataZ, w, h); - - writeDeepTiledFile("testTiled.deep.exr", window, window, tileSizeX, tileSizeY); - readDeepTiledFile ("testTiled.deep.exr", window, window, dataZ, dataA, sampleCount); + testDataA.resizeErase (h, w); + testDataZ.resizeErase (h, w); + drawImage2 (testDataA, testDataZ, w, h); + + writeDeepTiledFile ( + "testTiled.deep.exr", window, window, tileSizeX, tileSizeY); + readDeepTiledFile ( + "testTiled.deep.exr", window, window, dataZ, dataA, sampleCount); } diff --git a/src/examples/deepidexample.cpp b/src/examples/deepidexample.cpp index 50e9c90b4d..de6454dfcc 100644 --- a/src/examples/deepidexample.cpp +++ b/src/examples/deepidexample.cpp @@ -35,13 +35,17 @@ using std::vector; void printHelp () { + cerr << "syntax: deepidexample options output.deep.exr\n\n"; cerr - << "syntax: deepidexample options output.deep.exr\n\n"; - cerr << "--multivariate : combine 'material' and 'model' name into a single ID channel, rather than separate channels\n"; - cerr << "--64 : use 64 bit hashes in two channels, rather than a single channel 32 bit hash\n"; - cerr << "--frame number : specify animation frame number. Animation cycles every 200 frames\n"; - cerr << "--objectid : store object ids in a simple stringvector format rather than the idmanifest attribute\n"; - cerr << "--size width height : specify image dimensions for output (default 256 256)\n"; + << "--multivariate : combine 'material' and 'model' name into a single ID channel, rather than separate channels\n"; + cerr + << "--64 : use 64 bit hashes in two channels, rather than a single channel 32 bit hash\n"; + cerr + << "--frame number : specify animation frame number. Animation cycles every 200 frames\n"; + cerr + << "--objectid : store object ids in a simple stringvector format rather than the idmanifest attribute\n"; + cerr + << "--size width height : specify image dimensions for output (default 256 256)\n"; cerr << "--count number : number of objects to write (default 100)\n"; } @@ -56,7 +60,7 @@ struct Rgbaz // // depth sort (use ID to resolve ties) // - bool operator<(const Rgbaz& other) const + bool operator< (const Rgbaz& other) const { if (z < other.z) { return true; } if (z > other.z) { return false; } diff --git a/src/examples/generalInterfaceExamples.cpp b/src/examples/generalInterfaceExamples.cpp index 87c75c0279..65b479b9d9 100644 --- a/src/examples/generalInterfaceExamples.cpp +++ b/src/examples/generalInterfaceExamples.cpp @@ -162,35 +162,41 @@ readGZ1 ( FrameBuffer frameBuffer; - frameBuffer.insert ("R", // name - Slice (IMF::HALF, // type - (char *) (&rPixels[0][0] - // base - dw.min.x - - dw.min.y * width), - sizeof (rPixels[0][0]) * 1, // xStride - sizeof (rPixels[0][0]) * width, // yStride - 1, 1, // x/y sampling - 0.0)); // fillValue - - frameBuffer.insert ("G", // name - Slice (IMF::HALF, // type - (char *) (&gPixels[0][0] - // base - dw.min.x - - dw.min.y * width), - sizeof (gPixels[0][0]) * 1, // xStride - sizeof (gPixels[0][0]) * width, // yStride - 1, 1, // x/y sampling - 0.0)); // fillValue - - frameBuffer.insert ("Z", // name - Slice (IMF::FLOAT, // type - (char *) (&zPixels[0][0] - // base - dw.min.x - - dw.min.y * width), - sizeof (zPixels[0][0]) * 1, // xStride - sizeof (zPixels[0][0]) * width, // yStride - 1, 1, // x/y sampling - std::numeric_limits::max())); // fillValue + frameBuffer.insert ( + "R", // name + Slice ( + IMF::HALF, // type + (char*) (&rPixels[0][0] - // base + dw.min.x - dw.min.y * width), + sizeof (rPixels[0][0]) * 1, // xStride + sizeof (rPixels[0][0]) * width, // yStride + 1, + 1, // x/y sampling + 0.0)); // fillValue + + frameBuffer.insert ( + "G", // name + Slice ( + IMF::HALF, // type + (char*) (&gPixels[0][0] - // base + dw.min.x - dw.min.y * width), + sizeof (gPixels[0][0]) * 1, // xStride + sizeof (gPixels[0][0]) * width, // yStride + 1, + 1, // x/y sampling + 0.0)); // fillValue + + frameBuffer.insert ( + "Z", // name + Slice ( + IMF::FLOAT, // type + (char*) (&zPixels[0][0] - // base + dw.min.x - dw.min.y * width), + sizeof (zPixels[0][0]) * 1, // xStride + sizeof (zPixels[0][0]) * width, // yStride + 1, + 1, // x/y sampling + std::numeric_limits::max ())); // fillValue file.setFrameBuffer (frameBuffer); file.readPixels (dw.min.y, dw.max.y); diff --git a/src/examples/main.cpp b/src/examples/main.cpp index a1c2af830e..afa3d882a6 100644 --- a/src/examples/main.cpp +++ b/src/examples/main.cpp @@ -33,7 +33,7 @@ main (int argc, char* argv[]) lowLevelIoExamples (); previewImageExamples (); - + // This example uses the files created by // generalInterfaceExamples, // generalInterfaceTiledExamples, diff --git a/src/examples/multipartExamples.cpp b/src/examples/multipartExamples.cpp index 88b26cf184..bff58c34ae 100644 --- a/src/examples/multipartExamples.cpp +++ b/src/examples/multipartExamples.cpp @@ -40,213 +40,238 @@ using namespace IMF; using namespace std; using namespace IMATH_NAMESPACE; - template -void copyPixels ( - MultiPartInputFile & inputFile, - MultiPartOutputFile & outputFile, - int inputPartNumber, - int outputPartNumber) +void +copyPixels ( + MultiPartInputFile& inputFile, + MultiPartOutputFile& outputFile, + int inputPartNumber, + int outputPartNumber) { - InputPartType inPart (inputFile, inputPartNumber); + InputPartType inPart (inputFile, inputPartNumber); OutputPartType outPart (outputFile, outputPartNumber); outPart.copyPixels (inPart); } -void copyPixels( - const std::string & type, - MultiPartInputFile & inputFile, - MultiPartOutputFile & outputFile, - int inputPartNumber, - int outputPartNumber) +void +copyPixels ( + const std::string& type, + MultiPartInputFile& inputFile, + MultiPartOutputFile& outputFile, + int inputPartNumber, + int outputPartNumber) { // // Copy pixels from a given part of a multipart input file // to a given part of a multipart output file. // - + if (type == SCANLINEIMAGE) { - copyPixels (inputFile, outputFile, inputPartNumber, outputPartNumber); + copyPixels ( + inputFile, outputFile, inputPartNumber, outputPartNumber); } else if (type == TILEDIMAGE) { - copyPixels (inputFile, outputFile, inputPartNumber, outputPartNumber); + copyPixels ( + inputFile, outputFile, inputPartNumber, outputPartNumber); } else if (type == DEEPSCANLINE) { - copyPixels (inputFile, outputFile, inputPartNumber, outputPartNumber); + copyPixels ( + inputFile, outputFile, inputPartNumber, outputPartNumber); } else if (type == DEEPTILE) { - copyPixels (inputFile, outputFile, inputPartNumber, outputPartNumber); + copyPixels ( + inputFile, outputFile, inputPartNumber, outputPartNumber); } } -void combineFiles () +void +combineFiles () { // // Read multiple single-part input files and write them as a multi-part file. // If an input file is multi-part, only one part is copied. // All input files dimentions must be the same. // - - std::vector inputFiles; - std::vector
headers; - - const char * filenames[] = {"gz1.exr", "tiledgz1.exr", "test.deep.exr", "testTiled.deep.exr"}; - + + std::vector inputFiles; + std::vector
headers; + + const char* filenames[] = { + "gz1.exr", "tiledgz1.exr", "test.deep.exr", "testTiled.deep.exr"}; + for (size_t i = 0; i < sizeof (filenames) / sizeof (filenames[0]); i++) { - MultiPartInputFile * in_file = new MultiPartInputFile (filenames[i]); - Header header = in_file->header (0); - - if (!header.hasName ()) - { - header.setName (filenames[i]); - } - + MultiPartInputFile* in_file = new MultiPartInputFile (filenames[i]); + Header header = in_file->header (0); + + if (!header.hasName ()) { header.setName (filenames[i]); } + inputFiles.push_back (in_file); headers.push_back (header); } - - MultiPartOutputFile outputFile ("multipart.exr", headers.data (), (int)headers.size ()); - + + MultiPartOutputFile outputFile ( + "multipart.exr", headers.data (), (int) headers.size ()); + for (size_t i = 0; i < sizeof (filenames) / sizeof (filenames[0]); i++) { - Header & header = headers[i]; - const string& type = header.type (); + Header& header = headers[i]; + const string& type = header.type (); copyPixels (type, *inputFiles[i], outputFile, 0, i); delete inputFiles[i]; } } -void splitFiles () +void +splitFiles () { // // Read a multi-part input file and write all parts as separate files. // - + MultiPartInputFile inputFile ("modified.exr"); - + for (int i = 0; i < inputFile.parts (); i++) { Header header = inputFile.header (i); - string out_path = string ("split_part_") + to_string (i) + string (".exr"); - const string& type = header.type (); + string out_path = + string ("split_part_") + to_string (i) + string (".exr"); + const string& type = header.type (); MultiPartOutputFile outputFile (out_path.c_str (), &header, 1); copyPixels (type, inputFile, outputFile, i, 0); } } template -void insertSlice( - Box2i & dataWindow, - FrameBuffer & frameBuffer, - const char name[], - PixelType pixelType, - list> & channels) +void +insertSlice ( + Box2i& dataWindow, + FrameBuffer& frameBuffer, + const char name[], + PixelType pixelType, + list>& channels) { // // Allocate a pixel buffer and describe the layout of // the buffer in the FrameBuffer object. // - + size_t width = dataWindow.max.x - dataWindow.min.x + 1; size_t height = dataWindow.max.y - dataWindow.min.y + 1; - + channels.emplace_back (); - Array2D & buffer = channels.back (); + Array2D& buffer = channels.back (); buffer.resizeErase (height, width); - - char * base = (char *)(&buffer[0][0] - dataWindow.min.x - dataWindow.min.y * width); - + + char* base = + (char*) (&buffer[0][0] - dataWindow.min.x - dataWindow.min.y * width); + frameBuffer.insert ( - name, // name + name, // name Slice ( - pixelType, // type - base, // base - sizeof (ValueType) * 1, // xStride - sizeof (ValueType) * width // yStride - ) - ); + pixelType, // type + base, // base + sizeof (ValueType) * 1, // xStride + sizeof (ValueType) * width // yStride + )); } template -void insertDeepSlice( - Box2i & dataWindow, - DeepFrameBuffer & frameBuffer, - const char name[], - PixelType pixelType, - list> & channels) +void +insertDeepSlice ( + Box2i& dataWindow, + DeepFrameBuffer& frameBuffer, + const char name[], + PixelType pixelType, + list>& channels) { // // Allocate a pixel buffer and describe the layout of // the buffer in the DeepFrameBuffer object. // - + size_t width = dataWindow.max.x - dataWindow.min.x + 1; size_t height = dataWindow.max.y - dataWindow.min.y + 1; - + channels.emplace_back (); - Array2D & buffer = channels.back (); + Array2D& buffer = channels.back (); buffer.resizeErase (height, width); - - char * base = (char *)(&buffer[0][0] - dataWindow.min.x - dataWindow.min.y * width); - + + char* base = + (char*) (&buffer[0][0] - dataWindow.min.x - dataWindow.min.y * width); + frameBuffer.insert ( - name, // name + name, // name DeepSlice ( - pixelType, // type - base, // base - sizeof (ValueType *) * 1, // xStride - sizeof (ValueType *) * width, // yStride - sizeof (ValueType) * width // sample stride - ) - ); + pixelType, // type + base, // base + sizeof (ValueType*) * 1, // xStride + sizeof (ValueType*) * width, // yStride + sizeof (ValueType) * width // sample stride + )); } -FrameBuffer setupFramebuffer ( - const Header & header, - list> & intChannels, - list> & halfChannels, - list> & floatChannels -) +FrameBuffer +setupFramebuffer ( + const Header& header, + list>& intChannels, + list>& halfChannels, + list>& floatChannels) { // // Allocate pixel buffers for all channels specified in the header, describe the layout of // the buffers in the FrameBuffer object. // - + FrameBuffer frameBuffer; - Box2i dataWindow = header.dataWindow (); - - for (auto i = header.channels ().begin (); i != header.channels ().end (); i++) + Box2i dataWindow = header.dataWindow (); + + for (auto i = header.channels ().begin (); i != header.channels ().end (); + i++) { if (i.channel ().type == UINT) { - insertSlice (dataWindow, frameBuffer, i.name (), i.channel ().type, intChannels); + insertSlice ( + dataWindow, + frameBuffer, + i.name (), + i.channel ().type, + intChannels); } else if (i.channel ().type == HALF) { - insertSlice (dataWindow, frameBuffer, i.name (), i.channel ().type, halfChannels); + insertSlice ( + dataWindow, + frameBuffer, + i.name (), + i.channel ().type, + halfChannels); } else if (i.channel ().type == FLOAT) { - insertSlice (dataWindow, frameBuffer, i.name (), i.channel ().type, floatChannels); + insertSlice ( + dataWindow, + frameBuffer, + i.name (), + i.channel ().type, + floatChannels); } } return frameBuffer; } -DeepFrameBuffer setupDeepFramebuffer ( - const Header & header, - Array2D & sampleCount, - list> & intChannels, - list> & halfChannels, - list> & floatChannels -) +DeepFrameBuffer +setupDeepFramebuffer ( + const Header& header, + Array2D& sampleCount, + list>& intChannels, + list>& halfChannels, + list>& floatChannels) { // // Allocate pixel buffers for all channels specified in the header, describe the layout of @@ -259,31 +284,46 @@ DeepFrameBuffer setupDeepFramebuffer ( size_t width = dataWindow.max.x - dataWindow.min.x + 1; size_t height = dataWindow.max.y - dataWindow.min.y + 1; - + sampleCount.resizeErase (height, width); - - frameBuffer.insertSampleCountSlice ( - Slice ( - UINT, - (char*) (&sampleCount[0][0] - dataWindow.min.x - dataWindow.min.y * width), - sizeof (unsigned int) * 1, // xStride - sizeof (unsigned int) * width // yStride - ) - ); - - for (auto i = header.channels ().begin (); i != header.channels ().end (); i++) + + frameBuffer.insertSampleCountSlice (Slice ( + UINT, + (char*) (&sampleCount[0][0] - dataWindow.min.x - + dataWindow.min.y * width), + sizeof (unsigned int) * 1, // xStride + sizeof (unsigned int) * width // yStride + )); + + for (auto i = header.channels ().begin (); i != header.channels ().end (); + i++) { if (i.channel ().type == UINT) { - insertDeepSlice (dataWindow, frameBuffer, i.name (), i.channel ().type, intChannels); + insertDeepSlice ( + dataWindow, + frameBuffer, + i.name (), + i.channel ().type, + intChannels); } else if (i.channel ().type == HALF) { - insertDeepSlice (dataWindow, frameBuffer, i.name (), i.channel ().type, halfChannels); + insertDeepSlice ( + dataWindow, + frameBuffer, + i.name (), + i.channel ().type, + halfChannels); } else if (i.channel ().type == FLOAT) { - insertDeepSlice (dataWindow, frameBuffer, i.name (), i.channel ().type, floatChannels); + insertDeepSlice ( + dataWindow, + frameBuffer, + i.name (), + i.channel ().type, + floatChannels); } } @@ -291,35 +331,34 @@ DeepFrameBuffer setupDeepFramebuffer ( } template -void resizeDeepBuffers ( - Array2D & sampleCount, - list> & channels -) +void +resizeDeepBuffers (Array2D& sampleCount, list>& channels) { // // Allocate memory for samples in all pixel buffers according to the data in sampleCount buffer. // - + for (auto i = channels.begin (); i != channels.end (); i++) { - Array2D & channel = *i; + Array2D& channel = *i; for (int y = 0; y < channel.height (); y++) { for (int x = 0; x < channel.width (); x++) { uint32_t count = sampleCount[y][x]; - channel[y][x] = new T [count]; + channel[y][x] = new T[count]; } } } } template -void freeDeepBuffers (list> & channels) +void +freeDeepBuffers (list>& channels) { for (auto i = channels.begin (); i != channels.end (); i++) { - Array2D & channel = *i; + Array2D& channel = *i; for (int y = 0; y < channel.height (); y++) for (int x = 0; x < channel.width (); x++) delete[] channel[y][x]; @@ -327,16 +366,17 @@ void freeDeepBuffers (list> & channels) } template -void modifyChannels(list> & channels, T delta) +void +modifyChannels (list>& channels, T delta) { // // Dummy code modifying each pixel by incrementing every channel by a given delta. // - + for (auto i = channels.begin (); i != channels.end (); i++) { - Array2D & channel = *i; - + Array2D& channel = *i; + for (int y = 0; y < channel.height (); y++) { for (int x = 0; x < channel.width (); x++) @@ -348,16 +388,18 @@ void modifyChannels(list> & channels, T delta) } template -void modifyDeepChannels(Array2D & sampleCount, list> & channels, T delta) +void +modifyDeepChannels ( + Array2D& sampleCount, list>& channels, T delta) { // // Dummy code modifying each deep pixel by incrementing every sample of each channel by a given delta. // - + for (auto i = channels.begin (); i != channels.end (); i++) { - Array2D & channel = *i; - + Array2D& channel = *i; + for (int y = 0; y < channel.height (); y++) { for (int x = 0; x < channel.width (); x++) @@ -370,138 +412,167 @@ void modifyDeepChannels(Array2D & sampleCount, list> & ch } } -void modifyMultipart () +void +modifyMultipart () { // // Read all channels from a multi-part file, modify each pixel value, write the modified data as a multi-part file. // The parts in the file can be scanline- or tile-based, either flat or deep. // Every channel of the input file gets modified. // - + MultiPartInputFile inputFile ("multipart.exr"); - + std::vector
headers (inputFile.parts ()); - + for (int i = 0; i < inputFile.parts (); i++) { headers[i] = inputFile.header (i); } - - MultiPartOutputFile outputFile("modified.exr", headers.data (), (int)headers.size ()); - + + MultiPartOutputFile outputFile ( + "modified.exr", headers.data (), (int) headers.size ()); + for (int i = 0; i < inputFile.parts (); i++) { - Header & header = headers[i]; - + Header& header = headers[i]; + const string& type = header.type (); - if (type == SCANLINEIMAGE || - type == TILEDIMAGE) + if (type == SCANLINEIMAGE || type == TILEDIMAGE) { list> intChannels; list> halfChannels; list> floatChannels; - - FrameBuffer frameBuffer = setupFramebuffer (header, intChannels, halfChannels, floatChannels); - + + FrameBuffer frameBuffer = setupFramebuffer ( + header, intChannels, halfChannels, floatChannels); + if (type == SCANLINEIMAGE) { InputPart inputPart (inputFile, i); inputPart.setFrameBuffer (frameBuffer); - inputPart.readPixels (header.dataWindow ().min.y, header.dataWindow ().max.y); + inputPart.readPixels ( + header.dataWindow ().min.y, header.dataWindow ().max.y); } else { TiledInputPart inputPart (inputFile, i); inputPart.setFrameBuffer (frameBuffer); - inputPart.readTiles (0, inputPart.numXTiles () - 1, 0, inputPart.numYTiles () - 1); + inputPart.readTiles ( + 0, + inputPart.numXTiles () - 1, + 0, + inputPart.numYTiles () - 1); } - + modifyChannels (intChannels, 1); - modifyChannels (halfChannels, 0.3); - modifyChannels (floatChannels, 0.5); - + modifyChannels (halfChannels, 0.3); + modifyChannels (floatChannels, 0.5); + if (type == SCANLINEIMAGE) { - Box2i dataWindow = header.dataWindow (); + Box2i dataWindow = header.dataWindow (); OutputPart outputPart (outputFile, i); outputPart.setFrameBuffer (frameBuffer); - outputPart.writePixels (dataWindow.max.y - dataWindow.min.y + 1); + outputPart.writePixels ( + dataWindow.max.y - dataWindow.min.y + 1); } else { TiledOutputPart outputPart (outputFile, i); outputPart.setFrameBuffer (frameBuffer); - outputPart.writeTiles (0, outputPart.numXTiles () - 1, 0, outputPart.numYTiles () - 1); + outputPart.writeTiles ( + 0, + outputPart.numXTiles () - 1, + 0, + outputPart.numYTiles () - 1); } } else if (type == DEEPSCANLINE || type == DEEPTILE) { - Array2D sampleCount; - list> intChannels; - list> halfChannels; - list> floatChannels; - - DeepFrameBuffer frameBuffer = setupDeepFramebuffer (header, sampleCount, intChannels, halfChannels, floatChannels); - + Array2D sampleCount; + list> intChannels; + list> halfChannels; + list> floatChannels; + + DeepFrameBuffer frameBuffer = setupDeepFramebuffer ( + header, sampleCount, intChannels, halfChannels, floatChannels); + if (type == DEEPSCANLINE) { DeepScanLineInputPart inputPart (inputFile, i); inputPart.setFrameBuffer (frameBuffer); - inputPart.readPixelSampleCounts (header.dataWindow ().min.y, header.dataWindow ().max.y); - + inputPart.readPixelSampleCounts ( + header.dataWindow ().min.y, header.dataWindow ().max.y); + resizeDeepBuffers (sampleCount, intChannels); - resizeDeepBuffers (sampleCount, halfChannels); - resizeDeepBuffers (sampleCount, floatChannels); - - inputPart.readPixels (header.dataWindow ().min.y, header.dataWindow ().max.y); + resizeDeepBuffers (sampleCount, halfChannels); + resizeDeepBuffers (sampleCount, floatChannels); + + inputPart.readPixels ( + header.dataWindow ().min.y, header.dataWindow ().max.y); } else { DeepTiledInputPart inputPart (inputFile, i); inputPart.setFrameBuffer (frameBuffer); - inputPart.readPixelSampleCounts (0, inputPart.numXTiles () - 1, 0, inputPart.numYTiles () - 1); - + inputPart.readPixelSampleCounts ( + 0, + inputPart.numXTiles () - 1, + 0, + inputPart.numYTiles () - 1); + resizeDeepBuffers (sampleCount, intChannels); - resizeDeepBuffers (sampleCount, halfChannels); - resizeDeepBuffers (sampleCount, floatChannels); - - inputPart.readTiles (0, inputPart.numXTiles () - 1, 0, inputPart.numYTiles () - 1); + resizeDeepBuffers (sampleCount, halfChannels); + resizeDeepBuffers (sampleCount, floatChannels); + + inputPart.readTiles ( + 0, + inputPart.numXTiles () - 1, + 0, + inputPart.numYTiles () - 1); } - + modifyDeepChannels (sampleCount, intChannels, 1); - modifyDeepChannels (sampleCount, halfChannels, 0.3); - modifyDeepChannels (sampleCount, floatChannels, 0.5); - + modifyDeepChannels (sampleCount, halfChannels, 0.3); + modifyDeepChannels (sampleCount, floatChannels, 0.5); + if (type == DEEPSCANLINE) { - Box2i dataWindow = header.dataWindow (); + Box2i dataWindow = header.dataWindow (); DeepScanLineOutputPart outputPart (outputFile, i); outputPart.setFrameBuffer (frameBuffer); - outputPart.writePixels (dataWindow.max.y - dataWindow.min.y + 1); + outputPart.writePixels ( + dataWindow.max.y - dataWindow.min.y + 1); } else { DeepTiledOutputPart outputPart (outputFile, i); outputPart.setFrameBuffer (frameBuffer); - outputPart.writeTiles (0, outputPart.numXTiles () - 1, 0, outputPart.numYTiles () - 1); + outputPart.writeTiles ( + 0, + outputPart.numXTiles () - 1, + 0, + outputPart.numYTiles () - 1); } - freeDeepBuffers(intChannels); - freeDeepBuffers(halfChannels); - freeDeepBuffers(floatChannels); + freeDeepBuffers (intChannels); + freeDeepBuffers (halfChannels); + freeDeepBuffers (floatChannels); } } } -void multipartExamples() +void +multipartExamples () { // Read multiple single-part files and write them out as a single multi-part file. combineFiles (); - + // Read all parts from a multi-part file, modify each channel of every pixel by incrementing its value, write out as a multi-part file. modifyMultipart (); - + // Read a multi-part file and write out as multiple single-part files. splitFiles (); } diff --git a/src/examples/multipartExamples.h b/src/examples/multipartExamples.h index 87ed86e5b7..93dc045507 100644 --- a/src/examples/multipartExamples.h +++ b/src/examples/multipartExamples.h @@ -4,4 +4,3 @@ // void multipartExamples (); - diff --git a/src/lib/Iex/IexBaseExc.h b/src/lib/Iex/IexBaseExc.h index fef809961b..96d631644a 100644 --- a/src/lib/Iex/IexBaseExc.h +++ b/src/lib/Iex/IexBaseExc.h @@ -114,13 +114,20 @@ class IEX_EXPORT_TYPE BaseExc : public std::exception }; #define DEFINE_EXC_EXP_IMPL(exp, name, base) \ - exp name::name () : base () {} \ - exp name::name (const char* text) : base (text) {} \ - exp name::name (const std::string& text) : base (text) {} \ - exp name::name (std::string&& text) : base (std::move (text)) {} \ - exp name::name (std::stringstream& text) : base (text) {} \ - exp name::name (const name& other) : base (other) {} \ - exp name::name (name&& other) noexcept : base (other) {} \ + exp name::name () : base () \ + {} \ + exp name::name (const char* text) : base (text) \ + {} \ + exp name::name (const std::string& text) : base (text) \ + {} \ + exp name::name (std::string&& text) : base (std::move (text)) \ + {} \ + exp name::name (std::stringstream& text) : base (text) \ + {} \ + exp name::name (const name& other) : base (other) \ + {} \ + exp name::name (name&& other) noexcept : base (other) \ + {} \ exp name& name::operator= (name& other) \ { \ base::operator= (other); \ @@ -131,7 +138,8 @@ class IEX_EXPORT_TYPE BaseExc : public std::exception base::operator= (other); \ return *this; \ } \ - exp name::~name () noexcept {} + exp name::~name () noexcept \ + {} // For backward compatibility. #define DEFINE_EXC(name, base) DEFINE_EXC_EXP (, name, base) diff --git a/src/lib/Iex/IexExport.h b/src/lib/Iex/IexExport.h index bdf78915d9..f33a2aa056 100644 --- a/src/lib/Iex/IexExport.h +++ b/src/lib/Iex/IexExport.h @@ -15,9 +15,9 @@ // internally or not # if defined(IEX_EXPORTS) -# define IEX_EXPORT __declspec(dllexport) +# define IEX_EXPORT __declspec (dllexport) # else -# define IEX_EXPORT __declspec(dllimport) +# define IEX_EXPORT __declspec (dllimport) # endif // DLLs don't support these types of visibility controls, just leave them as empty diff --git a/src/lib/Iex/IexMathFloatExc.h b/src/lib/Iex/IexMathFloatExc.h index 8ee8e42258..1a61ffdb41 100644 --- a/src/lib/Iex/IexMathFloatExc.h +++ b/src/lib/Iex/IexMathFloatExc.h @@ -54,10 +54,10 @@ class IEX_EXPORT_TYPE MathExcOn public: IEX_EXPORT MathExcOn (int when); IEX_EXPORT ~MathExcOn (); - MathExcOn (const MathExcOn&) = delete; + MathExcOn (const MathExcOn&) = delete; MathExcOn& operator= (const MathExcOn&) = delete; MathExcOn (MathExcOn&&) = delete; - MathExcOn& operator= (MathExcOn&&) = delete; + MathExcOn& operator= (MathExcOn&&) = delete; // It is possible for functions to set the exception registers // yet not trigger a SIGFPE. Specifically, the implementation diff --git a/src/lib/Iex/IexMathFpu.cpp b/src/lib/Iex/IexMathFpu.cpp index 7876d8a014..cfc7ef010a 100644 --- a/src/lib/Iex/IexMathFpu.cpp +++ b/src/lib/Iex/IexMathFpu.cpp @@ -112,21 +112,21 @@ static inline uint16_t getSw () { uint16_t sw; - asm volatile("fnstsw %0" : "=m"(sw) :); + asm volatile ("fnstsw %0" : "=m"(sw) :); return sw; } static inline void setCw (uint16_t cw) { - asm volatile("fldcw %0" : : "m"(cw)); + asm volatile ("fldcw %0" : : "m"(cw)); } static inline uint16_t getCw () { uint16_t cw; - asm volatile("fnstcw %0" : "=m"(cw) :); + asm volatile ("fnstcw %0" : "=m"(cw) :); return cw; } @@ -134,14 +134,14 @@ static inline void setMxcsr (uint32_t mxcsr, bool clearExceptions) { mxcsr &= clearExceptions ? 0xffffffc0 : 0xffffffff; - asm volatile("ldmxcsr %0" : : "m"(mxcsr)); + asm volatile ("ldmxcsr %0" : : "m"(mxcsr)); } static inline uint32_t getMxcsr () { uint32_t mxcsr; - asm volatile("stmxcsr %0" : "=m"(mxcsr) :); + asm volatile ("stmxcsr %0" : "=m"(mxcsr) :); return mxcsr; } @@ -203,10 +203,10 @@ void clearExceptions () { uint32_t mxcsr = getMxcsr () & 0xffffffc0; - asm volatile("ldmxcsr %0\n" - "fnclex" - : - : "m"(mxcsr)); + asm volatile ("ldmxcsr %0\n" + "fnclex" + : + : "m"(mxcsr)); } // If the fpe was taken while doing a float-to-int cast using the x87, @@ -243,7 +243,8 @@ restoreControlRegs (const ucontext_t& ucon, bool clearExceptions) inline void restoreControlRegs (const ucontext_t& ucon, bool clearExceptions) { -# if (defined(__linux__) && defined(__i386__)) || defined(__ANDROID_API__) +# if (defined(__linux__) && defined(__i386__)) || \ + defined(__ANDROID_API__) setCw ((ucon.uc_mcontext.fpregs->cw & cwRestoreMask) | cwRestoreVal); # else setCw ((ucon.uc_mcontext.fpregs->cwd & cwRestoreMask) | cwRestoreVal); @@ -443,10 +444,7 @@ void fpExc_ (int x) { if (fpeHandler != 0) { fpeHandler (x, ""); } - else - { - assert (0 != "Floating point exception"); - } + else { assert (0 != "Floating point exception"); } } } // namespace diff --git a/src/lib/IlmThread/IlmThread.h b/src/lib/IlmThread/IlmThread.h index a1d043fa9a..ce060e0d5d 100644 --- a/src/lib/IlmThread/IlmThread.h +++ b/src/lib/IlmThread/IlmThread.h @@ -100,9 +100,9 @@ class ILMTHREAD_EXPORT_TYPE Thread #endif Thread& operator= (const Thread& t) = delete; - Thread& operator= (Thread&& t) = delete; - Thread (const Thread& t) = delete; - Thread (Thread&& t) = delete; + Thread& operator= (Thread&& t) = delete; + Thread (const Thread& t) = delete; + Thread (Thread&& t) = delete; }; ILMTHREAD_INTERNAL_NAMESPACE_HEADER_EXIT diff --git a/src/lib/IlmThread/IlmThreadExport.h b/src/lib/IlmThread/IlmThreadExport.h index a2fc813429..e880217a4d 100644 --- a/src/lib/IlmThread/IlmThreadExport.h +++ b/src/lib/IlmThread/IlmThreadExport.h @@ -20,9 +20,9 @@ // where we need to switch depending on whether we are compiling // internally or not # if defined(ILMTHREAD_EXPORTS) -# define ILMTHREAD_EXPORT __declspec(dllexport) +# define ILMTHREAD_EXPORT __declspec (dllexport) # else -# define ILMTHREAD_EXPORT __declspec(dllimport) +# define ILMTHREAD_EXPORT __declspec (dllimport) # endif // DLLs don't support these types of visibility controls, just leave them as empty diff --git a/src/lib/IlmThread/IlmThreadMutex.h b/src/lib/IlmThread/IlmThreadMutex.h index c789c46344..451200c0a4 100644 --- a/src/lib/IlmThread/IlmThreadMutex.h +++ b/src/lib/IlmThread/IlmThreadMutex.h @@ -47,10 +47,10 @@ class Lock { if (_locked) _mutex.unlock (); } - Lock (const Lock&) = delete; + Lock (const Lock&) = delete; Lock& operator= (const Lock&) = delete; Lock (Lock&&) = delete; - Lock& operator= (Lock&&) = delete; + Lock& operator= (Lock&&) = delete; void acquire () { diff --git a/src/lib/IlmThread/IlmThreadPool.cpp b/src/lib/IlmThread/IlmThreadPool.cpp index 07f747f0e7..067490fea7 100644 --- a/src/lib/IlmThread/IlmThreadPool.cpp +++ b/src/lib/IlmThread/IlmThreadPool.cpp @@ -518,7 +518,7 @@ ThreadPool::setNumThreads (int count) Data::ProviderPtr sp = _data->getProvider (); if (sp) { - int curT = sp->numThreads (); + int curT = sp->numThreads (); if (curT == count) return; if (count != 0) diff --git a/src/lib/IlmThread/IlmThreadPool.h b/src/lib/IlmThread/IlmThreadPool.h index 3f1f1bcb43..0d89742da3 100644 --- a/src/lib/IlmThread/IlmThreadPool.h +++ b/src/lib/IlmThread/IlmThreadPool.h @@ -64,10 +64,10 @@ class ILMTHREAD_EXPORT_TYPE ThreadPoolProvider virtual void finish () = 0; // Make the provider non-copyable - ThreadPoolProvider (const ThreadPoolProvider&) = delete; + ThreadPoolProvider (const ThreadPoolProvider&) = delete; ThreadPoolProvider& operator= (const ThreadPoolProvider&) = delete; ThreadPoolProvider (ThreadPoolProvider&&) = delete; - ThreadPoolProvider& operator= (ThreadPoolProvider&&) = delete; + ThreadPoolProvider& operator= (ThreadPoolProvider&&) = delete; }; class ILMTHREAD_EXPORT_TYPE ThreadPool @@ -101,10 +101,10 @@ class ILMTHREAD_EXPORT_TYPE ThreadPool //----------------------------------------------------------- ILMTHREAD_EXPORT virtual ~ThreadPool (); - ThreadPool (const ThreadPool&) = delete; + ThreadPool (const ThreadPool&) = delete; ThreadPool& operator= (const ThreadPool&) = delete; ThreadPool (ThreadPool&&) = delete; - ThreadPool& operator= (ThreadPool&&) = delete; + ThreadPool& operator= (ThreadPool&&) = delete; //-------------------------------------------------------- // Query and set the number of worker threads in the pool. @@ -157,10 +157,10 @@ class ILMTHREAD_EXPORT_TYPE Task public: ILMTHREAD_EXPORT Task (TaskGroup* g); ILMTHREAD_EXPORT virtual ~Task (); - Task (const Task&) = delete; + Task (const Task&) = delete; Task& operator= (const Task&) = delete; Task (Task&&) = delete; - Task& operator= (Task&&) = delete; + Task& operator= (Task&&) = delete; virtual void execute () = 0; ILMTHREAD_EXPORT @@ -176,10 +176,10 @@ class ILMTHREAD_EXPORT_TYPE TaskGroup ILMTHREAD_EXPORT TaskGroup (); ILMTHREAD_EXPORT ~TaskGroup (); - TaskGroup (const TaskGroup& other) = delete; + TaskGroup (const TaskGroup& other) = delete; TaskGroup& operator= (const TaskGroup& other) = delete; TaskGroup (TaskGroup&& other) = delete; - TaskGroup& operator= (TaskGroup&& other) = delete; + TaskGroup& operator= (TaskGroup&& other) = delete; // marks one task as finished // should be used by the thread pool provider to notify diff --git a/src/lib/IlmThread/IlmThreadSemaphore.h b/src/lib/IlmThread/IlmThreadSemaphore.h index 9f348fc20b..186386153f 100644 --- a/src/lib/IlmThread/IlmThreadSemaphore.h +++ b/src/lib/IlmThread/IlmThreadSemaphore.h @@ -69,13 +69,12 @@ class ILMTHREAD_EXPORT_TYPE Semaphore ILMTHREAD_EXPORT int value () const; private: - #if ILMTHREAD_SEMAPHORE_POSIX mutable sem_t _semaphore; #elif ILMTHREAD_SEMAPHORE_OSX - + mutable dispatch_semaphore_t _semaphore; #elif ILMTHREAD_SEMAPHORE_WINDOWS @@ -83,7 +82,7 @@ class ILMTHREAD_EXPORT_TYPE Semaphore mutable HANDLE _semaphore; #elif ILMTHREAD_SEMAPHORE_OTHER - + // // If the platform has threads but no semaphores, // then we implement them ourselves using condition variables @@ -103,8 +102,8 @@ class ILMTHREAD_EXPORT_TYPE Semaphore void operator= (const Semaphore& s) = delete; Semaphore (const Semaphore& s) = delete; - void operator= (Semaphore&& s) = delete; - Semaphore (Semaphore&& s) = delete; + void operator= (Semaphore&& s) = delete; + Semaphore (Semaphore&& s) = delete; }; ILMTHREAD_INTERNAL_NAMESPACE_HEADER_EXIT diff --git a/src/lib/IlmThread/IlmThreadSemaphoreOSX.cpp b/src/lib/IlmThread/IlmThreadSemaphoreOSX.cpp index 536bd329de..1f75ad893f 100644 --- a/src/lib/IlmThread/IlmThreadSemaphoreOSX.cpp +++ b/src/lib/IlmThread/IlmThreadSemaphoreOSX.cpp @@ -16,7 +16,7 @@ #if ILMTHREAD_SEMAPHORE_OSX -#include "Iex.h" +# include "Iex.h" ILMTHREAD_INTERNAL_NAMESPACE_SOURCE_ENTER diff --git a/src/lib/IlmThread/IlmThreadSemaphorePosix.cpp b/src/lib/IlmThread/IlmThreadSemaphorePosix.cpp index a04510e2c6..84ba1e945c 100644 --- a/src/lib/IlmThread/IlmThreadSemaphorePosix.cpp +++ b/src/lib/IlmThread/IlmThreadSemaphorePosix.cpp @@ -14,9 +14,9 @@ #if ILMTHREAD_SEMAPHORE_POSIX -#include "Iex.h" -#include -#include +# include "Iex.h" +# include +# include ILMTHREAD_INTERNAL_NAMESPACE_SOURCE_ENTER diff --git a/src/lib/IlmThread/IlmThreadSemaphoreWin32.cpp b/src/lib/IlmThread/IlmThreadSemaphoreWin32.cpp index a294cc28ff..85f5996cea 100644 --- a/src/lib/IlmThread/IlmThreadSemaphoreWin32.cpp +++ b/src/lib/IlmThread/IlmThreadSemaphoreWin32.cpp @@ -13,10 +13,10 @@ #if ILMTHREAD_SEMAPHORE_WINDOWS -#include "Iex.h" -#include -#include -#include +# include "Iex.h" +# include +# include +# include ILMTHREAD_INTERNAL_NAMESPACE_SOURCE_ENTER @@ -126,4 +126,3 @@ Semaphore::value () const ILMTHREAD_INTERNAL_NAMESPACE_SOURCE_EXIT #endif // ILMTHREAD_SEMAPHORE_WINDOWS - diff --git a/src/lib/OpenEXR/ImfAcesFile.cpp b/src/lib/OpenEXR/ImfAcesFile.cpp index 880ffb30f9..ba31bc24d0 100644 --- a/src/lib/OpenEXR/ImfAcesFile.cpp +++ b/src/lib/OpenEXR/ImfAcesFile.cpp @@ -40,10 +40,10 @@ class AcesOutputFile::Data Data (); ~Data (); - Data (const Data& other) = delete; + Data (const Data& other) = delete; Data& operator= (const Data& other) = delete; Data (Data&& other) = delete; - Data& operator= (Data&& other) = delete; + Data& operator= (Data&& other) = delete; RgbaOutputFile* rgbaFile; }; @@ -273,10 +273,10 @@ class AcesInputFile::Data Data (); ~Data (); - Data (const Data& other) = delete; + Data (const Data& other) = delete; Data& operator= (const Data& other) = delete; Data (Data&& other) = delete; - Data& operator= (Data&& other) = delete; + Data& operator= (Data&& other) = delete; void initColorConversion (); diff --git a/src/lib/OpenEXR/ImfAcesFile.h b/src/lib/OpenEXR/ImfAcesFile.h index 86a2de91ad..c2d5ed1dc3 100644 --- a/src/lib/OpenEXR/ImfAcesFile.h +++ b/src/lib/OpenEXR/ImfAcesFile.h @@ -193,10 +193,10 @@ class IMF_EXPORT_TYPE AcesOutputFile void updatePreviewImage (const PreviewRgba[]); private: - AcesOutputFile (const AcesOutputFile&) = delete; + AcesOutputFile (const AcesOutputFile&) = delete; AcesOutputFile& operator= (const AcesOutputFile&) = delete; AcesOutputFile (AcesOutputFile&&) = delete; - AcesOutputFile& operator= (AcesOutputFile&&) = delete; + AcesOutputFile& operator= (AcesOutputFile&&) = delete; class IMF_HIDDEN Data; @@ -294,10 +294,10 @@ class IMF_EXPORT_TYPE AcesInputFile int version () const; private: - AcesInputFile (const AcesInputFile&) = delete; + AcesInputFile (const AcesInputFile&) = delete; AcesInputFile& operator= (const AcesInputFile&) = delete; AcesInputFile (AcesInputFile&&) = delete; - AcesInputFile& operator= (AcesInputFile&&) = delete; + AcesInputFile& operator= (AcesInputFile&&) = delete; class IMF_HIDDEN Data; diff --git a/src/lib/OpenEXR/ImfArray.h b/src/lib/OpenEXR/ImfArray.h index 9f364d4316..211d818e39 100644 --- a/src/lib/OpenEXR/ImfArray.h +++ b/src/lib/OpenEXR/ImfArray.h @@ -90,10 +90,10 @@ template class IMF_EXPORT_TEMPLATE_TYPE Array long size () const { return _size; } private: - Array (const Array&) = delete; + Array (const Array&) = delete; Array& operator= (const Array&) = delete; Array (Array&&) = delete; - Array& operator= (Array&&) = delete; + Array& operator= (Array&&) = delete; long _size; T* _data; @@ -140,10 +140,10 @@ template class IMF_EXPORT_TEMPLATE_TYPE Array2D long width () const { return _sizeY; } private: - Array2D (const Array2D&) = delete; + Array2D (const Array2D&) = delete; Array2D& operator= (const Array2D&) = delete; Array2D (Array2D&&) = delete; - Array2D& operator= (Array2D&&) = delete; + Array2D& operator= (Array2D&&) = delete; long _sizeX; long _sizeY; diff --git a/src/lib/OpenEXR/ImfAttribute.h b/src/lib/OpenEXR/ImfAttribute.h index bccd980adc..d0232d9186 100644 --- a/src/lib/OpenEXR/ImfAttribute.h +++ b/src/lib/OpenEXR/ImfAttribute.h @@ -118,7 +118,7 @@ class IMF_EXPORT_TEMPLATE_TYPE TypedAttribute : public Attribute virtual ~TypedAttribute (); TypedAttribute& operator= (const TypedAttribute& other) = default; - TypedAttribute& operator= (TypedAttribute&& other) = default; + TypedAttribute& operator= (TypedAttribute&& other) = default; //-------------------------------- // Access to the attribute's value diff --git a/src/lib/OpenEXR/ImfAutoArray.h b/src/lib/OpenEXR/ImfAutoArray.h index 0cfa69bcae..74cbc99a28 100644 --- a/src/lib/OpenEXR/ImfAutoArray.h +++ b/src/lib/OpenEXR/ImfAutoArray.h @@ -29,10 +29,10 @@ template class AutoArray AutoArray () : _data (new T[size]) { memset (_data, 0, size * sizeof (T)); } ~AutoArray () { delete[] _data; } - AutoArray (const AutoArray& other) = delete; + AutoArray (const AutoArray& other) = delete; AutoArray& operator= (const AutoArray& other) = delete; AutoArray (AutoArray&& other) = delete; - AutoArray& operator= (AutoArray&& other) = delete; + AutoArray& operator= (AutoArray&& other) = delete; operator T* () { return _data; } operator const T* () const { return _data; } diff --git a/src/lib/OpenEXR/ImfCompositeDeepScanLine.cpp b/src/lib/OpenEXR/ImfCompositeDeepScanLine.cpp index 9250ed164a..8ac4a166bf 100644 --- a/src/lib/OpenEXR/ImfCompositeDeepScanLine.cpp +++ b/src/lib/OpenEXR/ImfCompositeDeepScanLine.cpp @@ -107,14 +107,8 @@ CompositeDeepScanLine::Data::check_valid (const Header& header) { std::string n (i.name ()); if (n == "ZBack") { _zback = true; } - else if (n == "Z") - { - has_z = true; - } - else if (n == "A") - { - has_alpha = true; - } + else if (n == "Z") { has_z = true; } + else if (n == "A") { has_alpha = true; } } if (!has_z) @@ -216,7 +210,8 @@ CompositeDeepScanLine::Data::handleDeepFrameBuffer ( qt.name (), DeepSlice ( OPENEXR_IMF_INTERNAL_NAMESPACE::FLOAT, - (char*) (&pointers[channel_in_source][0] - _dataWindow.min.x - start * width), + (char*) (&pointers[channel_in_source][0] - + _dataWindow.min.x - start * width), sizeof (float*), sizeof (float*) * width, sizeof (float))); @@ -275,14 +270,8 @@ CompositeDeepScanLine::setFrameBuffer (const FrameBuffer& fr) string name (q.name ()); if (name == "ZBack") { _Data->_bufferMap.push_back (1); } - else if (name == "Z") - { - _Data->_bufferMap.push_back (0); - } - else if (name == "A") - { - _Data->_bufferMap.push_back (2); - } + else if (name == "Z") { _Data->_bufferMap.push_back (0); } + else if (name == "A") { _Data->_bufferMap.push_back (2); } else { _Data->_bufferMap.push_back ( @@ -427,23 +416,23 @@ LineCompositeTask::execute () } // namespace - -namespace { +namespace +{ int64_t maximumSampleCount = 0; } -void CompositeDeepScanLine::setMaximumSampleCount(int64_t c) +void +CompositeDeepScanLine::setMaximumSampleCount (int64_t c) { maximumSampleCount = c; } -int64_t CompositeDeepScanLine::getMaximumSampleCount() +int64_t +CompositeDeepScanLine::getMaximumSampleCount () { return maximumSampleCount; } - - void CompositeDeepScanLine::readPixels (int start, int end) { @@ -525,15 +514,13 @@ CompositeDeepScanLine::readPixels (int start, int end) overall_sample_count += total_sizes[ptr]; } - if (maximumSampleCount > 0 && overall_sample_count > maximumSampleCount) + if (maximumSampleCount > 0 && overall_sample_count > maximumSampleCount) { throw IEX_NAMESPACE::ArgExc ( "Cannot composite scanline: total sample count on scanline exceeds " - "limit set by CompositeDeepScanLine::setMaximumSampleCount()" - ); + "limit set by CompositeDeepScanLine::setMaximumSampleCount()"); } - // // allocate arrays for pixel data // samples array accessed as in pixels[channel][sample] @@ -625,5 +612,4 @@ CompositeDeepScanLine::frameBuffer () const return _Data->_outputFrameBuffer; } - OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT diff --git a/src/lib/OpenEXR/ImfCompositeDeepScanLine.h b/src/lib/OpenEXR/ImfCompositeDeepScanLine.h index 30ee632b38..fa5a164709 100644 --- a/src/lib/OpenEXR/ImfCompositeDeepScanLine.h +++ b/src/lib/OpenEXR/ImfCompositeDeepScanLine.h @@ -106,7 +106,6 @@ class IMF_EXPORT_TYPE CompositeDeepScanLine struct IMF_HIDDEN Data; - // // set the maximum number of samples that will be composited. // If a single scanline has more samples, readPixels will throw @@ -117,19 +116,18 @@ class IMF_EXPORT_TYPE CompositeDeepScanLine // arbitrarily large sample counts to be composited // IMF_EXPORT - static void setMaximumSampleCount(int64_t sampleCount); + static void setMaximumSampleCount (int64_t sampleCount); IMF_EXPORT - static int64_t getMaximumSampleCount(); - + static int64_t getMaximumSampleCount (); private: struct Data* _Data; - CompositeDeepScanLine (const CompositeDeepScanLine&) = delete; + CompositeDeepScanLine (const CompositeDeepScanLine&) = delete; CompositeDeepScanLine& operator= (const CompositeDeepScanLine&) = delete; CompositeDeepScanLine (CompositeDeepScanLine&&) = delete; - CompositeDeepScanLine& operator= (CompositeDeepScanLine&&) = delete; + CompositeDeepScanLine& operator= (CompositeDeepScanLine&&) = delete; }; OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT diff --git a/src/lib/OpenEXR/ImfCompressionAttribute.cpp b/src/lib/OpenEXR/ImfCompressionAttribute.cpp index 54b0fd1a8f..ee9c4ff517 100644 --- a/src/lib/OpenEXR/ImfCompressionAttribute.cpp +++ b/src/lib/OpenEXR/ImfCompressionAttribute.cpp @@ -53,10 +53,7 @@ CompressionAttribute::readValueFrom ( // (Header::sanityCheck will throw an exception when files with invalid Compression types are read) // - if (!isValidCompression(tmp)) - { - tmp = NUM_COMPRESSION_METHODS; - } + if (!isValidCompression (tmp)) { tmp = NUM_COMPRESSION_METHODS; } _value = Compression (tmp); } diff --git a/src/lib/OpenEXR/ImfDeepScanLineInputFile.cpp b/src/lib/OpenEXR/ImfDeepScanLineInputFile.cpp index f17d821c90..fc641077b2 100644 --- a/src/lib/OpenEXR/ImfDeepScanLineInputFile.cpp +++ b/src/lib/OpenEXR/ImfDeepScanLineInputFile.cpp @@ -231,10 +231,10 @@ struct DeepScanLineInputFile::Data Data (int numThreads); ~Data (); - Data (const Data& data) = delete; + Data (const Data& data) = delete; Data& operator= (const Data& data) = delete; Data (Data&& data) = delete; - Data& operator= (Data&& data) = delete; + Data& operator= (Data&& data) = delete; inline LineBuffer* getLineBuffer (int number); // hash function from line // buffer indices into our @@ -1186,22 +1186,24 @@ DeepScanLineInputFile::initialize (const Header& header) for (int i = 0; i < _data->maxY - _data->minY + 1; i++) _data->gotSampleCount[i] = false; - int64_t imageHeight = static_cast(_data->maxY) - static_cast(_data->minY) + 1; - int64_t imageWidth = static_cast(_data->maxX) - static_cast(_data->minX) +1; + int64_t imageHeight = static_cast (_data->maxY) - + static_cast (_data->minY) + 1; + int64_t imageWidth = static_cast (_data->maxX) - + static_cast (_data->minX) + 1; - int64_t tableSize = min (static_cast(_data->linesInBuffer), imageHeight) * imageWidth - * sizeof (unsigned int); + int64_t tableSize = + min (static_cast (_data->linesInBuffer), imageHeight) * + imageWidth * sizeof (unsigned int); - if (tableSize>std::numeric_limits::max() ) + if (tableSize > std::numeric_limits::max ()) { - THROW (IEX_NAMESPACE::ArgExc, - "Deep scanline image size " - << imageWidth << " x " << imageHeight - << " exceeds maximum size"); + THROW ( + IEX_NAMESPACE::ArgExc, + "Deep scanline image size " << imageWidth << " x " + << imageHeight + << " exceeds maximum size"); } - _data->maxSampleCountTableSize =tableSize; - - + _data->maxSampleCountTableSize = tableSize; _data->sampleCountTableBuffer.resizeErase ( _data->maxSampleCountTableSize); diff --git a/src/lib/OpenEXR/ImfDeepScanLineInputFile.h b/src/lib/OpenEXR/ImfDeepScanLineInputFile.h index ae5be9a32e..8f22cc7fa5 100644 --- a/src/lib/OpenEXR/ImfDeepScanLineInputFile.h +++ b/src/lib/OpenEXR/ImfDeepScanLineInputFile.h @@ -45,8 +45,8 @@ class IMF_EXPORT_TYPE DeepScanLineInputFile : public GenericInputFile DeepScanLineInputFile (const DeepScanLineInputFile& other) = delete; DeepScanLineInputFile& - operator= (const DeepScanLineInputFile& other) = delete; - DeepScanLineInputFile (DeepScanLineInputFile&& other) = delete; + operator= (const DeepScanLineInputFile& other) = delete; + DeepScanLineInputFile (DeepScanLineInputFile&& other) = delete; DeepScanLineInputFile& operator= (DeepScanLineInputFile&& other) = delete; //----------------------------------------- diff --git a/src/lib/OpenEXR/ImfDeepScanLineOutputFile.cpp b/src/lib/OpenEXR/ImfDeepScanLineOutputFile.cpp index 915a59e5fc..d073ac0804 100644 --- a/src/lib/OpenEXR/ImfDeepScanLineOutputFile.cpp +++ b/src/lib/OpenEXR/ImfDeepScanLineOutputFile.cpp @@ -196,10 +196,10 @@ struct DeepScanLineOutputFile::Data Data (int numThreads); ~Data (); - Data (const Data& other) = delete; + Data (const Data& other) = delete; Data& operator= (const Data& other) = delete; Data (Data&& other) = delete; - Data& operator= (Data&& other) = delete; + Data& operator= (Data&& other) = delete; inline LineBuffer* getLineBuffer (int number); // hash function from line // buffer indices into our diff --git a/src/lib/OpenEXR/ImfDeepScanLineOutputFile.h b/src/lib/OpenEXR/ImfDeepScanLineOutputFile.h index 24cef6e16e..064eae667b 100644 --- a/src/lib/OpenEXR/ImfDeepScanLineOutputFile.h +++ b/src/lib/OpenEXR/ImfDeepScanLineOutputFile.h @@ -197,10 +197,10 @@ class DeepScanLineOutputFile : public GenericOutputFile //------------------------------------------------------------ DeepScanLineOutputFile (const OutputPartData* part); - DeepScanLineOutputFile (const DeepScanLineOutputFile&) = delete; + DeepScanLineOutputFile (const DeepScanLineOutputFile&) = delete; DeepScanLineOutputFile& operator= (const DeepScanLineOutputFile&) = delete; DeepScanLineOutputFile (DeepScanLineOutputFile&&) = delete; - DeepScanLineOutputFile& operator= (DeepScanLineOutputFile&&) = delete; + DeepScanLineOutputFile& operator= (DeepScanLineOutputFile&&) = delete; void initialize (const Header& header); void initializeLineBuffer (); diff --git a/src/lib/OpenEXR/ImfDeepTiledInputFile.cpp b/src/lib/OpenEXR/ImfDeepTiledInputFile.cpp index 7d1d882d68..dcd9e34411 100644 --- a/src/lib/OpenEXR/ImfDeepTiledInputFile.cpp +++ b/src/lib/OpenEXR/ImfDeepTiledInputFile.cpp @@ -228,7 +228,7 @@ struct DeepTiledInputFile::Data uint64_t maxSampleCountTableSize; // the max size in bytes for a pixel // sample count table - int combinedSampleSize; // total size of all channels combined to check sampletable size + int combinedSampleSize; // total size of all channels combined to check sampletable size static const int gLargeChunkTableSize = 1024 * 1024; void validateStreamSize (); // throw an exception if the file is significantly @@ -238,10 +238,10 @@ struct DeepTiledInputFile::Data Data (int numThreads); ~Data (); - Data (const Data& other) = delete; + Data (const Data& other) = delete; Data& operator= (const Data& other) = delete; Data (Data&& other) = delete; - Data& operator= (Data&& other) = delete; + Data& operator= (Data&& other) = delete; inline TileBuffer* getTileBuffer (int number); // hash function from tile indices diff --git a/src/lib/OpenEXR/ImfDeepTiledInputFile.h b/src/lib/OpenEXR/ImfDeepTiledInputFile.h index 5347984f87..599f86c02a 100644 --- a/src/lib/OpenEXR/ImfDeepTiledInputFile.h +++ b/src/lib/OpenEXR/ImfDeepTiledInputFile.h @@ -386,10 +386,10 @@ class IMF_EXPORT_TYPE DeepTiledInputFile : public GenericInputFile DeepTiledInputFile (InputPartData* part); - DeepTiledInputFile (const DeepTiledInputFile&) = delete; + DeepTiledInputFile (const DeepTiledInputFile&) = delete; DeepTiledInputFile& operator= (const DeepTiledInputFile&) = delete; DeepTiledInputFile (DeepTiledInputFile&&) = delete; - DeepTiledInputFile& operator= (DeepTiledInputFile&&) = delete; + DeepTiledInputFile& operator= (DeepTiledInputFile&&) = delete; DeepTiledInputFile ( const Header& header, diff --git a/src/lib/OpenEXR/ImfDeepTiledOutputFile.cpp b/src/lib/OpenEXR/ImfDeepTiledOutputFile.cpp index fc23df2643..b777de6fa0 100644 --- a/src/lib/OpenEXR/ImfDeepTiledOutputFile.cpp +++ b/src/lib/OpenEXR/ImfDeepTiledOutputFile.cpp @@ -166,10 +166,10 @@ struct BufferedTile delete[] sampleCountTableData; } - BufferedTile (const BufferedTile& other) = delete; + BufferedTile (const BufferedTile& other) = delete; BufferedTile& operator= (const BufferedTile& other) = delete; BufferedTile (BufferedTile&& other) = delete; - BufferedTile& operator= (BufferedTile&& other) = delete; + BufferedTile& operator= (BufferedTile&& other) = delete; }; typedef map TileMap; @@ -270,10 +270,10 @@ struct DeepTiledOutputFile::Data Data (int numThreads); ~Data (); - Data (const Data& other) = delete; + Data (const Data& other) = delete; Data& operator= (const Data& other) = delete; Data (Data&& other) = delete; - Data& operator= (Data&& other) = delete; + Data& operator= (Data&& other) = delete; inline TileBuffer* getTileBuffer (int number); // hash function from tile diff --git a/src/lib/OpenEXR/ImfDeepTiledOutputFile.h b/src/lib/OpenEXR/ImfDeepTiledOutputFile.h index 01c5e09eda..7354b7b59c 100644 --- a/src/lib/OpenEXR/ImfDeepTiledOutputFile.h +++ b/src/lib/OpenEXR/ImfDeepTiledOutputFile.h @@ -429,10 +429,10 @@ class IMF_EXPORT_TYPE DeepTiledOutputFile : public GenericOutputFile // ---------------------------------------------------------------- DeepTiledOutputFile (const OutputPartData* part); - DeepTiledOutputFile (const DeepTiledOutputFile&) = delete; + DeepTiledOutputFile (const DeepTiledOutputFile&) = delete; DeepTiledOutputFile& operator= (const DeepTiledOutputFile&) = delete; DeepTiledOutputFile (DeepTiledOutputFile&&) = delete; - DeepTiledOutputFile& operator= (DeepTiledOutputFile&&) = delete; + DeepTiledOutputFile& operator= (DeepTiledOutputFile&&) = delete; void initialize (const Header& header); diff --git a/src/lib/OpenEXR/ImfDwaCompressor.cpp b/src/lib/OpenEXR/ImfDwaCompressor.cpp index d47add163d..dfaafec7ef 100644 --- a/src/lib/OpenEXR/ImfDwaCompressor.cpp +++ b/src/lib/OpenEXR/ImfDwaCompressor.cpp @@ -2075,7 +2075,8 @@ DwaCompressor::compress ( if (*unknownUncompressedSize > 0) { size_t outSize; - if (EXR_ERR_SUCCESS != exr_compress_buffer( + if (EXR_ERR_SUCCESS != + exr_compress_buffer ( nullptr, 9, // TODO: use default??? the old call to zlib had 9 hardcoded _planarUncBuffer[UNKNOWN], @@ -2114,9 +2115,11 @@ DwaCompressor::compress ( case DEFLATE: { - size_t sourceLen = *totalAcUncompressedCount * sizeof (unsigned short); + size_t sourceLen = + *totalAcUncompressedCount * sizeof (unsigned short); size_t destLen; - if (EXR_ERR_SUCCESS != exr_compress_buffer( + if (EXR_ERR_SUCCESS != + exr_compress_buffer ( nullptr, 9, // TODO: use default??? the old call to zlib had 9 hardcoded _packedAcBuffer, @@ -2167,7 +2170,8 @@ DwaCompressor::compress ( (signed char*) _rleBuffer); size_t dstLen; - if (EXR_ERR_SUCCESS != exr_compress_buffer( + if (EXR_ERR_SUCCESS != + exr_compress_buffer ( nullptr, 9, // TODO: use default??? the old call to zlib had 9 hardcoded _rleBuffer, @@ -2252,11 +2256,11 @@ DwaCompressor::uncompress ( // std::array counterBuf; - memcpy (counterBuf.data (), inPtr, counterBuf.size() * sizeof (uint64_t)); + memcpy (counterBuf.data (), inPtr, counterBuf.size () * sizeof (uint64_t)); for (int i = 0; i < NUM_SIZES_SINGLE; ++i) { - uint64_t* dst = counterBuf.data() + i; - const char* src = (char*) (counterBuf.data() + i); + uint64_t* dst = counterBuf.data () + i; + const char* src = (char*) (counterBuf.data () + i); Xdr::read (src, *dst); } @@ -2265,7 +2269,7 @@ DwaCompressor::uncompress ( // Unwind all the counter info // - const uint64_t* inPtr64 = counterBuf.data(); + const uint64_t* inPtr64 = counterBuf.data (); uint64_t version = *(inPtr64 + VERSION); uint64_t unknownUncompressedSize = *(inPtr64 + UNKNOWN_UNCOMPRESSED_SIZE); @@ -2406,12 +2410,12 @@ DwaCompressor::uncompress ( } if (EXR_ERR_SUCCESS != exr_uncompress_buffer ( - nullptr, - compressedUnknownBuf, - unknownCompressedSize, - _planarUncBuffer[UNKNOWN], - unknownUncompressedSize, - nullptr)) + nullptr, + compressedUnknownBuf, + unknownCompressedSize, + _planarUncBuffer[UNKNOWN], + unknownUncompressedSize, + nullptr)) { throw IEX_NAMESPACE::BaseExc ("Error uncompressing UNKNOWN data."); } @@ -2450,7 +2454,8 @@ DwaCompressor::uncompress ( case DEFLATE: { size_t destLen; - if (EXR_ERR_SUCCESS != exr_uncompress_buffer ( + if (EXR_ERR_SUCCESS != + exr_uncompress_buffer ( nullptr, compressedAcBuf, acCompressedSize, @@ -2523,12 +2528,12 @@ DwaCompressor::uncompress ( size_t dstLen; if (EXR_ERR_SUCCESS != exr_uncompress_buffer ( - nullptr, - compressedRleBuf, - rleCompressedSize, - _rleBuffer, - rleUncompressedSize, - &dstLen)) + nullptr, + compressedRleBuf, + rleCompressedSize, + _rleBuffer, + rleUncompressedSize, + &dstLen)) { throw IEX_NAMESPACE::BaseExc ("Error uncompressing RLE data."); } @@ -2883,7 +2888,8 @@ DwaCompressor::initializeBuffers (size_t& outBufferSize) maxOutBufferSize += std::max ( 2lu * maxLossyDctAcSize + 65536lu, - static_cast (exr_compress_max_buffer_size (maxLossyDctAcSize))); + static_cast ( + exr_compress_max_buffer_size (maxLossyDctAcSize))); numLossyDctChans++; break; @@ -2923,14 +2929,15 @@ DwaCompressor::initializeBuffers (size_t& outBufferSize) // which could take slightly more space // - maxOutBufferSize += static_cast (exr_compress_max_buffer_size (rleBufferSize)); + maxOutBufferSize += + static_cast (exr_compress_max_buffer_size (rleBufferSize)); // // And the same goes for the UNKNOWN data // - maxOutBufferSize += - static_cast (exr_compress_max_buffer_size (unknownBufferSize)); + maxOutBufferSize += static_cast ( + exr_compress_max_buffer_size (unknownBufferSize)); // // Allocate a zip/deflate compressor big enough to hold the DC data diff --git a/src/lib/OpenEXR/ImfDwaCompressorSimd.h b/src/lib/OpenEXR/ImfDwaCompressorSimd.h index c6e8323c07..a88620a4e0 100644 --- a/src/lib/OpenEXR/ImfDwaCompressorSimd.h +++ b/src/lib/OpenEXR/ImfDwaCompressorSimd.h @@ -400,12 +400,17 @@ convertFloatToHalf64_scalar (unsigned short* dst, float* src) void convertFloatToHalf64_neon (unsigned short* dst, float* src) { - for (int i = 0; i < 64; i += 8) { + for (int i = 0; i < 64; i += 8) + { float32x4x2_t vec_fp32 = vld1q_f32_x2 (src + i); - vst1q_u16 (dst + i, vcombine_u16(vreinterpret_u16_f16(vcvt_f16_f32(vec_fp32.val[0])),vreinterpret_u16_f16(vcvt_f16_f32(vec_fp32.val[1])))); + vst1q_u16 ( + dst + i, + vcombine_u16 ( + vreinterpret_u16_f16 (vcvt_f16_f32 (vec_fp32.val[0])), + vreinterpret_u16_f16 (vcvt_f16_f32 (vec_fp32.val[1])))); } } -#endif +#endif // // F16C conversion - Assumes aligned src and dst @@ -430,39 +435,39 @@ convertFloatToHalf64_f16c (unsigned short* dst, float* src) // #if defined IMF_HAVE_GCC_INLINEASM_X86 - __asm__("vmovaps (%0), %%ymm0 \n" - "vmovaps 0x20(%0), %%ymm1 \n" - "vmovaps 0x40(%0), %%ymm2 \n" - "vmovaps 0x60(%0), %%ymm3 \n" - "vcvtps2ph $0, %%ymm0, %%xmm0 \n" - "vcvtps2ph $0, %%ymm1, %%xmm1 \n" - "vcvtps2ph $0, %%ymm2, %%xmm2 \n" - "vcvtps2ph $0, %%ymm3, %%xmm3 \n" - "vmovdqa %%xmm0, 0x00(%1) \n" - "vmovdqa %%xmm1, 0x10(%1) \n" - "vmovdqa %%xmm2, 0x20(%1) \n" - "vmovdqa %%xmm3, 0x30(%1) \n" - "vmovaps 0x80(%0), %%ymm0 \n" - "vmovaps 0xa0(%0), %%ymm1 \n" - "vmovaps 0xc0(%0), %%ymm2 \n" - "vmovaps 0xe0(%0), %%ymm3 \n" - "vcvtps2ph $0, %%ymm0, %%xmm0 \n" - "vcvtps2ph $0, %%ymm1, %%xmm1 \n" - "vcvtps2ph $0, %%ymm2, %%xmm2 \n" - "vcvtps2ph $0, %%ymm3, %%xmm3 \n" - "vmovdqa %%xmm0, 0x40(%1) \n" - "vmovdqa %%xmm1, 0x50(%1) \n" - "vmovdqa %%xmm2, 0x60(%1) \n" - "vmovdqa %%xmm3, 0x70(%1) \n" + __asm__ ("vmovaps (%0), %%ymm0 \n" + "vmovaps 0x20(%0), %%ymm1 \n" + "vmovaps 0x40(%0), %%ymm2 \n" + "vmovaps 0x60(%0), %%ymm3 \n" + "vcvtps2ph $0, %%ymm0, %%xmm0 \n" + "vcvtps2ph $0, %%ymm1, %%xmm1 \n" + "vcvtps2ph $0, %%ymm2, %%xmm2 \n" + "vcvtps2ph $0, %%ymm3, %%xmm3 \n" + "vmovdqa %%xmm0, 0x00(%1) \n" + "vmovdqa %%xmm1, 0x10(%1) \n" + "vmovdqa %%xmm2, 0x20(%1) \n" + "vmovdqa %%xmm3, 0x30(%1) \n" + "vmovaps 0x80(%0), %%ymm0 \n" + "vmovaps 0xa0(%0), %%ymm1 \n" + "vmovaps 0xc0(%0), %%ymm2 \n" + "vmovaps 0xe0(%0), %%ymm3 \n" + "vcvtps2ph $0, %%ymm0, %%xmm0 \n" + "vcvtps2ph $0, %%ymm1, %%xmm1 \n" + "vcvtps2ph $0, %%ymm2, %%xmm2 \n" + "vcvtps2ph $0, %%ymm3, %%xmm3 \n" + "vmovdqa %%xmm0, 0x40(%1) \n" + "vmovdqa %%xmm1, 0x50(%1) \n" + "vmovdqa %%xmm2, 0x60(%1) \n" + "vmovdqa %%xmm3, 0x70(%1) \n" # ifndef __AVX__ - "vzeroupper \n" -# endif /* __AVX__ */ - : /* Output */ - : /* Input */ "r"(src), "r"(dst) + "vzeroupper \n" +# endif /* __AVX__ */ + : /* Output */ + : /* Input */ "r"(src), "r"(dst) # ifndef __AVX__ - : /* Clobber */ "%xmm0", "%xmm1", "%xmm2", "%xmm3", "memory" + : /* Clobber */ "%xmm0", "%xmm1", "%xmm2", "%xmm3", "memory" # else - : /* Clobber */ "%ymm0", "%ymm1", "%ymm2", "%ymm3", "memory" + : /* Clobber */ "%ymm0", "%ymm1", "%ymm2", "%ymm3", "memory" # endif /* __AVX__ */ ); #else @@ -823,36 +828,39 @@ fromHalfZigZag_f16c (unsigned short* src, float* dst) #ifdef IMF_HAVE_NEON_AARCH64 - void -fromHalfZigZag_neon(unsigned short* __restrict__ src, float* __restrict__ dst) +fromHalfZigZag_neon (unsigned short* __restrict__ src, float* __restrict__ dst) { uint8x16_t res_tbl[4] = { - {0, 1, 5, 6, 14, 15, 27, 28, 2 , 4 , 7 ,13, 16, 26, 29, 42}, - {3 , 8 ,12 ,17, 25, 30, 41, 43,9 ,11 ,18 ,24, 31, 40, 44, 53}, - {10 ,19 ,23 ,32, 39, 45, 52, 54,20 ,22 ,33 ,38, 46, 51, 55, 60}, - {21 ,34 ,37 ,47, 50, 56, 59, 61,35 ,36 ,48 ,49, 57, 58, 62, 63}}; - - uint8x16x4_t vec_input_l,vec_input_h; - + {0, 1, 5, 6, 14, 15, 27, 28, 2, 4, 7, 13, 16, 26, 29, 42}, + {3, 8, 12, 17, 25, 30, 41, 43, 9, 11, 18, 24, 31, 40, 44, 53}, + {10, 19, 23, 32, 39, 45, 52, 54, 20, 22, 33, 38, 46, 51, 55, 60}, + {21, 34, 37, 47, 50, 56, 59, 61, 35, 36, 48, 49, 57, 58, 62, 63}}; + + uint8x16x4_t vec_input_l, vec_input_h; + for (int i = 0; i < 4; i++) { - uint8x16x2_t vec_in_u8 = vld2q_u8 ((unsigned char*)(src + 16 * i)); - vec_input_l.val[i] = vec_in_u8.val[0]; - vec_input_h.val[i] = vec_in_u8.val[1]; + uint8x16x2_t vec_in_u8 = vld2q_u8 ((unsigned char*) (src + 16 * i)); + vec_input_l.val[i] = vec_in_u8.val[0]; + vec_input_h.val[i] = vec_in_u8.val[1]; } - -#pragma unroll(4) - for (int i = 0; i < 4 ; i++) { - uint8x16_t res_vec_l,res_vec_h; - res_vec_l = vqtbl4q_u8(vec_input_l,res_tbl[i]); - res_vec_h = vqtbl4q_u8(vec_input_h,res_tbl[i]); - float16x8_t res_vec_l_f16 = vreinterpretq_f16_u8(vzip1q_u8(res_vec_l,res_vec_h)); - float16x8_t res_vec_h_f16 = vreinterpretq_f16_u8(vzip2q_u8(res_vec_l,res_vec_h)); - vst1q_f32(dst + i*16, vcvt_f32_f16(vget_low_f16(res_vec_l_f16))); - vst1q_f32(dst + i*16+4, vcvt_high_f32_f16(res_vec_l_f16)); - vst1q_f32(dst + i*16+8, vcvt_f32_f16(vget_low_f16(res_vec_h_f16))); - vst1q_f32(dst + i*16+12, vcvt_high_f32_f16(res_vec_h_f16)); + +# pragma unroll(4) + for (int i = 0; i < 4; i++) + { + uint8x16_t res_vec_l, res_vec_h; + res_vec_l = vqtbl4q_u8 (vec_input_l, res_tbl[i]); + res_vec_h = vqtbl4q_u8 (vec_input_h, res_tbl[i]); + float16x8_t res_vec_l_f16 = + vreinterpretq_f16_u8 (vzip1q_u8 (res_vec_l, res_vec_h)); + float16x8_t res_vec_h_f16 = + vreinterpretq_f16_u8 (vzip2q_u8 (res_vec_l, res_vec_h)); + vst1q_f32 (dst + i * 16, vcvt_f32_f16 (vget_low_f16 (res_vec_l_f16))); + vst1q_f32 (dst + i * 16 + 4, vcvt_high_f32_f16 (res_vec_l_f16)); + vst1q_f32 ( + dst + i * 16 + 8, vcvt_f32_f16 (vget_low_f16 (res_vec_h_f16))); + vst1q_f32 (dst + i * 16 + 12, vcvt_high_f32_f16 (res_vec_h_f16)); } } diff --git a/src/lib/OpenEXR/ImfEnvmap.cpp b/src/lib/OpenEXR/ImfEnvmap.cpp index 64e41419ef..3558c32091 100644 --- a/src/lib/OpenEXR/ImfEnvmap.cpp +++ b/src/lib/OpenEXR/ImfEnvmap.cpp @@ -49,10 +49,7 @@ latLong (const Box2i& dataWindow, const V2f& pixelPosition) (dataWindow.max.y - dataWindow.min.y) - 0.5f); } - else - { - latitude = 0; - } + else { latitude = 0; } if (dataWindow.max.x > dataWindow.min.x) { @@ -61,10 +58,7 @@ latLong (const Box2i& dataWindow, const V2f& pixelPosition) (dataWindow.max.x - dataWindow.min.x) - 0.5f); } - else - { - longitude = 0; - } + else { longitude = 0; } return V2f (latitude, longitude); } @@ -235,10 +229,7 @@ direction (CubeMapFace face, const Box2i& dataWindow, const V2f& positionInFace) positionInFace.x / (sof - 1) * 2 - 1, positionInFace.y / (sof - 1) * 2 - 1); } - else - { - pos = V2f (0, 0); - } + else { pos = V2f (0, 0); } V3f dir (1, 0, 0); diff --git a/src/lib/OpenEXR/ImfExport.h b/src/lib/OpenEXR/ImfExport.h index e53065e407..2b2702295d 100644 --- a/src/lib/OpenEXR/ImfExport.h +++ b/src/lib/OpenEXR/ImfExport.h @@ -18,7 +18,7 @@ // where we need to switch depending on whether we are compiling // internally or not # if defined(OPENEXR_EXPORTS) -# define IMF_EXPORT __declspec(dllexport) +# define IMF_EXPORT __declspec (dllexport) // mingw needs the export when the extern is defined # if defined(__MINGW32__) @@ -37,7 +37,7 @@ # endif # else // OPENEXR_EXPORTS -# define IMF_EXPORT __declspec(dllimport) +# define IMF_EXPORT __declspec (dllimport) # define IMF_EXPORT_EXTERN_TEMPLATE IMF_EXPORT # define IMF_EXPORT_TEMPLATE_INSTANCE # define IMF_EXPORT_TEMPLATE_TYPE diff --git a/src/lib/OpenEXR/ImfFastHuf.cpp b/src/lib/OpenEXR/ImfFastHuf.cpp index 82cf2ed278..a750929cb5 100644 --- a/src/lib/OpenEXR/ImfFastHuf.cpp +++ b/src/lib/OpenEXR/ImfFastHuf.cpp @@ -13,7 +13,6 @@ // Static enabling/disabling the fast huffman decode - #if defined(__APPLE__) && defined(__clang__) // // Enabled for clang on Apple platforms (tested): @@ -325,11 +324,11 @@ FastHufDecoder::~FastHufDecoder () bool FastHufDecoder::enabled () { -# ifdef OPENEXR_IMF_ENABLE_FAST_HUF_DECODER +#ifdef OPENEXR_IMF_ENABLE_FAST_HUF_DECODER return true; -# else +#else return false; -# endif +#endif } // @@ -425,10 +424,7 @@ FastHufDecoder::buildTables (uint64_t* base, uint64_t* offset) _tableMin = 0xffffffffffffffffULL; } - else - { - _tableMin = _ljBase[minIdx]; - } + else { _tableMin = _ljBase[minIdx]; } } // @@ -523,10 +519,7 @@ FastHufDecoder::refill ( // if (bufferBackNumBits <= numBits) { bufferBack = 0; } - else - { - bufferBack = bufferBack << numBits; - } + else { bufferBack = bufferBack << numBits; } bufferBackNumBits -= numBits; } diff --git a/src/lib/OpenEXR/ImfFastHuf.h b/src/lib/OpenEXR/ImfFastHuf.h index a21892588d..8add2c37c5 100644 --- a/src/lib/OpenEXR/ImfFastHuf.h +++ b/src/lib/OpenEXR/ImfFastHuf.h @@ -62,10 +62,10 @@ class FastHufDecoder ~FastHufDecoder (); - FastHufDecoder (const FastHufDecoder& other) = delete; + FastHufDecoder (const FastHufDecoder& other) = delete; FastHufDecoder& operator= (const FastHufDecoder& other) = delete; FastHufDecoder (FastHufDecoder&& other) = delete; - FastHufDecoder& operator= (FastHufDecoder&& other) = delete; + FastHufDecoder& operator= (FastHufDecoder&& other) = delete; static bool enabled (); diff --git a/src/lib/OpenEXR/ImfGenericOutputFile.cpp b/src/lib/OpenEXR/ImfGenericOutputFile.cpp index 08c54f9526..b694c1a6a2 100644 --- a/src/lib/OpenEXR/ImfGenericOutputFile.cpp +++ b/src/lib/OpenEXR/ImfGenericOutputFile.cpp @@ -68,10 +68,7 @@ GenericOutputFile::writeMagicNumberAndVersionField ( { if (headers[0].type () == TILEDIMAGE) version |= TILED_FLAG; } - else - { - version |= MULTI_PART_FILE_FLAG; - } + else { version |= MULTI_PART_FILE_FLAG; } for (int i = 0; i < parts; i++) { diff --git a/src/lib/OpenEXR/ImfHeader.cpp b/src/lib/OpenEXR/ImfHeader.cpp index be7f3c9664..875686b26f 100644 --- a/src/lib/OpenEXR/ImfHeader.cpp +++ b/src/lib/OpenEXR/ImfHeader.cpp @@ -68,8 +68,8 @@ struct CompressionRecord { CompressionRecord () { - exr_get_default_zip_compression_level(&zip_level); - exr_get_default_dwa_compression_quality(&dwa_level); + exr_get_default_zip_compression_level (&zip_level); + exr_get_default_dwa_compression_quality (&dwa_level); } int zip_level; float dwa_level; @@ -419,7 +419,8 @@ Header::erase (const char name[]) "Image attribute name cannot be an empty string."); AttributeMap::iterator i = _map.find (name); - if (i != _map.end ()) { + if (i != _map.end ()) + { delete i->second; _map.erase (i); } @@ -1274,18 +1275,17 @@ Header::setMaxTileSize (int maxWidth, int maxHeight) void Header::getMaxImageSize (int& maxWidth, int& maxHeight) { - maxWidth = maxImageWidth; + maxWidth = maxImageWidth; maxHeight = maxImageHeight; } void Header::getMaxTileSize (int& maxWidth, int& maxHeight) { - maxWidth = maxTileWidth; - maxHeight= maxTileHeight; + maxWidth = maxTileWidth; + maxHeight = maxTileHeight; } - bool Header::readsNothing () { diff --git a/src/lib/OpenEXR/ImfHeader.h b/src/lib/OpenEXR/ImfHeader.h index e09782b89c..e965bffbc9 100644 --- a/src/lib/OpenEXR/ImfHeader.h +++ b/src/lib/OpenEXR/ImfHeader.h @@ -451,7 +451,6 @@ class IMF_EXPORT_TYPE Header IMF_EXPORT static void getMaxTileSize (int& maxWidth, int& maxHeight); - // // Check if the header reads nothing. // diff --git a/src/lib/OpenEXR/ImfHuf.cpp b/src/lib/OpenEXR/ImfHuf.cpp index 15bb9bbe6b..17e1ac8abd 100644 --- a/src/lib/OpenEXR/ImfHuf.cpp +++ b/src/lib/OpenEXR/ImfHuf.cpp @@ -610,10 +610,7 @@ hufBuildDecTable ( delete[] p; } - else - { - pl->p = new int[1]; - } + else { pl->p = new int[1]; } pl->p[pl->lit - 1] = im; } @@ -785,14 +782,8 @@ int hufEncode // return: output size (in bits) while (cs-- > 0) \ *out++ = s; \ } \ - else if (out < oe) \ - { \ - *out++ = po; \ - } \ - else \ - { \ - tooMuchData (); \ - } \ + else if (out < oe) { *out++ = po; } \ + else { tooMuchData (); } \ } // diff --git a/src/lib/OpenEXR/ImfIDManifest.cpp b/src/lib/OpenEXR/ImfIDManifest.cpp index 1cb53d7c5d..3df9a930dd 100644 --- a/src/lib/OpenEXR/ImfIDManifest.cpp +++ b/src/lib/OpenEXR/ImfIDManifest.cpp @@ -343,10 +343,7 @@ IDManifest::init (const char* data, const char* endOfData) size_t ((unsigned char) (stringList[i][1])); stringStart = 2; } - else - { - common = (unsigned char) stringList[i][0]; - } + else { common = (unsigned char) stringList[i][0]; } if (common > stringList[i - 1].size ()) { throw IEX_NAMESPACE::InputExc ( @@ -537,15 +534,15 @@ IDManifest::IDManifest (const CompressedIDManifest& compressed) // vector uncomp (compressed._uncompressedDataSize); - size_t outSize; - size_t inSize = static_cast (compressed._compressedDataSize); + size_t outSize; + size_t inSize = static_cast (compressed._compressedDataSize); if (EXR_ERR_SUCCESS != exr_uncompress_buffer ( - nullptr, - compressed._data, - inSize, - uncomp.data(), - compressed._uncompressedDataSize, - &outSize)) + nullptr, + compressed._data, + inSize, + uncomp.data (), + compressed._uncompressedDataSize, + &outSize)) { throw IEX_NAMESPACE::InputExc ( "IDManifest decompression (zlib) failed."); @@ -1071,15 +1068,15 @@ CompressedIDManifest::CompressedIDManifest (const IDManifest& manifest) // size_t compressedBufferSize = exr_compress_max_buffer_size (outputSize); size_t compressedDataSize; - _data = (unsigned char*) malloc (compressedBufferSize); + _data = (unsigned char*) malloc (compressedBufferSize); if (EXR_ERR_SUCCESS != exr_compress_buffer ( - nullptr, - -1, - serial.data (), - outputSize, - _data, - compressedBufferSize, - &compressedDataSize)) + nullptr, + -1, + serial.data (), + outputSize, + _data, + compressedBufferSize, + &compressedDataSize)) { throw IEX_NAMESPACE::InputExc ("ID manifest compression failed"); } @@ -1244,10 +1241,7 @@ IDManifest::ChannelGroupManifest::insert (const std::vector& text) { uint64_t hash; if (_hashScheme == MURMURHASH3_32) { hash = MurmurHash32 (text); } - else if (_hashScheme == MURMURHASH3_64) - { - hash = MurmurHash64 (text); - } + else if (_hashScheme == MURMURHASH3_64) { hash = MurmurHash64 (text); } else { THROW ( @@ -1263,10 +1257,7 @@ IDManifest::ChannelGroupManifest::insert (const std::string& text) { uint64_t hash; if (_hashScheme == MURMURHASH3_32) { hash = MurmurHash32 (text); } - else if (_hashScheme == MURMURHASH3_64) - { - hash = MurmurHash64 (text); - } + else if (_hashScheme == MURMURHASH3_64) { hash = MurmurHash64 (text); } else { THROW ( @@ -1300,10 +1291,7 @@ IDManifest::ChannelGroupManifest::operator<< (uint64_t idValue) // There's little purpose to this, but it means that this entry is now 'complete' // if (_components.size () == 0) { _insertingEntry = false; } - else - { - _insertingEntry = true; - } + else { _insertingEntry = true; } return *this; } diff --git a/src/lib/OpenEXR/ImfIDManifestAttribute.cpp b/src/lib/OpenEXR/ImfIDManifestAttribute.cpp index 71f41abe8d..6882bb597e 100644 --- a/src/lib/OpenEXR/ImfIDManifestAttribute.cpp +++ b/src/lib/OpenEXR/ImfIDManifestAttribute.cpp @@ -40,7 +40,7 @@ IDManifestAttribute::readValueFrom ( OPENEXR_IMF_INTERNAL_NAMESPACE::IStream& is, int size, int version) { - if (size < static_cast(sizeof (uint64_t))) + if (size < static_cast (sizeof (uint64_t))) { throw IEX_NAMESPACE::InputExc ( "Invalid size field reading idmanifest attribute"); @@ -65,8 +65,9 @@ IDManifestAttribute::readValueFrom ( // // allocate memory for compressed storage and read data // - _value._data = static_cast (malloc (size - sizeof (uint64_t))); - char* input = (char*) _value._data; + _value._data = + static_cast (malloc (size - sizeof (uint64_t))); + char* input = (char*) _value._data; Xdr::read (is, input, _value._compressedDataSize); } diff --git a/src/lib/OpenEXR/ImfIO.h b/src/lib/OpenEXR/ImfIO.h index 4d9f772969..1008e639e2 100644 --- a/src/lib/OpenEXR/ImfIO.h +++ b/src/lib/OpenEXR/ImfIO.h @@ -99,10 +99,10 @@ class IMF_EXPORT_TYPE IStream IMF_EXPORT IStream (const char fileName[]); private: - IStream (const IStream&) = delete; + IStream (const IStream&) = delete; IStream& operator= (const IStream&) = delete; IStream (IStream&&) = delete; - IStream& operator= (IStream&&) = delete; + IStream& operator= (IStream&&) = delete; std::string _fileName; }; @@ -156,10 +156,10 @@ class IMF_EXPORT_TYPE OStream IMF_EXPORT OStream (const char fileName[]); private: - OStream (const OStream&) = delete; + OStream (const OStream&) = delete; OStream& operator= (const OStream&) = delete; OStream (OStream&&) = delete; - OStream& operator= (OStream&&) = delete; + OStream& operator= (OStream&&) = delete; std::string _fileName; }; diff --git a/src/lib/OpenEXR/ImfInputFile.cpp b/src/lib/OpenEXR/ImfInputFile.cpp index e5e4d218d4..cf401f96b2 100644 --- a/src/lib/OpenEXR/ImfInputFile.cpp +++ b/src/lib/OpenEXR/ImfInputFile.cpp @@ -82,10 +82,10 @@ struct InputFile::Data Data (int numThreads); ~Data (); - Data (const Data& other) = delete; + Data (const Data& other) = delete; Data& operator= (const Data& other) = delete; Data (Data&& other) = delete; - Data& operator= (Data&& other) = delete; + Data& operator= (Data&& other) = delete; void deleteCachedBuffer (); }; @@ -142,17 +142,17 @@ InputFile::Data::deleteCachedBuffer () { case OPENEXR_IMF_INTERNAL_NAMESPACE::UINT: - delete[](((unsigned int*) s.base) + offset); + delete[] (((unsigned int*) s.base) + offset); break; case OPENEXR_IMF_INTERNAL_NAMESPACE::HALF: - delete[]((half*) s.base + offset); + delete[] ((half*) s.base + offset); break; case OPENEXR_IMF_INTERNAL_NAMESPACE::FLOAT: - delete[](((float*) s.base) + offset); + delete[] (((float*) s.base) + offset); break; case NUM_PIXELTYPES: throw (IEX_NAMESPACE::ArgExc ("Invalid pixel type")); @@ -338,7 +338,8 @@ bufferedReadPixels (InputFile::Data* ifd, int scanLine1, int scanLine2) switch (toSlice.type) { case UINT: { - unsigned int fill = static_cast(toSlice.fillValue); + unsigned int fill = + static_cast (toSlice.fillValue); for (int x = xStart; x <= levelRange.max.x; x += toSlice.xSampling) { @@ -770,17 +771,20 @@ InputFile::setFrameBuffer (const FrameBuffer& frameBuffer) { case OPENEXR_IMF_INTERNAL_NAMESPACE::UINT: - _data->cachedBuffer->insert - (k.name(), - Slice (UINT, - (char *)(new unsigned int[tileRowSize] - - _data->offset), + _data->cachedBuffer->insert ( + k.name (), + Slice ( + UINT, + (char*) (new unsigned int[tileRowSize] - + _data->offset), sizeof (unsigned int), sizeof (unsigned int) * - _data->tFile->levelWidth(0), - 1, 1, + _data->tFile->levelWidth (0), + 1, + 1, s.fillValue, - false, true)); + false, + true)); break; case OPENEXR_IMF_INTERNAL_NAMESPACE::HALF: @@ -789,7 +793,8 @@ InputFile::setFrameBuffer (const FrameBuffer& frameBuffer) k.name (), Slice ( HALF, - (char*) (new half[tileRowSize] - _data->offset), + (char*) (new half[tileRowSize] - + _data->offset), sizeof (half), sizeof (half) * _data->tFile->levelWidth (0), @@ -806,7 +811,8 @@ InputFile::setFrameBuffer (const FrameBuffer& frameBuffer) k.name (), Slice ( OPENEXR_IMF_INTERNAL_NAMESPACE::FLOAT, - (char*) (new float[tileRowSize] - _data->offset), + (char*) (new float[tileRowSize] - + _data->offset), sizeof (float), sizeof (float) * _data->tFile->levelWidth (0), @@ -852,10 +858,7 @@ InputFile::frameBuffer () const #endif return _data->tFileBuffer; } - else - { - return _data->sFile->frameBuffer (); - } + else { return _data->sFile->frameBuffer (); } } bool @@ -873,10 +876,7 @@ bool InputFile::isOptimizationEnabled () const { if (_data->sFile) { return _data->sFile->isOptimizationEnabled (); } - else - { - return false; - } + else { return false; } } void @@ -893,10 +893,7 @@ InputFile::readPixels (int scanLine1, int scanLine2) #endif bufferedReadPixels (_data, scanLine1, scanLine2); } - else - { - _data->sFile->readPixels (scanLine1, scanLine2); - } + else { _data->sFile->readPixels (scanLine1, scanLine2); } } void diff --git a/src/lib/OpenEXR/ImfInputFile.h b/src/lib/OpenEXR/ImfInputFile.h index 28ec427389..ecda904e4e 100644 --- a/src/lib/OpenEXR/ImfInputFile.h +++ b/src/lib/OpenEXR/ImfInputFile.h @@ -204,10 +204,10 @@ class IMF_EXPORT_TYPE InputFile : public GenericInputFile private: IMF_HIDDEN InputFile (InputPartData* part); - InputFile (const InputFile&) = delete; + InputFile (const InputFile&) = delete; InputFile& operator= (const InputFile&) = delete; InputFile (InputFile&&) = delete; - InputFile& operator= (InputFile&&) = delete; + InputFile& operator= (InputFile&&) = delete; IMF_HIDDEN void initialize (); IMF_HIDDEN void multiPartInitialize (InputPartData* part); diff --git a/src/lib/OpenEXR/ImfMisc.cpp b/src/lib/OpenEXR/ImfMisc.cpp index fbf035d4d1..01e7469102 100644 --- a/src/lib/OpenEXR/ImfMisc.cpp +++ b/src/lib/OpenEXR/ImfMisc.cpp @@ -684,7 +684,8 @@ copyIntoDeepFrameBuffer ( for (int x = minX; x <= maxX; x++) { char* writePtr = *( - char**) (base + (y - yOffsetForData) * yPointerStride + (x - xOffsetForData) * xPointerStride); + char**) (base + (y - yOffsetForData) * yPointerStride + + (x - xOffsetForData) * xPointerStride); if (writePtr) { int count = sampleCount ( @@ -711,7 +712,8 @@ copyIntoDeepFrameBuffer ( for (int x = minX; x <= maxX; x++) { char* writePtr = *( - char**) (base + (y - yOffsetForData) * yPointerStride + (x - xOffsetForData) * xPointerStride); + char**) (base + (y - yOffsetForData) * yPointerStride + + (x - xOffsetForData) * xPointerStride); if (writePtr) { @@ -739,7 +741,8 @@ copyIntoDeepFrameBuffer ( for (int x = minX; x <= maxX; x++) { char* writePtr = *( - char**) (base + (y - yOffsetForData) * yPointerStride + (x - xOffsetForData) * xPointerStride); + char**) (base + (y - yOffsetForData) * yPointerStride + + (x - xOffsetForData) * xPointerStride); if (writePtr) { @@ -783,7 +786,9 @@ copyIntoDeepFrameBuffer ( for (int x = minX; x <= maxX; x++) { char* writePtr = *( - char**) (base + (y - yOffsetForData) * yPointerStride + (x - xOffsetForData) * xPointerStride); + char**) (base + + (y - yOffsetForData) * yPointerStride + + (x - xOffsetForData) * xPointerStride); int count = sampleCount ( sampleCountBase, @@ -815,7 +820,9 @@ copyIntoDeepFrameBuffer ( for (int x = minX; x <= maxX; x++) { char* writePtr = *( - char**) (base + (y - yOffsetForData) * yPointerStride + (x - xOffsetForData) * xPointerStride); + char**) (base + + (y - yOffsetForData) * yPointerStride + + (x - xOffsetForData) * xPointerStride); int count = sampleCount ( sampleCountBase, @@ -847,7 +854,9 @@ copyIntoDeepFrameBuffer ( for (int x = minX; x <= maxX; x++) { char* writePtr = *( - char**) (base + (y - yOffsetForData) * yPointerStride + (x - xOffsetForData) * xPointerStride); + char**) (base + + (y - yOffsetForData) * yPointerStride + + (x - xOffsetForData) * xPointerStride); int count = sampleCount ( sampleCountBase, @@ -888,7 +897,9 @@ copyIntoDeepFrameBuffer ( for (int x = minX; x <= maxX; x++) { char* writePtr = *( - char**) (base + (y - yOffsetForData) * yPointerStride + (x - xOffsetForData) * xPointerStride); + char**) (base + + (y - yOffsetForData) * yPointerStride + + (x - xOffsetForData) * xPointerStride); int count = sampleCount ( sampleCountBase, @@ -921,7 +932,9 @@ copyIntoDeepFrameBuffer ( for (int x = minX; x <= maxX; x++) { char* writePtr = *( - char**) (base + (y - yOffsetForData) * yPointerStride + (x - xOffsetForData) * xPointerStride); + char**) (base + + (y - yOffsetForData) * yPointerStride + + (x - xOffsetForData) * xPointerStride); int count = sampleCount ( sampleCountBase, @@ -952,7 +965,9 @@ copyIntoDeepFrameBuffer ( for (int x = minX; x <= maxX; x++) { char* writePtr = *( - char**) (base + (y - yOffsetForData) * yPointerStride + (x - xOffsetForData) * xPointerStride); + char**) (base + + (y - yOffsetForData) * yPointerStride + + (x - xOffsetForData) * xPointerStride); int count = sampleCount ( sampleCountBase, @@ -993,7 +1008,9 @@ copyIntoDeepFrameBuffer ( for (int x = minX; x <= maxX; x++) { char* writePtr = *( - char**) (base + (y - yOffsetForData) * yPointerStride + (x - xOffsetForData) * xPointerStride); + char**) (base + + (y - yOffsetForData) * yPointerStride + + (x - xOffsetForData) * xPointerStride); int count = sampleCount ( sampleCountBase, @@ -1025,7 +1042,9 @@ copyIntoDeepFrameBuffer ( for (int x = minX; x <= maxX; x++) { char* writePtr = *( - char**) (base + (y - yOffsetForData) * yPointerStride + (x - xOffsetForData) * xPointerStride); + char**) (base + + (y - yOffsetForData) * yPointerStride + + (x - xOffsetForData) * xPointerStride); int count = sampleCount ( sampleCountBase, @@ -1057,7 +1076,9 @@ copyIntoDeepFrameBuffer ( for (int x = minX; x <= maxX; x++) { char* writePtr = *( - char**) (base + (y - yOffsetForData) * yPointerStride + (x - xOffsetForData) * xPointerStride); + char**) (base + + (y - yOffsetForData) * yPointerStride + + (x - xOffsetForData) * xPointerStride); int count = sampleCount ( sampleCountBase, @@ -1110,7 +1131,9 @@ copyIntoDeepFrameBuffer ( for (int x = minX; x <= maxX; x++) { char* writePtr = *( - char**) (base + (y - yOffsetForData) * yPointerStride + (x - xOffsetForData) * xPointerStride); + char**) (base + + (y - yOffsetForData) * yPointerStride + + (x - xOffsetForData) * xPointerStride); int count = sampleCount ( sampleCountBase, @@ -1132,10 +1155,7 @@ copyIntoDeepFrameBuffer ( writePtr += sampleStride; } } - else - { - readPtr += sizeof (unsigned int) * count; - } + else { readPtr += sizeof (unsigned int) * count; } } break; @@ -1144,7 +1164,9 @@ copyIntoDeepFrameBuffer ( for (int x = minX; x <= maxX; x++) { char* writePtr = *( - char**) (base + (y - yOffsetForData) * yPointerStride + (x - xOffsetForData) * xPointerStride); + char**) (base + + (y - yOffsetForData) * yPointerStride + + (x - xOffsetForData) * xPointerStride); int count = sampleCount ( sampleCountBase, @@ -1163,10 +1185,7 @@ copyIntoDeepFrameBuffer ( writePtr += sampleStride; } } - else - { - readPtr += sizeof (half) * count; - } + else { readPtr += sizeof (half) * count; } } break; @@ -1175,7 +1194,9 @@ copyIntoDeepFrameBuffer ( for (int x = minX; x <= maxX; x++) { char* writePtr = *( - char**) (base + (y - yOffsetForData) * yPointerStride + (x - xOffsetForData) * xPointerStride); + char**) (base + + (y - yOffsetForData) * yPointerStride + + (x - xOffsetForData) * xPointerStride); int count = sampleCount ( sampleCountBase, @@ -1199,10 +1220,7 @@ copyIntoDeepFrameBuffer ( writePtr += sampleStride; } } - else - { - readPtr += sizeof (float) * count; - } + else { readPtr += sizeof (float) * count; } } break; default: @@ -1221,7 +1239,9 @@ copyIntoDeepFrameBuffer ( for (int x = minX; x <= maxX; x++) { char* writePtr = *( - char**) (base + (y - yOffsetForData) * yPointerStride + (x - xOffsetForData) * xPointerStride); + char**) (base + + (y - yOffsetForData) * yPointerStride + + (x - xOffsetForData) * xPointerStride); int count = sampleCount ( sampleCountBase, @@ -1246,10 +1266,7 @@ copyIntoDeepFrameBuffer ( writePtr += sampleStride; } } - else - { - readPtr += sizeof (unsigned int) * count; - } + else { readPtr += sizeof (unsigned int) * count; } } break; @@ -1258,7 +1275,9 @@ copyIntoDeepFrameBuffer ( for (int x = minX; x <= maxX; x++) { char* writePtr = *( - char**) (base + (y - yOffsetForData) * yPointerStride + (x - xOffsetForData) * xPointerStride); + char**) (base + + (y - yOffsetForData) * yPointerStride + + (x - xOffsetForData) * xPointerStride); int count = sampleCount ( sampleCountBase, @@ -1276,10 +1295,7 @@ copyIntoDeepFrameBuffer ( writePtr += sampleStride; } } - else - { - readPtr += sizeof (half) * count; - } + else { readPtr += sizeof (half) * count; } } break; @@ -1288,7 +1304,9 @@ copyIntoDeepFrameBuffer ( for (int x = minX; x <= maxX; x++) { char* writePtr = *( - char**) (base + (y - yOffsetForData) * yPointerStride + (x - xOffsetForData) * xPointerStride); + char**) (base + + (y - yOffsetForData) * yPointerStride + + (x - xOffsetForData) * xPointerStride); int count = sampleCount ( sampleCountBase, @@ -1311,10 +1329,7 @@ copyIntoDeepFrameBuffer ( writePtr += sampleStride; } } - else - { - readPtr += sizeof (float) * count; - } + else { readPtr += sizeof (float) * count; } } break; default: @@ -1333,7 +1348,9 @@ copyIntoDeepFrameBuffer ( for (int x = minX; x <= maxX; x++) { char* writePtr = *( - char**) (base + (y - yOffsetForData) * yPointerStride + (x - xOffsetForData) * xPointerStride); + char**) (base + + (y - yOffsetForData) * yPointerStride + + (x - xOffsetForData) * xPointerStride); int count = sampleCount ( sampleCountBase, @@ -1358,10 +1375,7 @@ copyIntoDeepFrameBuffer ( writePtr += sampleStride; } } - else - { - readPtr += sizeof (unsigned int) * count; - } + else { readPtr += sizeof (unsigned int) * count; } } break; @@ -1370,7 +1384,9 @@ copyIntoDeepFrameBuffer ( for (int x = minX; x <= maxX; x++) { char* writePtr = *( - char**) (base + (y - yOffsetForData) * yPointerStride + (x - xOffsetForData) * xPointerStride); + char**) (base + + (y - yOffsetForData) * yPointerStride + + (x - xOffsetForData) * xPointerStride); int count = sampleCount ( sampleCountBase, @@ -1389,10 +1405,7 @@ copyIntoDeepFrameBuffer ( writePtr += sampleStride; } } - else - { - readPtr += sizeof (half) * count; - } + else { readPtr += sizeof (half) * count; } } break; @@ -1401,7 +1414,9 @@ copyIntoDeepFrameBuffer ( for (int x = minX; x <= maxX; x++) { char* writePtr = *( - char**) (base + (y - yOffsetForData) * yPointerStride + (x - xOffsetForData) * xPointerStride); + char**) (base + + (y - yOffsetForData) * yPointerStride + + (x - xOffsetForData) * xPointerStride); int count = sampleCount ( sampleCountBase, @@ -1421,10 +1436,7 @@ copyIntoDeepFrameBuffer ( writePtr += sampleStride; } } - else - { - readPtr += sizeof (float) * count; - } + else { readPtr += sizeof (float) * count; } } break; default: @@ -1992,7 +2004,7 @@ WidenFilename (const char* filename) } const char* -getLibraryVersion() +getLibraryVersion () { return OPENEXR_VERSION_STRING; } diff --git a/src/lib/OpenEXR/ImfMisc.h b/src/lib/OpenEXR/ImfMisc.h index cb65ab6701..b7e9d1a281 100644 --- a/src/lib/OpenEXR/ImfMisc.h +++ b/src/lib/OpenEXR/ImfMisc.h @@ -446,7 +446,7 @@ std::wstring WidenFilename (const char* filename); // Return the string that describes the major.minor.patch release version // -IMF_EXPORT const char* getLibraryVersion(); +IMF_EXPORT const char* getLibraryVersion (); OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT diff --git a/src/lib/OpenEXR/ImfMultiPartInputFile.cpp b/src/lib/OpenEXR/ImfMultiPartInputFile.cpp index dc04a66dc1..75a3ee193c 100644 --- a/src/lib/OpenEXR/ImfMultiPartInputFile.cpp +++ b/src/lib/OpenEXR/ImfMultiPartInputFile.cpp @@ -86,10 +86,10 @@ struct MultiPartInputFile::Data : public InputStreamMutex delete parts[i]; } - Data (const Data& other) = delete; + Data (const Data& other) = delete; Data& operator= (const Data& other) = delete; Data (Data&& other) = delete; - Data& operator= (Data&& other) = delete; + Data& operator= (Data&& other) = delete; template T* createInputPartT (int partNumber) {} }; @@ -197,7 +197,7 @@ MultiPartInputFile::getPart (int partNumber) const Header& MultiPartInputFile::header (int n) const { - if (n < 0 || static_cast(n) >= _data->_headers.size ()) + if (n < 0 || static_cast (n) >= _data->_headers.size ()) { THROW ( IEX_NAMESPACE::ArgExc, @@ -845,7 +845,7 @@ bool MultiPartInputFile::partComplete (int part) const { - if (part < 0 || static_cast(part) >= _data->_headers.size ()) + if (part < 0 || static_cast (part) >= _data->_headers.size ()) { THROW ( IEX_NAMESPACE::ArgExc, diff --git a/src/lib/OpenEXR/ImfMultiPartInputFile.h b/src/lib/OpenEXR/ImfMultiPartInputFile.h index afe622d5c2..0b499147a5 100644 --- a/src/lib/OpenEXR/ImfMultiPartInputFile.h +++ b/src/lib/OpenEXR/ImfMultiPartInputFile.h @@ -75,10 +75,10 @@ class IMF_EXPORT_TYPE MultiPartInputFile : public GenericInputFile private: Data* _data; - MultiPartInputFile (const MultiPartInputFile&) = delete; + MultiPartInputFile (const MultiPartInputFile&) = delete; MultiPartInputFile& operator= (const MultiPartInputFile&) = delete; MultiPartInputFile (MultiPartInputFile&&) = delete; - MultiPartInputFile& operator= (MultiPartInputFile&&) = delete; + MultiPartInputFile& operator= (MultiPartInputFile&&) = delete; // // used internally by 'Part' types to access individual parts of the multipart file diff --git a/src/lib/OpenEXR/ImfMultiPartOutputFile.cpp b/src/lib/OpenEXR/ImfMultiPartOutputFile.cpp index fbb3914ba9..b431717b35 100644 --- a/src/lib/OpenEXR/ImfMultiPartOutputFile.cpp +++ b/src/lib/OpenEXR/ImfMultiPartOutputFile.cpp @@ -86,10 +86,10 @@ struct MultiPartOutputFile::Data : public OutputStreamMutex delete parts[i]; } - Data (const Data& other) = delete; + Data (const Data& other) = delete; Data& operator= (const Data& other) = delete; Data (Data&& other) = delete; - Data& operator= (Data&& other) = delete; + Data& operator= (Data&& other) = delete; }; void diff --git a/src/lib/OpenEXR/ImfMultiPartOutputFile.h b/src/lib/OpenEXR/ImfMultiPartOutputFile.h index 81d707d917..8d19f36da0 100644 --- a/src/lib/OpenEXR/ImfMultiPartOutputFile.h +++ b/src/lib/OpenEXR/ImfMultiPartOutputFile.h @@ -68,10 +68,10 @@ class IMF_EXPORT_TYPE MultiPartOutputFile : public GenericOutputFile IMF_EXPORT ~MultiPartOutputFile (); - MultiPartOutputFile (const MultiPartOutputFile& other) = delete; + MultiPartOutputFile (const MultiPartOutputFile& other) = delete; MultiPartOutputFile& operator= (const MultiPartOutputFile& other) = delete; MultiPartOutputFile (MultiPartOutputFile&& other) = delete; - MultiPartOutputFile& operator= (MultiPartOutputFile&& other) = delete; + MultiPartOutputFile& operator= (MultiPartOutputFile&& other) = delete; struct IMF_HIDDEN Data; diff --git a/src/lib/OpenEXR/ImfName.h b/src/lib/OpenEXR/ImfName.h index 01d3df220d..5d905c0d49 100644 --- a/src/lib/OpenEXR/ImfName.h +++ b/src/lib/OpenEXR/ImfName.h @@ -43,8 +43,8 @@ class IMF_EXPORT_TYPE Name //-------------------- Name& operator= (const Name&) = default; - Name& operator= (Name&&) = default; - Name& operator = (const char text[]); + Name& operator= (Name&&) = default; + Name& operator= (const char text[]); //--------------------- // Access to the string diff --git a/src/lib/OpenEXR/ImfOutputFile.cpp b/src/lib/OpenEXR/ImfOutputFile.cpp index 385473b268..cae04be95f 100644 --- a/src/lib/OpenEXR/ImfOutputFile.cpp +++ b/src/lib/OpenEXR/ImfOutputFile.cpp @@ -168,10 +168,10 @@ struct OutputFile::Data Data (int numThreads); ~Data (); - Data (const Data& other) = delete; + Data (const Data& other) = delete; Data& operator= (const Data& other) = delete; Data (Data&& other) = delete; - Data& operator= (Data&& other) = delete; + Data& operator= (Data&& other) = delete; inline LineBuffer* getLineBuffer (int number); // hash function from line // buffer indices into our diff --git a/src/lib/OpenEXR/ImfOutputFile.h b/src/lib/OpenEXR/ImfOutputFile.h index 7eb69ced87..631483b5bb 100644 --- a/src/lib/OpenEXR/ImfOutputFile.h +++ b/src/lib/OpenEXR/ImfOutputFile.h @@ -211,10 +211,10 @@ class IMF_EXPORT_TYPE OutputFile : public GenericOutputFile //------------------------------------------------------------ IMF_HIDDEN OutputFile (const OutputPartData* part); - OutputFile (const OutputFile&) = delete; + OutputFile (const OutputFile&) = delete; OutputFile& operator= (const OutputFile&) = delete; OutputFile (OutputFile&&) = delete; - OutputFile& operator= (OutputFile&&) = delete; + OutputFile& operator= (OutputFile&&) = delete; void initialize (const Header& header); diff --git a/src/lib/OpenEXR/ImfPartHelper.h b/src/lib/OpenEXR/ImfPartHelper.h index 36e3bffd4d..641ca8c96c 100644 --- a/src/lib/OpenEXR/ImfPartHelper.h +++ b/src/lib/OpenEXR/ImfPartHelper.h @@ -108,10 +108,7 @@ SplitChannels ( if (lname == "") { if (i->view == heroView) { i->internal_name = i->name; } - else - { - i->internal_name = i->view + "." + i->name; - } + else { i->internal_name = i->view + "." + i->name; } } else { @@ -218,10 +215,7 @@ GetChannelsInMultiPartFile (const MultiPartInputFile& file, T& chans) m.view = viewFromChannelName (m.name, mview); m.name = removeViewName (m.internal_name, m.view); } - else - { - m.view = view; - } + else { m.view = view; } m.part_number = p; chans.push_back (m); } diff --git a/src/lib/OpenEXR/ImfPxr24Compressor.cpp b/src/lib/OpenEXR/ImfPxr24Compressor.cpp index 21172193a6..d7796e58c1 100644 --- a/src/lib/OpenEXR/ImfPxr24Compressor.cpp +++ b/src/lib/OpenEXR/ImfPxr24Compressor.cpp @@ -341,16 +341,16 @@ Pxr24Compressor::compress ( } size_t inBufferSize = static_cast (tmpBufferEnd - _tmpBuffer); - size_t outSize = exr_compress_max_buffer_size (inBufferSize); + size_t outSize = exr_compress_max_buffer_size (inBufferSize); if (EXR_ERR_SUCCESS != exr_compress_buffer ( - nullptr, - -1, - _tmpBuffer, - inBufferSize, - _outBuffer, - outSize, - &outSize)) + nullptr, + -1, + _tmpBuffer, + inBufferSize, + _outBuffer, + outSize, + &outSize)) { throw IEX_NAMESPACE::BaseExc ("Data compression (zlib) failed."); } @@ -371,13 +371,9 @@ Pxr24Compressor::uncompress ( size_t tmpSize = static_cast (_maxScanLineSize * _numScanLines); - if (EXR_ERR_SUCCESS != exr_uncompress_buffer( - nullptr, - inPtr, - inSize, - _tmpBuffer, - tmpSize, - &tmpSize)) + if (EXR_ERR_SUCCESS != + exr_uncompress_buffer ( + nullptr, inPtr, inSize, _tmpBuffer, tmpSize, &tmpSize)) { throw IEX_NAMESPACE::InputExc ("Data decompression (zlib) failed."); } @@ -415,7 +411,8 @@ Pxr24Compressor::uncompress ( ptr[3] = ptr[2] + n; tmpBufferEnd = ptr[3] + n; - if (static_cast (tmpBufferEnd - _tmpBuffer) > tmpSize) + if (static_cast (tmpBufferEnd - _tmpBuffer) > + tmpSize) notEnoughData (); for (int j = 0; j < n; ++j) @@ -440,7 +437,8 @@ Pxr24Compressor::uncompress ( ptr[1] = ptr[0] + n; tmpBufferEnd = ptr[1] + n; - if (static_cast (tmpBufferEnd - _tmpBuffer) > tmpSize) + if (static_cast (tmpBufferEnd - _tmpBuffer) > + tmpSize) notEnoughData (); for (int j = 0; j < n; ++j) @@ -463,7 +461,8 @@ Pxr24Compressor::uncompress ( ptr[2] = ptr[1] + n; tmpBufferEnd = ptr[2] + n; - if (static_cast (tmpBufferEnd - _tmpBuffer) > tmpSize) + if (static_cast (tmpBufferEnd - _tmpBuffer) > + tmpSize) notEnoughData (); for (int j = 0; j < n; ++j) @@ -486,7 +485,8 @@ Pxr24Compressor::uncompress ( } } - if (static_cast (tmpBufferEnd - _tmpBuffer) < tmpSize) tooMuchData (); + if (static_cast (tmpBufferEnd - _tmpBuffer) < tmpSize) + tooMuchData (); outPtr = _outBuffer; return writePtr - _outBuffer; diff --git a/src/lib/OpenEXR/ImfRgbaFile.cpp b/src/lib/OpenEXR/ImfRgbaFile.cpp index 195a7f8ca4..3e357b3ca2 100644 --- a/src/lib/OpenEXR/ImfRgbaFile.cpp +++ b/src/lib/OpenEXR/ImfRgbaFile.cpp @@ -146,10 +146,10 @@ class RgbaOutputFile::ToYca : public std::mutex ToYca (OutputFile& outputFile, RgbaChannels rgbaChannels); ~ToYca (); - ToYca (const ToYca& other) = delete; + ToYca (const ToYca& other) = delete; ToYca& operator= (const ToYca& other) = delete; ToYca (ToYca&& other) = delete; - ToYca& operator= (ToYca&& other) = delete; + ToYca& operator= (ToYca&& other) = delete; void setYCRounding (unsigned int roundY, unsigned int roundC); @@ -634,10 +634,7 @@ RgbaOutputFile::writePixels (int numScanLines) std::lock_guard lock (*_toYca); _toYca->writePixels (numScanLines); } - else - { - _outputFile->writePixels (numScanLines); - } + else { _outputFile->writePixels (numScanLines); } } int @@ -648,10 +645,7 @@ RgbaOutputFile::currentScanLine () const std::lock_guard lock (*_toYca); return _toYca->currentScanLine (); } - else - { - return _outputFile->currentScanLine (); - } + else { return _outputFile->currentScanLine (); } } const Header& @@ -742,10 +736,10 @@ class RgbaInputFile::FromYca : public std::mutex FromYca (InputPart& inputFile, RgbaChannels rgbaChannels); ~FromYca (); - FromYca (const FromYca& other) = delete; + FromYca (const FromYca& other) = delete; FromYca& operator= (const FromYca& other) = delete; FromYca (FromYca&& other) = delete; - FromYca& operator= (FromYca&& other) = delete; + FromYca& operator= (FromYca&& other) = delete; void setFrameBuffer ( Rgba* base, diff --git a/src/lib/OpenEXR/ImfRgbaFile.h b/src/lib/OpenEXR/ImfRgbaFile.h index d31a6189e2..c5e620c1b7 100644 --- a/src/lib/OpenEXR/ImfRgbaFile.h +++ b/src/lib/OpenEXR/ImfRgbaFile.h @@ -250,10 +250,10 @@ class IMF_EXPORT_TYPE RgbaOutputFile void breakScanLine (int y, int offset, int length, char c); private: - RgbaOutputFile (const RgbaOutputFile&) = delete; + RgbaOutputFile (const RgbaOutputFile&) = delete; RgbaOutputFile& operator= (const RgbaOutputFile&) = delete; RgbaOutputFile (RgbaOutputFile&&) = delete; - RgbaOutputFile& operator= (RgbaOutputFile&&) = delete; + RgbaOutputFile& operator= (RgbaOutputFile&&) = delete; class IMF_HIDDEN ToYca; @@ -436,10 +436,10 @@ class IMF_EXPORT_TYPE RgbaInputFile int version () const; private: - RgbaInputFile (const RgbaInputFile&) = delete; + RgbaInputFile (const RgbaInputFile&) = delete; RgbaInputFile& operator= (const RgbaInputFile&) = delete; RgbaInputFile (RgbaInputFile&&) = delete; - RgbaInputFile& operator= (RgbaInputFile&&) = delete; + RgbaInputFile& operator= (RgbaInputFile&&) = delete; class IMF_HIDDEN FromYca; diff --git a/src/lib/OpenEXR/ImfScanLineInputFile.cpp b/src/lib/OpenEXR/ImfScanLineInputFile.cpp index adaaa9f86f..396d7c0e8e 100644 --- a/src/lib/OpenEXR/ImfScanLineInputFile.cpp +++ b/src/lib/OpenEXR/ImfScanLineInputFile.cpp @@ -120,10 +120,10 @@ struct LineBuffer LineBuffer (Compressor* const comp); ~LineBuffer (); - LineBuffer (const LineBuffer& other) = delete; + LineBuffer (const LineBuffer& other) = delete; LineBuffer& operator= (const LineBuffer& other) = delete; LineBuffer (LineBuffer&& other) = delete; - LineBuffer& operator= (LineBuffer&& other) = delete; + LineBuffer& operator= (LineBuffer&& other) = delete; inline void wait () { _sem.wait (); } inline void post () { _sem.post (); } @@ -159,8 +159,8 @@ struct sliceOptimizationData bool fill; ///< is this channel being filled with constant, instead of read? half fillValue; ///< if filling, the value to use size_t - offset; ///< position this channel will be in the read buffer, accounting for previous channels, as well as their type - PixelType type; ///< type of channel + offset; ///< position this channel will be in the read buffer, accounting for previous channels, as well as their type + PixelType type; ///< type of channel size_t xStride; ///< x-stride of channel in buffer (must be set to cause channels to interleave) size_t @@ -215,10 +215,10 @@ struct ScanLineInputFile::Data Data (int numThreads); ~Data (); - Data (const Data& other) = delete; + Data (const Data& other) = delete; Data& operator= (const Data& other) = delete; Data (Data&& other) = delete; - Data& operator= (Data&& other) = delete; + Data& operator= (Data&& other) = delete; inline LineBuffer* getLineBuffer (int number); // hash function from line // buffer indices into our @@ -1151,10 +1151,10 @@ ScanLineInputFile::initialize (const Header& header) _data->linesInBuffer = numLinesInBuffer (comp); - uint64_t lineOffsetSize = - (static_cast(dataWindow.max.y) - static_cast(dataWindow.min.y) + static_cast(_data->linesInBuffer)) / - static_cast(_data->linesInBuffer); - + uint64_t lineOffsetSize = (static_cast (dataWindow.max.y) - + static_cast (dataWindow.min.y) + + static_cast (_data->linesInBuffer)) / + static_cast (_data->linesInBuffer); // // avoid allocating excessive memory due to large lineOffsets and bytesPerLine table sizes. diff --git a/src/lib/OpenEXR/ImfScanLineInputFile.h b/src/lib/OpenEXR/ImfScanLineInputFile.h index 9014fd3057..e303d65aa1 100644 --- a/src/lib/OpenEXR/ImfScanLineInputFile.h +++ b/src/lib/OpenEXR/ImfScanLineInputFile.h @@ -40,10 +40,10 @@ class IMF_EXPORT_TYPE ScanLineInputFile : public GenericInputFile IMF_EXPORT virtual ~ScanLineInputFile (); - ScanLineInputFile (const ScanLineInputFile& other) = delete; + ScanLineInputFile (const ScanLineInputFile& other) = delete; ScanLineInputFile& operator= (const ScanLineInputFile& other) = delete; ScanLineInputFile (ScanLineInputFile&& other) = delete; - ScanLineInputFile& operator= (ScanLineInputFile&& other) = delete; + ScanLineInputFile& operator= (ScanLineInputFile&& other) = delete; //------------------------ // Access to the file name diff --git a/src/lib/OpenEXR/ImfSimd.h b/src/lib/OpenEXR/ImfSimd.h index c2065ba719..56060c545a 100644 --- a/src/lib/OpenEXR/ImfSimd.h +++ b/src/lib/OpenEXR/ImfSimd.h @@ -63,7 +63,6 @@ extern "C" { #ifdef IMF_HAVE_NEON # include #endif - } #include "OpenEXRConfigInternal.h" diff --git a/src/lib/OpenEXR/ImfStandardAttributes.cpp b/src/lib/OpenEXR/ImfStandardAttributes.cpp index 90c81fbe7e..a6f7d53b93 100644 --- a/src/lib/OpenEXR/ImfStandardAttributes.cpp +++ b/src/lib/OpenEXR/ImfStandardAttributes.cpp @@ -68,7 +68,8 @@ IMF_STD_ATTRIBUTE_IMP (worldToNDC, WorldToNDC, M44f) IMF_STD_ATTRIBUTE_IMP (sensorCenterOffset, SensorCenterOffset, V2f) IMF_STD_ATTRIBUTE_IMP (sensorOverallDimensions, SensorOverallDimensions, V2f) IMF_STD_ATTRIBUTE_IMP (sensorPhotositePitch, SensorPhotositePitch, float) -IMF_STD_ATTRIBUTE_IMP (sensorAcquisitionRectangle, SensorAcquisitionRectangle, Box2i) +IMF_STD_ATTRIBUTE_IMP ( + sensorAcquisitionRectangle, SensorAcquisitionRectangle, Box2i) IMF_STD_ATTRIBUTE_IMP (ascFramingDecisionList, AscFramingDecisionList, string) IMF_STD_ATTRIBUTE_IMP (xDensity, XDensity, float) IMF_STD_ATTRIBUTE_IMP (longitude, Longitude, float) diff --git a/src/lib/OpenEXR/ImfStandardAttributes.h b/src/lib/OpenEXR/ImfStandardAttributes.h index e1501f7cf2..f9db495688 100644 --- a/src/lib/OpenEXR/ImfStandardAttributes.h +++ b/src/lib/OpenEXR/ImfStandardAttributes.h @@ -138,7 +138,8 @@ IMF_STD_ATTRIBUTE_DEF (worldToNDC, WorldToNDC, IMATH_NAMESPACE::M44f) // and what was at the bottom of the scene being captured. // -IMF_STD_ATTRIBUTE_DEF (sensorCenterOffset, SensorCenterOffset, IMATH_NAMESPACE::V2f) +IMF_STD_ATTRIBUTE_DEF ( + sensorCenterOffset, SensorCenterOffset, IMATH_NAMESPACE::V2f) // // sensorOverallDimensions -- dimensions of the light-sensitive area of the @@ -146,9 +147,7 @@ IMF_STD_ATTRIBUTE_DEF (sensorCenterOffset, SensorCenterOffset, IMATH_NAMESPACE:: // which image data are obtained. IMF_STD_ATTRIBUTE_DEF ( - sensorOverallDimensions, - SensorOverallDimensions, - IMATH_NAMESPACE::V2f) + sensorOverallDimensions, SensorOverallDimensions, IMATH_NAMESPACE::V2f) // // sensorPhotositePitch -- distance between centers of sensor photosites, @@ -166,7 +165,8 @@ IMF_STD_ATTRIBUTE_DEF (sensorPhotositePitch, SensorPhotositePitch, float) IMF_STD_ATTRIBUTE_DEF ( sensorAcquisitionRectangle, - SensorAcquisitionRectangle, IMATH_NAMESPACE::Box2i) + SensorAcquisitionRectangle, + IMATH_NAMESPACE::Box2i) // // ascFramingDecisionList -- JSON-encoded description of framing decisions @@ -176,7 +176,8 @@ IMF_STD_ATTRIBUTE_DEF ( // If present, the value should be UTF-8-encoded and have a nonzero length. // -IMF_STD_ATTRIBUTE_DEF (ascFramingDecisionList, AscFramingDecisionList, std::string) +IMF_STD_ATTRIBUTE_DEF ( + ascFramingDecisionList, AscFramingDecisionList, std::string) // // xDensity -- horizontal output density, in pixels per inch. @@ -230,7 +231,8 @@ IMF_STD_ATTRIBUTE_DEF (cameraSerialNumber, CameraSerialNumber, std::string) // If present, the value should be UTF-8-encoded and have a nonzero length. // -IMF_STD_ATTRIBUTE_DEF (cameraFirmwareVersion, CameraFirmwareVersion, std::string) +IMF_STD_ATTRIBUTE_DEF ( + cameraFirmwareVersion, CameraFirmwareVersion, std::string) // // cameraUuid -- identifies this camera uniquely among all @@ -307,7 +309,7 @@ IMF_STD_ATTRIBUTE_DEF (cameraCCTSetting, CameraCCTSetting, float) // If the camera vendor maps cameraCCTSetting to a point defined by // a linear crossfade between a Planckian blackbody locus and loci of // CIE D Series illuminants, the slope of the tint isotherm at the -// exact points where the linear crossfade starts and ends can be +// exact points where the linear crossfade starts and ends can be // indeterminate and an inverse mapping from chromaticity to a pair // of CCT and tint can be one-to-many. // @@ -333,14 +335,15 @@ IMF_STD_ATTRIBUTE_DEF (cameraTintSetting, CameraTintSetting, float) // For example, if a physical digital cinema camera was configured with // a CCT of 3200K and a tint of -3 (in some camera vendor dependent unit), // and the camera output had been processed such that the image containing -// this attribute was encoded as per SMPTE ST 2065-4:2023, then +// this attribute was encoded as per SMPTE ST 2065-4:2023, then // the adoptedNeutral attribute would have the value corresponding to // the ACES neutral chromaticity, very near that of CIE Illuminant D60, // whereas the cameraColorBalance would have a chromaticity much, much // warmer than that of the adoptedNeutral attribute. -// +// -IMF_STD_ATTRIBUTE_DEF (cameraColorBalance, CameraColorBalance, IMATH_NAMESPACE::V2f) +IMF_STD_ATTRIBUTE_DEF ( + cameraColorBalance, CameraColorBalance, IMATH_NAMESPACE::V2f) // // isoSpeed -- the ISO speed of the film or the ISO setting of the camera @@ -370,13 +373,13 @@ IMF_STD_ATTRIBUTE_DEF (shutterAngle, ShutterAngle, float) // captureRate -- capture rate, in frames per second, of the image // sequence to which the image belongs, represented as a rational // number -// +// // For variable frame rates, time-lapse photography, etc. the capture // rate r is calculated as // // r = 1 / (tN - tNm1) // -// where tn is the time, in seconds, of the center of frame N's +// where tn is the time, in seconds, of the center of frame N's // exposure interval, and tNm1 is the time, in seconds, of the center // of frame N-1's exposure interval. // @@ -568,8 +571,8 @@ IMF_STD_ATTRIBUTE_DEF (framesPerSecond, FramesPerSecond, Rational) // // imageCounter -- an image number // -// For a sequence of images, the image number increases -// when the images are accessed in the intended play order. +// For a sequence of images, the image number increases +// when the images are accessed in the intended play order. // imageCounter can be used to order frames when more standard // ordering systems are inapplicable, including but not limited // to uniquely identifying frames of high-speed photography that @@ -626,8 +629,16 @@ IMF_STD_ATTRIBUTE_DEF (adoptedNeutral, AdoptedNeutral, IMATH_NAMESPACE::V2f) // If present, values should be UTF-8-encoded and have nonzero length. // -IMF_STD_ATTRIBUTE_DEF_DEPRECATED (renderingTransform, RenderingTransform, std::string, "this attribute is obsolete as of OpenEXR v3.2") -IMF_STD_ATTRIBUTE_DEF_DEPRECATED (lookModTransform, LookModTransform, std::string, "this attribute is obsolete as of OpenEXR v3.2") +IMF_STD_ATTRIBUTE_DEF_DEPRECATED ( + renderingTransform, + RenderingTransform, + std::string, + "this attribute is obsolete as of OpenEXR v3.2") +IMF_STD_ATTRIBUTE_DEF_DEPRECATED ( + lookModTransform, + LookModTransform, + std::string, + "this attribute is obsolete as of OpenEXR v3.2") // // envmap -- if this attribute is present, the image represents diff --git a/src/lib/OpenEXR/ImfStdIO.h b/src/lib/OpenEXR/ImfStdIO.h index 8bfd27b4b5..10a02477bc 100644 --- a/src/lib/OpenEXR/ImfStdIO.h +++ b/src/lib/OpenEXR/ImfStdIO.h @@ -48,10 +48,10 @@ class IMF_EXPORT_TYPE StdIFStream IMF_EXPORT StdIFStream (std::ifstream& is, const char fileName[]); IMF_EXPORT virtual ~StdIFStream (); - StdIFStream (const StdIFStream&) = delete; - StdIFStream (StdIFStream&&) = delete; + StdIFStream (const StdIFStream&) = delete; + StdIFStream (StdIFStream&&) = delete; StdIFStream& operator= (const StdIFStream&) = delete; - StdIFStream& operator= (StdIFStream&&) = delete; + StdIFStream& operator= (StdIFStream&&) = delete; IMF_EXPORT virtual bool read (char c[/*n*/], int n); IMF_EXPORT virtual uint64_t tellg (); @@ -74,10 +74,10 @@ class IMF_EXPORT_TYPE StdISStream public: IMF_EXPORT StdISStream (); IMF_EXPORT ~StdISStream (); - StdISStream (const StdISStream&) = delete; - StdISStream (StdISStream&&) = delete; + StdISStream (const StdISStream&) = delete; + StdISStream (StdISStream&&) = delete; StdISStream& operator= (const StdISStream&) = delete; - StdISStream& operator= (StdISStream&&) = delete; + StdISStream& operator= (StdISStream&&) = delete; IMF_EXPORT virtual bool read (char c[/*n*/], int n); IMF_EXPORT virtual uint64_t tellg (); @@ -117,10 +117,10 @@ class IMF_EXPORT_TYPE StdOFStream IMF_EXPORT StdOFStream (std::ofstream& os, const char fileName[]); IMF_EXPORT virtual ~StdOFStream (); - StdOFStream (const StdOFStream&) = delete; - StdOFStream (StdOFStream&&) = delete; + StdOFStream (const StdOFStream&) = delete; + StdOFStream (StdOFStream&&) = delete; StdOFStream& operator= (const StdOFStream&) = delete; - StdOFStream& operator= (StdOFStream&&) = delete; + StdOFStream& operator= (StdOFStream&&) = delete; IMF_EXPORT virtual void write (const char c[/*n*/], int n); IMF_EXPORT virtual uint64_t tellp (); @@ -142,10 +142,10 @@ class IMF_EXPORT_TYPE StdOSStream public: IMF_EXPORT StdOSStream (); IMF_EXPORT ~StdOSStream (); - StdOSStream (const StdOSStream&) = delete; - StdOSStream (StdOSStream&&) = delete; + StdOSStream (const StdOSStream&) = delete; + StdOSStream (StdOSStream&&) = delete; StdOSStream& operator= (const StdOSStream&) = delete; - StdOSStream& operator= (StdOSStream&&) = delete; + StdOSStream& operator= (StdOSStream&&) = delete; IMF_EXPORT virtual void write (const char c[/*n*/], int n); IMF_EXPORT virtual uint64_t tellp (); diff --git a/src/lib/OpenEXR/ImfSystemSpecific.cpp b/src/lib/OpenEXR/ImfSystemSpecific.cpp index ae4611cbbb..ae955bf805 100644 --- a/src/lib/OpenEXR/ImfSystemSpecific.cpp +++ b/src/lib/OpenEXR/ImfSystemSpecific.cpp @@ -9,7 +9,7 @@ #include "OpenEXRConfig.h" #include "OpenEXRConfigInternal.h" #if defined(_MSC_VER) -#include +# include #endif OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER @@ -22,20 +22,21 @@ namespace void cpuid (int n, int& eax, int& ebx, int& ecx, int& edx) { - __asm__ __volatile__( + __asm__ __volatile__ ( "cpuid" : /* Output */ "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) : /* Input */ "a"(n) : /* Clobber */); } -#elif defined(_MSC_VER) && ( defined(_M_IX86) || ( defined(_M_AMD64) && !defined(_M_ARM64EC) ) ) +#elif defined(_MSC_VER) && \ + (defined(_M_IX86) || (defined(_M_AMD64) && !defined(_M_ARM64EC))) // Helper functions for MSVC void cpuid (int n, int& eax, int& ebx, int& ecx, int& edx) { - int cpuInfo[4] = { -1 }; + int cpuInfo[4] = {-1}; __cpuid (cpuInfo, n); eax = cpuInfo[0]; ebx = cpuInfo[1]; @@ -59,10 +60,10 @@ cpuid (int n, int& eax, int& ebx, int& ecx, int& edx) void xgetbv (int n, int& eax, int& edx) { - __asm__ __volatile__("xgetbv" - : /* Output */ "=a"(eax), "=d"(edx) - : /* Input */ "c"(n) - : /* Clobber */); + __asm__ __volatile__ ("xgetbv" + : /* Output */ "=a"(eax), "=d"(edx) + : /* Input */ "c"(n) + : /* Clobber */); } #else // IMF_HAVE_GCC_INLINEASM_X86 diff --git a/src/lib/OpenEXR/ImfTileOffsets.cpp b/src/lib/OpenEXR/ImfTileOffsets.cpp index 1b60a498df..7cab0e3dd0 100644 --- a/src/lib/OpenEXR/ImfTileOffsets.cpp +++ b/src/lib/OpenEXR/ImfTileOffsets.cpp @@ -237,10 +237,7 @@ TileOffsets::readFrom ( complete = false; reconstructFromFile (is, isMultiPartFile, isDeep); } - else - { - complete = true; - } + else { complete = true; } } void diff --git a/src/lib/OpenEXR/ImfTiledInputFile.cpp b/src/lib/OpenEXR/ImfTiledInputFile.cpp index 58508beb7e..595d7a5add 100644 --- a/src/lib/OpenEXR/ImfTiledInputFile.cpp +++ b/src/lib/OpenEXR/ImfTiledInputFile.cpp @@ -122,10 +122,10 @@ struct TileBuffer TileBuffer (Compressor* const comp); ~TileBuffer (); - TileBuffer (const TileBuffer& other) = delete; + TileBuffer (const TileBuffer& other) = delete; TileBuffer& operator= (const TileBuffer& other) = delete; TileBuffer (TileBuffer&& other) = delete; - TileBuffer& operator= (TileBuffer&& other) = delete; + TileBuffer& operator= (TileBuffer&& other) = delete; inline void wait () { _sem.wait (); } inline void post () { _sem.post (); } @@ -219,10 +219,10 @@ struct TiledInputFile::Data Data (int numThreads); ~Data (); - Data (const Data& other) = delete; + Data (const Data& other) = delete; Data& operator= (const Data& other) = delete; Data (Data&& other) = delete; - Data& operator= (Data&& other) = delete; + Data& operator= (Data&& other) = delete; static const int gLargeChunkTableSize = 1024 * 1024; void diff --git a/src/lib/OpenEXR/ImfTiledInputFile.h b/src/lib/OpenEXR/ImfTiledInputFile.h index d867b2deab..8b9250d909 100644 --- a/src/lib/OpenEXR/ImfTiledInputFile.h +++ b/src/lib/OpenEXR/ImfTiledInputFile.h @@ -59,10 +59,10 @@ class IMF_EXPORT_TYPE TiledInputFile : public GenericInputFile IMF_EXPORT virtual ~TiledInputFile (); - TiledInputFile (const TiledInputFile& other) = delete; + TiledInputFile (const TiledInputFile& other) = delete; TiledInputFile& operator= (const TiledInputFile& other) = delete; TiledInputFile (TiledInputFile&& other) = delete; - TiledInputFile& operator= (TiledInputFile&& other) = delete; + TiledInputFile& operator= (TiledInputFile&& other) = delete; //------------------------ // Access to the file name diff --git a/src/lib/OpenEXR/ImfTiledOutputFile.cpp b/src/lib/OpenEXR/ImfTiledOutputFile.cpp index 82849d0d8d..2990516e42 100644 --- a/src/lib/OpenEXR/ImfTiledOutputFile.cpp +++ b/src/lib/OpenEXR/ImfTiledOutputFile.cpp @@ -140,10 +140,10 @@ struct BufferedTile ~BufferedTile () { delete[] pixelData; } - BufferedTile (const BufferedTile& other) = delete; + BufferedTile (const BufferedTile& other) = delete; BufferedTile& operator= (const BufferedTile& other) = delete; BufferedTile (BufferedTile&& other) = delete; - BufferedTile& operator= (BufferedTile&& other) = delete; + BufferedTile& operator= (BufferedTile&& other) = delete; }; typedef map TileMap; @@ -227,10 +227,10 @@ struct TiledOutputFile::Data Data (int numThreads); ~Data (); - Data (const Data& other) = delete; + Data (const Data& other) = delete; Data& operator= (const Data& other) = delete; Data (Data&& other) = delete; - Data& operator= (Data&& other) = delete; + Data& operator= (Data&& other) = delete; inline TileBuffer* getTileBuffer (int number); // hash function from tile diff --git a/src/lib/OpenEXR/ImfTiledOutputFile.h b/src/lib/OpenEXR/ImfTiledOutputFile.h index ecaafabb70..201f09cc76 100644 --- a/src/lib/OpenEXR/ImfTiledOutputFile.h +++ b/src/lib/OpenEXR/ImfTiledOutputFile.h @@ -446,10 +446,10 @@ class IMF_EXPORT_TYPE TiledOutputFile : public GenericOutputFile IMF_HIDDEN TiledOutputFile (const OutputPartData* part); - TiledOutputFile (const TiledOutputFile&) = delete; + TiledOutputFile (const TiledOutputFile&) = delete; TiledOutputFile& operator= (const TiledOutputFile&) = delete; TiledOutputFile (TiledOutputFile&&) = delete; - TiledOutputFile& operator= (TiledOutputFile&&) = delete; + TiledOutputFile& operator= (TiledOutputFile&&) = delete; IMF_HIDDEN void initialize (const Header& header); diff --git a/src/lib/OpenEXR/ImfTiledRgbaFile.cpp b/src/lib/OpenEXR/ImfTiledRgbaFile.cpp index 1299b3fc03..f9f71e9dee 100644 --- a/src/lib/OpenEXR/ImfTiledRgbaFile.cpp +++ b/src/lib/OpenEXR/ImfTiledRgbaFile.cpp @@ -523,10 +523,7 @@ TiledRgbaOutputFile::writeTile (int dx, int dy, int l) #endif _toYa->writeTile (dx, dy, l, l); } - else - { - _outputFile->writeTile (dx, dy, l); - } + else { _outputFile->writeTile (dx, dy, l); } } void @@ -539,10 +536,7 @@ TiledRgbaOutputFile::writeTile (int dx, int dy, int lx, int ly) #endif _toYa->writeTile (dx, dy, lx, ly); } - else - { - _outputFile->writeTile (dx, dy, lx, ly); - } + else { _outputFile->writeTile (dx, dy, lx, ly); } } void @@ -558,10 +552,7 @@ TiledRgbaOutputFile::writeTiles ( for (int dx = dxMin; dx <= dxMax; dx++) _toYa->writeTile (dx, dy, lx, ly); } - else - { - _outputFile->writeTiles (dxMin, dxMax, dyMin, dyMax, lx, ly); - } + else { _outputFile->writeTiles (dxMin, dxMax, dyMin, dyMax, lx, ly); } } void @@ -1009,10 +1000,7 @@ TiledRgbaInputFile::readTile (int dx, int dy, int l) #endif _fromYa->readTile (dx, dy, l, l); } - else - { - _inputFile->readTile (dx, dy, l); - } + else { _inputFile->readTile (dx, dy, l); } } void @@ -1025,10 +1013,7 @@ TiledRgbaInputFile::readTile (int dx, int dy, int lx, int ly) #endif _fromYa->readTile (dx, dy, lx, ly); } - else - { - _inputFile->readTile (dx, dy, lx, ly); - } + else { _inputFile->readTile (dx, dy, lx, ly); } } void @@ -1044,10 +1029,7 @@ TiledRgbaInputFile::readTiles ( for (int dx = dxMin; dx <= dxMax; dx++) _fromYa->readTile (dx, dy, lx, ly); } - else - { - _inputFile->readTiles (dxMin, dxMax, dyMin, dyMax, lx, ly); - } + else { _inputFile->readTiles (dxMin, dxMax, dyMin, dyMax, lx, ly); } } void diff --git a/src/lib/OpenEXR/ImfTiledRgbaFile.h b/src/lib/OpenEXR/ImfTiledRgbaFile.h index 048741a9f8..bc8a939373 100644 --- a/src/lib/OpenEXR/ImfTiledRgbaFile.h +++ b/src/lib/OpenEXR/ImfTiledRgbaFile.h @@ -275,10 +275,10 @@ class IMF_EXPORT_TYPE TiledRgbaOutputFile // Copy constructor and assignment are not implemented // - TiledRgbaOutputFile (const TiledRgbaOutputFile&) = delete; + TiledRgbaOutputFile (const TiledRgbaOutputFile&) = delete; TiledRgbaOutputFile& operator= (const TiledRgbaOutputFile&) = delete; TiledRgbaOutputFile (TiledRgbaOutputFile&&) = delete; - TiledRgbaOutputFile& operator= (TiledRgbaOutputFile&&) = delete; + TiledRgbaOutputFile& operator= (TiledRgbaOutputFile&&) = delete; class IMF_HIDDEN ToYa; @@ -489,10 +489,10 @@ class IMF_EXPORT_TYPE TiledRgbaInputFile // Copy constructor and assignment are not implemented // - TiledRgbaInputFile (const TiledRgbaInputFile&) = delete; + TiledRgbaInputFile (const TiledRgbaInputFile&) = delete; TiledRgbaInputFile& operator= (const TiledRgbaInputFile&) = delete; TiledRgbaInputFile (TiledRgbaInputFile&&) = delete; - TiledRgbaInputFile& operator= (TiledRgbaInputFile&&) = delete; + TiledRgbaInputFile& operator= (TiledRgbaInputFile&&) = delete; class FromYa; diff --git a/src/lib/OpenEXR/ImfZip.cpp b/src/lib/OpenEXR/ImfZip.cpp index 4121c13b50..7b209fb3d8 100644 --- a/src/lib/OpenEXR/ImfZip.cpp +++ b/src/lib/OpenEXR/ImfZip.cpp @@ -93,13 +93,13 @@ Zip::compress (const char* raw, int rawSize, char* compressed) // size_t outSize; if (EXR_ERR_SUCCESS != exr_compress_buffer ( - nullptr, - _zipLevel, - _tmpBuffer, - rawSize, - compressed, - maxCompressedSize (), - &outSize)) + nullptr, + _zipLevel, + _tmpBuffer, + rawSize, + compressed, + maxCompressedSize (), + &outSize)) { throw IEX_NAMESPACE::BaseExc ("Data compression failed."); } @@ -174,8 +174,8 @@ reconstruct_neon (char* buf, size_t outSize) buf[0] += -128; unsigned char* vBuf = reinterpret_cast (buf); - uint8x16_t vZero = vdupq_n_u8 (0); - uint8x16_t vPrev = vdupq_n_u8 (0); + uint8x16_t vZero = vdupq_n_u8 (0); + uint8x16_t vPrev = vdupq_n_u8 (0); for (size_t i = 0; i < vOutSize; ++i) { uint8x16_t d = vaddq_u8 (vld1q_u8 (vBuf), c); @@ -206,7 +206,6 @@ reconstruct_neon (char* buf, size_t outSize) #endif - void reconstruct_scalar (char* buf, size_t outSize) { @@ -275,14 +274,18 @@ interleave_neon (const char* source, size_t outSize, char* out) for (size_t i = 0; i < vOutSize; ++i) { - uint8x16_t a = vld1q_u8 (v1); v1 += sizeof (uint8x16_t); - uint8x16_t b = vld1q_u8 (v2); v2 += sizeof (uint8x16_t); + uint8x16_t a = vld1q_u8 (v1); + v1 += sizeof (uint8x16_t); + uint8x16_t b = vld1q_u8 (v2); + v2 += sizeof (uint8x16_t); uint8x16_t lo = vzip1q_u8 (a, b); uint8x16_t hi = vzip2q_u8 (a, b); - vst1q_u8 (vOut, lo); vOut += sizeof (uint8x16_t); - vst1q_u8 (vOut, hi); vOut += sizeof (uint8x16_t); + vst1q_u8 (vOut, lo); + vOut += sizeof (uint8x16_t); + vst1q_u8 (vOut, hi); + vOut += sizeof (uint8x16_t); } const char* t1 = reinterpret_cast (v1); @@ -320,7 +323,7 @@ interleave_scalar (const char* source, size_t outSize, char* out) } auto reconstruct = reconstruct_scalar; -auto interleave = interleave_scalar; +auto interleave = interleave_scalar; } // namespace @@ -329,12 +332,12 @@ Zip::uncompress (const char* compressed, int compressedSize, char* raw) { size_t outSize = 0; if (EXR_ERR_SUCCESS != exr_uncompress_buffer ( - nullptr, - compressed, - (size_t)compressedSize, - _tmpBuffer, - _maxRawSize, - &outSize)) + nullptr, + compressed, + (size_t) compressedSize, + _tmpBuffer, + _maxRawSize, + &outSize)) { throw IEX_NAMESPACE::InputExc ("Data decompression failed."); } @@ -360,22 +363,16 @@ Zip::initializeFuncs () CpuId cpuId; #ifdef IMF_HAVE_SSE4_1 - if (cpuId.sse4_1) - { - reconstruct = reconstruct_sse41; - } + if (cpuId.sse4_1) { reconstruct = reconstruct_sse41; } #endif #ifdef IMF_HAVE_SSE2 - if (cpuId.sse2) - { - interleave = interleave_sse2; - } + if (cpuId.sse2) { interleave = interleave_sse2; } #endif #ifdef IMF_HAVE_NEON_AARCH64 reconstruct = reconstruct_neon; - interleave = interleave_neon; + interleave = interleave_neon; #endif } diff --git a/src/lib/OpenEXR/ImfZip.h b/src/lib/OpenEXR/ImfZip.h index 01da619681..1bc19c2edd 100644 --- a/src/lib/OpenEXR/ImfZip.h +++ b/src/lib/OpenEXR/ImfZip.h @@ -20,10 +20,10 @@ class Zip Zip (size_t maxScanlineSize, size_t numScanLines, int level); ~Zip (); - Zip (const Zip& other) = delete; + Zip (const Zip& other) = delete; Zip& operator= (const Zip& other) = delete; Zip (Zip&& other) = delete; - Zip& operator= (Zip&& other) = delete; + Zip& operator= (Zip&& other) = delete; size_t maxRawSize (); size_t maxCompressedSize (); diff --git a/src/lib/OpenEXR/dwaLookups.cpp b/src/lib/OpenEXR/dwaLookups.cpp index 9f7f810811..77c96130a2 100644 --- a/src/lib/OpenEXR/dwaLookups.cpp +++ b/src/lib/OpenEXR/dwaLookups.cpp @@ -71,10 +71,10 @@ class LutHeaderWorker , _elements (new unsigned short[1024 * 1024 * 2]) {} - LutHeaderWorker (const LutHeaderWorker& other) = delete; + LutHeaderWorker (const LutHeaderWorker& other) = delete; LutHeaderWorker& operator= (const LutHeaderWorker& other) = delete; LutHeaderWorker (LutHeaderWorker&& other) = delete; - LutHeaderWorker& operator= (LutHeaderWorker&& other) = delete; + LutHeaderWorker& operator= (LutHeaderWorker&& other) = delete; ~LutHeaderWorker () { diff --git a/src/lib/OpenEXRCore/attributes.c b/src/lib/OpenEXRCore/attributes.c index 14543d09dd..4c740354e5 100644 --- a/src/lib/OpenEXRCore/attributes.c +++ b/src/lib/OpenEXRCore/attributes.c @@ -537,8 +537,7 @@ add_to_list ( list->num_attributes = nattrsz; rv = attr_init (ctxt, nattr); - if (rv != EXR_ERR_SUCCESS) - exr_attr_list_remove (ctxt, list, nattr); + if (rv != EXR_ERR_SUCCESS) exr_attr_list_remove (ctxt, list, nattr); return rv; } @@ -629,10 +628,7 @@ check_attr_handler (exr_context_t ctxt, exr_attribute_t* attr) { exr_attribute_t* handler = NULL; exr_result_t rv = exr_attr_list_find_by_name ( - ctxt, - &(ctxt->custom_handlers), - attr->type_name, - &handler); + ctxt, &(ctxt->custom_handlers), attr->type_name, &handler); if (rv == EXR_ERR_SUCCESS && handler) { attr->opaque->unpack_func_ptr = handler->opaque->unpack_func_ptr; @@ -759,8 +755,7 @@ exr_attr_list_add_by_type ( ctxt, EXR_ERR_INVALID_ARGUMENT, "Invalid type to add_by_type"); } - rval = - validate_attr_arguments (ctxt, list, name, data_len, data_ptr, attr); + rval = validate_attr_arguments (ctxt, list, name, data_len, data_ptr, attr); if (rval != EXR_ERR_SUCCESS) { if (rval < 0) @@ -887,8 +882,7 @@ exr_attr_list_add ( if (!ctxt) return EXR_ERR_MISSING_CONTEXT_ARG; - rval = - validate_attr_arguments (ctxt, list, name, data_len, data_ptr, attr); + rval = validate_attr_arguments (ctxt, list, name, data_len, data_ptr, attr); if (rval != EXR_ERR_SUCCESS) { if (rval < 0) @@ -944,15 +938,7 @@ exr_attr_list_add ( known = &(the_predefined_attr_typenames[tidx]); rval = create_attr_block ( - ctxt, - &nattr, - known->exp_size, - data_len, - data_ptr, - name, - nlen, - NULL, - 0); + ctxt, &nattr, known->exp_size, data_len, data_ptr, name, nlen, NULL, 0); if (rval == EXR_ERR_SUCCESS) { @@ -993,8 +979,7 @@ exr_attr_list_add_static_name ( if (!ctxt) return EXR_ERR_MISSING_CONTEXT_ARG; - rval = - validate_attr_arguments (ctxt, list, name, data_len, data_ptr, attr); + rval = validate_attr_arguments (ctxt, list, name, data_len, data_ptr, attr); if (rval != EXR_ERR_SUCCESS) { if (rval < 0) diff --git a/src/lib/OpenEXRCore/chunk.c b/src/lib/OpenEXRCore/chunk.c index bbf2d58711..b7130f3062 100644 --- a/src/lib/OpenEXRCore/chunk.c +++ b/src/lib/OpenEXRCore/chunk.c @@ -449,11 +449,9 @@ read_and_validate_chunk_leader ( // this should behave the same as the old ImfMultiPartInputFile static exr_result_t reconstruct_chunk_table ( - exr_const_context_t ctxt, - exr_const_priv_part_t part, - uint64_t* chunktable) + exr_const_context_t ctxt, exr_const_priv_part_t part, uint64_t* chunktable) { - exr_result_t rv = EXR_ERR_SUCCESS; + exr_result_t rv = EXR_ERR_SUCCESS; exr_result_t firstfailrv = EXR_ERR_SUCCESS; uint64_t offset_start, chunk_start, max_offset; uint64_t* curctable; @@ -494,8 +492,8 @@ reconstruct_chunk_table ( if (rv != EXR_ERR_SUCCESS) return rv; } - chunkbytes = (size_t)part->chunk_count * sizeof(uint64_t); - curctable = (uint64_t*) ctxt->alloc_fn (chunkbytes); + chunkbytes = (size_t) part->chunk_count * sizeof (uint64_t); + curctable = (uint64_t*) ctxt->alloc_fn (chunkbytes); if (!curctable) return EXR_ERR_OUT_OF_MEMORY; memset (curctable, 0, chunkbytes); @@ -511,7 +509,7 @@ reconstruct_chunk_table ( computed_ci = part->chunk_count - (ci + 1); found_ci = computed_ci; - rv = read_and_validate_chunk_leader ( + rv = read_and_validate_chunk_leader ( ctxt, part, partnum, chunk_start, &found_ci, &offset_start); if (rv != EXR_ERR_SUCCESS) { @@ -533,8 +531,7 @@ reconstruct_chunk_table ( if (found_ci >= 0 && found_ci < part->chunk_count) { - if (curctable[found_ci] == 0) - curctable[found_ci] = chunk_start; + if (curctable[found_ci] == 0) curctable[found_ci] = chunk_start; } } memcpy (chunktable, curctable, chunkbytes); @@ -589,7 +586,7 @@ extract_chunk_table ( if (rv != EXR_ERR_SUCCESS) { ctxt->free_fn (ctable); - ctable = (uint64_t *) UINTPTR_MAX; + ctable = (uint64_t*) UINTPTR_MAX; } else if (!ctxt->disable_chunk_reconstruct) { @@ -617,8 +614,8 @@ extract_chunk_table ( if (ctxt->strict_header) { ctxt->free_fn (ctable); - ctable = (uint64_t *) UINTPTR_MAX; - rv = ctxt->report_error ( + ctable = (uint64_t*) UINTPTR_MAX; + rv = ctxt->report_error ( ctxt, EXR_ERR_BAD_CHUNK_LEADER, "Incomplete / corrupt chunk table, unable to reconstruct"); @@ -637,8 +634,7 @@ extract_chunk_table ( &eptr, nptr)) { - if (nptr != UINTPTR_MAX) - ctxt->free_fn (ctable); + if (nptr != UINTPTR_MAX) ctxt->free_fn (ctable); ctable = (uint64_t*) eptr; if (ctable == NULL) return ctxt->standard_error (ctxt, EXR_ERR_OUT_OF_MEMORY); @@ -646,16 +642,15 @@ extract_chunk_table ( } *chunktable = ctable; - return ((uintptr_t)ctable) == UINTPTR_MAX ? EXR_ERR_BAD_CHUNK_LEADER : EXR_ERR_SUCCESS; + return ((uintptr_t) ctable) == UINTPTR_MAX ? EXR_ERR_BAD_CHUNK_LEADER + : EXR_ERR_SUCCESS; } /**************************************/ static exr_result_t alloc_chunk_table ( - exr_const_context_t ctxt, - exr_const_priv_part_t part, - uint64_t** chunktable) + exr_const_context_t ctxt, exr_const_priv_part_t part, uint64_t** chunktable) { uint64_t* ctable = NULL; @@ -692,11 +687,7 @@ alloc_chunk_table ( static uint64_t compute_chunk_unpack_size ( - int y, - int width, - int height, - int lpc, - exr_const_priv_part_t part) + int y, int width, int height, int lpc, exr_const_priv_part_t part) { uint64_t unpacksize = 0; if (part->chan_has_line_sampling || height != lpc) @@ -1438,8 +1429,7 @@ exr_read_deep_chunk ( cinfo->sample_count_data_offset, ctxt->file_size); - if (ctxt->file_size > 0 && - cinfo->data_offset > (uint64_t) ctxt->file_size) + if (ctxt->file_size > 0 && cinfo->data_offset > (uint64_t) ctxt->file_size) return ctxt->print_error ( ctxt, EXR_ERR_INVALID_ARGUMENT, diff --git a/src/lib/OpenEXRCore/coding.c b/src/lib/OpenEXRCore/coding.c index e36576f5e0..4c47aeee5c 100644 --- a/src/lib/OpenEXRCore/coding.c +++ b/src/lib/OpenEXRCore/coding.c @@ -10,12 +10,12 @@ exr_result_t internal_coding_fill_channel_info ( - exr_coding_channel_info_t** channels, - int16_t* num_chans, - exr_coding_channel_info_t* builtinextras, - const exr_chunk_info_t* cinfo, - exr_const_context_t ctxt, - exr_const_priv_part_t part) + exr_coding_channel_info_t** channels, + int16_t* num_chans, + exr_coding_channel_info_t* builtinextras, + const exr_chunk_info_t* cinfo, + exr_const_context_t ctxt, + exr_const_priv_part_t part) { int chans; exr_attr_chlist_t* chanlist; @@ -72,11 +72,11 @@ internal_coding_fill_channel_info ( exr_result_t internal_coding_update_channel_info ( - exr_coding_channel_info_t* channels, - int16_t num_chans, - const exr_chunk_info_t* cinfo, - exr_const_context_t ctxt, - exr_const_priv_part_t part) + exr_coding_channel_info_t* channels, + int16_t num_chans, + const exr_chunk_info_t* cinfo, + exr_const_context_t ctxt, + exr_const_priv_part_t part) { int chans; exr_attr_chlist_t* chanlist; diff --git a/src/lib/OpenEXRCore/context.c b/src/lib/OpenEXRCore/context.c index 3698c8d897..5222e98d3c 100644 --- a/src/lib/OpenEXRCore/context.c +++ b/src/lib/OpenEXRCore/context.c @@ -49,12 +49,7 @@ dispatch_read ( if (ctxt->read_fn) rval = ctxt->read_fn ( - ctxt, - ctxt->user_data, - buf, - sz, - *offsetp, - ctxt->print_error); + ctxt, ctxt->user_data, buf, sz, *offsetp, ctxt->print_error); else return ctxt->standard_error (ctxt, EXR_ERR_NOT_OPEN_READ); @@ -73,10 +68,7 @@ dispatch_read ( static exr_result_t dispatch_write ( - exr_context_t ctxt, - const void* buf, - uint64_t sz, - uint64_t* offsetp) + exr_context_t ctxt, const void* buf, uint64_t sz, uint64_t* offsetp) { int64_t rval = -1; @@ -90,12 +82,7 @@ dispatch_write ( if (ctxt->write_fn) rval = ctxt->write_fn ( - ctxt, - ctxt->user_data, - buf, - sz, - *offsetp, - ctxt->print_error); + ctxt, ctxt->user_data, buf, sz, *offsetp, ctxt->print_error); else return ctxt->standard_error (ctxt, EXR_ERR_NOT_OPEN_WRITE); @@ -107,8 +94,7 @@ dispatch_write ( /**************************************/ static exr_result_t -process_query_size ( - exr_context_t ctxt, exr_context_initializer_t* inits) +process_query_size (exr_context_t ctxt, exr_context_initializer_t* inits) { if (inits->size_fn) { @@ -175,8 +161,7 @@ exr_test_file_header ( { ret->do_read = &dispatch_read; - rv = exr_attr_string_create ( - ret, &(ret->filename), filename); + rv = exr_attr_string_create (ret, &(ret->filename), filename); if (rv == EXR_ERR_SUCCESS) { if (!inits.read_fn) @@ -226,8 +211,7 @@ exr_finish (exr_context_t* pctxt) if (ctxt->mode != EXR_CONTEXT_READ) rv = finalize_write (ctxt, failed); - if (ctxt->destroy_fn) - ctxt->destroy_fn (ctxt, ctxt->user_data, failed); + if (ctxt->destroy_fn) ctxt->destroy_fn (ctxt, ctxt->user_data, failed); internal_exr_destroy_context (ctxt); } @@ -479,8 +463,8 @@ exr_register_attr_type_handler ( "Provided type name '%s' is a reserved / internal type name", type)); - rv = exr_attr_list_find_by_name ( - ctxt, &(ctxt->custom_handlers), type, &ent); + rv = + exr_attr_list_find_by_name (ctxt, &(ctxt->custom_handlers), type, &ent); if (rv == EXR_ERR_SUCCESS) return EXR_UNLOCK_AND_RETURN (ctxt->print_error ( ctxt, @@ -493,10 +477,7 @@ exr_register_attr_type_handler ( ctxt, &(ctxt->custom_handlers), type, type, 0, NULL, &ent); if (rv != EXR_ERR_SUCCESS) return EXR_UNLOCK_AND_RETURN (ctxt->print_error ( - ctxt, - rv, - "Unable to register custom handler for type '%s'", - type)); + ctxt, rv, "Unable to register custom handler for type '%s'", type)); ent->opaque->unpack_func_ptr = unpack_func_ptr; ent->opaque->pack_func_ptr = pack_func_ptr; @@ -653,7 +634,7 @@ exr_write_header (exr_context_t ctxt) { exr_priv_part_t curp = ctxt->parts[p]; - curp->chunk_table_offset = ctxt->output_file_offset; + curp->chunk_table_offset = ctxt->output_file_offset; ctxt->output_file_offset += (uint64_t) (curp->chunk_count) * sizeof (uint64_t); } diff --git a/src/lib/OpenEXRCore/debug.c b/src/lib/OpenEXRCore/debug.c index a7a227326e..34d510f0a1 100644 --- a/src/lib/OpenEXRCore/debug.c +++ b/src/lib/OpenEXRCore/debug.c @@ -288,7 +288,7 @@ exr_print_context_info (exr_const_context_t ctxt, int verbose) (int) ctxt->version, ctxt->is_singlepart_tiled ? " singletile" : "", ctxt->max_name_length == EXR_LONGNAME_MAXLEN ? " longnames" - : " shortnames", + : " shortnames", ctxt->has_nonimage_data ? " deep" : "", ctxt->is_multipart ? " multipart" : ""); printf (" parts: %d\n", ctxt->num_parts); diff --git a/src/lib/OpenEXRCore/decoding.c b/src/lib/OpenEXRCore/decoding.c index 5127b7ec88..7a8bfb8dde 100644 --- a/src/lib/OpenEXRCore/decoding.c +++ b/src/lib/OpenEXRCore/decoding.c @@ -200,10 +200,7 @@ default_read_chunk (exr_decode_pipeline_t* decode) decode->chunk.packed_size); if (rv != EXR_ERR_SUCCESS) return rv; rv = exr_read_chunk ( - ctxt, - decode->part_index, - &(decode->chunk), - decode->packed_buffer); + ctxt, decode->part_index, &(decode->chunk), decode->packed_buffer); } return rv; @@ -287,7 +284,7 @@ decompress_data ( static exr_result_t default_decompress_chunk (exr_decode_pipeline_t* decode) { - exr_result_t rv = EXR_ERR_SUCCESS; + exr_result_t rv = EXR_ERR_SUCCESS; exr_const_context_t ctxt = decode->context; EXR_READONLY_AND_DEFINE_PART (decode->part_index); @@ -360,8 +357,8 @@ unpack_sample_table (exr_const_context_t ctxt, exr_decode_pipeline_t* decode) { for (int32_t y = 0; y < h; ++y) { - int32_t *cursampline = samptable + y * w; - int32_t prevsamp = 0; + int32_t* cursampline = samptable + y * w; + int32_t prevsamp = 0; for (int32_t x = 0; x < w; ++x) { int32_t nsamps = @@ -371,18 +368,17 @@ unpack_sample_table (exr_const_context_t ctxt, exr_decode_pipeline_t* decode) cursampline[x] = nsamps - prevsamp; prevsamp = nsamps; } - totsamp += (uint64_t)prevsamp; + totsamp += (uint64_t) prevsamp; } - if (totsamp >= (uint64_t)INT32_MAX) - return EXR_ERR_INVALID_SAMPLE_DATA; - samptable[w * h] = (int32_t)totsamp; + if (totsamp >= (uint64_t) INT32_MAX) return EXR_ERR_INVALID_SAMPLE_DATA; + samptable[w * h] = (int32_t) totsamp; } else { for (int32_t y = 0; y < h; ++y) { - int32_t *cursampline = samptable + y * w; - int32_t prevsamp = 0; + int32_t* cursampline = samptable + y * w; + int32_t prevsamp = 0; for (int32_t x = 0; x < w; ++x) { int32_t nsamps = @@ -391,13 +387,12 @@ unpack_sample_table (exr_const_context_t ctxt, exr_decode_pipeline_t* decode) if (nsamps < prevsamp) return EXR_ERR_INVALID_SAMPLE_DATA; cursampline[x] = nsamps; - prevsamp = nsamps; + prevsamp = nsamps; } - totsamp += (uint64_t)prevsamp; + totsamp += (uint64_t) prevsamp; } - if (totsamp >= (uint64_t)INT32_MAX) - return EXR_ERR_INVALID_SAMPLE_DATA; + if (totsamp >= (uint64_t) INT32_MAX) return EXR_ERR_INVALID_SAMPLE_DATA; } if ((totsamp * combSampSize) > decode->chunk.unpacked_size) @@ -680,17 +675,22 @@ exr_decoding_run ( decode->sample_count_table != decode->packed_sample_count_table) { /* happens when we're requested to pack to 'individual' mode */ - if (decode->sample_count_alloc_size < decode->chunk.sample_count_table_size) + if (decode->sample_count_alloc_size < + decode->chunk.sample_count_table_size) return EXR_ERR_OUT_OF_MEMORY; if (decode->chunk.sample_count_table_size > 0) { - memcpy (decode->sample_count_table, - decode->packed_sample_count_table, - decode->chunk.sample_count_table_size); + memcpy ( + decode->sample_count_table, + decode->packed_sample_count_table, + decode->chunk.sample_count_table_size); } else { - memset (decode->sample_count_table, 0, decode->sample_count_alloc_size); + memset ( + decode->sample_count_table, + 0, + decode->sample_count_alloc_size); } } @@ -700,9 +700,7 @@ exr_decoding_run ( if (rv != EXR_ERR_SUCCESS) return ctxt->report_error ( - ctxt, - rv, - "Decode pipeline unable to unpack deep sample table"); + ctxt, rv, "Decode pipeline unable to unpack deep sample table"); } if (rv == EXR_ERR_SUCCESS && decode->realloc_nonimage_data_fn) diff --git a/src/lib/OpenEXRCore/internal_b44.c b/src/lib/OpenEXRCore/internal_b44.c index 30d0f6696d..8924f86408 100644 --- a/src/lib/OpenEXRCore/internal_b44.c +++ b/src/lib/OpenEXRCore/internal_b44.c @@ -241,39 +241,73 @@ unpack14 (const uint8_t b[14], uint16_t s[16]) shift = (b[2] >> 2); bias = (uint16_t) (0x20u << shift); - s[4] = - (uint16_t) ((uint32_t) s[0] + (uint32_t) ((((uint32_t) (b[2] << 4) | (uint32_t) (b[3] >> 4)) & 0x3fu) << shift) - bias); - s[8] = - (uint16_t) ((uint32_t) s[4] + (uint32_t) ((((uint32_t) (b[3] << 2) | (uint32_t) (b[4] >> 6)) & 0x3fu) << shift) - bias); - s[12] = - (uint16_t) ((uint32_t) s[8] + (uint32_t) ((uint32_t) (b[4] & 0x3fu) << shift) - bias); - - s[1] = - (uint16_t) ((uint32_t) s[0] + (uint32_t) ((uint32_t) (b[5] >> 2) << shift) - bias); - s[5] = - (uint16_t) ((uint32_t) s[4] + (uint32_t) ((((uint32_t) (b[5] << 4) | (uint32_t) (b[6] >> 4)) & 0x3fu) << shift) - bias); - s[9] = - (uint16_t) ((uint32_t) s[8] + (uint32_t) ((((uint32_t) (b[6] << 2) | (uint32_t) (b[7] >> 6)) & 0x3fu) << shift) - bias); - s[13] = - (uint16_t) ((uint32_t) s[12] + (uint32_t) ((uint32_t) (b[7] & 0x3fu) << shift) - bias); - - s[2] = - (uint16_t) ((uint32_t) s[1] + (uint32_t) ((uint32_t) (b[8] >> 2) << shift) - bias); - s[6] = - (uint16_t) ((uint32_t) s[5] + (uint32_t) ((((uint32_t) (b[8] << 4) | (uint32_t) (b[9] >> 4)) & 0x3fu) << shift) - bias); - s[10] = - (uint16_t) ((uint32_t) s[9] + (uint32_t) ((((uint32_t) (b[9] << 2) | (uint32_t) (b[10] >> 6)) & 0x3fu) << shift) - bias); + s[4] = (uint16_t) ((uint32_t) s[0] + + (uint32_t) ((((uint32_t) (b[2] << 4) | + (uint32_t) (b[3] >> 4)) & + 0x3fu) + << shift) - + bias); + s[8] = (uint16_t) ((uint32_t) s[4] + + (uint32_t) ((((uint32_t) (b[3] << 2) | + (uint32_t) (b[4] >> 6)) & + 0x3fu) + << shift) - + bias); + s[12] = (uint16_t) ((uint32_t) s[8] + + (uint32_t) ((uint32_t) (b[4] & 0x3fu) << shift) - bias); + + s[1] = (uint16_t) ((uint32_t) s[0] + + (uint32_t) ((uint32_t) (b[5] >> 2) << shift) - bias); + s[5] = (uint16_t) ((uint32_t) s[4] + + (uint32_t) ((((uint32_t) (b[5] << 4) | + (uint32_t) (b[6] >> 4)) & + 0x3fu) + << shift) - + bias); + s[9] = (uint16_t) ((uint32_t) s[8] + + (uint32_t) ((((uint32_t) (b[6] << 2) | + (uint32_t) (b[7] >> 6)) & + 0x3fu) + << shift) - + bias); + s[13] = (uint16_t) ((uint32_t) s[12] + + (uint32_t) ((uint32_t) (b[7] & 0x3fu) << shift) - bias); + + s[2] = (uint16_t) ((uint32_t) s[1] + + (uint32_t) ((uint32_t) (b[8] >> 2) << shift) - bias); + s[6] = (uint16_t) ((uint32_t) s[5] + + (uint32_t) ((((uint32_t) (b[8] << 4) | + (uint32_t) (b[9] >> 4)) & + 0x3fu) + << shift) - + bias); + s[10] = (uint16_t) ((uint32_t) s[9] + + (uint32_t) ((((uint32_t) (b[9] << 2) | + (uint32_t) (b[10] >> 6)) & + 0x3fu) + << shift) - + bias); s[14] = - (uint16_t) ((uint32_t) s[13] + (uint32_t) ((uint32_t) (b[10] & 0x3fu) << shift) - bias); - - s[3] = - (uint16_t) ((uint32_t) s[2] + (uint32_t) ((uint32_t) (b[11] >> 2) << shift) - bias); - s[7] = - (uint16_t) ((uint32_t) s[6] + (uint32_t) ((((uint32_t) (b[11] << 4) | (uint32_t) (b[12] >> 4)) & 0x3fu) << shift) - bias); - s[11] = - (uint16_t) ((uint32_t) s[10] + (uint32_t) ((((uint32_t) (b[12] << 2) | (uint32_t) (b[13] >> 6)) & 0x3fu) << shift) - bias); + (uint16_t) ((uint32_t) s[13] + + (uint32_t) ((uint32_t) (b[10] & 0x3fu) << shift) - bias); + + s[3] = (uint16_t) ((uint32_t) s[2] + + (uint32_t) ((uint32_t) (b[11] >> 2) << shift) - bias); + s[7] = (uint16_t) ((uint32_t) s[6] + + (uint32_t) ((((uint32_t) (b[11] << 4) | + (uint32_t) (b[12] >> 4)) & + 0x3fu) + << shift) - + bias); + s[11] = (uint16_t) ((uint32_t) s[10] + + (uint32_t) ((((uint32_t) (b[12] << 2) | + (uint32_t) (b[13] >> 6)) & + 0x3fu) + << shift) - + bias); s[15] = - (uint16_t) ((uint32_t) s[14] + (uint32_t) ((uint32_t) (b[13] & 0x3fu) << shift) - bias); + (uint16_t) ((uint32_t) s[14] + + (uint32_t) ((uint32_t) (b[13] & 0x3fu) << shift) - bias); for (int i = 0; i < 16; ++i) { diff --git a/src/lib/OpenEXRCore/internal_cpuid.h b/src/lib/OpenEXRCore/internal_cpuid.h index 439431dcba..90ce6ae361 100644 --- a/src/lib/OpenEXRCore/internal_cpuid.h +++ b/src/lib/OpenEXRCore/internal_cpuid.h @@ -8,7 +8,8 @@ #include "OpenEXRConfigInternal.h" -#if defined(i386) || defined(__i386__) || defined(__i386) || defined(_M_X86) || defined(__x86_64__) || defined(_M_X64) +#if defined(i386) || defined(__i386__) || defined(__i386) || \ + defined(_M_X86) || defined(__x86_64__) || defined(_M_X64) # define OPENEXR_ENABLE_X86_SIMD_CHECK 1 #else # define OPENEXR_ENABLE_X86_SIMD_CHECK 0 @@ -51,15 +52,15 @@ check_for_x86_simd (int* f16c, int* avx, int* sse2) #elif OPENEXR_ENABLE_X86_SIMD_CHECK -# if defined(_WIN32) - int regs[4]={0}, osxsave; +# if defined(_WIN32) + int regs[4] = {0}, osxsave; __cpuid (regs, 0); if (regs[0] >= 1) { __cpuidex (regs, 1, 0); } else regs[2] = 0; -# else - unsigned int regs[4]={0}, osxsave; +# else + unsigned int regs[4] = {0}, osxsave; __get_cpuid (0, ®s[0], ®s[1], ®s[2], ®s[3]); if (regs[0] >= 1) { @@ -67,7 +68,7 @@ check_for_x86_simd (int* f16c, int* avx, int* sse2) } else regs[2] = 0; -# endif +# endif /* * linux cpuid.h for x86 has defines but not consistent cross platform @@ -77,8 +78,8 @@ check_for_x86_simd (int* f16c, int* avx, int* sse2) osxsave = (regs[2] & (1 << 27)) ? 1 : 0; /* AVX is indicated by bit 28, F16C by 29 of ECX (reg 2) */ - *avx = (regs[2] & (1 << 28)) ? 1 : 0; - *f16c = (regs[2] & (1 << 29)) ? 1 : 0; + *avx = (regs[2] & (1 << 28)) ? 1 : 0; + *f16c = (regs[2] & (1 << 29)) ? 1 : 0; /* sse2 is in EDX bit 26 */ *sse2 = (regs[3] & (1 << 26)) ? 1 : 0; @@ -94,7 +95,7 @@ check_for_x86_simd (int* f16c, int* avx, int* sse2) # if defined(_MSC_VER) /* TODO: remove the following disablement once we can do inline msvc */ # if defined(OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX) - regs[0] = _xgetbv(0); + regs[0] = _xgetbv (0); # else regs[0] = 0; # endif @@ -111,8 +112,8 @@ check_for_x86_simd (int* f16c, int* avx, int* sse2) *f16c = 0; } # else - *avx = 0; - *f16c = 0; + *avx = 0; + *f16c = 0; # endif } @@ -122,7 +123,6 @@ check_for_x86_simd (int* f16c, int* avx, int* sse2) *avx = 0; *sse2 = 0; #endif - } static inline int @@ -141,4 +141,3 @@ has_native_half (void) #undef OPENEXR_ENABLE_X86_SIMD_CHECK #endif - diff --git a/src/lib/OpenEXRCore/internal_dwa_compressor.h b/src/lib/OpenEXRCore/internal_dwa_compressor.h index 54bb1414e7..705a036c59 100644 --- a/src/lib/OpenEXRCore/internal_dwa_compressor.h +++ b/src/lib/OpenEXRCore/internal_dwa_compressor.h @@ -253,9 +253,8 @@ DwaCompressor_compress (DwaCompressor* me) // Starting with DWA v2, we write the channel // classification rules into the file - me->_channelRules = sDefaultChannelRules; - me->_channelRuleCount = - sizeof (sDefaultChannelRules) / sizeof (Classifier); + me->_channelRules = sDefaultChannelRules; + me->_channelRuleCount = sizeof (sDefaultChannelRules) / sizeof (Classifier); rv = DwaCompressor_initializeBuffers (me, &outBufferSize); @@ -758,8 +757,8 @@ DwaCompressor_uncompress ( dcCompressedSize + rleCompressedSize; dataPtrEnd = inPtr + iSize; - dataPtr = inPtr + headerSize; - dataLeft = iSize - headerSize; + dataPtr = inPtr + headerSize; + dataLeft = iSize - headerSize; /* Both the sum and individual sizes are checked in case of overflow. */ if (iSize < (headerSize + compressedSize) || @@ -836,12 +835,9 @@ DwaCompressor_uncompress ( compressedDcBuf = compressedAcBuf + (ptrdiff_t) (acCompressedSize); compressedRleBuf = compressedDcBuf + (ptrdiff_t) (dcCompressedSize); - if (compressedUnknownBuf > dataPtrEnd || - dataPtr > compressedAcBuf || - compressedAcBuf > dataPtrEnd || - dataPtr > compressedDcBuf || - compressedDcBuf > dataPtrEnd || - dataPtr > compressedRleBuf || + if (compressedUnknownBuf > dataPtrEnd || dataPtr > compressedAcBuf || + compressedAcBuf > dataPtrEnd || dataPtr > compressedDcBuf || + compressedDcBuf > dataPtrEnd || dataPtr > compressedRleBuf || compressedRleBuf > dataPtrEnd || (compressedRleBuf + rleCompressedSize) > dataPtrEnd) { @@ -1703,7 +1699,7 @@ DwaCompressor_setupChannelData (DwaCompressor* me) { for (int byte = 1; byte < curc->bytes_per_element; ++byte) { - cd->planarUncRle[byte] = 0; + cd->planarUncRle[byte] = 0; cd->planarUncRleEnd[byte] = 0; } } diff --git a/src/lib/OpenEXRCore/internal_dwa_decoder.h b/src/lib/OpenEXRCore/internal_dwa_decoder.h index bcdebd985f..e66733d765 100644 --- a/src/lib/OpenEXRCore/internal_dwa_decoder.h +++ b/src/lib/OpenEXRCore/internal_dwa_decoder.h @@ -133,7 +133,14 @@ LossyDctDecoder_construct ( // rv = LossyDctDecoder_base_construct ( - d, packedAc, packedAcEnd, packedDc, remDcCount, toLinear, width, height); + d, + packedAc, + packedAcEnd, + packedDc, + remDcCount, + toLinear, + width, + height); d->_channel_decode_data[0] = rowPtrs; d->_channel_decode_data_count = 1; @@ -168,7 +175,14 @@ LossyDctDecoderCsc_construct ( { exr_result_t rv; rv = LossyDctDecoder_base_construct ( - d, packedAc, packedAcEnd, packedDc, remDcCount, toLinear, width, height); + d, + packedAc, + packedAcEnd, + packedDc, + remDcCount, + toLinear, + width, + height); if (rv != EXR_ERR_SUCCESS) return rv; d->_channel_decode_data[0] = rowPtrsR; @@ -224,9 +238,9 @@ LossyDctDecoder_execute ( DctCoderChannelData* chanData[3]; int lastNonZero = 0; int numBlocksX = (d->_width + 7) / 8; - int numBlocksY = (d->_height + 7) / 8; - int leftoverX = d->_width - (numBlocksX - 1) * 8; - int leftoverY = d->_height - (numBlocksY - 1) * 8; + int numBlocksY = (d->_height + 7) / 8; + int leftoverX = d->_width - (numBlocksX - 1) * 8; + int leftoverY = d->_height - (numBlocksY - 1) * 8; int numFullBlocksX = d->_width / 8; @@ -236,7 +250,8 @@ LossyDctDecoder_execute ( uint8_t* rowBlockHandle; uint16_t* rowBlock[3]; - if (d->_remDcCount < ((uint64_t)numComp * (uint64_t)numBlocksX * (uint64_t)numBlocksY)) + if (d->_remDcCount < + ((uint64_t) numComp * (uint64_t) numBlocksX * (uint64_t) numBlocksY)) { return EXR_ERR_CORRUPT_CHUNK; } diff --git a/src/lib/OpenEXRCore/internal_file.h b/src/lib/OpenEXRCore/internal_file.h index 06aa014782..504abe64e0 100644 --- a/src/lib/OpenEXRCore/internal_file.h +++ b/src/lib/OpenEXRCore/internal_file.h @@ -23,18 +23,15 @@ exr_result_t internal_exr_check_magic (exr_context_t ctxt); /* in openexr_parse_header.c, reads the header and populates the file structure */ exr_result_t internal_exr_parse_header (exr_context_t ctxt); exr_result_t internal_exr_compute_tile_information ( - exr_context_t ctxt, - exr_priv_part_t curpart, - int rebuild); -int32_t -internal_exr_compute_chunk_offset_size (exr_priv_part_t curpart); + exr_context_t ctxt, exr_priv_part_t curpart, int rebuild); +int32_t internal_exr_compute_chunk_offset_size (exr_priv_part_t curpart); exr_result_t internal_exr_write_header (exr_context_t ctxt); /* in openexr_validate.c, functions to validate the header during read / pre-write */ -exr_result_t internal_exr_validate_read_part ( - exr_context_t ctxt, exr_priv_part_t curpart); -exr_result_t internal_exr_validate_write_part ( - exr_context_t ctxt, exr_priv_part_t curpart); +exr_result_t +internal_exr_validate_read_part (exr_context_t ctxt, exr_priv_part_t curpart); +exr_result_t +internal_exr_validate_write_part (exr_context_t ctxt, exr_priv_part_t curpart); #endif /* OPENEXR_PRIVATE_FILE_UTIL_H */ diff --git a/src/lib/OpenEXRCore/internal_huf.c b/src/lib/OpenEXRCore/internal_huf.c index 1a6a0fffa1..21f554c4d6 100644 --- a/src/lib/OpenEXRCore/internal_huf.c +++ b/src/lib/OpenEXRCore/internal_huf.c @@ -1017,11 +1017,12 @@ readUInt (const uint8_t* b) #endif #ifdef SWAP64 -static inline uint64_t READ64(const uint8_t *src) +static inline uint64_t +READ64 (const uint8_t* src) { uint64_t v; // unaligned reads are UB - memcpy (&v, src, sizeof(uint64_t)); + memcpy (&v, src, sizeof (uint64_t)); return SWAP64 (v); } #else @@ -1851,7 +1852,7 @@ internal_huf_decompress ( uint64_t nBytes; const uint8_t* ptr; exr_result_t rv; - exr_const_context_t pctxt = NULL; + exr_const_context_t pctxt = NULL; const uint64_t hufInfoBlockSize = 5 * sizeof (uint32_t); if (decode) pctxt = decode->context; diff --git a/src/lib/OpenEXRCore/internal_posix_file_impl.h b/src/lib/OpenEXRCore/internal_posix_file_impl.h index ff42795fdc..187a8e2cbf 100644 --- a/src/lib/OpenEXRCore/internal_posix_file_impl.h +++ b/src/lib/OpenEXRCore/internal_posix_file_impl.h @@ -4,7 +4,7 @@ */ /* implementation for unix-like file io routines (used in context.c) */ -#include "openexr_config.h" +#include "openexr_config.h" #include @@ -36,7 +36,7 @@ struct _internal_exr_filehandle #else struct _internal_exr_filehandle { - int fd; + int fd; # ifdef ILMTHREAD_THREADING_ENABLED pthread_mutex_t mutex; # endif diff --git a/src/lib/OpenEXRCore/internal_structs.c b/src/lib/OpenEXRCore/internal_structs.c index 5eabdbae77..f985500753 100644 --- a/src/lib/OpenEXRCore/internal_structs.c +++ b/src/lib/OpenEXRCore/internal_structs.c @@ -78,8 +78,7 @@ default_error_handler ( } static exr_result_t -dispatch_error ( - exr_const_context_t ctxt, exr_result_t code, const char* msg) +dispatch_error (exr_const_context_t ctxt, exr_result_t code, const char* msg) { if (ctxt) { @@ -102,17 +101,12 @@ dispatch_standard_error (exr_const_context_t ctxt, exr_result_t code) /**************************************/ static exr_result_t dispatch_print_error ( - exr_const_context_t ctxt, - exr_result_t code, - const char* msg, - ...) EXR_PRINTF_FUNC_ATTRIBUTE; + exr_const_context_t ctxt, exr_result_t code, const char* msg, ...) + EXR_PRINTF_FUNC_ATTRIBUTE; static exr_result_t dispatch_print_error ( - exr_const_context_t ctxt, - exr_result_t code, - const char* msg, - ...) + exr_const_context_t ctxt, exr_result_t code, const char* msg, ...) { char stackbuf[256]; char* heapbuf = NULL; @@ -149,8 +143,7 @@ dispatch_print_error ( /**************************************/ static void -internal_exr_destroy_part ( - exr_context_t ctxt, exr_priv_part_t cur) +internal_exr_destroy_part (exr_context_t ctxt, exr_priv_part_t cur) { exr_memory_free_func_t dofree = ctxt->free_fn; uint64_t* ctable; @@ -168,7 +161,7 @@ internal_exr_destroy_part ( ctable = (uint64_t*) atomic_load (&(cur->chunk_table)); atomic_store (&(cur->chunk_table), (uintptr_t) (0)); #endif - if (ctable && ((uintptr_t)ctable) != UINTPTR_MAX) dofree (ctable); + if (ctable && ((uintptr_t) ctable) != UINTPTR_MAX) dofree (ctable); } /**************************************/ @@ -197,11 +190,9 @@ internal_exr_destroy_parts (exr_context_t ctxt) exr_result_t internal_exr_add_part ( - exr_context_t f, - exr_priv_part_t* outpart, - int* new_index) + exr_context_t f, exr_priv_part_t* outpart, int* new_index) { - int ncount = f->num_parts + 1; + int ncount = f->num_parts + 1; exr_priv_part_t part; exr_priv_part_t* nptrs = NULL; @@ -221,8 +212,7 @@ internal_exr_add_part ( part = f->alloc_fn (sizeof (struct _priv_exr_part_t)); if (!part) return f->standard_error (f, EXR_ERR_OUT_OF_MEMORY); - nptrs = - f->alloc_fn (sizeof (exr_priv_part_t) * (size_t) ncount); + nptrs = f->alloc_fn (sizeof (exr_priv_part_t) * (size_t) ncount); if (!nptrs) { f->free_fn (part); @@ -264,11 +254,9 @@ internal_exr_add_part ( void internal_exr_revert_add_part ( - exr_context_t ctxt, - exr_priv_part_t* outpart, - int* new_index) + exr_context_t ctxt, exr_priv_part_t* outpart, int* new_index) { - int ncount = ctxt->num_parts - 1; + int ncount = ctxt->num_parts - 1; exr_priv_part_t part = *outpart; *outpart = NULL; diff --git a/src/lib/OpenEXRCore/internal_structs.h b/src/lib/OpenEXRCore/internal_structs.h index 985ed89312..fcf7e1297b 100644 --- a/src/lib/OpenEXRCore/internal_structs.h +++ b/src/lib/OpenEXRCore/internal_structs.h @@ -163,14 +163,10 @@ struct _priv_exr_context_t exr_result_t (*standard_error) ( exr_const_context_t ctxt, exr_result_t code); exr_result_t (*report_error) ( - exr_const_context_t ctxt, - exr_result_t code, - const char* msg); + exr_const_context_t ctxt, exr_result_t code, const char* msg); exr_result_t (*print_error) ( - exr_const_context_t ctxt, - exr_result_t code, - const char* msg, - ...) EXR_PRINTF_FUNC_ATTRIBUTE; + exr_const_context_t ctxt, exr_result_t code, const char* msg, ...) + EXR_PRINTF_FUNC_ATTRIBUTE; exr_error_handler_cb_t error_handler_fn; @@ -229,8 +225,7 @@ static inline void internal_exr_lock (exr_const_context_t c) { #ifdef ILMTHREAD_THREADING_ENABLED - exr_context_t nonc = - EXR_CONST_CAST (exr_context_t, c); + exr_context_t nonc = EXR_CONST_CAST (exr_context_t, c); # ifdef _WIN32 EnterCriticalSection (&nonc->mutex); # else @@ -243,8 +238,7 @@ static inline void internal_exr_unlock (exr_const_context_t c) { #ifdef ILMTHREAD_THREADING_ENABLED - exr_context_t nonc = - EXR_CONST_CAST (exr_context_t, c); + exr_context_t nonc = EXR_CONST_CAST (exr_context_t, c); # ifdef _WIN32 LeaveCriticalSection (&nonc->mutex); # else @@ -255,8 +249,9 @@ internal_exr_unlock (exr_const_context_t c) #define EXR_UNLOCK_AND_RETURN(v) ((void) (internal_exr_unlock (ctxt)), v) #define EXR_UNLOCK_WRITE_AND_RETURN(v) \ - ((void) ((ctxt->mode == EXR_CONTEXT_WRITE) ? \ - internal_exr_unlock (ctxt) : ((void) 0)), v) + ((void) ((ctxt->mode == EXR_CONTEXT_WRITE) ? internal_exr_unlock (ctxt) \ + : ((void) 0)), \ + v) #define EXR_LOCK_AND_DEFINE_PART(pi) \ exr_priv_part_t part; \ @@ -279,19 +274,19 @@ internal_exr_unlock (exr_const_context_t c) if (ctxt->mode == EXR_CONTEXT_WRITE) internal_exr_lock (ctxt); \ if (pi < 0 || pi >= ctxt->num_parts) \ { \ - if (ctxt->mode == EXR_CONTEXT_WRITE) internal_exr_unlock(ctxt); \ + if (ctxt->mode == EXR_CONTEXT_WRITE) internal_exr_unlock (ctxt); \ return ctxt->print_error ( \ - ctxt, \ - EXR_ERR_ARGUMENT_OUT_OF_RANGE, \ - "Part index (%d) out of range", \ - pi); \ + ctxt, \ + EXR_ERR_ARGUMENT_OUT_OF_RANGE, \ + "Part index (%d) out of range", \ + pi); \ } \ part = ctxt->parts[pi] #define EXR_CHECK_CONTEXT_AND_PART(pi) \ if (!ctxt) return EXR_ERR_MISSING_CONTEXT_ARG; \ if (pi < 0 || pi >= ctxt->num_parts) \ - return ctxt->print_error ( \ + return ctxt->print_error ( \ ctxt, \ EXR_ERR_ARGUMENT_OUT_OF_RANGE, \ "Part index (%d) out of range", \ @@ -317,8 +312,8 @@ exr_result_t internal_exr_add_part ( void internal_exr_revert_add_part ( exr_context_t ctxt, exr_priv_part_t* outpart, int* new_index); -exr_result_t internal_exr_context_restore_handlers ( - exr_context_t ctxt, exr_result_t rv); +exr_result_t +internal_exr_context_restore_handlers (exr_context_t ctxt, exr_result_t rv); exr_result_t internal_exr_alloc_context ( exr_context_t* out, diff --git a/src/lib/OpenEXRCore/openexr_attr.h b/src/lib/OpenEXRCore/openexr_attr.h index eabcd57d9c..7b01e4b350 100644 --- a/src/lib/OpenEXRCore/openexr_attr.h +++ b/src/lib/OpenEXRCore/openexr_attr.h @@ -284,7 +284,7 @@ typedef struct ((exr_tile_round_mode_t) ((((tiledesc).level_and_round) >> 4) & 0xF)) /** @brief Macro to pack the tiling type and rounding mode into packed structure. */ #define EXR_PACK_TILE_LEVEL_ROUND(lvl, mode) \ - ((uint8_t) ((((uint8_t) ((mode) &0xF) << 4)) | ((uint8_t) ((lvl) &0xF)))) + ((uint8_t) ((((uint8_t) ((mode) & 0xF) << 4)) | ((uint8_t) ((lvl) & 0xF)))) #pragma pack(pop) diff --git a/src/lib/OpenEXRCore/parse_header.c b/src/lib/OpenEXRCore/parse_header.c index 5027f047e7..5eb78c69c9 100644 --- a/src/lib/OpenEXRCore/parse_header.c +++ b/src/lib/OpenEXRCore/parse_header.c @@ -20,10 +20,7 @@ /**************************************/ static exr_result_t -silent_error ( - exr_const_context_t pctxt, - exr_result_t code, - const char* msg) +silent_error (exr_const_context_t pctxt, exr_result_t code, const char* msg) { (void) pctxt; (void) msg; @@ -31,8 +28,7 @@ silent_error ( } static exr_result_t -silent_standard_error ( - exr_const_context_t pctxt, exr_result_t code) +silent_standard_error (exr_const_context_t pctxt, exr_result_t code) { (void) pctxt; return code; @@ -40,10 +36,7 @@ silent_standard_error ( static exr_result_t silent_print_error ( - exr_const_context_t pctxt, - exr_result_t code, - const char* msg, - ...) + exr_const_context_t pctxt, exr_result_t code, const char* msg, ...) { (void) pctxt; (void) msg; @@ -68,8 +61,7 @@ struct _internal_exr_seq_scratch }; static inline int -scratch_attr_too_big ( - struct _internal_exr_seq_scratch* scr, int32_t attrsz) +scratch_attr_too_big (struct _internal_exr_seq_scratch* scr, int32_t attrsz) { int64_t acmp = (int64_t) attrsz; if (scr->ctxt->file_size > 0 && (acmp > scr->navail)) @@ -220,9 +212,7 @@ scratch_seq_skip (struct _internal_exr_seq_scratch* scr, int32_t sz) static exr_result_t priv_init_scratch ( - exr_context_t ctxt, - struct _internal_exr_seq_scratch* scr, - uint64_t offset) + exr_context_t ctxt, struct _internal_exr_seq_scratch* scr, uint64_t offset) { scr->curpos = 0; scr->navail = 0; @@ -256,7 +246,7 @@ check_bad_attrsz ( const char* tname, int32_t* outsz) { - int32_t n = attrsz; + int32_t n = attrsz; *outsz = n; if (attrsz < 0) @@ -343,12 +333,12 @@ extract_attr_chlist ( const char* tname, int32_t attrsz) { - char chname[256]; - int32_t chlen; - int32_t ptype, xsamp, ysamp; - uint8_t flags[4]; - int32_t maxlen = ctxt->max_name_length; - exr_result_t rv; + char chname[256]; + int32_t chlen; + int32_t ptype, xsamp, ysamp; + uint8_t flags[4]; + int32_t maxlen = ctxt->max_name_length; + exr_result_t rv; rv = check_bad_attrsz (scratch, attrsz, 1, aname, tname, &chlen); @@ -513,8 +503,8 @@ extract_attr_float_vector ( const char* tname, int32_t attrsz) { - int32_t n = 0; - exr_result_t rv = check_bad_attrsz ( + int32_t n = 0; + exr_result_t rv = check_bad_attrsz ( scratch, attrsz, (int) sizeof (float), aname, tname, &n); /* in case of duplicate attr name in header (mostly fuzz testing) */ @@ -556,7 +546,7 @@ extract_attr_string ( int32_t attrsz, char* strptr) { - exr_result_t rv = + exr_result_t rv = scratch->sequential_read (scratch, (void*) strptr, (uint64_t) attrsz); if (rv != EXR_ERR_SUCCESS) @@ -739,8 +729,8 @@ extract_attr_opaque ( const char* tname, int32_t attrsz) { - int32_t n; - exr_result_t rv; + int32_t n; + exr_result_t rv; rv = check_bad_attrsz (scratch, attrsz, 1, aname, tname, &n); if (rv != EXR_ERR_SUCCESS) return rv; @@ -776,10 +766,10 @@ extract_attr_preview ( const char* tname, int32_t attrsz) { - uint64_t bytes; - uint32_t sz[2]; - exr_result_t rv; - int64_t fsize = ctxt->file_size; + uint64_t bytes; + uint32_t sz[2]; + exr_result_t rv; + int64_t fsize = ctxt->file_size; /* mostly for fuzzing, but just in case there's a duplicate name */ exr_attr_preview_destroy (ctxt, attrdata); @@ -1471,8 +1461,7 @@ check_populate_name ( uint8_t* outstr; int32_t n; - rv = check_bad_attrsz ( - scratch, attrsz, 1, EXR_REQ_NAME_STR, tname, &n); + rv = check_bad_attrsz (scratch, attrsz, 1, EXR_REQ_NAME_STR, tname, &n); if (rv != EXR_ERR_SUCCESS) return rv; if (curpart->name) @@ -1515,18 +1504,14 @@ check_populate_name ( rv = scratch->sequential_read (scratch, outstr, (uint64_t) attrsz); if (rv != EXR_ERR_SUCCESS) { - exr_attr_list_remove ( - ctxt, &(curpart->attributes), curpart->name); + exr_attr_list_remove (ctxt, &(curpart->attributes), curpart->name); curpart->name = NULL; return ctxt->report_error (ctxt, rv, "Unable to read 'name' data"); } outstr[attrsz] = '\0'; rv = exr_attr_string_init_static_with_length ( - ctxt, - curpart->name->string, - (const char*) outstr, - attrsz); + ctxt, curpart->name->string, (const char*) outstr, attrsz); if (rv != EXR_ERR_SUCCESS) { exr_attr_list_remove ( @@ -1552,8 +1537,7 @@ check_populate_type ( uint8_t* outstr; int32_t n; - rv = check_bad_attrsz ( - scratch, attrsz, 1, EXR_REQ_TYPE_STR, tname, &n); + rv = check_bad_attrsz (scratch, attrsz, 1, EXR_REQ_TYPE_STR, tname, &n); if (rv != EXR_ERR_SUCCESS) return rv; if (curpart->type) @@ -1603,10 +1587,7 @@ check_populate_type ( outstr[attrsz] = '\0'; rv = exr_attr_string_init_static_with_length ( - ctxt, - curpart->type->string, - (const char*) outstr, - attrsz); + ctxt, curpart->type->string, (const char*) outstr, attrsz); if (rv != EXR_ERR_SUCCESS) { exr_attr_list_remove (ctxt, &(curpart->attributes), curpart->type); @@ -1914,13 +1895,7 @@ pull_attr ( else { rv = exr_attr_list_add_by_type ( - ctxt, - &(curpart->attributes), - name, - type, - 0, - NULL, - &nattr); + ctxt, &(curpart->attributes), name, type, 0, NULL, &nattr); } if (rv != EXR_ERR_SUCCESS) @@ -2143,9 +2118,7 @@ calc_level_size ( exr_result_t internal_exr_compute_tile_information ( - exr_context_t ctxt, - exr_priv_part_t curpart, - int rebuild) + exr_context_t ctxt, exr_priv_part_t curpart, int rebuild) { exr_result_t rv = EXR_ERR_SUCCESS; if (curpart->storage_mode == EXR_STORAGE_SCANLINE || @@ -2240,9 +2213,9 @@ internal_exr_compute_tile_information ( dw.max.x, sx, l); - levcntX[l] = - (int32_t) (((uint64_t) sx + tiledesc->x_size - 1) / tiledesc->x_size); - levszX[l] = (int32_t) sx; + levcntX[l] = (int32_t) (((uint64_t) sx + tiledesc->x_size - 1) / + tiledesc->x_size); + levszX[l] = (int32_t) sx; } for (int32_t l = 0; l < numY; ++l) @@ -2259,9 +2232,9 @@ internal_exr_compute_tile_information ( dw.max.y, sy, l); - levcntY[l] = - (int32_t) (((uint64_t) sy + tiledesc->y_size - 1) / tiledesc->y_size); - levszY[l] = (int32_t) sy; + levcntY[l] = (int32_t) (((uint64_t) sy + tiledesc->y_size - 1) / + tiledesc->y_size); + levszY[l] = (int32_t) sy; } curpart->tile_level_tile_count_x = levcntX; @@ -2396,8 +2369,7 @@ internal_exr_compute_chunk_offset_size (exr_priv_part_t curpart) static exr_result_t update_chunk_offsets ( - exr_context_t ctxt, - struct _internal_exr_seq_scratch* scratch) + exr_context_t ctxt, struct _internal_exr_seq_scratch* scratch) { exr_priv_part_t curpart, prevpart; @@ -2457,8 +2429,7 @@ update_chunk_offsets ( /**************************************/ static exr_result_t -read_magic_and_flags ( - exr_context_t ctxt, uint32_t* outflags, uint64_t* initpos) +read_magic_and_flags (exr_context_t ctxt, uint32_t* outflags, uint64_t* initpos) { uint32_t magic_and_version[2]; uint32_t flags; diff --git a/src/lib/OpenEXRCore/part.c b/src/lib/OpenEXRCore/part.c index 737d25c2aa..07172b44a2 100644 --- a/src/lib/OpenEXRCore/part.c +++ b/src/lib/OpenEXRCore/part.c @@ -62,7 +62,7 @@ exr_add_part ( exr_result_t rv; int32_t attrsz = -1; const char* typestr = NULL; - exr_priv_part_t part = NULL; + exr_priv_part_t part = NULL; if (!ctxt) return EXR_ERR_MISSING_CONTEXT_ARG; internal_exr_lock (ctxt); @@ -371,8 +371,7 @@ exr_get_scanlines_per_chunk ( { EXR_LOCK_WRITE_AND_DEFINE_PART (part_index); - if (!out) - return EXR_UNLOCK_WRITE_AND_RETURN (EXR_ERR_INVALID_ARGUMENT); + if (!out) return EXR_UNLOCK_WRITE_AND_RETURN (EXR_ERR_INVALID_ARGUMENT); if (part->storage_mode == EXR_STORAGE_SCANLINE || part->storage_mode == EXR_STORAGE_DEEP_SCANLINE) diff --git a/src/lib/OpenEXRCore/part_attr.c b/src/lib/OpenEXRCore/part_attr.c index f798d304ea..f65420f2d9 100644 --- a/src/lib/OpenEXRCore/part_attr.c +++ b/src/lib/OpenEXRCore/part_attr.c @@ -489,9 +489,7 @@ copy_attr ( break; case EXR_ATTR_UNKNOWN: case EXR_ATTR_LAST_KNOWN_TYPE: - default: - rv = ctxt->standard_error (ctxt, EXR_ERR_INVALID_ATTR); - break; + default: rv = ctxt->standard_error (ctxt, EXR_ERR_INVALID_ATTR); break; } if (rv != EXR_ERR_SUCCESS) @@ -514,8 +512,7 @@ exr_copy_unset_attributes ( int update_tiles = 0; EXR_LOCK_AND_DEFINE_PART (part_index); - if (!source) - return EXR_UNLOCK_AND_RETURN (EXR_ERR_MISSING_CONTEXT_ARG); + if (!source) return EXR_UNLOCK_AND_RETURN (EXR_ERR_MISSING_CONTEXT_ARG); if (source != ctxt) internal_exr_lock (source); if (src_part_index < 0 || src_part_index >= source->num_parts) @@ -560,61 +557,61 @@ exr_copy_unset_attributes ( /**************************************/ #define REQ_ATTR_GET_IMPL(name, entry, t) \ - EXR_LOCK_WRITE_AND_DEFINE_PART (part_index); \ + EXR_LOCK_WRITE_AND_DEFINE_PART (part_index); \ if (!out) \ - return EXR_UNLOCK_WRITE_AND_RETURN (ctxt->print_error ( \ - ctxt, EXR_ERR_INVALID_ARGUMENT, "NULL output for '%s'", #name)); \ + return EXR_UNLOCK_WRITE_AND_RETURN (ctxt->print_error ( \ + ctxt, EXR_ERR_INVALID_ARGUMENT, "NULL output for '%s'", #name)); \ if (part->name) \ { \ if (part->name->type != t) \ - return EXR_UNLOCK_WRITE_AND_RETURN (ctxt->print_error ( \ - ctxt, \ + return EXR_UNLOCK_WRITE_AND_RETURN (ctxt->print_error ( \ + ctxt, \ EXR_ERR_FILE_BAD_HEADER, \ "Invalid required attribute type '%s' for '%s'", \ part->name->type_name, \ #name)); \ *out = part->name->entry; \ - return EXR_UNLOCK_WRITE_AND_RETURN (EXR_ERR_SUCCESS); \ + return EXR_UNLOCK_WRITE_AND_RETURN (EXR_ERR_SUCCESS); \ } \ return EXR_UNLOCK_WRITE_AND_RETURN (EXR_ERR_NO_ATTR_BY_NAME) #define REQ_ATTR_GET_IMPL_DEREF(name, entry, t) \ - EXR_LOCK_WRITE_AND_DEFINE_PART (part_index); \ + EXR_LOCK_WRITE_AND_DEFINE_PART (part_index); \ if (!out) \ - return EXR_UNLOCK_WRITE_AND_RETURN (ctxt->print_error ( \ - ctxt, EXR_ERR_INVALID_ARGUMENT, "NULL output for '%s'", #name)); \ + return EXR_UNLOCK_WRITE_AND_RETURN (ctxt->print_error ( \ + ctxt, EXR_ERR_INVALID_ARGUMENT, "NULL output for '%s'", #name)); \ if (part->name) \ { \ if (part->name->type != t) \ - return EXR_UNLOCK_WRITE_AND_RETURN (ctxt->print_error ( \ - ctxt, \ + return EXR_UNLOCK_WRITE_AND_RETURN (ctxt->print_error ( \ + ctxt, \ EXR_ERR_FILE_BAD_HEADER, \ "Invalid required attribute type '%s' for '%s'", \ part->name->type_name, \ #name)); \ *out = *(part->name->entry); \ - return EXR_UNLOCK_WRITE_AND_RETURN (EXR_ERR_SUCCESS); \ + return EXR_UNLOCK_WRITE_AND_RETURN (EXR_ERR_SUCCESS); \ } \ return EXR_UNLOCK_WRITE_AND_RETURN (EXR_ERR_NO_ATTR_BY_NAME) #define REQ_ATTR_FIND_CREATE(name, t) \ exr_attribute_t* attr = NULL; \ exr_result_t rv = EXR_ERR_SUCCESS; \ - EXR_LOCK_AND_DEFINE_PART (part_index); \ - if (ctxt->mode == EXR_CONTEXT_READ) \ - return EXR_UNLOCK_AND_RETURN ( \ - ctxt->standard_error (ctxt, EXR_ERR_NOT_OPEN_WRITE)); \ - if (ctxt->mode == EXR_CONTEXT_WRITING_DATA) \ - return EXR_UNLOCK_AND_RETURN ( \ - ctxt->standard_error (ctxt, EXR_ERR_ALREADY_WROTE_ATTRS)); \ + EXR_LOCK_AND_DEFINE_PART (part_index); \ + if (ctxt->mode == EXR_CONTEXT_READ) \ + return EXR_UNLOCK_AND_RETURN ( \ + ctxt->standard_error (ctxt, EXR_ERR_NOT_OPEN_WRITE)); \ + if (ctxt->mode == EXR_CONTEXT_WRITING_DATA) \ + return EXR_UNLOCK_AND_RETURN ( \ + ctxt->standard_error (ctxt, EXR_ERR_ALREADY_WROTE_ATTRS)); \ if (!part->name) \ { \ rv = exr_attr_list_add ( \ ctxt, &(part->attributes), #name, t, 0, NULL, &(part->name)); \ } \ else if (part->name->type != t) \ - return EXR_UNLOCK_AND_RETURN (ctxt->print_error ( \ - ctxt, \ + return EXR_UNLOCK_AND_RETURN (ctxt->print_error ( \ + ctxt, \ EXR_ERR_FILE_BAD_HEADER, \ "Invalid required attribute type '%s' for '%s'", \ part->name->type_name, \ @@ -1083,10 +1080,10 @@ exr_set_chunk_count (exr_context_t ctxt, int part_index, int32_t val) #define ATTR_FIND_ATTR(t, entry) \ exr_attribute_t* attr; \ exr_result_t rv; \ - EXR_LOCK_WRITE_AND_DEFINE_PART (part_index); \ + EXR_LOCK_WRITE_AND_DEFINE_PART (part_index); \ if (!name || name[0] == '\0') \ - return EXR_UNLOCK_WRITE_AND_RETURN (ctxt->report_error ( \ - ctxt, \ + return EXR_UNLOCK_WRITE_AND_RETURN (ctxt->report_error ( \ + ctxt, \ EXR_ERR_INVALID_ARGUMENT, \ "Invalid name for " #entry " attribute query")); \ rv = exr_attr_list_find_by_name ( \ @@ -1094,10 +1091,10 @@ exr_set_chunk_count (exr_context_t ctxt, int part_index, int32_t val) EXR_CONST_CAST (exr_attribute_list_t*, &(part->attributes)), \ name, \ &attr); \ - if (rv != EXR_ERR_SUCCESS) return EXR_UNLOCK_WRITE_AND_RETURN (rv); \ + if (rv != EXR_ERR_SUCCESS) return EXR_UNLOCK_WRITE_AND_RETURN (rv); \ if (attr->type != t) \ - return EXR_UNLOCK_WRITE_AND_RETURN (ctxt->print_error ( \ - ctxt, \ + return EXR_UNLOCK_WRITE_AND_RETURN (ctxt->print_error ( \ + ctxt, \ EXR_ERR_ATTR_TYPE_MISMATCH, \ "'%s' requested type '" #entry \ "', but stored attributes is type '%s'", \ @@ -1107,35 +1104,35 @@ exr_set_chunk_count (exr_context_t ctxt, int part_index, int32_t val) #define ATTR_GET_IMPL(t, entry) \ ATTR_FIND_ATTR (t, entry); \ if (!out) \ - return EXR_UNLOCK_WRITE_AND_RETURN (ctxt->print_error ( \ - ctxt, EXR_ERR_INVALID_ARGUMENT, "NULL output for '%s'", name)); \ + return EXR_UNLOCK_WRITE_AND_RETURN (ctxt->print_error ( \ + ctxt, EXR_ERR_INVALID_ARGUMENT, "NULL output for '%s'", name)); \ *out = attr->entry; \ return EXR_UNLOCK_WRITE_AND_RETURN (rv) #define ATTR_GET_IMPL_DEREF(t, entry) \ ATTR_FIND_ATTR (t, entry); \ if (!out) \ - return EXR_UNLOCK_WRITE_AND_RETURN (ctxt->print_error ( \ - ctxt, EXR_ERR_INVALID_ARGUMENT, "NULL output for '%s'", name)); \ + return EXR_UNLOCK_WRITE_AND_RETURN (ctxt->print_error ( \ + ctxt, EXR_ERR_INVALID_ARGUMENT, "NULL output for '%s'", name)); \ *out = *(attr->entry); \ return EXR_UNLOCK_WRITE_AND_RETURN (rv) #define ATTR_FIND_CREATE(t, entry) \ exr_attribute_t* attr = NULL; \ exr_result_t rv = EXR_ERR_SUCCESS; \ - EXR_LOCK_AND_DEFINE_PART (part_index); \ - if (ctxt->mode == EXR_CONTEXT_READ) \ - return EXR_UNLOCK_AND_RETURN ( \ - ctxt->standard_error (ctxt, EXR_ERR_NOT_OPEN_WRITE)); \ - if (ctxt->mode == EXR_CONTEXT_WRITING_DATA) \ - return EXR_UNLOCK_AND_RETURN ( \ - ctxt->standard_error (ctxt, EXR_ERR_ALREADY_WROTE_ATTRS)); \ + EXR_LOCK_AND_DEFINE_PART (part_index); \ + if (ctxt->mode == EXR_CONTEXT_READ) \ + return EXR_UNLOCK_AND_RETURN ( \ + ctxt->standard_error (ctxt, EXR_ERR_NOT_OPEN_WRITE)); \ + if (ctxt->mode == EXR_CONTEXT_WRITING_DATA) \ + return EXR_UNLOCK_AND_RETURN ( \ + ctxt->standard_error (ctxt, EXR_ERR_ALREADY_WROTE_ATTRS)); \ rv = exr_attr_list_find_by_name ( \ ctxt, (exr_attribute_list_t*) &(part->attributes), name, &attr); \ if (rv == EXR_ERR_NO_ATTR_BY_NAME) \ { \ - if (ctxt->mode != EXR_CONTEXT_WRITE) \ - return EXR_UNLOCK_AND_RETURN (rv); \ + if (ctxt->mode != EXR_CONTEXT_WRITE) \ + return EXR_UNLOCK_AND_RETURN (rv); \ \ rv = exr_attr_list_add ( \ ctxt, &(part->attributes), name, t, 0, NULL, &(attr)); \ @@ -1143,8 +1140,8 @@ exr_set_chunk_count (exr_context_t ctxt, int part_index, int32_t val) else if (rv == EXR_ERR_SUCCESS) \ { \ if (attr->type != t) \ - return EXR_UNLOCK_AND_RETURN (ctxt->print_error ( \ - ctxt, \ + return EXR_UNLOCK_AND_RETURN (ctxt->print_error ( \ + ctxt, \ EXR_ERR_ATTR_TYPE_MISMATCH, \ "'%s' requested type '" #entry \ "', but stored attributes is type '%s'", \ @@ -1162,8 +1159,8 @@ exr_set_chunk_count (exr_context_t ctxt, int part_index, int32_t val) #define ATTR_SET_IMPL_DEREF(t, entry) \ ATTR_FIND_CREATE (t, entry); \ if (!val) \ - return EXR_UNLOCK_AND_RETURN (ctxt->print_error ( \ - ctxt, \ + return EXR_UNLOCK_AND_RETURN (ctxt->print_error ( \ + ctxt, \ EXR_ERR_INVALID_ARGUMENT, \ "No input value for setting '%s', type '%s'", \ name, \ @@ -1498,8 +1495,7 @@ exr_attr_set_float_vector ( if (rv == EXR_ERR_NO_ATTR_BY_NAME) { - if (ctxt->mode != EXR_CONTEXT_WRITE) - return EXR_UNLOCK_AND_RETURN (rv); + if (ctxt->mode != EXR_CONTEXT_WRITE) return EXR_UNLOCK_AND_RETURN (rv); rv = exr_attr_list_add ( ctxt, @@ -1758,8 +1754,7 @@ exr_attr_set_preview ( if (rv == EXR_ERR_NO_ATTR_BY_NAME) { - if (ctxt->mode != EXR_CONTEXT_WRITE) - return EXR_UNLOCK_AND_RETURN (rv); + if (ctxt->mode != EXR_CONTEXT_WRITE) return EXR_UNLOCK_AND_RETURN (rv); rv = exr_attr_list_add ( ctxt, @@ -1864,8 +1859,7 @@ exr_attr_set_string ( EXR_LOCK_AND_DEFINE_PART (part_index); if (name && !strcmp (name, EXR_REQ_NAME_STR)) - return EXR_UNLOCK_AND_RETURN ( - exr_set_name (ctxt, part_index, name)); + return EXR_UNLOCK_AND_RETURN (exr_set_name (ctxt, part_index, name)); if (name && !strcmp (name, EXR_REQ_TYPE_STR)) return EXR_UNLOCK_AND_RETURN (ctxt->print_error ( @@ -1895,8 +1889,7 @@ exr_attr_set_string ( if (rv == EXR_ERR_NO_ATTR_BY_NAME) { - if (ctxt->mode != EXR_CONTEXT_WRITE) - return EXR_UNLOCK_AND_RETURN (rv); + if (ctxt->mode != EXR_CONTEXT_WRITE) return EXR_UNLOCK_AND_RETURN (rv); rv = exr_attr_list_add ( ctxt, &(part->attributes), name, EXR_ATTR_STRING, 0, NULL, &(attr)); @@ -2009,8 +2002,7 @@ exr_attr_set_string_vector ( if (rv == EXR_ERR_NO_ATTR_BY_NAME) { - if (ctxt->mode != EXR_CONTEXT_WRITE) - return EXR_UNLOCK_AND_RETURN (rv); + if (ctxt->mode != EXR_CONTEXT_WRITE) return EXR_UNLOCK_AND_RETURN (rv); rv = exr_attr_list_add ( ctxt, @@ -2343,8 +2335,7 @@ exr_attr_set_user ( ctxt, (exr_attribute_list_t*) &(part->attributes), name, &attr); if (rv == EXR_ERR_NO_ATTR_BY_NAME) { - if (ctxt->mode != EXR_CONTEXT_WRITE) - return EXR_UNLOCK_AND_RETURN (rv); + if (ctxt->mode != EXR_CONTEXT_WRITE) return EXR_UNLOCK_AND_RETURN (rv); rv = exr_attr_list_add_by_type ( ctxt, &(part->attributes), name, type, 0, NULL, &(attr)); } diff --git a/src/lib/OpenEXRCore/unpack.c b/src/lib/OpenEXRCore/unpack.c index 1324508c5b..f5abc9954c 100644 --- a/src/lib/OpenEXRCore/unpack.c +++ b/src/lib/OpenEXRCore/unpack.c @@ -886,7 +886,7 @@ unpack_16bit (exr_decode_pipeline_t* decode) #else if (pixincrement == 2) { - memcpy (cdata, srcbuffer, (size_t) (w) *2); + memcpy (cdata, srcbuffer, (size_t) (w) * 2); } else { @@ -951,7 +951,7 @@ unpack_32bit (exr_decode_pipeline_t* decode) #else if (pixincrement == 4) { - memcpy (cdata, srcbuffer, (size_t) (w) *4); + memcpy (cdata, srcbuffer, (size_t) (w) * 4); } else { diff --git a/src/lib/OpenEXRCore/validation.c b/src/lib/OpenEXRCore/validation.c index 1c4a624d75..01fa0b33cf 100644 --- a/src/lib/OpenEXRCore/validation.c +++ b/src/lib/OpenEXRCore/validation.c @@ -12,7 +12,7 @@ /**************************************/ static exr_result_t -validate_req_attr (exr_context_t f,exr_priv_part_t curpart, int adddefault) +validate_req_attr (exr_context_t f, exr_priv_part_t curpart, int adddefault) { exr_result_t rv = EXR_ERR_SUCCESS; if (!curpart->channels) @@ -317,9 +317,7 @@ validate_image_dimensions (exr_context_t f, exr_priv_part_t curpart) static exr_result_t validate_channels ( - exr_context_t f, - exr_priv_part_t curpart, - const exr_attr_chlist_t* channels) + exr_context_t f, exr_priv_part_t curpart, const exr_attr_chlist_t* channels) { exr_attr_box2i_t dw; int64_t w, h; diff --git a/src/lib/OpenEXRCore/write_header.c b/src/lib/OpenEXRCore/write_header.c index a4eadbf5fc..f53aef35ad 100644 --- a/src/lib/OpenEXRCore/write_header.c +++ b/src/lib/OpenEXRCore/write_header.c @@ -204,8 +204,7 @@ save_chlist (exr_context_t ctxt, const exr_attribute_t* a) /**************************************/ static exr_result_t -save_chromaticities ( - exr_context_t ctxt, const exr_attribute_t* a) +save_chromaticities (exr_context_t ctxt, const exr_attribute_t* a) { exr_result_t rv; exr_attr_chromaticities_t tmp = *(a->chromaticities); @@ -377,8 +376,7 @@ save_string (exr_context_t ctxt, const exr_attribute_t* a) /**************************************/ static exr_result_t -save_string_vector ( - exr_context_t ctxt, const exr_attribute_t* a) +save_string_vector (exr_context_t ctxt, const exr_attribute_t* a) { exr_result_t rv; size_t attrsz = 0; diff --git a/src/lib/OpenEXRUtil/ImfCheckFile.cpp b/src/lib/OpenEXRUtil/ImfCheckFile.cpp index b9de50268d..16090b73cf 100644 --- a/src/lib/OpenEXRUtil/ImfCheckFile.cpp +++ b/src/lib/OpenEXRUtil/ImfCheckFile.cpp @@ -74,10 +74,7 @@ getStep (const Box2i& dw, bool reduceTime) static_cast (pixelCount / gTargetPixelsToRead), static_cast (rowCount / gMaxScanlinesToRead))); } - else - { - return 1; - } + else { return 1; } } // // read image or part using the Rgba interface @@ -185,13 +182,43 @@ readScanline (T& in, bool reduceMemory, bool reduceTime) switch (channelIndex % 3) { case 0: - i.insert(c.name(),Slice(HALF, (char*) (halfData - sizeof(half)*(dx/c.channel().xSampling)) , sizeof(half) , 0 , c.channel().xSampling , c.channel().ySampling )); + i.insert ( + c.name (), + Slice ( + HALF, + (char*) (halfData - + sizeof (half) * + (dx / c.channel ().xSampling)), + sizeof (half), + 0, + c.channel ().xSampling, + c.channel ().ySampling)); break; case 1: - i.insert(c.name(),Slice(FLOAT, (char*) (floatData - sizeof(float)*(dx/c.channel().xSampling)) , sizeof(float) , 0 , c.channel().xSampling , c.channel().ySampling )); + i.insert ( + c.name (), + Slice ( + FLOAT, + (char*) (floatData - + sizeof (float) * + (dx / c.channel ().xSampling)), + sizeof (float), + 0, + c.channel ().xSampling, + c.channel ().ySampling)); break; case 2: - i.insert(c.name(),Slice(UINT, (char*) (uintData - sizeof(unsigned int)*(dx/c.channel().xSampling)) , sizeof(unsigned int) , 0 , c.channel().xSampling , c.channel().ySampling )); + i.insert ( + c.name (), + Slice ( + UINT, + (char*) (uintData - + sizeof (unsigned int) * + (dx / c.channel ().xSampling)), + sizeof (unsigned int), + 0, + c.channel ().xSampling, + c.channel ().ySampling)); break; } channelIndex++; @@ -477,7 +504,7 @@ readDeepScanLine (T& in, bool reduceMemory, bool reduceTime) // - bufferSize is how much memory this function will allocate // - fileBufferSize tracks how much decompressed data the library will require // - size_t bufferSize = 0; + size_t bufferSize = 0; size_t fileBufferSize = 0; for (uint64_t j = 0; j < w; j++) { @@ -499,7 +526,8 @@ readDeepScanLine (T& in, bool reduceMemory, bool reduceTime) // // limit total number of samples read in reduceMemory mode // - if (!reduceMemory || fileBufferSize + bufferSize < gMaxBytesPerDeepScanline) + if (!reduceMemory || + fileBufferSize + bufferSize < gMaxBytesPerDeepScanline) { // // allocate sample buffer and set per-pixel pointers into buffer @@ -563,7 +591,7 @@ readDeepTile (T& in, bool reduceMemory, bool reduceTime) Array2D localSampleCount; - int bytesPerSample = calculateBytesPerPixel (in.header ()); + int bytesPerSample = calculateBytesPerPixel (in.header ()); const TileDescription& td = in.header ().tileDescription (); int tileWidth = td.xSize; @@ -657,15 +685,16 @@ readDeepTile (T& in, bool reduceMemory, bool reduceTime) in.readPixelSampleCounts ( x, y, x, y, xlevel, ylevel); - size_t bufferSize = 0; + size_t bufferSize = 0; size_t fileBufferSize = 0; for (int ty = 0; ty < tileHeight; ++ty) { for (int tx = 0; tx < tileWidth; ++tx) { - fileBufferSize += channelCount * - localSampleCount[ty][tx]; + fileBufferSize += + channelCount * + localSampleCount[ty][tx]; if (!reduceMemory || localSampleCount[ty][tx] * @@ -682,7 +711,8 @@ readDeepTile (T& in, bool reduceMemory, bool reduceTime) // skip reading if no data to read, or limiting memory and tile is too large if (bufferSize > 0 && (!reduceMemory || - (fileBufferSize + bufferSize) * bytesPerSample < + (fileBufferSize + bufferSize) * + bytesPerSample < gMaxBytesPerDeepPixel)) { @@ -1028,25 +1058,22 @@ runChecks (T& source, bool reduceMemory, bool reduceTime) // in reduceMemory/reduceTime mode, limit image size, tile size, and maximum deep samples // - uint64_t oldMaxSampleCount = CompositeDeepScanLine::getMaximumSampleCount(); - - int maxImageWidth , maxImageHeight; - Header::getMaxImageSize(maxImageWidth,maxImageHeight); + uint64_t oldMaxSampleCount = + CompositeDeepScanLine::getMaximumSampleCount (); - int maxTileWidth , maxTileHeight; - Header::getMaxImageSize(maxTileWidth,maxTileHeight); + int maxImageWidth, maxImageHeight; + Header::getMaxImageSize (maxImageWidth, maxImageHeight); + int maxTileWidth, maxTileHeight; + Header::getMaxImageSize (maxTileWidth, maxTileHeight); - if( reduceMemory || reduceTime) + if (reduceMemory || reduceTime) { - CompositeDeepScanLine::setMaximumSampleCount(1<<20); - Header::setMaxImageSize(2048,2048); - Header::setMaxTileSize(512,512); + CompositeDeepScanLine::setMaximumSampleCount (1 << 20); + Header::setMaxImageSize (2048, 2048); + Header::setMaxTileSize (512, 512); } - - - // // multipart test: also grab the type of the first part to // check which other tests are expected to fail @@ -1065,7 +1092,7 @@ runChecks (T& source, bool reduceMemory, bool reduceTime) // If the MultiPartInputFile constructor throws an exception, the first part // will assumed to be a wide image // - bool largeTiles = true; + bool largeTiles = true; bool threw = false; { @@ -1191,11 +1218,9 @@ runChecks (T& source, bool reduceMemory, bool reduceTime) if (gotThrow && firstPartType == DEEPTILE) { threw = true; } } - - - CompositeDeepScanLine::setMaximumSampleCount(oldMaxSampleCount); - Header::setMaxImageSize(maxImageWidth,maxImageHeight); - Header::setMaxTileSize(maxTileWidth,maxTileHeight); + CompositeDeepScanLine::setMaximumSampleCount (oldMaxSampleCount); + Header::setMaxImageSize (maxImageWidth, maxImageHeight); + Header::setMaxTileSize (maxTileWidth, maxTileHeight); return threw; } @@ -1204,16 +1229,16 @@ runChecks (T& source, bool reduceMemory, bool reduceTime) // total unpacked_size field which can be used for allocation // but this adds an additional point to use when debugging issues. static exr_result_t -realloc_deepdata(exr_decode_pipeline_t* decode) +realloc_deepdata (exr_decode_pipeline_t* decode) { - int32_t w = decode->chunk.width; - int32_t h = decode->chunk.height; - uint64_t totsamps = 0, bytes = 0; - const int32_t *sampbuffer = decode->sample_count_table; - std::vector* ud = static_cast*>( - decode->decoding_user_data); - - if ( ! ud ) + int32_t w = decode->chunk.width; + int32_t h = decode->chunk.height; + uint64_t totsamps = 0, bytes = 0; + const int32_t* sampbuffer = decode->sample_count_table; + std::vector* ud = + static_cast*> (decode->decoding_user_data); + + if (!ud) { for (int c = 0; c < decode->channel_count; c++) { @@ -1225,8 +1250,7 @@ realloc_deepdata(exr_decode_pipeline_t* decode) return EXR_ERR_SUCCESS; } - if ((decode->decode_flags & - EXR_DECODE_SAMPLE_COUNTS_AS_INDIVIDUAL)) + if ((decode->decode_flags & EXR_DECODE_SAMPLE_COUNTS_AS_INDIVIDUAL)) { for (int32_t y = 0; y < h; ++y) { @@ -1238,7 +1262,7 @@ realloc_deepdata(exr_decode_pipeline_t* decode) else { for (int32_t y = 0; y < h; ++y) - totsamps += sampbuffer[y*w + w - 1]; + totsamps += sampbuffer[y * w + w - 1]; } for (int c = 0; c < decode->channel_count; c++) @@ -1262,8 +1286,7 @@ realloc_deepdata(exr_decode_pipeline_t* decode) if (ud->size () < bytes) { ud->resize (bytes); - if (ud->capacity() < bytes) - return EXR_ERR_OUT_OF_MEMORY; + if (ud->capacity () < bytes) return EXR_ERR_OUT_OF_MEMORY; } uint8_t* dptr = &((*ud)[0]); @@ -1296,7 +1319,7 @@ readCoreScanlinePart ( (uint64_t) ((int64_t) datawin.max.y - (int64_t) datawin.min.y + 1); std::vector imgdata; - bool doread = false; + bool doread = false; exr_decode_pipeline_t decoder = EXR_DECODE_PIPELINE_INITIALIZER; int32_t lines_per_chunk; @@ -1336,8 +1359,7 @@ readCoreScanlinePart ( } doread = true; - if (reduceMemory && bytes >= gMaxBytesPerScanline) - doread = false; + if (reduceMemory && bytes >= gMaxBytesPerScanline) doread = false; if (cinfo.type == EXR_STORAGE_DEEP_SCANLINE) { @@ -1375,11 +1397,11 @@ readCoreScanlinePart ( { exr_coding_channel_info_t& outc = decoder.channels[c]; outc.decode_to_ptr = dptr; - outc.user_pixel_stride = outc.user_bytes_per_element; - outc.user_line_stride = outc.user_pixel_stride * width; + outc.user_pixel_stride = outc.user_bytes_per_element; + outc.user_line_stride = outc.user_pixel_stride * width; dptr += width * (uint64_t) outc.user_bytes_per_element * - (uint64_t) lines_per_chunk; + (uint64_t) lines_per_chunk; } } @@ -1421,7 +1443,7 @@ readCoreTiledPart ( rv = exr_get_tile_levels (f, part, &levelsx, &levelsy); if (rv != EXR_ERR_SUCCESS) return true; - frv = rv; + frv = rv; bool keepgoing = true; for (int32_t ylevel = 0; keepgoing && ylevel < levelsy; ++ylevel) { @@ -1489,7 +1511,7 @@ readCoreTiledPart ( exr_decoding_initialize (f, part, &cinfo, &decoder); if (rv != EXR_ERR_SUCCESS) { - frv = rv; + frv = rv; keepgoing = false; break; } @@ -1516,8 +1538,9 @@ readCoreTiledPart ( if (cinfo.type == EXR_STORAGE_DEEP_TILED) { - decoder.decoding_user_data = &tiledata; - decoder.realloc_nonimage_data_fn = &realloc_deepdata; + decoder.decoding_user_data = &tiledata; + decoder.realloc_nonimage_data_fn = + &realloc_deepdata; } else { @@ -1527,7 +1550,7 @@ readCoreTiledPart ( f, part, &decoder); if (rv != EXR_ERR_SUCCESS) { - frv = rv; + frv = rv; keepgoing = false; break; } @@ -1562,8 +1585,8 @@ readCoreTiledPart ( outc.user_line_stride = outc.user_pixel_stride * curtw; dptr += (uint64_t) curtw * - (uint64_t) outc.user_bytes_per_element * - (uint64_t) curth; + (uint64_t) outc.user_bytes_per_element * + (uint64_t) curth; } } @@ -1605,14 +1628,12 @@ checkCoreFile (exr_context_t f, bool reduceMemory, bool reduceTime) rv = exr_get_storage (f, p, &store); if (rv != EXR_ERR_SUCCESS) return true; - if (store == EXR_STORAGE_SCANLINE || - store == EXR_STORAGE_DEEP_SCANLINE) + if (store == EXR_STORAGE_SCANLINE || store == EXR_STORAGE_DEEP_SCANLINE) { if (readCoreScanlinePart (f, p, reduceMemory, reduceTime)) return true; } - else if (store == EXR_STORAGE_TILED || - store == EXR_STORAGE_DEEP_TILED) + else if (store == EXR_STORAGE_TILED || store == EXR_STORAGE_DEEP_TILED) { if (readCoreTiledPart (f, p, reduceMemory, reduceTime)) return true; } @@ -1659,10 +1680,10 @@ runCoreChecks (const char* filename, bool reduceMemory, bool reduceTime) * exr_set_default_maximum_image_size (2048, 2048); * exr_set_default_maximum_tile_size (512, 512); */ - cinit.max_image_width = 2048; + cinit.max_image_width = 2048; cinit.max_image_height = 2048; - cinit.max_tile_width = 512; - cinit.max_tile_height = 512; + cinit.max_tile_width = 512; + cinit.max_tile_height = 512; } rv = exr_start_read (&f, filename, &cinit); @@ -1697,7 +1718,7 @@ memstream_read ( { memdata* md = static_cast (userdata); uint64_t left = sz; - if (offset > md->bytes || sz > md->bytes || offset+sz > md->bytes) + if (offset > md->bytes || sz > md->bytes || offset + sz > md->bytes) left = (offset < md->bytes) ? md->bytes - offset : 0; if (left > 0) memcpy (buffer, md->data + offset, left); rdsz = static_cast (left); @@ -1742,10 +1763,10 @@ runCoreChecks ( * exr_set_default_maximum_image_size (2048, 2048); * exr_set_default_maximum_tile_size (512, 512); */ - cinit.max_image_width = 2048; + cinit.max_image_width = 2048; cinit.max_image_height = 2048; - cinit.max_tile_width = 512; - cinit.max_tile_height = 512; + cinit.max_tile_width = 512; + cinit.max_tile_height = 512; } rv = exr_start_read (&f, "", &cinit); @@ -1762,21 +1783,14 @@ runCoreChecks ( bool checkOpenEXRFile ( - const char* fileName, - bool reduceMemory, - bool reduceTime, - bool runCoreCheck) + const char* fileName, bool reduceMemory, bool reduceTime, bool runCoreCheck) { if (runCoreCheck) { return runCoreChecks (fileName, reduceMemory, reduceTime); } - else - { - return runChecks (fileName, reduceMemory, reduceTime); - } - + else { return runChecks (fileName, reduceMemory, reduceTime); } } bool @@ -1788,18 +1802,15 @@ checkOpenEXRFile ( bool runCoreCheck) { - - if (runCoreCheck) - { + if (runCoreCheck) + { return runCoreChecks (data, numBytes, reduceMemory, reduceTime); - } - else - { + } + else + { PtrIStream stream (data, numBytes); return runChecks (stream, reduceMemory, reduceTime); } - - } OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT diff --git a/src/lib/OpenEXRUtil/ImfCheckFile.h b/src/lib/OpenEXRUtil/ImfCheckFile.h index 7ed6dfe170..57afa299a3 100644 --- a/src/lib/OpenEXRUtil/ImfCheckFile.h +++ b/src/lib/OpenEXRUtil/ImfCheckFile.h @@ -30,8 +30,8 @@ OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER IMFUTIL_EXPORT bool checkOpenEXRFile ( const char* fileName, - bool reduceMemory = false, - bool reduceTime = false, + bool reduceMemory = false, + bool reduceTime = false, bool runCoreCheck = false); // @@ -41,8 +41,8 @@ IMFUTIL_EXPORT bool checkOpenEXRFile ( IMFUTIL_EXPORT bool checkOpenEXRFile ( const char* data, size_t numBytes, - bool reduceMemory = false, - bool reduceTime = false, + bool reduceMemory = false, + bool reduceTime = false, bool runCoreCheck = false); OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT diff --git a/src/lib/OpenEXRUtil/ImfDeepImageChannel.h b/src/lib/OpenEXRUtil/ImfDeepImageChannel.h index 85ba44bf5e..9096cfebc2 100644 --- a/src/lib/OpenEXRUtil/ImfDeepImageChannel.h +++ b/src/lib/OpenEXRUtil/ImfDeepImageChannel.h @@ -72,10 +72,10 @@ class IMFUTIL_EXPORT_TYPE DeepImageChannel : public ImageChannel IMFUTIL_EXPORT DeepImageChannel (DeepImageLevel& level, bool pLinear); IMFUTIL_EXPORT virtual ~DeepImageChannel (); - DeepImageChannel (const DeepImageChannel& other) = delete; + DeepImageChannel (const DeepImageChannel& other) = delete; DeepImageChannel& operator= (const DeepImageChannel& other) = delete; DeepImageChannel (DeepImageChannel&& other) = delete; - DeepImageChannel& operator= (DeepImageChannel&& other) = delete; + DeepImageChannel& operator= (DeepImageChannel&& other) = delete; virtual void setSamplesToZero ( size_t i, unsigned int oldNumSamples, unsigned int newNumSamples) = 0; @@ -161,8 +161,8 @@ class IMFUTIL_EXPORT_TEMPLATE_TYPE TypedDeepImageChannel TypedDeepImageChannel (const TypedDeepImageChannel& other) = delete; TypedDeepImageChannel& - operator= (const TypedDeepImageChannel& other) = delete; - TypedDeepImageChannel (TypedDeepImageChannel&& other) = delete; + operator= (const TypedDeepImageChannel& other) = delete; + TypedDeepImageChannel (TypedDeepImageChannel&& other) = delete; TypedDeepImageChannel& operator= (TypedDeepImageChannel&& other) = delete; IMFUTIL_HIDDEN diff --git a/src/lib/OpenEXRUtil/ImfFlatImageChannel.h b/src/lib/OpenEXRUtil/ImfFlatImageChannel.h index cf522abd25..ac22f653ef 100644 --- a/src/lib/OpenEXRUtil/ImfFlatImageChannel.h +++ b/src/lib/OpenEXRUtil/ImfFlatImageChannel.h @@ -65,10 +65,10 @@ class IMFUTIL_EXPORT_TYPE FlatImageChannel : public ImageChannel IMFUTIL_EXPORT virtual ~FlatImageChannel (); - FlatImageChannel (const FlatImageChannel& other) = delete; + FlatImageChannel (const FlatImageChannel& other) = delete; FlatImageChannel& operator= (const FlatImageChannel& other) = delete; FlatImageChannel (FlatImageChannel&& other) = delete; - FlatImageChannel& operator= (FlatImageChannel&& other) = delete; + FlatImageChannel& operator= (FlatImageChannel&& other) = delete; IMFUTIL_EXPORT virtual void resize (); @@ -139,8 +139,8 @@ class IMFUTIL_EXPORT_TEMPLATE_TYPE TypedFlatImageChannel TypedFlatImageChannel (const TypedFlatImageChannel& other) = delete; TypedFlatImageChannel& - operator= (const TypedFlatImageChannel& other) = delete; - TypedFlatImageChannel (TypedFlatImageChannel&& other) = delete; + operator= (const TypedFlatImageChannel& other) = delete; + TypedFlatImageChannel (TypedFlatImageChannel&& other) = delete; TypedFlatImageChannel& operator= (TypedFlatImageChannel&& other) = delete; IMFUTIL_HIDDEN diff --git a/src/lib/OpenEXRUtil/ImfImage.cpp b/src/lib/OpenEXRUtil/ImfImage.cpp index 30cbfa26bf..238c24815c 100644 --- a/src/lib/OpenEXRUtil/ImfImage.cpp +++ b/src/lib/OpenEXRUtil/ImfImage.cpp @@ -528,10 +528,7 @@ Image::renameChannels (const RenamingMap& oldToNewNames) "channel would be named \"" << newName << "\"."); } - else - { - newNames.insert (newName); - } + else { newNames.insert (newName); } } try diff --git a/src/lib/OpenEXRUtil/ImfImageChannel.h b/src/lib/OpenEXRUtil/ImfImageChannel.h index 8feb86295d..ef7e147b43 100644 --- a/src/lib/OpenEXRUtil/ImfImageChannel.h +++ b/src/lib/OpenEXRUtil/ImfImageChannel.h @@ -91,10 +91,10 @@ class IMFUTIL_EXPORT_TYPE ImageChannel void boundsCheck (int x, int y) const; private: - ImageChannel (const ImageChannel&) = delete; + ImageChannel (const ImageChannel&) = delete; ImageChannel& operator= (const ImageChannel&) = delete; ImageChannel (ImageChannel&&) = delete; - ImageChannel& operator= (ImageChannel&&) = delete; + ImageChannel& operator= (ImageChannel&&) = delete; ImageLevel& _level; int _xSampling; diff --git a/src/lib/OpenEXRUtil/ImfSampleCountChannel.h b/src/lib/OpenEXRUtil/ImfSampleCountChannel.h index 3b85a3b29e..d070b3e808 100644 --- a/src/lib/OpenEXRUtil/ImfSampleCountChannel.h +++ b/src/lib/OpenEXRUtil/ImfSampleCountChannel.h @@ -187,10 +187,10 @@ class IMFUTIL_EXPORT_TYPE SampleCountChannel : public ImageChannel IMFUTIL_EXPORT ~Edit (); - Edit (const Edit& other) = delete; + Edit (const Edit& other) = delete; Edit& operator= (const Edit& other) = delete; Edit (Edit&& other) = delete; - Edit& operator= (Edit&& other) = delete; + Edit& operator= (Edit&& other) = delete; // // Access to the writable sample count array. diff --git a/src/lib/OpenEXRUtil/ImfUtilExport.h b/src/lib/OpenEXRUtil/ImfUtilExport.h index 403e2e0140..94e639e665 100644 --- a/src/lib/OpenEXRUtil/ImfUtilExport.h +++ b/src/lib/OpenEXRUtil/ImfUtilExport.h @@ -15,7 +15,7 @@ #if defined(OPENEXR_DLL) # if defined(OPENEXRUTIL_EXPORTS) -# define IMFUTIL_EXPORT __declspec(dllexport) +# define IMFUTIL_EXPORT __declspec (dllexport) // mingw needs the export when the extern is defined # if defined(__MINGW32__) @@ -34,7 +34,7 @@ # endif # else // OPENEXRUTIL_EXPORTS -# define IMFUTIL_EXPORT __declspec(dllimport) +# define IMFUTIL_EXPORT __declspec (dllimport) # define IMFUTIL_EXPORT_EXTERN_TEMPLATE IMFUTIL_EXPORT # define IMFUTIL_EXPORT_TEMPLATE_INSTANCE # define IMFUTIL_EXPORT_TEMPLATE_TYPE diff --git a/src/test/IexTest/mathFuncs.cpp b/src/test/IexTest/mathFuncs.cpp index 2777584ced..82762525ab 100644 --- a/src/test/IexTest/mathFuncs.cpp +++ b/src/test/IexTest/mathFuncs.cpp @@ -25,7 +25,7 @@ grow (float x, int y) std::cout << "grow (" << x << ", " << y << ")" << std::endl; for (int i = 0; i < y; i++) - x = x * x; + x = x * x; return x; } diff --git a/src/test/IexTest/mathFuncs.h b/src/test/IexTest/mathFuncs.h index 032c7df91a..6658ec18c6 100644 --- a/src/test/IexTest/mathFuncs.h +++ b/src/test/IexTest/mathFuncs.h @@ -4,4 +4,3 @@ float divide (float x, float y); float root (float x); float grow (float x, int y); - diff --git a/src/test/IexTest/testBaseExc.cpp b/src/test/IexTest/testBaseExc.cpp index cf8c2e1a9d..5367ae8280 100644 --- a/src/test/IexTest/testBaseExc.cpp +++ b/src/test/IexTest/testBaseExc.cpp @@ -194,7 +194,7 @@ test6 () // T e0; - + T e1 ("arg"); e1 += "X"; @@ -202,7 +202,7 @@ test6 () ss << "Y"; e1 += ss; - T e2 (e1); + T e2 (e1); assert (e1.message () == "argXY"); assert (e1.stackTrace () == getStackTrace ()); @@ -219,24 +219,24 @@ test6 () assert (e3.message () == ss.str ()); std::string str4 ("e4"); - T e4(str4); - assert (e4.message() == str4); + T e4 (str4); + assert (e4.message () == str4); const std::string str5 ("e5"); - T e5(str5); - assert (e5.message() == str5); - + T e5 (str5); + assert (e5.message () == str5); + { - const T e6("e6"); - T e7(e6); - assert (e7.message() == e6.message()); + const T e6 ("e6"); + T e7 (e6); + assert (e7.message () == e6.message ()); } { e5 = e4; - assert (e5.message() == e4.message()); + assert (e5.message () == e4.message ()); } - + // // Confirm the throw/catch // @@ -262,13 +262,13 @@ test6 () template void -testThrowErrnoExc(int err) +testThrowErrnoExc (int err) { bool caught = false; - + try { - IEX_INTERNAL_NAMESPACE::throwErrnoExc("err", err); + IEX_INTERNAL_NAMESPACE::throwErrnoExc ("err", err); } catch (const T& e) { @@ -276,489 +276,491 @@ testThrowErrnoExc(int err) } catch (const std::exception& e) { - std::cerr << "testThrowErrnoExc: caught " << typeid(e).name() - << ", expected " << typeid(T).name() - << std::endl; + std::cerr << "testThrowErrnoExc: caught " << typeid (e).name () + << ", expected " << typeid (T).name () << std::endl; } - + assert (caught); } - + void -test7() +test7 () { #if defined(EPERM) - testThrowErrnoExc(EPERM); + testThrowErrnoExc (EPERM); #endif #if defined(ENOENT) - testThrowErrnoExc(ENOENT); + testThrowErrnoExc (ENOENT); #endif #if defined(ESRCH) - testThrowErrnoExc(ESRCH); + testThrowErrnoExc (ESRCH); #endif #if defined(EINTR) - testThrowErrnoExc(EINTR); + testThrowErrnoExc (EINTR); #endif #if defined(EIO) - testThrowErrnoExc(EIO); + testThrowErrnoExc (EIO); #endif #if defined(ENXIO) - testThrowErrnoExc(ENXIO); + testThrowErrnoExc (ENXIO); #endif #if defined(E2BIG) - testThrowErrnoExc(E2BIG); + testThrowErrnoExc (E2BIG); #endif #if defined(ENOEXEC) - testThrowErrnoExc(ENOEXEC); + testThrowErrnoExc (ENOEXEC); #endif #if defined(EBADF) - testThrowErrnoExc(EBADF); + testThrowErrnoExc (EBADF); #endif #if defined(ECHILD) - testThrowErrnoExc(ECHILD); + testThrowErrnoExc (ECHILD); #endif #if defined(EAGAIN) - testThrowErrnoExc(EAGAIN); + testThrowErrnoExc (EAGAIN); #endif #if defined(ENOMEM) - testThrowErrnoExc(ENOMEM); + testThrowErrnoExc (ENOMEM); #endif #if defined(EACCES) - testThrowErrnoExc(EACCES); + testThrowErrnoExc (EACCES); #endif #if defined(EFAULT) - testThrowErrnoExc(EFAULT); + testThrowErrnoExc (EFAULT); #endif #if defined(ENOTBLK) - testThrowErrnoExc(ENOTBLK); + testThrowErrnoExc (ENOTBLK); #endif #if defined(EBUSY) - testThrowErrnoExc(EBUSY); + testThrowErrnoExc (EBUSY); #endif #if defined(EEXIST) - testThrowErrnoExc(EEXIST); + testThrowErrnoExc (EEXIST); #endif #if defined(EXDEV) - testThrowErrnoExc(EXDEV); + testThrowErrnoExc (EXDEV); #endif #if defined(ENODEV) - testThrowErrnoExc(ENODEV); + testThrowErrnoExc (ENODEV); #endif #if defined(ENOTDIR) - testThrowErrnoExc(ENOTDIR); + testThrowErrnoExc (ENOTDIR); #endif #if defined(EISDIR) - testThrowErrnoExc(EISDIR); + testThrowErrnoExc (EISDIR); #endif #if defined(EINVAL) - testThrowErrnoExc(EINVAL); + testThrowErrnoExc (EINVAL); #endif #if defined(ENFILE) - testThrowErrnoExc(ENFILE); + testThrowErrnoExc (ENFILE); #endif #if defined(EMFILE) - testThrowErrnoExc(EMFILE); + testThrowErrnoExc (EMFILE); #endif #if defined(ENOTTY) - testThrowErrnoExc(ENOTTY); + testThrowErrnoExc (ENOTTY); #endif #if defined(ETXTBSY) - testThrowErrnoExc(ETXTBSY); + testThrowErrnoExc (ETXTBSY); #endif #if defined(EFBIG) - testThrowErrnoExc(EFBIG); + testThrowErrnoExc (EFBIG); #endif #if defined(ENOSPC) - testThrowErrnoExc(ENOSPC); + testThrowErrnoExc (ENOSPC); #endif #if defined(ESPIPE) - testThrowErrnoExc(ESPIPE); + testThrowErrnoExc (ESPIPE); #endif #if defined(EROFS) - testThrowErrnoExc(EROFS); + testThrowErrnoExc (EROFS); #endif #if defined(EMLINK) - testThrowErrnoExc(EMLINK); + testThrowErrnoExc (EMLINK); #endif #if defined(EPIPE) - testThrowErrnoExc(EPIPE); + testThrowErrnoExc (EPIPE); #endif #if defined(EDOM) - testThrowErrnoExc(EDOM); + testThrowErrnoExc (EDOM); #endif #if defined(ERANGE) - testThrowErrnoExc(ERANGE); + testThrowErrnoExc (ERANGE); #endif #if defined(ENOMSG) - testThrowErrnoExc(ENOMSG); + testThrowErrnoExc (ENOMSG); #endif #if defined(EIDRM) - testThrowErrnoExc(EIDRM); + testThrowErrnoExc (EIDRM); #endif #if defined(ECHRNG) - testThrowErrnoExc(ECHRNG); + testThrowErrnoExc (ECHRNG); #endif #if defined(EL2NSYNC) - testThrowErrnoExc(EL2NSYNC); + testThrowErrnoExc (EL2NSYNC); #endif #if defined(EL3HLT) - testThrowErrnoExc(EL3HLT); + testThrowErrnoExc (EL3HLT); #endif #if defined(EL3RST) - testThrowErrnoExc(EL3RST); + testThrowErrnoExc (EL3RST); #endif #if defined(ELNRNG) - testThrowErrnoExc(ELNRNG); + testThrowErrnoExc (ELNRNG); #endif #if defined(EUNATCH) - testThrowErrnoExc(EUNATCH); + testThrowErrnoExc (EUNATCH); #endif #if defined(ENOCSI) - testThrowErrnoExc(ENOCSI); + testThrowErrnoExc (ENOCSI); #endif #if defined(EL2HLT) - testThrowErrnoExc(EL2HLT); + testThrowErrnoExc (EL2HLT); #endif #if defined(EDEADLK) - testThrowErrnoExc(EDEADLK); + testThrowErrnoExc (EDEADLK); #endif #if defined(ENOLCK) - testThrowErrnoExc(ENOLCK); + testThrowErrnoExc (ENOLCK); #endif #if defined(EBADE) - testThrowErrnoExc(EBADE); + testThrowErrnoExc (EBADE); #endif #if defined(EBADR) - testThrowErrnoExc(EBADR); + testThrowErrnoExc (EBADR); #endif #if defined(EXFULL) - testThrowErrnoExc(EXFULL); + testThrowErrnoExc (EXFULL); #endif #if defined(ENOANO) - testThrowErrnoExc(ENOANO); + testThrowErrnoExc (ENOANO); #endif #if defined(EBADRQC) - testThrowErrnoExc(EBADRQC); + testThrowErrnoExc (EBADRQC); #endif #if defined(EBADSLT) - testThrowErrnoExc(EBADSLT); + testThrowErrnoExc (EBADSLT); #endif #if defined(EDEADLOCK) && defined(EDEADLK) # if EDEADLOCK != EDEADLK - testThrowErrnoExc(EDEADLOCK); + testThrowErrnoExc (EDEADLOCK); # endif #elif defined(EDEADLOCK) - testThrowErrnoExc(EDEADLOCK); + testThrowErrnoExc (EDEADLOCK); #endif #if defined(EBFONT) - testThrowErrnoExc(EBFONT); + testThrowErrnoExc (EBFONT); #endif #if defined(ENOSTR) - testThrowErrnoExc(ENOSTR); + testThrowErrnoExc (ENOSTR); #endif #if defined(ENODATA) - testThrowErrnoExc(ENODATA); + testThrowErrnoExc (ENODATA); #endif #if defined(ETIME) - testThrowErrnoExc(ETIME); + testThrowErrnoExc (ETIME); #endif #if defined(ENOSR) - testThrowErrnoExc(ENOSR); + testThrowErrnoExc (ENOSR); #endif #if defined(ENONET) - testThrowErrnoExc(ENONET); + testThrowErrnoExc (ENONET); #endif #if defined(ENOPKG) - testThrowErrnoExc(ENOPKG); + testThrowErrnoExc (ENOPKG); #endif #if defined(EREMOTE) - testThrowErrnoExc(EREMOTE); + testThrowErrnoExc (EREMOTE); #endif #if defined(ENOLINK) - testThrowErrnoExc(ENOLINK); + testThrowErrnoExc (ENOLINK); #endif #if defined(EADV) - testThrowErrnoExc(EADV); + testThrowErrnoExc (EADV); #endif #if defined(ESRMNT) - testThrowErrnoExc(ESRMNT); + testThrowErrnoExc (ESRMNT); #endif #if defined(ECOMM) - testThrowErrnoExc(ECOMM); + testThrowErrnoExc (ECOMM); #endif #if defined(EPROTO) - testThrowErrnoExc(EPROTO); + testThrowErrnoExc (EPROTO); #endif #if defined(EMULTIHOP) - testThrowErrnoExc(EMULTIHOP); + testThrowErrnoExc (EMULTIHOP); #endif #if defined(EBADMSG) - testThrowErrnoExc(EBADMSG); + testThrowErrnoExc (EBADMSG); #endif #if defined(ENAMETOOLONG) - testThrowErrnoExc(ENAMETOOLONG); + testThrowErrnoExc (ENAMETOOLONG); #endif #if defined(EOVERFLOW) - testThrowErrnoExc(EOVERFLOW); + testThrowErrnoExc (EOVERFLOW); #endif #if defined(ENOTUNIQ) - testThrowErrnoExc(ENOTUNIQ); + testThrowErrnoExc (ENOTUNIQ); #endif #if defined(EBADFD) - testThrowErrnoExc(EBADFD); + testThrowErrnoExc (EBADFD); #endif #if defined(EREMCHG) - testThrowErrnoExc(EREMCHG); + testThrowErrnoExc (EREMCHG); #endif #if defined(ELIBACC) - testThrowErrnoExc(ELIBACC); + testThrowErrnoExc (ELIBACC); #endif #if defined(ELIBBAD) - testThrowErrnoExc(ELIBBAD); + testThrowErrnoExc (ELIBBAD); #endif #if defined(ELIBSCN) - testThrowErrnoExc(ELIBSCN); + testThrowErrnoExc (ELIBSCN); #endif #if defined(ELIBMAX) - testThrowErrnoExc(ELIBMAX); + testThrowErrnoExc (ELIBMAX); #endif #if defined(ELIBEXEC) - testThrowErrnoExc(ELIBEXEC); + testThrowErrnoExc (ELIBEXEC); #endif #if defined(EILSEQ) - testThrowErrnoExc(EILSEQ); + testThrowErrnoExc (EILSEQ); #endif #if defined(ENOSYS) - testThrowErrnoExc(ENOSYS); + testThrowErrnoExc (ENOSYS); #endif #if defined(ELOOP) - testThrowErrnoExc(ELOOP); + testThrowErrnoExc (ELOOP); #endif #if defined(ERESTART) - testThrowErrnoExc(ERESTART); + testThrowErrnoExc (ERESTART); #endif #if defined(ESTRPIPE) - testThrowErrnoExc(ESTRPIPE); + testThrowErrnoExc (ESTRPIPE); #endif #if defined(ENOTEMPTY) - testThrowErrnoExc(ENOTEMPTY); + testThrowErrnoExc (ENOTEMPTY); #endif #if defined(EUSERS) - testThrowErrnoExc(EUSERS); + testThrowErrnoExc (EUSERS); #endif #if defined(ENOTSOCK) - testThrowErrnoExc(ENOTSOCK); + testThrowErrnoExc (ENOTSOCK); #endif #if defined(EDESTADDRREQ) - testThrowErrnoExc(EDESTADDRREQ); + testThrowErrnoExc (EDESTADDRREQ); #endif #if defined(EMSGSIZE) - testThrowErrnoExc(EMSGSIZE); + testThrowErrnoExc (EMSGSIZE); #endif #if defined(EPROTOTYPE) - testThrowErrnoExc(EPROTOTYPE); + testThrowErrnoExc (EPROTOTYPE); #endif #if defined(ENOPROTOOPT) - testThrowErrnoExc(ENOPROTOOPT); + testThrowErrnoExc (ENOPROTOOPT); #endif #if defined(EPROTONOSUPPORT) - testThrowErrnoExc(EPROTONOSUPPORT); + testThrowErrnoExc ( + EPROTONOSUPPORT); #endif #if defined(ESOCKTNOSUPPORT) - testThrowErrnoExc(ESOCKTNOSUPPORT); + testThrowErrnoExc ( + ESOCKTNOSUPPORT); #endif #if defined(EOPNOTSUPP) - testThrowErrnoExc(EOPNOTSUPP); + testThrowErrnoExc (EOPNOTSUPP); #endif #if defined(EPFNOSUPPORT) - testThrowErrnoExc(EPFNOSUPPORT); + testThrowErrnoExc (EPFNOSUPPORT); #endif #if defined(EAFNOSUPPORT) - testThrowErrnoExc(EAFNOSUPPORT); + testThrowErrnoExc (EAFNOSUPPORT); #endif #if defined(EADDRINUSE) - testThrowErrnoExc(EADDRINUSE); + testThrowErrnoExc (EADDRINUSE); #endif #if defined(EADDRNOTAVAIL) - testThrowErrnoExc(EADDRNOTAVAIL); + testThrowErrnoExc (EADDRNOTAVAIL); #endif #if defined(ENETDOWN) - testThrowErrnoExc(ENETDOWN); + testThrowErrnoExc (ENETDOWN); #endif #if defined(ENETUNREACH) - testThrowErrnoExc(ENETUNREACH); + testThrowErrnoExc (ENETUNREACH); #endif #if defined(ENETRESET) - testThrowErrnoExc(ENETRESET); + testThrowErrnoExc (ENETRESET); #endif #if defined(ECONNABORTED) - testThrowErrnoExc(ECONNABORTED); + testThrowErrnoExc (ECONNABORTED); #endif #if defined(ECONNRESET) - testThrowErrnoExc(ECONNRESET); + testThrowErrnoExc (ECONNRESET); #endif #if defined(ENOBUFS) - testThrowErrnoExc(ENOBUFS); + testThrowErrnoExc (ENOBUFS); #endif #if defined(EISCONN) - testThrowErrnoExc(EISCONN); + testThrowErrnoExc (EISCONN); #endif #if defined(ENOTCONN) - testThrowErrnoExc(ENOTCONN); + testThrowErrnoExc (ENOTCONN); #endif #if defined(ESHUTDOWN) - testThrowErrnoExc(ESHUTDOWN); + testThrowErrnoExc (ESHUTDOWN); #endif #if defined(ETOOMANYREFS) - testThrowErrnoExc(ETOOMANYREFS); + testThrowErrnoExc (ETOOMANYREFS); #endif #if defined(ETIMEDOUT) - testThrowErrnoExc(ETIMEDOUT); + testThrowErrnoExc (ETIMEDOUT); #endif #if defined(ECONNREFUSED) - testThrowErrnoExc(ECONNREFUSED); + testThrowErrnoExc (ECONNREFUSED); #endif #if defined(EHOSTDOWN) - testThrowErrnoExc(EHOSTDOWN); + testThrowErrnoExc (EHOSTDOWN); #endif #if defined(EHOSTUNREACH) - testThrowErrnoExc(EHOSTUNREACH); + testThrowErrnoExc (EHOSTUNREACH); #endif #if defined(EALREADY) - testThrowErrnoExc(EALREADY); + testThrowErrnoExc (EALREADY); #endif #if defined(EINPROGRESS) - testThrowErrnoExc(EINPROGRESS); + testThrowErrnoExc (EINPROGRESS); #endif #if defined(ESTALE) - testThrowErrnoExc(ESTALE); + testThrowErrnoExc (ESTALE); #endif #if defined(EIORESID) - testThrowErrnoExc(EIORESID); + testThrowErrnoExc (EIORESID); #endif #if defined(EUCLEAN) - testThrowErrnoExc(EUCLEAN); + testThrowErrnoExc (EUCLEAN); #endif #if defined(ENOTNAM) - testThrowErrnoExc(ENOTNAM); + testThrowErrnoExc (ENOTNAM); #endif #if defined(ENAVAIL) - testThrowErrnoExc(ENAVAIL); + testThrowErrnoExc (ENAVAIL); #endif #if defined(EISNAM) - testThrowErrnoExc(EISNAM); + testThrowErrnoExc (EISNAM); #endif #if defined(EREMOTEIO) - testThrowErrnoExc(EREMOTEIO); + testThrowErrnoExc (EREMOTEIO); #endif #if defined(EINIT) - testThrowErrnoExc(EINIT); + testThrowErrnoExc (EINIT); #endif #if defined(EREMDEV) - testThrowErrnoExc(EREMDEV); + testThrowErrnoExc (EREMDEV); #endif #if defined(ECANCELED) - testThrowErrnoExc(ECANCELED); + testThrowErrnoExc (ECANCELED); #endif #if defined(ENOLIMFILE) - testThrowErrnoExc(ENOLIMFILE); + testThrowErrnoExc (ENOLIMFILE); #endif #if defined(EPROCLIM) - testThrowErrnoExc(EPROCLIM); + testThrowErrnoExc (EPROCLIM); #endif #if defined(EDISJOINT) - testThrowErrnoExc(EDISJOINT); + testThrowErrnoExc (EDISJOINT); #endif #if defined(ENOLOGIN) - testThrowErrnoExc(ENOLOGIN); + testThrowErrnoExc (ENOLOGIN); #endif #if defined(ELOGINLIM) - testThrowErrnoExc(ELOGINLIM); + testThrowErrnoExc (ELOGINLIM); #endif #if defined(EGROUPLOOP) - testThrowErrnoExc(EGROUPLOOP); + testThrowErrnoExc (EGROUPLOOP); #endif #if defined(ENOATTACH) - testThrowErrnoExc(ENOATTACH); + testThrowErrnoExc (ENOATTACH); #endif #if defined(ENOTSUP) && defined(EOPNOTSUPP) # if ENOTSUP != EOPNOTSUPP - testThrowErrnoExc(ENOTSUP); + testThrowErrnoExc (ENOTSUP); # endif #elif defined(ENOTSUP) - testThrowErrnoExc(ENOTSUP); + testThrowErrnoExc (ENOTSUP); #endif #if defined(ENOATTR) - testThrowErrnoExc(ENOATTR); + testThrowErrnoExc (ENOATTR); #endif #if defined(EDIRCORRUPTED) - testThrowErrnoExc(EDIRCORRUPTED); + testThrowErrnoExc (EDIRCORRUPTED); #endif #if defined(EDQUOT) - testThrowErrnoExc(EDQUOT); + testThrowErrnoExc (EDQUOT); #endif #if defined(ENFSREMOTE) - testThrowErrnoExc(ENFSREMOTE); + testThrowErrnoExc (ENFSREMOTE); #endif #if defined(ECONTROLLER) - testThrowErrnoExc(ECONTROLLER); + testThrowErrnoExc (ECONTROLLER); #endif #if defined(ENOTCONTROLLER) - testThrowErrnoExc(ENOTCONTROLLER); + testThrowErrnoExc ( + ENOTCONTROLLER); #endif #if defined(EENQUEUED) - testThrowErrnoExc(EENQUEUED); + testThrowErrnoExc (EENQUEUED); #endif #if defined(ENOTENQUEUED) - testThrowErrnoExc(ENOTENQUEUED); + testThrowErrnoExc (ENOTENQUEUED); #endif #if defined(EJOINED) - testThrowErrnoExc(EJOINED); + testThrowErrnoExc (EJOINED); #endif #if defined(ENOTJOINED) - testThrowErrnoExc(ENOTJOINED); + testThrowErrnoExc (ENOTJOINED); #endif #if defined(ENOPROC) - testThrowErrnoExc(ENOPROC); + testThrowErrnoExc (ENOPROC); #endif #if defined(EMUSTRUN) - testThrowErrnoExc(EMUSTRUN); + testThrowErrnoExc (EMUSTRUN); #endif #if defined(ENOTSTOPPED) - testThrowErrnoExc(ENOTSTOPPED); + testThrowErrnoExc (ENOTSTOPPED); #endif #if defined(ECLOCKCPU) - testThrowErrnoExc(ECLOCKCPU); + testThrowErrnoExc (ECLOCKCPU); #endif #if defined(EINVALSTATE) - testThrowErrnoExc(EINVALSTATE); + testThrowErrnoExc (EINVALSTATE); #endif #if defined(ENOEXIST) - testThrowErrnoExc(ENOEXIST); + testThrowErrnoExc (ENOEXIST); #endif #if defined(EENDOFMINOR) - testThrowErrnoExc(EENDOFMINOR); + testThrowErrnoExc (EENDOFMINOR); #endif #if defined(EBUFSIZE) - testThrowErrnoExc(EBUFSIZE); + testThrowErrnoExc (EBUFSIZE); #endif #if defined(EEMPTY) - testThrowErrnoExc(EEMPTY); + testThrowErrnoExc (EEMPTY); #endif #if defined(ENOINTRGROUP) - testThrowErrnoExc(ENOINTRGROUP); + testThrowErrnoExc (ENOINTRGROUP); #endif #if defined(EINVALMODE) - testThrowErrnoExc(EINVALMODE); + testThrowErrnoExc (EINVALMODE); #endif #if defined(ECANTEXTENT) - testThrowErrnoExc(ECANTEXTENT); + testThrowErrnoExc (ECANTEXTENT); #endif #if defined(EINVALTIME) - testThrowErrnoExc(EINVALTIME); + testThrowErrnoExc (EINVALTIME); #endif #if defined(EDESTROYED) - testThrowErrnoExc(EDESTROYED); + testThrowErrnoExc (EDESTROYED); #endif } @@ -945,7 +947,7 @@ testBaseExc () test6 (); test6 (); - test7(); - + test7 (); + std::cout << "ok\n" << std::endl; } diff --git a/src/test/IexTest/testMathExc.cpp b/src/test/IexTest/testMathExc.cpp index b0c3217577..e0c7faebf3 100644 --- a/src/test/IexTest/testMathExc.cpp +++ b/src/test/IexTest/testMathExc.cpp @@ -11,7 +11,8 @@ #include #include -namespace { +namespace +{ void print (float f) @@ -19,7 +20,6 @@ print (float f) std::cout << f << std::endl; } - void test1 () { @@ -35,62 +35,58 @@ test1 () for (int i = 0; i < 3; ++i) { - try - { - print (divide (1, 0)); // division by zero - print (root (-1)); // invalid operation - print (grow (1000, 100)); // overflow - } - catch (...) - { - assert (false); - } + try + { + print (divide (1, 0)); // division by zero + print (root (-1)); // invalid operation + print (grow (1000, 100)); // overflow + } + catch (...) + { + assert (false); + } } } - void test2a () { try { - print (divide (1, 0)); // division by zero + print (divide (1, 0)); // division by zero } - catch (const IEX_INTERNAL_NAMESPACE::DivzeroExc &e) + catch (const IEX_INTERNAL_NAMESPACE::DivzeroExc& e) { - std::cout << "caught exception: " << e.what() << std::endl; + std::cout << "caught exception: " << e.what () << std::endl; } } - void test2b () { try { - print (root (-1)); // invalid operation + print (root (-1)); // invalid operation } - catch (const IEX_INTERNAL_NAMESPACE::InvalidFpOpExc &e) + catch (const IEX_INTERNAL_NAMESPACE::InvalidFpOpExc& e) { - std::cout << "caught exception: " << e.what() << std::endl; + std::cout << "caught exception: " << e.what () << std::endl; } } - void test2c () { try { - print (grow (1000, 100)); // overflow + print (grow (1000, 100)); // overflow } - catch (const IEX_INTERNAL_NAMESPACE::OverflowExc &e) + catch (const IEX_INTERNAL_NAMESPACE::OverflowExc& e) { - std::cout << "caught exception: " << e.what() << std::endl; + std::cout << "caught exception: " << e.what () << std::endl; } } - void test2 () { @@ -102,17 +98,19 @@ test2 () std::cout << "invalid operations / exception handling on" << std::endl; - IEX_INTERNAL_NAMESPACE::mathExcOn (IEX_INTERNAL_NAMESPACE::IEEE_OVERFLOW | IEX_INTERNAL_NAMESPACE::IEEE_DIVZERO | IEX_INTERNAL_NAMESPACE::IEEE_INVALID); + IEX_INTERNAL_NAMESPACE::mathExcOn ( + IEX_INTERNAL_NAMESPACE::IEEE_OVERFLOW | + IEX_INTERNAL_NAMESPACE::IEEE_DIVZERO | + IEX_INTERNAL_NAMESPACE::IEEE_INVALID); for (int i = 0; i < 3; ++i) { - test2a(); - test2b(); - test2c(); + test2a (); + test2b (); + test2c (); } } - void test3 () { @@ -121,7 +119,6 @@ test3 () // was most recently set with setMathExcOn(). // - #if defined(HAVE_UCONTEXT_H) && \ (defined(IEX_HAVE_SIGCONTEXT_CONTROL_REGISTER_SUPPORT) || \ defined(IEX_HAVE_CONTROL_REGISTER_SUPPORT)) @@ -131,41 +128,42 @@ test3 () int when = 0; IEX_INTERNAL_NAMESPACE::mathExcOn (when); - assert (IEX_INTERNAL_NAMESPACE::getMathExcOn() == when); + assert (IEX_INTERNAL_NAMESPACE::getMathExcOn () == when); when = IEX_INTERNAL_NAMESPACE::IEEE_OVERFLOW; IEX_INTERNAL_NAMESPACE::mathExcOn (when); - assert (IEX_INTERNAL_NAMESPACE::getMathExcOn() == when); + assert (IEX_INTERNAL_NAMESPACE::getMathExcOn () == when); when = IEX_INTERNAL_NAMESPACE::IEEE_DIVZERO; IEX_INTERNAL_NAMESPACE::mathExcOn (when); - assert (IEX_INTERNAL_NAMESPACE::getMathExcOn() == when); + assert (IEX_INTERNAL_NAMESPACE::getMathExcOn () == when); when = IEX_INTERNAL_NAMESPACE::IEEE_INVALID; IEX_INTERNAL_NAMESPACE::mathExcOn (when); - assert (IEX_INTERNAL_NAMESPACE::getMathExcOn() == when); + assert (IEX_INTERNAL_NAMESPACE::getMathExcOn () == when); - when = IEX_INTERNAL_NAMESPACE::IEEE_OVERFLOW | IEX_INTERNAL_NAMESPACE::IEEE_DIVZERO | IEX_INTERNAL_NAMESPACE::IEEE_INVALID; + when = IEX_INTERNAL_NAMESPACE::IEEE_OVERFLOW | + IEX_INTERNAL_NAMESPACE::IEEE_DIVZERO | + IEX_INTERNAL_NAMESPACE::IEEE_INVALID; IEX_INTERNAL_NAMESPACE::mathExcOn (when); - assert (IEX_INTERNAL_NAMESPACE::getMathExcOn() == when); + assert (IEX_INTERNAL_NAMESPACE::getMathExcOn () == when); #endif } } // namespace - void -testMathExc() +testMathExc () { std::cout << "See if floating-point exceptions work:" << std::endl; - test1(); - test2(); - test3(); + test1 (); + test2 (); + test3 (); std::cout << " ok" << std::endl; } diff --git a/src/test/IexTest/testMathExc.h b/src/test/IexTest/testMathExc.h index 94f73babbf..4fae49c94c 100644 --- a/src/test/IexTest/testMathExc.h +++ b/src/test/IexTest/testMathExc.h @@ -1,5 +1,4 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenEXR Project. -void testMathExc(); - +void testMathExc (); diff --git a/src/test/OpenEXRCoreTest/base_units.cpp b/src/test/OpenEXRCoreTest/base_units.cpp index 0e074e5807..910cbc7fa5 100644 --- a/src/test/OpenEXRCoreTest/base_units.cpp +++ b/src/test/OpenEXRCoreTest/base_units.cpp @@ -44,8 +44,8 @@ testBase (const std::string& tempdir) std::cerr << "'" << std::endl; EXRCORE_TEST (false); } - std::cout << "Testing OpenEXR library version: '" << major << "." << minor << "." - << patch; + std::cout << "Testing OpenEXR library version: '" << major << "." << minor + << "." << patch; if (extra[0] != '\0') std::cout << extra; std::cout << "'" << std::endl; @@ -362,30 +362,31 @@ testBaseDebug (const std::string& tempdir) exr_print_context_info (c, 1); } -void testCPUIdent (const std::string& tempdir) +void +testCPUIdent (const std::string& tempdir) { - int hf16c, havx, hsse2; + int hf16c, havx, hsse2; OPENEXR_IMF_NAMESPACE::CpuId id; check_for_x86_simd (&hf16c, &havx, &hsse2); - if (hf16c != (int)id.f16c) + if (hf16c != (int) id.f16c) { - std::cerr - << "CPU Id test f16c mismatch: " << hf16c << " vs " << (int)id.f16c << std::endl; + std::cerr << "CPU Id test f16c mismatch: " << hf16c << " vs " + << (int) id.f16c << std::endl; EXRCORE_TEST (false); } - if (havx != (int)id.avx) + if (havx != (int) id.avx) { - std::cerr - << "CPU Id test avx mismatch: " << havx << " vs " << (int)id.avx << std::endl; + std::cerr << "CPU Id test avx mismatch: " << havx << " vs " + << (int) id.avx << std::endl; EXRCORE_TEST (false); } - if (hsse2 != (int)id.sse2) + if (hsse2 != (int) id.sse2) { - std::cerr - << "CPU Id test sse2 mismatch: " << hsse2 << " vs " << (int)id.sse2 << std::endl; + std::cerr << "CPU Id test sse2 mismatch: " << hsse2 << " vs " + << (int) id.sse2 << std::endl; EXRCORE_TEST (false); } @@ -400,7 +401,8 @@ void testCPUIdent (const std::string& tempdir) #endif } -void testHalf (const std::string& tempdir) +void +testHalf (const std::string& tempdir) { EXRCORE_TEST (half_to_float (0) == 0.f); EXRCORE_TEST (float_to_half (0.f) == 0); @@ -418,4 +420,3 @@ void testHalf (const std::string& tempdir) EXRCORE_TEST (uint_to_float (0) == 0.f); EXRCORE_TEST (uint_to_float_int (0) == 0); } - diff --git a/src/test/OpenEXRCoreTest/buffer.cpp b/src/test/OpenEXRCoreTest/buffer.cpp index e3fcdf96b9..be84d083f6 100644 --- a/src/test/OpenEXRCoreTest/buffer.cpp +++ b/src/test/OpenEXRCoreTest/buffer.cpp @@ -14,25 +14,25 @@ #include "test_value.h" #include -void testBufferCompression (const std::string& tempdir) +void +testBufferCompression (const std::string& tempdir) { - size_t bc0 = exr_compress_max_buffer_size(0); - size_t bc128 = exr_compress_max_buffer_size(128); - if (bc0 < 9) - EXRCORE_TEST_FAIL(bc0 < 9); - if (bc128 < 128 + 9) - EXRCORE_TEST_FAIL(bc0 < 9); + size_t bc0 = exr_compress_max_buffer_size (0); + size_t bc128 = exr_compress_max_buffer_size (128); + if (bc0 < 9) EXRCORE_TEST_FAIL (bc0 < 9); + if (bc128 < 128 + 9) EXRCORE_TEST_FAIL (bc0 < 9); std::cout << "Max Buffer Size (0): " << bc0 << std::endl; std::cout << "Max Buffer Size (128): " << bc128 << std::endl; std::vector buf, cbuf; buf = {'O', 'p', 'e', 'n', 'E', 'X', 'R'}; - cbuf.resize( exr_compress_max_buffer_size (buf.size()) ); + cbuf.resize (exr_compress_max_buffer_size (buf.size ())); size_t outsz; - EXRCORE_TEST_RVAL (exr_compress_buffer (nullptr, 9, buf.data(), buf.size(), &cbuf[0], cbuf.size(), &outsz)); + EXRCORE_TEST_RVAL (exr_compress_buffer ( + nullptr, 9, buf.data (), buf.size (), &cbuf[0], cbuf.size (), &outsz)); std::cout << "compressed size: " << outsz << std::endl; - EXRCORE_TEST_RVAL (exr_uncompress_buffer (nullptr, cbuf.data(), outsz, &buf[0], buf.size(), &outsz)); + EXRCORE_TEST_RVAL (exr_uncompress_buffer ( + nullptr, cbuf.data (), outsz, &buf[0], buf.size (), &outsz)); std::cout << "uncompressed size: " << outsz << std::endl; - if (buf[0] != 'O') - EXRCORE_TEST_FAIL(buf[0] != 'O'); + if (buf[0] != 'O') EXRCORE_TEST_FAIL (buf[0] != 'O'); } diff --git a/src/test/OpenEXRCoreTest/compression.cpp b/src/test/OpenEXRCoreTest/compression.cpp index 772111647f..69bb37b3da 100644 --- a/src/test/OpenEXRCoreTest/compression.cpp +++ b/src/test/OpenEXRCoreTest/compression.cpp @@ -42,39 +42,44 @@ # include # include -static int compare_files (const char *fn, const char *fn2) +static int +compare_files (const char* fn, const char* fn2) { struct stat sb1, sb2; - if ( 0 == stat (fn, &sb1) && 0 == stat (fn2, &sb2)) + if (0 == stat (fn, &sb1) && 0 == stat (fn2, &sb2)) { if (sb1.st_size != sb2.st_size) { - std::cerr << "File sizes do not match: '" << fn << "' " << sb1.st_size << " '" << fn2 << "' " << sb2.st_size << std::endl; + std::cerr << "File sizes do not match: '" << fn << "' " + << sb1.st_size << " '" << fn2 << "' " << sb2.st_size + << std::endl; return 1; } int fd1, fd2; int ret = 0; - fd1 = open (fn, O_RDONLY); - fd2 = open (fn2, O_RDONLY); + fd1 = open (fn, O_RDONLY); + fd2 = open (fn2, O_RDONLY); if (fd1 >= 0 && fd2 >= 0) { uint8_t buf1[512], buf2[512]; - size_t toRead = sb1.st_size; - size_t chunkReq = sizeof(buf1); - size_t offset = 0; + size_t toRead = sb1.st_size; + size_t chunkReq = sizeof (buf1); + size_t offset = 0; while (toRead > 0) { ssize_t nr1 = read (fd1, buf1, chunkReq); ssize_t nr2 = read (fd2, buf2, chunkReq); if (nr1 < 0 || nr2 < 0) { - std::cerr << "Unable to read from files " << nr1 << ", " << nr2 << std::endl; + std::cerr << "Unable to read from files " << nr1 << ", " + << nr2 << std::endl; ret = -1; break; } if (nr1 != nr2) { - std::cerr << "Mismatch in read amounts " << nr1 << ", " << nr2 << std::endl; + std::cerr << "Mismatch in read amounts " << nr1 << ", " + << nr2 << std::endl; ret = -1; break; } @@ -82,11 +87,13 @@ static int compare_files (const char *fn, const char *fn2) { if (memcmp (buf1, buf2, nr1) != 0) { - for ( ssize_t b = 0; b < nr1; ++b ) + for (ssize_t b = 0; b < nr1; ++b) { if (buf1[b] != buf2[b]) { - std::cerr << "Files '" << fn << "' and '" << fn2 << "' differ in chunk starting at " << offset + b << std::endl; + std::cerr << "Files '" << fn << "' and '" << fn2 + << "' differ in chunk starting at " + << offset + b << std::endl; break; } } @@ -104,7 +111,8 @@ static int compare_files (const char *fn, const char *fn2) } else { - std::cerr << "Unable to stat '" << fn << "' and '" << fn2 << "'" << std::endl; + std::cerr << "Unable to stat '" << fn << "' and '" << fn2 << "'" + << std::endl; } return -1; } @@ -161,13 +169,12 @@ withinDWAErrorBounds (const uint16_t a, const uint16_t b) float a1 = imath_half_to_float (a); if (!std::isnan (a1)) { - float a2 = imath_half_to_float (b); - float denominator = - std::max (1.f, std::max (fabsf (a2), fabsf (a1))); + float a2 = imath_half_to_float (b); + float denominator = std::max (1.f, std::max (fabsf (a2), fabsf (a1))); if (fabs (a1 / denominator - a2 / denominator) >= 0.1) { - std::cerr << "DWA" << " B bits " << std::hex << b - << std::dec << " (" << a2 + std::cerr << "DWA" + << " B bits " << std::hex << b << std::dec << " (" << a2 << ") too different from A1 bits " << std::hex << a << std::dec << " (" << a1 << ")" << " delta " << fabs (a1 / denominator - a2 / denominator) @@ -470,7 +477,8 @@ struct pixels << " not equal: " << taga << " 0x" << std::hex << a << std::dec << " (" << imath_half_to_float (a) << ") vs " << tagb << " 0x" << std::hex << b << std::hex << " (" - << imath_half_to_float (b) << ")" << std::dec << std::endl; + << imath_half_to_float (b) << ")" << std::dec + << std::endl; } EXRCORE_TEST (a == b); } @@ -626,7 +634,9 @@ struct pixels for (int c = 0; c < 4; ++c) { EXRCORE_TEST_LOCATION ( - withinDWAErrorBounds (o.rgba[c][idx], rgba[c][idx]), x, y) + withinDWAErrorBounds (o.rgba[c][idx], rgba[c][idx]), + x, + y) } } } @@ -1351,14 +1361,11 @@ doWriteRead ( #ifdef __linux if (getenv ("ENABLE_EXACT_FILE_COMPARE") && - 0 != compare_files (filename.c_str(), cppfilename.c_str())) + 0 != compare_files (filename.c_str (), cppfilename.c_str ())) { EXRCORE_TEST_FAIL (compare_files); } - else - { - compare_files (filename.c_str(), cppfilename.c_str()); - } + else { compare_files (filename.c_str (), cppfilename.c_str ()); } #endif pixels restore = p; pixels cpprestore = p; @@ -1494,10 +1501,11 @@ testHUF (const std::string& tempdir) // decsize 1 << 16 + 1 // decsize 1 << 14 EXRCORE_TEST (esize == 65537 * (8 + 8 + sizeof (uint64_t*) + 4)); - const uint64_t hufdecsize = (sizeof (uint32_t*) + sizeof(int32_t) + sizeof(uint32_t)); + const uint64_t hufdecsize = + (sizeof (uint32_t*) + sizeof (int32_t) + sizeof (uint32_t)); // sizeof(FastHufDecoder) is bother to manually compute, just assume it's ok // if it's returning at least enough for the slow path - EXRCORE_TEST (dsize >= (65537 * sizeof(uint64_t) + 16383 * hufdecsize)); + EXRCORE_TEST (dsize >= (65537 * sizeof (uint64_t) + 16383 * hufdecsize)); std::vector hspare; diff --git a/src/test/OpenEXRCoreTest/deep.cpp b/src/test/OpenEXRCoreTest/deep.cpp index 842ae1f5a4..d8fd2ae94b 100644 --- a/src/test/OpenEXRCoreTest/deep.cpp +++ b/src/test/OpenEXRCoreTest/deep.cpp @@ -98,9 +98,10 @@ generateRandomScanFile ( frameBuffer.insertSampleCountSlice (Slice ( IMF::UINT, // type // 7 - (char*) (&sampleCountScans[0][0] - dataWindow.min.x - dataWindow.min.y * width), // base - sizeof (unsigned int) * 1, // xStride - sizeof (unsigned int) * width)); // yStride + (char*) (&sampleCountScans[0][0] - dataWindow.min.x - + dataWindow.min.y * width), // base + sizeof (unsigned int) * 1, // xStride + sizeof (unsigned int) * width)); // yStride for (int i = 0; i < channelCount; i++) { @@ -124,10 +125,11 @@ generateRandomScanFile ( str, // name // 6 DeepSlice ( type, // type // 7 - (char*) (&data[i][0][0] - dataWindow.min.x - dataWindow.min.y * width), // base // 8 - pointerSize * 1, // xStride// 9 - pointerSize * width, // yStride// 10 - sampleSize)); // sampleStride + (char*) (&data[i][0][0] - dataWindow.min.x - + dataWindow.min.y * width), // base // 8 + pointerSize * 1, // xStride// 9 + pointerSize * width, // yStride// 10 + sampleSize)); // sampleStride } file.setFrameBuffer (frameBuffer); @@ -169,9 +171,10 @@ generateRandomScanFile ( for (int j = 0; j < width; j++) for (int k = 0; k < channelCount; k++) { - if (channelTypes[k] == 0) delete[](unsigned int*) data[k][i][j]; - if (channelTypes[k] == 1) delete[](half*) data[k][i][j]; - if (channelTypes[k] == 2) delete[](float*) data[k][i][j]; + if (channelTypes[k] == 0) + delete[] (unsigned int*) data[k][i][j]; + if (channelTypes[k] == 1) delete[] (half*) data[k][i][j]; + if (channelTypes[k] == 2) delete[] (float*) data[k][i][j]; } std::cout << " --> done" << std::endl; @@ -354,10 +357,11 @@ generateRandomTileFile ( for (int k = 0; k < channelCount; k++) { if (channelTypes[k] == 0) - delete[](unsigned int*) data[k][i][j]; - if (channelTypes[k] == 1) delete[](half*) data[k][i][j]; + delete[] (unsigned int*) data[k][i][j]; + if (channelTypes[k] == 1) + delete[] (half*) data[k][i][j]; if (channelTypes[k] == 2) - delete[](float*) data[k][i][j]; + delete[] (float*) data[k][i][j]; } } std::cout << " --> done" << std::endl; diff --git a/src/test/OpenEXRCoreTest/general_attr.cpp b/src/test/OpenEXRCoreTest/general_attr.cpp index e98259277e..fcc7439258 100644 --- a/src/test/OpenEXRCoreTest/general_attr.cpp +++ b/src/test/OpenEXRCoreTest/general_attr.cpp @@ -88,7 +88,7 @@ createDummyFile (const char* test) // fail. commented out until we've investigated. // cinit.free_fn = failable_free; - + EXRCORE_TEST_RVAL ( exr_start_write (&f, test, EXR_WRITE_FILE_DIRECTLY, &cinit)); EXRCORE_TEST_RVAL (exr_add_part (f, "dummy", EXR_STORAGE_SCANLINE, NULL)); @@ -1764,7 +1764,7 @@ testXDR (const std::string& tempdir) uint16_t v16buf[] = {0xAA00, 0xBB11, 0xCC22, 0xDD33, 0xEE44}; uint32_t v32buf[] = {0xAA00BB11, 0xCC22DD33}; uint64_t v64buf[] = {0xAA00BB11CC22DD33, 0xEE44FF5500661177}; - float v32f = 42.f; + float v32f = 42.f; EXRCORE_TEST (one_to_native64 (one_from_native64 (v64)) == v64); EXRCORE_TEST (one_to_native32 (one_from_native32 (v32)) == v32); EXRCORE_TEST (one_to_native16 (one_from_native16 (v16)) == v16); diff --git a/src/test/OpenEXRCoreTest/performance.cpp b/src/test/OpenEXRCoreTest/performance.cpp index d0c8162a2d..3e35639106 100644 --- a/src/test/OpenEXRCoreTest/performance.cpp +++ b/src/test/OpenEXRCoreTest/performance.cpp @@ -277,7 +277,7 @@ read_pixels_raw (MultiPartInputFile* f) auto& dw = head.dataWindow (); int64_t w = dw.max.x - dw.min.x + 1; int64_t h = dw.max.y - dw.min.y + 1; - uint64_t ret = 0; + uint64_t ret = 0; if (w <= 0) return ret; diff --git a/src/test/OpenEXRCoreTest/read.cpp b/src/test/OpenEXRCoreTest/read.cpp index f129796727..656ad234ce 100644 --- a/src/test/OpenEXRCoreTest/read.cpp +++ b/src/test/OpenEXRCoreTest/read.cpp @@ -123,7 +123,7 @@ testReadMeta (const std::string& tempdir) fn += "v1.7.test.1.exr"; exr_context_initializer_t cinit = EXR_DEFAULT_CONTEXT_INITIALIZER; cinit.error_handler_fn = &err_cb; - exr_attribute_t* newattr; + exr_attribute_t* newattr; EXRCORE_TEST_RVAL (exr_test_file_header (fn.c_str (), &cinit)); EXRCORE_TEST_RVAL (exr_start_read (&f, fn.c_str (), &cinit)); diff --git a/src/test/OpenEXRFuzzTest/main.cpp b/src/test/OpenEXRFuzzTest/main.cpp index a341bc84c3..9715884c30 100644 --- a/src/test/OpenEXRFuzzTest/main.cpp +++ b/src/test/OpenEXRFuzzTest/main.cpp @@ -107,10 +107,7 @@ main (int argc, char* argv[]) cout << ' ' << *i << endl; } } - else if (!testFound) - { - cout << "No such test: " << argv[1] << endl; - } + else if (!testFound) { cout << "No such test: " << argv[1] << endl; } else { #ifdef OPENEXR_IMF_HAVE_LINUX_PROCFS diff --git a/src/test/OpenEXRFuzzTest/testFuzzDeepScanLines.cpp b/src/test/OpenEXRFuzzTest/testFuzzDeepScanLines.cpp index 24b0c37cc6..462783c2d2 100644 --- a/src/test/OpenEXRFuzzTest/testFuzzDeepScanLines.cpp +++ b/src/test/OpenEXRFuzzTest/testFuzzDeepScanLines.cpp @@ -102,9 +102,10 @@ generateRandomFile ( frameBuffer.insertSampleCountSlice (Slice ( IMF::UINT, // type // 7 - (char*) (&sampleCount[0][0] - dataWindow.min.x - dataWindow.min.y * width), // base // 8 - sizeof (unsigned int) * 1, // xStride// 9 - sizeof (unsigned int) * width)); // yStride// 10 + (char*) (&sampleCount[0][0] - dataWindow.min.x - + dataWindow.min.y * width), // base // 8 + sizeof (unsigned int) * 1, // xStride// 9 + sizeof (unsigned int) * width)); // yStride// 10 for (int i = 0; i < channelCount; i++) { @@ -121,10 +122,11 @@ generateRandomFile ( str, // name // 6 DeepSlice ( type, // type // 7 - (char*) (&data[i][0][0] - dataWindow.min.x - dataWindow.min.y * width), // base // 8 - pointerSize * 1, // xStride// 9 - pointerSize * width, // yStride// 10 - sampleSize)); // sampleStride + (char*) (&data[i][0][0] - dataWindow.min.x - + dataWindow.min.y * width), // base // 8 + pointerSize * 1, // xStride// 9 + pointerSize * width, // yStride// 10 + sampleSize)); // sampleStride } for (int p = 0; p < parts; p++) @@ -164,7 +166,7 @@ generateRandomFile ( sampleCount[i][j] = rand () % 4 + 1; for (int k = 0; k < channelCount; k++) { - delete[](float*) data[k][i][j]; + delete[] (float*) data[k][i][j]; } } } @@ -199,9 +201,10 @@ readFile (const char filename[]) frameBuffer.insertSampleCountSlice (Slice ( IMF::UINT, // type // 7 - (char*) (&localSampleCount[0][0] - dataWindow.min.x - dataWindow.min.y * width), // base // 8) - sizeof (unsigned int) * 1, // xStride// 9 - sizeof (unsigned int) * width)); // yStride// 10 + (char*) (&localSampleCount[0][0] - dataWindow.min.x - + dataWindow.min.y * width), // base // 8) + sizeof (unsigned int) * 1, // xStride// 9 + sizeof (unsigned int) * width)); // yStride// 10 vector read_channel (channelCount); @@ -221,10 +224,11 @@ readFile (const char filename[]) str, DeepSlice ( type, - (char*) (&data[i][0][0] - dataWindow.min.x - dataWindow.min.y * width), // base // 8) - pointerSize * 1, // xStride// 9 - pointerSize * width, // yStride// 10 - sampleSize)); // sampleStride + (char*) (&data[i][0][0] - dataWindow.min.x - + dataWindow.min.y * width), // base // 8) + pointerSize * 1, // xStride// 9 + pointerSize * width, // yStride// 10 + sampleSize)); // sampleStride } file.setFrameBuffer (frameBuffer); @@ -254,7 +258,7 @@ readFile (const char filename[]) for (int j = 0; j < width; j++) for (int k = 0; k < channelCount; k++) { - delete[](float*) data[k][i][j]; + delete[] (float*) data[k][i][j]; } } catch (std::exception& e) @@ -288,12 +292,12 @@ readFile (const char filename[]) DeepFrameBuffer frameBuffer; - frameBuffer.insertSampleCountSlice (Slice (IMF::UINT, // type // 7 - (char *) (&localSampleCount[0][0] - - dataWindow.min.x - - dataWindow.min.y * width), // base // 8) - sizeof (unsigned int) * 1, // xStride// 9 - sizeof (unsigned int) * width)); // yStride// 10 + frameBuffer.insertSampleCountSlice (Slice ( + IMF::UINT, // type // 7 + (char*) (&localSampleCount[0][0] - dataWindow.min.x - + dataWindow.min.y * width), // base // 8) + sizeof (unsigned int) * 1, // xStride// 9 + sizeof (unsigned int) * width)); // yStride// 10 vector read_channel (channelCount); @@ -309,14 +313,15 @@ readFile (const char filename[]) int pointerSize = sizeof (char*); - frameBuffer.insert (str, - DeepSlice (type, - (char *) (&data[i][0][0] - - dataWindow.min.x - - dataWindow.min.y * width), // base // 8) - pointerSize * 1, // xStride// 9 - pointerSize * width, // yStride// 10 - sampleSize)); // sampleStride + frameBuffer.insert ( + str, + DeepSlice ( + type, + (char*) (&data[i][0][0] - dataWindow.min.x - + dataWindow.min.y * width), // base // 8) + pointerSize * 1, // xStride// 9 + pointerSize * width, // yStride// 10 + sampleSize)); // sampleStride } inpart.setFrameBuffer (frameBuffer); @@ -346,7 +351,7 @@ readFile (const char filename[]) { for (int k = 0; k < channelCount; k++) { - delete[](float*) data[k][i][j]; + delete[] (float*) data[k][i][j]; } } } diff --git a/src/test/OpenEXRFuzzTest/testFuzzDeepTiles.cpp b/src/test/OpenEXRFuzzTest/testFuzzDeepTiles.cpp index 3fc6802789..f4cc7d704c 100644 --- a/src/test/OpenEXRFuzzTest/testFuzzDeepTiles.cpp +++ b/src/test/OpenEXRFuzzTest/testFuzzDeepTiles.cpp @@ -331,7 +331,7 @@ readFile (const char filename[]) { for (int k = 0; k < channelCount; k++) { - delete[](float*) data[k][i][j]; + delete[] (float*) data[k][i][j]; } } } @@ -464,7 +464,7 @@ readFile (const char filename[]) { for (int k = 0; k < channelCount; k++) { - delete[](float*) data[k][i][j]; + delete[] (float*) data[k][i][j]; } } } diff --git a/src/test/OpenEXRTest/compareDwa.cpp b/src/test/OpenEXRTest/compareDwa.cpp index 99a17efd55..692d7ae175 100644 --- a/src/test/OpenEXRTest/compareDwa.cpp +++ b/src/test/OpenEXRTest/compareDwa.cpp @@ -92,15 +92,9 @@ compareDwa ( if (fabs (srcNonlin) < .1) continue; if (fabs (srcNonlin) < .25) { assert (relError < .25); } - else - { - assert (relError < .1); - } - } - else - { - assert (srcNonlin != testNonlin); + else { assert (relError < .1); } } + else { assert (srcNonlin != testNonlin); } } } } diff --git a/src/test/OpenEXRTest/testAttributes.cpp b/src/test/OpenEXRTest/testAttributes.cpp index 15f79e5219..700f88d14e 100644 --- a/src/test/OpenEXRTest/testAttributes.cpp +++ b/src/test/OpenEXRTest/testAttributes.cpp @@ -583,7 +583,7 @@ static int move_assignment_operator; struct TestType { - TestType () : _f(0) { default_constructor++; } + TestType () : _f (0) { default_constructor++; } ~TestType () { destructor++; } diff --git a/src/test/OpenEXRTest/testCompositeDeepScanLine.cpp b/src/test/OpenEXRTest/testCompositeDeepScanLine.cpp index 555c377eeb..9798d93dfd 100644 --- a/src/test/OpenEXRTest/testCompositeDeepScanLine.cpp +++ b/src/test/OpenEXRTest/testCompositeDeepScanLine.cpp @@ -86,7 +86,7 @@ template class data vector _channels; // channel names - same size and order as in all other arrays, vector - _current_result; // one value per channel: the ground truth value for the given pixel + _current_result; // one value per channel: the ground truth value for the given pixel vector> _results; // a list of result pixels bool _inserting_result; @@ -105,20 +105,14 @@ template class data { _type = OPENEXR_IMF_NAMESPACE::HALF; } - else - { - _type = OPENEXR_IMF_NAMESPACE::FLOAT; - } + else { _type = OPENEXR_IMF_NAMESPACE::FLOAT; } } // add a value to the current sample data& operator<< (float value) { if (_inserting_result) { _current_result.push_back (value); } - else - { - _current_sample.push_back (T (value)); - } + else { _current_sample.push_back (T (value)); } _started = true; return *this; } @@ -290,13 +284,15 @@ template class data sizeof (unsigned int) * (dw.size ().x + 1))); for (size_t c = 0; c < _channels.size (); c++) { - fb.insert(_channels[c], - DeepSlice(_type,(char *)(&sample_pointers[c][0]-dw.min.x-(dw.size().x+1)*dw.min.y), - sizeof(T *), - sizeof(T *)*(dw.size().x+1), - sizeof(T) - ) - ); + fb.insert ( + _channels[c], + DeepSlice ( + _type, + (char*) (&sample_pointers[c][0] - dw.min.x - + (dw.size ().x + 1) * dw.min.y), + sizeof (T*), + sizeof (T*) * (dw.size ().x + 1), + sizeof (T))); } part.setFrameBuffer (fb); part.writePixels (dw.size ().y + 1); @@ -547,10 +543,7 @@ write_file (const char* filename, const data& main, int number_of_parts) { DeepScanLineOutputPart p (f, i); if (number_of_parts == 1) { main.writeData (p); } - else - { - sub_parts[i].writeData (p); - } + else { sub_parts[i].writeData (p); } } } @@ -583,8 +576,7 @@ test_parts ( comp.addSource (parts[i]); } - main.setUpFrameBuffer ( - data, testbuf, comp.dataWindow (), load_depths); + main.setUpFrameBuffer (data, testbuf, comp.dataWindow (), load_depths); comp.setFrameBuffer (testbuf); diff --git a/src/test/OpenEXRTest/testCopyDeepScanLine.cpp b/src/test/OpenEXRTest/testCopyDeepScanLine.cpp index 17ebbf2126..d2b2d9036c 100644 --- a/src/test/OpenEXRTest/testCopyDeepScanLine.cpp +++ b/src/test/OpenEXRTest/testCopyDeepScanLine.cpp @@ -99,9 +99,10 @@ generateRandomFile ( frameBuffer.insertSampleCountSlice (Slice ( IMF::UINT, // type // 7 - (char*) (&sampleCount[0][0] - dataWindow.min.x - dataWindow.min.y * width), // base // 8 - sizeof (unsigned int) * 1, // xStride// 9 - sizeof (unsigned int) * width)); // yStride// 10 + (char*) (&sampleCount[0][0] - dataWindow.min.x - + dataWindow.min.y * width), // base // 8 + sizeof (unsigned int) * 1, // xStride// 9 + sizeof (unsigned int) * width)); // yStride// 10 for (int i = 0; i < channelCount; i++) { @@ -125,10 +126,11 @@ generateRandomFile ( str, // name // 6 DeepSlice ( type, // type // 7 - (char*) (&data[i][0][0] - dataWindow.min.x - dataWindow.min.y * width), // base // 8 - pointerSize * 1, // xStride// 9 - pointerSize * width, // yStride// 10 - sampleSize)); // sampleStride + (char*) (&data[i][0][0] - dataWindow.min.x - + dataWindow.min.y * width), // base // 8 + pointerSize * 1, // xStride// 9 + pointerSize * width, // yStride// 10 + sampleSize)); // sampleStride } file.setFrameBuffer (frameBuffer); @@ -171,9 +173,10 @@ generateRandomFile ( for (int j = 0; j < width; j++) for (int k = 0; k < channelCount; k++) { - if (channelTypes[k] == 0) delete[](unsigned int*) data[k][i][j]; - if (channelTypes[k] == 1) delete[](half*) data[k][i][j]; - if (channelTypes[k] == 2) delete[](float*) data[k][i][j]; + if (channelTypes[k] == 0) + delete[] (unsigned int*) data[k][i][j]; + if (channelTypes[k] == 1) delete[] (half*) data[k][i][j]; + if (channelTypes[k] == 2) delete[] (float*) data[k][i][j]; } } @@ -221,9 +224,10 @@ readFile (const std::string& copy_filename, int channelCount) frameBuffer.insertSampleCountSlice (Slice ( IMF::UINT, // type // 7 - (char*) (&localSampleCount[0][0] - dataWindow.min.x - dataWindow.min.y * width), // base // 8) - sizeof (unsigned int) * 1, // xStride// 9 - sizeof (unsigned int) * width)); // yStride// 10 + (char*) (&localSampleCount[0][0] - dataWindow.min.x - + dataWindow.min.y * width), // base // 8) + sizeof (unsigned int) * 1, // xStride// 9 + sizeof (unsigned int) * width)); // yStride// 10 for (int i = 0; i < channelCount; i++) { @@ -247,10 +251,11 @@ readFile (const std::string& copy_filename, int channelCount) str, // name // 6 DeepSlice ( type, // type // 7 - (char*) (&data[i][0][0] - dataWindow.min.x - dataWindow.min.y * width), // base // 8) - pointerSize * 1, // xStride// 9 - pointerSize * width, // yStride// 10 - sampleSize)); // sampleStride + (char*) (&data[i][0][0] - dataWindow.min.x - + dataWindow.min.y * width), // base // 8) + pointerSize * 1, // xStride// 9 + pointerSize * width, // yStride// 10 + sampleSize)); // sampleStride } file.setFrameBuffer (frameBuffer); @@ -328,9 +333,10 @@ readFile (const std::string& copy_filename, int channelCount) for (int j = 0; j < width; j++) for (int k = 0; k < channelCount; k++) { - if (channelTypes[k] == 0) delete[](unsigned int*) data[k][i][j]; - if (channelTypes[k] == 1) delete[](half*) data[k][i][j]; - if (channelTypes[k] == 2) delete[](float*) data[k][i][j]; + if (channelTypes[k] == 0) + delete[] (unsigned int*) data[k][i][j]; + if (channelTypes[k] == 1) delete[] (half*) data[k][i][j]; + if (channelTypes[k] == 2) delete[] (float*) data[k][i][j]; } } diff --git a/src/test/OpenEXRTest/testCopyDeepTiled.cpp b/src/test/OpenEXRTest/testCopyDeepTiled.cpp index fd50db5c73..9801ea4129 100644 --- a/src/test/OpenEXRTest/testCopyDeepTiled.cpp +++ b/src/test/OpenEXRTest/testCopyDeepTiled.cpp @@ -219,10 +219,11 @@ generateRandomFile ( for (int k = 0; k < channelCount; k++) { if (channelTypes[k] == 0) - delete[](unsigned int*) data[k][i][j]; - if (channelTypes[k] == 1) delete[](half*) data[k][i][j]; + delete[] (unsigned int*) data[k][i][j]; + if (channelTypes[k] == 1) + delete[] (half*) data[k][i][j]; if (channelTypes[k] == 2) - delete[](float*) data[k][i][j]; + delete[] (float*) data[k][i][j]; } } } @@ -443,10 +444,11 @@ readFile (int channelCount, const std::string& cpyFn) for (int k = 0; k < channelCount; k++) { if (channelTypes[k] == 0) - delete[](unsigned int*) data[k][i][j]; - if (channelTypes[k] == 1) delete[](half*) data[k][i][j]; + delete[] (unsigned int*) data[k][i][j]; + if (channelTypes[k] == 1) + delete[] (half*) data[k][i][j]; if (channelTypes[k] == 2) - delete[](float*) data[k][i][j]; + delete[] (float*) data[k][i][j]; } } } diff --git a/src/test/OpenEXRTest/testDeepScanLineBasic.cpp b/src/test/OpenEXRTest/testDeepScanLineBasic.cpp index 61cfde844e..0f66822b53 100644 --- a/src/test/OpenEXRTest/testDeepScanLineBasic.cpp +++ b/src/test/OpenEXRTest/testDeepScanLineBasic.cpp @@ -94,9 +94,10 @@ generateRandomFile ( frameBuffer.insertSampleCountSlice (Slice ( IMF::UINT, // type // 7 - (char*) (&sampleCount[0][0] - dataWindow.min.x - dataWindow.min.y * width), // base - sizeof (unsigned int) * 1, // xStride - sizeof (unsigned int) * width)); // yStride + (char*) (&sampleCount[0][0] - dataWindow.min.x - + dataWindow.min.y * width), // base + sizeof (unsigned int) * 1, // xStride + sizeof (unsigned int) * width)); // yStride for (int i = 0; i < channelCount; i++) { @@ -120,10 +121,11 @@ generateRandomFile ( str, // name // 6 DeepSlice ( type, // type // 7 - (char*) (&data[i][0][0] - dataWindow.min.x - dataWindow.min.y * width), // base // 8 - pointerSize * 1, // xStride// 9 - pointerSize * width, // yStride// 10 - sampleSize)); // sampleStride + (char*) (&data[i][0][0] - dataWindow.min.x - + dataWindow.min.y * width), // base // 8 + pointerSize * 1, // xStride// 9 + pointerSize * width, // yStride// 10 + sampleSize)); // sampleStride } file.setFrameBuffer (frameBuffer); @@ -175,10 +177,7 @@ generateRandomFile ( (i * width + j) % 2049; } } - else - { - data[k][i][j] = nullptr; - } + else { data[k][i][j] = nullptr; } } } } @@ -226,10 +225,7 @@ generateRandomFile ( (i * width + j) % 2049; } } - else - { - data[k][i][j] = nullptr; - } + else { data[k][i][j] = nullptr; } } } file.writePixels (1); @@ -240,9 +236,10 @@ generateRandomFile ( for (int j = 0; j < width; j++) for (int k = 0; k < channelCount; k++) { - if (channelTypes[k] == 0) delete[](unsigned int*) data[k][i][j]; - if (channelTypes[k] == 1) delete[](half*) data[k][i][j]; - if (channelTypes[k] == 2) delete[](float*) data[k][i][j]; + if (channelTypes[k] == 0) + delete[] (unsigned int*) data[k][i][j]; + if (channelTypes[k] == 1) delete[] (half*) data[k][i][j]; + if (channelTypes[k] == 2) delete[] (float*) data[k][i][j]; } } @@ -254,10 +251,7 @@ readFile ( bool randomChannels) { if (randomChannels) { cout << " reading random channels " << flush; } - else - { - cout << " reading all channels " << flush; - } + else { cout << " reading all channels " << flush; } DeepScanLineInputFile file (filename.c_str (), 8); @@ -291,9 +285,10 @@ readFile ( frameBuffer.insertSampleCountSlice (Slice ( IMF::UINT, // type // 7 - (char*) (&localSampleCount[0][0] - dataWindow.min.x - dataWindow.min.y * width), // base // 8) - sizeof (unsigned int) * 1, // xStride// 9 - sizeof (unsigned int) * width)); // yStride// 10 + (char*) (&localSampleCount[0][0] - dataWindow.min.x - + dataWindow.min.y * width), // base // 8) + sizeof (unsigned int) * 1, // xStride// 9 + sizeof (unsigned int) * width)); // yStride// 10 vector read_channel (channelCount); @@ -324,10 +319,11 @@ readFile ( str, // name // 6 DeepSlice ( type, // type // 7 - (char*) (&data[i][0][0] - dataWindow.min.x - dataWindow.min.y * width), // base // 8) - pointerSize * 1, // xStride// 9 - pointerSize * width, // yStride// 10 - sampleSize)); // sampleStride + (char*) (&data[i][0][0] - dataWindow.min.x - + dataWindow.min.y * width), // base // 8) + pointerSize * 1, // xStride// 9 + pointerSize * width, // yStride// 10 + sampleSize)); // sampleStride channels_added++; } } @@ -346,14 +342,15 @@ readFile ( // generate channel names that aren't in file but (might) interleave with existing file ss << i << "fill"; string str = ss.str (); - frameBuffer.insert (str, // name // 6 - DeepSlice (type, // type // 7 - (char *) (&data[i+channelCount][0][0] - - dataWindow.min.x - - dataWindow.min.y * width), // base // 8) - pointerSize * 1, // xStride// 9 - pointerSize * width, // yStride// 10 - sampleSize)); // sampleStride + frameBuffer.insert ( + str, // name // 6 + DeepSlice ( + type, // type // 7 + (char*) (&data[i + channelCount][0][0] - dataWindow.min.x - + dataWindow.min.y * width), // base // 8) + pointerSize * 1, // xStride// 9 + pointerSize * width, // yStride// 10 + sampleSize)); // sampleStride } file.setFrameBuffer (frameBuffer); @@ -381,10 +378,7 @@ readFile ( if (channelTypes[k] == 2) data[k][i][j] = new float[localSampleCount[i][j]]; } - else - { - data[k][i][j] = nullptr; - } + else { data[k][i][j] = nullptr; } } for (int f = 0; f < fillChannels; ++f) { @@ -423,10 +417,7 @@ readFile ( if (channelTypes[k] == 2) data[k][i][j] = new float[localSampleCount[i][j]]; } - else - { - data[k][i][j] = nullptr; - } + else { data[k][i][j] = nullptr; } } for (int f = 0; f < fillChannels; ++f) { @@ -499,14 +490,14 @@ readFile ( if (!randomChannels || read_channel[k] == 1) { if (channelTypes[k] == 0) - delete[](unsigned int*) data[k][i][j]; - if (channelTypes[k] == 1) delete[](half*) data[k][i][j]; - if (channelTypes[k] == 2) delete[](float*) data[k][i][j]; + delete[] (unsigned int*) data[k][i][j]; + if (channelTypes[k] == 1) delete[] (half*) data[k][i][j]; + if (channelTypes[k] == 2) delete[] (float*) data[k][i][j]; } } for (int f = 0; f < fillChannels; ++f) { - delete[](float*) data[f + channelCount][i][j]; + delete[] (float*) data[f + channelCount][i][j]; } } } diff --git a/src/test/OpenEXRTest/testDeepScanLineHuge.cpp b/src/test/OpenEXRTest/testDeepScanLineHuge.cpp index 877d9b1243..ea8b746e0e 100644 --- a/src/test/OpenEXRTest/testDeepScanLineHuge.cpp +++ b/src/test/OpenEXRTest/testDeepScanLineHuge.cpp @@ -105,9 +105,10 @@ generateRandomFile ( frameBuffer.insertSampleCountSlice (Slice ( IMF::UINT, // type // 7 - (char*) (&sampleCount[0][0] - dataWindow.min.x - dataWindow.min.y * width), // base // 8 - sizeof (unsigned int) * 1, // xStride// 9 - sizeof (unsigned int) * width)); // yStride// 10 + (char*) (&sampleCount[0][0] - dataWindow.min.x - + dataWindow.min.y * width), // base // 8 + sizeof (unsigned int) * 1, // xStride// 9 + sizeof (unsigned int) * width)); // yStride// 10 // count total size of all pixels uint64_t bytes_per_sample = 0; @@ -135,10 +136,11 @@ generateRandomFile ( str, // name // 6 DeepSlice ( type, // type // 7 - (char*) (&data[i][0][0] - dataWindow.min.x - dataWindow.min.y * width), // base // 8 - pointerSize * 1, // xStride// 9 - pointerSize * width, // yStride// 10 - sampleSize)); // sampleStride + (char*) (&data[i][0][0] - dataWindow.min.x - + dataWindow.min.y * width), // base // 8 + pointerSize * 1, // xStride// 9 + pointerSize * width, // yStride// 10 + sampleSize)); // sampleStride } file.setFrameBuffer (frameBuffer); @@ -265,9 +267,10 @@ readFile (int channelCount, bool bulkRead, const std::string& fn) frameBuffer.insertSampleCountSlice (Slice ( IMF::UINT, // type // 7 - (char*) (&localSampleCount[0][0] - dataWindow.min.x - dataWindow.min.y * width), // base // 8) - sizeof (unsigned int) * 1, // xStride// 9 - sizeof (unsigned int) * width)); // yStride// 10 + (char*) (&localSampleCount[0][0] - dataWindow.min.x - + dataWindow.min.y * width), // base // 8) + sizeof (unsigned int) * 1, // xStride// 9 + sizeof (unsigned int) * width)); // yStride// 10 uint64_t bytes_per_sample = 0; @@ -295,10 +298,11 @@ readFile (int channelCount, bool bulkRead, const std::string& fn) str, // name // 6 DeepSlice ( type, // type // 7 - (char*) (&data[i][0][0] - dataWindow.min.x - dataWindow.min.y * width), // base // 8) - pointerSize * 1, // xStride// 9 - pointerSize * width, // yStride// 10 - sampleSize)); // sampleStride + (char*) (&data[i][0][0] - dataWindow.min.x - + dataWindow.min.y * width), // base // 8) + pointerSize * 1, // xStride// 9 + pointerSize * width, // yStride// 10 + sampleSize)); // sampleStride } file.setFrameBuffer (frameBuffer); diff --git a/src/test/OpenEXRTest/testDeepTiledBasic.cpp b/src/test/OpenEXRTest/testDeepTiledBasic.cpp index e8c74ead2b..dd99e4b635 100644 --- a/src/test/OpenEXRTest/testDeepTiledBasic.cpp +++ b/src/test/OpenEXRTest/testDeepTiledBasic.cpp @@ -356,12 +356,12 @@ generateRandomFile ( int ty = y - box.min.y; int tx = x - box.min.x; if (channelTypes[k] == 0) - delete[](unsigned int*) - data[k][ty][tx]; + delete[] ( + unsigned int*) data[k][ty][tx]; if (channelTypes[k] == 1) - delete[](half*) data[k][ty][tx]; + delete[] (half*) data[k][ty][tx]; if (channelTypes[k] == 2) - delete[](float*) data[k][ty][tx]; + delete[] (float*) data[k][ty][tx]; } } } @@ -375,11 +375,11 @@ generateRandomFile ( for (int k = 0; k < channelCount; k++) { if (channelTypes[k] == 0) - delete[](unsigned int*) data[k][i][j]; + delete[] (unsigned int*) data[k][i][j]; if (channelTypes[k] == 1) - delete[](half*) data[k][i][j]; + delete[] (half*) data[k][i][j]; if (channelTypes[k] == 2) - delete[](float*) data[k][i][j]; + delete[] (float*) data[k][i][j]; } } } @@ -750,18 +750,19 @@ readFile ( dwx, dwy); if (channelTypes[k] == 0) - delete[](unsigned int*) + delete[] (unsigned int*) data[k][ty][tx]; if (channelTypes[k] == 1) - delete[](half*) data[k][ty][tx]; + delete[] ( + half*) data[k][ty][tx]; if (channelTypes[k] == 2) - delete[](float*) - data[k][ty][tx]; + delete[] ( + float*) data[k][ty][tx]; } } for (int f = 0; f < fillChannels; ++f) { - delete[](float*) + delete[] (float*) data[f + channelTypes.size ()][ty] [tx]; } @@ -838,16 +839,16 @@ readFile ( for (int k = 0; k < channelCount; k++) { if (channelTypes[k] == 0) - delete[](unsigned int*) data[k][i][j]; + delete[] (unsigned int*) data[k][i][j]; if (channelTypes[k] == 1) - delete[](half*) data[k][i][j]; + delete[] (half*) data[k][i][j]; if (channelTypes[k] == 2) - delete[](float*) data[k][i][j]; + delete[] (float*) data[k][i][j]; } for (int f = 0; f < fillChannels; ++f) { - delete[](float*) - data[f + channelTypes.size ()][i][j]; + delete[] ( + float*) data[f + channelTypes.size ()][i][j]; } } } diff --git a/src/test/OpenEXRTest/testDwaCompressorSimd.cpp b/src/test/OpenEXRTest/testDwaCompressorSimd.cpp index 4ba2091e00..a36810770d 100644 --- a/src/test/OpenEXRTest/testDwaCompressorSimd.cpp +++ b/src/test/OpenEXRTest/testDwaCompressorSimd.cpp @@ -283,10 +283,7 @@ testDct () { \ orig._buffer[i] = test._buffer[i] = rand48.nextf (); \ } \ - else \ - { \ - orig._buffer[i] = test._buffer[i] = 0; \ - } \ + else { orig._buffer[i] = test._buffer[i] = 0; } \ } \ dctInverse8x8_scalar<0> (orig._buffer); \ _func<_n> (test._buffer); \ @@ -353,10 +350,7 @@ testFloatToHalf () { src._buffer[i] = (float) 140000 * (rand48.nextf () - .5); } - else - { - src._buffer[i] = (float) (rand48.nextf () - .5); - } + else { src._buffer[i] = (float) (rand48.nextf () - .5); } dst._buffer[i] = 0; } @@ -386,10 +380,7 @@ testFloatToHalf () { src._buffer[i] = (float) 140000 * (rand48.nextf () - .5); } - else - { - src._buffer[i] = (float) (rand48.nextf () - .5); - } + else { src._buffer[i] = (float) (rand48.nextf () - .5); } dst._buffer[i] = 0; } @@ -437,7 +428,7 @@ testFloatToHalf () } } } - #endif // IMF_HAVE_NEON_AARCH64 +#endif // IMF_HAVE_NEON_AARCH64 } // @@ -497,10 +488,7 @@ testFromHalfZigZag () for (int i = 0; i < 64; ++i) { if (i < 32) { h = (half) (140000. * (rand48.nextf () - .5)); } - else - { - h = (half) (rand48.nextf () - .5); - } + else { h = (half) (rand48.nextf () - .5); } src._buffer[i] = h.bits (); } @@ -521,7 +509,7 @@ testFromHalfZigZag () } // f16c #ifdef IMF_HAVE_NEON_AARCH64 - { + { const int numIter = 1000000; Rand48 rand48 (0); half h; @@ -534,10 +522,7 @@ testFromHalfZigZag () for (int i = 0; i < 64; ++i) { if (i < 32) { h = (half) (140000. * (rand48.nextf () - .5)); } - else - { - h = (half) (rand48.nextf () - .5); - } + else { h = (half) (rand48.nextf () - .5); } src._buffer[i] = h.bits (); } diff --git a/src/test/OpenEXRTest/testExistingStreams.cpp b/src/test/OpenEXRTest/testExistingStreams.cpp index 16ba9ab3dd..e9952494bc 100644 --- a/src/test/OpenEXRTest/testExistingStreams.cpp +++ b/src/test/OpenEXRTest/testExistingStreams.cpp @@ -26,10 +26,10 @@ #ifdef _WIN32 #else -#include -#include -#include -#include +# include +# include +# include +# include #endif #include @@ -108,10 +108,10 @@ class MMIFStream : public OPENEXR_IMF_NAMESPACE::IStream #else int _f; #endif - void* _mmap; + void* _mmap; const char* _mmapStart; - uint64_t _pos; - uint64_t _length; + uint64_t _pos; + uint64_t _length; }; MMIFStream::MMIFStream (const char fileName[]) @@ -121,7 +121,7 @@ MMIFStream::MMIFStream (const char fileName[]) #else , _f (-1) #endif - , _mmap (reinterpret_cast(-1)) + , _mmap (reinterpret_cast (-1)) , _mmapStart (nullptr) , _pos (0) , _length (0) @@ -158,10 +158,7 @@ MMIFStream::MMIFStream (const char fileName[]) _length = s.st_size; _mmap = CreateFileMapping (_f, 0, PAGE_READONLY, 0, 0, 0); - if (!_mmap) - { - throw IEX_NAMESPACE::IoExc ("Cannot memory map file."); - } + if (!_mmap) { throw IEX_NAMESPACE::IoExc ("Cannot memory map file."); } _mmapStart = reinterpret_cast ( MapViewOfFile (_mmap, FILE_MAP_READ, 0, 0, 0)); @@ -172,23 +169,20 @@ MMIFStream::MMIFStream (const char fileName[]) #else - _f = open(fileName, O_RDONLY); - if (-1 == _f) - { - throw IEX_NAMESPACE::IoExc ("Cannot open file."); - } + _f = open (fileName, O_RDONLY); + if (-1 == _f) { throw IEX_NAMESPACE::IoExc ("Cannot open file."); } struct stat s; - memset(&s, 0, sizeof(struct stat)); - if (stat(fileName, &s) != 0) + memset (&s, 0, sizeof (struct stat)); + if (stat (fileName, &s) != 0) { throw IEX_NAMESPACE::IoExc ("Cannot stat file."); } _length = s.st_size; - _mmap = mmap(0, _length, PROT_READ, MAP_SHARED, _f, 0); - if (_mmap == (void*)-1) + _mmap = mmap (0, _length, PROT_READ, MAP_SHARED, _f, 0); + if (_mmap == (void*) -1) { throw IEX_NAMESPACE::IoExc ("Cannot memory map file."); } @@ -200,29 +194,14 @@ MMIFStream::MMIFStream (const char fileName[]) MMIFStream::~MMIFStream () { #ifdef _WIN32 - if (_mmapStart) - { - UnmapViewOfFile ((void*) _mmapStart); - } - if (_mmap) - { - CloseHandle (_mmap); - } - if (_f != INVALID_HANDLE_VALUE) - { - CloseHandle (_f); - } + if (_mmapStart) { UnmapViewOfFile ((void*) _mmapStart); } + if (_mmap) { CloseHandle (_mmap); } + if (_f != INVALID_HANDLE_VALUE) { CloseHandle (_f); } #else - if (_mmap != (void*)-1) - { - munmap(_mmap, _length); - } - if (_f != -1) - { - close(_f); - } + if (_mmap != (void*) -1) { munmap (_mmap, _length); } + if (_f != -1) { close (_f); } #endif } @@ -255,17 +234,17 @@ MMIFStream::readMemoryMapped (int n) if (_pos + n > _length) throw IEX_NAMESPACE::InputExc ("Reading past end of file."); - char* retVal = const_cast(_mmapStart) + _pos; + char* retVal = const_cast (_mmapStart) + _pos; _pos += n; return retVal; } void writeReadScanLines ( - const char fileName[], - int width, - int height, - Compression compression, + const char fileName[], + int width, + int height, + Compression compression, const Array2D& p1) { // @@ -288,7 +267,7 @@ writeReadScanLines ( testutil::OpenStreamWithUTF8Name ( os, fileName, ios::out | ios_base::binary); StdOFStream ofs (os, fileName); - Header header ( + Header header ( width, height, 1, @@ -350,7 +329,7 @@ writeReadScanLines ( in.setFrameBuffer (&p2[-dy][-dx], 1, w); in.readPixels (dw.min.y, dw.max.y); - if (!isLossyCompression(compression)) + if (!isLossyCompression (compression)) { cout << ", comparing"; for (int y = 0; y < h; ++y) @@ -373,10 +352,10 @@ writeReadScanLines ( void writeReadMultiPart ( - const char fileName[], - int width, - int height, - Compression compression, + const char fileName[], + int width, + int height, + Compression compression, const Array2D& p1) { // @@ -606,10 +585,10 @@ writeReadMultiPart ( void writeReadTiles ( - const char fileName[], - int width, - int height, - Compression compression, + const char fileName[], + int width, + int height, + Compression compression, const Array2D& p1) { // @@ -630,7 +609,7 @@ writeReadTiles ( testutil::OpenStreamWithUTF8Name ( os, fileName, ios_base::out | ios_base::binary); StdOFStream ofs (os, fileName); - Header header ( + Header header ( width, height, 1, @@ -1005,29 +984,29 @@ testExistingStreams (const std::string& tempDir) fillPixels1 (p1, W, H); writeReadScanLines ( - (tempDir + "imf_test_streams.exr").c_str (), - W, - H, - static_cast(compression), - p1); + (tempDir + "imf_test_streams.exr").c_str (), + W, + H, + static_cast (compression), + p1); writeReadScanLines (W, H, p1); fillPixels2 (p1, W, H); writeReadTiles ( - (tempDir + "imf_test_streams2.exr").c_str (), - W, - H, + (tempDir + "imf_test_streams2.exr").c_str (), + W, + H, static_cast (compression), - p1); + p1); writeReadTiles (W, H, p1); fillPixels1 (p1, W, H); writeReadMultiPart ( - (tempDir + "imf_test_streams3.exr").c_str (), - W, - H, + (tempDir + "imf_test_streams3.exr").c_str (), + W, + H, static_cast (compression), - p1); + p1); writeReadMultiPart (W, H, p1); } diff --git a/src/test/OpenEXRTest/testFutureProofing.cpp b/src/test/OpenEXRTest/testFutureProofing.cpp index d01e915f5e..feef42e9fd 100644 --- a/src/test/OpenEXRTest/testFutureProofing.cpp +++ b/src/test/OpenEXRTest/testFutureProofing.cpp @@ -822,10 +822,7 @@ readWholeFiles (int modification) { assert (header.type () != headers[i].type ()); } - else - { - assert (header.type () == headers[i].type ()); - } + else { assert (header.type () == headers[i].type ()); } } cout << "Reading whole files " << flush; diff --git a/src/test/OpenEXRTest/testHeader.cpp b/src/test/OpenEXRTest/testHeader.cpp index d0854b7d70..7160a1f923 100644 --- a/src/test/OpenEXRTest/testHeader.cpp +++ b/src/test/OpenEXRTest/testHeader.cpp @@ -21,35 +21,35 @@ using namespace IMATH_NAMESPACE; using namespace OPENEXR_IMF_NAMESPACE; using namespace std; -template -struct Test +template struct Test { - void testFind(const string& name) + void testFind (const string& name) { Header header; - auto iterator = header.find(name); - assert(iterator != header.end()); + auto iterator = header.find (name); + assert (iterator != header.end ()); } - void testSubscript(const string& name) + void testSubscript (const string& name) { Header header; - auto& comparand = header.find("displayWindow").attribute(); - auto& attribute = header[name]; - assert(&attribute == &comparand); + auto& comparand = header.find ("displayWindow").attribute (); + auto& attribute = header[name]; + assert (&attribute == &comparand); } - void testIterators(const string& name) + void testIterators (const string& name) { Header header; - auto& comparand = header.find("displayWindow").attribute(); + auto& comparand = header.find ("displayWindow").attribute (); - for (auto iterator = header.begin(); iterator != header.end(); ++iterator) + for (auto iterator = header.begin (); iterator != header.end (); + ++iterator) { - if (iterator.name() == name) + if (iterator.name () == name) { - assert(&iterator.attribute() == &comparand); + assert (&iterator.attribute () == &comparand); return; } } @@ -58,21 +58,23 @@ struct Test } }; -void testEraseAttribute(const string& name) +void +testEraseAttribute (const string& name) { Header header; - assert(header.find(name) != header.end()); - header.erase(name); - assert(header.find(name) == header.end()); + assert (header.find (name) != header.end ()); + header.erase (name); + assert (header.find (name) == header.end ()); } -void testEraseAttributeThrowsWithEmptyString() +void +testEraseAttributeThrowsWithEmptyString () { Header header; try { - header.erase(""); + header.erase (""); assert (false); } catch (const ArgExc&) @@ -81,24 +83,25 @@ void testEraseAttributeThrowsWithEmptyString() } } -void testHeader (const string& tempDir) +void +testHeader (const string& tempDir) { try { { Test
headerTest; - headerTest.testFind("displayWindow"); - headerTest.testSubscript("displayWindow"); - headerTest.testIterators("displayWindow"); + headerTest.testFind ("displayWindow"); + headerTest.testSubscript ("displayWindow"); + headerTest.testIterators ("displayWindow"); } { Test headerTest; - headerTest.testFind("displayWindow"); - headerTest.testSubscript("displayWindow"); - headerTest.testIterators("displayWindow"); + headerTest.testFind ("displayWindow"); + headerTest.testSubscript ("displayWindow"); + headerTest.testIterators ("displayWindow"); } - testEraseAttribute("displayWindow"); - testEraseAttributeThrowsWithEmptyString(); + testEraseAttribute ("displayWindow"); + testEraseAttributeThrowsWithEmptyString (); cout << "ok\n" << endl; } catch (const exception& e) diff --git a/src/test/OpenEXRTest/testHuf.cpp b/src/test/OpenEXRTest/testHuf.cpp index df30c89382..e3bb7bda1e 100644 --- a/src/test/OpenEXRTest/testHuf.cpp +++ b/src/test/OpenEXRTest/testHuf.cpp @@ -31,8 +31,8 @@ fill1 ( IMATH_NAMESPACE::Rand48& rand48) { for (int i = 0; i < n; ++i) - data[i] = - (unsigned short) (pow (rand48.nextf (), double (bias)) * (USHRT_MAX + 1)); + data[i] = (unsigned short) (pow (rand48.nextf (), double (bias)) * + (USHRT_MAX + 1)); } void @@ -194,10 +194,7 @@ compressVerify (const unsigned short raw[], int n, const unsigned int dekHash) { cout << std::hex << (0xFF & (int) (*cptr++)); if ((i & 0xF) == 0) { cout << '\n'; } - else - { - cout << ' '; - } + else { cout << ' '; } } cout << "\n"; } diff --git a/src/test/OpenEXRTest/testIDManifest.cpp b/src/test/OpenEXRTest/testIDManifest.cpp index 135b931ca9..6b2aaa4c3b 100644 --- a/src/test/OpenEXRTest/testIDManifest.cpp +++ b/src/test/OpenEXRTest/testIDManifest.cpp @@ -69,10 +69,7 @@ operator<< (std::ostream& out, const IDManifest& mfst) ++s) { if (!first) { out << ','; } - else - { - first = false; - } + else { first = false; } out << *s; } @@ -136,8 +133,8 @@ doReadWriteManifest (const IDManifest& mfst, const string& fn, bool dump) // // allocate a buffer which is guaranteed to be big enough for compression // - size_t sourceDataSize = str.str ().size (); - size_t compressedDataSize = exr_compress_max_buffer_size (sourceDataSize); + size_t sourceDataSize = str.str ().size (); + size_t compressedDataSize = exr_compress_max_buffer_size (sourceDataSize); vector compressed (compressedDataSize); exr_compress_buffer ( @@ -302,19 +299,10 @@ randomWord (bool alphaNumeric, const std::vector& options) int index = random_int (62); // 26 letters*2 for case + 10 digits if (index < 26) { word[l] = 'A' + index; } - else if (index < 52) - { - word[l] = 'a' + (index - 26); - } - else - { - word[l] = '0' + (index - 52); - } - } - else - { - word[l] = random_int (256); + else if (index < 52) { word[l] = 'a' + (index - 26); } + else { word[l] = '0' + (index - 52); } } + else { word[l] = random_int (256); } } return word; } diff --git a/src/test/OpenEXRTest/testLargeDataWindowOffsets.cpp b/src/test/OpenEXRTest/testLargeDataWindowOffsets.cpp index db7f860745..4973a3fc30 100644 --- a/src/test/OpenEXRTest/testLargeDataWindowOffsets.cpp +++ b/src/test/OpenEXRTest/testLargeDataWindowOffsets.cpp @@ -103,10 +103,7 @@ compare ( default: cout << "don't know about that\n"; exit (1); } } - else - { - writtenHalf = half (i.slice ().fillValue); - } + else { writtenHalf = half (i.slice ().fillValue); } if (writtenHalf.bits () != readHalf.bits ()) { @@ -155,10 +152,7 @@ setupBuffer ( size_t size = samples * 4; if (writing) { writingBuffer.resize (size); } - else - { - readingBuffer.resize (size); - } + else { readingBuffer.resize (size); } const char* write_ptr = writing ? &writingBuffer[0] : &readingBuffer[0]; // fill with random halfs, casting to floats for float channels - don't write NaN values @@ -178,10 +172,7 @@ setupBuffer ( { *(half*) write_ptr = half (v); } - else - { - *(float*) write_ptr = float (v); - } + else { *(float*) write_ptr = float (v); } chan++; write_ptr += 4; if (chan == activechans) { chan = 0; } @@ -377,10 +368,7 @@ test (int testCount) if (hdr.compression () < 5) { if (compare (readFrameBuf, writeFrameBuf, dw)) { cout << " OK "; } - else - { - cout << " FAIL" << endl; - } + else { cout << " FAIL" << endl; } } cout << "\n"; } diff --git a/src/test/OpenEXRTest/testMultiPartApi.cpp b/src/test/OpenEXRTest/testMultiPartApi.cpp index 7981dafa25..64672c2ae7 100644 --- a/src/test/OpenEXRTest/testMultiPartApi.cpp +++ b/src/test/OpenEXRTest/testMultiPartApi.cpp @@ -467,10 +467,7 @@ generateRandomFile (int partCount, const std::string& fn) int partType = partTypes[i]; if (partType == 0) { delete (OutputPart*) parts[i]; } - else - { - delete (TiledOutputPart*) parts[i]; - } + else { delete (TiledOutputPart*) parts[i]; } } delete[] tiledHalfData; diff --git a/src/test/OpenEXRTest/testMultiPartThreading.cpp b/src/test/OpenEXRTest/testMultiPartThreading.cpp index 293034b7b9..fc25bc21d3 100644 --- a/src/test/OpenEXRTest/testMultiPartThreading.cpp +++ b/src/test/OpenEXRTest/testMultiPartThreading.cpp @@ -637,10 +637,7 @@ generateRandomFile (int partCount, const std::string& fn) for (int i = 0; i < partCount; i++) { if (partTypes[i] == 0) { delete (OutputPart*) parts[i]; } - else - { - delete (TiledOutputPart*) parts[i]; - } + else { delete (TiledOutputPart*) parts[i]; } } delete threadPool; diff --git a/src/test/OpenEXRTest/testOptimizedInterleavePatterns.cpp b/src/test/OpenEXRTest/testOptimizedInterleavePatterns.cpp index 155be2bb90..ae9a27de71 100644 --- a/src/test/OpenEXRTest/testOptimizedInterleavePatterns.cpp +++ b/src/test/OpenEXRTest/testOptimizedInterleavePatterns.cpp @@ -58,7 +58,7 @@ struct Schema const char* _name; // name of this scheme const char* const* _active; // channels to be read const char* const* - _passive; // channels to be ignored (keep in buffer passed to inputfile, should not be overwritten) + _passive; // channels to be ignored (keep in buffer passed to inputfile, should not be overwritten) int _banks; const char* const* _views; // list of views to write, or NULL const PixelType* _types; // NULL for all HALF, otherwise per-channel type @@ -252,10 +252,7 @@ compare ( default: cout << "don't know about that\n"; exit (1); } } - else - { - writtenHalf = half (i.slice ().fillValue); - } + else { writtenHalf = half (i.slice ().fillValue); } if (writtenHalf.bits () != readHalf.bits ()) { @@ -289,10 +286,11 @@ setupBuffer ( FrameBuffer& prereadbuf, // channels which aren't being read - indexes into the preread buffer FrameBuffer& - postreadbuf, // channels which aren't being read - indexes into the postread buffer - int banks, // number of banks - channels within each bank are interleaved, banks are scanline interleaved + postreadbuf, // channels which aren't being read - indexes into the postread buffer + int banks, // number of banks - channels within each bank are interleaved, banks are scanline interleaved bool writing, // true if should allocate - bool allowNonfinite // true if the buffer is allowed to create infinity or NaN values + bool + allowNonfinite // true if the buffer is allowed to create infinity or NaN values ) { Box2i dw = hdr.dataWindow (); @@ -361,10 +359,7 @@ setupBuffer ( int size = samples * bytes_per_pixel; if (writing) { writingBuffer.resize (size); } - else - { - readingBuffer.resize (size); - } + else { readingBuffer.resize (size); } const char* write_ptr = writing ? &writingBuffer[0] : &readingBuffer[0]; // fill with random halfs, casting to floats for float channels @@ -381,7 +376,7 @@ setupBuffer ( unsigned short int values = random_int (std::numeric_limits::max ()); v.setBits (values); - } while(!( (v-v)==0 || allowNonfinite )); + } while (!((v - v) == 0 || allowNonfinite)); if (pt == NULL || pt[chan] == IMF::HALF) { @@ -490,7 +485,7 @@ setupBuffer ( } Box2i -writefile (Schema& scheme, FrameBuffer& buf, bool tiny , bool allowNonfinite) +writefile (Schema& scheme, FrameBuffer& buf, bool tiny, bool allowNonfinite) { const int height = 128; const int width = 128; @@ -548,7 +543,7 @@ readfile ( FrameBuffer& buf, ///< list of channels to read: index to readingBuffer FrameBuffer& preread, ///< list of channels to skip: index to preReadBuffer FrameBuffer& - postread, ///< list of channels to skip: index to readingBuffer) + postread, ///< list of channels to skip: index to readingBuffer) bool allowNonfinite) { InputFile infile (filename.c_str ()); @@ -583,14 +578,19 @@ test (Schema writeScheme, Schema readScheme, bool nonfatal, bool tiny) FrameBuffer writeFrameBuf; // only allow NaN and infinity values if file is read and written as half float // (otherwise casting between half and float may cause different bit patterns) - bool allowNonfinite = (writeScheme._types == nullptr && readScheme._types==nullptr); - Box2i dw = writefile (writeScheme, writeFrameBuf, tiny , allowNonfinite); + bool allowNonfinite = + (writeScheme._types == nullptr && readScheme._types == nullptr); + Box2i dw = writefile (writeScheme, writeFrameBuf, tiny, allowNonfinite); FrameBuffer readFrameBuf; FrameBuffer preReadFrameBuf; FrameBuffer postReadFrameBuf; cout.flush (); - bool opt = - readfile (readScheme, readFrameBuf, preReadFrameBuf, postReadFrameBuf,allowNonfinite); + bool opt = readfile ( + readScheme, + readFrameBuf, + preReadFrameBuf, + postReadFrameBuf, + allowNonfinite); if (compare (readFrameBuf, writeFrameBuf, dw, nonfatal) && compare (preReadFrameBuf, postReadFrameBuf, dw, nonfatal)) { @@ -637,10 +637,7 @@ runtests (bool nonfatal, bool tiny) << Schemes[j]._name << ": known to crash\n"; skipped++; } - else - { - test (Schemes[i], Schemes[j], nonfatal, tiny); - } + else { test (Schemes[i], Schemes[j], nonfatal, tiny); } j++; } i++; diff --git a/src/test/OpenEXRTest/testRgba.cpp b/src/test/OpenEXRTest/testRgba.cpp index fcec76e2d5..b73bcb2282 100644 --- a/src/test/OpenEXRTest/testRgba.cpp +++ b/src/test/OpenEXRTest/testRgba.cpp @@ -348,10 +348,7 @@ void writeReadLayers (const std::string& tempDir, bool multiPart) { if (multiPart) { cout << "\nreading multi-part file" << endl; } - else - { - cout << "\nreading multi-layer file" << endl; - } + else { cout << "\nreading multi-layer file" << endl; } std::string fileName = tempDir + "imf_test_multi_layer_rgba.exr"; diff --git a/src/test/OpenEXRTest/testSharedFrameBuffer.cpp b/src/test/OpenEXRTest/testSharedFrameBuffer.cpp index 0f181b00d2..66107a6e4e 100644 --- a/src/test/OpenEXRTest/testSharedFrameBuffer.cpp +++ b/src/test/OpenEXRTest/testSharedFrameBuffer.cpp @@ -90,10 +90,7 @@ WriterThread::run () _outfile->writePixels (n); remainingScanlines -= n; } - else - { - break; - } + else { break; } } // diff --git a/src/test/OpenEXRTest/testStandardAttributes.cpp b/src/test/OpenEXRTest/testStandardAttributes.cpp index b10e979344..6c8b10c06a 100644 --- a/src/test/OpenEXRTest/testStandardAttributes.cpp +++ b/src/test/OpenEXRTest/testStandardAttributes.cpp @@ -905,7 +905,7 @@ generatedFunctions () assert (hasWrapmodes (header) == false); assert (hasMultiView (header) == false); assert (hasDeepImageState (header) == false); - assert (hasIDManifest(header) == false); + assert (hasIDManifest (header) == false); } } // namespace diff --git a/src/wrappers/python/OpenEXR.cpp b/src/wrappers/python/OpenEXR.cpp index 964b0f5c01..d7e270a3da 100644 --- a/src/wrappers/python/OpenEXR.cpp +++ b/src/wrappers/python/OpenEXR.cpp @@ -8,35 +8,40 @@ #if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) typedef int Py_ssize_t; -#define PY_SSIZE_T_MAX INT_MAX -#define PY_SSIZE_T_MIN INT_MIN +# define PY_SSIZE_T_MAX INT_MAX +# define PY_SSIZE_T_MIN INT_MIN #endif #if PY_MAJOR_VERSION >= 3 - #define MOD_ERROR_VAL NULL - #define MOD_SUCCESS_VAL(val) val - #define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void) - #define MOD_DEF(ob, name, doc, methods) \ - static struct PyModuleDef moduledef = { \ - PyModuleDef_HEAD_INIT, name, doc, -1, methods, }; \ - ob = PyModule_Create(&moduledef); - #define PyInt_FromLong(x) PyLong_FromLong(x) - #define PyInt_AsLong(x) PyLong_AsLong(x) - #define PyInt_Check(x) PyLong_Check(x) - #define PyString_Check(x) PyBytes_Check(x) - #define PyString_AsString(x) PyBytes_AsString(x) - #define PyString_Size(x) PyBytes_Size(x) - #define PyString_FromString(x) PyBytes_FromString(x) - #define PyString_FromStringAndSize(x, y) PyBytes_FromStringAndSize(x, y) - #define PyUTF8_AsSstring(x) PyString_AsString(PyUnicode_AsUTF8String(x)) - #define PyUTF8_FromSstring(x) Something... +# define MOD_ERROR_VAL NULL +# define MOD_SUCCESS_VAL(val) val +# define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name (void) +# define MOD_DEF(ob, name, doc, methods) \ + static struct PyModuleDef moduledef = { \ + PyModuleDef_HEAD_INIT, \ + name, \ + doc, \ + -1, \ + methods, \ + }; \ + ob = PyModule_Create (&moduledef); +# define PyInt_FromLong(x) PyLong_FromLong (x) +# define PyInt_AsLong(x) PyLong_AsLong (x) +# define PyInt_Check(x) PyLong_Check (x) +# define PyString_Check(x) PyBytes_Check (x) +# define PyString_AsString(x) PyBytes_AsString (x) +# define PyString_Size(x) PyBytes_Size (x) +# define PyString_FromString(x) PyBytes_FromString (x) +# define PyString_FromStringAndSize(x, y) PyBytes_FromStringAndSize (x, y) +# define PyUTF8_AsSstring(x) PyString_AsString (PyUnicode_AsUTF8String (x)) +# define PyUTF8_FromSstring(x) Something... #else - #define MOD_ERROR_VAL - #define MOD_SUCCESS_VAL(val) - #define MOD_INIT(name) extern "C" void init##name(void) - #define MOD_DEF(ob, name, doc, methods) \ - ob = Py_InitModule3(name, methods, doc); - #define PyUTF8_AsSstring(x) PyString_AsString(x) +# define MOD_ERROR_VAL +# define MOD_SUCCESS_VAL(val) +# define MOD_INIT(name) extern "C" void init##name (void) +# define MOD_DEF(ob, name, doc, methods) \ + ob = Py_InitModule3 (name, methods, doc); +# define PyUTF8_AsSstring(x) PyString_AsString (x) #endif #include @@ -82,33 +87,35 @@ typedef int Py_ssize_t; #include #include -#define IMATH_VERSION IMATH_VERSION_MAJOR * 10000 + \ - IMATH_VERSION_MINOR * 100 + \ - IMATH_VERSION_PATCH +#define IMATH_VERSION \ + IMATH_VERSION_MAJOR * 10000 + IMATH_VERSION_MINOR * 100 + \ + IMATH_VERSION_PATCH #if IMATH_VERSION >= 30001 -#define Int64 uint64_t -#define SInt64 int64_t +# define Int64 uint64_t +# define SInt64 int64_t #endif using namespace std; using namespace OPENEXR_IMF_NAMESPACE; using namespace IMATH_NAMESPACE; -static PyObject *OpenEXR_error = NULL; -static PyObject *pModuleImath; +static PyObject* OpenEXR_error = NULL; +static PyObject* pModuleImath; -static PyObject *PyObject_StealAttrString(PyObject* o, const char *name) +static PyObject* +PyObject_StealAttrString (PyObject* o, const char* name) { - PyObject *r = PyObject_GetAttrString(o, name); - Py_DECREF(r); + PyObject* r = PyObject_GetAttrString (o, name); + Py_DECREF (r); return r; } -static PyObject *PyObject_Call1(PyObject *f, PyObject* a) +static PyObject* +PyObject_Call1 (PyObject* f, PyObject* a) { - PyObject *r = PyObject_CallObject(f, a); - Py_DECREF(a); + PyObject* r = PyObject_CallObject (f, a); + Py_DECREF (a); return r; } @@ -117,14 +124,15 @@ static PyObject *PyObject_Call1(PyObject *f, PyObject* a) * @param sep The separator * @return The list of strings */ -static std::vector split(const std::string& str, const char sep) +static std::vector +split (const std::string& str, const char sep) { - std::stringstream spliter(str); - std::string token; + std::stringstream spliter (str); + std::string token; std::vector words; - while (std::getline(spliter, token, sep)) { - if (token.size()) - words.push_back(token); + while (std::getline (spliter, token, sep)) + { + if (token.size ()) words.push_back (token); } return words; } @@ -133,594 +141,699 @@ static std::vector split(const std::string& str, const char sep) // Istream and Ostream derivatives //////////////////////////////////////////////////////////////////////// -class C_IStream: public IStream +class C_IStream : public IStream { - public: - C_IStream (PyObject *fo): - IStream(""), _fo(fo) {} - virtual bool read (char c[], int n); - virtual Int64 tellg (); - virtual void seekg (Int64 pos); - virtual void clear (); - virtual const char* fileName() const; - private: - PyObject *_fo; +public: + C_IStream (PyObject* fo) : IStream (""), _fo (fo) {} + virtual bool read (char c[], int n); + virtual Int64 tellg (); + virtual void seekg (Int64 pos); + virtual void clear (); + virtual const char* fileName () const; + +private: + PyObject* _fo; }; bool C_IStream::read (char c[], int n) { - PyObject *data = PyObject_CallMethod(_fo, (char*)"read", (char*)"(i)", n); - if (data != NULL && PyString_AsString(data) && PyString_Size(data) == (Py_ssize_t)n) { - memcpy(c, PyString_AsString(data), PyString_Size(data)); - Py_DECREF(data); - } else { - throw IEX_NAMESPACE::InputExc("file read failed"); + PyObject* data = + PyObject_CallMethod (_fo, (char*) "read", (char*) "(i)", n); + if (data != NULL && PyString_AsString (data) && + PyString_Size (data) == (Py_ssize_t) n) + { + memcpy (c, PyString_AsString (data), PyString_Size (data)); + Py_DECREF (data); } + else { throw IEX_NAMESPACE::InputExc ("file read failed"); } return 0; } -const char* C_IStream::fileName() const +const char* +C_IStream::fileName () const { - return "xxx"; + return "xxx"; } - Int64 C_IStream::tellg () { - PyObject *rv = PyObject_CallMethod(_fo, (char*)"tell", NULL); - if (rv != NULL && PyNumber_Check(rv)) { - PyObject *lrv = PyNumber_Long(rv); - long long t = PyLong_AsLong(lrv); - Py_DECREF(lrv); - Py_DECREF(rv); - return (Int64)t; - } else { - throw IEX_NAMESPACE::InputExc("tell failed"); + PyObject* rv = PyObject_CallMethod (_fo, (char*) "tell", NULL); + if (rv != NULL && PyNumber_Check (rv)) + { + PyObject* lrv = PyNumber_Long (rv); + long long t = PyLong_AsLong (lrv); + Py_DECREF (lrv); + Py_DECREF (rv); + return (Int64) t; } + else { throw IEX_NAMESPACE::InputExc ("tell failed"); } } void C_IStream::seekg (Int64 pos) { - PyObject *data = PyObject_CallMethod(_fo, (char*)"seek", (char*)"(L)", pos); - if (data != NULL) { - Py_DECREF(data); - } else { - throw IEX_NAMESPACE::InputExc("seek failed"); - } + PyObject* data = + PyObject_CallMethod (_fo, (char*) "seek", (char*) "(L)", pos); + if (data != NULL) { Py_DECREF (data); } + else { throw IEX_NAMESPACE::InputExc ("seek failed"); } } void C_IStream::clear () -{ -} +{} //////////////////////////////////////////////////////////////////////// -class C_OStream: public OStream +class C_OStream : public OStream { - public: - C_OStream (PyObject *fo): OStream(""), _fo(fo) {} - virtual void write (const char *c, int n); - virtual Int64 tellp (); - virtual void seekp (Int64 pos); - virtual void clear (); - virtual const char* fileName() const; - private: - PyObject *_fo; +public: + C_OStream (PyObject* fo) : OStream (""), _fo (fo) {} + virtual void write (const char* c, int n); + virtual Int64 tellp (); + virtual void seekp (Int64 pos); + virtual void clear (); + virtual const char* fileName () const; + +private: + PyObject* _fo; }; - void -C_OStream::write (const char*c, int n) +C_OStream::write (const char* c, int n) { - PyObject *data = PyObject_CallMethod(_fo, (char*)"write", (char*)"(s#)", c, n); - if (data != NULL) { - Py_DECREF(data); - } else { - throw IEX_NAMESPACE::InputExc("file write failed"); - } + PyObject* data = + PyObject_CallMethod (_fo, (char*) "write", (char*) "(s#)", c, n); + if (data != NULL) { Py_DECREF (data); } + else { throw IEX_NAMESPACE::InputExc ("file write failed"); } } -const char* C_OStream::fileName() const +const char* +C_OStream::fileName () const { - return "xxx"; + return "xxx"; } - Int64 C_OStream::tellp () { - PyObject *rv = PyObject_CallMethod(_fo, (char*)"tell", NULL); - if (rv != NULL && PyNumber_Check(rv)) { - PyObject *lrv = PyNumber_Long(rv); - long long t = PyLong_AsLong(lrv); - Py_DECREF(lrv); - Py_DECREF(rv); - return (Int64)t; - } else { - throw IEX_NAMESPACE::InputExc("tell failed"); + PyObject* rv = PyObject_CallMethod (_fo, (char*) "tell", NULL); + if (rv != NULL && PyNumber_Check (rv)) + { + PyObject* lrv = PyNumber_Long (rv); + long long t = PyLong_AsLong (lrv); + Py_DECREF (lrv); + Py_DECREF (rv); + return (Int64) t; } + else { throw IEX_NAMESPACE::InputExc ("tell failed"); } } void C_OStream::seekp (Int64 pos) { - PyObject *data = PyObject_CallMethod(_fo, (char*)"seek", (char*)"(L)", pos); - if (data != NULL) { - Py_DECREF(data); - } else { - throw IEX_NAMESPACE::InputExc("seek failed"); - } + PyObject* data = + PyObject_CallMethod (_fo, (char*) "seek", (char*) "(L)", pos); + if (data != NULL) { Py_DECREF (data); } + else { throw IEX_NAMESPACE::InputExc ("seek failed"); } } void C_OStream::clear () -{ -} +{} //////////////////////////////////////////////////////////////////////// // InputFile //////////////////////////////////////////////////////////////////////// -typedef struct { - PyObject_HEAD - InputFile i; - PyObject *fo; - C_IStream *istream; - int is_opened; +typedef struct +{ + PyObject_HEAD InputFile i; + PyObject* fo; + C_IStream* istream; + int is_opened; } InputFileC; -static PyObject *channel(PyObject *self, PyObject *args, PyObject *kw) +static PyObject* +channel (PyObject* self, PyObject* args, PyObject* kw) { - InputFile *file = &((InputFileC *)self)->i; + InputFile* file = &((InputFileC*) self)->i; - Box2i dw = file->header().dataWindow(); - int miny, maxy; + Box2i dw = file->header ().dataWindow (); + int miny, maxy; miny = dw.min.y; maxy = dw.max.y; - char *cname; - PyObject *pixel_type = NULL; - char *keywords[] = { (char*)"cname", (char*)"pixel_type", (char*)"scanLine1", (char*)"scanLine2", NULL }; - if (!PyArg_ParseTupleAndKeywords(args, kw, "s|Oii", keywords, &cname, &pixel_type, &miny, &maxy)) + char* cname; + PyObject* pixel_type = NULL; + char* keywords[] = { + (char*) "cname", + (char*) "pixel_type", + (char*) "scanLine1", + (char*) "scanLine2", + NULL}; + if (!PyArg_ParseTupleAndKeywords ( + args, kw, "s|Oii", keywords, &cname, &pixel_type, &miny, &maxy)) return NULL; - if (maxy < miny) { - PyErr_SetString(PyExc_TypeError, "scanLine1 must be <= scanLine2"); + if (maxy < miny) + { + PyErr_SetString (PyExc_TypeError, "scanLine1 must be <= scanLine2"); return NULL; } - if (miny < dw.min.y) { - PyErr_SetString(PyExc_TypeError, "scanLine1 cannot be outside dataWindow"); + if (miny < dw.min.y) + { + PyErr_SetString ( + PyExc_TypeError, "scanLine1 cannot be outside dataWindow"); return NULL; } - if (maxy > dw.max.y) { - PyErr_SetString(PyExc_TypeError, "scanLine2 cannot be outside dataWindow"); + if (maxy > dw.max.y) + { + PyErr_SetString ( + PyExc_TypeError, "scanLine2 cannot be outside dataWindow"); return NULL; } - ChannelList channels = file->header().channels(); - Channel *channelPtr = channels.findChannel(cname); - if (channelPtr == NULL) { - return PyErr_Format(PyExc_TypeError, "There is no channel '%s' in the image", cname); + ChannelList channels = file->header ().channels (); + Channel* channelPtr = channels.findChannel (cname); + if (channelPtr == NULL) + { + return PyErr_Format ( + PyExc_TypeError, "There is no channel '%s' in the image", cname); } Imf::PixelType pt; - if (pixel_type != NULL) { - if (PyObject_GetAttrString(pixel_type,"v") == NULL) { - return PyErr_Format(PyExc_TypeError, "Invalid PixelType object"); + if (pixel_type != NULL) + { + if (PyObject_GetAttrString (pixel_type, "v") == NULL) + { + return PyErr_Format (PyExc_TypeError, "Invalid PixelType object"); } - pt = PixelType(PyLong_AsLong(PyObject_StealAttrString(pixel_type, "v"))); - } else { - pt = channelPtr->type; + pt = PixelType ( + PyLong_AsLong (PyObject_StealAttrString (pixel_type, "v"))); } + else { pt = channelPtr->type; } int xSampling = channelPtr->xSampling; int ySampling = channelPtr->ySampling; - int width = (dw.max.x - dw.min.x + 1) / xSampling; - int height = (maxy - miny + 1) / ySampling; + int width = (dw.max.x - dw.min.x + 1) / xSampling; + int height = (maxy - miny + 1) / ySampling; size_t typeSize; - switch (pt) { - case HALF: - typeSize = 2; - break; - - case FLOAT: - case UINT: - typeSize = 4; - break; - - default: - PyErr_SetString(PyExc_TypeError, "Unknown type"); - return NULL; + switch (pt) + { + case HALF: typeSize = 2; break; + + case FLOAT: + case UINT: typeSize = 4; break; + + default: PyErr_SetString (PyExc_TypeError, "Unknown type"); return NULL; } - PyObject *r = PyString_FromStringAndSize(NULL, typeSize * width * height); + PyObject* r = PyString_FromStringAndSize (NULL, typeSize * width * height); - char *pixels = PyString_AsString(r); + char* pixels = PyString_AsString (r); try { FrameBuffer frameBuffer; - size_t xstride = typeSize; - size_t ystride = typeSize * width; - frameBuffer.insert(cname, - Slice(pt, - pixels - dw.min.x * xstride / xSampling - miny * ystride / ySampling, - xstride, - ystride, - xSampling, ySampling, - 0.0)); - file->setFrameBuffer(frameBuffer); - file->readPixels(miny, maxy); + size_t xstride = typeSize; + size_t ystride = typeSize * width; + frameBuffer.insert ( + cname, + Slice ( + pt, + pixels - dw.min.x * xstride / xSampling - + miny * ystride / ySampling, + xstride, + ystride, + xSampling, + ySampling, + 0.0)); + file->setFrameBuffer (frameBuffer); + file->readPixels (miny, maxy); } - catch (const std::exception &e) + catch (const std::exception& e) { - PyErr_SetString(PyExc_IOError, e.what()); - return NULL; + PyErr_SetString (PyExc_IOError, e.what ()); + return NULL; } return r; } -static PyObject *channels(PyObject *self, PyObject *args, PyObject *kw) +static PyObject* +channels (PyObject* self, PyObject* args, PyObject* kw) { - InputFile *file = &((InputFileC *)self)->i; + InputFile* file = &((InputFileC*) self)->i; - Box2i dw = file->header().dataWindow(); - int miny, maxy; + Box2i dw = file->header ().dataWindow (); + int miny, maxy; miny = dw.min.y; maxy = dw.max.y; - PyObject *clist; - PyObject *pixel_type = NULL; - char *keywords[] = { (char*)"cnames", (char*)"pixel_type", (char*)"scanLine1", (char*)"scanLine2", NULL }; - if (!PyArg_ParseTupleAndKeywords(args, kw, "O|Oii", keywords, &clist, &pixel_type, &miny, &maxy)) + PyObject* clist; + PyObject* pixel_type = NULL; + char* keywords[] = { + (char*) "cnames", + (char*) "pixel_type", + (char*) "scanLine1", + (char*) "scanLine2", + NULL}; + if (!PyArg_ParseTupleAndKeywords ( + args, kw, "O|Oii", keywords, &clist, &pixel_type, &miny, &maxy)) return NULL; - if (maxy < miny) { - PyErr_SetString(PyExc_TypeError, "scanLine1 must be <= scanLine2"); + if (maxy < miny) + { + PyErr_SetString (PyExc_TypeError, "scanLine1 must be <= scanLine2"); return NULL; } - if (miny < dw.min.y) { - PyErr_SetString(PyExc_TypeError, "scanLine1 cannot be outside dataWindow"); + if (miny < dw.min.y) + { + PyErr_SetString ( + PyExc_TypeError, "scanLine1 cannot be outside dataWindow"); return NULL; } - if (maxy > dw.max.y) { - PyErr_SetString(PyExc_TypeError, "scanLine2 cannot be outside dataWindow"); + if (maxy > dw.max.y) + { + PyErr_SetString ( + PyExc_TypeError, "scanLine2 cannot be outside dataWindow"); return NULL; } - ChannelList channels = file->header().channels(); + ChannelList channels = file->header ().channels (); FrameBuffer frameBuffer; int width = dw.max.x - dw.min.x + 1; int height = maxy - miny + 1; - PyObject *retval = PyList_New(0); - PyObject *iterator = PyObject_GetIter(clist); - if (iterator == NULL) { - PyErr_SetString(PyExc_TypeError, "Channel list must be iterable"); - return NULL; + PyObject* retval = PyList_New (0); + PyObject* iterator = PyObject_GetIter (clist); + if (iterator == NULL) + { + PyErr_SetString (PyExc_TypeError, "Channel list must be iterable"); + return NULL; } - PyObject *item; - - while ((item = PyIter_Next(iterator)) != NULL) { - char *cname = PyUTF8_AsSstring(item); - Channel *channelPtr = channels.findChannel(cname); - if (channelPtr == NULL) { - return PyErr_Format(PyExc_TypeError, "There is no channel '%s' in the image", cname); - } - - Imf::PixelType pt; - if (pixel_type != NULL) { - pt = PixelType(PyLong_AsLong(PyObject_StealAttrString(pixel_type, "v"))); - } else { - pt = channelPtr->type; - } - - // Use pt to compute typeSize - size_t typeSize; - switch (pt) { - case HALF: - typeSize = 2; - break; - - case FLOAT: - case UINT: - typeSize = 4; - break; - - default: - PyErr_SetString(PyExc_TypeError, "Unknown type"); - return NULL; - } - - size_t xstride = typeSize; - size_t ystride = typeSize * width; - - PyObject *r = PyString_FromStringAndSize(NULL, typeSize * width * height); - PyList_Append(retval, r); - Py_DECREF(r); - - char *pixels = PyString_AsString(r); - - try - { - frameBuffer.insert(cname, - Slice(pt, - pixels - dw.min.x * xstride - miny * ystride, - xstride, - ystride, - 1,1, - 0.0)); - } - catch (const std::exception &e) - { - PyErr_SetString(PyExc_IOError, e.what()); - return NULL; - } - Py_DECREF(item); + PyObject* item; + + while ((item = PyIter_Next (iterator)) != NULL) + { + char* cname = PyUTF8_AsSstring (item); + Channel* channelPtr = channels.findChannel (cname); + if (channelPtr == NULL) + { + return PyErr_Format ( + PyExc_TypeError, + "There is no channel '%s' in the image", + cname); + } + + Imf::PixelType pt; + if (pixel_type != NULL) + { + pt = PixelType ( + PyLong_AsLong (PyObject_StealAttrString (pixel_type, "v"))); + } + else { pt = channelPtr->type; } + + // Use pt to compute typeSize + size_t typeSize; + switch (pt) + { + case HALF: typeSize = 2; break; + + case FLOAT: + case UINT: typeSize = 4; break; + + default: + PyErr_SetString (PyExc_TypeError, "Unknown type"); + return NULL; + } + + size_t xstride = typeSize; + size_t ystride = typeSize * width; + + PyObject* r = + PyString_FromStringAndSize (NULL, typeSize * width * height); + PyList_Append (retval, r); + Py_DECREF (r); + + char* pixels = PyString_AsString (r); + + try + { + frameBuffer.insert ( + cname, + Slice ( + pt, + pixels - dw.min.x * xstride - miny * ystride, + xstride, + ystride, + 1, + 1, + 0.0)); + } + catch (const std::exception& e) + { + PyErr_SetString (PyExc_IOError, e.what ()); + return NULL; + } + Py_DECREF (item); } - Py_DECREF(iterator); - file->setFrameBuffer(frameBuffer); - file->readPixels(miny, maxy); + Py_DECREF (iterator); + file->setFrameBuffer (frameBuffer); + file->readPixels (miny, maxy); return retval; } -static PyObject *inclose(PyObject *self, PyObject *args) +static PyObject* +inclose (PyObject* self, PyObject* args) { - InputFileC *pc = ((InputFileC *)self); - if (pc->is_opened) { - pc->is_opened = 0; - InputFile *file = &((InputFileC *)self)->i; - file->~InputFile(); - } - Py_RETURN_NONE; + InputFileC* pc = ((InputFileC*) self); + if (pc->is_opened) + { + pc->is_opened = 0; + InputFile* file = &((InputFileC*) self)->i; + file->~InputFile (); + } + Py_RETURN_NONE; } -static PyObject *dict_from_header(Header h) +static PyObject* +dict_from_header (Header h) { - PyObject *object; - - object = PyDict_New(); - - PyObject *pV2FFunc = PyObject_GetAttrString(pModuleImath, "V2f"); - PyObject *pChanFunc = PyObject_GetAttrString(pModuleImath, "Channel"); - PyObject *pPTFunc = PyObject_GetAttrString(pModuleImath, "PixelType"); - PyObject *pBoxFunc = PyObject_GetAttrString(pModuleImath, "Box2i"); - PyObject *pPointFunc = PyObject_GetAttrString(pModuleImath, "point"); - PyObject *pPIFunc = PyObject_GetAttrString(pModuleImath, "PreviewImage"); - PyObject *pLOFunc = PyObject_GetAttrString(pModuleImath, "LineOrder"); - PyObject *pCFunc = PyObject_GetAttrString(pModuleImath, "Compression"); - PyObject *pCHFunc = PyObject_GetAttrString(pModuleImath, "chromaticity"); - PyObject *pCHSFunc = PyObject_GetAttrString(pModuleImath, "Chromaticities"); - PyObject *pLevelMode = PyObject_GetAttrString(pModuleImath, "LevelMode"); - PyObject *pLevelRoundingMode = PyObject_GetAttrString(pModuleImath, "LevelRoundingMode"); - PyObject *pTileDescription = PyObject_GetAttrString(pModuleImath, "TileDescription"); - PyObject *pRationalFunc = PyObject_GetAttrString(pModuleImath, "Rational"); - PyObject *pKeyCodeFunc = PyObject_GetAttrString(pModuleImath, "KeyCode"); - PyObject *pTimeCodeFunc = PyObject_GetAttrString(pModuleImath, "TimeCode"); - - for (Header::ConstIterator i = h.begin(); i != h.end(); ++i) { - const Attribute *a = &i.attribute(); - PyObject *ob = NULL; + PyObject* object; + + object = PyDict_New (); + + PyObject* pV2FFunc = PyObject_GetAttrString (pModuleImath, "V2f"); + PyObject* pChanFunc = PyObject_GetAttrString (pModuleImath, "Channel"); + PyObject* pPTFunc = PyObject_GetAttrString (pModuleImath, "PixelType"); + PyObject* pBoxFunc = PyObject_GetAttrString (pModuleImath, "Box2i"); + PyObject* pPointFunc = PyObject_GetAttrString (pModuleImath, "point"); + PyObject* pPIFunc = PyObject_GetAttrString (pModuleImath, "PreviewImage"); + PyObject* pLOFunc = PyObject_GetAttrString (pModuleImath, "LineOrder"); + PyObject* pCFunc = PyObject_GetAttrString (pModuleImath, "Compression"); + PyObject* pCHFunc = PyObject_GetAttrString (pModuleImath, "chromaticity"); + PyObject* pCHSFunc = + PyObject_GetAttrString (pModuleImath, "Chromaticities"); + PyObject* pLevelMode = PyObject_GetAttrString (pModuleImath, "LevelMode"); + PyObject* pLevelRoundingMode = + PyObject_GetAttrString (pModuleImath, "LevelRoundingMode"); + PyObject* pTileDescription = + PyObject_GetAttrString (pModuleImath, "TileDescription"); + PyObject* pRationalFunc = PyObject_GetAttrString (pModuleImath, "Rational"); + PyObject* pKeyCodeFunc = PyObject_GetAttrString (pModuleImath, "KeyCode"); + PyObject* pTimeCodeFunc = PyObject_GetAttrString (pModuleImath, "TimeCode"); + + for (Header::ConstIterator i = h.begin (); i != h.end (); ++i) + { + const Attribute* a = &i.attribute (); + PyObject* ob = NULL; // cout << i.name() << " (type " << a->typeName() << ")\n"; - if (const Box2iAttribute *ta = dynamic_cast (a)) { - - PyObject *ptargs[2]; - ptargs[0] = Py_BuildValue("ii", ta->value().min.x, ta->value().min.y); - ptargs[1] = Py_BuildValue("ii", ta->value().max.x, ta->value().max.y); - PyObject *pt[2]; - pt[0] = PyObject_CallObject(pPointFunc, ptargs[0]); - pt[1] = PyObject_CallObject(pPointFunc, ptargs[1]); - PyObject *boxArgs = Py_BuildValue("NN", pt[0], pt[1]); - - ob = PyObject_CallObject(pBoxFunc, boxArgs); - Py_DECREF(boxArgs); - Py_DECREF(ptargs[0]); - Py_DECREF(ptargs[1]); - } else if (const KeyCodeAttribute *ka = dynamic_cast (a)) { - PyObject *args = Py_BuildValue("iiiiiii", - ka->value().filmMfcCode(), - ka->value().filmType(), - ka->value().prefix(), - ka->value().count(), - ka->value().perfOffset(), - ka->value().perfsPerFrame(), - ka->value().perfsPerCount()); - ob = PyObject_CallObject(pKeyCodeFunc, args); - Py_DECREF(args); - } else if (const TimeCodeAttribute *ta = dynamic_cast (a)) { - PyObject *args = Py_BuildValue("iiiiiiiiiiiiiiiiii", - ta->value().hours(), - ta->value().minutes(), - ta->value().seconds(), - ta->value().frame(), - ta->value().dropFrame(), - ta->value().colorFrame(), - ta->value().fieldPhase(), - ta->value().bgf0(), - ta->value().bgf1(), - ta->value().bgf2(), - ta->value().binaryGroup(1), - ta->value().binaryGroup(2), - ta->value().binaryGroup(3), - ta->value().binaryGroup(4), - ta->value().binaryGroup(5), - ta->value().binaryGroup(6), - ta->value().binaryGroup(7), - ta->value().binaryGroup(8)); - ob = PyObject_CallObject(pTimeCodeFunc, args); - Py_DECREF(args); - - } else if (const RationalAttribute *ra = dynamic_cast (a)) { - PyObject *args = Py_BuildValue("ii", ra->value().n, ra->value().d); - ob = PyObject_CallObject(pRationalFunc, args); - Py_DECREF(args); - } else if (const PreviewImageAttribute *pia = dynamic_cast (a)) { - int size = pia->value().width() * pia->value().height() * 4; + if (const Box2iAttribute* ta = dynamic_cast (a)) + { + + PyObject* ptargs[2]; + ptargs[0] = + Py_BuildValue ("ii", ta->value ().min.x, ta->value ().min.y); + ptargs[1] = + Py_BuildValue ("ii", ta->value ().max.x, ta->value ().max.y); + PyObject* pt[2]; + pt[0] = PyObject_CallObject (pPointFunc, ptargs[0]); + pt[1] = PyObject_CallObject (pPointFunc, ptargs[1]); + PyObject* boxArgs = Py_BuildValue ("NN", pt[0], pt[1]); + + ob = PyObject_CallObject (pBoxFunc, boxArgs); + Py_DECREF (boxArgs); + Py_DECREF (ptargs[0]); + Py_DECREF (ptargs[1]); + } + else if ( + const KeyCodeAttribute* ka = + dynamic_cast (a)) + { + PyObject* args = Py_BuildValue ( + "iiiiiii", + ka->value ().filmMfcCode (), + ka->value ().filmType (), + ka->value ().prefix (), + ka->value ().count (), + ka->value ().perfOffset (), + ka->value ().perfsPerFrame (), + ka->value ().perfsPerCount ()); + ob = PyObject_CallObject (pKeyCodeFunc, args); + Py_DECREF (args); + } + else if ( + const TimeCodeAttribute* ta = + dynamic_cast (a)) + { + PyObject* args = Py_BuildValue ( + "iiiiiiiiiiiiiiiiii", + ta->value ().hours (), + ta->value ().minutes (), + ta->value ().seconds (), + ta->value ().frame (), + ta->value ().dropFrame (), + ta->value ().colorFrame (), + ta->value ().fieldPhase (), + ta->value ().bgf0 (), + ta->value ().bgf1 (), + ta->value ().bgf2 (), + ta->value ().binaryGroup (1), + ta->value ().binaryGroup (2), + ta->value ().binaryGroup (3), + ta->value ().binaryGroup (4), + ta->value ().binaryGroup (5), + ta->value ().binaryGroup (6), + ta->value ().binaryGroup (7), + ta->value ().binaryGroup (8)); + ob = PyObject_CallObject (pTimeCodeFunc, args); + Py_DECREF (args); + } + else if ( + const RationalAttribute* ra = + dynamic_cast (a)) + { + PyObject* args = + Py_BuildValue ("ii", ra->value ().n, ra->value ().d); + ob = PyObject_CallObject (pRationalFunc, args); + Py_DECREF (args); + } + else if ( + const PreviewImageAttribute* pia = + dynamic_cast (a)) + { + int size = pia->value ().width () * pia->value ().height () * 4; #if PY_MAJOR_VERSION >= 3 const char fmt[] = "iiy#"; #else const char fmt[] = "iis#"; #endif - PyObject *args = Py_BuildValue(fmt, pia->value().width(), pia->value().height(), (char*)pia->value().pixels(), size); - ob = PyObject_CallObject(pPIFunc, args); - - Py_DECREF(args); - } else if (const LineOrderAttribute *ta = dynamic_cast (a)) { - PyObject *args = PyTuple_Pack(1, PyInt_FromLong(ta->value())); - ob = PyObject_CallObject(pLOFunc, args); - Py_DECREF(args); - } else if (const CompressionAttribute *ta = dynamic_cast (a)) { - PyObject *args = PyTuple_Pack(1, PyInt_FromLong(ta->value())); - ob = PyObject_CallObject(pCFunc, args); - Py_DECREF(args); - } else if (const ChannelListAttribute *ta = dynamic_cast (a)) { - const ChannelList cl = ta->value(); - PyObject *CS = PyDict_New(); - for (ChannelList::ConstIterator j = cl.begin(); j != cl.end(); ++j) { - PyObject *ptarg = Py_BuildValue("(i)", j.channel().type); - PyObject *pt = PyObject_CallObject(pPTFunc, ptarg); - PyObject *chanarg = Py_BuildValue("Nii", - pt, - j.channel().xSampling, - j.channel().ySampling); - PyObject *C = PyObject_CallObject(pChanFunc, chanarg); - PyDict_SetItemString(CS, j.name(), C); - Py_DECREF(C); - Py_DECREF(ptarg); - Py_DECREF(chanarg); + PyObject* args = Py_BuildValue ( + fmt, + pia->value ().width (), + pia->value ().height (), + (char*) pia->value ().pixels (), + size); + ob = PyObject_CallObject (pPIFunc, args); + + Py_DECREF (args); + } + else if ( + const LineOrderAttribute* ta = + dynamic_cast (a)) + { + PyObject* args = PyTuple_Pack (1, PyInt_FromLong (ta->value ())); + ob = PyObject_CallObject (pLOFunc, args); + Py_DECREF (args); + } + else if ( + const CompressionAttribute* ta = + dynamic_cast (a)) + { + PyObject* args = PyTuple_Pack (1, PyInt_FromLong (ta->value ())); + ob = PyObject_CallObject (pCFunc, args); + Py_DECREF (args); + } + else if ( + const ChannelListAttribute* ta = + dynamic_cast (a)) + { + const ChannelList cl = ta->value (); + PyObject* CS = PyDict_New (); + for (ChannelList::ConstIterator j = cl.begin (); j != cl.end (); + ++j) + { + PyObject* ptarg = Py_BuildValue ("(i)", j.channel ().type); + PyObject* pt = PyObject_CallObject (pPTFunc, ptarg); + PyObject* chanarg = Py_BuildValue ( + "Nii", pt, j.channel ().xSampling, j.channel ().ySampling); + PyObject* C = PyObject_CallObject (pChanFunc, chanarg); + PyDict_SetItemString (CS, j.name (), C); + Py_DECREF (C); + Py_DECREF (ptarg); + Py_DECREF (chanarg); } ob = CS; - } else if (const FloatAttribute *ta = dynamic_cast (a)) { - ob = PyFloat_FromDouble(ta->value()); - } else if (const IntAttribute *ta = dynamic_cast (a)) { - ob = PyInt_FromLong(ta->value()); - } else if (const V2fAttribute *ta = dynamic_cast (a)) { - PyObject *args = Py_BuildValue("ff", ta->value().x, ta->value().y); - ob = PyObject_CallObject(pV2FFunc, args); - Py_DECREF(args); - } else if (const StringAttribute *ta = dynamic_cast (a)) { - ob = PyString_FromString(ta->value().c_str()); - } else if (const TileDescriptionAttribute *ta = dynamic_cast(a)) { - const TileDescription td = ta->value(); - PyObject *m = PyObject_Call1(pLevelMode, Py_BuildValue("(i)", td.mode)); - PyObject *r = PyObject_Call1(pLevelRoundingMode, Py_BuildValue("(i)", td.roundingMode)); - ob = PyObject_Call1(pTileDescription, Py_BuildValue("(iiNN)", td.xSize, td.ySize, m, r)); - } else if (const ChromaticitiesAttribute *ta = dynamic_cast(a)) { - const Chromaticities &ch(ta->value()); - PyObject *rgbwargs[4]; - rgbwargs[0] = Py_BuildValue("ff", ch.red[0], ch.red[1]); - rgbwargs[1] = Py_BuildValue("ff", ch.green[0], ch.green[1]); - rgbwargs[2] = Py_BuildValue("ff", ch.blue[0], ch.blue[1]); - rgbwargs[3] = Py_BuildValue("ff", ch.white[0], ch.white[1]); - PyObject *chromas[4]; - chromas[0] = PyObject_CallObject(pCHFunc, rgbwargs[0]); - chromas[1] = PyObject_CallObject(pCHFunc, rgbwargs[1]); - chromas[2] = PyObject_CallObject(pCHFunc, rgbwargs[2]); - chromas[3] = PyObject_CallObject(pCHFunc, rgbwargs[3]); - PyObject *cargs = Py_BuildValue("NNNN", chromas[0], chromas[1], chromas[2], chromas[3]); - ob = PyObject_CallObject(pCHSFunc, cargs); - Py_DECREF(cargs); - Py_DECREF(rgbwargs[0]); - Py_DECREF(rgbwargs[1]); - Py_DECREF(rgbwargs[2]); - Py_DECREF(rgbwargs[3]); + } + else if ( + const FloatAttribute* ta = dynamic_cast (a)) + { + ob = PyFloat_FromDouble (ta->value ()); + } + else if (const IntAttribute* ta = dynamic_cast (a)) + { + ob = PyInt_FromLong (ta->value ()); + } + else if (const V2fAttribute* ta = dynamic_cast (a)) + { + PyObject* args = + Py_BuildValue ("ff", ta->value ().x, ta->value ().y); + ob = PyObject_CallObject (pV2FFunc, args); + Py_DECREF (args); + } + else if ( + const StringAttribute* ta = + dynamic_cast (a)) + { + ob = PyString_FromString (ta->value ().c_str ()); + } + else if ( + const TileDescriptionAttribute* ta = + dynamic_cast (a)) + { + const TileDescription td = ta->value (); + PyObject* m = + PyObject_Call1 (pLevelMode, Py_BuildValue ("(i)", td.mode)); + PyObject* r = PyObject_Call1 ( + pLevelRoundingMode, Py_BuildValue ("(i)", td.roundingMode)); + ob = PyObject_Call1 ( + pTileDescription, + Py_BuildValue ("(iiNN)", td.xSize, td.ySize, m, r)); + } + else if ( + const ChromaticitiesAttribute* ta = + dynamic_cast (a)) + { + const Chromaticities& ch (ta->value ()); + PyObject* rgbwargs[4]; + rgbwargs[0] = Py_BuildValue ("ff", ch.red[0], ch.red[1]); + rgbwargs[1] = Py_BuildValue ("ff", ch.green[0], ch.green[1]); + rgbwargs[2] = Py_BuildValue ("ff", ch.blue[0], ch.blue[1]); + rgbwargs[3] = Py_BuildValue ("ff", ch.white[0], ch.white[1]); + PyObject* chromas[4]; + chromas[0] = PyObject_CallObject (pCHFunc, rgbwargs[0]); + chromas[1] = PyObject_CallObject (pCHFunc, rgbwargs[1]); + chromas[2] = PyObject_CallObject (pCHFunc, rgbwargs[2]); + chromas[3] = PyObject_CallObject (pCHFunc, rgbwargs[3]); + PyObject* cargs = Py_BuildValue ( + "NNNN", chromas[0], chromas[1], chromas[2], chromas[3]); + ob = PyObject_CallObject (pCHSFunc, cargs); + Py_DECREF (cargs); + Py_DECREF (rgbwargs[0]); + Py_DECREF (rgbwargs[1]); + Py_DECREF (rgbwargs[2]); + Py_DECREF (rgbwargs[3]); #ifdef INCLUDED_IMF_STRINGVECTOR_ATTRIBUTE_H - } else if (const StringVectorAttribute *ta = dynamic_cast(a)) { - StringVector sv = ta->value(); - ob = PyList_New(sv.size()); - for (size_t i = 0; i < sv.size(); i++) - PyList_SetItem(ob, i, PyString_FromString(sv[i].c_str())); + } + else if ( + const StringVectorAttribute* ta = + dynamic_cast (a)) + { + StringVector sv = ta->value (); + ob = PyList_New (sv.size ()); + for (size_t i = 0; i < sv.size (); i++) + PyList_SetItem (ob, i, PyString_FromString (sv[i].c_str ())); #endif - } else { + } + else + { // Unknown type for this object, so set its value to None. // printf("Baffled by type %s\n", a->typeName()); ob = Py_None; - Py_INCREF(ob); + Py_INCREF (ob); } - PyDict_SetItemString(object, i.name(), ob); - Py_DECREF(ob); + PyDict_SetItemString (object, i.name (), ob); + Py_DECREF (ob); } - Py_DECREF(pV2FFunc); - Py_DECREF(pChanFunc); - Py_DECREF(pPTFunc); - Py_DECREF(pBoxFunc); - Py_DECREF(pPointFunc); - Py_DECREF(pPIFunc); - Py_DECREF(pLOFunc); - Py_DECREF(pCFunc); - Py_DECREF(pLevelMode); - Py_DECREF(pLevelRoundingMode); - Py_DECREF(pTileDescription); - Py_DECREF(pRationalFunc); - Py_DECREF(pKeyCodeFunc); - Py_DECREF(pTimeCodeFunc); + Py_DECREF (pV2FFunc); + Py_DECREF (pChanFunc); + Py_DECREF (pPTFunc); + Py_DECREF (pBoxFunc); + Py_DECREF (pPointFunc); + Py_DECREF (pPIFunc); + Py_DECREF (pLOFunc); + Py_DECREF (pCFunc); + Py_DECREF (pLevelMode); + Py_DECREF (pLevelRoundingMode); + Py_DECREF (pTileDescription); + Py_DECREF (pRationalFunc); + Py_DECREF (pKeyCodeFunc); + Py_DECREF (pTimeCodeFunc); return object; } -static PyObject *inheader(PyObject *self, PyObject *args) +static PyObject* +inheader (PyObject* self, PyObject* args) { - InputFile *file = &((InputFileC *)self)->i; - return dict_from_header(file->header()); + InputFile* file = &((InputFileC*) self)->i; + return dict_from_header (file->header ()); } -static PyObject *isComplete(PyObject *self, PyObject *args) +static PyObject* +isComplete (PyObject* self, PyObject* args) { - InputFile *file = &((InputFileC *)self)->i; - return PyBool_FromLong(file->isComplete()); + InputFile* file = &((InputFileC*) self)->i; + return PyBool_FromLong (file->isComplete ()); } /* Method table */ static PyMethodDef InputFile_methods[] = { - {"header", inheader, METH_VARARGS}, - {"channel", (PyCFunction)channel, METH_VARARGS | METH_KEYWORDS}, - {"channels", (PyCFunction)channels, METH_VARARGS | METH_KEYWORDS}, - {"close", inclose, METH_VARARGS}, - {"isComplete", isComplete, METH_VARARGS}, - {NULL, NULL}, + {"header", inheader, METH_VARARGS}, + {"channel", (PyCFunction) channel, METH_VARARGS | METH_KEYWORDS}, + {"channels", (PyCFunction) channels, METH_VARARGS | METH_KEYWORDS}, + {"close", inclose, METH_VARARGS}, + {"isComplete", isComplete, METH_VARARGS}, + {NULL, NULL}, }; static void -InputFile_dealloc(PyObject *self) +InputFile_dealloc (PyObject* self) { - InputFileC *object = ((InputFileC *)self); - if (object->fo) - Py_DECREF(object->fo); - Py_DECREF(inclose(self, NULL)); - PyObject_Del(self); + InputFileC* object = ((InputFileC*) self); + if (object->fo) Py_DECREF (object->fo); + Py_DECREF (inclose (self, NULL)); + PyObject_Del (self); } -static PyObject * -InputFile_Repr(PyObject *self) +static PyObject* +InputFile_Repr (PyObject* self) { //PyObject *result = NULL; char buf[50]; - sprintf(buf, "InputFile represented"); - return PyUnicode_FromString(buf); + sprintf (buf, "InputFile represented"); + return PyUnicode_FromString (buf); } static PyTypeObject InputFile_Type = { - PyVarObject_HEAD_INIT(&PyType_Type, 0) - "OpenEXR.InputFile", - sizeof(InputFileC), + PyVarObject_HEAD_INIT (&PyType_Type, 0) "OpenEXR.InputFile", + sizeof (InputFileC), 0, - (destructor)InputFile_dealloc, + (destructor) InputFile_dealloc, 0, 0, 0, 0, - (reprfunc)InputFile_Repr, + (reprfunc) InputFile_Repr, 0, //&InputFile_as_number, 0, //&InputFile_as_sequence, 0, @@ -730,9 +843,9 @@ static PyTypeObject InputFile_Type = { 0, 0, 0, - + 0, - + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, "OpenEXR Input file object", @@ -749,224 +862,255 @@ static PyTypeObject InputFile_Type = { /* the rest are NULLs */ }; -int makeInputFile(PyObject *self, PyObject *args, PyObject *kwds) +int +makeInputFile (PyObject* self, PyObject* args, PyObject* kwds) { - InputFileC *object = ((InputFileC *)self); - PyObject *fo; - char *filename = NULL; - - if (PyArg_ParseTuple(args, "O:InputFile", &fo)) { - if (PyString_Check(fo)) { - filename = PyString_AsString(fo); - object->fo = NULL; - object->istream = NULL; - } else if (PyUnicode_Check(fo)) { - filename = PyUTF8_AsSstring(fo); - object->fo = NULL; - object->istream = NULL; - } else { - object->fo = fo; - Py_INCREF(fo); - object->istream = new C_IStream(fo); - } - } else { - return -1; + InputFileC* object = ((InputFileC*) self); + PyObject* fo; + char* filename = NULL; + + if (PyArg_ParseTuple (args, "O:InputFile", &fo)) + { + if (PyString_Check (fo)) + { + filename = PyString_AsString (fo); + object->fo = NULL; + object->istream = NULL; + } + else if (PyUnicode_Check (fo)) + { + filename = PyUTF8_AsSstring (fo); + object->fo = NULL; + object->istream = NULL; + } + else + { + object->fo = fo; + Py_INCREF (fo); + object->istream = new C_IStream (fo); + } } + else { return -1; } try { if (filename != NULL) - new(&object->i) InputFile(filename); + new (&object->i) InputFile (filename); else - new(&object->i) InputFile(*object->istream); + new (&object->i) InputFile (*object->istream); } - catch (const std::exception &e) + catch (const std::exception& e) { - // Py_DECREF(object); - PyErr_SetString(PyExc_IOError, e.what()); - return -1; + // Py_DECREF(object); + PyErr_SetString (PyExc_IOError, e.what ()); + return -1; } object->is_opened = 1; return 0; } - //////////////////////////////////////////////////////////////////////// // OutputFile //////////////////////////////////////////////////////////////////////// -typedef struct { - PyObject_HEAD - OutputFile o; - C_OStream *ostream; - PyObject *fo; - int is_opened; +typedef struct +{ + PyObject_HEAD OutputFile o; + C_OStream* ostream; + PyObject* fo; + int is_opened; } OutputFileC; -static void releaseviews(std::vector &views) +static void +releaseviews (std::vector& views) { - for (size_t i=0; i < views.size(); i++) - PyBuffer_Release(&views[i]); + for (size_t i = 0; i < views.size (); i++) + PyBuffer_Release (&views[i]); } -static PyObject *outwrite(PyObject *self, PyObject *args) +static PyObject* +outwrite (PyObject* self, PyObject* args) { - OutputFile *file = &((OutputFileC *)self)->o; + OutputFile* file = &((OutputFileC*) self)->o; // long height = PyLong_AsLong(PyTuple_GetItem(args, 1)); - Box2i dw = file->header().dataWindow(); - int width = dw.max.x - dw.min.x + 1; - int height = dw.max.y - dw.min.y + 1; - PyObject *pixeldata; - - if (!PyArg_ParseTuple(args, "O!|i:writePixels", &PyDict_Type, &pixeldata, &height)) - return NULL; - - int currentScanLine = file->currentScanLine(); - if (file->header().lineOrder() == DECREASING_Y) { + Box2i dw = file->header ().dataWindow (); + int width = dw.max.x - dw.min.x + 1; + int height = dw.max.y - dw.min.y + 1; + PyObject* pixeldata; + + if (!PyArg_ParseTuple ( + args, "O!|i:writePixels", &PyDict_Type, &pixeldata, &height)) + return NULL; + + int currentScanLine = file->currentScanLine (); + if (file->header ().lineOrder () == DECREASING_Y) + { // With DECREASING_Y, currentScanLine() returns the maximum Y value of // the window on the first call, and decrements at each scan line. // We have to adjust to point to the correct address in the client buffer. currentScanLine = dw.max.y - currentScanLine + dw.min.y; } - FrameBuffer frameBuffer; + FrameBuffer frameBuffer; std::vector views; - const ChannelList &channels = file->header().channels(); - for (ChannelList::ConstIterator i = channels.begin(); - i != channels.end(); - ++i) { - PyObject *channel_spec = PyDict_GetItem(pixeldata, PyUnicode_FromString(i.name())); - if (channel_spec != NULL) { - Imf::PixelType pt = i.channel().type; - int typeSize = 4; - switch (pt) { - case HALF: - typeSize = 2; - break; - - case FLOAT: - case UINT: - typeSize = 4; - break; - - default: - break; + const ChannelList& channels = file->header ().channels (); + for (ChannelList::ConstIterator i = channels.begin (); i != channels.end (); + ++i) + { + PyObject* channel_spec = + PyDict_GetItem (pixeldata, PyUnicode_FromString (i.name ())); + if (channel_spec != NULL) + { + Imf::PixelType pt = i.channel ().type; + int typeSize = 4; + switch (pt) + { + case HALF: typeSize = 2; break; + + case FLOAT: + case UINT: typeSize = 4; break; + + default: break; } - int xSampling = i.channel().xSampling; - int ySampling = i.channel().ySampling; - int yStride = typeSize * width; - char *srcPixels; - int expectedSize = (height * yStride) / (xSampling * ySampling); + int xSampling = i.channel ().xSampling; + int ySampling = i.channel ().ySampling; + int yStride = typeSize * width; + char* srcPixels; + int expectedSize = (height * yStride) / (xSampling * ySampling); Py_ssize_t bufferSize; - if (PyString_Check(channel_spec)) { - bufferSize = PyString_Size(channel_spec); - srcPixels = PyString_AsString(channel_spec); - } else if (PyObject_CheckBuffer(channel_spec)) { + if (PyString_Check (channel_spec)) + { + bufferSize = PyString_Size (channel_spec); + srcPixels = PyString_AsString (channel_spec); + } + else if (PyObject_CheckBuffer (channel_spec)) + { Py_buffer view; - if (PyObject_GetBuffer(channel_spec, &view, PyBUF_CONTIG_RO) != 0) { - releaseviews(views); - PyErr_Format(PyExc_TypeError, "Unsupported buffer structure for channel '%s'", i.name()); + if (PyObject_GetBuffer (channel_spec, &view, PyBUF_CONTIG_RO) != + 0) + { + releaseviews (views); + PyErr_Format ( + PyExc_TypeError, + "Unsupported buffer structure for channel '%s'", + i.name ()); return NULL; } - views.push_back(view); + views.push_back (view); bufferSize = view.len; - srcPixels = (char*)view.buf; - } else { - releaseviews(views); - PyErr_Format(PyExc_TypeError, "Data for channel '%s' must be a string or support buffer protocol", i.name()); + srcPixels = (char*) view.buf; + } + else + { + releaseviews (views); + PyErr_Format ( + PyExc_TypeError, + "Data for channel '%s' must be a string or support buffer protocol", + i.name ()); return NULL; } - if (bufferSize != expectedSize) { - releaseviews(views); - PyErr_Format(PyExc_TypeError, "Data for channel '%s' should have size %zu but got %zu", i.name(), expectedSize, bufferSize); + if (bufferSize != expectedSize) + { + releaseviews (views); + PyErr_Format ( + PyExc_TypeError, + "Data for channel '%s' should have size %zu but got %zu", + i.name (), + expectedSize, + bufferSize); return NULL; } - frameBuffer.insert(i.name(), // name - Slice(pt, // type - srcPixels - dw.min.x * typeSize / xSampling - currentScanLine * yStride / ySampling, // base - typeSize, // xStride - yStride, // yStride - xSampling, ySampling)); // subsampling + frameBuffer.insert ( + i.name (), // name + Slice ( + pt, // type + srcPixels - dw.min.x * typeSize / xSampling - + currentScanLine * yStride / ySampling, // base + typeSize, // xStride + yStride, // yStride + xSampling, + ySampling)); // subsampling } } try { - file->setFrameBuffer(frameBuffer); - file->writePixels(height); + file->setFrameBuffer (frameBuffer); + file->writePixels (height); } - catch (const std::exception &e) + catch (const std::exception& e) { - releaseviews(views); - PyErr_SetString(PyExc_IOError, e.what()); + releaseviews (views); + PyErr_SetString (PyExc_IOError, e.what ()); return NULL; } - releaseviews(views); + releaseviews (views); Py_RETURN_NONE; } -static PyObject *outcurrentscanline(PyObject *self, PyObject *args) +static PyObject* +outcurrentscanline (PyObject* self, PyObject* args) { - OutputFile *file = &((OutputFileC *)self)->o; - return PyLong_FromLong(file->currentScanLine()); + OutputFile* file = &((OutputFileC*) self)->o; + return PyLong_FromLong (file->currentScanLine ()); } -static PyObject *outclose(PyObject *self, PyObject *args) +static PyObject* +outclose (PyObject* self, PyObject* args) { - OutputFileC *oc = (OutputFileC *)self; - if (oc->is_opened) { - oc->is_opened = 0; - OutputFile *file = &oc->o; - file->~OutputFile(); + OutputFileC* oc = (OutputFileC*) self; + if (oc->is_opened) + { + oc->is_opened = 0; + OutputFile* file = &oc->o; + file->~OutputFile (); } Py_RETURN_NONE; } /* Method table */ static PyMethodDef OutputFile_methods[] = { - {"writePixels", outwrite, METH_VARARGS}, - {"currentScanLine", outcurrentscanline, METH_VARARGS}, - {"close", outclose, METH_VARARGS}, - {NULL, NULL}, + {"writePixels", outwrite, METH_VARARGS}, + {"currentScanLine", outcurrentscanline, METH_VARARGS}, + {"close", outclose, METH_VARARGS}, + {NULL, NULL}, }; static void -OutputFile_dealloc(PyObject *self) +OutputFile_dealloc (PyObject* self) { - OutputFileC *object = ((OutputFileC *)self); - if (object->fo) - Py_DECREF(object->fo); - Py_DECREF(outclose(self, NULL)); - PyObject_Del(self); + OutputFileC* object = ((OutputFileC*) self); + if (object->fo) Py_DECREF (object->fo); + Py_DECREF (outclose (self, NULL)); + PyObject_Del (self); } -static PyObject * -OutputFile_Repr(PyObject *self) +static PyObject* +OutputFile_Repr (PyObject* self) { //PyObject *result = NULL; char buf[50]; - sprintf(buf, "OutputFile represented"); - return PyUnicode_FromString(buf); + sprintf (buf, "OutputFile represented"); + return PyUnicode_FromString (buf); } static PyTypeObject OutputFile_Type = { - PyVarObject_HEAD_INIT(&PyType_Type, 0) - "OpenEXR.OutputFile", - sizeof(OutputFileC), + PyVarObject_HEAD_INIT (&PyType_Type, 0) "OpenEXR.OutputFile", + sizeof (OutputFileC), 0, - (destructor)OutputFile_dealloc, + (destructor) OutputFile_dealloc, 0, 0, 0, 0, - (reprfunc)OutputFile_Repr, + (reprfunc) OutputFile_Repr, 0, //&InputFile_as_number, 0, //&InputFile_as_sequence, 0, @@ -976,9 +1120,9 @@ static PyTypeObject OutputFile_Type = { 0, 0, 0, - + 0, - + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, "OpenEXR Output file object", @@ -995,188 +1139,287 @@ static PyTypeObject OutputFile_Type = { /* the rest are NULLs */ }; -int makeOutputFile(PyObject *self, PyObject *args, PyObject *kwds) +int +makeOutputFile (PyObject* self, PyObject* args, PyObject* kwds) { - PyObject *fo; - PyObject *header_dict; - - char *filename = NULL; - - OutputFileC *object = (OutputFileC *)self; - - if (PyArg_ParseTuple(args, "OO!:OutputFile", &fo, &PyDict_Type, &header_dict)) { - if (PyString_Check(fo)) { - filename = PyString_AsString(fo); - object->fo = NULL; - object->ostream = NULL; - } else if (PyUnicode_Check(fo)) { - filename = PyUTF8_AsSstring(fo); - object->fo = NULL; - object->ostream = NULL; - } else { - object->fo = fo; - Py_INCREF(fo); - object->ostream = new C_OStream(fo); - } - } else { - return -1; - } + PyObject* fo; + PyObject* header_dict; + + char* filename = NULL; - Header header(64, 64); + OutputFileC* object = (OutputFileC*) self; - PyObject *pB2i = PyObject_GetAttrString(pModuleImath, "Box2i"); - PyObject *pB2f = PyObject_GetAttrString(pModuleImath, "Box2f"); - PyObject *pV2f = PyObject_GetAttrString(pModuleImath, "V2f"); - PyObject *pLO = PyObject_GetAttrString(pModuleImath, "LineOrder"); - PyObject *pCOMP = PyObject_GetAttrString(pModuleImath, "Compression"); - PyObject *pPI = PyObject_GetAttrString(pModuleImath, "PreviewImage"); - PyObject *pCH = PyObject_GetAttrString(pModuleImath, "Chromaticities"); - PyObject *pTD = PyObject_GetAttrString(pModuleImath, "TileDescription"); - PyObject *pRA = PyObject_GetAttrString(pModuleImath, "Rational"); - PyObject *pKA = PyObject_GetAttrString(pModuleImath, "KeyCode"); - PyObject *pTC = PyObject_GetAttrString(pModuleImath, "TimeCode"); + if (PyArg_ParseTuple ( + args, "OO!:OutputFile", &fo, &PyDict_Type, &header_dict)) + { + if (PyString_Check (fo)) + { + filename = PyString_AsString (fo); + object->fo = NULL; + object->ostream = NULL; + } + else if (PyUnicode_Check (fo)) + { + filename = PyUTF8_AsSstring (fo); + object->fo = NULL; + object->ostream = NULL; + } + else + { + object->fo = fo; + Py_INCREF (fo); + object->ostream = new C_OStream (fo); + } + } + else { return -1; } + + Header header (64, 64); + + PyObject* pB2i = PyObject_GetAttrString (pModuleImath, "Box2i"); + PyObject* pB2f = PyObject_GetAttrString (pModuleImath, "Box2f"); + PyObject* pV2f = PyObject_GetAttrString (pModuleImath, "V2f"); + PyObject* pLO = PyObject_GetAttrString (pModuleImath, "LineOrder"); + PyObject* pCOMP = PyObject_GetAttrString (pModuleImath, "Compression"); + PyObject* pPI = PyObject_GetAttrString (pModuleImath, "PreviewImage"); + PyObject* pCH = PyObject_GetAttrString (pModuleImath, "Chromaticities"); + PyObject* pTD = PyObject_GetAttrString (pModuleImath, "TileDescription"); + PyObject* pRA = PyObject_GetAttrString (pModuleImath, "Rational"); + PyObject* pKA = PyObject_GetAttrString (pModuleImath, "KeyCode"); + PyObject* pTC = PyObject_GetAttrString (pModuleImath, "TimeCode"); Py_ssize_t pos = 0; - PyObject *key, *value; + PyObject * key, *value; + + while (PyDict_Next (header_dict, &pos, &key, &value)) + { + const char* ks = PyUTF8_AsSstring (key); + if (PyFloat_Check (value)) + { + header.insert (ks, FloatAttribute (PyFloat_AsDouble (value))); + } + else if (PyInt_Check (value)) + { + header.insert (ks, IntAttribute (PyInt_AsLong (value))); + } + else if (PyBytes_Check (value)) + { + header.insert (ks, StringAttribute (PyString_AsString (value))); + } + else if (PyObject_IsInstance (value, pB2i)) + { + Box2i box ( + V2i ( + PyLong_AsLong (PyObject_StealAttrString ( + PyObject_StealAttrString (value, "min"), "x")), + PyLong_AsLong (PyObject_StealAttrString ( + PyObject_StealAttrString (value, "min"), "y"))), + V2i ( + PyLong_AsLong (PyObject_StealAttrString ( + PyObject_StealAttrString (value, "max"), "x")), + PyLong_AsLong (PyObject_StealAttrString ( + PyObject_StealAttrString (value, "max"), "y")))); + header.insert (ks, Box2iAttribute (box)); + } + else if (PyObject_IsInstance (value, pB2f)) + { + Box2f box ( + V2f ( + PyFloat_AsDouble (PyObject_StealAttrString ( + PyObject_StealAttrString (value, "min"), "x")), + PyFloat_AsDouble (PyObject_StealAttrString ( + PyObject_StealAttrString (value, "min"), "y"))), + V2f ( + PyFloat_AsDouble (PyObject_StealAttrString ( + PyObject_StealAttrString (value, "max"), "x")), + PyFloat_AsDouble (PyObject_StealAttrString ( + PyObject_StealAttrString (value, "max"), "y")))); + header.insert (ks, Box2fAttribute (box)); + } + else if (PyObject_IsInstance (value, pPI)) + { + PreviewImage pi ( + PyLong_AsLong (PyObject_StealAttrString (value, "width")), + PyLong_AsLong (PyObject_StealAttrString (value, "height")), + (Imf::PreviewRgba*) PyString_AsString ( + PyObject_StealAttrString (value, "pixels"))); + header.insert (ks, PreviewImageAttribute (pi)); + } + else if (PyObject_IsInstance (value, pV2f)) + { + V2f v ( + PyFloat_AsDouble (PyObject_StealAttrString (value, "x")), + PyFloat_AsDouble (PyObject_StealAttrString (value, "y"))); - while (PyDict_Next(header_dict, &pos, &key, &value)) { - const char *ks = PyUTF8_AsSstring(key); - if (PyFloat_Check(value)) { - header.insert(ks, FloatAttribute(PyFloat_AsDouble(value))); + header.insert (ks, V2fAttribute (v)); } - else if (PyInt_Check(value)) { - header.insert(ks, IntAttribute(PyInt_AsLong(value))); - } else if (PyBytes_Check(value)) { - header.insert(ks, StringAttribute(PyString_AsString(value))); - } else if (PyObject_IsInstance(value, pB2i)) { - Box2i box(V2i(PyLong_AsLong(PyObject_StealAttrString(PyObject_StealAttrString(value, "min"), "x")), - PyLong_AsLong(PyObject_StealAttrString(PyObject_StealAttrString(value, "min"), "y"))), - V2i(PyLong_AsLong(PyObject_StealAttrString(PyObject_StealAttrString(value, "max"), "x")), - PyLong_AsLong(PyObject_StealAttrString(PyObject_StealAttrString(value, "max"), "y")))); - header.insert(ks, Box2iAttribute(box)); - } else if (PyObject_IsInstance(value, pB2f)) { - Box2f box(V2f(PyFloat_AsDouble(PyObject_StealAttrString(PyObject_StealAttrString(value, "min"), "x")), - PyFloat_AsDouble(PyObject_StealAttrString(PyObject_StealAttrString(value, "min"), "y"))), - V2f(PyFloat_AsDouble(PyObject_StealAttrString(PyObject_StealAttrString(value, "max"), "x")), - PyFloat_AsDouble(PyObject_StealAttrString(PyObject_StealAttrString(value, "max"), "y")))); - header.insert(ks, Box2fAttribute(box)); - } else if (PyObject_IsInstance(value, pPI)) { - PreviewImage pi(PyLong_AsLong(PyObject_StealAttrString(value, "width")), - PyLong_AsLong(PyObject_StealAttrString(value, "height")), - (Imf::PreviewRgba *)PyString_AsString(PyObject_StealAttrString(value, "pixels"))); - header.insert(ks, PreviewImageAttribute(pi)); - } else if (PyObject_IsInstance(value, pV2f)) { - V2f v(PyFloat_AsDouble(PyObject_StealAttrString(value, "x")), PyFloat_AsDouble(PyObject_StealAttrString(value, "y"))); - - header.insert(ks, V2fAttribute(v)); - } else if (PyObject_IsInstance(value, pLO)) { - LineOrder i = (LineOrder)PyInt_AsLong(PyObject_StealAttrString(value, "v")); - - header.insert(ks, LineOrderAttribute(i)); - } else if (PyObject_IsInstance(value, pTC)) { - TimeCode v(PyLong_AsLong(PyObject_StealAttrString(value,"hours")), - PyLong_AsLong(PyObject_StealAttrString(value,"minutes")), - PyLong_AsLong(PyObject_StealAttrString(value,"seconds")), - PyLong_AsLong(PyObject_StealAttrString(value,"frame")), - PyLong_AsLong(PyObject_StealAttrString(value,"dropFrame")), - PyLong_AsLong(PyObject_StealAttrString(value,"colorFrame")), - PyLong_AsLong(PyObject_StealAttrString(value,"fieldPhase")), - PyLong_AsLong(PyObject_StealAttrString(value,"bgf0")), - PyLong_AsLong(PyObject_StealAttrString(value,"bgf1")), - PyLong_AsLong(PyObject_StealAttrString(value,"bgf2")), - PyLong_AsLong(PyObject_StealAttrString(value,"binaryGroup1")), - PyLong_AsLong(PyObject_StealAttrString(value,"binaryGroup2")), - PyLong_AsLong(PyObject_StealAttrString(value,"binaryGroup3")), - PyLong_AsLong(PyObject_StealAttrString(value,"binaryGroup4")), - PyLong_AsLong(PyObject_StealAttrString(value,"binaryGroup5")), - PyLong_AsLong(PyObject_StealAttrString(value,"binaryGroup6")), - PyLong_AsLong(PyObject_StealAttrString(value,"binaryGroup7")), - PyLong_AsLong(PyObject_StealAttrString(value,"binaryGroup8"))); - - header.insert(ks, TimeCodeAttribute(v)); - - } else if (PyObject_IsInstance(value, pKA)) { - KeyCode v(PyLong_AsLong(PyObject_StealAttrString(value, "filmMfcCode")), - PyLong_AsLong(PyObject_StealAttrString(value, "filmType")), - PyLong_AsLong(PyObject_StealAttrString(value, "prefix")), - PyLong_AsLong(PyObject_StealAttrString(value, "count")), - PyLong_AsLong(PyObject_StealAttrString(value, "perfOffset")), - PyLong_AsLong(PyObject_StealAttrString(value, "perfsPerFrame")), - PyLong_AsLong(PyObject_StealAttrString(value, "perfsPerCount"))); - header.insert(ks, KeyCodeAttribute(v)); - } else if (PyObject_IsInstance(value, pRA)) { - Rational v(PyLong_AsLong(PyObject_StealAttrString(value, "n")), PyLong_AsLong(PyObject_StealAttrString(value, "d"))); - header.insert(ks, RationalAttribute(v)); - } else if (PyObject_IsInstance(value, pCOMP)) { - Compression i = (Compression)PyInt_AsLong(PyObject_StealAttrString(value, "v")); - - header.insert(ks, CompressionAttribute(i)); - } else if (PyObject_IsInstance(value, pCH)) { - V2f red(PyFloat_AsDouble(PyObject_StealAttrString(PyObject_StealAttrString(value, "red"), "x")), - PyFloat_AsDouble(PyObject_StealAttrString(PyObject_StealAttrString(value, "red"), "y"))); - V2f green(PyFloat_AsDouble(PyObject_StealAttrString(PyObject_StealAttrString(value, "green"), "x")), - PyFloat_AsDouble(PyObject_StealAttrString(PyObject_StealAttrString(value, "green"), "y"))); - V2f blue(PyFloat_AsDouble(PyObject_StealAttrString(PyObject_StealAttrString(value, "blue"), "x")), - PyFloat_AsDouble(PyObject_StealAttrString(PyObject_StealAttrString(value, "blue"), "y"))); - V2f white(PyFloat_AsDouble(PyObject_StealAttrString(PyObject_StealAttrString(value, "white"), "x")), - PyFloat_AsDouble(PyObject_StealAttrString(PyObject_StealAttrString(value, "white"), "y"))); - Chromaticities c(red, green, blue, white); - header.insert(ks, ChromaticitiesAttribute(c)); - } else if (PyObject_IsInstance(value, pTD)) { - TileDescription td(PyInt_AsLong(PyObject_StealAttrString(value, "xSize")), - PyInt_AsLong(PyObject_StealAttrString(value, "ySize")), - (Imf::LevelMode)PyInt_AsLong(PyObject_StealAttrString(PyObject_StealAttrString(value, "mode"), "v")), - (Imf::LevelRoundingMode)PyInt_AsLong(PyObject_StealAttrString(PyObject_StealAttrString(value, "roundingMode"), "v")) - ); - header.insert(ks, TileDescriptionAttribute(td)); - } else if (PyDict_Check(value)) { - PyObject *key2, *value2; + else if (PyObject_IsInstance (value, pLO)) + { + LineOrder i = (LineOrder) PyInt_AsLong ( + PyObject_StealAttrString (value, "v")); + + header.insert (ks, LineOrderAttribute (i)); + } + else if (PyObject_IsInstance (value, pTC)) + { + TimeCode v ( + PyLong_AsLong (PyObject_StealAttrString (value, "hours")), + PyLong_AsLong (PyObject_StealAttrString (value, "minutes")), + PyLong_AsLong (PyObject_StealAttrString (value, "seconds")), + PyLong_AsLong (PyObject_StealAttrString (value, "frame")), + PyLong_AsLong (PyObject_StealAttrString (value, "dropFrame")), + PyLong_AsLong (PyObject_StealAttrString (value, "colorFrame")), + PyLong_AsLong (PyObject_StealAttrString (value, "fieldPhase")), + PyLong_AsLong (PyObject_StealAttrString (value, "bgf0")), + PyLong_AsLong (PyObject_StealAttrString (value, "bgf1")), + PyLong_AsLong (PyObject_StealAttrString (value, "bgf2")), + PyLong_AsLong ( + PyObject_StealAttrString (value, "binaryGroup1")), + PyLong_AsLong ( + PyObject_StealAttrString (value, "binaryGroup2")), + PyLong_AsLong ( + PyObject_StealAttrString (value, "binaryGroup3")), + PyLong_AsLong ( + PyObject_StealAttrString (value, "binaryGroup4")), + PyLong_AsLong ( + PyObject_StealAttrString (value, "binaryGroup5")), + PyLong_AsLong ( + PyObject_StealAttrString (value, "binaryGroup6")), + PyLong_AsLong ( + PyObject_StealAttrString (value, "binaryGroup7")), + PyLong_AsLong ( + PyObject_StealAttrString (value, "binaryGroup8"))); + + header.insert (ks, TimeCodeAttribute (v)); + } + else if (PyObject_IsInstance (value, pKA)) + { + KeyCode v ( + PyLong_AsLong (PyObject_StealAttrString (value, "filmMfcCode")), + PyLong_AsLong (PyObject_StealAttrString (value, "filmType")), + PyLong_AsLong (PyObject_StealAttrString (value, "prefix")), + PyLong_AsLong (PyObject_StealAttrString (value, "count")), + PyLong_AsLong (PyObject_StealAttrString (value, "perfOffset")), + PyLong_AsLong ( + PyObject_StealAttrString (value, "perfsPerFrame")), + PyLong_AsLong ( + PyObject_StealAttrString (value, "perfsPerCount"))); + header.insert (ks, KeyCodeAttribute (v)); + } + else if (PyObject_IsInstance (value, pRA)) + { + Rational v ( + PyLong_AsLong (PyObject_StealAttrString (value, "n")), + PyLong_AsLong (PyObject_StealAttrString (value, "d"))); + header.insert (ks, RationalAttribute (v)); + } + else if (PyObject_IsInstance (value, pCOMP)) + { + Compression i = (Compression) PyInt_AsLong ( + PyObject_StealAttrString (value, "v")); + + header.insert (ks, CompressionAttribute (i)); + } + else if (PyObject_IsInstance (value, pCH)) + { + V2f red ( + PyFloat_AsDouble (PyObject_StealAttrString ( + PyObject_StealAttrString (value, "red"), "x")), + PyFloat_AsDouble (PyObject_StealAttrString ( + PyObject_StealAttrString (value, "red"), "y"))); + V2f green ( + PyFloat_AsDouble (PyObject_StealAttrString ( + PyObject_StealAttrString (value, "green"), "x")), + PyFloat_AsDouble (PyObject_StealAttrString ( + PyObject_StealAttrString (value, "green"), "y"))); + V2f blue ( + PyFloat_AsDouble (PyObject_StealAttrString ( + PyObject_StealAttrString (value, "blue"), "x")), + PyFloat_AsDouble (PyObject_StealAttrString ( + PyObject_StealAttrString (value, "blue"), "y"))); + V2f white ( + PyFloat_AsDouble (PyObject_StealAttrString ( + PyObject_StealAttrString (value, "white"), "x")), + PyFloat_AsDouble (PyObject_StealAttrString ( + PyObject_StealAttrString (value, "white"), "y"))); + Chromaticities c (red, green, blue, white); + header.insert (ks, ChromaticitiesAttribute (c)); + } + else if (PyObject_IsInstance (value, pTD)) + { + TileDescription td ( + PyInt_AsLong (PyObject_StealAttrString (value, "xSize")), + PyInt_AsLong (PyObject_StealAttrString (value, "ySize")), + (Imf::LevelMode) PyInt_AsLong (PyObject_StealAttrString ( + PyObject_StealAttrString (value, "mode"), "v")), + (Imf::LevelRoundingMode) PyInt_AsLong ( + PyObject_StealAttrString ( + PyObject_StealAttrString (value, "roundingMode"), + "v"))); + header.insert (ks, TileDescriptionAttribute (td)); + } + else if (PyDict_Check (value)) + { + PyObject * key2, *value2; Py_ssize_t pos2 = 0; - while (PyDict_Next(value, &pos2, &key2, &value2)) { + while (PyDict_Next (value, &pos2, &key2, &value2)) + { if (0) - printf("%s -> %s\n", - PyString_AsString(key2), - PyString_AsString(PyObject_Str(PyObject_Type(value2)))); - header.channels().insert(PyUTF8_AsSstring(key2), - Channel(PixelType(PyLong_AsLong(PyObject_StealAttrString(PyObject_StealAttrString(value2, "type"), "v"))), - PyLong_AsLong(PyObject_StealAttrString(value2, "xSampling")), - PyLong_AsLong(PyObject_StealAttrString(value2, "ySampling")))); + printf ( + "%s -> %s\n", + PyString_AsString (key2), + PyString_AsString ( + PyObject_Str (PyObject_Type (value2)))); + header.channels ().insert ( + PyUTF8_AsSstring (key2), + Channel ( + PixelType (PyLong_AsLong (PyObject_StealAttrString ( + PyObject_StealAttrString (value2, "type"), "v"))), + PyLong_AsLong ( + PyObject_StealAttrString (value2, "xSampling")), + PyLong_AsLong ( + PyObject_StealAttrString (value2, "ySampling")))); } #ifdef INCLUDED_IMF_STRINGVECTOR_ATTRIBUTE_H - } else if (PyList_Check(value)) { - StringVector sv(PyList_Size(value)); - for (size_t i = 0; i < sv.size(); i++) - sv[i] = PyUTF8_AsSstring(PyList_GetItem(value, i)); - header.insert(ks, StringVectorAttribute(sv)); + } + else if (PyList_Check (value)) + { + StringVector sv (PyList_Size (value)); + for (size_t i = 0; i < sv.size (); i++) + sv[i] = PyUTF8_AsSstring (PyList_GetItem (value, i)); + header.insert (ks, StringVectorAttribute (sv)); #endif - } else { - printf("XXX - unknown attribute: %s\n", PyUTF8_AsSstring(PyObject_Str(key))); + } + else + { + printf ( + "XXX - unknown attribute: %s\n", + PyUTF8_AsSstring (PyObject_Str (key))); } } - Py_DECREF(pB2i); - Py_DECREF(pB2f); - Py_DECREF(pV2f); - Py_DECREF(pLO); - Py_DECREF(pCOMP); - Py_DECREF(pPI); - Py_DECREF(pCH); - Py_DECREF(pTD); - Py_DECREF(pRA); - Py_DECREF(pKA); - Py_DECREF(pTC); + Py_DECREF (pB2i); + Py_DECREF (pB2f); + Py_DECREF (pV2f); + Py_DECREF (pLO); + Py_DECREF (pCOMP); + Py_DECREF (pPI); + Py_DECREF (pCH); + Py_DECREF (pTD); + Py_DECREF (pRA); + Py_DECREF (pKA); + Py_DECREF (pTC); try { if (filename != NULL) - new(&object->o) OutputFile(filename, header); + new (&object->o) OutputFile (filename, header); else - new(&object->o) OutputFile(*object->ostream, header); + new (&object->o) OutputFile (*object->ostream, header); } - catch (const std::exception &e) + catch (const std::exception& e) { - PyErr_SetString(PyExc_IOError, e.what()); + PyErr_SetString (PyExc_IOError, e.what ()); return -1; } object->is_opened = 1; @@ -1185,46 +1428,47 @@ int makeOutputFile(PyObject *self, PyObject *args, PyObject *kwds) //////////////////////////////////////////////////////////////////////// -PyObject *makeHeader(PyObject *self, PyObject *args) +PyObject* +makeHeader (PyObject* self, PyObject* args) { - int w, h; - const char *channels = "R,G,B"; - if (!PyArg_ParseTuple(args, "ii|s:Header", &w, &h, &channels)) - return NULL; - Header header(w, h); - for (auto channel : split(channels, ',')) { - header.channels().insert(channel.c_str(), Channel(FLOAT)); + int w, h; + const char* channels = "R,G,B"; + if (!PyArg_ParseTuple (args, "ii|s:Header", &w, &h, &channels)) return NULL; + Header header (w, h); + for (auto channel: split (channels, ',')) + { + header.channels ().insert (channel.c_str (), Channel (FLOAT)); } - return dict_from_header(header); + return dict_from_header (header); } //////////////////////////////////////////////////////////////////////// -static bool -isOpenExrFile (const char fileName[]) -{ - std::ifstream f (fileName, std::ios_base::binary); - char bytes[4]; - f.read (bytes, sizeof (bytes)); - return !!f && Imf::isImfMagic (bytes); -} - +static bool +isOpenExrFile (const char fileName[]) +{ + std::ifstream f (fileName, std::ios_base::binary); + char bytes[4]; + f.read (bytes, sizeof (bytes)); + return !!f && Imf::isImfMagic (bytes); +} -PyObject *_isOpenExrFile(PyObject *self, PyObject *args) +PyObject* +_isOpenExrFile (PyObject* self, PyObject* args) { - char *filename; - if (!PyArg_ParseTuple(args, "s:isOpenExrFile", &filename)) - return NULL; - return PyBool_FromLong(isOpenExrFile(filename)); + char* filename; + if (!PyArg_ParseTuple (args, "s:isOpenExrFile", &filename)) return NULL; + return PyBool_FromLong (isOpenExrFile (filename)); } #ifdef VERSION_HAS_ISTILED -PyObject *_isTiledOpenExrFile(PyObject *self, PyObject *args) +PyObject* +_isTiledOpenExrFile (PyObject* self, PyObject* args) { - char *filename; - if (!PyArg_ParseTuple(args, "s:isTiledOpenExrFile", &filename)) + char* filename; + if (!PyArg_ParseTuple (args, "s:isTiledOpenExrFile", &filename)) return NULL; - return PyBool_FromLong(isTiledOpenExrFile(filename)); + return PyBool_FromLong (isTiledOpenExrFile (filename)); } #endif @@ -1239,40 +1483,41 @@ static PyMethodDef methods[] = { {NULL, NULL}, }; -MOD_INIT(OpenEXR) +MOD_INIT (OpenEXR) { PyObject *m, *d, *item; - Imf::staticInitialize(); + Imf::staticInitialize (); - MOD_DEF(m, "OpenEXR", "", methods) - d = PyModule_GetDict(m); + MOD_DEF (m, "OpenEXR", "", methods) + d = PyModule_GetDict (m); - pModuleImath = PyImport_ImportModule("Imath"); + pModuleImath = PyImport_ImportModule ("Imath"); /* initialize module variables/constants */ - InputFile_Type.tp_new = PyType_GenericNew; - InputFile_Type.tp_init = makeInputFile; - OutputFile_Type.tp_new = PyType_GenericNew; + InputFile_Type.tp_new = PyType_GenericNew; + InputFile_Type.tp_init = makeInputFile; + OutputFile_Type.tp_new = PyType_GenericNew; OutputFile_Type.tp_init = makeOutputFile; - if (PyType_Ready(&InputFile_Type) != 0) - return MOD_ERROR_VAL; - if (PyType_Ready(&OutputFile_Type) != 0) - return MOD_ERROR_VAL; - PyModule_AddObject(m, "InputFile", (PyObject *)&InputFile_Type); - PyModule_AddObject(m, "OutputFile", (PyObject *)&OutputFile_Type); + if (PyType_Ready (&InputFile_Type) != 0) return MOD_ERROR_VAL; + if (PyType_Ready (&OutputFile_Type) != 0) return MOD_ERROR_VAL; + PyModule_AddObject (m, "InputFile", (PyObject*) &InputFile_Type); + PyModule_AddObject (m, "OutputFile", (PyObject*) &OutputFile_Type); #if PYTHON_API_VERSION >= 1007 - OpenEXR_error = PyErr_NewException((char*)"OpenEXR.error", NULL, NULL); + OpenEXR_error = PyErr_NewException ((char*) "OpenEXR.error", NULL, NULL); #else - OpenEXR_error = PyString_FromString("OpenEXR.error"); + OpenEXR_error = PyString_FromString ("OpenEXR.error"); #endif - PyDict_SetItemString(d, "error", OpenEXR_error); - Py_DECREF(OpenEXR_error); + PyDict_SetItemString (d, "error", OpenEXR_error); + Py_DECREF (OpenEXR_error); - PyDict_SetItemString(d, "UINT", item= PyLong_FromLong(UINT)); Py_DECREF(item); - PyDict_SetItemString(d, "HALF", item= PyLong_FromLong(HALF)); Py_DECREF(item); - PyDict_SetItemString(d, "FLOAT", item= PyLong_FromLong(FLOAT)); Py_DECREF(item); + PyDict_SetItemString (d, "UINT", item = PyLong_FromLong (UINT)); + Py_DECREF (item); + PyDict_SetItemString (d, "HALF", item = PyLong_FromLong (HALF)); + Py_DECREF (item); + PyDict_SetItemString (d, "FLOAT", item = PyLong_FromLong (FLOAT)); + Py_DECREF (item); - return MOD_SUCCESS_VAL(m); + return MOD_SUCCESS_VAL (m); }