TuttleOFX  1
TimeShiftPlugin.cpp
Go to the documentation of this file.
00001 #include "TimeShiftPlugin.hpp"
00002 #include "TimeShiftDefinitions.hpp"
00003 
00004 #include <boost/gil/gil_all.hpp>
00005 
00006 namespace tuttle {
00007 namespace plugin {
00008 namespace timeShift {
00009 
00010 TimeShiftPlugin::TimeShiftPlugin( OfxImageEffectHandle handle )
00011         : ImageEffectGilPlugin( handle )
00012 {
00013         switch( getContext() )
00014         {
00015                 case OFX::eContextRetimer:
00016                         // @todo tuttle: do something else...
00017                         _offset = fetchDoubleParam( kOfxImageEffectRetimerParamName );
00018                         break;
00019                 default:
00020                         _offset = fetchDoubleParam( kParamOffset );
00021                         break;
00022         }
00023 }
00024 
00025 TimeShiftProcessParams<TimeShiftPlugin::Scalar> TimeShiftPlugin::getProcessParams() const
00026 {
00027         TimeShiftProcessParams<TimeShiftPlugin::Scalar> params;
00028         params._offset = _offset->getValue();
00029         return params;
00030 }
00031 
00032 bool TimeShiftPlugin::getTimeDomain( OfxRangeD& range )
00033 {
00034         TimeShiftProcessParams<TimeShiftPlugin::Scalar> params = getProcessParams();
00035         if( params._offset == 0 )
00036                 return false;
00037         
00038         TUTTLE_TLOG( TUTTLE_INFO, "[Time Shift] TimeDomain--" );
00039         
00040         range = _clipSrc->getFrameRange();
00041         TUTTLE_TLOG_VAR2( TUTTLE_INFO, range.min, range.max );
00042         TUTTLE_TLOG_VAR( TUTTLE_INFO, params._offset );
00043         range.min += params._offset;
00044         range.max += params._offset;
00045         
00046         TUTTLE_TLOG_VAR2( TUTTLE_INFO, range.min, range.max );
00047         
00048         return true;
00049 }
00050 
00051 void TimeShiftPlugin::getFramesNeeded( const OFX::FramesNeededArguments &args, OFX::FramesNeededSetter &frames )
00052 {
00053         TimeShiftProcessParams<TimeShiftPlugin::Scalar> params = getProcessParams();
00054         const OfxTime inTime = args.time - params._offset;
00055         const OfxRangeD range = { inTime, inTime };
00056         frames.setFramesNeeded( *_clipSrc, range );
00057         
00058         TUTTLE_TLOG( TUTTLE_INFO, "[Time Shift] FrameNeeded--" );
00059         TUTTLE_TLOG_VAR( TUTTLE_INFO, args.time );
00060         TUTTLE_TLOG_VAR( TUTTLE_INFO, params._offset );
00061         TUTTLE_TLOG_VAR( TUTTLE_INFO, inTime );
00062 }
00063 
00064 bool TimeShiftPlugin::isIdentity( const OFX::RenderArguments& args, OFX::Clip*& identityClip, double& identityTime )
00065 {
00066         identityClip = _clipSrc;
00067 
00068         identityTime = args.time - _offset->getValue();
00069         
00070         TUTTLE_TLOG( TUTTLE_INFO, "[Time Shift] isIdentity--" );
00071         TUTTLE_TLOG_VAR( TUTTLE_INFO, args.time );
00072         TUTTLE_TLOG_VAR( TUTTLE_INFO, _offset->getValue() );
00073         TUTTLE_TLOG_VAR( TUTTLE_INFO, identityTime );
00074         
00075         return true;
00076 }
00077 
00078 /**
00079  * @brief The overridden render function
00080  * @param[in]   args     Rendering parameters
00081  */
00082 void TimeShiftPlugin::render( const OFX::RenderArguments& args )
00083 {
00084 }
00085 
00086 
00087 }
00088 }
00089 }