TuttleOFX
1
|
00001 #include "OCIOLutPlugin.hpp" 00002 #include "OCIOLutProcess.hpp" 00003 00004 #include <tuttle/common/utils/color.hpp> 00005 00006 #include <boost/filesystem/operations.hpp> 00007 #include <boost/gil/gil_all.hpp> 00008 #include <boost/filesystem.hpp> 00009 00010 namespace bfs = boost::filesystem; 00011 00012 namespace tuttle { 00013 namespace plugin { 00014 namespace ocio { 00015 namespace lut { 00016 00017 using namespace boost::gil; 00018 00019 OCIOLutPlugin::OCIOLutPlugin(OfxImageEffectHandle handle) : 00020 ImageEffectGilPlugin(handle) 00021 { 00022 _paramFilename = fetchStringParam(kTuttlePluginFilename); 00023 _paramInterpolationType = fetchChoiceParam(kParamInterpolationType); 00024 00025 } 00026 00027 /** 00028 * @brief The overridden render function 00029 * @param[in] args Rendering parameters 00030 */ 00031 void OCIOLutPlugin::render(const OFX::RenderArguments& args) 00032 { 00033 using namespace boost::gil; 00034 // instantiate the render code based on the pixel depth of the dst clip 00035 OFX::EBitDepth bitDepth = _clipDst->getPixelDepth(); 00036 OFX::EPixelComponent components = _clipDst->getPixelComponents(); 00037 00038 // do the rendering 00039 switch (components) { 00040 case OFX::ePixelComponentRGBA: { 00041 switch (bitDepth) { 00042 case OFX::eBitDepthFloat: { 00043 doGilRender<OCIOLutProcess, false, rgba_layout_t, bits32f> (*this, 00044 args); 00045 return; 00046 } 00047 case OFX::eBitDepthUByte: 00048 case OFX::eBitDepthUShort: 00049 case OFX::eBitDepthCustom: 00050 case OFX::eBitDepthNone: { 00051 BOOST_THROW_EXCEPTION( exception::Unsupported() 00052 << exception::user() + "Bit depth (" + mapBitDepthEnumToString(bitDepth) + ") not recognized by the plugin." ); 00053 } 00054 } 00055 break; 00056 } 00057 case OFX::ePixelComponentRGB: { 00058 switch (bitDepth) { 00059 case OFX::eBitDepthFloat: { 00060 doGilRender<OCIOLutProcess, false, rgb_layout_t, bits32f> (*this, 00061 args); 00062 return; 00063 } 00064 case OFX::eBitDepthUByte: 00065 case OFX::eBitDepthUShort: 00066 case OFX::eBitDepthCustom: 00067 case OFX::eBitDepthNone: { 00068 BOOST_THROW_EXCEPTION( exception::Unsupported() 00069 << exception::user() + "Bit depth (" + mapBitDepthEnumToString(bitDepth) + ") not recognized by the plugin." ); 00070 } 00071 } 00072 break; 00073 } 00074 case OFX::ePixelComponentAlpha: //@todo support Alpha (mfe) 00075 case OFX::ePixelComponentCustom: 00076 case OFX::ePixelComponentNone: { 00077 BOOST_THROW_EXCEPTION( exception::Unsupported() 00078 << exception::user() + "Pixel components (" + mapPixelComponentEnumToString(components) + ") not supported by the plugin." ); 00079 } 00080 } 00081 BOOST_THROW_EXCEPTION( exception::Unknown() ); 00082 } 00083 00084 OCIOLutProcessParams OCIOLutPlugin::getProcessParams( const OfxPointD& renderScale) const 00085 { 00086 using namespace boost::filesystem; 00087 00088 OCIOLutProcessParams params; 00089 params._interpolationType = getOCIOInterpolationType( static_cast<EInterpolationType>( _paramInterpolationType->getValue() ) ); 00090 00091 params._filename = _paramFilename->getValue(); 00092 if (!bfs::exists( params._filename )) { 00093 BOOST_THROW_EXCEPTION( exception::FileNotExist( ) 00094 << exception::filename( params._filename ) ); 00095 } 00096 00097 return params; 00098 } 00099 00100 } 00101 } 00102 } 00103 }