TuttleOFX  1
InputBufferPluginFactory.cpp
Go to the documentation of this file.
00001 #include "InputBufferPluginFactory.hpp"
00002 #include "InputBufferPlugin.hpp"
00003 #include "InputBufferDefinitions.hpp"
00004 #include "ofxsImageEffect.h"
00005 
00006 #include <limits>
00007 
00008 namespace tuttle {
00009 namespace plugin {
00010 namespace inputBuffer {
00011 
00012 static const bool kSupportTiles = false;
00013 
00014 
00015 /**
00016  * @brief Function called to describe the plugin main features.
00017  * @param[in, out] desc Effect descriptor
00018  */
00019 void InputBufferPluginFactory::describe( OFX::ImageEffectDescriptor& desc )
00020 {
00021         desc.setLabels(
00022                 "TuttleInputBuffer",
00023                 "InputBuffer",
00024                 "InputBuffer" );
00025         desc.setPluginGrouping( "tuttle/image/io" );
00026 
00027         desc.setDescription(
00028                 "This is a DANGEROUS plugin dedicated to developers.\n"
00029                 "\n"
00030                 "WARNING: If you put a wrong value, you will crash your application.\n"
00031                 "\n"
00032                 "It allows to introduce an image buffer inside the graph." );
00033 
00034         // add the supported contexts, only filter at the moment
00035         desc.addSupportedContext( OFX::eContextFilter );
00036         desc.addSupportedContext( OFX::eContextGeneral );
00037 
00038         // add supported pixel depths
00039         desc.addSupportedBitDepth( OFX::eBitDepthUByte );
00040         desc.addSupportedBitDepth( OFX::eBitDepthUShort );
00041         desc.addSupportedBitDepth( OFX::eBitDepthFloat );
00042 
00043         // plugin flags
00044         desc.setSupportsTiles( kSupportTiles );
00045         desc.setRenderThreadSafety( OFX::eRenderFullySafe );
00046         desc.setSupportsMultipleClipDepths( true );
00047         desc.setSupportsMultiResolution( false );
00048         desc.setSupportsTiles( false );
00049 }
00050 
00051 /**
00052  * @brief Function called to describe the plugin controls and features.
00053  * @param[in, out]   desc       Effect descriptor
00054  * @param[in]        context    Application context
00055  */
00056 void InputBufferPluginFactory::describeInContext( OFX::ImageEffectDescriptor& desc,
00057                                                   OFX::EContext context )
00058 {
00059         // Create the mandated output clip
00060         OFX::ClipDescriptor* dstClip = desc.defineClip( kOfxImageEffectOutputClipName );
00061         dstClip->addSupportedComponent( OFX::ePixelComponentRGBA );
00062         dstClip->addSupportedComponent( OFX::ePixelComponentRGB );
00063         dstClip->addSupportedComponent( OFX::ePixelComponentAlpha );
00064         dstClip->setSupportsTiles( kSupportTiles );
00065         
00066         OFX::ChoiceParamDescriptor* inputMode = desc.defineChoiceParam( kParamInputMode );
00067         inputMode->setLabel( "Mode" );
00068         inputMode->appendOption( kParamInputModeBufferPointer );
00069         inputMode->appendOption( kParamInputModeCallbackPointer );
00070         inputMode->setDefault( 0 );
00071         inputMode->setAnimates( false );
00072         
00073         OFX::StringParamDescriptor* inputBuffer = desc.defineStringParam( kParamInputBufferPointer );
00074         inputBuffer->setLabel( "Input Buffer Pointer" );
00075         inputBuffer->setHint(
00076                 "This parameter represent a pointer to a memory allocated image buffer.\n"
00077                 "WARNING:\n"
00078                 " - Your application will crash if you set an invalid value here.\n"
00079                 " - If you want to animate this parameter to put different image buffer, be careful to disable interpolation.\n"
00080                 );
00081         inputBuffer->setCacheInvalidation( OFX::eCacheInvalidateValueAll );
00082         // This is a pointer to a dynamic memory allocation, so there no sense to store this value!
00083         // Need to be setted at each load.
00084         inputBuffer->setIsPersistant( false );
00085         inputBuffer->setDefault( "" );
00086         
00087         OFX::StringParamDescriptor* callbackPointer = desc.defineStringParam( kParamInputCallbackPointer );
00088         callbackPointer->setLabel( "Callback Pointer" );
00089         callbackPointer->setHint(
00090                 "This parameter represent a pointer to a function of type \"void*(*)(int time, void* inputCustomData)\" .\n"
00091                 "WARNING:\n"
00092                 " - Your application will crash if you set an invalid value here.\n"
00093                 );
00094         callbackPointer->setCacheInvalidation( OFX::eCacheInvalidateValueAll );
00095         callbackPointer->setIsPersistant( false );
00096         callbackPointer->setAnimates( false );
00097         callbackPointer->setDefault( "" );
00098         
00099         OFX::StringParamDescriptor* customData = desc.defineStringParam( kParamInputCustomData );
00100         customData->setLabel( "Callback Custom Data Pointer" );
00101         customData->setHint(
00102                 "This parameter represent a pointer to a custom data which is given to the callback function.\n"
00103                 "WARNING:\n"
00104                 " - Your application could crash if you set an invalid value here.\n"
00105                 );
00106         customData->setCacheInvalidation( OFX::eCacheInvalidateValueAll );
00107         customData->setIsPersistant( false );
00108         customData->setAnimates( false );
00109         customData->setDefault( "" );
00110         
00111         
00112         OFX::Int2DParamDescriptor* imgSize = desc.defineInt2DParam( kParamSize );
00113         imgSize->setLabel( "Image Size" );
00114         imgSize->setCacheInvalidation( OFX::eCacheInvalidateValueAll );
00115         imgSize->setDefault( 0, 0 );
00116         
00117         OFX::IntParamDescriptor* rowBytesSize = desc.defineIntParam( kParamRowBytesSize );
00118         rowBytesSize->setLabel( "Row Bytes Size" );
00119         rowBytesSize->setHint( "Put 0 if there is no padding between lines." );
00120         rowBytesSize->setCacheInvalidation( OFX::eCacheInvalidateValueAll );
00121         rowBytesSize->setDefault( 0 );
00122         
00123         OFX::DoubleParamDescriptor* par = desc.defineDoubleParam( kParamPixelAspectRatio );
00124         par->setLabel( "Pixel Aspect Ratio" );
00125         par->setCacheInvalidation( OFX::eCacheInvalidateValueAll );
00126         par->setAnimates( false );
00127         par->setDefault( 1.0 );
00128         
00129         OFX::DoubleParamDescriptor* framerate = desc.defineDoubleParam( kParamFramerate );
00130         framerate->setLabel( "Framerate" );
00131         framerate->setCacheInvalidation( OFX::eCacheInvalidateValueAll );
00132         framerate->setAnimates( false );
00133         framerate->setDefault( 25.0 );
00134         
00135 //      OFX::ImageEffectHostDescription* hostDesc = OFX::getImageEffectHostDescription();
00136         
00137         OFX::ChoiceParamDescriptor* components = desc.defineChoiceParam( kParamPixelComponents );
00138         components->setLabel( "Pixel Components" );
00139         components->setCacheInvalidation( OFX::eCacheInvalidateValueAll );
00140 //      if( hostDesc->supportsPixelComponent( OFX::ePixelComponentAlpha ) )
00141                 components->appendOption( kParamPixelComponentsAlpha  );
00142 //      if( hostDesc->supportsPixelComponent( OFX::ePixelComponentRGB ) )
00143                 components->appendOption( kParamPixelComponentsRGB );
00144 //      if( hostDesc->supportsPixelComponent( OFX::ePixelComponentRGBA ) )
00145                 components->appendOption( kParamPixelComponentsRGBA );
00146         components->setDefault( eParamPixelComponentRGBA );
00147         
00148         
00149         OFX::ChoiceParamDescriptor* bitDepth = desc.defineChoiceParam( kParamBitDepth );
00150         bitDepth->setLabel( "Bit Depth" );
00151         bitDepth->setCacheInvalidation( OFX::eCacheInvalidateValueAll );
00152 //      if( hostDesc->supportsBitDepth( OFX::eBitDepthUByte ) )
00153                 bitDepth->appendOption( kParamBitDepthUByte  );
00154 //      if( hostDesc->supportsBitDepth( OFX::eBitDepthUShort ) )
00155                 bitDepth->appendOption( kParamBitDepthUShort );
00156 //      if( hostDesc->supportsBitDepth( OFX::eBitDepthFloat ) )
00157                 bitDepth->appendOption( kParamBitDepthFloat );
00158         bitDepth->setDefault( eParamBitDepthFloat );
00159         
00160         OFX::ChoiceParamDescriptor* field = desc.defineChoiceParam( kParamField );
00161         field->setLabel( "Field" );
00162         field->setCacheInvalidation( OFX::eCacheInvalidateValueAll );
00163         field->appendOption( kParamFieldNone );
00164         field->appendOption( kParamFieldBoth );
00165         field->appendOption( kParamFieldLower );
00166         field->appendOption( kParamFieldUpper );
00167         field->setDefault( eParamFieldNone );
00168         
00169         OFX::ChoiceParamDescriptor* orientation = desc.defineChoiceParam( kParamOrientation );
00170         orientation->setLabel( "Orientation" );
00171         orientation->setHint( "Orientation in memory of the image buffer." );
00172         orientation->setCacheInvalidation( OFX::eCacheInvalidateValueAll );
00173         orientation->appendOption( kParamOrientationFromBottomToTop );
00174         orientation->appendOption( kParamOrientationFromTopToBottom );
00175         orientation->setDefault( eParamOrientationFromBottomToTop );
00176         
00177         OFX::Double2DParamDescriptor* timeDomain = desc.defineDouble2DParam( kParamTimeDomain );
00178         timeDomain->setLabel( "Time Domain" );
00179         timeDomain->setCacheInvalidation( OFX::eCacheInvalidateValueAll );
00180         timeDomain->setDefault( kOfxFlagInfiniteMin, kOfxFlagInfiniteMax );
00181         timeDomain->setAnimates( false );
00182         
00183         OFX::StringParamDescriptor* callbackDestroyCustomData = desc.defineStringParam( kParamInputCallbackDestroyCustomData );
00184         callbackDestroyCustomData->setLabel( "Callback Destroy Custom Data" );
00185         callbackDestroyCustomData->setHint(
00186                 "This parameter represents a pointer to a function.\n"
00187                 "WARNING:\n"
00188                 " - Your application could crash if you set an invalid value here.\n"
00189                 );
00190         callbackDestroyCustomData->setCacheInvalidation( OFX::eCacheInvalidateValueAll );
00191         callbackDestroyCustomData->setIsPersistant( false );
00192         callbackDestroyCustomData->setAnimates( false );
00193         callbackDestroyCustomData->setDefault( "" );
00194 }
00195 
00196 /**
00197  * @brief Function called to create a plugin effect instance
00198  * @param[in] handle  Effect handle
00199  * @param[in] context Application context
00200  * @return  plugin instance
00201  */
00202 OFX::ImageEffect* InputBufferPluginFactory::createInstance( OfxImageEffectHandle handle,
00203                                                             OFX::EContext context )
00204 {
00205         return new InputBufferPlugin( handle );
00206 }
00207 
00208 }
00209 }
00210 }
00211