diff --git a/CMakeLists.txt b/CMakeLists.txt index 04f146d7..45b82bd1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,10 +16,16 @@ set(RAWTOACES_UTIL_LIB "rawtoaces_util") set( CMAKE_MACOSX_RPATH 1 ) +# Set strict compiler flags by default for all builds if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") -# set(warnings "/W4 /WX /EHsc") - add_compile_options ( /W0 ) + # MSVC strict flags + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX /EHsc") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4 /WX") add_compile_definitions( NOMINMAX ) +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + # GCC/Clang strict flags + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -pedantic") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wall -Wextra -pedantic") endif() if (NOT CONFIGURED_ONCE) diff --git a/src/rawtoaces_core/define.h b/src/rawtoaces_core/define.h index 398fcec6..52dbf677 100644 --- a/src/rawtoaces_core/define.h +++ b/src/rawtoaces_core/define.h @@ -24,7 +24,7 @@ # include //# define snprintf _snprintf # define _CRT_SECURE_NO_WARNINGS -# define cmp_str stricmp +# define cmp_str _stricmp #else # define cmp_str strcasecmp #endif @@ -37,11 +37,6 @@ # define FALSE 0 #endif -#define FORI( val ) for ( int i = 0; i < val; i++ ) -#define FORJ( val ) for ( int j = 0; j < val; j++ ) -#define FORIJ( val1, val2 ) \ - for ( int i = 0; i < val1; i++ ) \ - for ( int j = 0; j < val2; j++ ) #define countSize( a ) ( static_cast( sizeof( a ) / sizeof( ( a )[0] ) ) ) namespace rta @@ -263,16 +258,16 @@ inline std::vector openDir( std::string path = "." ) } return paths; -}; +} // Function to covert upper-case to lower-case inline void lowerCase( char *tex ) { std::string tmp( tex ); - FORI( tmp.size() ) - tex[i] = tolower( tex[i] ); -}; + for ( size_t i = 0; i < tmp.size(); i++ ) + tex[i] = static_cast( tolower( tex[i] ) ); +} // Function to check if a value is numeric inline bool isNumeric( const char *val ) @@ -283,7 +278,7 @@ inline bool isNumeric( const char *val ) return ( input.find_first_not_of( base.substr( 0, base.size() ) ) == std::string::npos ); -}; +} // Function to check if a input is a alphabetic letter inline bool isCTLetterDigit( const char c ) @@ -291,13 +286,13 @@ inline bool isCTLetterDigit( const char c ) return ( ( c >= 'a' && c <= 'z' ) || ( c >= 'A' && c <= 'Z' ) || ( c == '-' ) || isdigit( c ) ); -}; +} // Function to check if a string is a valid input // to represent color temperature(s) (e.g., D60, 3200K) inline bool isValidCT( std::string str ) { - int i = 0; + size_t i = 0; size_t length = str.length(); if ( length == 0 ) @@ -344,7 +339,7 @@ inline bool isValidCT( std::string str ) return false; return true; -}; +} } // namespace core } // namespace rta diff --git a/src/rawtoaces_core/mathOps.h b/src/rawtoaces_core/mathOps.h index 3f96764f..658b4e6b 100644 --- a/src/rawtoaces_core/mathOps.h +++ b/src/rawtoaces_core/mathOps.h @@ -23,14 +23,14 @@ namespace core template int isSquare( const vector> &vm ) { - FORI( vm.size() ) + for ( size_t i = 0; i < vm.size(); i++ ) { if ( vm[i].size() != vm.size() ) return 0; } return 1; -}; +} template vector addVectors( const vector &vectorA, const vector &vectorB ) @@ -45,7 +45,7 @@ vector addVectors( const vector &vectorA, const vector &vectorB ) std::back_inserter( sum ), std::plus() ); return sum; -}; +} template vector subVectors( const vector &vectorA, const vector &vectorB ) @@ -60,7 +60,7 @@ vector subVectors( const vector &vectorA, const vector &vectorB ) std::back_inserter( diff ), std::minus() ); return diff; -}; +} /// Calculate the 2D cross product (scalar) of two 2D vectors. /// This function computes the cross product of two 2D vectors, which results in a scalar @@ -77,7 +77,7 @@ T cross2d_scalar( const vector &vectorA, const vector &vectorB ) { assert( vectorA.size() == 2 && vectorB.size() == 2 ); return vectorA[0] * vectorB[1] - vectorA[1] * vectorB[0]; -}; +} template vector> invertVM( const vector> &vMtx ) @@ -86,7 +86,9 @@ vector> invertVM( const vector> &vMtx ) Eigen::Matrix m; m.resize( vMtx.size(), vMtx[0].size() ); - FORIJ( m.rows(), m.cols() ) m( i, j ) = vMtx[i][j]; + for ( Eigen::Index i = 0; i < m.rows(); i++ ) + for ( Eigen::Index j = 0; j < m.cols(); j++ ) + m( i, j ) = vMtx[i][j]; // Map < Eigen::Matrix < T, Eigen::Dynamic, Eigen::Dynamic, RowMajor > > m (vMtx[0]); // m.resize(vMtx.size(), vMtx[0].size()); @@ -94,41 +96,46 @@ vector> invertVM( const vector> &vMtx ) m = m.inverse(); vector> vMtxR( m.rows(), vector( m.cols() ) ); - FORIJ( m.rows(), m.cols() ) vMtxR[i][j] = m( i, j ); + for ( Eigen::Index i = 0; i < m.rows(); i++ ) + for ( Eigen::Index j = 0; j < m.cols(); j++ ) + vMtxR[i][j] = m( i, j ); return vMtxR; -}; +} template vector invertV( const vector &vMtx ) { - int size = std::sqrt( static_cast( vMtx.size() ) ); + size_t size = static_cast( std::sqrt( vMtx.size() ) ); vector> tmp( size, vector( size ) ); - FORIJ( size, size ) - tmp[i][j] = vMtx[i * size + j]; + for ( size_t i = 0; i < size; i++ ) + for ( size_t j = 0; j < size; j++ ) + tmp[i][j] = vMtx[i * size + j]; tmp = invertVM( tmp ); vector result( vMtx.size() ); - FORIJ( size, size ) result[i * size + j] = tmp[i][j]; + for ( size_t i = 0; i < size; i++ ) + for ( size_t j = 0; j < size; j++ ) + result[i * size + j] = tmp[i][j]; return result; -}; +} template vector diagV( const vector &vct ) { assert( vct.size() != 0 ); - int length = static_cast( vct.size() ); + size_t length = vct.size(); vector vctdiag( length * length, T( 0.0 ) ); - FORI( length ) + for ( size_t i = 0; i < length; i++ ) { vctdiag[i * length + i] = vct[i]; } return vctdiag; -}; +} template vector> transposeVec( const vector> &vMtx ) @@ -138,51 +145,58 @@ vector> transposeVec( const vector> &vMtx ) Eigen::Matrix m; m.resize( vMtx.size(), vMtx[0].size() ); - FORIJ( m.rows(), m.cols() ) m( i, j ) = vMtx[i][j]; + for ( Eigen::Index i = 0; i < m.rows(); i++ ) + for ( Eigen::Index j = 0; j < m.cols(); j++ ) + m( i, j ) = vMtx[i][j]; m.transposeInPlace(); vector> vTran( m.rows(), vector( m.cols() ) ); - FORIJ( m.rows(), m.cols() ) vTran[i][j] = m( i, j ); + for ( Eigen::Index i = 0; i < m.rows(); i++ ) + for ( Eigen::Index j = 0; j < m.cols(); j++ ) + vTran[i][j] = m( i, j ); return vTran; -}; +} template T sumVector( const vector &vct ) { Eigen::Matrix v; v.resize( vct.size(), 1 ); - FORI( v.rows() ) v( i, 0 ) = vct[i]; + for ( Eigen::Index i = 0; i < v.rows(); i++ ) + v( i, 0 ) = vct[i]; return v.sum(); -}; +} template T sumVectorM( const vector> &vct ) { size_t row = vct.size(); size_t col = vct[0].size(); - T sum = T( 0 ); Eigen::Matrix v; v.resize( row * col, 1 ); - FORIJ( row, col ) - v( i * col + j ) = vct[i][j]; + for ( size_t i = 0; i < row; i++ ) + for ( size_t j = 0; j < col; j++ ) + v( i * col + j ) = vct[i][j]; return v.sum(); -}; +} template void scaleVector( vector &vct, const T scale ) { Eigen::Matrix v; v.resize( vct.size(), 1 ); - FORI( vct.size() ) v( i, 0 ) = vct[i]; + for ( size_t i = 0; i < vct.size(); i++ ) + v( i, 0 ) = vct[i]; v *= scale; - FORI( vct.size() ) vct[i] = v( i, 0 ); + for ( size_t i = 0; i < vct.size(); i++ ) + vct[i] = v( i, 0 ); return; -}; +} template vector mulVectorElement( const vector &vct1, const vector &vct2 ) @@ -193,7 +207,7 @@ vector mulVectorElement( const vector &vct1, const vector &vct2 ) a1.resize( vct1.size(), 1 ); a2.resize( vct1.size(), 1 ); - FORI( a1.rows() ) + for ( Eigen::Index i = 0; i < a1.rows(); i++ ) { a1( i, 0 ) = vct1[i]; a2( i, 0 ) = vct2[i]; @@ -203,13 +217,13 @@ vector mulVectorElement( const vector &vct1, const vector &vct2 ) vector vct3( a1.data(), a1.data() + a1.rows() * a1.cols() ); return vct3; -}; +} template vector mulVector( vector vct1, vector vct2, int k = 3 ) { - int rows = ( static_cast( vct1.size() ) ) / k; - int cols = ( static_cast( vct2.size() ) ) / k; + size_t rows = vct1.size() / k; + size_t cols = vct2.size() / k; assert( rows * k == vct1.size() ); assert( k * cols == vct2.size() ); @@ -219,11 +233,11 @@ vector mulVector( vector vct1, vector vct2, int k = 3 ) T *pB = &vct2[0]; T *pC = &vct3[0]; - for ( int r = 0; r < rows; r++ ) + for ( size_t r = 0; r < rows; r++ ) { for ( int cArB = 0; cArB < k; cArB++ ) { - for ( int c = 0; c < cols; c++ ) + for ( size_t c = 0; c < cols; c++ ) { pC[r * cols + c] += pA[r * k + cArB] * pB[cArB * cols + c]; } @@ -231,7 +245,7 @@ vector mulVector( vector vct1, vector vct2, int k = 3 ) } return vct3; -}; +} template vector> @@ -243,18 +257,22 @@ mulVector( const vector> &vct1, const vector> &vct2 ) m1.resize( vct1.size(), vct1[0].size() ); m2.resize( vct2[0].size(), vct2.size() ); - FORIJ( m1.rows(), m1.cols() ) - m1( i, j ) = vct1[i][j]; - FORIJ( m2.rows(), m2.cols() ) - m2( i, j ) = vct2[j][i]; + for ( Eigen::Index i = 0; i < m1.rows(); i++ ) + for ( Eigen::Index j = 0; j < m1.cols(); j++ ) + m1( i, j ) = vct1[i][j]; + for ( Eigen::Index i = 0; i < m2.rows(); i++ ) + for ( Eigen::Index j = 0; j < m2.cols(); j++ ) + m2( i, j ) = vct2[j][i]; m3 = m1 * m2; vector> vct3( m3.rows(), vector( m3.cols() ) ); - FORIJ( m3.rows(), m3.cols() ) vct3[i][j] = m3( i, j ); + for ( Eigen::Index i = 0; i < m3.rows(); i++ ) + for ( Eigen::Index j = 0; j < m3.cols(); j++ ) + vct3[i][j] = m3( i, j ); return vct3; -}; +} template vector mulVector( const vector> &vct1, const vector &vct2 ) @@ -265,23 +283,24 @@ vector mulVector( const vector> &vct1, const vector &vct2 ) m1.resize( vct1.size(), vct1[0].size() ); m2.resize( vct2.size(), 1 ); - FORIJ( m1.rows(), m1.cols() ) - m1( i, j ) = vct1[i][j]; - FORI( m2.rows() ) - m2( i, 0 ) = vct2[i]; + for ( Eigen::Index i = 0; i < m1.rows(); i++ ) + for ( Eigen::Index j = 0; j < m1.cols(); j++ ) + m1( i, j ) = vct1[i][j]; + for ( Eigen::Index i = 0; i < m2.rows(); i++ ) + m2( i, 0 ) = vct2[i]; m3 = m1 * m2; vector vct3( m3.data(), m3.data() + m3.rows() * m3.cols() ); return vct3; -}; +} template vector mulVector( const vector &vct1, const vector> &vct2 ) { return mulVector( vct2, vct1 ); -}; +} /// Calculate the Sum of Squared Errors (SSE) between two vectors. /// The SSE measures how well the calculated values (tcp) match the reference values (src). @@ -298,30 +317,30 @@ T calculate_SSE( const vector &tcp, const vector &src ) vector tmp( src.size() ); T sum = T( 0.0 ); - FORI( tcp.size() ) - sum += std::pow( ( tcp[i] / src[i] - 1.0 ), T( 2.0 ) ); + for ( size_t i = 0; i < tcp.size(); i++ ) + sum += std::pow( ( tcp[i] / src[i] - 1.0 ), T( 2.0 ) ); return sum; -}; +} template -int findIndexInterp1( T val, const vector &x, int size ) +int findIndexInterp1( T val, const vector &x, size_t size ) { T dist = T( 1e9 ); int index = -1; - FORI( size ) + for ( size_t i = 0; i < size; i++ ) { T tmp = val - x[i]; if ( tmp < dist && tmp >= T( 0 ) ) { dist = tmp; - index = i; + index = static_cast( i ); } } return index; -}; +} template vector interp1DLinear( @@ -331,7 +350,7 @@ vector interp1DLinear( vector slope, intercept, Y1; - FORI( X0.size() - 1 ) + for ( size_t i = 0; i < X0.size() - 1; i++ ) { slope.push_back( ( Y0[i + 1] - Y0[i] ) / ( X0[i + 1] - X0[i] ) ); intercept.push_back( Y0[i] - X0[i] * slope[i] ); @@ -340,9 +359,9 @@ vector interp1DLinear( slope.push_back( slope[slope.size() - 1] ); intercept.push_back( intercept[intercept.size() - 1] ); - FORI( X1.size() ) + for ( size_t i = 0; i < X1.size(); i++ ) { - int index = findIndexInterp1( X1[i], X0, int( X0.size() ) ); + int index = findIndexInterp1( X1[i], X0, X0.size() ); if ( index != -1 ) Y1.push_back( slope[index] * X1[i] + intercept[index] ); else @@ -350,7 +369,7 @@ vector interp1DLinear( } return Y1; -}; +} template vector xy_to_XYZ( const vector &xy ) { @@ -360,7 +379,7 @@ template vector xy_to_XYZ( const vector &xy ) XYZ[2] = 1 - xy[0] - xy[1]; return XYZ; -}; +} template vector uv_to_xy( const vector &uv ) { @@ -372,12 +391,12 @@ template vector uv_to_xy( const vector &uv ) scaleVector( xyScale, 1.0 / scale ); return xyScale; -}; +} template vector uv_to_XYZ( const vector &uv ) { return xy_to_XYZ( uv_to_xy( uv ) ); -}; +} template vector XYZ_to_uv( const vector &XYZ ) { @@ -392,7 +411,7 @@ template vector XYZ_to_uv( const vector &XYZ ) scaleVector( uvScale, 1.0 / scale ); return uvScale; -}; +} template std::vector> calculate_CAT( @@ -420,17 +439,18 @@ vector> XYZ_to_LAB( const vector> &XYZ ) T add = T( 16.0 / 116.0 ); vector> tmpXYZ( XYZ.size(), vector( 3, T( 1.0 ) ) ); - FORIJ( XYZ.size(), 3 ) - { - tmpXYZ[i][j] = XYZ[i][j] / ACES_white_point_XYZ[j]; - if ( tmpXYZ[i][j] > T( e ) ) - tmpXYZ[i][j] = ceres::pow( tmpXYZ[i][j], T( 1.0 / 3.0 ) ); - else - tmpXYZ[i][j] = T( k ) * tmpXYZ[i][j] + add; - } + for ( size_t i = 0; i < XYZ.size(); i++ ) + for ( size_t j = 0; j < 3; j++ ) + { + tmpXYZ[i][j] = XYZ[i][j] / ACES_white_point_XYZ[j]; + if ( tmpXYZ[i][j] > T( e ) ) + tmpXYZ[i][j] = ceres::pow( tmpXYZ[i][j], T( 1.0 / 3.0 ) ); + else + tmpXYZ[i][j] = T( k ) * tmpXYZ[i][j] + add; + } vector> outCalcLab( XYZ.size(), vector( 3 ) ); - FORI( XYZ.size() ) + for ( size_t i = 0; i < XYZ.size(); i++ ) { outCalcLab[i][0] = T( 116.0 ) * tmpXYZ[i][1] - T( 16.0 ); outCalcLab[i][1] = T( 500.0 ) * ( tmpXYZ[i][0] - tmpXYZ[i][1] ); @@ -438,7 +458,7 @@ vector> XYZ_to_LAB( const vector> &XYZ ) } return outCalcLab; -}; +} template vector> @@ -449,7 +469,9 @@ getCalcXYZt( const vector> &RGB, const T beta_params[6] ) vector> BV( 3, vector( 3 ) ); vector> M( 3, vector( 3 ) ); - FORIJ( 3, 3 ) M[i][j] = T( acesrgb_XYZ_3[i][j] ); + for ( size_t i = 0; i < 3; i++ ) + for ( size_t j = 0; j < 3; j++ ) + M[i][j] = T( acesrgb_XYZ_3[i][j] ); BV[0][0] = beta_params[0]; BV[0][1] = beta_params[1]; @@ -464,7 +486,7 @@ getCalcXYZt( const vector> &RGB, const T beta_params[6] ) vector> outCalcXYZt = mulVector( mulVector( RGB, BV ), M ); return outCalcXYZt; -}; +} } // namespace core } // namespace rta diff --git a/src/rawtoaces_core/rawtoaces_core.cpp b/src/rawtoaces_core/rawtoaces_core.cpp index 84cef571..88834ce2 100644 --- a/src/rawtoaces_core/rawtoaces_core.cpp +++ b/src/rawtoaces_core/rawtoaces_core.cpp @@ -44,7 +44,7 @@ vector CCT_to_xy( const double &cct ) void calculate_daylight_SPD( const int &cct_input, Spectrum &spectrum ) { - int step = spectrum.shape.step; + int step = static_cast( spectrum.shape.step ); int wavelength_range = s_series[53].wl - s_series[0].wl; assert( wavelength_range % step == 0 ); @@ -72,7 +72,7 @@ void calculate_daylight_SPD( const int &cct_input, Spectrum &spectrum ) double m1 = ( -1.3515 - 1.7703 * xy[0] + 5.9114 * xy[1] ) / m0; double m2 = ( 0.03000 - 31.4424 * xy[0] + 30.0717 * xy[1] ) / m0; - FORI( countSize( s_series ) ) + for ( int i = 0; i < countSize( s_series ); i++ ) { wavelengths.push_back( s_series[i].wl ); s00.push_back( s_series[i].RGB[0] ); @@ -81,7 +81,7 @@ void calculate_daylight_SPD( const int &cct_input, Spectrum &spectrum ) } int num_wavelengths = wavelength_range / step + 1; - FORI( num_wavelengths ) + for ( int i = 0; i < num_wavelengths; i++ ) { wavelengths_interpolated.push_back( s_series[0].wl + step * i ); } @@ -90,7 +90,7 @@ void calculate_daylight_SPD( const int &cct_input, Spectrum &spectrum ) s11 = interp1DLinear( wavelengths, wavelengths_interpolated, s10 ); s21 = interp1DLinear( wavelengths, wavelengths_interpolated, s20 ); - FORI( num_wavelengths ) + for ( int i = 0; i < num_wavelengths; i++ ) { int wavelength = s_series[0].wl + step * i; if ( wavelength >= 380 && wavelength <= 780 ) @@ -170,11 +170,11 @@ SpectralSolver::SpectralSolver( verbosity = 0; _IDT_matrix.resize( 3 ); _WB_multipliers.resize( 3 ); - FORI( 3 ) + for ( int i = 0; i < 3; i++ ) { _IDT_matrix[i].resize( 3 ); _WB_multipliers[i] = 1.0; - FORJ( 3 ) + for ( size_t j = 0; j < 3; j++ ) { _IDT_matrix[i][j] = neutral3[i][j]; } @@ -272,12 +272,12 @@ bool SpectralSolver::load_spectral_data( { for ( const auto &directory: _search_directories ) { - std::filesystem::path path( directory ); - path.append( file_path ); + std::filesystem::path search_path( directory ); + search_path.append( file_path ); - if ( std::filesystem::exists( path ) ) + if ( std::filesystem::exists( search_path ) ) { - return out_data.load( path.string() ); + return out_data.load( search_path.string() ); } } @@ -320,16 +320,16 @@ bool SpectralSolver::find_illuminant( const std::string &type ) if ( is_daylight ) { - int cct = atoi( type.substr( 1 ).c_str() ); - const std::string type = "d" + std::to_string( cct ); - generate_illuminant( cct, type, true, illuminant ); + int cct = atoi( type.substr( 1 ).c_str() ); + const std::string illuminant_type = "d" + std::to_string( cct ); + generate_illuminant( cct, illuminant_type, true, illuminant ); return true; } else if ( is_blackbody ) { int cct = atoi( type.substr( 0, type.length() - 1 ).c_str() ); - const std::string type = std::to_string( cct ) + "k"; - generate_illuminant( cct, type, false, illuminant ); + const std::string illuminant_type = std::to_string( cct ) + "k"; + generate_illuminant( cct, illuminant_type, false, illuminant ); return true; } else @@ -364,25 +364,25 @@ bool SpectralSolver::find_illuminant( const vector &wb ) // Daylight - pre-calculate for ( int cct = 4000; cct <= 25000; cct += 500 ) { - SpectralData &illuminant = _all_illuminants.emplace_back(); - const std::string type = "d" + std::to_string( cct / 100 ); - generate_illuminant( cct, type, true, illuminant ); + SpectralData &illuminant_data = _all_illuminants.emplace_back(); + const std::string type = "d" + std::to_string( cct / 100 ); + generate_illuminant( cct, type, true, illuminant_data ); } // Blackbody - pre-calculate for ( int cct = 1500; cct < 4000; cct += 500 ) { - SpectralData &illuminant = _all_illuminants.emplace_back(); - const std::string type = std::to_string( cct ) + "k"; - generate_illuminant( cct, type, false, illuminant ); + SpectralData &illuminant_data = _all_illuminants.emplace_back(); + const std::string type = std::to_string( cct ) + "k"; + generate_illuminant( cct, type, false, illuminant_data ); } auto illuminant_files = collect_data_files( "illuminant" ); for ( const auto &illuminant_file: illuminant_files ) { - SpectralData &illuminant = _all_illuminants.emplace_back(); - if ( !illuminant.load( illuminant_file ) ) + SpectralData &illuminant_data = _all_illuminants.emplace_back(); + if ( !illuminant_data.load( illuminant_file ) ) { _all_illuminants.pop_back(); continue; @@ -578,17 +578,15 @@ std::vector> calculate_XYZ( /// @return 2D vector containing RGB values for each training patch std::vector> calculate_RGB( const SpectralData &camera, - const SpectralData &illuminant, const std::vector &WB_multipliers, const std::vector &training_illuminants ) { assert( training_illuminants.size() > 0 ); assert( training_illuminants[0].values.size() == 81 ); - const Spectrum &camera_r = camera["R"]; - const Spectrum &camera_g = camera["G"]; - const Spectrum &camera_b = camera["B"]; - const Spectrum &illuminant_spectrum = illuminant["power"]; + const Spectrum &camera_r = camera["R"]; + const Spectrum &camera_g = camera["G"]; + const Spectrum &camera_b = camera["B"]; std::vector> RGB; for ( auto &training_illuminant: training_illuminants ) @@ -691,7 +689,7 @@ bool curveFit( if ( verbosity > 1 ) { printf( "The IDT matrix is ...\n" ); - FORI( 3 ) + for ( int i = 0; i < 3; i++ ) { printf( " %f %f %f\n", @@ -748,7 +746,7 @@ bool SpectralSolver::calculate_IDT_matrix() double beta_params_start[6] = { 1.0, 0.0, 0.0, 1.0, 0.0, 0.0 }; auto TI = calculate_TI( illuminant, training_data ); - auto RGB = calculate_RGB( camera, illuminant, _WB_multipliers, TI ); + auto RGB = calculate_RGB( camera, _WB_multipliers, TI ); auto XYZ = calculate_XYZ( observer, illuminant, TI ); return curveFit( RGB, XYZ, beta_params_start, verbosity, _IDT_matrix ); @@ -843,7 +841,7 @@ double light_source_to_color_temp( const unsigned short tag ) { 20, 5500 }, { 21, 6500 }, { 22, 7500 } }; - FORI( countSize( exif_light_source_temperature_map ) ) + for ( int i = 0; i < countSize( exif_light_source_temperature_map ); i++ ) { if ( exif_light_source_temperature_map[i][0] == static_cast( tag ) ) @@ -1108,7 +1106,7 @@ vector matrix_RGB_to_XYZ( const double chromaticities[][2] ) xy_to_XYZ( vector( chromaticities[3], chromaticities[3] + 2 ) ); vector rgb_matrix( 9 ); - FORI( 3 ) + for ( int i = 0; i < 3; i++ ) { rgb_matrix[0 + i * 3] = red_XYZ[i]; rgb_matrix[1 + i * 3] = green_XYZ[i]; @@ -1193,18 +1191,21 @@ vector> MetadataSolver::calculate_IDT_matrix() // 2. Converts the CAT matrix to a flattened format for matrix multiplication vector XYZ_D65_acesrgb( 9 ), CAT( 9 ); - FORIJ( 3, 3 ) - { - XYZ_D65_acesrgb[i * 3 + j] = XYZ_D65_acesrgb_3[i][j]; - CAT[i * 3 + j] = CAT_matrix[i][j]; - } + for ( size_t i = 0; i < 3; i++ ) + for ( size_t j = 0; j < 3; j++ ) + { + XYZ_D65_acesrgb[i * 3 + j] = XYZ_D65_acesrgb_3[i][j]; + CAT[i * 3 + j] = CAT_matrix[i][j]; + } // 3. Multiplies the D65 ACES RGB to XYZ matrix with the CAT matrix vector matrix = mulVector( XYZ_D65_acesrgb, CAT, 3 ); // 4. Reshapes the result into a 3×3 transformation matrix vector> DNG_IDT_matrix( 3, vector( 3 ) ); - FORIJ( 3, 3 ) DNG_IDT_matrix[i][j] = matrix[i * 3 + j]; + for ( size_t i = 0; i < 3; i++ ) + for ( size_t j = 0; j < 3; j++ ) + DNG_IDT_matrix[i][j] = matrix[i * 3 + j]; // 5. Validates the matrix properties (non-zero determinant) assert( std::fabs( sumVectorM( DNG_IDT_matrix ) - 0.0 ) > 1e-09 ); @@ -1232,11 +1233,15 @@ template bool IDTOptimizationCost::operator()( const T *beta_params, T *residuals ) const { vector> RGB_copy( 190, vector( 3 ) ); - FORIJ( 190, 3 ) RGB_copy[i][j] = T( _RGB[i][j] ); + for ( size_t i = 0; i < 190; i++ ) + for ( size_t j = 0; j < 3; j++ ) + RGB_copy[i][j] = T( _RGB[i][j] ); vector> out_calc_LAB = XYZ_to_LAB( getCalcXYZt( RGB_copy, beta_params ) ); - FORIJ( 190, 3 ) residuals[i * 3 + j] = _outLAB[i][j] - out_calc_LAB[i][j]; + for ( size_t i = 0; i < 190; i++ ) + for ( size_t j = 0; j < 3; j++ ) + residuals[i * 3 + j] = _outLAB[i][j] - out_calc_LAB[i][j]; return true; } diff --git a/src/rawtoaces_core/rawtoaces_core_priv.h b/src/rawtoaces_core/rawtoaces_core_priv.h index 8e5e8de6..c0a928e2 100644 --- a/src/rawtoaces_core/rawtoaces_core_priv.h +++ b/src/rawtoaces_core/rawtoaces_core_priv.h @@ -31,7 +31,6 @@ std::vector> calculate_XYZ( std::vector> calculate_RGB( const SpectralData &camera, - const SpectralData &illuminant, const std::vector &WB_multipliers, const std::vector &TI ); diff --git a/src/rawtoaces_core/spectral_data.cpp b/src/rawtoaces_core/spectral_data.cpp index f089d095..cdf04793 100644 --- a/src/rawtoaces_core/spectral_data.cpp +++ b/src/rawtoaces_core/spectral_data.cpp @@ -23,7 +23,9 @@ Spectrum::Spectrum( double value, const Shape &reference_shape ) { if ( shape.step > 0 ) values.resize( - ( shape.last - shape.first + shape.step ) / shape.step, value ); + static_cast( + ( shape.last - shape.first + shape.step ) / shape.step ), + value ); } template @@ -252,7 +254,6 @@ bool SpectralData::load( const std::string &path, bool reshape ) auto &set_entry = data[set_name]; size_t count = set_entry.size(); - size_t channel_index = 0; for ( auto &[bin_wavelength, bin_values]: spectral_data[set_name].items() ) { @@ -280,12 +281,10 @@ bool SpectralData::load( const std::string &path, bool reshape ) prev_wavelength = this_wavelength; - for ( int j = 0; j < count; j++ ) + for ( size_t j = 0; j < count; j++ ) { set_entry[j].second.values.push_back( bin_values[j] ); } - - channel_index++; } } diff --git a/src/rawtoaces_util/image_converter.cpp b/src/rawtoaces_util/image_converter.cpp index f00d1fb3..88cc4374 100644 --- a/src/rawtoaces_util/image_converter.cpp +++ b/src/rawtoaces_util/image_converter.cpp @@ -159,7 +159,7 @@ std::vector database_paths() OIIO::Strutil::split( path, result, separator ); return result; -}; +} /// Get camera info (with make and model) from image metadata or custom settings. /// @@ -443,7 +443,7 @@ bool prepare_transform_DNG( // Extract illuminant type for this calibration auto key = "raw:dng:calibration_illuminant" + index_string; metadata.calibration[k].illuminant = - image_spec.get_int_attribute( key ); + static_cast( image_spec.get_int_attribute( key ) ); // Extract XYZ to RGB color matrix auto key1 = "raw:dng:color_matrix" + index_string; @@ -860,11 +860,12 @@ void ImageConverter::init_parser( OIIO::ArgParse &arg_parser ) .help( "(-v) Print progress messages. " "Repeated -v will increase verbosity." ) - .action( - [&]( OIIO::cspan argv ) { settings.verbosity++; } ); + .action( [&]( OIIO::cspan /* argv */ ) { + settings.verbosity++; + } ); arg_parser.arg( "-v" ).hidden().action( - [&]( OIIO::cspan argv ) { settings.verbosity++; } ); + [&]( OIIO::cspan /* argv */ ) { settings.verbosity++; } ); } bool ImageConverter::parse_parameters( const OIIO::ArgParse &arg_parser ) @@ -1025,7 +1026,7 @@ bool ImageConverter::parse_parameters( const OIIO::ArgParse &arg_parser ) [&]() { for ( int i = 0; i < 3; i++ ) for ( int j = 0; j < 3; j++ ) - settings.custom_matrix[i][j] = i == j ? 1.0 : 0.0; + settings.custom_matrix[i][j] = i == j ? 1.0f : 0.0f; } ); auto crop_box = arg_parser["crop-box"].as_vec(); @@ -1064,7 +1065,8 @@ bool ImageConverter::parse_parameters( const OIIO::ArgParse &arg_parser ) if ( chromatic_aberration.size() == 2 ) { for ( size_t i = 0; i < 2; i++ ) - settings.chromatic_aberration[i] = chromatic_aberration[i]; + settings.chromatic_aberration[i] = + static_cast( chromatic_aberration[i] ); } auto demosaic_algorithm = arg_parser["demosaic"].get(); @@ -1094,7 +1096,7 @@ bool ImageConverter::parse_parameters( const OIIO::ArgParse &arg_parser ) settings.headroom = arg_parser["headroom"].get(); settings.auto_bright = arg_parser["auto-bright"].get(); settings.adjust_maximum_threshold = - arg_parser["adjust-maximum-threshold"].get(); + arg_parser["adjust-maximum-threshold"].get(); settings.black_level = arg_parser["black-level"].get(); settings.saturation_level = arg_parser["saturation-level"].get(); settings.half_size = arg_parser["half-size"].get(); @@ -1400,10 +1402,10 @@ bool ImageConverter::configure( for ( size_t i = 0; i < _WB_multipliers.size(); i++ ) { - custom_WB[i] = _WB_multipliers[i]; + custom_WB[i] = static_cast( _WB_multipliers[i] ); } if ( _WB_multipliers.size() == 3 ) - custom_WB[3] = _WB_multipliers[1]; + custom_WB[3] = static_cast( _WB_multipliers[1] ); options.attribute( "raw:user_mul", @@ -1472,7 +1474,7 @@ bool apply_matrix( { for ( size_t j = 0; j < num_columns; j++ ) { - M[j][i] = matrix[i][j]; + M[j][i] = static_cast( matrix[i][j] ); } for ( size_t j = num_columns; j < 4; j++ ) @@ -1521,14 +1523,14 @@ bool ImageConverter::apply_matrix( } bool ImageConverter::apply_scale( - OIIO::ImageBuf &dst, const OIIO::ImageBuf &src, OIIO::ROI roi ) + OIIO::ImageBuf &dst, const OIIO::ImageBuf &src, OIIO::ROI /* roi */ ) { return OIIO::ImageBufAlgo::mul( dst, src, settings.headroom * settings.scale ); } bool ImageConverter::apply_crop( - OIIO::ImageBuf &dst, const OIIO::ImageBuf &src, OIIO::ROI roi ) + OIIO::ImageBuf &dst, const OIIO::ImageBuf &src, OIIO::ROI /* roi */ ) { if ( settings.crop_mode == Settings::CropMode::Off ) { @@ -1633,8 +1635,8 @@ bool ImageConverter::save_image( // - acesImageContainerFlag present, // - no compression. - const float chromaticities[] = { 0.7347, 0.2653, 0, 1, - 0.0001, -0.077, 0.32168, 0.33767 }; + const float chromaticities[] = { 0.7347f, 0.2653f, 0.0f, 1.0f, + 0.0001f, -0.077f, 0.32168f, 0.33767f }; OIIO::ImageSpec image_spec = buf.spec(); image_spec.set_format( OIIO::TypeDesc::HALF ); diff --git a/tests/config_tests/core/test_installed_core.cpp b/tests/config_tests/core/test_installed_core.cpp index 23666087..d283ce1a 100644 --- a/tests/config_tests/core/test_installed_core.cpp +++ b/tests/config_tests/core/test_installed_core.cpp @@ -48,11 +48,11 @@ void testIllum_calDayLightSPD() std::vector &data = illuminant.values; for ( size_t i = 0; i < data.size(); i++ ) OIIO_CHECK_EQUAL_THRESH( data[i], spd[i], 1e-5 ); -}; +} int main( int, char ** ) { testIllum_calDayLightSPD(); return unit_test_failures; -}; +} diff --git a/tests/config_tests/util/test_installed_util.cpp b/tests/config_tests/util/test_installed_util.cpp index 25196d9b..ff6cb683 100644 --- a/tests/config_tests/util/test_installed_util.cpp +++ b/tests/config_tests/util/test_installed_util.cpp @@ -82,7 +82,7 @@ void test_AcesRender() for ( size_t j = 0; j < 3; j++ ) OIIO_CHECK_EQUAL_THRESH( idt[i][j], matrix[i][j], 1e-5 ); } -}; +} int main( int, char ** ) { diff --git a/tests/testDNGIdt.cpp b/tests/testDNGIdt.cpp index 27bf5e0b..30fad692 100644 --- a/tests/testDNGIdt.cpp +++ b/tests/testDNGIdt.cpp @@ -13,7 +13,7 @@ void testIDT_CcttoMired() double cct = 6500.0; double mired = rta::core::CCT_to_mired( cct ); OIIO_CHECK_EQUAL_THRESH( mired, 153.8461538462, 1e-5 ); -}; +} void testIDT_RobertsonLength() { @@ -23,14 +23,14 @@ void testIDT_RobertsonLength() std::vector uvtVector( uvt, uvt + 3 ); double rLength = rta::core::robertson_length( uvVector, uvtVector ); OIIO_CHECK_EQUAL_THRESH( rLength, 0.060234937, 1e-5 ); -}; +} void testIDT_LightSourceToColorTemp() { unsigned short tag = 17; double ct = rta::core::light_source_to_color_temp( tag ); OIIO_CHECK_EQUAL_THRESH( ct, 2856.0, 1e-5 ); -}; +} void init_metadata( rta::core::Metadata &metadata ) { @@ -61,7 +61,7 @@ void testIDT_XYZToColorTemperature() double cct = rta::core::XYZ_to_color_temperature( XYZVector ); OIIO_CHECK_EQUAL_THRESH( cct, 5564.6648479019, 1e-5 ); -}; +} void testIDT_XYZtoCameraWeightedMatrix() { @@ -82,9 +82,9 @@ void testIDT_XYZtoCameraWeightedMatrix() mirs[0], mirs[1], mirs[2], matrix1, matrix2 ); delete di; - FORI( countSize( matrix ) ) - OIIO_CHECK_EQUAL_THRESH( result[i], matrix[i], 1e-5 ); -}; + for ( int i = 0; i < countSize( matrix ); i++ ) + OIIO_CHECK_EQUAL_THRESH( result[i], matrix[i], 1e-5 ); +} void testIDT_FindXYZtoCameraMtx() { @@ -101,9 +101,9 @@ void testIDT_FindXYZtoCameraMtx() delete di; - FORI( countSize( matrix ) ) - OIIO_CHECK_EQUAL_THRESH( result[i], matrix[i], 1e-5 ); -}; + for ( int i = 0; i < countSize( matrix ); i++ ) + OIIO_CHECK_EQUAL_THRESH( result[i], matrix[i], 1e-5 ); +} void testIDT_ColorTemperatureToXYZ() { @@ -111,9 +111,9 @@ void testIDT_ColorTemperatureToXYZ() double XYZ[3] = { 0.3135279229, 0.3235340821, 0.3629379950 }; std::vector result = rta::core::color_temperature_to_XYZ( cct ); - FORI( countSize( XYZ ) ) - OIIO_CHECK_EQUAL_THRESH( result[i], XYZ[i], 1e-5 ); -}; + for ( int i = 0; i < countSize( XYZ ); i++ ) + OIIO_CHECK_EQUAL_THRESH( result[i], XYZ[i], 1e-5 ); +} void testIDT_MatrixRGBtoXYZ() { @@ -123,9 +123,9 @@ void testIDT_MatrixRGBtoXYZ() std::vector result = rta::core::matrix_RGB_to_XYZ( rta::core::chromaticitiesACES ); - FORI( countSize( XYZ ) ) - OIIO_CHECK_EQUAL_THRESH( result[i], XYZ[i], 1e-5 ); -}; + for ( int i = 0; i < countSize( XYZ ); i++ ) + OIIO_CHECK_EQUAL_THRESH( result[i], XYZ[i], 1e-5 ); +} void testIDT_GetDNGCATMatrix() { @@ -139,9 +139,10 @@ void testIDT_GetDNGCATMatrix() delete di; - FORIJ( 3, 3 ) - OIIO_CHECK_EQUAL_THRESH( result[i][j], matrix[i][j], 1e-5 ); -}; + for ( size_t i = 0; i < 3; i++ ) + for ( size_t j = 0; j < 3; j++ ) + OIIO_CHECK_EQUAL_THRESH( result[i][j], matrix[i][j], 1e-5 ); +} void testIDT_GetDNGIDTMatrix() { @@ -155,9 +156,10 @@ void testIDT_GetDNGIDTMatrix() delete di; - FORIJ( 3, 3 ) - OIIO_CHECK_EQUAL_THRESH( result[i][j], matrix[i][j], 1e-5 ); -}; + for ( size_t i = 0; i < 3; i++ ) + for ( size_t j = 0; j < 3; j++ ) + OIIO_CHECK_EQUAL_THRESH( result[i][j], matrix[i][j], 1e-5 ); +} int main( int, char ** ) { diff --git a/tests/testIDT.cpp b/tests/testIDT.cpp index 6c5b180b..8b34c25f 100644 --- a/tests/testIDT.cpp +++ b/tests/testIDT.cpp @@ -127,7 +127,7 @@ void testIDT_LoadCameraSpst() OIIO_CHECK_EQUAL_THRESH( spectrum.values[j], rgb[j][i], 1e-5 ); } } -}; +} void testIDT_LoadIlluminant() { @@ -168,8 +168,9 @@ void testIDT_LoadIlluminant() vector &illumTestData = illuminant["power"].values; OIIO_CHECK_EQUAL( illumTestData.size(), 81 ); - FORI( 81 ) OIIO_CHECK_EQUAL_THRESH( illumTestData[i], iso7589[i], 1e-5 ); -}; + for ( int i = 0; i < 81; i++ ) + OIIO_CHECK_EQUAL_THRESH( illumTestData[i], iso7589[i], 1e-5 ); +} void testIDT_LoadTrainingData() { @@ -181,87 +182,87 @@ void testIDT_LoadTrainingData() result = training_data.load( absolutePath.string() ); OIIO_CHECK_ASSERT( result ); - float TS[81][3] = { { 0.0600000000, 0.0649000000, 0.1365000000 }, - { 0.0501123560, 0.0706580560, 0.1696284150 }, - { 0.0418000000, 0.0758000000, 0.2251000000 }, - { 0.0350998380, 0.0801336960, 0.3047719550 }, - { 0.0299000000, 0.0833000000, 0.4026000000 }, - { 0.0262312100, 0.0850925650, 0.5160895950 }, - { 0.0237000000, 0.0862000000, 0.6230000000 }, - { 0.0220001450, 0.0873012580, 0.6969408830 }, - { 0.0209000000, 0.0882000000, 0.7415000000 }, - { 0.0200563220, 0.0886410630, 0.7614921490 }, - { 0.0195000000, 0.0889000000, 0.7686000000 }, - { 0.0191313310, 0.0892983440, 0.7734411040 }, - { 0.0190000000, 0.0898000000, 0.7776000000 }, - { 0.0189999140, 0.0902695880, 0.7811146070 }, - { 0.0190000000, 0.0905000000, 0.7837000000 }, - { 0.0190000450, 0.0903346640, 0.7852352570 }, - { 0.0190000000, 0.0899000000, 0.7861000000 }, - { 0.0189998960, 0.0893885820, 0.7867377390 }, - { 0.0190000000, 0.0890000000, 0.7874000000 }, - { 0.0191687820, 0.0888728670, 0.7882846290 }, - { 0.0195000000, 0.0889000000, 0.7895000000 }, - { 0.0199125050, 0.0889360840, 0.7908977150 }, - { 0.0203000000, 0.0889000000, 0.7913000000 }, - { 0.0205188110, 0.0887548340, 0.7897356040 }, - { 0.0206000000, 0.0886000000, 0.7873000000 }, - { 0.0204875090, 0.0885331680, 0.7852825210 }, - { 0.0202000000, 0.0885000000, 0.7837000000 }, - { 0.0197375060, 0.0884512830, 0.7823640220 }, - { 0.0192000000, 0.0885000000, 0.7814000000 }, - { 0.0186874580, 0.0887431370, 0.7809309610 }, - { 0.0182000000, 0.0890000000, 0.7807000000 }, - { 0.0177812690, 0.0890853500, 0.7803794660 }, - { 0.0174000000, 0.0891000000, 0.7797000000 }, - { 0.0170124950, 0.0891746130, 0.7785013760 }, - { 0.0167000000, 0.0893000000, 0.7771000000 }, - { 0.0165437470, 0.0894540490, 0.7758601140 }, - { 0.0165000000, 0.0897000000, 0.7750000000 }, - { 0.0165187480, 0.0900728950, 0.7746880440 }, - { 0.0166000000, 0.0904000000, 0.7751000000 }, - { 0.0167687280, 0.0905287860, 0.7764827900 }, - { 0.0170000000, 0.0906000000, 0.7788000000 }, - { 0.0173062380, 0.0907616700, 0.7817986900 }, - { 0.0176000000, 0.0909000000, 0.7847000000 }, - { 0.0178062810, 0.0908870780, 0.7867549510 }, - { 0.0179000000, 0.0908000000, 0.7880000000 }, - { 0.0177875460, 0.0907149890, 0.7886161600 }, - { 0.0175000000, 0.0905000000, 0.7887000000 }, - { 0.0170062410, 0.0900525930, 0.7883616800 }, - { 0.0165000000, 0.0896000000, 0.7879000000 }, - { 0.0161562750, 0.0893622470, 0.7876391210 }, - { 0.0160000000, 0.0892000000, 0.7878000000 }, - { 0.0159998880, 0.0889372410, 0.7886421240 }, - { 0.0160000000, 0.0886000000, 0.7905000000 }, - { 0.0160939180, 0.0882496730, 0.7934294850 }, - { 0.0166000000, 0.0879000000, 0.7963000000 }, - { 0.0174441030, 0.0875515320, 0.7980180100 }, - { 0.0193000000, 0.0872000000, 0.7989000000 }, - { 0.0223132060, 0.0868549990, 0.7995381550 }, - { 0.0280000000, 0.0866000000, 0.8003000000 }, - { 0.0375761310, 0.0865036750, 0.8014685500 }, - { 0.0521000000, 0.0865000000, 0.8032000000 }, - { 0.0729586870, 0.0865216070, 0.8053548300 }, - { 0.1004000000, 0.0866000000, 0.8067000000 }, - { 0.1357709420, 0.0867350970, 0.8062601750 }, - { 0.1771000000, 0.0867000000, 0.8052000000 }, - { 0.2236366190, 0.0863201740, 0.8047534660 }, - { 0.2726000000, 0.0860000000, 0.8043000000 }, - { 0.3210461520, 0.0860991330, 0.8030389740 }, - { 0.3682000000, 0.0862000000, 0.8013000000 }, - { 0.4120116150, 0.0858605930, 0.7995765160 }, - { 0.4546000000, 0.0853000000, 0.7979000000 }, - { 0.4977308940, 0.0848230890, 0.7962063190 }, - { 0.5410000000, 0.0844000000, 0.7945000000 }, - { 0.5842237740, 0.0839571040, 0.7927983150 }, - { 0.6274000000, 0.0835000000, 0.7911000000 }, - { 0.6705919440, 0.0830480940, 0.7894004560 }, - { 0.7138000000, 0.0826000000, 0.7877000000 }, - { 0.7570033060, 0.0821506240, 0.7859998490 }, - { 0.8002000000, 0.0817000000, 0.7843000000 }, - { 0.8433958970, 0.0812493900, 0.7826001500 }, - { 0.8866000000, 0.0808000000, 0.7809000000 } }; + float TS[81][3] = { { 0.0600000000f, 0.0649000000f, 0.1365000000f }, + { 0.0501123560f, 0.0706580560f, 0.1696284150f }, + { 0.0418000000f, 0.0758000000f, 0.2251000000f }, + { 0.0350998380f, 0.0801336960f, 0.3047719550f }, + { 0.0299000000f, 0.0833000000f, 0.4026000000f }, + { 0.0262312100f, 0.0850925650f, 0.5160895950f }, + { 0.0237000000f, 0.0862000000f, 0.6230000000f }, + { 0.0220001450f, 0.0873012580f, 0.6969408830f }, + { 0.0209000000f, 0.0882000000f, 0.7415000000f }, + { 0.0200563220f, 0.0886410630f, 0.7614921490f }, + { 0.0195000000f, 0.0889000000f, 0.7686000000f }, + { 0.0191313310f, 0.0892983440f, 0.7734411040f }, + { 0.0190000000f, 0.0898000000f, 0.7776000000f }, + { 0.0189999140f, 0.0902695880f, 0.7811146070f }, + { 0.0190000000f, 0.0905000000f, 0.7837000000f }, + { 0.0190000450f, 0.0903346640f, 0.7852352570f }, + { 0.0190000000f, 0.0899000000f, 0.7861000000f }, + { 0.0189998960f, 0.0893885820f, 0.7867377390f }, + { 0.0190000000f, 0.0890000000f, 0.7874000000f }, + { 0.0191687820f, 0.0888728670f, 0.7882846290f }, + { 0.0195000000f, 0.0889000000f, 0.7895000000f }, + { 0.0199125050f, 0.0889360840f, 0.7908977150f }, + { 0.0203000000f, 0.0889000000f, 0.7913000000f }, + { 0.0205188110f, 0.0887548340f, 0.7897356040f }, + { 0.0206000000f, 0.0886000000f, 0.7873000000f }, + { 0.0204875090f, 0.0885331680f, 0.7852825210f }, + { 0.0202000000f, 0.0885000000f, 0.7837000000f }, + { 0.0197375060f, 0.0884512830f, 0.7823640220f }, + { 0.0192000000f, 0.0885000000f, 0.7814000000f }, + { 0.0186874580f, 0.0887431370f, 0.7809309610f }, + { 0.0182000000f, 0.0890000000f, 0.7807000000f }, + { 0.0177812690f, 0.0890853500f, 0.7803794660f }, + { 0.0174000000f, 0.0891000000f, 0.7797000000f }, + { 0.0170124950f, 0.0891746130f, 0.7785013760f }, + { 0.0167000000f, 0.0893000000f, 0.7771000000f }, + { 0.0165437470f, 0.0894540490f, 0.7758601140f }, + { 0.0165000000f, 0.0897000000f, 0.7750000000f }, + { 0.0165187480f, 0.0900728950f, 0.7746880440f }, + { 0.0166000000f, 0.0904000000f, 0.7751000000f }, + { 0.0167687280f, 0.0905287860f, 0.7764827900f }, + { 0.0170000000f, 0.0906000000f, 0.7788000000f }, + { 0.0173062380f, 0.0907616700f, 0.7817986900f }, + { 0.0176000000f, 0.0909000000f, 0.7847000000f }, + { 0.0178062810f, 0.0908870780f, 0.7867549510f }, + { 0.0179000000f, 0.0908000000f, 0.7880000000f }, + { 0.0177875460f, 0.0907149890f, 0.7886161600f }, + { 0.0175000000f, 0.0905000000f, 0.7887000000f }, + { 0.0170062410f, 0.0900525930f, 0.7883616800f }, + { 0.0165000000f, 0.0896000000f, 0.7879000000f }, + { 0.0161562750f, 0.0893622470f, 0.7876391210f }, + { 0.0160000000f, 0.0892000000f, 0.7878000000f }, + { 0.0159998880f, 0.0889372410f, 0.7886421240f }, + { 0.0160000000f, 0.0886000000f, 0.7905000000f }, + { 0.0160939180f, 0.0882496730f, 0.7934294850f }, + { 0.0166000000f, 0.0879000000f, 0.7963000000f }, + { 0.0174441030f, 0.0875515320f, 0.7980180100f }, + { 0.0193000000f, 0.0872000000f, 0.7989000000f }, + { 0.0223132060f, 0.0868549990f, 0.7995381550f }, + { 0.0280000000f, 0.0866000000f, 0.8003000000f }, + { 0.0375761310f, 0.0865036750f, 0.8014685500f }, + { 0.0521000000f, 0.0865000000f, 0.8032000000f }, + { 0.0729586870f, 0.0865216070f, 0.8053548300f }, + { 0.1004000000f, 0.0866000000f, 0.8067000000f }, + { 0.1357709420f, 0.0867350970f, 0.8062601750f }, + { 0.1771000000f, 0.0867000000f, 0.8052000000f }, + { 0.2236366190f, 0.0863201740f, 0.8047534660f }, + { 0.2726000000f, 0.0860000000f, 0.8043000000f }, + { 0.3210461520f, 0.0860991330f, 0.8030389740f }, + { 0.3682000000f, 0.0862000000f, 0.8013000000f }, + { 0.4120116150f, 0.0858605930f, 0.7995765160f }, + { 0.4546000000f, 0.0853000000f, 0.7979000000f }, + { 0.4977308940f, 0.0848230890f, 0.7962063190f }, + { 0.5410000000f, 0.0844000000f, 0.7945000000f }, + { 0.5842237740f, 0.0839571040f, 0.7927983150f }, + { 0.6274000000f, 0.0835000000f, 0.7911000000f }, + { 0.6705919440f, 0.0830480940f, 0.7894004560f }, + { 0.7138000000f, 0.0826000000f, 0.7877000000f }, + { 0.7570033060f, 0.0821506240f, 0.7859998490f }, + { 0.8002000000f, 0.0817000000f, 0.7843000000f }, + { 0.8433958970f, 0.0812493900f, 0.7826001500f }, + { 0.8866000000f, 0.0808000000f, 0.7809000000f } }; for ( size_t i = 1; i < 81; i++ ) { @@ -272,7 +273,7 @@ void testIDT_LoadTrainingData() OIIO_CHECK_EQUAL_THRESH( TS[i][2], training_data["patch3"].values[i], 1e-5 ); } -}; +} void testIDT_LoadCMF() { @@ -284,8 +285,6 @@ void testIDT_LoadCMF() result = spectral_data.load( absolutePath.string() ); OIIO_CHECK_ASSERT( result ); - auto &data = spectral_data.data["main"]; - double cmf[401][3] = { { 0.001368, 3.90E-05, 0.006450001 }, { 0.00150205, 4.28E-05, 0.007083216 }, { 0.001642328, 4.69E-05, 0.007745488 }, @@ -688,7 +687,7 @@ void testIDT_LoadCMF() { 4.45E-05, 1.61E-05, 0 }, { 4.15E-05, 1.50E-05, 0 } }; - FORI( 81 ) + for ( int i = 0; i < 81; i++ ) { OIIO_CHECK_EQUAL_THRESH( spectral_data["X"].values[i], cmf[i * 5][0], 1e-5 ); @@ -697,7 +696,7 @@ void testIDT_LoadCMF() OIIO_CHECK_EQUAL_THRESH( spectral_data["Z"].values[i], cmf[i * 5][2], 1e-5 ); } -}; +} void load_camera_helper( rta::core::SpectralSolver &solver, @@ -780,9 +779,9 @@ void testIDT_scaleLSC() OIIO_CHECK_EQUAL( illumDataScaled.size(), 81 ); OIIO_CHECK_EQUAL( illuminant.illuminant, "iso7589" ); OIIO_CHECK_EQUAL( illuminant["power"].shape.step, 5 ); - FORI( 81 ) - OIIO_CHECK_EQUAL_THRESH( illumDataScaled[i], scaledIllum[i], 1e-5 ); -}; + for ( int i = 0; i < 81; i++ ) + OIIO_CHECK_EQUAL_THRESH( illumDataScaled[i], scaledIllum[i], 1e-5 ); +} void testIDT_CalCM() { @@ -794,10 +793,11 @@ void testIDT_CalCM() vector CM_test = calculate_CM( camera, illuminant ); - float CM[81] = { 1.0000000000, 1.4418439699, 1.8703081160 }; + float CM[81] = { 1.0000000000f, 1.4418439699f, 1.8703081160f }; - FORI( 3 ) OIIO_CHECK_EQUAL_THRESH( CM[i], CM_test[i], 1e-5 ); -}; + for ( int i = 0; i < 3; i++ ) + OIIO_CHECK_EQUAL_THRESH( CM[i], CM_test[i], 1e-5 ); +} void testIDT_CalWB() { @@ -810,11 +810,11 @@ void testIDT_CalWB() vector WB_test = _calculate_WB( camera, illuminant ); double WB[3] = { 1.1397265, 1.0000000, 2.3240151 }; - FORI( WB_test.size() ) + for ( size_t i = 0; i < WB_test.size(); i++ ) { OIIO_CHECK_EQUAL_THRESH( WB[i], WB_test[i], 1e-5 ); } -}; +} void testIDT_ChooseIllumSrc() { @@ -850,9 +850,9 @@ void testIDT_ChooseIllumSrc() }; OIIO_CHECK_EQUAL( illumType_Test, "d45" ); - FORI( illumData_Test.size() ) - OIIO_CHECK_EQUAL_THRESH( illumData[i], illumData_Test[i], 1e-5 ); -}; + for ( size_t i = 0; i < illumData_Test.size(); i++ ) + OIIO_CHECK_EQUAL_THRESH( illumData[i], illumData_Test[i], 1e-5 ); +} void testIDT_ChooseIllumType() { @@ -888,9 +888,9 @@ void testIDT_ChooseIllumType() }; OIIO_CHECK_EQUAL( illumType_Test, "iso7589" ); - FORI( illumData_Test.size() ) - OIIO_CHECK_EQUAL_THRESH( illumData[i], illumData_Test[i], 1e-5 ); -}; + for ( size_t i = 0; i < illumData_Test.size(); i++ ) + OIIO_CHECK_EQUAL_THRESH( illumData[i], illumData_Test[i], 1e-5 ); +} void testIDT_CalTI() { @@ -4804,7 +4804,7 @@ void testIDT_CalTI() OIIO_CHECK_EQUAL_THRESH( TI[j][i], spectrum.values[j], 1e-4 ); } } -}; +} void testIDT_CalXYZ() { @@ -5016,9 +5016,10 @@ void testIDT_CalXYZ() { 0.2281042219, 0.1104278429, 0.1135106455 }, { 0.4603248290, 0.3206987361, 0.3960834297 } }; - FORIJ( 190, 3 ) - OIIO_CHECK_EQUAL_THRESH( XYZ[i][j], XYZ_test[i][j], 1e-5 ); -}; + for ( size_t i = 0; i < 190; i++ ) + for ( size_t j = 0; j < 3; j++ ) + OIIO_CHECK_EQUAL_THRESH( XYZ[i][j], XYZ_test[i][j], 1e-5 ); +} void testIDT_CalRGB() { @@ -5037,7 +5038,7 @@ void testIDT_CalRGB() scale_illuminant( camera, illuminant ); auto WB = _calculate_WB( camera, illuminant ); auto TI = calculate_TI( illuminant, training_data ); - auto RGB_test = calculate_RGB( camera, illuminant, WB, TI ); + auto RGB_test = calculate_RGB( camera, WB, TI ); double RGB[190][3] = { { 0.0202216733, 0.0193805976, 0.0242277400 }, { 0.0895652372, 0.0893690961, 0.0891448525 }, @@ -5230,9 +5231,10 @@ void testIDT_CalRGB() { 0.3303063191, 0.0484327700, 0.0971516302 }, { 0.5608623445, 0.2394587589, 0.3637261707 } }; - FORIJ( 190, 3 ) - OIIO_CHECK_EQUAL_THRESH( RGB[i][j], RGB_test[i][j], 1e-5 ); -}; + for ( size_t i = 0; i < 190; i++ ) + for ( size_t j = 0; j < 3; j++ ) + OIIO_CHECK_EQUAL_THRESH( RGB[i][j], RGB_test[i][j], 1e-5 ); +} void testIDT_CurveFit() { @@ -5252,7 +5254,7 @@ void testIDT_CurveFit() auto WB = _calculate_WB( camera, illuminant ); auto TI = calculate_TI( illuminant, training_data ); auto XYZ = calculate_XYZ( observer, illuminant, TI ); - auto RGB = calculate_RGB( camera, illuminant, WB, TI ); + auto RGB = calculate_RGB( camera, WB, TI ); double BStart[6] = { 1.0, 0.0, 0.0, 1.0, 0.0, 0.0 }; @@ -5260,13 +5262,14 @@ void testIDT_CurveFit() OIIO_CHECK_ASSERT( rta::core::curveFit( RGB, XYZ, BStart, 0, IDT_test ) ); - float IDT[3][3] = { { 0.7447691479, 0.1434200377, 0.1118108144 }, - { 0.0451759890, 1.0082622042, -0.0534381932 }, - { 0.0247144012, -0.1245524896, 1.0998380884 } }; + float IDT[3][3] = { { 0.7447691479f, 0.1434200377f, 0.1118108144f }, + { 0.0451759890f, 1.0082622042f, -0.0534381932f }, + { 0.0247144012f, -0.1245524896f, 1.0998380884f } }; - FORIJ( 3, 3 ) - OIIO_CHECK_EQUAL_THRESH( IDT[i][j], IDT_test[i][j], 1e-5 ); -}; + for ( size_t i = 0; i < 3; i++ ) + for ( size_t j = 0; j < 3; j++ ) + OIIO_CHECK_EQUAL_THRESH( IDT[i][j], IDT_test[i][j], 1e-5 ); +} void testIDT_CalIDT() { @@ -5277,13 +5280,14 @@ void testIDT_CalIDT() OIIO_CHECK_ASSERT( solver.calculate_IDT_matrix() ); vector> IDT_test = solver.get_IDT_matrix(); - float IDT[3][3] = { { 1.0915120600, -0.2516916464, 0.1601795864 }, - { -0.0089998772, 1.2147199060, -0.2057200288 }, - { -0.1312667887, -0.7361633199, 1.8674301085 } }; + float IDT[3][3] = { { 1.0915120600f, -0.2516916464f, 0.1601795864f }, + { -0.0089998772f, 1.2147199060f, -0.2057200288f }, + { -0.1312667887f, -0.7361633199f, 1.8674301085f } }; - FORIJ( 3, 3 ) - OIIO_CHECK_EQUAL_THRESH( IDT[i][j], IDT_test[i][j], 1e-4 ); -}; + for ( size_t i = 0; i < 3; i++ ) + for ( size_t j = 0; j < 3; j++ ) + OIIO_CHECK_EQUAL_THRESH( IDT[i][j], IDT_test[i][j], 1e-4 ); +} int main( int, char ** ) { diff --git a/tests/testIllum.cpp b/tests/testIllum.cpp index ac3cf3af..fd58628d 100644 --- a/tests/testIllum.cpp +++ b/tests/testIllum.cpp @@ -21,7 +21,7 @@ void testIllum_cctToxy() OIIO_CHECK_EQUAL_THRESH( xy[0], 0.3456619734948, 1e-9 ); OIIO_CHECK_EQUAL_THRESH( xy[1], 0.3586032641691, 1e-9 ); -}; +} void testIllum_readSPD() { @@ -60,8 +60,9 @@ void testIllum_readSPD() vector &illumTestData = illuminant["power"].values; OIIO_CHECK_EQUAL( illumTestData.size(), 81 ); - FORI( 81 ) OIIO_CHECK_EQUAL_THRESH( illumTestData[i], iso7589[i], 1e-5 ); -}; + for ( int i = 0; i < 81; i++ ) + OIIO_CHECK_EQUAL_THRESH( illumTestData[i], iso7589[i], 1e-5 ); +} void testIllum_calDayLightSPD() { @@ -99,9 +100,9 @@ void testIllum_calDayLightSPD() }; vector &data = illuminant.values; - FORI( data.size() ) - OIIO_CHECK_EQUAL_THRESH( data[i], spd[i], 1e-5 ); -}; + for ( size_t i = 0; i < data.size(); i++ ) + OIIO_CHECK_EQUAL_THRESH( data[i], spd[i], 1e-5 ); +} void testIllum_calBlackBodySPD() { @@ -129,9 +130,9 @@ void testIllum_calBlackBodySPD() }; vector &data = illuminant.values; - FORI( data.size() ) - OIIO_CHECK_EQUAL_THRESH( data[i] * 1e-12, spd[i], 1e-5 ); -}; + for ( size_t i = 0; i < data.size(); i++ ) + OIIO_CHECK_EQUAL_THRESH( data[i] * 1e-12, spd[i], 1e-5 ); +} int main( int, char ** ) { diff --git a/tests/testLogic.cpp b/tests/testLogic.cpp index 55af8b07..4bd8a9b1 100644 --- a/tests/testLogic.cpp +++ b/tests/testLogic.cpp @@ -22,23 +22,21 @@ void test_getCAT() vector src( D65, D65 + 3 ); vector des( D60, D60 + 3 ); - // FORI(3) src[i]= D65[i]; - // FORI(3) des[i]= D60[i]; vector> final_Output_getCAT = calculate_CAT( src, des ); vector destination( 3, 0 ); - FORI( 3 ) - destination[i] = final_Output_getCAT[i][0] * src[0] + - final_Output_getCAT[i][1] * src[1] + - final_Output_getCAT[i][2] * src[2]; + for ( int i = 0; i < 3; i++ ) + destination[i] = final_Output_getCAT[i][0] * src[0] + + final_Output_getCAT[i][1] * src[1] + + final_Output_getCAT[i][2] * src[2]; OIIO_CHECK_EQUAL_THRESH( destination[0], des[0], 1e-9 ); OIIO_CHECK_EQUAL_THRESH( destination[1], des[1], 1e-9 ); OIIO_CHECK_EQUAL_THRESH( destination[2], des[2], 1e-9 ); - FORI( 3 ) + for ( int i = 0; i < 3; i++ ) { OIIO_CHECK_EQUAL_THRESH( final_Output_getCAT[i][0], final_matrix[i][0], 5 ); @@ -47,7 +45,7 @@ void test_getCAT() OIIO_CHECK_EQUAL_THRESH( final_Output_getCAT[i][2], final_matrix[i][2], 5 ); } -}; +} int main( int, char ** ) { diff --git a/tests/testMath.cpp b/tests/testMath.cpp index eb027711..ef965ada 100644 --- a/tests/testMath.cpp +++ b/tests/testMath.cpp @@ -17,12 +17,14 @@ void test_IsSquare() { vector> a; a.resize( 2 ); - FORI( 2 ) a[i].resize( 2 ); + for ( int i = 0; i < 2; i++ ) + a[i].resize( 2 ); OIIO_CHECK_EQUAL( isSquare( a ), 1 ); - FORI( 2 ) a[i].resize( 1 ); + for ( int i = 0; i < 2; i++ ) + a[i].resize( 1 ); OIIO_CHECK_EQUAL( isSquare( a ), 0 ); -}; +} void test_AddVectors() { @@ -35,9 +37,9 @@ void test_AddVectors() vector bv( b, b + 5 ); vector cv = addVectors( av, bv ); - FORI( 5 ) - OIIO_CHECK_EQUAL_THRESH( cv[i], c[i], 1e-9 ); -}; + for ( int i = 0; i < 5; i++ ) + OIIO_CHECK_EQUAL_THRESH( cv[i], c[i], 1e-9 ); +} void test_SubVectors() { @@ -50,9 +52,9 @@ void test_SubVectors() vector bv( b, b + 5 ); vector cv = subVectors( av, bv ); - FORI( 5 ) - OIIO_CHECK_EQUAL_THRESH( cv[i], c[i], 1e-9 ); -}; + for ( int i = 0; i < 5; i++ ) + OIIO_CHECK_EQUAL_THRESH( cv[i], c[i], 1e-9 ); +} void test_Cross2() { @@ -64,7 +66,7 @@ void test_Cross2() double cross2_test = cross2d_scalar( av, bv ); OIIO_CHECK_EQUAL_THRESH( cross2_test, 3.50, 1e-5 ); -}; +} void test_InvertVM() { @@ -76,17 +78,19 @@ void test_InvertVM() { 613.114494, -518.860936, 72.376689 } }; vector> MV( 3, vector( 3 ) ); - FORIJ( 3, 3 ) MV[i][j] = M[i][j]; + for ( size_t i = 0; i < 3; i++ ) + for ( size_t j = 0; j < 3; j++ ) + MV[i][j] = M[i][j]; vector> MV_Inverse = invertVM( MV ); - FORI( 3 ) + for ( int i = 0; i < 3; i++ ) { OIIO_CHECK_EQUAL_THRESH( MV_Inverse[i][0], M_Inverse[i][0], 1e-5 ); OIIO_CHECK_EQUAL_THRESH( MV_Inverse[i][1], M_Inverse[i][1], 1e-5 ); OIIO_CHECK_EQUAL_THRESH( MV_Inverse[i][2], M_Inverse[i][2], 1e-5 ); } -}; +} void test_InvertV() { @@ -99,8 +103,9 @@ void test_InvertV() vector MV( V, V + 9 ); vector MV_Inverse = invertV( MV ); - FORI( 9 ) OIIO_CHECK_EQUAL_THRESH( V_Inverse[i], MV_Inverse[i], 1e-5 ); -}; + for ( int i = 0; i < 9; i++ ) + OIIO_CHECK_EQUAL_THRESH( V_Inverse[i], MV_Inverse[i], 1e-5 ); +} void test_DiagV() { @@ -109,11 +114,11 @@ void test_DiagV() vector VV( v, v + 3 ); vector DV = diagV( VV ); - FORI( 9 ) + for ( int i = 0; i < 9; i++ ) { OIIO_CHECK_EQUAL_THRESH( DV[i], vd[i], 1e-5 ); } -}; +} void test_TransposeVec() { @@ -142,12 +147,15 @@ void test_TransposeVec() 4.0000000000 } }; vector> MV( 6, vector( 3 ) ); - FORIJ( 6, 3 ) MV[i][j] = M[i][j]; + for ( size_t i = 0; i < 6; i++ ) + for ( size_t j = 0; j < 3; j++ ) + MV[i][j] = M[i][j]; vector> MVT = transposeVec( MV ); - FORIJ( 3, 6 ) - OIIO_CHECK_EQUAL_THRESH( MVT[i][j], MT[i][j], 1e-5 ); -}; + for ( size_t i = 0; i < 3; i++ ) + for ( size_t j = 0; j < 6; j++ ) + OIIO_CHECK_EQUAL_THRESH( MVT[i][j], MT[i][j], 1e-5 ); +} void test_SumVector() { @@ -156,7 +164,7 @@ void test_SumVector() double sum = sumVector( MV ); OIIO_CHECK_EQUAL_THRESH( sum, 55.0000, 1e-5 ); -}; +} void test_MulVectorElement() { @@ -168,9 +176,9 @@ void test_MulVectorElement() vector MV2( M2, M2 + 10 ); vector MV3 = mulVectorElement( MV1, MV2 ); - FORI( MV3.size() ) - OIIO_CHECK_EQUAL_THRESH( MV3[i], 10.0000000000, 1e-5 ); -}; + for ( size_t i = 0; i < MV3.size(); i++ ) + OIIO_CHECK_EQUAL_THRESH( MV3[i], 10.0000000000, 1e-5 ); +} void test_MulVector1() { @@ -190,16 +198,18 @@ void test_MulVector1() vector> MV1( 3, vector( 3 ) ); vector> MV2( 3, vector( 3 ) ); - FORIJ( 3, 3 ) - { - MV1[i][j] = M1[i][j]; - MV2[i][j] = M2[i][j]; - } + for ( size_t i = 0; i < 3; i++ ) + for ( size_t j = 0; j < 3; j++ ) + { + MV1[i][j] = M1[i][j]; + MV2[i][j] = M2[i][j]; + } vector> MV3 = mulVector( MV1, MV2 ); - FORIJ( 3, 3 ) - OIIO_CHECK_EQUAL_THRESH( MV3[i][j], M3[i][j], 1e-5 ); -}; + for ( size_t i = 0; i < 3; i++ ) + for ( size_t j = 0; j < 3; j++ ) + OIIO_CHECK_EQUAL_THRESH( MV3[i][j], M3[i][j], 1e-5 ); +} void test_MulVector2() { @@ -212,27 +222,28 @@ void test_MulVector2() vector> MV1( 3, vector( 3 ) ); vector MV2( M2, M2 + 3 ); - FORIJ( 3, 3 ) - { - MV1[i][j] = M1[i][j]; - } + for ( size_t i = 0; i < 3; i++ ) + for ( size_t j = 0; j < 3; j++ ) + { + MV1[i][j] = M1[i][j]; + } vector MV3 = mulVector( MV1, MV2 ); - FORI( 3 ) - OIIO_CHECK_EQUAL_THRESH( MV3[i], M2[i], 1e-5 ); -}; + for ( int i = 0; i < 3; i++ ) + OIIO_CHECK_EQUAL_THRESH( MV3[i], M2[i], 1e-5 ); +} void test_FindIndexInterp1() { int M[100]; - FORI( sizeof( M ) / sizeof( int ) ) - M[i] = i * 2; + for ( size_t i = 0; i < sizeof( M ) / sizeof( int ); i++ ) + M[i] = static_cast( i * 2 ); vector MV( M, M + 100 ); int index = findIndexInterp1( 100, MV, (int)MV.size() ); OIIO_CHECK_EQUAL( index, 50 ); -}; +} void test_Interp1DLinear() { @@ -267,7 +278,7 @@ void test_Interp1DLinear() 672.0000000000, 679.0000000000, 686.0000000000, 693.0000000000 }; - FORI( 100 ) + for ( int i = 0; i < 100; i++ ) { X0[i] = i; X1[i] = i * 2; @@ -280,21 +291,20 @@ void test_Interp1DLinear() vector YV1 = interp1DLinear( XV0, XV1, YV0 ); - FORI( YV1.size() ) - OIIO_CHECK_EQUAL_THRESH( YV1[i], Y1[i], 1e-5 ); -}; + for ( size_t i = 0; i < YV1.size(); i++ ) + OIIO_CHECK_EQUAL_THRESH( YV1[i], Y1[i], 1e-5 ); +} void testIDT_XytoXYZ() { - double xy[3] = { 0.7347, 0.2653 }; - double XYZ[3] = { 0.7347, 0.2653, 0.0 }; - vector XYZV = xy_to_XYZ( vector( xy, xy + 2 ) ); + double xy[3] = { 0.7347, 0.2653 }; + vector XYZV = xy_to_XYZ( vector( xy, xy + 2 ) ); - FORI( 3 ) + for ( int i = 0; i < 3; i++ ) { OIIO_CHECK_EQUAL_THRESH( XYZV[i], XYZV[i], 1e-5 ); } -}; +} void testIDT_Uvtoxy() { @@ -302,11 +312,11 @@ void testIDT_Uvtoxy() double xy[2] = { 0.658530026, 0.158530026 }; vector xyV = uv_to_xy( vector( uv, uv + 2 ) ); - FORI( 2 ) + for ( int i = 0; i < 2; i++ ) { OIIO_CHECK_EQUAL_THRESH( xy[i], xyV[i], 1e-5 ); } -}; +} void testIDT_UvtoXYZ() { @@ -314,11 +324,11 @@ void testIDT_UvtoXYZ() double XYZ[3] = { 0.658530026, 0.158530026, 0.18293995 }; vector XYZV = uv_to_XYZ( vector( uv, uv + 2 ) ); - FORI( 3 ) + for ( int i = 0; i < 3; i++ ) { OIIO_CHECK_EQUAL_THRESH( XYZ[i], XYZV[i], 1e-5 ); } -}; +} void testIDT_XYZTouv() { @@ -326,11 +336,11 @@ void testIDT_XYZTouv() double uv[2] = { 0.7347, 0.2653 }; vector uvV = XYZ_to_uv( vector( XYZ, XYZ + 3 ) ); - FORI( 2 ) + for ( int i = 0; i < 2; i++ ) { OIIO_CHECK_EQUAL_THRESH( uv[i], uvV[i], 1e-5 ); } -}; +} void testIDT_GetCAT() { @@ -339,23 +349,24 @@ void testIDT_GetCAT() vector> CAT_test = calculate_CAT( dIV, dOV ); - float CAT[3][3] = { { 0.9711790957, -0.0217386019, 0.0460288393 }, - { -0.0156935400, 1.0000112293, 0.0183278569 }, - { 0.0009710255, 0.0030856714, 1.2179433335 } }; + float CAT[3][3] = { { 0.9711790957f, -0.0217386019f, 0.0460288393f }, + { -0.0156935400f, 1.0000112293f, 0.0183278569f }, + { 0.0009710255f, 0.0030856714f, 1.2179433335f } }; - FORI( 3 ) + for ( int i = 0; i < 3; i++ ) { OIIO_CHECK_EQUAL_THRESH( CAT[i][0], CAT_test[i][0], 1e-5 ); OIIO_CHECK_EQUAL_THRESH( CAT[i][1], CAT_test[i][1], 1e-5 ); OIIO_CHECK_EQUAL_THRESH( CAT[i][2], CAT_test[i][2], 1e-5 ); } -}; +} void test_XYZtoLAB() { vector> XYZ( 190, ( vector( 3 ) ) ); - FORIJ( 190, 3 ) - XYZ[i][j] = 116 / ( i * j + 1 ); + for ( size_t i = 0; i < 190; i++ ) + for ( size_t j = 0; j < 3; j++ ) + XYZ[i][j] = static_cast( 116 / ( i * j + 1 ) ); vector> LAB_test = XYZ_to_LAB( XYZ ); double LAB[190][3] = { { 549.7318794845, 39.7525650490, 2.8525942657 }, @@ -549,22 +560,24 @@ void test_XYZtoLAB() { 0.0000000000, 2409.2865283442, 0.0000000000 }, { 0.0000000000, 2409.2865283442, 0.0000000000 } }; - FORIJ( 190, 3 ) - { - if ( LAB[i][j] == 0 ) - OIIO_CHECK_LE( std::abs( LAB_test[i][j] ), 1e-7 ); - else - OIIO_CHECK_EQUAL_THRESH( LAB_test[i][j], LAB[i][j], 1e-5 ); - } -}; + for ( size_t i = 0; i < 190; i++ ) + for ( size_t j = 0; j < 3; j++ ) + { + if ( LAB[i][j] == 0 ) + OIIO_CHECK_LE( std::abs( LAB_test[i][j] ), 1e-7 ); + else + OIIO_CHECK_EQUAL_THRESH( LAB_test[i][j], LAB[i][j], 1e-5 ); + } +} void test_GetCalcXYZt() { vector> RGB( 190, ( vector( 3 ) ) ); const double BStart[6] = { 1.0, 0.0, 0.0, 1.0, 0.0, 0.0 }; - FORIJ( 190, 3 ) - RGB[i][j] = 10 / ( i * j + 1 ); + for ( size_t i = 0; i < 190; i++ ) + for ( size_t j = 0; j < 3; j++ ) + RGB[i][j] = static_cast( 10 / ( i * j + 1 ) ); vector> XYZ_test = getCalcXYZt( RGB, BStart ); double XYZ[190][3] = { { 9.5264607457, 10.0000000000, 10.0882518435 }, @@ -758,9 +771,10 @@ void test_GetCalcXYZt() { 9.5255239594, 3.4396644977, 0.0000000000 }, { 9.5255239594, 3.4396644977, 0.0000000000 } }; - FORIJ( 190, 3 ) - OIIO_CHECK_EQUAL_THRESH( XYZ_test[i][j], XYZ[i][j], 1e-5 ); -}; + for ( size_t i = 0; i < 190; i++ ) + for ( size_t j = 0; j < 3; j++ ) + OIIO_CHECK_EQUAL_THRESH( XYZ_test[i][j], XYZ[i][j], 1e-5 ); +} int main( int, char ** ) { diff --git a/tests/testMisc.cpp b/tests/testMisc.cpp index bf570492..85762b85 100644 --- a/tests/testMisc.cpp +++ b/tests/testMisc.cpp @@ -23,7 +23,7 @@ void test_OpenDir() OIIO_CHECK_EQUAL( fPaths.size(), 1 ); std::vector::iterator it = fPaths.begin(); OIIO_CHECK_EQUAL( absolutePath_test.string(), *it ); -}; +} void test_LowerCase() { @@ -31,9 +31,9 @@ void test_LowerCase() char text_test[] = "rawtoaces"; lowerCase( text ); - FORI( strlen( text ) ) - OIIO_CHECK_EQUAL( text[i], text_test[i] ); -}; + for ( size_t i = 0; i < strlen( text ); i++ ) + OIIO_CHECK_EQUAL( text[i], text_test[i] ); +} void test_IsNumeric() { @@ -42,7 +42,7 @@ void test_IsNumeric() const char val2[] = "123456789A"; OIIO_CHECK_EQUAL( false, isNumeric( val2 ) ); -}; +} void test_IsCTLetterDigit() { @@ -60,7 +60,7 @@ void test_IsCTLetterDigit() const char val5 = '.'; OIIO_CHECK_EQUAL( false, isCTLetterDigit( val5 ) ); -}; +} void test_IsValidCT() { @@ -90,7 +90,7 @@ void test_IsValidCT() std::string val9 = "d65k"; OIIO_CHECK_EQUAL( false, isValidCT( val9 ) ); -}; +} int main( int, char ** ) { diff --git a/tests/test_SpectralData.cpp b/tests/test_SpectralData.cpp index dd286940..ce0eeeef 100644 --- a/tests/test_SpectralData.cpp +++ b/tests/test_SpectralData.cpp @@ -17,7 +17,7 @@ void init_Spectrum( rta::core::Spectrum &spectrum ) { for ( size_t i = 0; i < spectrum.values.size(); i++ ) - spectrum.values[i] = i; + spectrum.values[i] = static_cast( i ); } void check_Spectrum( @@ -239,7 +239,7 @@ void testSpectralData_LoadSpst() OIIO_CHECK_EQUAL_THRESH( spectrum.values[j], rgb[j][i], 1e-5 ); } } -}; +} int main( int, char ** ) { diff --git a/tests/usage_example_core.cpp b/tests/usage_example_core.cpp index 50b108fe..9af9c382 100644 --- a/tests/usage_example_core.cpp +++ b/tests/usage_example_core.cpp @@ -64,7 +64,7 @@ void test_SpectralSolver_multipliers() for ( size_t col = 0; col < 3; col++ ) OIIO_CHECK_EQUAL_THRESH( solved_IDT[row][col], true_IDT[row][col], 1e-5 ); -}; +} /// Test the spectral solver, white-balancing to a specific illuminant. void test_SpectralSolver_illuminant() @@ -107,7 +107,7 @@ void test_SpectralSolver_illuminant() for ( size_t col = 0; col < 3; col++ ) OIIO_CHECK_EQUAL_THRESH( solved_IDT[row][col], true_IDT[row][col], 1e-5 ); -}; +} /// A helper function to init the metadata object. /// Normally the values come from a DNG file metadata. @@ -157,7 +157,7 @@ void test_MetadataSolver() for ( size_t col = 0; col < 3; col++ ) OIIO_CHECK_EQUAL_THRESH( solved_IDT[row][col], true_IDT[row][col], 1e-5 ); -}; +} int main( int, char ** ) { diff --git a/tests/usage_example_util.cpp b/tests/usage_example_util.cpp index fed50b7c..d2406ef1 100644 --- a/tests/usage_example_util.cpp +++ b/tests/usage_example_util.cpp @@ -38,7 +38,7 @@ void test_ImageConverter_arguments() // Check the result. OIIO_CHECK_ASSERT( result ); -}; +} /// Test the image converter, initialising the settings struct directly. void test_ImageConverter_settings() @@ -65,7 +65,7 @@ void test_ImageConverter_settings() // Check the result. OIIO_CHECK_ASSERT( result ); -}; +} int main( int, char ** ) {