TuttleOFX
1
|
00001 #include "ReaderPlugin.hpp" 00002 00003 namespace tuttle { 00004 namespace plugin { 00005 00006 namespace bfs = boost::filesystem; 00007 00008 ReaderPlugin::ReaderPlugin( OfxImageEffectHandle handle ) 00009 : OFX::ImageEffect( handle ) 00010 { 00011 _clipDst = fetchClip( kOfxImageEffectOutputClipName ); 00012 _paramFilepath = fetchStringParam( kTuttlePluginFilename ); 00013 _isSequence = _filePattern.initFromDetection( _paramFilepath->getValue() ); 00014 _paramBitDepth = fetchChoiceParam( kTuttlePluginBitDepth ); 00015 _paramChannel = fetchChoiceParam( kTuttlePluginChannel ); 00016 } 00017 00018 ReaderPlugin::~ReaderPlugin() 00019 {} 00020 00021 void ReaderPlugin::changedParam( const OFX::InstanceChangedArgs& args, const std::string& paramName ) 00022 { 00023 if( paramName == kTuttlePluginFilename ) 00024 { 00025 _isSequence = _filePattern.initFromDetection( _paramFilepath->getValue() ); 00026 } 00027 } 00028 00029 void ReaderPlugin::getClipPreferences( OFX::ClipPreferencesSetter& clipPreferences ) 00030 { 00031 // If pattern detected (frame varying on time) 00032 clipPreferences.setOutputFrameVarying( varyOnTime() ); 00033 00034 switch( getExplicitBitDepthConversion() ) 00035 { 00036 case eParamReaderBitDepthByte: 00037 { 00038 clipPreferences.setClipBitDepth( *this->_clipDst, OFX::eBitDepthUByte ); 00039 break; 00040 } 00041 case eParamReaderBitDepthShort: 00042 { 00043 clipPreferences.setClipBitDepth( *this->_clipDst, OFX::eBitDepthUShort ); 00044 break; 00045 } 00046 case eParamReaderBitDepthAuto: 00047 case eParamReaderBitDepthFloat: 00048 { 00049 clipPreferences.setClipBitDepth( *this->_clipDst, OFX::eBitDepthFloat ); 00050 break; 00051 } 00052 } 00053 switch( getExplicitChannelConversion() ) 00054 { 00055 case eParamReaderChannelGray: 00056 { 00057 clipPreferences.setClipComponents( *this->_clipDst, OFX::ePixelComponentAlpha ); 00058 break; 00059 } 00060 case eParamReaderChannelRGB: 00061 { 00062 if( OFX::getImageEffectHostDescription()->supportsPixelComponent( OFX::ePixelComponentRGB ) ) 00063 clipPreferences.setClipComponents( *this->_clipDst, OFX::ePixelComponentRGB ); 00064 else 00065 clipPreferences.setClipComponents( *this->_clipDst, OFX::ePixelComponentRGBA ); 00066 break; 00067 } 00068 case eParamReaderChannelAuto: 00069 case eParamReaderChannelRGBA: 00070 { 00071 clipPreferences.setClipComponents( *this->_clipDst, OFX::ePixelComponentRGBA ); 00072 break; 00073 } 00074 } 00075 00076 clipPreferences.setPixelAspectRatio( *this->_clipDst, 1.0 ); 00077 } 00078 00079 bool ReaderPlugin::getTimeDomain( OfxRangeD& range ) 00080 { 00081 range.min = getFirstTime(); 00082 range.max = getLastTime(); 00083 TUTTLE_TLOG( TUTTLE_INFO, "[Reader plugin] Time Domain : " << range.min << " to " << range.max ); 00084 return true; 00085 } 00086 00087 void ReaderPlugin::render( const OFX::RenderArguments& args ) 00088 { 00089 std::string filename = getAbsoluteFilenameAt( args.time ); 00090 TUTTLE_LOG_INFO( " >-- " << filename ); 00091 } 00092 00093 } 00094 }