| 32 | } |
| 33 | |
| 34 | void 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 | |
| 80 | int main(int argc, const char ** argv) |
| 81 | { |
no test coverage detected