Skip to content

Commit 4d20772

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

File tree

8 files changed

+59
-74
lines changed

8 files changed

+59
-74
lines changed

.github/workflows/analysis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@ jobs:
5959
shell: bash
6060
run: |
6161
build_scripts/install_deps_linux.bash
62-
63-
- name: Install sonar-scanner and build-wrapper
64-
uses: sonarsource/sonarcloud-github-c-cpp@e4882e1621ad2fb48dddfa48287411bed34789b1 # v2.0.2
6562
6663
- name: Configure CMake
6764
run: >
@@ -84,3 +81,7 @@ jobs:
8481
with:
8582
name: "CodeChecker Bug Reports"
8683
path: ${{ steps.codechecker.outputs.result-html-dir }}
84+
85+
- name: "Break build if CodeChecker reported any findings"
86+
if: ${{ steps.codechecker.outputs.warnings == 'true' }}
87+
run: exit 1

include/rawtoaces/image_converter.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,9 @@ class ImageConverter
277277

278278
private:
279279
// Solved transform of the current image.
280-
std::vector<std::vector<double>> _IDT_matrix;
281-
std::vector<std::vector<double>> _CAT_matrix;
282-
std::vector<double> _WB_multipliers;
280+
std::vector<std::vector<double>> _idt_matrix;
281+
std::vector<std::vector<double>> _cat_matrix;
282+
std::vector<double> _wb_multipliers;
283283
};
284284

285285
} //namespace util

include/rawtoaces/rawtoaces_core.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ class SpectralSolver
169169
std::vector<std::string> _search_directories;
170170
std::vector<SpectralData> _all_illuminants;
171171

172-
std::vector<double> _WB_multipliers;
173-
std::vector<std::vector<double>> _IDT_matrix;
172+
std::vector<double> _wb_multipliers;
173+
std::vector<std::vector<double>> _idt_matrix;
174174
};
175175

176176
/// DNG metadata required to calculate an input transform.

src/rawtoaces/main.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@ int main( int argc, const char *argv[] )
1212
#else
1313
_putenv( (char *)"TZ=UTC" );
1414
#endif
15-
16-
17-
int x;
18-
19-
int y = x;
20-
std::cerr << y;
21-
2215

2316
rta::util::ImageConverter converter;
2417

src/rawtoaces_core/define.h

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

4-
#ifndef _DEFINE_h__
5-
#define _DEFINE_h__
4+
#pragma once
65

76
#include <string>
87
#include <algorithm>
@@ -343,5 +342,3 @@ inline bool isValidCT( std::string str )
343342

344343
} // namespace core
345344
} // namespace rta
346-
347-
#endif

src/rawtoaces_core/mathOps.h

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

4-
#ifndef _MATHOPS_h__
5-
#define _MATHOPS_h__
4+
#pragma once
65

76
#include "define.h"
87

@@ -491,5 +490,3 @@ getCalcXYZt( const vector<vector<T>> &RGB, const T beta_params[6] )
491490

492491
} // namespace core
493492
} // namespace rta
494-
495-
#endif

src/rawtoaces_core/rawtoaces_core.cpp

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,8 @@ void calculate_daylight_SPD( const int &cct_input, Spectrum &spectrum )
5555
cct = cct_input * 1.0;
5656
else
5757
{
58-
fprintf(
59-
stderr,
60-
"The range of Correlated Color Temperature for "
61-
"Day Light should be from 4000 to 25000. \n" );
58+
std::cerr << "The range of Correlated Color Temperature for "
59+
<< "Day Light should be from 4000 to 25000." << std::endl;
6260
exit( 1 );
6361
}
6462

@@ -104,10 +102,8 @@ void calculate_blackbody_SPD( const int &cct, Spectrum &spectrum )
104102
{
105103
if ( cct < 1500 || cct >= 4000 )
106104
{
107-
fprintf(
108-
stderr,
109-
"The range of Color Temperature for BlackBody "
110-
"should be from 1500 to 3999. \n" );
105+
std::cerr << "The range of Color Temperature for BlackBody "
106+
<< "should be from 1500 to 3999." << std::endl;
111107
exit( 1 );
112108
}
113109

@@ -147,10 +143,11 @@ void generate_illuminant(
147143
auto &main_spectral_set = main_iter->second;
148144

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

155152
illuminant.illuminant = type;
156153
if ( is_daylight )
@@ -168,15 +165,15 @@ SpectralSolver::SpectralSolver(
168165
: _search_directories( search_directories )
169166
{
170167
verbosity = 0;
171-
_IDT_matrix.resize( 3 );
172-
_WB_multipliers.resize( 3 );
168+
_idt_matrix.resize( 3 );
169+
_wb_multipliers.resize( 3 );
173170
for ( int i = 0; i < 3; i++ )
174171
{
175-
_IDT_matrix[i].resize( 3 );
176-
_WB_multipliers[i] = 1.0;
172+
_idt_matrix[i].resize( 3 );
173+
_wb_multipliers[i] = 1.0;
177174
for ( size_t j = 0; j < 3; j++ )
178175
{
179-
_IDT_matrix[i][j] = neutral3[i][j];
176+
_idt_matrix[i][j] = neutral3[i][j];
180177
}
181178
}
182179
}
@@ -402,7 +399,7 @@ bool SpectralSolver::find_illuminant( const vector<double> &wb )
402399
{
403400
sse = sse_tmp;
404401
illuminant = current_illuminant;
405-
_WB_multipliers = wb_tmp;
402+
_wb_multipliers = wb_tmp;
406403
}
407404
}
408405

@@ -431,7 +428,7 @@ bool SpectralSolver::calculate_WB()
431428
return false;
432429
}
433430

434-
_WB_multipliers = _calculate_WB( camera, illuminant );
431+
_wb_multipliers = _calculate_WB( camera, illuminant );
435432
return true;
436433
}
437434

@@ -455,7 +452,7 @@ calculate_CM( const SpectralData &camera, const SpectralData &illuminant )
455452
double g = ( camera_g * illuminant_spectrum ).integrate();
456453
double b = ( camera_b * illuminant_spectrum ).integrate();
457454

458-
double max = std::max( r, std::max( g, b ) );
455+
double max = std::max( { r, g, b } );
459456

460457
std::vector<double> result( 3 );
461458
result[0] = max / r;
@@ -746,10 +743,10 @@ bool SpectralSolver::calculate_IDT_matrix()
746743
double beta_params_start[6] = { 1.0, 0.0, 0.0, 1.0, 0.0, 0.0 };
747744

748745
auto TI = calculate_TI( illuminant, training_data );
749-
auto RGB = calculate_RGB( camera, _WB_multipliers, TI );
746+
auto RGB = calculate_RGB( camera, _wb_multipliers, TI );
750747
auto XYZ = calculate_XYZ( observer, illuminant, TI );
751748

752-
return curveFit( RGB, XYZ, beta_params_start, verbosity, _IDT_matrix );
749+
return curveFit( RGB, XYZ, beta_params_start, verbosity, _idt_matrix );
753750
}
754751

755752
// =====================================================================
@@ -763,12 +760,12 @@ bool SpectralSolver::calculate_IDT_matrix()
763760

764761
const vector<vector<double>> &SpectralSolver::get_IDT_matrix() const
765762
{
766-
return _IDT_matrix;
763+
return _idt_matrix;
767764
}
768765

769766
const vector<double> &SpectralSolver::get_WB_multipliers() const
770767
{
771-
return _WB_multipliers;
768+
return _wb_multipliers;
772769
}
773770

774771
MetadataSolver::MetadataSolver( const core::Metadata &metadata )
@@ -953,13 +950,13 @@ vector<double> find_XYZ_to_camera_matrix(
953950

954951
if ( metadata.calibration[0].illuminant == 0 )
955952
{
956-
fprintf( stderr, " No calibration illuminants were found. \n " );
953+
std::cerr << "No calibration illuminants were found." << std::endl;
957954
return metadata.calibration[0].XYZ_to_RGB_matrix;
958955
}
959956

960957
if ( neutral_RGB.size() == 0 )
961958
{
962-
fprintf( stderr, " no neutral RGB values were found. \n " );
959+
std::cerr << "No neutral RGB values were found." << std::endl;
963960
return metadata.calibration[0].XYZ_to_RGB_matrix;
964961
}
965962

@@ -1247,4 +1244,4 @@ bool IDTOptimizationCost::operator()( const T *beta_params, T *residuals ) const
12471244
}
12481245

12491246
} // namespace core
1250-
} // namespace rta
1247+
} // namespace rta

src/rawtoaces_util/image_converter.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,9 +1328,9 @@ bool ImageConverter::configure(
13281328
OIIO::TypeDesc( OIIO::TypeDesc::FLOAT, 4 ),
13291329
custom_WB );
13301330

1331-
_WB_multipliers.resize( 4 );
1331+
_wb_multipliers.resize( 4 );
13321332
for ( size_t i = 0; i < 4; i++ )
1333-
_WB_multipliers[i] = custom_WB[i];
1333+
_wb_multipliers[i] = custom_WB[i];
13341334
}
13351335
break;
13361336
}
@@ -1366,9 +1366,9 @@ bool ImageConverter::configure(
13661366
OIIO::TypeDesc( OIIO::TypeDesc::FLOAT, 4 ),
13671367
settings.custom_WB );
13681368

1369-
_WB_multipliers.resize( 4 );
1369+
_wb_multipliers.resize( 4 );
13701370
for ( size_t i = 0; i < 4; i++ )
1371-
_WB_multipliers[i] = settings.custom_WB[i];
1371+
_wb_multipliers[i] = settings.custom_WB[i];
13721372
break;
13731373

13741374
default:
@@ -1422,13 +1422,13 @@ bool ImageConverter::configure(
14221422
options["raw:ColorSpace"] = "raw";
14231423
options["raw:use_camera_matrix"] = 0;
14241424

1425-
_IDT_matrix.resize( 3 );
1425+
_idt_matrix.resize( 3 );
14261426
for ( int i = 0; i < 3; i++ )
14271427
{
1428-
_IDT_matrix[i].resize( 3 );
1428+
_idt_matrix[i].resize( 3 );
14291429
for ( int j = 0; j < 3; j++ )
14301430
{
1431-
_IDT_matrix[i][j] = settings.custom_matrix[i][j];
1431+
_idt_matrix[i][j] = settings.custom_matrix[i][j];
14321432
}
14331433
}
14341434
break;
@@ -1448,9 +1448,9 @@ bool ImageConverter::configure(
14481448
if ( !prepare_transform_spectral(
14491449
image_spec,
14501450
settings,
1451-
_WB_multipliers,
1452-
_IDT_matrix,
1453-
_CAT_matrix ) )
1451+
_wb_multipliers,
1452+
_idt_matrix,
1453+
_cat_matrix ) )
14541454
{
14551455
std::cerr << "ERROR: the colour space transform has not been "
14561456
<< "configured properly (spectral mode)." << std::endl;
@@ -1461,12 +1461,12 @@ bool ImageConverter::configure(
14611461
{
14621462
float custom_WB[4];
14631463

1464-
for ( size_t i = 0; i < _WB_multipliers.size(); i++ )
1464+
for ( size_t i = 0; i < _wb_multipliers.size(); i++ )
14651465
{
1466-
custom_WB[i] = static_cast<float>( _WB_multipliers[i] );
1466+
custom_WB[i] = static_cast<float>( _wb_multipliers[i] );
14671467
}
1468-
if ( _WB_multipliers.size() == 3 )
1469-
custom_WB[3] = static_cast<float>( _WB_multipliers[1] );
1468+
if ( _wb_multipliers.size() == 3 )
1469+
custom_WB[3] = static_cast<float>( _wb_multipliers[1] );
14701470

14711471
options.attribute(
14721472
"raw:user_mul",
@@ -1483,7 +1483,7 @@ bool ImageConverter::configure(
14831483
options["raw:use_camera_wb"] = 1;
14841484

14851485
if ( !prepare_transform_DNG(
1486-
image_spec, settings, _IDT_matrix, _CAT_matrix ) )
1486+
image_spec, settings, _idt_matrix, _cat_matrix ) )
14871487
{
14881488
std::cerr << "ERROR: the colour space transform has not been "
14891489
<< "configured properly (metadata mode)."
@@ -1493,12 +1493,12 @@ bool ImageConverter::configure(
14931493
}
14941494
else
14951495
{
1496-
prepare_transform_nonDNG( _IDT_matrix, _CAT_matrix );
1496+
prepare_transform_nonDNG( _idt_matrix, _cat_matrix );
14971497
}
14981498
}
14991499
else if ( matrix_method == Settings::MatrixMethod::Adobe )
15001500
{
1501-
prepare_transform_nonDNG( _IDT_matrix, _CAT_matrix );
1501+
prepare_transform_nonDNG( _idt_matrix, _cat_matrix );
15021502
}
15031503

15041504
if ( settings.verbosity > 1 )
@@ -1660,16 +1660,16 @@ bool ImageConverter::apply_matrix(
16601660
if ( !roi.defined() )
16611661
roi = dst.roi();
16621662

1663-
if ( _IDT_matrix.size() )
1663+
if ( _idt_matrix.size() )
16641664
{
1665-
success = rta::util::apply_matrix( _IDT_matrix, dst, src, roi );
1665+
success = rta::util::apply_matrix( _idt_matrix, dst, src, roi );
16661666
if ( !success )
16671667
return false;
16681668
}
16691669

1670-
if ( _CAT_matrix.size() )
1670+
if ( _cat_matrix.size() )
16711671
{
1672-
success = rta::util::apply_matrix( _CAT_matrix, dst, dst, roi );
1672+
success = rta::util::apply_matrix( _cat_matrix, dst, dst, roi );
16731673
if ( !success )
16741674
return false;
16751675

@@ -1917,17 +1917,17 @@ bool ImageConverter::process_image( const std::string &input_filename )
19171917

19181918
const std::vector<double> &ImageConverter::get_WB_multipliers()
19191919
{
1920-
return _WB_multipliers;
1920+
return _wb_multipliers;
19211921
}
19221922

19231923
const std::vector<std::vector<double>> &ImageConverter::get_IDT_matrix()
19241924
{
1925-
return _IDT_matrix;
1925+
return _idt_matrix;
19261926
}
19271927

19281928
const std::vector<std::vector<double>> &ImageConverter::get_CAT_matrix()
19291929
{
1930-
return _CAT_matrix;
1930+
return _cat_matrix;
19311931
}
19321932

19331933
} //namespace util

0 commit comments

Comments
 (0)