Skip to content

Commit

Permalink
Merge pull request #134 from antond-weta/header_cleanup
Browse files Browse the repository at this point in the history
remove unnecessary stuff from headers
  • Loading branch information
KelSolaar authored Dec 14, 2023
2 parents 71418e5 + 3f17b94 commit ed8034a
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 74 deletions.
8 changes: 1 addition & 7 deletions include/rawtoaces/acesrender.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,7 @@

#include <rawtoaces/rta.h>

#ifndef __aces_oeWriter__
# include <aces/aces_Writer.h>
#endif

#ifndef _LIBRAW_CLASS_H
# include <libraw/libraw.h>
#endif
#include <unordered_map>

using namespace rta;

Expand Down
29 changes: 2 additions & 27 deletions include/rawtoaces/define.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,31 +54,12 @@
#ifndef _DEFINE_h__
#define _DEFINE_h__

#include <assert.h>
#include <stdlib.h>
#include <stdexcept>
#include <string>
#include <math.h>
#include <ctype.h>
#include <cfloat>
//#include <stdexcept>
#include <vector>
#include <unordered_map>
#include <mutex>
#include <thread>
#include <Imath/half.h>
#include <Eigen/Core>
#include <glog/logging.h>
#include <ceres/ceres.h>
#include <boost/lexical_cast.hpp>
#include <algorithm>
#include <boost/filesystem.hpp>

#ifndef WIN32
# include <fcntl.h>
# include <unistd.h>
# include <sys/stat.h>
# include <sys/mman.h>
# include <sys/time.h>
#endif

#define INV_255 ( 1.0 / (double)255.0 )
Expand All @@ -87,6 +68,7 @@
#ifdef WIN32
// suppress sprintf-related warning. sprintf() is permitted in sample code
# include <string.h>
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# define snprintf _snprintf
# define _CRT_SECURE_NO_WARNINGS
Expand All @@ -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 ) \
Expand All @@ -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
{
Expand Down
7 changes: 6 additions & 1 deletion include/rawtoaces/mathOps.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@

#include "define.h"

//using namespace Eigen;
#include <cfloat>

#include <Eigen/Core>
#include <ceres/ceres.h>

using namespace Eigen;

// Non-class functions
inline double invertD( double val )
Expand Down
30 changes: 2 additions & 28 deletions include/rawtoaces/rta.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <iostream>
#include <fstream>
#include <stdexcept>
#include <stdint.h>
#include <math.h>
#include <string>
#include <ctype.h>
#include <stdlib.h>
#include <Imath/half.h>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/foreach.hpp>
#include <libraw/libraw.h>

#include "mathOps.h"

using namespace std;
using namespace ceres;
using namespace boost::property_tree;

namespace rta
{
Expand Down Expand Up @@ -284,16 +267,7 @@ struct Objfun
: _RGB( RGB ), _outLAB( outLAB )
{}

template <typename T> bool operator()( const T *B, T *residuals ) const
{
vector<vector<T>> RGBJet( 190, vector<T>( 3 ) );
FORIJ( 190, 3 ) RGBJet[i][j] = T( _RGB[i][j] );

vector<vector<T>> outCalcLAB = XYZtoLAB( getCalcXYZt( RGBJet, B ) );
FORIJ( 190, 3 ) residuals[i * 3 + j] = _outLAB[i][j] - outCalcLAB[i][j];

return true;
}
template <typename T> bool operator()( const T *B, T *residuals ) const;

const vector<vector<double>> _RGB;
const vector<vector<double>> _outLAB;
Expand Down
42 changes: 32 additions & 10 deletions src/rawtoaces_idt/rta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@
///////////////////////////////////////////////////////////////////////////

#include <rawtoaces/rta.h>
#include <rawtoaces/mathOps.h>

#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/foreach.hpp>

using namespace boost::property_tree;
using namespace ceres;

namespace rta
{
Expand Down Expand Up @@ -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;

Expand All @@ -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 );
Expand Down Expand Up @@ -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> rgbsen;
vector<double> max( 3, dmin );
Expand Down Expand Up @@ -706,7 +714,7 @@ vector<RGBSen> Spst::getSensitivity()

void Spst::setBrand( const char *brand )
{
assert( brand != null_ptr );
assert( brand != nullptr );
size_t len = strlen( brand );

assert( len < 64 );
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -1341,8 +1349,9 @@ int Idt::curveFit(
Problem problem;
vector<vector<double>> outLAB = XYZtoLAB( XYZ );

CostFunction *cost_function = new AutoDiffCostFunction<Objfun, DYNAMIC, 6>(
new Objfun( RGB, outLAB ), int( RGB.size() * ( RGB[0].size() ) ) );
CostFunction *cost_function =
new AutoDiffCostFunction<Objfun, ceres::DYNAMIC, 6>(
new Objfun( RGB, outLAB ), int( RGB.size() * ( RGB[0].size() ) ) );

problem.AddResidualBlock( cost_function, NULL, B );

Expand Down Expand Up @@ -1606,9 +1615,10 @@ double DNGIdt::robertsonLength(
const vector<double> &uv, const vector<double> &uvt ) const
{

double t = uvt[2];
double t = uvt[2];
double sign = t < 0 ? -1.0 : t > 0 ? 1.0 : 0.0;
vector<double> 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<double> uvr( uvt.begin(), uvt.begin() + 2 );
Expand Down Expand Up @@ -1893,4 +1903,16 @@ vector<vector<double>> DNGIdt::getDNGIDTMatrix()

return DNGIDTMatrix;
}

template <typename T> bool Objfun::operator()( const T *B, T *residuals ) const
{
vector<vector<T>> RGBJet( 190, vector<T>( 3 ) );
FORIJ( 190, 3 ) RGBJet[i][j] = T( _RGB[i][j] );

vector<vector<T>> outCalcLAB = XYZtoLAB( getCalcXYZt( RGBJet, B ) );
FORIJ( 190, 3 ) residuals[i * 3 + j] = _outLAB[i][j] - outCalcLAB[i][j];

return true;
}

} // namespace rta
18 changes: 17 additions & 1 deletion src/rawtoaces_util/acesrender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,22 @@
///////////////////////////////////////////////////////////////////////////

#include <rawtoaces/acesrender.h>
#include <rawtoaces/mathOps.h>

#include <Imath/half.h>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/foreach.hpp>

#include <aces/aces_Writer.h>

#ifndef WIN32
# include <fcntl.h>
# include <sys/mman.h>
#endif

using namespace std;
using namespace boost::property_tree;

#include <boost/filesystem.hpp>

Expand Down Expand Up @@ -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();
}

Expand Down

0 comments on commit ed8034a

Please sign in to comment.