void addPlugin( OfxhPlugin* plugin ) { // Check if the same plugin has already been loaded if( _loadedMap.find( plugin->getIdentity() ) == _loadedMap.end() ) { _loadedMap[plugin->getIdentity()] = true; } else { TUTTLE_LOG_WARNING( "Plugin: " << plugin->getRawIdentifier() << " loaded twice! (" << plugin->getBinary().getFilePath() << ")" ); } _plugins.push_back( plugin ); if( _pluginsByID.find( plugin->getIdentifier() ) != _pluginsByID.end() ) { OfxhPlugin& otherPlugin = *_pluginsByID[plugin->getIdentifier()]; if( plugin->trumps( otherPlugin ) ) { _pluginsByID[plugin->getIdentifier()] = plugin; } } else { _pluginsByID[plugin->getIdentifier()] = plugin; } }
void addPlugin( OfxhPlugin* plugin ) { // Check if the same plugin has already been loaded if( _loadedMap.find( plugin->getIdentity() ) == _loadedMap.end() ) { _loadedMap[plugin->getIdentity()] = true; } else { std::string message = "Warning! Plugin: "; message += plugin->getRawIdentifier(); message += " loaded twice!"; message += " ("; message += plugin->getBinary().getFilePath(); message += ")"; TUTTLE_LOG_WARNING( message ); } _plugins.push_back( plugin ); if( _pluginsByID.find( plugin->getIdentifier() ) != _pluginsByID.end() ) { OfxhPlugin& otherPlugin = *_pluginsByID[plugin->getIdentifier()]; if( plugin->trumps( otherPlugin ) ) { _pluginsByID[plugin->getIdentifier()] = plugin; } } else { _pluginsByID[plugin->getIdentifier()] = plugin; } }
void signal_callback_handler( int signum ) { std::ostringstream os; os << "Signal "<< strsignal(signum) << "(" << signum << ") was caught.\nTerminate sam."; TUTTLE_LOG_WARNING(os.str()); exit(signum); }
/* *Generate average from color selection clip */ bool SelectionAverage::computeAverageSelection(OFX::Clip* clipColor, const OfxPointD& renderScale) { // connection test if(!clipColor->isConnected()) { return false; } boost::scoped_ptr<OFX::Image> src(clipColor->fetchImage( _time, clipColor->getCanonicalRod(_time, renderScale))); // scoped pointer of current source clip // Compatibility tests if(!src.get()) // source isn't accessible { std::cout << "color src is not accessible (average)" << std::endl; return false; } if(src->getRowDistanceBytes() == 0) // if source is wrong { BOOST_THROW_EXCEPTION(exception::WrongRowBytes()); return false; } const OfxRectI srcPixelRod = clipColor->getPixelRod(_time, renderScale); // get current RoD if((clipColor->getPixelDepth() != OFX::eBitDepthFloat) || (!clipColor->getPixelComponents())) { BOOST_THROW_EXCEPTION(exception::Unsupported() << exception::user() + "Can't compute histogram data with the actual input clip format."); return false; } // TUTTLE_LOG_VAR( TUTTLE_INFO, src->getBounds()); // TUTTLE_LOG_VAR( TUTTLE_INFO, src->getRegionOfDefinition() ); if(srcPixelRod != src->getBounds()) // the host does bad things ! { // remove overlay... but do not crash. TUTTLE_LOG_WARNING("Image RoD and image bounds are not the same (rod=" << srcPixelRod << " , bounds:" << src->getBounds() << ")."); return false; } // Compute if source is OK SView colorView = tuttle::plugin::getGilView<SView>(src.get(), srcPixelRod, eImageOrientationIndependant); // get current view from color clip ComputeAverage<SView>::CPixel average = ComputeAverage<SView>()(colorView); // compute color clip average // copy computed average into average stock variable _averageValue.x = average[0]; // red channel value _averageValue.y = average[1]; // green channel value _averageValue.z = average[2]; // blue channel values return true; // average has been computed }
/* * Extend a geodesicForm using the selection */ void SelectionAverage::extendGeodesicForm(OFX::Clip* clipColor, const OfxPointD& renderScale, GeodesicForm& geodesicForm) { // connection test if(!clipColor->isConnected()) { return; } boost::scoped_ptr<OFX::Image> src(clipColor->fetchImage( _time, clipColor->getCanonicalRod(_time, renderScale))); // scoped pointer of current source clip // TUTTLE_LOG_VAR( TUTTLE_INFO, clipColor->getPixelRod(_time,renderScale)); // TUTTLE_LOG_VAR( TUTTLE_INFO, clipColor->getCanonicalRod(_time, renderScale)); // Compatibility tests if(!src.get()) // source isn't accessible { std::cout << "src is not accessible (color clip)" << std::endl; return; } if(src->getRowDistanceBytes() == 0) // if source is wrong { BOOST_THROW_EXCEPTION(exception::WrongRowBytes()); return; } const OfxRectI srcPixelRod = clipColor->getPixelRod(_time, renderScale); // get current RoD if((clipColor->getPixelDepth() != OFX::eBitDepthFloat) || (!clipColor->getPixelComponents())) { BOOST_THROW_EXCEPTION(exception::Unsupported() << exception::user() + "Can't compute histogram data with the actual input clip format."); return; } if(srcPixelRod != src->getBounds()) // the host does bad things ! { // remove overlay... but do not crash. TUTTLE_LOG_WARNING("Image RoD and image bounds are not the same (rod=" << srcPixelRod << " , bounds:" << src->getBounds() << ")."); return; } // Compute if source is OK SView colorView = tuttle::plugin::getGilView<SView>(src.get(), srcPixelRod, eImageOrientationIndependant); // get current view from color clip Pixel_extend_GeodesicForm funct(geodesicForm); // functor declaration //initialize functor terry::algorithm::transform_pixels(colorView, funct); // with functor reference; }
/** * Open src clip return if opening has been done (y or n) * @param clipSrc source of the plugin * @param renderScale current renderScale */ bool CloudPointData::generateVBOData( OFX::Clip* clipSrc, const OfxPointD& renderScale, const bool vboWithDiscretization, const int discretizationStep) { _isVBOBuilt = false; //VBO is not built anymore // connection test if( ! clipSrc->isConnected() ) { return false; } boost::scoped_ptr<OFX::Image> src( clipSrc->fetchImage(_time, clipSrc->getCanonicalRod(_time)) ); //scoped pointer of current source clip // Compatibility tests if( !src.get() ) // source isn't accessible { std::cout << "src is not accessible (cloud point)" << std::endl; return false; } if( src->getRowDistanceBytes() == 0 )//if source is wrong { BOOST_THROW_EXCEPTION( exception::WrongRowBytes() ); return false; } const OfxRectI srcPixelRod = clipSrc->getPixelRod( _time, renderScale ); //get current RoD if( (clipSrc->getPixelDepth() != OFX::eBitDepthFloat) || (clipSrc->getPixelComponents() == OFX::ePixelComponentNone) ) { BOOST_THROW_EXCEPTION( exception::Unsupported() << exception::user() + "Can't compute histogram data with the actual input clip format." ); return false; } if( srcPixelRod != src->getBounds() )// the host does bad things ! { // remove overlay... but do not crash. TUTTLE_LOG_WARNING( "Image RoD and image bounds are not the same (rod=" << srcPixelRod << " , bounds:" << src->getBounds() << ")." ); return false; } // Compute if source is OK SView srcView = tuttle::plugin::getGilView<SView>( src.get(), srcPixelRod, eImageOrientationIndependant ); // get current view from source clip _imgCopy.clear(); //clear buffer if( vboWithDiscretization ) //does user want to discretize the VBO { generateDiscretizedVBOData( srcView, discretizationStep); //create data and return buffer size } else { generateAllPointsVBOData( srcView ); // create data and return buffer size } _isVBOBuilt = true; //VBO has been built return true; }
bool CloudPointData::generateSpillSelectionVBO(OFX::Clip* clipSpill, const OfxPointD& renderScale, bool vboWithDiscretization, int discretizationStep) { _isSpillSelectionVBOBuilt = false; // selection VBO is not built // connection test if( ! clipSpill->isConnected() ) { return false; } boost::scoped_ptr<OFX::Image> src( clipSpill->fetchImage(_time, clipSpill->getCanonicalRod(_time)) ); //scoped pointer of current color clip // Compatibility tests if( !src.get() ) // color clip source isn't accessible { std::cout << "src is not accessible (spill clip)" << std::endl; return false; } if( src->getRowDistanceBytes() == 0 )//if source is wrong { BOOST_THROW_EXCEPTION( exception::WrongRowBytes() ); return false; } const OfxRectI srcPixelRod = clipSpill->getPixelRod( _time, renderScale ); //get current RoD if( (clipSpill->getPixelDepth() != OFX::eBitDepthFloat) || (clipSpill->getPixelComponents() == OFX::ePixelComponentNone) ) { BOOST_THROW_EXCEPTION( exception::Unsupported() << exception::user() + "Can't compute histogram data with the actual input clip format." ); return false; } if( srcPixelRod != src->getBounds() )// the host does bad things ! { // remove overlay... but do not crash. TUTTLE_LOG_WARNING( "Image RoD and image bounds are not the same (rod=" << srcPixelRod << " , bounds:" << src->getBounds() << ")." ); return false; } // Compute if source is OK SView srcView = tuttle::plugin::getGilView<SView>( src.get(), srcPixelRod, eImageOrientationIndependant ); // get current view from source clip if( vboWithDiscretization ) //there is discretization on VBO { //treatment VBO discretization (maybe) } //VBO without discretization generateAllPointsSpillVBOData( srcView ); //generate a selection VBO without discretization _isSpillSelectionVBOBuilt = true; // selection VBO is not built return true; // treatment has been done correctly }
bool LibAVParams::setOption( const std::string& libAVOptionName, const std::string& value, const std::string& detailedName ) { try { // Get libav option avtranscoder::Option& option = getLibAVOption( libAVOptionName, detailedName ); // Set libav option's value option.setString( value ); // Get corresponding OFX parameter OFX::ValueParam* param = getOFXParameter( libAVOptionName, detailedName ); if( ! param) { TUTTLE_LOG_WARNING( "Can't get OFX parameter corresponding to option " << libAVOptionName << " of subgroup " << detailedName ); return false; } // Set OFX parameter's value OFX::BooleanParam* paramBoolean = dynamic_cast<OFX::BooleanParam*>( param ); if( paramBoolean ) { paramBoolean->setValue( option.getBool() ); return true; } OFX::IntParam* paramInt = dynamic_cast<OFX::IntParam*>( param ); if( paramInt ) { paramInt->setValue( option.getInt() ); return true; } OFX::DoubleParam* paramDouble = dynamic_cast<OFX::DoubleParam*>( param ); if( paramDouble ) { paramDouble->setValue( option.getDouble() ); return true; } OFX::StringParam* paramString = dynamic_cast<OFX::StringParam*>( param ); if( paramString ) { paramString->setValue( option.getString() ); return true; } OFX::Int2DParam* paramRatio = dynamic_cast<OFX::Int2DParam*>( param ); if( paramRatio ) { paramRatio->setValue( option.getRatio().first, option.getRatio().second ); return true; } OFX::ChoiceParam* paramChoice = dynamic_cast<OFX::ChoiceParam*>( param ); if( paramChoice ) { paramChoice->setValue( option.getInt() ); return true; } } catch( std::exception& e ) { TUTTLE_LOG_WARNING( "Can't set option " << libAVOptionName << " to " << value << ": " << e.what() ); return false; } }