예제 #1
0
void OCIOColorSpace::_validate(bool for_real)
{
    input0().validate(for_real);

    if(!m_hasColorSpaces)
    {
        error("No colorspaces available for input and/or output.");
        return;
    }

    int inputColorSpaceCount = static_cast<int>(m_inputColorSpaceCstrNames.size()) - 1;
    if(m_inputColorSpaceIndex < 0 || m_inputColorSpaceIndex >= inputColorSpaceCount)
    {
        std::ostringstream err;
        err << "Input colorspace index (" << m_inputColorSpaceIndex << ") out of range.";
        error(err.str().c_str());
        return;
    }

    int outputColorSpaceCount = static_cast<int>(m_outputColorSpaceCstrNames.size()) - 1;
    if(m_outputColorSpaceIndex < 0 || m_outputColorSpaceIndex >= outputColorSpaceCount)
    {
        std::ostringstream err;
        err << "Output colorspace index (" << m_outputColorSpaceIndex << ") out of range.";
        error(err.str().c_str());
        return;
    }

    try
    {
        const char * inputName = m_inputColorSpaceCstrNames[m_inputColorSpaceIndex];
        const char * outputName = m_outputColorSpaceCstrNames[m_outputColorSpaceIndex];
        
        OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
        config->sanityCheck();
        
        OCIO::ConstContextRcPtr context = getLocalContext();
        m_processor = config->getProcessor(context, inputName, outputName);
    }
    catch(OCIO::Exception &e)
    {
        error(e.what());
        return;
    }
    
    if(m_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);
}
예제 #2
0
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);
}
예제 #3
0
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);
}
예제 #4
0
void OCIOCDLTransform::_validate(bool for_real)
{
    input0().validate(for_real);
    
    try
    {
        OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
        config->sanityCheck();

        OCIO::CDLTransformRcPtr cc = OCIO::CDLTransform::Create();
        cc->setSlope(m_slope);
        cc->setOffset(m_offset);
        cc->setPower(m_power);
        cc->setSat(m_saturation);

        if(m_dirindex == 0) cc->setDirection(OCIO::TRANSFORM_DIR_FORWARD);
        else cc->setDirection(OCIO::TRANSFORM_DIR_INVERSE);

        m_processor = config->getProcessor(cc);
    }
    catch(OCIO::Exception &e)
    {
        error(e.what());
        return;
    }
    
    if(m_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);
}
예제 #5
0
void OCIOLogConvert::_validate(bool for_real)
{
    try
    {
        OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
        
        const char * src = 0;
        const char * dst = 0;
        
        if(modeindex == 0)
        {
            src = OCIO::ROLE_COMPOSITING_LOG;
            dst = OCIO::ROLE_SCENE_LINEAR;
        }
        else
        {
            src = OCIO::ROLE_SCENE_LINEAR;
            dst = OCIO::ROLE_COMPOSITING_LOG;
        }
        
        processor = config->getProcessor(src, dst);
    }
    catch(OCIO::Exception &e)
    {
        error(e.what());
        return;
    }
    
    if(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);
}
예제 #6
0
void OCIOLookTransform::_validate(bool for_real)
{
    if(!m_hasColorSpaces)
    {
        error("No colorspaces available for input and/or output.");
        return;
    }

    int inputColorSpaceCount = static_cast<int>(m_inputColorSpaceCstrNames.size()) - 1;
    if(m_inputColorSpaceIndex < 0 || m_inputColorSpaceIndex >= inputColorSpaceCount)
    {
        std::ostringstream err;
        err << "Input colorspace index (" << m_inputColorSpaceIndex << ") out of range.";
        error(err.str().c_str());
        return;
    }

    int outputColorSpaceCount = static_cast<int>(m_outputColorSpaceCstrNames.size()) - 1;
    if(m_outputColorSpaceIndex < 0 || m_outputColorSpaceIndex >= outputColorSpaceCount)
    {
        std::ostringstream err;
        err << "Output colorspace index (" << m_outputColorSpaceIndex << ") out of range.";
        error(err.str().c_str());
        return;
    }

    try
    {
        OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
        
        const char * inputName = config->getColorSpaceNameByIndex(m_inputColorSpaceIndex);
        const char * outputName = config->getColorSpaceNameByIndex(m_outputColorSpaceIndex);
        
        OCIO::LookTransformRcPtr transform = OCIO::LookTransform::Create();
        const char * look = m_lookCstrNames[m_lookIndex];
        if(look != NULL)
        {
            transform->setLooks(look);
        }
        
        OCIO::ConstContextRcPtr context = getLocalContext();
        OCIO::TransformDirection direction = OCIO::TRANSFORM_DIR_UNKNOWN;
        bool invertTransform = (m_dirIndex == 0) ? false : true;
        
        // Forward
        if(!invertTransform)
        {
            transform->setSrc(inputName);
            transform->setDst(outputName);
            direction = OCIO::TRANSFORM_DIR_FORWARD;
        }
        else
        {
            // The TRANSFORM_DIR_INVERSE applies an inverse for the end-to-end transform,
            // which would otherwise do dst->inv look -> src.
            // This is an unintuitive result for the artist (who would expect in, out to
            // remain unchanged), so we account for that here by flipping src/dst
            
            transform->setSrc(outputName);
            transform->setDst(inputName);
            direction = OCIO::TRANSFORM_DIR_INVERSE;
        }
        
        try
        {
            m_processor = config->getProcessor(context, transform, direction);
        }
        // We only catch the exceptions for missing files, and try to succeed
        // in this case. All other errors represent more serious problems and
        // should fail through.
        catch(const OCIO::ExceptionMissingFile &e)
        {
            if(!m_ignoreErrors) throw;
            m_processor = config->getProcessor(context, inputName, outputName);
        }
    }
    catch(const OCIO::Exception &e)
    {
        error(e.what());
        return;
    }
    catch (...)
    {
        error("OCIOLookTransform: Unknown exception during _validate.");
        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);
}