TuttleOFX  1
AVReaderProcess.tcc
Go to the documentation of this file.
00001 #include "AVReaderPlugin.hpp"
00002 
00003 #include <boost/numeric/conversion/cast.hpp>
00004 
00005 namespace tuttle {
00006 namespace plugin {
00007 namespace av {
00008 namespace reader {
00009 
00010 template<class View>
00011 AVReaderProcess<View>::AVReaderProcess( AVReaderPlugin& instance )
00012         : ImageGilProcessor<View>( instance, eImageOrientationFromTopToBottom )
00013         , _plugin( instance )
00014 {
00015         this->setNoMultiThreading();
00016 }
00017 
00018 template<class View>
00019 void AVReaderProcess<View>::setup( const OFX::RenderArguments& args )
00020 {
00021         if( !_plugin.ensureVideoIsOpen() )
00022                 BOOST_THROW_EXCEPTION( exception::Failed()
00023                     << exception::user( "Can't open this video file" )
00024                     << exception::filename( _plugin._paramFilepath->getValue() ) );
00025 
00026         // Fetch output image
00027         if( !_plugin._reader.read( boost::numeric_cast<int>( args.time ) ) )
00028                 BOOST_THROW_EXCEPTION( exception::Failed()
00029                     << exception::user() + "Can't open the frame at time " + args.time
00030                     << exception::filename( _plugin._paramFilepath->getValue() ) );
00031 
00032         ImageGilProcessor<View>::setup( args );
00033 }
00034 
00035 /**
00036  * @brief Function called by rendering thread each time a process must be done.
00037  * @param[in] procWindowRoW  Processing window in RoW
00038  */
00039 template<class View>
00040 void AVReaderProcess<View>::multiThreadProcessImages( const OfxRectI& procWindowRoW )
00041 {
00042         using namespace boost::gil;
00043         BOOST_ASSERT( procWindowRoW == this->_dstPixelRod );
00044 
00045         rgb8c_view_t avSrcView =
00046             interleaved_view( _plugin._reader.width(), _plugin._reader.height(),
00047                               (const rgb8c_pixel_t*)( _plugin._reader.data() ),
00048                               _plugin._reader.width() * 3 );
00049 
00050         copy_and_convert_pixels( avSrcView, this->_dstView );
00051 }
00052 
00053 }
00054 }
00055 }
00056 }