From 3f17b94fedc3883fff7796e5be1e305d4038a574 Mon Sep 17 00:00:00 2001 From: Anton Dukhovnikov Date: Tue, 14 Nov 2023 11:02:53 +1300 Subject: [PATCH] remove unnecessary stuff from headers Signed-off-by: Anton Dukhovnikov --- include/rawtoaces/acesrender.h | 8 +----- include/rawtoaces/define.h | 29 ++------------------- include/rawtoaces/mathOps.h | 7 +++++- include/rawtoaces/rta.h | 30 ++-------------------- src/rawtoaces_idt/rta.cpp | 42 +++++++++++++++++++++++-------- src/rawtoaces_util/acesrender.cpp | 18 ++++++++++++- 6 files changed, 60 insertions(+), 74 deletions(-) diff --git a/include/rawtoaces/acesrender.h b/include/rawtoaces/acesrender.h index cde11e6..2d8d98c 100644 --- a/include/rawtoaces/acesrender.h +++ b/include/rawtoaces/acesrender.h @@ -57,13 +57,7 @@ #include -#ifndef __aces_oeWriter__ -# include -#endif - -#ifndef _LIBRAW_CLASS_H -# include -#endif +#include using namespace rta; diff --git a/include/rawtoaces/define.h b/include/rawtoaces/define.h index d43ef13..c76b6db 100644 --- a/include/rawtoaces/define.h +++ b/include/rawtoaces/define.h @@ -54,31 +54,12 @@ #ifndef _DEFINE_h__ #define _DEFINE_h__ -#include -#include -#include #include -#include -#include -#include -//#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include #ifndef WIN32 -# include -# include # include -# include -# include #endif #define INV_255 ( 1.0 / (double)255.0 ) @@ -87,6 +68,7 @@ #ifdef WIN32 // suppress sprintf-related warning. sprintf() is permitted in sample code # include +# define WIN32_LEAN_AND_MEAN # include # define snprintf _snprintf # define _CRT_SECURE_NO_WARNINGS @@ -103,7 +85,6 @@ # define FALSE 0 #endif -#define sign( x ) ( ( x ) > 0 ? 1 : ( ( x ) < 0 ? ( 0 - 1 ) : 0 ) ) #define FORI( val ) for ( int i = 0; i < val; i++ ) #define FORJ( val ) for ( int j = 0; j < val; j++ ) #define FORIJ( val1, val2 ) \ @@ -115,12 +96,6 @@ typedef float float32_t; typedef double float64_t; using namespace std; -using ceres::AutoDiffCostFunction; -using ceres::CauchyLoss; -using ceres::CostFunction; -using ceres::Problem; -using ceres::Solve; -using ceres::Solver; enum matMethods_t { diff --git a/include/rawtoaces/mathOps.h b/include/rawtoaces/mathOps.h index 17c844e..b9b3130 100644 --- a/include/rawtoaces/mathOps.h +++ b/include/rawtoaces/mathOps.h @@ -57,7 +57,12 @@ #include "define.h" -//using namespace Eigen; +#include + +#include +#include + +using namespace Eigen; // Non-class functions inline double invertD( double val ) diff --git a/include/rawtoaces/rta.h b/include/rawtoaces/rta.h index 0c9163d..bb867dc 100644 --- a/include/rawtoaces/rta.h +++ b/include/rawtoaces/rta.h @@ -55,29 +55,12 @@ #ifndef _RTA_h__ #define _RTA_h__ -// # C++ 11:201103L, C++ 97:199711L -// #define null_ptr (__cplusplus > 201103L ? (nullptr) : 0) -#define null_ptr nullptr +#include "define.h" -#include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include "mathOps.h" - using namespace std; -using namespace ceres; -using namespace boost::property_tree; namespace rta { @@ -284,16 +267,7 @@ struct Objfun : _RGB( RGB ), _outLAB( outLAB ) {} - template bool operator()( const T *B, T *residuals ) const - { - vector> RGBJet( 190, vector( 3 ) ); - FORIJ( 190, 3 ) RGBJet[i][j] = T( _RGB[i][j] ); - - vector> outCalcLAB = XYZtoLAB( getCalcXYZt( RGBJet, B ) ); - FORIJ( 190, 3 ) residuals[i * 3 + j] = _outLAB[i][j] - outCalcLAB[i][j]; - - return true; - } + template bool operator()( const T *B, T *residuals ) const; const vector> _RGB; const vector> _outLAB; diff --git a/src/rawtoaces_idt/rta.cpp b/src/rawtoaces_idt/rta.cpp index 00b7629..73b2973 100644 --- a/src/rawtoaces_idt/rta.cpp +++ b/src/rawtoaces_idt/rta.cpp @@ -53,6 +53,14 @@ /////////////////////////////////////////////////////////////////////////// #include +#include + +#include +#include +#include + +using namespace boost::property_tree; +using namespace ceres; namespace rta { @@ -421,8 +429,8 @@ void Illum::calBlackBodySPD( const int &cct ) Spst::Spst() { - _brand = null_ptr; - _model = null_ptr; + _brand = nullptr; + _model = nullptr; _increment = 5; _spstMaxCol = -1; @@ -434,7 +442,7 @@ Spst::Spst() Spst::Spst( const Spst &spstobject ) { - assert( spstobject._brand != null_ptr && spstobject._model != null_ptr ); + assert( spstobject._brand != nullptr && spstobject._model != nullptr ); size_t lenb = strlen( spstobject._brand ); assert( lenb < 64 ); @@ -584,7 +592,7 @@ int Spst::getWLIncrement() int Spst::loadSpst( const string &path, const char *maker, const char *model ) { - assert( path.length() > 0 && maker != null_ptr && model != null_ptr ); + assert( path.length() > 0 && maker != nullptr && model != nullptr ); vector rgbsen; vector max( 3, dmin ); @@ -706,7 +714,7 @@ vector Spst::getSensitivity() void Spst::setBrand( const char *brand ) { - assert( brand != null_ptr ); + assert( brand != nullptr ); size_t len = strlen( brand ); assert( len < 64 ); @@ -734,7 +742,7 @@ void Spst::setBrand( const char *brand ) void Spst::setModel( const char *model ) { - assert( model != null_ptr ); + assert( model != nullptr ); size_t len = strlen( model ); assert( len < 64 ); @@ -1341,8 +1349,9 @@ int Idt::curveFit( Problem problem; vector> outLAB = XYZtoLAB( XYZ ); - CostFunction *cost_function = new AutoDiffCostFunction( - new Objfun( RGB, outLAB ), int( RGB.size() * ( RGB[0].size() ) ) ); + CostFunction *cost_function = + new AutoDiffCostFunction( + new Objfun( RGB, outLAB ), int( RGB.size() * ( RGB[0].size() ) ) ); problem.AddResidualBlock( cost_function, NULL, B ); @@ -1606,9 +1615,10 @@ double DNGIdt::robertsonLength( const vector &uv, const vector &uvt ) const { - double t = uvt[2]; + double t = uvt[2]; + double sign = t < 0 ? -1.0 : t > 0 ? 1.0 : 0.0; vector slope( 2 ); - slope[0] = -sign( t ) / std::sqrt( 1 + t * t ); + slope[0] = -sign / std::sqrt( 1 + t * t ); slope[1] = t * slope[0]; vector uvr( uvt.begin(), uvt.begin() + 2 ); @@ -1893,4 +1903,16 @@ vector> DNGIdt::getDNGIDTMatrix() return DNGIDTMatrix; } + +template bool Objfun::operator()( const T *B, T *residuals ) const +{ + vector> RGBJet( 190, vector( 3 ) ); + FORIJ( 190, 3 ) RGBJet[i][j] = T( _RGB[i][j] ); + + vector> outCalcLAB = XYZtoLAB( getCalcXYZt( RGBJet, B ) ); + FORIJ( 190, 3 ) residuals[i * 3 + j] = _outLAB[i][j] - outCalcLAB[i][j]; + + return true; +} + } // namespace rta diff --git a/src/rawtoaces_util/acesrender.cpp b/src/rawtoaces_util/acesrender.cpp index fd04876..069eb10 100644 --- a/src/rawtoaces_util/acesrender.cpp +++ b/src/rawtoaces_util/acesrender.cpp @@ -53,6 +53,22 @@ /////////////////////////////////////////////////////////////////////////// #include +#include + +#include +#include +#include +#include + +#include + +#ifndef WIN32 +# include +# include +#endif + +using namespace std; +using namespace boost::property_tree; #include @@ -1859,7 +1875,7 @@ void AcesRender::acesWrite( const char *name, float *aces, float ratio ) const else if ( bits == 16 ) aces[i] = (double)aces[i] * INV_65535 * ( _opts.scale ) * ratio; - half tmpV( aces[i] ); + Imath::half tmpV( aces[i] ); halfIn[i] = tmpV.bits(); }