Skip to content

Commit 495bedf

Browse files
author
Remi Achard
committed
Code annotations
1 parent 774c2e3 commit 495bedf

File tree

33 files changed

+407
-3
lines changed

33 files changed

+407
-3
lines changed

src/OpenColorIO/Config.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2825,13 +2825,15 @@ bool Config::isColorSpaceLinear(const char * colorSpace, ReferenceSpaceType refe
28252825
// where the neutral may be linear but there is non-linearity off the neutral axis.
28262826
auto evaluate = [](const Config & config, ConstTransformRcPtr &t) -> bool
28272827
{
2828+
// clang-format off
28282829
std::vector<float> img =
28292830
{
28302831
0.0625f, 0.0625f, 0.0625f, 4.f, 4.f, 4.f,
28312832
0.0625f, 0.f, 0.f, 4.f, 0.f, 0.f,
28322833
0.f, 0.0625f, 0.f, 0.f, 4.f, 0.f,
28332834
0.f, 0.f, 0.0625f, 0.f, 0.f, 4.f
28342835
};
2836+
// clang-format on
28352837
std::vector<float> dst(img.size(), 0.f);
28362838

28372839
PackedImageDesc desc(&img[0], 8, 1, CHANNEL_ORDERING_RGB);

src/OpenColorIO/ConfigUtils.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,11 +430,13 @@ int getReferenceSpaceFromLinearSpace(const ConstConfigRcPtr & srcConfig,
430430
{
431431
// Define a set of (somewhat arbitrary) RGB values to test whether the combined transform is
432432
// enough of an identity.
433+
// clang-format off
433434
std::vector<float> vals = { 0.7f, 0.4f, 0.02f, 0.f,
434435
0.02f, 0.6f, -0.2f, 0.f,
435436
0.3f, 0.02f, 1.5f, 0.f,
436437
0.f, 0.f, 0.f, 0.f,
437438
1.f, 1.f, 1.f, 0.f };
439+
// clang-format on
438440

439441
// Test the transform from the test color space to its reference space against all combinations
440442
// of the built-in linear color spaces. If one of them results in an identity, that identifies
@@ -513,6 +515,7 @@ int getReferenceSpaceFromSRGBSpace(const ConstConfigRcPtr & srcConfig,
513515
// reference space primaries.
514516

515517
// Break point is at 0.039286, so include at least one value below this.
518+
// clang-format off
516519
std::vector<float> vals =
517520
{
518521
0.5f, 0.5f, 0.5f,
@@ -522,6 +525,7 @@ int getReferenceSpaceFromSRGBSpace(const ConstConfigRcPtr & srcConfig,
522525
0.f, 0.f, 0.f,
523526
1.f, 1.f , 1.f
524527
};
528+
// clang-format on
525529
std::vector<float> out(vals.size(), 0.f);
526530

527531
PackedImageDesc desc( &vals[0], (long) vals.size() / 3, 1, CHANNEL_ORDERING_RGB );
@@ -568,11 +572,13 @@ int getReferenceSpaceFromSRGBSpace(const ConstConfigRcPtr & srcConfig,
568572
// Define a (somewhat arbitrary) set of RGB values to test whether the transform is in fact
569573
// converting sRGB texture values to the candidate reference space. It includes 0.02 which is
570574
// on the sRGB linear segment, color values, and neutral values.
575+
// clang-format off
571576
vals = { 0.7f, 0.4f, 0.02f, 0.f,
572577
0.02f, 0.6f, 0.2f, 0.f,
573578
0.3f, 0.02f, 0.5f, 0.f,
574579
0.f, 0.f, 0.f, 0.f,
575580
1.f, 1.f, 1.f, 0.f, };
581+
// clang-format on
576582

577583
// The color space has the sRGB non-linearity. Now try combining the transform with a
578584
// transform from the Built-in config that goes from a variety of reference spaces to an
@@ -794,11 +800,13 @@ const char * IdentifyBuiltinColorSpace(const ConstConfigRcPtr & srcConfig,
794800

795801
if (*builtinInterchangeName)
796802
{
803+
// clang-format off
797804
std::vector<float> vals = { 0.7f, 0.4f, 0.02f, 0.f,
798805
0.02f, 0.6f, 0.2f, 0.f,
799806
0.3f, 0.02f, 0.5f, 0.f,
800807
0.f, 0.f, 0.f, 0.f,
801808
1.f, 1.f, 1.f, 0.f };
809+
// clang-format on
802810

803811
// Loop over the active, non-excluded, color spaces in the source config and test if the
804812
// conversion to the specified space in the built-in config is an identity.

src/OpenColorIO/FileRules.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,14 @@ std::string ConvertToRegularExpression(const char * globPattern, bool ignoreCase
101101
for (size_t idx = 0; idx < globSize; idx = nextIdx)
102102
{
103103
nextIdx = idx + 1;
104+
// clang-format off
104105
if (globString[idx] == '.') { regexPattern += "\\."; continue; }
105106
if (globString[idx] == '?') { regexPattern += "."; continue; }
106107
if (globString[idx] == '*') { regexPattern += ".*"; continue; }
108+
// clang-format on
107109

108110
// Escape regex characters.
111+
// clang-format off
109112
if (globString[idx] == '+') { regexPattern += "\\+"; continue; }
110113
if (globString[idx] == '^') { regexPattern += "\\^"; continue; }
111114
if (globString[idx] == '$') { regexPattern += "\\$"; continue; }
@@ -114,6 +117,7 @@ std::string ConvertToRegularExpression(const char * globPattern, bool ignoreCase
114117
if (globString[idx] == '(') { regexPattern += "\\("; continue; }
115118
if (globString[idx] == ')') { regexPattern += "\\)"; continue; }
116119
if (globString[idx] == '|') { regexPattern += "\\|"; continue; }
120+
// clang-format on
117121

118122
if (globString[idx] == ']')
119123
{
@@ -131,6 +135,7 @@ std::string ConvertToRegularExpression(const char * globPattern, bool ignoreCase
131135
{
132136
subString += '^';
133137
}
138+
// clang-format off
134139
else if (globString[end] == '+'
135140
|| globString[end] == '^'
136141
|| globString[end] == '$'
@@ -139,6 +144,7 @@ std::string ConvertToRegularExpression(const char * globPattern, bool ignoreCase
139144
|| globString[end] == '('
140145
|| globString[end] == ')'
141146
|| globString[end] == '|')
147+
// clang-format on
142148
{
143149
// Escape regex characters.
144150
subString += "\\";

src/OpenColorIO/MathUtils.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ template bool IsM44Identity(const double * m44);
195195
// (We have seen IsScalarEqualToZero sensitivities here on 32-bit
196196
// virtual machines)
197197

198+
// clang-format off
198199
bool GetM44Inverse(float* inverse_out, const float* m_)
199200
{
200201
double m[16];
@@ -298,6 +299,7 @@ void GetM44V4Product(float* vout, const float* m, const float* v_)
298299
vout[2] = m[ 8]*v[0] + m[ 9]*v[1] + m[10]*v[2] + m[11]*v[3];
299300
vout[3] = m[12]*v[0] + m[13]*v[1] + m[14]*v[2] + m[15]*v[3];
300301
}
302+
// clang-format on
301303

302304
void GetV4Sum(float* vout, const float* v1, const float* v2)
303305
{
@@ -350,6 +352,8 @@ bool GetMxbInverse(float* mout, float* vout,
350352
return true;
351353
}
352354

355+
// clang-format off
356+
353357
//------------------------------------------------------------------------------
354358
//
355359
// Map a floating-point number (already represented as an integer) to an ordered
@@ -394,11 +398,14 @@ bool GetMxbInverse(float* mout, float* vout,
394398
// | -NaN | Negative floats | Negative denorms | Positive denorms | Positive floats | NaN |
395399
// +------------+-----------------+------------------+------------------+-----------------+-----------+
396400
//
401+
// clang-format on
397402
inline int FloatForCompare(const unsigned floatBits)
398403
{
399404
return floatBits < 0x80000000 ? (0x80000000 + floatBits) : (0x80000000 - (floatBits & 0x7FFFFFFF));
400405
}
401406

407+
// clang-format off
408+
402409
//------------------------------------------------------------------------------
403410
//
404411
// Map a floating-point number (already represented as an integer) to an ordered

src/OpenColorIO/OpOptimizers.cpp

100755100644
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,15 @@ bool IsPairInverseEnabled(OpData::Type type, OptimizationFlags flags)
6060

6161
bool IsCombineEnabled(OpData::Type type, OptimizationFlags flags)
6262
{
63+
// clang-format off
6364
// Some types are controlled by a flag.
6465
return (type == OpData::ExponentType && HasFlag(flags, OPTIMIZATION_COMP_EXPONENT)) ||
6566
(type == OpData::GammaType && HasFlag(flags, OPTIMIZATION_COMP_GAMMA)) ||
6667
(type == OpData::Lut1DType && HasFlag(flags, OPTIMIZATION_COMP_LUT1D)) ||
6768
(type == OpData::Lut3DType && HasFlag(flags, OPTIMIZATION_COMP_LUT3D)) ||
6869
(type == OpData::MatrixType && HasFlag(flags, OPTIMIZATION_COMP_MATRIX)) ||
6970
(type == OpData::RangeType && HasFlag(flags, OPTIMIZATION_COMP_RANGE));
71+
// clang-format on
7072
}
7173

7274
constexpr int MAX_OPTIMIZATION_PASSES = 80;

src/OpenColorIO/builtinconfigs/BuiltinConfigRegistry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
// OpenColorIO must be first - order is important.
1010
#include <OpenColorIO/OpenColorIO.h>
11-
#include "Mutex.h"
1211

12+
#include "Mutex.h"
1313
#include "Platform.h"
1414

1515
#include "builtinconfigs/BuiltinConfigRegistry.h"

src/OpenColorIO/fileformats/FileFormatICC.cpp

100755100644
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,12 +771,14 @@ LocalFileFormat::buildFileOps(OpRcPtrVec & ops,
771771
// a D50 XYZ to a D65 XYZ.
772772
// In most cases, combining this with the matrix in the ICC profile
773773
// recovers what would be the actual matrix for a D65 native monitor.
774+
// clang-format off
774775
static constexpr double D50_to_D65_m44[] = {
775776
0.955509474537, -0.023074829492, 0.063312392987, 0.0,
776777
-0.028327238868, 1.00994465504, 0.021055592145, 0.0,
777778
0.012329273379, -0.020536209966, 1.33072998567, 0.0,
778779
0.0, 0.0, 0.0, 1.0
779780
};
781+
// clang-format on
780782

781783
const auto fileInterp = fileTransform.getInterpolation();
782784

src/OpenColorIO/fileformats/ctf/CTFReaderUtils.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <regex>
77

88
#include "fileformats/ctf/CTFReaderUtils.h"
9+
910
#include "Platform.h"
1011

1112
namespace OCIO_NAMESPACE

src/OpenColorIO/fileformats/ctf/CTFTransform.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2469,44 +2469,51 @@ void MatrixWriter::writeContent() const
24692469
values[8] * inOutScale, values[9] * inOutScale, values[10] * inOutScale, values[11] * inOutScale, offsets[2] * outScale,
24702470
values[12] * inOutScale, values[13]* inOutScale, values[14] * inOutScale, values[15] * inOutScale, offsets[3] * outScale
24712471
};
2472+
// clang-format on
24722473

24732474
WriteValues(m_formatter, v, v + 20, 5, BIT_DEPTH_F32, 1, 1.0);
24742475
}
24752476
else
24762477
{
24772478
// Write in 4x4x4 compact mode.
2479+
// clang-format off
24782480
const double v[16]
24792481
{
24802482
values[0] * inOutScale, values[1] * inOutScale, values[2] * inOutScale, values[3] * inOutScale,
24812483
values[4] * inOutScale, values[5] * inOutScale, values[6] * inOutScale, values[7] * inOutScale,
24822484
values[8] * inOutScale, values[9] * inOutScale, values[10] * inOutScale, values[11] * inOutScale,
24832485
values[12] * inOutScale, values[13] * inOutScale, values[14] * inOutScale, values[15] * inOutScale
24842486
};
2487+
// clang-format on
24852488

24862489
WriteValues(m_formatter, v, v + 16, 4, BIT_DEPTH_F32, 1, 1.0);
24872490
}
24882491
}
24892492
else if (matrix->hasOffsets())
24902493
{
24912494
// Write in 3x4x3 compact mode.
2495+
// clang-format off
24922496
const double v[12]
24932497
{
24942498
values[0] * inOutScale, values[1] * inOutScale, values[2] * inOutScale, offsets[0] * outScale,
24952499
values[4] * inOutScale, values[5] * inOutScale, values[6] * inOutScale, offsets[1] * outScale,
24962500
values[8] * inOutScale, values[9] * inOutScale, values[10] * inOutScale, offsets[2] * outScale
24972501
};
2502+
// clang-format on
24982503

24992504
WriteValues(m_formatter, v, v + 12, 4, BIT_DEPTH_F32, 1, 1.0);
25002505
}
25012506
else
25022507
{
25032508
// Write in 3x3x3 compact mode.
2509+
// clang-format off
25042510
const double v[9]
25052511
{
25062512
values[0] * inOutScale, values[1] * inOutScale, values[2] * inOutScale,
25072513
values[4] * inOutScale, values[5] * inOutScale, values[6] * inOutScale,
25082514
values[8] * inOutScale, values[9] * inOutScale, values[10] * inOutScale
25092515
};
2516+
// clang-format on
25102517

25112518
WriteValues(m_formatter, v, v + 9, 3, BIT_DEPTH_F32, 1, 1.0);
25122519
}

src/OpenColorIO/ops/exposurecontrast/ExposureContrastOpGPU.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ void AddECLinearShader(GpuShaderCreatorRcPtr & shaderCreator,
9797
const std::string & contrastName,
9898
const std::string & gammaName)
9999
{
100+
// clang-format off
101+
100102
const double pivot = std::max(EC::MIN_PIVOT, ec->getPivot());
101103

102104
st.newLine() << st.floatDecl("exposure") << " = pow( 2., " << exposureName << " );";
@@ -122,6 +124,8 @@ void AddECLinearShader(GpuShaderCreatorRcPtr & shaderCreator,
122124
st.dedent();
123125
}
124126
st.newLine() << "}";
127+
128+
// clang-format on
125129
}
126130

127131
void AddECLinearRevShader(GpuShaderCreatorRcPtr & shaderCreator,
@@ -131,6 +135,8 @@ void AddECLinearRevShader(GpuShaderCreatorRcPtr & shaderCreator,
131135
const std::string & contrastName,
132136
const std::string & gammaName)
133137
{
138+
// clang-format off
139+
134140
const double pivot = std::max(EC::MIN_PIVOT, ec->getPivot());
135141

136142
st.newLine() << st.floatDecl("exposure") << " = pow( 2., " << exposureName << " );";
@@ -157,6 +163,8 @@ void AddECLinearRevShader(GpuShaderCreatorRcPtr & shaderCreator,
157163

158164
st.newLine() << shaderCreator->getPixelName() << ".rgb = "
159165
<< shaderCreator->getPixelName() << ".rgb / exposure;";
166+
167+
// clang-format on
160168
}
161169

162170
void AddECVideoShader(GpuShaderCreatorRcPtr & shaderCreator,
@@ -166,6 +174,8 @@ void AddECVideoShader(GpuShaderCreatorRcPtr & shaderCreator,
166174
const std::string & contrastName,
167175
const std::string & gammaName)
168176
{
177+
// clang-format off
178+
169179
double pivot = std::pow(std::max(EC::MIN_PIVOT, ec->getPivot()), EC::VIDEO_OETF_POWER);
170180

171181
st.newLine() << st.floatDecl("exposure") << " = pow( pow( 2., " << exposureName << " ), "
@@ -191,6 +201,8 @@ void AddECVideoShader(GpuShaderCreatorRcPtr & shaderCreator,
191201
st.dedent();
192202
}
193203
st.newLine() << "}";
204+
205+
// clang-format on
194206
}
195207

196208
void AddECVideoRevShader(GpuShaderCreatorRcPtr & shaderCreator,
@@ -200,6 +212,8 @@ void AddECVideoRevShader(GpuShaderCreatorRcPtr & shaderCreator,
200212
const std::string & contrastName,
201213
const std::string & gammaName)
202214
{
215+
// clang-format off
216+
203217
double pivot = std::pow(std::max(EC::MIN_PIVOT, ec->getPivot()), EC::VIDEO_OETF_POWER);
204218

205219
st.newLine() << st.floatDecl("exposure") << " = pow( pow( 2., " << exposureName << " ), "
@@ -227,6 +241,8 @@ void AddECVideoRevShader(GpuShaderCreatorRcPtr & shaderCreator,
227241

228242
st.newLine() << shaderCreator->getPixelName() << ".rgb = "
229243
<< shaderCreator->getPixelName() << ".rgb / exposure;";
244+
245+
// clang-format on
230246
}
231247

232248
void AddECLogarithmicShader(GpuShaderCreatorRcPtr & shaderCreator,
@@ -236,6 +252,8 @@ void AddECLogarithmicShader(GpuShaderCreatorRcPtr & shaderCreator,
236252
const std::string & contrastName,
237253
const std::string & gammaName)
238254
{
255+
// clang-format off
256+
239257
double pivot = std::max(EC::MIN_PIVOT, ec->getPivot());
240258
float logPivot = (float)std::max(0., std::log2(pivot / 0.18) *
241259
ec->getLogExposureStep() +
@@ -250,6 +268,8 @@ void AddECLogarithmicShader(GpuShaderCreatorRcPtr & shaderCreator,
250268

251269
st.newLine() << shaderCreator->getPixelName() << ".rgb = "
252270
<< shaderCreator->getPixelName() << ".rgb * contrast + offset;";
271+
272+
// clang-format on
253273
}
254274

255275
void AddECLogarithmicRevShader(GpuShaderCreatorRcPtr & shaderCreator,
@@ -259,6 +279,8 @@ void AddECLogarithmicRevShader(GpuShaderCreatorRcPtr & shaderCreator,
259279
const std::string & contrastName,
260280
const std::string & gammaName)
261281
{
282+
// clang-format off
283+
262284
double pivot = std::max(EC::MIN_PIVOT, ec->getPivot());
263285
float logPivot = (float)std::max(0., std::log2(pivot / 0.18) *
264286
ec->getLogExposureStep() +
@@ -273,6 +295,8 @@ void AddECLogarithmicRevShader(GpuShaderCreatorRcPtr & shaderCreator,
273295

274296
st.newLine() << shaderCreator->getPixelName() << ".rgb = "
275297
<< shaderCreator->getPixelName() << ".rgb / contrast + offset;";
298+
299+
// clang-format on
276300
}
277301

278302

@@ -288,6 +312,8 @@ void GetExposureContrastGPUShaderProgram(GpuShaderCreatorRcPtr & shaderCreator,
288312
GpuShaderText st(shaderCreator->getLanguage());
289313
st.indent();
290314

315+
// clang-format off
316+
291317
st.newLine() << "";
292318
st.newLine() << "// Add ExposureContrast '"
293319
<< ExposureContrastOpData::ConvertStyleToString(ec->getStyle())
@@ -296,6 +322,8 @@ void GetExposureContrastGPUShaderProgram(GpuShaderCreatorRcPtr & shaderCreator,
296322
st.newLine() << "{";
297323
st.indent();
298324

325+
// clang-format on
326+
299327
AddProperties(shaderCreator, st, ec,
300328
exposureName,
301329
contrastName,

0 commit comments

Comments
 (0)