TuttleOFX
1
|
00001 #include "TurboJpegWriterPluginFactory.hpp" 00002 #include "TurboJpegWriterPlugin.hpp" 00003 #include "TurboJpegWriterDefinitions.hpp" 00004 00005 #include <tuttle/plugin/context/WriterPluginFactory.hpp> 00006 00007 #include <boost/algorithm/string/join.hpp> 00008 #include <boost/assign/std/vector.hpp> 00009 00010 #include <string> 00011 #include <vector> 00012 00013 namespace tuttle { 00014 namespace plugin { 00015 namespace turboJpeg { 00016 namespace writer { 00017 00018 static const bool kSupportTiles = false; 00019 00020 00021 /** 00022 * @brief Function called to describe the plugin main features. 00023 * @param[in, out] desc Effect descriptor 00024 */ 00025 void TurboJpegWriterPluginFactory::describe( OFX::ImageEffectDescriptor& desc ) 00026 { 00027 desc.setLabels( 00028 "TuttleTurboJpegWriter", 00029 "TurboJpegWriter", 00030 "Turbo Jpeg file writer" ); 00031 desc.setPluginGrouping( "tuttle/image/io" ); 00032 00033 using namespace boost::assign; 00034 std::vector<std::string> supportedExtensions; 00035 supportedExtensions += "jpeg", "jpg", "jpe", "jfif", "jfi"; 00036 00037 desc.setDescription( "Turbo Jpeg File writer\n" 00038 "Plugin is used to write jpeg files.\n\n" 00039 "supported extensions: \n" + 00040 boost::algorithm::join( supportedExtensions, ", " ) 00041 ); 00042 00043 // add the supported contexts 00044 desc.addSupportedContext( OFX::eContextWriter ); 00045 desc.addSupportedContext( OFX::eContextGeneral ); 00046 00047 // add supported pixel depths 00048 desc.addSupportedBitDepth( OFX::eBitDepthUByte ); 00049 desc.addSupportedBitDepth( OFX::eBitDepthUShort ); 00050 desc.addSupportedBitDepth( OFX::eBitDepthFloat ); 00051 00052 // plugin flags 00053 desc.setRenderThreadSafety( OFX::eRenderFullySafe ); 00054 desc.setHostFrameThreading( false ); 00055 desc.setSupportsMultiResolution( false ); 00056 desc.setSupportsMultipleClipDepths( true ); 00057 desc.setSupportsTiles( kSupportTiles ); 00058 } 00059 00060 /** 00061 * @brief Function called to describe the plugin controls and features. 00062 * @param[in, out] desc Effect descriptor 00063 * @param[in] context Application context 00064 */ 00065 void TurboJpegWriterPluginFactory::describeInContext( OFX::ImageEffectDescriptor& desc, 00066 OFX::EContext context ) 00067 { 00068 OFX::ClipDescriptor* srcClip = desc.defineClip( kOfxImageEffectSimpleSourceClipName ); 00069 srcClip->addSupportedComponent( OFX::ePixelComponentRGBA ); 00070 srcClip->addSupportedComponent( OFX::ePixelComponentRGB ); 00071 srcClip->addSupportedComponent( OFX::ePixelComponentAlpha ); 00072 srcClip->setSupportsTiles( kSupportTiles ); 00073 00074 // Create the mandated output clip 00075 OFX::ClipDescriptor* dstClip = desc.defineClip( kOfxImageEffectOutputClipName ); 00076 dstClip->addSupportedComponent( OFX::ePixelComponentRGBA ); 00077 dstClip->addSupportedComponent( OFX::ePixelComponentRGB ); 00078 dstClip->addSupportedComponent( OFX::ePixelComponentAlpha ); 00079 dstClip->setSupportsTiles( kSupportTiles ); 00080 00081 // Controls 00082 describeWriterParamsInContext( desc, context ); 00083 00084 OFX::ChoiceParamDescriptor* channel = static_cast<OFX::ChoiceParamDescriptor*>( desc.getParamDescriptor( kTuttlePluginChannel ) ); 00085 channel->resetOptions(); 00086 channel->appendOption( kTuttlePluginChannelRGB ); 00087 channel->setDefault( 0 ); 00088 channel->setEnabled( false ); 00089 00090 OFX::ChoiceParamDescriptor* bitDepth = static_cast<OFX::ChoiceParamDescriptor*>( desc.getParamDescriptor( kTuttlePluginBitDepth ) ); 00091 bitDepth->resetOptions(); 00092 bitDepth->appendOption( kTuttlePluginBitDepth8 ); 00093 bitDepth->setDefault( eTuttlePluginBitDepth8 ); 00094 bitDepth->setEnabled( false ); 00095 00096 OFX::BooleanParamDescriptor* premult = static_cast<OFX::BooleanParamDescriptor*>( desc.getParamDescriptor( kParamPremultiplied ) ); 00097 premult->setDefault( true ); 00098 00099 OFX::IntParamDescriptor* quality = desc.defineIntParam( kParamQuality ); 00100 quality->setLabel( "Quality" ); 00101 quality->setRange( 0, 100 ); 00102 quality->setDisplayRange( 0, 100 ); 00103 quality->setDefault( 80 ); 00104 00105 00106 OFX::ChoiceParamDescriptor* subsampling = desc.defineChoiceParam( kParamSubsampling ); 00107 subsampling->setLabel( kParamSubsamplingLabel ); 00108 subsampling->setHint( kParamSubsamplingHint ); 00109 subsampling->appendOption( kTurboJpegSubsampling444 ); 00110 subsampling->appendOption( kTurboJpegSubsampling422 ); 00111 subsampling->appendOption( kTurboJpegSubsampling420 ); 00112 subsampling->appendOption( kTurboJpegSubsamplingGray ); 00113 subsampling->appendOption( kTurboJpegSubsampling440 ); 00114 subsampling->setDefault( eTurboJpegSubsampling420 ); 00115 00116 OFX::ChoiceParamDescriptor* optimization = desc.defineChoiceParam( kParamOptimization ); 00117 optimization->setLabel( kParamOptimizationLabel ); 00118 optimization->setHint( kParamOptimizationHint ); 00119 optimization->appendOption( kTurboJpegOptimizationNone ); 00120 optimization->appendOption( kTurboJpegOptimizationMMX ); 00121 optimization->appendOption( kTurboJpegOptimizationSSE ); 00122 optimization->appendOption( kTurboJpegOptimizationSSE2 ); 00123 optimization->appendOption( kTurboJpegOptimizationSSE3 ); 00124 optimization->setDefault( eTurboJpegOptimizationSSE3 ); 00125 } 00126 00127 /** 00128 * @brief Function called to create a plugin effect instance 00129 * @param[in] handle Effect handle 00130 * @param[in] context Application context 00131 * @return plugin instance 00132 */ 00133 OFX::ImageEffect* TurboJpegWriterPluginFactory::createInstance( OfxImageEffectHandle handle, 00134 OFX::EContext context ) 00135 { 00136 return new TurboJpegWriterPlugin( handle ); 00137 } 00138 00139 } 00140 } 00141 } 00142 }