TuttleOFX  1
ResizePluginFactory.cpp
Go to the documentation of this file.
00001 #include "ResizePluginFactory.hpp"
00002 #include "ResizePlugin.hpp"
00003 #include "ResizeDefinitions.hpp"
00004 
00005 #include <tuttle/plugin/context/SamplerPluginFactory.hpp>
00006 
00007 #include <limits>
00008 
00009 
00010 namespace tuttle {
00011 namespace plugin {
00012 namespace resize {
00013 
00014 static const bool kSupportTiles = false;
00015 
00016 
00017 /**
00018  * @brief Function called to describe the plugin main features.
00019  * @param[in, out] desc Effect descriptor
00020  */
00021 void ResizePluginFactory::describe( OFX::ImageEffectDescriptor& desc )
00022 {
00023         desc.setLabels( "TuttleResize", "Resize", "Resize" );
00024         desc.setPluginGrouping( "tuttle/image/process/geometry" );
00025 
00026         // add the supported contexts, only filter at the moment
00027         desc.addSupportedContext( OFX::eContextFilter );
00028         desc.addSupportedContext( OFX::eContextGeneral );
00029 
00030         // add supported pixel depths
00031         desc.addSupportedBitDepth( OFX::eBitDepthUByte );
00032         desc.addSupportedBitDepth( OFX::eBitDepthUShort );
00033         desc.addSupportedBitDepth( OFX::eBitDepthFloat );
00034 
00035         // plugin flags
00036         desc.setSupportsTiles( kSupportTiles );
00037         desc.setRenderThreadSafety( OFX::eRenderFullySafe );
00038 }
00039 
00040 /**
00041  * @brief Function called to describe the plugin controls and features.
00042  * @param[in, out]   desc       Effect descriptor
00043  * @param[in]        context    Application context
00044  */
00045 void ResizePluginFactory::describeInContext( OFX::ImageEffectDescriptor& desc, OFX::EContext context )
00046 {
00047         OFX::ClipDescriptor* srcClip = desc.defineClip( kOfxImageEffectSimpleSourceClipName );
00048         srcClip->addSupportedComponent( OFX::ePixelComponentRGBA );
00049         srcClip->addSupportedComponent( OFX::ePixelComponentRGB );
00050         srcClip->addSupportedComponent( OFX::ePixelComponentAlpha );
00051         srcClip->setSupportsTiles( kSupportTiles );
00052 
00053         // Create the mandated output clip
00054         OFX::ClipDescriptor* dstClip = desc.defineClip( kOfxImageEffectOutputClipName );
00055         dstClip->addSupportedComponent( OFX::ePixelComponentRGBA );
00056         dstClip->addSupportedComponent( OFX::ePixelComponentRGB );
00057         dstClip->addSupportedComponent( OFX::ePixelComponentAlpha );
00058         dstClip->setSupportsTiles( kSupportTiles );
00059 
00060         OFX::ChoiceParamDescriptor* method = desc.defineChoiceParam( kParamMode );
00061         method->setLabel( "Mode" );
00062         method->appendOption( kParamModeFormat );
00063         method->appendOption( kParamModeSize );
00064         method->appendOption( kParamModeScale );
00065         method->setDefault( eParamModeFormat );
00066 
00067         OFX::ChoiceParamDescriptor* format = desc.defineChoiceParam( kParamFormat );
00068         format->setLabel( "Format" );
00069         format->appendOption( kParamFormatPCVideo, kParamFormatPCVideoLabel );
00070         format->appendOption( kParamFormatNTSC, kParamFormatNTSCLabel );
00071         format->appendOption( kParamFormatPAL, kParamFormatPALLabel );
00072         format->appendOption( kParamFormatHD, kParamFormatHDLabel );
00073         format->appendOption( kParamFormatNTSC169, kParamFormatNTSC169Label );
00074         format->appendOption( kParamFormatPAL169, kParamFormatPAL169Label );
00075         format->appendOption( kParamFormat1kSuper35, kParamFormat1kSuper35Label );
00076         format->appendOption( kParamFormat1kCinemascope, kParamFormat1kCinemascopeLabel );
00077         format->appendOption( kParamFormat2kSuper35, kParamFormat2kSuper35Label );
00078         format->appendOption( kParamFormat2kCinemascope, kParamFormat2kCinemascopeLabel );
00079         format->appendOption( kParamFormat4kSuper35, kParamFormat4kSuper35Label );
00080         format->appendOption( kParamFormat4kCinemascope, kParamFormat4kCinemascopeLabel );
00081         format->appendOption( kParamFormatSquare256, kParamFormatSquare256Label );
00082         format->appendOption( kParamFormatSquare512, kParamFormatSquare512Label );
00083         format->appendOption( kParamFormatSquare1k, kParamFormatSquare1kLabel );
00084         format->appendOption( kParamFormatSquare2k, kParamFormatSquare2kLabel );
00085         format->setDefault( eParamFormat2kCinemascope );
00086 
00087         OFX::Double2DParamDescriptor* scale = desc.defineDouble2DParam( kParamScale );
00088         scale->setLabel( "Scale" );
00089         scale->setDefault( 1.0, 1.0 );
00090         scale->setRange( 0.01, 0.01, std::numeric_limits<double>::max(), std::numeric_limits<double>::max() );
00091         scale->setDisplayRange( 0.1, 0.1, 2.5, 2.5 );
00092         scale->setHint( "Scale the input image [0, 0, width*scale, height*scale]." );
00093 
00094         OFX::BooleanParamDescriptor* keepRatio = desc.defineBooleanParam( kParamSizeKeepRatio );
00095         keepRatio->setLabel( "Keep ratio" );
00096         keepRatio->setDefault( false );
00097         keepRatio->setHint( "Keep input image ratio." );
00098 
00099         OFX::Int2DParamDescriptor* size = desc.defineInt2DParam( kParamSize );
00100         size->setLabel( "Size" );
00101         size->setDefault( 200, 200 );
00102         size->setRange( 1, 1, std::numeric_limits<int>::max(), std::numeric_limits<int>::max() );
00103         size->setHint( "Set the output size (width, height)." );
00104 
00105         OFX::ChoiceParamDescriptor* direction = desc.defineChoiceParam( kParamSizeOrientation );
00106         direction->setLabel( "Orientation" );
00107         direction->appendOption( kParamSizeOrientationX );
00108         direction->appendOption( kParamSizeOrientationY );
00109         direction->setDefault( eParamSizeOrientationX );
00110 
00111         OFX::IntParamDescriptor* width = desc.defineIntParam( kParamSizeWidth );
00112         width->setLabel( "Width" );
00113         width->setDefault( 200 );
00114         width->setRange( 1, std::numeric_limits<int>::max() );
00115         width->setDisplayRange( 0, 3000 );
00116         width->setHint( "Set the width in pixels and keep the input image ratio." );
00117 
00118         OFX::IntParamDescriptor* height = desc.defineIntParam( kParamSizeHeight );
00119         height->setLabel( "Height" );
00120         height->setDefault( 200 );
00121         height->setRange( 1, std::numeric_limits<int>::max() );
00122         height->setDisplayRange( 0, 3000 );
00123         height->setHint( "Set the height in pixels and keep the input image ratio." );
00124 
00125 #ifndef TUTTLE_PRODUCTION
00126         OFX::BooleanParamDescriptor* center = desc.defineBooleanParam( kParamCenter );
00127         center->setLabel( "Center resizing" );
00128         center->setDefault( false );
00129         center->setHint( "Resize around the center point." );
00130 
00131         OFX::Double2DParamDescriptor* centerPoint = desc.defineDouble2DParam( kParamCenterPoint );
00132         centerPoint->setDefault( 100, 100 );
00133         centerPoint->setLabel( "Center point at" );
00134         centerPoint->setHint( "Position of the center point." );
00135 #endif
00136 
00137         // sampler parameters //
00138         describeSamplerParamsInContext( desc, context );
00139 }
00140 
00141 /**
00142  * @brief Function called to create a plugin effect instance
00143  * @param[in] handle  Effect handle
00144  * @param[in] context Application context
00145  * @return  plugin instance
00146  */
00147 OFX::ImageEffect* ResizePluginFactory::createInstance( OfxImageEffectHandle handle,
00148                                                             OFX::EContext context )
00149 {
00150         return new ResizePlugin( handle );
00151 }
00152 
00153 }
00154 }
00155 }
00156