MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenColorIO / initialize

Method initialize

src/OpenColorIO/ops/lut3d/Lut3DOpCPU.cpp:1306–1388  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1304}
1305
1306void InvLut3DRenderer::RangeTree::initialize(float *grvec, unsigned long gsz)
1307{
1308 m_chans = 3; // only supporting Lut3D for now
1309 m_gsz[0] = m_gsz[1] = m_gsz[2] = gsz;
1310 m_gsz[3] = 0;
1311
1312 // Determine depth of tree.
1313 float maxGsz = 0.f;
1314 for (unsigned long i = 0; i<m_chans; i++)
1315 {
1316 maxGsz = std::max(maxGsz, (float)m_gsz[i]);
1317 }
1318 int log2base;
1319 frexp(maxGsz - 2.f, &log2base);
1320 m_depth = (unsigned long)log2base;
1321
1322 m_levels.resize(m_depth);
1323
1324 // Determine size of each level.
1325 for (unsigned long i = 0; i < m_depth; i++)
1326 {
1327 unsigned long levelSize = 1;
1328 for (unsigned long j = 0; j < m_chans; j++)
1329 {
1330 unsigned long g = m_gsz[j] - 2;
1331 unsigned long m = g >> (((int)m_depth) - 1 - i);
1332 levelSize *= (m + 1);
1333 }
1334 m_levels[i].elems = levelSize;
1335 m_levels[i].chans = m_chans;
1336 }
1337
1338 // Determine scale to use for hash.
1339 m_levelScales.resize(m_depth);
1340 for (unsigned long level = 0; level < m_depth; level++)
1341 {
1342 const unsigned long depthm1 = m_depth - 1;
1343 const unsigned long shift = (m_chans + 1) * (depthm1 - level);
1344 const unsigned long scale = 1 << shift;
1345 m_levelScales[level] = scale;
1346 }
1347
1348 // Initialize indices into 3d-LUT.
1349 initInds();
1350
1351 // Calculate hash for indices.
1352
1353 const unsigned long cnt = static_cast<unsigned long>(m_baseInds.size());
1354 for (unsigned long i = 0; i < cnt; i++)
1355 {
1356 indsToHash(i);
1357 }
1358
1359 // Sort indices based on hash.
1360 std::sort(m_baseInds.begin(), m_baseInds.end());
1361
1362 // Copy sorted hashes into temp vector.
1363 ulongVector hashes(cnt);

Callers 1

updateDataMethod · 0.45

Calls 4

resizeMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected