TuttleOFX
1
|
00001 #include "ColorTransferPlugin.hpp" 00002 #include "ColorTransferProcess.hpp" 00003 #include "ColorTransferDefinitions.hpp" 00004 00005 #include <boost/gil/gil_all.hpp> 00006 #include <terry/numeric/operations.hpp> 00007 #include <terry/numeric/assign.hpp> 00008 00009 namespace tuttle { 00010 namespace plugin { 00011 namespace colorTransfer { 00012 00013 00014 ColorTransferPlugin::ColorTransferPlugin( OfxImageEffectHandle handle ) 00015 : ImageEffectGilPlugin( handle ) 00016 { 00017 _clipSrcRef = this->fetchClip( kClipSrcRef ); 00018 _clipDstRef = this->fetchClip( kClipDstRef ); 00019 00020 _paramColospace = this->fetchChoiceParam( kParamColorspace ); 00021 _paramAverageCoef = this->fetchDoubleParam( kParamAverageCoef ); 00022 _paramDynamicCoef = this->fetchDoubleParam( kParamDynamicCoef ); 00023 00024 // _paramRegionA = this->fetchDouble2DParam( kParamRegionA ); 00025 // _paramRegionB = this->fetchDouble2DParam( kParamRegionB ); 00026 // _paramSameRegion = this->fetchBooleanParam( kParamSameRegion ); 00027 // _paramInputRegionA = this->fetchDouble2DParam( kParamInputRegionA ); 00028 // _paramInputRegionB = this->fetchDouble2DParam( kParamInputRegionB ); 00029 // const OFX::InstanceChangedArgs args( this->timeLineGetTime() ); 00030 // changedParam( args, kParamSameRegion ); 00031 } 00032 00033 ColorTransferProcessParams<ColorTransferPlugin::Scalar> ColorTransferPlugin::getProcessParams( const OfxPointD& renderScale ) const 00034 { 00035 ColorTransferProcessParams<Scalar> params; 00036 params._colorspace = static_cast<EColorspace>( _paramColospace->getValue() ); 00037 params._averageCoef = _paramAverageCoef->getValue(); 00038 params._dynamicCoef = _paramDynamicCoef->getValue(); 00039 return params; 00040 } 00041 00042 void ColorTransferPlugin::changedParam( const OFX::InstanceChangedArgs &args, const std::string ¶mName ) 00043 { 00044 // if( paramName == kParamSameRegion ) 00045 // { 00046 // const bool status = _paramSameRegion->getValue(); 00047 // _paramInputRegionA->setIsSecretAndDisabled( status ); 00048 // _paramInputRegionB->setIsSecretAndDisabled( status ); 00049 // } 00050 } 00051 00052 void ColorTransferPlugin::getRegionsOfInterest( const OFX::RegionsOfInterestArguments& args, OFX::RegionOfInterestSetter& rois ) 00053 { 00054 if( _clipSrcRef->isConnected() ) 00055 { 00056 OfxRectD srcRod = args.regionOfInterest; 00057 rois.setRegionOfInterest( *this->_clipSrc, srcRod ); 00058 } 00059 else 00060 { 00061 OfxRectD srcRod = _clipSrc->getCanonicalRod( args.time ); 00062 rois.setRegionOfInterest( *this->_clipSrc, srcRod ); 00063 } 00064 00065 OfxRectD srcRefRod = _clipSrcRef->getCanonicalRod( args.time ); 00066 rois.setRegionOfInterest( *_clipSrcRef, srcRefRod ); 00067 00068 OfxRectD dstRefRod = _clipDstRef->getCanonicalRod( args.time ); 00069 rois.setRegionOfInterest( *_clipDstRef, dstRefRod ); 00070 } 00071 00072 /** 00073 * @brief The overridden render function 00074 * @param[in] args Rendering parameters 00075 */ 00076 void ColorTransferPlugin::render( const OFX::RenderArguments &args ) 00077 { 00078 // doGilRender<ColorTransferProcess>( *this, args ); 00079 00080 // instantiate the render code based on the pixel depth of the dst clip 00081 OFX::EBitDepth bitDepth = _clipDst->getPixelDepth(); 00082 OFX::EPixelComponent components = _clipDst->getPixelComponents(); 00083 00084 switch( components ) 00085 { 00086 case OFX::ePixelComponentRGBA: 00087 { 00088 doGilRender<ColorTransferProcess, false, boost::gil::rgba_layout_t>( *this, args, bitDepth ); 00089 return; 00090 } 00091 case OFX::ePixelComponentRGB: 00092 { 00093 doGilRender<ColorTransferProcess, false, boost::gil::rgb_layout_t>( *this, args, bitDepth ); 00094 return; 00095 } 00096 case OFX::ePixelComponentAlpha: 00097 case OFX::ePixelComponentCustom: 00098 case OFX::ePixelComponentNone: 00099 { 00100 BOOST_THROW_EXCEPTION( exception::Unsupported() 00101 << exception::user() + "Pixel components (" + mapPixelComponentEnumToString(components) + ") not supported by the plugin." ); 00102 } 00103 } 00104 BOOST_THROW_EXCEPTION( exception::Unknown() ); 00105 } 00106 00107 00108 } 00109 } 00110 }