void OCIOFileTransform::_validate(bool for_real) { if(!m_file) { error("The source file must be specified."); return; } try { OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig(); OCIO::FileTransformRcPtr transform = OCIO::FileTransform::Create(); transform->setSrc(m_file); transform->setCCCId(m_cccid.c_str()); if(m_dirindex == 0) transform->setDirection(OCIO::TRANSFORM_DIR_FORWARD); else transform->setDirection(OCIO::TRANSFORM_DIR_INVERSE); if(m_interpindex == 0) transform->setInterpolation(OCIO::INTERP_NEAREST); else if(m_interpindex == 1) transform->setInterpolation(OCIO::INTERP_LINEAR); else if(m_interpindex == 2) transform->setInterpolation(OCIO::INTERP_TETRAHEDRAL); else if(m_interpindex == 3) transform->setInterpolation(OCIO::INTERP_BEST); else { // Should never happen error("Interpolation value out of bounds"); return; } m_processor = config->getProcessor(transform, OCIO::TRANSFORM_DIR_FORWARD); } catch(OCIO::Exception &e) { error(e.what()); return; } if(m_processor->isNoOp()) { set_out_channels(DD::Image::Mask_None); // prevents engine() from being called } else { set_out_channels(DD::Image::Mask_All); } DD::Image::PixelIop::_validate(for_real); }
void OCIOFileTransform::_validate(bool for_real) { input0().validate(for_real); if(!src) { error("The source file must be specified."); return; } try { OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig(); config->sanityCheck(); OCIO::FileTransformRcPtr transform = OCIO::FileTransform::Create(); transform->setSrc(src); // TODO: For some reason, cccid is NOT incorporated in this node's hash. // Until then, cccid is considered broken. Figure out why. transform->setCCCId(cccid.c_str()); if(dirindex == 0) transform->setDirection(OCIO::TRANSFORM_DIR_FORWARD); else transform->setDirection(OCIO::TRANSFORM_DIR_INVERSE); if(interpindex == 0) transform->setInterpolation(OCIO::INTERP_NEAREST); else transform->setInterpolation(OCIO::INTERP_LINEAR); processor = config->getProcessor(transform, OCIO::TRANSFORM_DIR_FORWARD); } catch(OCIO::Exception &e) { error(e.what()); return; } if(processor->isNoOp()) { // TODO or call disable() ? set_out_channels(DD::Image::Mask_None); // prevents engine() from being called copy_info(); return; } set_out_channels(DD::Image::Mask_All); DD::Image::PixelIop::_validate(for_real); }
OCIO_ADD_GPU_TEST(Lut1DOp, lut1d_3_big_inverse_generic_shader) { OCIO::FileTransformRcPtr file = GetFileTransform("lut1d_3.spi1d"); file->setDirection(OCIO::TRANSFORM_DIR_INVERSE); OCIO::GpuShaderDescRcPtr shaderDesc = OCIO::GpuShaderDesc::CreateShaderDesc(); test.setContext(file->createEditableCopy(), shaderDesc); test.setErrorThreshold(1e-4f); }
OCIO_ADD_GPU_TEST(Lut1DOp, lut1d_2_inverse_legacy_shader) { OCIO::FileTransformRcPtr file = GetFileTransform("lut1d_2.spi1d"); file->setDirection(OCIO::TRANSFORM_DIR_INVERSE); OCIO::GpuShaderDescRcPtr shaderDesc = OCIO::GpuShaderDesc::CreateLegacyShaderDesc(2*LUT3D_EDGE_SIZE); test.setContext(file->createEditableCopy(), shaderDesc); test.setErrorThreshold(5e-4f); }
OCIO_ADD_GPU_TEST(Lut1DOp, lut1d_1_small_inverse_legacy_shader) { OCIO::FileTransformRcPtr file = GetFileTransform("lut1d_1.spi1d"); file->setDirection(OCIO::TRANSFORM_DIR_INVERSE); OCIO::GpuShaderDescRcPtr shaderDesc = OCIO::GpuShaderDesc::CreateLegacyShaderDesc(2*LUT3D_EDGE_SIZE); test.setContext(file->createEditableCopy(), shaderDesc); // TODO: Investigate why the test needs such a threshold test.setErrorThreshold(1e-2f); }
OCIO::GroupTransformRcPtr parse_luts(int argc, const char *argv[]) { OCIO::GroupTransformRcPtr groupTransform = OCIO::GroupTransform::Create(); const char *lastCCCId = NULL; // Ugly to use this but using GroupTransform::getTransform() // returns a const object so we must set this // prior to using --lut for now. for(int i=0; i<argc; ++i) { std::string arg(argv[i]); if(arg == "--lut" || arg == "-lut") { if(i+1>=argc) { throw OCIO::Exception("Error parsing --lut. Invalid num args"); } OCIO::FileTransformRcPtr t = OCIO::FileTransform::Create(); t->setSrc(argv[i+1]); t->setInterpolation(OCIO::INTERP_BEST); if (lastCCCId) { t->setCCCId(lastCCCId); } groupTransform->push_back(t); i += 1; } else if(arg == "--cccid" || arg == "-cccid") { if(i+1>=argc) { throw OCIO::Exception("Error parsing --cccid. Invalid num args"); } lastCCCId = argv[i+1]; i += 1; } else if(arg == "--invlut" || arg == "-invlut") { if(i+1>=argc) { throw OCIO::Exception("Error parsing --invlut. Invalid num args"); } OCIO::FileTransformRcPtr t = OCIO::FileTransform::Create(); t->setSrc(argv[i+1]); t->setInterpolation(OCIO::INTERP_BEST); t->setDirection(OCIO::TRANSFORM_DIR_INVERSE); groupTransform->push_back(t); i += 1; } else if(arg == "--slope" || arg == "-slope") { if(i+3>=argc) { throw OCIO::Exception("Error parsing --slope. Invalid num args"); } OCIO::CDLTransformRcPtr t = OCIO::CDLTransform::Create(); float scale[3]; scale[0] = (float) atof(argv[i+1]); scale[1] = (float) atof(argv[i+2]); scale[2] = (float) atof(argv[i+3]); t->setSlope(scale); groupTransform->push_back(t); i += 3; } else if(arg == "--offset" || arg == "-offset") { if(i+3>=argc) { throw OCIO::Exception("Error parsing --offset. Invalid num args"); } OCIO::CDLTransformRcPtr t = OCIO::CDLTransform::Create(); float offset[3]; offset[0] = (float) atof(argv[i+1]); offset[1] = (float) atof(argv[i+2]); offset[2] = (float) atof(argv[i+3]); t->setOffset(offset); groupTransform->push_back(t); i += 3; } else if(arg == "--offset10" || arg == "-offset10") { if(i+3>=argc) { throw OCIO::Exception("Error parsing --offset10. Invalid num args"); } OCIO::CDLTransformRcPtr t = OCIO::CDLTransform::Create(); float offset[3]; offset[0] = (float) atof(argv[i+1]) / 1023.0f; offset[1] = (float) atof(argv[i+2]) / 1023.0f; offset[2] = (float) atof(argv[i+3]) / 1023.0f; t->setOffset(offset); groupTransform->push_back(t); i += 3; } else if(arg == "--power" || arg == "-power") { if(i+3>=argc) { throw OCIO::Exception("Error parsing --power. Invalid num args"); } OCIO::CDLTransformRcPtr t = OCIO::CDLTransform::Create(); float power[3]; power[0] = (float) atof(argv[i+1]); power[1] = (float) atof(argv[i+2]); power[2] = (float) atof(argv[i+3]); t->setPower(power); groupTransform->push_back(t); i += 3; } else if(arg == "--sat" || arg == "-sat") { if(i+1>=argc) { throw OCIO::Exception("Error parsing --sat. Invalid num args"); } OCIO::CDLTransformRcPtr t = OCIO::CDLTransform::Create(); t->setSat((float) atof(argv[i+1])); groupTransform->push_back(t); i += 1; } } return groupTransform; }