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

Function CreateOutputLutFile

src/apps/ociomakeclf/main.cpp:34–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32}
33
34void CreateOutputLutFile(const std::string & outLutFilepath, OCIO::ConstGroupTransformRcPtr transform)
35{
36 // Get the processor.
37
38 // Get a basic config to create a processor.
39 OCIO::ConstConfigRcPtr config = OCIO::Config::CreateRaw();
40
41 OCIO::ConstProcessorRcPtr processor = config->getProcessor(transform);
42
43 // CLF file format does not support inverse 1D LUTs, optimize the processor
44 // to replace inverse 1D LUTs by 'fast forward' 1D LUTs.
45 OCIO::ConstProcessorRcPtr optProcessor
46 = processor->getOptimizedProcessor(OCIO::BIT_DEPTH_F32,
47 OCIO::BIT_DEPTH_F32,
48 OCIO::OPTIMIZATION_LUT_INV_FAST);
49
50 // Create the CLF file.
51
52 std::ofstream outfs(outLutFilepath, std::ios::out | std::ios::trunc);
53 if (outfs.good())
54 {
55 try
56 {
57 const auto group = optProcessor->createGroupTransform();
58 group->write(config, "Academy/ASC Common LUT Format", outfs);
59 }
60 catch (const OCIO::Exception &)
61 {
62 outfs.close();
63 remove(outLutFilepath.c_str());
64 throw;
65 }
66
67 outfs.close();
68 }
69 else
70 {
71 std::ostringstream oss;
72 oss << "Could not open the file '"
73 << outLutFilepath
74 << "'."
75 << std::endl;
76 throw OCIO::Exception(oss.str().c_str());
77 }
78}
79
80int main(int argc, const char ** argv)
81{

Callers 1

mainFunction · 0.85

Calls 5

getOptimizedProcessorMethod · 0.80
createGroupTransformMethod · 0.80
getProcessorMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected