TuttleOFX  1
SwscalePluginFactory.cpp
Go to the documentation of this file.
00001 #include "SwscalePluginFactory.hpp"
00002 #include "SwscalePlugin.hpp"
00003 #include "SwscaleDefinitions.hpp"
00004 
00005 #include <tuttle/plugin/context/SamplerPluginFactory.hpp>
00006 
00007 #include <limits>
00008 
00009 
00010 namespace tuttle {
00011 namespace plugin {
00012 namespace swscale {
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 SwscalePluginFactory::describe( OFX::ImageEffectDescriptor& desc )
00022 {
00023         desc.setLabels( "TuttleSwscale", "Swscale", "Swscale" );
00024         desc.setPluginGrouping( "tuttle/image/process/geometry" );
00025         
00026         desc.setDescription( "SwScale: fast resizing plugin\n"
00027                                 "Plugin using swscale library from LibAV.\n"
00028                                 "Warning: Could not run with floating point images and\n"
00029                                 "                       RGBA data different of 8 bit (32bpp).\n"
00030         );
00031 
00032         // add the supported contexts, only filter at the moment
00033         desc.addSupportedContext( OFX::eContextFilter );
00034         desc.addSupportedContext( OFX::eContextGeneral );
00035 
00036         // add supported pixel depths
00037         desc.addSupportedBitDepth( OFX::eBitDepthUByte );
00038         desc.addSupportedBitDepth( OFX::eBitDepthUShort );
00039         //desc.addSupportedBitDepth( OFX::eBitDepthFloat );
00040 
00041         // plugin flags
00042         desc.setSupportsTiles( kSupportTiles );
00043         desc.setRenderThreadSafety( OFX::eRenderFullySafe );
00044 }
00045 
00046 /**
00047  * @brief Function called to describe the plugin controls and features.
00048  * @param[in, out]   desc       Effect descriptor
00049  * @param[in]        context    Application context
00050  */
00051 void SwscalePluginFactory::describeInContext( OFX::ImageEffectDescriptor& desc, OFX::EContext context )
00052 {
00053         OFX::ClipDescriptor* srcClip = desc.defineClip( kOfxImageEffectSimpleSourceClipName );
00054         srcClip->addSupportedComponent( OFX::ePixelComponentRGBA );
00055         srcClip->addSupportedComponent( OFX::ePixelComponentRGB );
00056         srcClip->addSupportedComponent( OFX::ePixelComponentAlpha );
00057         srcClip->setSupportsTiles( kSupportTiles );
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* method = desc.defineChoiceParam( kParamMode );
00067         method->setLabel( "Mode" );
00068         method->appendOption( kParamModeFormat );
00069         method->appendOption( kParamModeSize );
00070         method->appendOption( kParamModeScale );
00071         method->setDefault( eParamModeFormat );
00072 
00073         OFX::ChoiceParamDescriptor* format = desc.defineChoiceParam( kParamFormat );
00074         format->setLabel( "Format" );
00075         format->appendOption( kParamFormatPCVideo, kParamFormatPCVideoLabel );
00076         format->appendOption( kParamFormatNTSC, kParamFormatNTSCLabel );
00077         format->appendOption( kParamFormatPAL, kParamFormatPALLabel );
00078         format->appendOption( kParamFormatHD, kParamFormatHDLabel );
00079         format->appendOption( kParamFormatNTSC169, kParamFormatNTSC169Label );
00080         format->appendOption( kParamFormatPAL169, kParamFormatPAL169Label );
00081         format->appendOption( kParamFormat1kSuper35, kParamFormat1kSuper35Label );
00082         format->appendOption( kParamFormat1kCinemascope, kParamFormat1kCinemascopeLabel );
00083         format->appendOption( kParamFormat2kSuper35, kParamFormat2kSuper35Label );
00084         format->appendOption( kParamFormat2kCinemascope, kParamFormat2kCinemascopeLabel );
00085         format->appendOption( kParamFormat4kSuper35, kParamFormat4kSuper35Label );
00086         format->appendOption( kParamFormat4kCinemascope, kParamFormat4kCinemascopeLabel );
00087         format->appendOption( kParamFormatSquare256, kParamFormatSquare256Label );
00088         format->appendOption( kParamFormatSquare512, kParamFormatSquare512Label );
00089         format->appendOption( kParamFormatSquare1k, kParamFormatSquare1kLabel );
00090         format->appendOption( kParamFormatSquare2k, kParamFormatSquare2kLabel );
00091         format->setDefault( eParamFormat2kCinemascope );
00092 
00093         OFX::Double2DParamDescriptor* scale = desc.defineDouble2DParam( kParamScale );
00094         scale->setLabel( "Scale" );
00095         scale->setDefault( 1.0, 1.0 );
00096         scale->setRange( 0.01, 0.01, std::numeric_limits<double>::max(), std::numeric_limits<double>::max() );
00097         scale->setDisplayRange( 0.1, 0.1, 2.5, 2.5 );
00098         scale->setHint( "Scale the input image [0, 0, width*scale, height*scale]." );
00099 
00100         OFX::BooleanParamDescriptor* keepRatio = desc.defineBooleanParam( kParamSizeKeepRatio );
00101         keepRatio->setLabel( "Keep ratio" );
00102         keepRatio->setDefault( false );
00103         keepRatio->setHint( "Keep input image ratio." );
00104 
00105         OFX::Int2DParamDescriptor* size = desc.defineInt2DParam( kParamSize );
00106         size->setLabel( "Size" );
00107         size->setDefault( 200, 200 );
00108         size->setRange( 1, 1, std::numeric_limits<int>::max(), std::numeric_limits<int>::max() );
00109         size->setHint( "Set the output size (width, height)." );
00110 
00111         OFX::ChoiceParamDescriptor* direction = desc.defineChoiceParam( kParamSizeOrientation );
00112         direction->setLabel( "Orientation" );
00113         direction->appendOption( kParamSizeOrientationX );
00114         direction->appendOption( kParamSizeOrientationY );
00115         direction->setDefault( eParamSizeOrientationX );
00116 
00117         OFX::IntParamDescriptor* width = desc.defineIntParam( kParamSizeWidth );
00118         width->setLabel( "Width" );
00119         width->setDefault( 200 );
00120         width->setRange( 1, std::numeric_limits<int>::max() );
00121         width->setDisplayRange( 0, 3000 );
00122         width->setHint( "Set the width in pixels and keep the input image ratio." );
00123 
00124         OFX::IntParamDescriptor* height = desc.defineIntParam( kParamSizeHeight );
00125         height->setLabel( "Height" );
00126         height->setDefault( 200 );
00127         height->setRange( 1, std::numeric_limits<int>::max() );
00128         height->setDisplayRange( 0, 3000 );
00129         height->setHint( "Set the height in pixels and keep the input image ratio." );
00130 
00131         // sampler parameters //
00132         OFX::ChoiceParamDescriptor* filter = desc.defineChoiceParam( kParamFilter );
00133         filter->setLabel( "Filter" );
00134         filter->appendOption( kParamFilterFastBilinear );
00135         filter->appendOption( kParamFilterBilinear );
00136         filter->appendOption( kParamFilterBicubic );
00137         filter->appendOption( kParamFilterX );
00138         filter->appendOption( kParamFilterPoint );
00139         filter->appendOption( kParamFilterArea );
00140         filter->appendOption( kParamFilterBicublin );
00141         filter->appendOption( kParamFilterGauss );
00142         filter->appendOption( kParamFilterSinc );
00143         filter->appendOption( kParamFilterLanczos );
00144         filter->appendOption( kParamFilterSpline );
00145         filter->setDefault( eParamFilterBicubic );
00146 }
00147 
00148 /**
00149  * @brief Function called to create a plugin effect instance
00150  * @param[in] handle  Effect handle
00151  * @param[in] context Application context
00152  * @return  plugin instance
00153  */
00154 OFX::ImageEffect* SwscalePluginFactory::createInstance( OfxImageEffectHandle handle,
00155                                                                                                                 OFX::EContext context )
00156 {
00157         return new SwscalePlugin( handle );
00158 }
00159 
00160 }
00161 }
00162 }
00163