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

Method read

src/OpenColorIO/fileformats/FileFormatHDL.cpp:307–588  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

305}
306
307CachedFileRcPtr
308LocalFileFormat::read(std::istream & istream,
309 const std::string & /* fileName unused */,
310 Interpolation interp) const
311{
312
313 // this shouldn't happen
314 if (!istream)
315 throw Exception ("file stream empty when trying to read Houdini LUT");
316
317 //
318 CachedFileHDLRcPtr cachedFile = CachedFileHDLRcPtr (new CachedFileHDL ());
319
320 Lut3DOpDataRcPtr lut3d_ptr;
321
322 // Parse headers into key-value pairs
323 StringToStringVecMap header_chunks;
324 StringToStringVecMap::iterator iter;
325
326 // Read headers, ending after the "LUT:" line
327 readHeaders(header_chunks, istream);
328
329 // Grab useful values from headers
330 StringUtils::StringVec value;
331
332 // "Version 3" - format version (currently one version
333 // number per LUT type)
334 value = findHeaderItem(header_chunks, "version", 1);
335 cachedFile->hdlversion = value[0];
336
337 // "Format any" - bit depth of image the LUT should be
338 // applied to (this is basically ignored)
339 value = findHeaderItem(header_chunks, "format", 1);
340 cachedFile->hdlformat = value[0];
341
342 // "Type 3d" - type of LUT
343 {
344 value = findHeaderItem(header_chunks, "type", 1);
345
346 cachedFile->hdltype = value[0];
347 }
348
349 // "From 0.0 1.0" - range of input values
350 {
351 float from_min = 0.0f;
352 float from_max = 1.0f;
353 value = findHeaderItem(header_chunks, "from", 2);
354
355 if(!StringToFloat(&from_min, value[0].c_str()) ||
356 !StringToFloat(&from_max, value[1].c_str()))
357 {
358 std::ostringstream os;
359 os << "Invalid float value(s) on 'From' line, '";
360 os << value[0] << "' and '" << value[1] << "'";
361 throw Exception(os.str().c_str());
362 }
363 cachedFile->from_min = from_min;
364 cachedFile->from_max = from_max;

Callers

nothing calls this directly

Calls 12

readHeadersFunction · 0.85
findHeaderItemFunction · 0.85
readLutsFunction · 0.85
setLUT1DMethod · 0.80
StringToFloatFunction · 0.50
StringToIntFunction · 0.50
sizeMethod · 0.45
push_backMethod · 0.45
setInterpolationMethod · 0.45
setFileOutputBitDepthMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected