Skip to content

Commit ca2ff46

Browse files
committed
analysis
Signed-off-by: Anton Dukhovnikov <[email protected]>
1 parent e86e816 commit ca2ff46

15 files changed

+62
-20
lines changed

include/rawtoaces/image_converter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33

44
#pragma once
55

6+
#ifndef __clang_analyzer__
67
#include <OpenImageIO/imagebuf.h>
78
#include <OpenImageIO/argparse.h>
9+
#endif
810

911
namespace rta
1012
{

src/rawtoaces_core/rawtoaces_core.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,10 @@ void generate_illuminant(
143143
auto &main_spectral_set = main_iter->second;
144144

145145
// Add the power channel and get a reference to it
146-
auto &power_spectrum =
147-
main_spectral_set
148-
.emplace_back(
149-
SpectralData::SpectralChannel( "power", Spectrum( 0 ) ) )
150-
.second;
146+
auto &power_data = main_spectral_set.emplace_back(
147+
SpectralData::SpectralChannel(
148+
"power", Spectrum( 0 ) ) );
149+
auto &power_spectrum = power_data.second;
151150

152151
illuminant.illuminant = type;
153152
if ( is_daylight )
@@ -980,13 +979,13 @@ vector<double> find_XYZ_to_camera_matrix(
980979
std::clamp( std::min( mir1, mir2 ), min_mired, max_mired );
981980
double high_mired =
982981
std::clamp( std::max( mir1, mir2 ), min_mired, max_mired );
983-
double mirStep = std::max( 5.0, ( high_mired - low_mired ) / 50.0 );
982+
double mired_step = std::max( 5.0, ( high_mired - low_mired ) / 50.0 );
984983

985-
double current_mired = 0.0, last_mired = 0.0, estimated_mired = 0.0,
986-
current_error = 0.0, last_error = 0.0, smallest_error = 0.0;
984+
double last_mired = 0.0, estimated_mired = 0.0, current_error = 0.0,
985+
last_error = 0.0, smallest_error = 0.0;
987986

988-
for ( current_mired = low_mired; current_mired < high_mired;
989-
current_mired += mirStep )
987+
double current_mired = low_mired;
988+
while( current_mired < high_mired )
990989
{
991990
current_error =
992991
current_mired -
@@ -1017,6 +1016,8 @@ vector<double> find_XYZ_to_camera_matrix(
10171016

10181017
last_error = current_error;
10191018
last_mired = current_mired;
1019+
1020+
current_mired += mired_step;
10201021
}
10211022

10221023
return XYZ_to_camera_weighted_matrix(

src/rawtoaces_core/spectral_data.cpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,24 @@ void Spectrum::reshape()
8888

8989
std::vector<double> temp;
9090
size_t src = 0;
91-
float wl_src = shape.first;
92-
float wl_dst = ReferenceShape.first;
91+
92+
double wl_src_first = shape.first;
93+
double wl_src_step = shape.step;
9394

94-
while ( wl_dst <= ReferenceShape.last )
95+
double wl_dst_first = ReferenceShape.first;
96+
double wl_dst_last = ReferenceShape.last;
97+
double wl_dst_step = ReferenceShape.step;
98+
99+
double wl_src = wl_src_first;
100+
double wl_dst = wl_dst_first;
101+
102+
while ( wl_dst <= wl_dst_last )
95103
{
96104
if ( wl_src < wl_dst )
97105
{
98106
if ( src < values.size() - 1 )
99107
{
100-
float next_wl_src = shape.first + shape.step * ( src + 1 );
108+
float next_wl_src = wl_src_first + wl_src_step * ( src + 1 );
101109
if ( next_wl_src <= wl_dst )
102110
{
103111
// The next source wavelength is still not big enough,
@@ -114,30 +122,28 @@ void Spectrum::reshape()
114122
double vv =
115123
values[src] * ( 1.0 - ratio ) + values[src + 1] * ratio;
116124
temp.push_back( vv );
117-
wl_dst = ReferenceShape.first +
118-
ReferenceShape.step * temp.size();
125+
wl_dst = wl_dst_first + wl_dst_step * temp.size();
119126
}
120127
}
121128
else
122129
{
123130
// We have passed all available source samples,
124131
// copying the last sample.
125132
temp.push_back( values[src] );
126-
wl_dst =
127-
ReferenceShape.first + ReferenceShape.step * temp.size();
133+
wl_dst = wl_dst_first + wl_dst_step * temp.size();
128134
}
129135
}
130136
else if ( wl_src == wl_dst )
131137
{
132138
// Found an exact match, just copy it over.
133139
temp.push_back( values[src] );
134-
wl_dst = ReferenceShape.first + ReferenceShape.step * temp.size();
140+
wl_dst = wl_dst_first + wl_dst_step * temp.size();
135141
}
136142
else
137143
{
138144
// Haven't reached the available source range yet, advancing.
139145
temp.push_back( values[src] );
140-
wl_dst = ReferenceShape.first + ReferenceShape.step * temp.size();
146+
wl_dst = wl_dst_first + wl_dst_step * temp.size();
141147
}
142148
}
143149

src/rawtoaces_util/image_converter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
#include <set>
99
#include <filesystem>
1010

11+
#ifndef __clang_analyzer__
1112
#include <OpenImageIO/imageio.h>
1213
#include <OpenImageIO/imagebuf.h>
1314
#include <OpenImageIO/imagebufalgo.h>
15+
#endif
1416

1517
namespace rta
1618
{

tests/testDNGIdt.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
// Copyright Contributors to the rawtoaces Project.
33

44
#include <filesystem>
5+
6+
#ifndef __clang_analyzer__
57
#include <OpenImageIO/unittest.h>
8+
#endif
69

710
#include <rawtoaces/rawtoaces_core.h>
811
#include "../src/rawtoaces_core/define.h"

tests/testIDT.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
#endif
88

99
#include <filesystem>
10+
11+
#ifndef __clang_analyzer__
1012
#include <OpenImageIO/unittest.h>
13+
#endif
1114

1215
#include "../src/rawtoaces_core/mathOps.h"
1316
#include <rawtoaces/rawtoaces_core.h>

tests/testIllum.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
#endif
88

99
#include <filesystem>
10+
11+
#ifndef __clang_analyzer__
1012
#include <OpenImageIO/unittest.h>
13+
#endif
1114

1215
#include "../src/rawtoaces_core/mathOps.h"
1316
#include <rawtoaces/rawtoaces_core.h>

tests/testLogic.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// SPDX-License-Identifier: Apache-2.0
22
// Copyright Contributors to the rawtoaces Project.
33

4+
#ifndef __clang_analyzer__
45
#include <OpenImageIO/unittest.h>
6+
#endif
57

68
#include "../src/rawtoaces_core/mathOps.h"
79

tests/testMath.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
# undef RGB
88
#endif
99

10+
#ifndef __clang_analyzer__
1011
#include <OpenImageIO/unittest.h>
12+
#endif
1113

1214
#include "../src/rawtoaces_core/mathOps.h"
1315

tests/testMisc.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
// SPDX-License-Identifier: Apache-2.0
22
// Copyright Contributors to the rawtoaces Project.
33

4+
#ifndef __clang_analyzer__
45
#include <OpenImageIO/unittest.h>
6+
#endif
7+
58
#include <filesystem>
69

710
#include "../src/rawtoaces_core/define.h"

0 commit comments

Comments
 (0)