TuttleOFX  1
BitDepthProcess.tcc
Go to the documentation of this file.
00001 #include "BitDepthPlugin.hpp"
00002 #include "BitDepthDefinitions.hpp"
00003 
00004 #include <terry/globals.hpp>
00005 #include <tuttle/plugin/exceptions.hpp>
00006 
00007 
00008 namespace tuttle {
00009 namespace plugin {
00010 namespace bitDepth {
00011 
00012 template<class SView, class DView>
00013 BitDepthProcess<SView, DView>::BitDepthProcess( BitDepthPlugin& instance )
00014         : ImageGilProcessor<DView>( instance, eImageOrientationIndependant )
00015         , _plugin( instance )
00016 {
00017         _clipSrc = _plugin.fetchClip( kOfxImageEffectSimpleSourceClipName );
00018 }
00019 
00020 template<class SView, class DView>
00021 void BitDepthProcess<SView, DView>::setup( const OFX::RenderArguments& args )
00022 {
00023         ImageGilProcessor<DView>::setup( args );
00024 
00025         // source view
00026         _src.reset( _clipSrc->fetchImage( args.time ) );
00027         if( ! _src.get() )
00028                 BOOST_THROW_EXCEPTION( exception::ImageNotReady() );
00029         if( _src->getRowDistanceBytes() == 0 )
00030                 BOOST_THROW_EXCEPTION( exception::WrongRowBytes() );
00031         _srcView = ImageGilProcessor<DView>::template getCustomView<SView>( _src.get(), _clipSrc->getPixelRod( args.time ) );
00032         
00033         if( OFX::getImageEffectHostDescription()->hostName == "uk.co.thefoundry.nuke" )
00034         {
00035                 // bug in nuke, getRegionOfDefinition() on OFX::Image returns bounds
00036                 _srcPixelRod   = _clipSrc->getPixelRod( args.time, args.renderScale );
00037         }
00038         else
00039         {
00040                 _srcPixelRod = _src->getRegionOfDefinition();
00041         }
00042 }
00043 
00044 /**
00045  * @brief Function called by rendering thread each time a process must be done.
00046  * @param[in] procWindowRoW  Processing window in RoW
00047  */
00048 template<class SView, class DView>
00049 void BitDepthProcess<SView, DView>::multiThreadProcessImages( const OfxRectI& procWindowRoW )
00050 {
00051         using namespace boost::gil;
00052         OfxRectI procWindowOutput = this->translateRoWToOutputClipCoordinates( procWindowRoW );
00053         OfxPointI procWindowSize  = {
00054                 procWindowRoW.x2 - procWindowRoW.x1,
00055                 procWindowRoW.y2 - procWindowRoW.y1
00056         };
00057 
00058         SView src = subimage_view( this->_srcView, procWindowOutput.x1, procWindowOutput.y1,
00059                                    procWindowSize.x,
00060                                    procWindowSize.y );
00061         DView dst = subimage_view( this->_dstView, procWindowOutput.x1, procWindowOutput.y1,
00062                                    procWindowSize.x,
00063                                    procWindowSize.y );
00064 
00065         copy_and_convert_pixels( src, dst );
00066 }
00067 
00068 }
00069 }
00070 }