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

Method read

src/OpenColorIO/fileformats/FileFormatCSP.cpp:361–699  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

359}
360
361CachedFileRcPtr LocalFileFormat::read(std::istream & istream,
362 const std::string & fileName,
363 Interpolation interp) const
364{
365 Lut1DOpDataRcPtr lut1d_ptr;
366 Lut3DOpDataRcPtr lut3d_ptr;
367
368 // Try and read the LUT header.
369 std::string line;
370 bool notEmpty = nextline (istream, line);
371
372 if (!notEmpty)
373 {
374 std::ostringstream os;
375 os << "File " << fileName;
376 os << ": file stream empty when trying to read csp LUT.";
377 throw Exception(os.str().c_str());
378 }
379
380 if (!startswithU(line, "CSPLUTV100"))
381 {
382 std::ostringstream os;
383 os << "File " << fileName << " doesn't seem to be a csp LUT, ";
384 os << "expected 'CSPLUTV100'. First line: '" << line << "'.";
385 throw Exception(os.str().c_str());
386 }
387
388 // Next line tells us if we are reading a 1D or 3D LUT.
389 nextline (istream, line);
390 if (!startswithU(line, "1D") && !startswithU(line, "3D"))
391 {
392 std::ostringstream os;
393 os << "Unsupported CSP LUT type. Require 1D or 3D. ";
394 os << "Found, '" << line << "' in " << fileName << ".";
395 throw Exception(os.str().c_str());
396 }
397 std::string csptype = line;
398
399 // Read meta data block.
400 std::string metadata;
401 bool lineUpdateNeeded = false;
402 nextline (istream, line);
403 if(startswithU(line, "BEGIN METADATA"))
404 {
405 while (!startswithU(line, "END METADATA") ||
406 !istream)
407 {
408 nextline (istream, line);
409 if (!startswithU(line, "END METADATA"))
410 metadata += line + "\n";
411 }
412 lineUpdateNeeded = true;
413 } // Else line update not needed.
414
415 // Make 3 vectors of prelut inputs + output values.
416 std::vector<float> prelut_in[3];
417 std::vector<float> prelut_out[3];
418 bool useprelut[3] = { false, false, false };

Callers

nothing calls this directly

Calls 15

nextlineFunction · 0.85
startswithUFunction · 0.85
SplitByWhiteSpacesFunction · 0.85
VecsEqualWithRelErrorFunction · 0.85
StringVecToIntVecFunction · 0.85
GetLut3DIndex_BlueFastFunction · 0.85
lerpfFunction · 0.85

Tested by

no test coverage detected