Fix OpenCV build with OpenEXR before 2.2.0.
authorAlexander Smorkalov <alexander.smorkalov@xperience.ai>
Wed, 28 Apr 2021 07:41:59 +0000 (10:41 +0300)
committerAlexander Smorkalov <alexander.smorkalov@xperience.ai>
Thu, 29 Apr 2021 06:50:30 +0000 (09:50 +0300)
modules/imgcodecs/include/opencv2/imgcodecs.hpp
modules/imgcodecs/src/grfmt_exr.cpp

index 42227f3788e5f96508c1e64bf41f0935bb443025..101a944146d24f0aa04d0e1c314a0c8c6cdd38f1 100644 (file)
@@ -120,8 +120,8 @@ enum ImwriteEXRCompressionFlags {
        IMWRITE_EXR_COMPRESSION_PXR24 = 5, //!< lossy 24-bit float compression
        IMWRITE_EXR_COMPRESSION_B44   = 6, //!< lossy 4-by-4 pixel block compression, fixed compression rate
        IMWRITE_EXR_COMPRESSION_B44A  = 7, //!< lossy 4-by-4 pixel block compression, flat fields are compressed more
-       IMWRITE_EXR_COMPRESSION_DWAA  = 8, //!< lossy DCT based compression, in blocks of 32 scanlines. More efficient for partial buffer access.
-       IMWRITE_EXR_COMPRESSION_DWAB  = 9, //!< lossy DCT based compression, in blocks of 256 scanlines. More efficient space wise and faster to decode full frames than DWAA_COMPRESSION.
+       IMWRITE_EXR_COMPRESSION_DWAA  = 8, //!< lossy DCT based compression, in blocks of 32 scanlines. More efficient for partial buffer access. Supported since OpenEXR 2.2.0.
+       IMWRITE_EXR_COMPRESSION_DWAB  = 9, //!< lossy DCT based compression, in blocks of 256 scanlines. More efficient space wise and faster to decode full frames than DWAA_COMPRESSION. Supported since OpenEXR 2.2.0.
      };
 
 //! Imwrite PNG specific flags used to tune the compression algorithm.
index aaf28eead6f7882c0e402310385bca4482c02926..7acaf434c682ea8557ad10e6189820ffb33e9fdc 100644 (file)
@@ -64,6 +64,7 @@
 #include <ImfStandardAttributes.h>
 #include <half.h>
 #include "grfmt_exr.hpp"
+#include "OpenEXRConfig.h"
 
 #if defined _WIN32
 
@@ -649,12 +650,14 @@ bool  ExrEncoder::write( const Mat& img, const std::vector<int>& params )
             case IMWRITE_EXR_COMPRESSION_B44A:
                 header.compression() = B44A_COMPRESSION;
                 break;
+#if ((OPENEXR_VERSION_MAJOR * 1000 + OPENEXR_VERSION_MINOR) >= (2 * 1000 + 2)) // available since version 2.2.0
             case IMWRITE_EXR_COMPRESSION_DWAA:
                 header.compression() = DWAA_COMPRESSION;
                 break;
             case IMWRITE_EXR_COMPRESSION_DWAB:
                 header.compression() = DWAB_COMPRESSION;
                 break;
+#endif
             default:
                 CV_Error(Error::StsBadArg, "IMWRITE_EXR_COMPRESSION is invalid or not supported");
             }