TuttleOFX
1
|
00001 #include <terry/geometry/pinning.hpp> 00002 00003 #include <tuttle/plugin/ofxToGil/rect.hpp> 00004 #include <tuttle/plugin/exceptions.hpp> 00005 00006 #include <terry/globals.hpp> 00007 #include <terry/sampler/all.hpp> 00008 #include <terry/sampler/resample_progress.hpp> 00009 00010 namespace tuttle { 00011 namespace plugin { 00012 namespace pinning { 00013 00014 template<class View> 00015 PinningProcess<View>::PinningProcess( PinningPlugin& effect ) 00016 : ImageGilFilterProcessor<View>( effect, eImageOrientationIndependant ) 00017 , _plugin( effect ) 00018 { 00019 } 00020 00021 template<class View> 00022 void PinningProcess<View>::setup( const OFX::RenderArguments& args ) 00023 { 00024 ImageGilFilterProcessor<View>::setup( args ); 00025 00026 _params = _plugin.getProcessParams( args.time, args.renderScale ); 00027 } 00028 00029 /** 00030 * @brief Function called by rendering thread each time a process must be done. 00031 * @param[in] procWindowRoW Processing window 00032 */ 00033 template<class View> 00034 void PinningProcess<View>::multiThreadProcessImages( const OfxRectI& procWindowRoW ) 00035 { 00036 using namespace terry; 00037 using namespace terry::sampler; 00038 00039 const terry::Rect<std::ssize_t> procWindowOutput = ofxToGil( this->translateRoWToOutputClipCoordinates( procWindowRoW ) ); 00040 00041 switch( _params._samplerProcessParams._filter ) 00042 { 00043 case eParamFilterNearest: 00044 { 00045 resample< ::terry::sampler::nearest_neighbor_sampler >( this->_srcView, this->_dstView, procWindowOutput ); 00046 return; 00047 } 00048 case eParamFilterBilinear: 00049 { 00050 resample< ::terry::sampler::bilinear_sampler >( this->_srcView, this->_dstView, procWindowOutput ); 00051 return; 00052 } 00053 case eParamFilterBC: 00054 { 00055 bc_sampler BCsampler ( _params._samplerProcessParams._paramB, _params._samplerProcessParams._paramC ); 00056 resample( this->_srcView, this->_dstView, procWindowOutput, BCsampler ); 00057 return; 00058 } 00059 case eParamFilterBicubic: 00060 { 00061 resample<bicubic_sampler>( this->_srcView, this->_dstView, procWindowOutput ); 00062 return; 00063 } 00064 case eParamFilterCatrom: 00065 { 00066 resample<catrom_sampler>( this->_srcView, this->_dstView, procWindowOutput ); 00067 return; 00068 } 00069 case eParamFilterMitchell: 00070 { 00071 resample<mitchell_sampler>( this->_srcView, this->_dstView, procWindowOutput ); 00072 return; 00073 } 00074 case eParamFilterParzen: 00075 { 00076 resample<parzen_sampler>( this->_srcView, this->_dstView, procWindowOutput ); 00077 return; 00078 } 00079 case eParamFilterKeys: 00080 { 00081 resample<keys_sampler>( this->_srcView, this->_dstView, procWindowOutput ); 00082 return; 00083 } 00084 case eParamFilterSimon: 00085 { 00086 resample<simon_sampler>( this->_srcView, this->_dstView, procWindowOutput ); 00087 return; 00088 } 00089 case eParamFilterRifman: 00090 { 00091 resample<rifman_sampler>( this->_srcView, this->_dstView, procWindowOutput ); 00092 return; 00093 } 00094 case eParamFilterLanczos: 00095 { 00096 lanczos_sampler lanczosSampler ( _params._samplerProcessParams._filterSize, _params._samplerProcessParams._filterSharpen ); 00097 resample( this->_srcView, this->_dstView, procWindowOutput, lanczosSampler ); 00098 return; 00099 } 00100 case eParamFilterLanczos3: 00101 { 00102 resample<lanczos3_sampler>( this->_srcView, this->_dstView, procWindowOutput ); 00103 return; 00104 } 00105 case eParamFilterLanczos4: 00106 { 00107 resample<lanczos4_sampler>( this->_srcView, this->_dstView, procWindowOutput ); 00108 return; 00109 } 00110 case eParamFilterLanczos6: 00111 { 00112 resample<lanczos6_sampler>( this->_srcView, this->_dstView, procWindowOutput ); 00113 return; 00114 } 00115 case eParamFilterLanczos12: 00116 { 00117 resample<lanczos12_sampler>( this->_srcView, this->_dstView, procWindowOutput ); 00118 return; 00119 } 00120 case eParamFilterGaussian: 00121 { 00122 gaussian_sampler gaussianSampler ( _params._samplerProcessParams._filterSize, _params._samplerProcessParams._filterSigma ); 00123 resample<gaussian_sampler>( this->_srcView, this->_dstView, procWindowOutput ); 00124 return; 00125 } 00126 } 00127 BOOST_THROW_EXCEPTION( exception::Bug() 00128 << exception::user( "Interpolation method not recognize." ) ); 00129 } 00130 00131 template<class View> 00132 template<class Sampler> 00133 void PinningProcess<View>::resample( View& srcView, View& dstView, const terry::Rect<std::ssize_t>& procWindow, const Sampler& sampler ) 00134 { 00135 using namespace boost::gil; 00136 switch( _params._method ) 00137 { 00138 case eParamMethodAffine: 00139 case eParamMethodPerspective: 00140 terry::sampler::resample_pixels_progress<Sampler>( srcView, dstView, _params._perspective, procWindow, _params._samplerProcessParams._outOfImageProcess, this->getOfxProgress(), sampler ); 00141 return; 00142 case eParamMethodBilinear: 00143 terry::sampler::resample_pixels_progress<Sampler>( srcView, dstView, _params._bilinear , procWindow, _params._samplerProcessParams._outOfImageProcess, this->getOfxProgress(), sampler ); 00144 return; 00145 } 00146 } 00147 00148 } 00149 } 00150 } 00151