Example #1
0
/**
 * Compute only curve from selection data (averages,histograms buffer and selection buffer)
 * @param clipSrc	source of the plugin
 * @param time	current time
 * @param renderScale	current renderScale
 */
void OverlayData::computeCurveFromSelectionData( OFX::Clip* clipSrc, const OfxTime time, const OfxPointD& renderScale)
{
	_isComputing = true;

	resetCurvesFromSelectionData();
	
	if( ! clipSrc->isConnected() )
	{	
		_isComputing = false;
		return;
	}
	boost::scoped_ptr<OFX::Image> src( clipSrc->fetchImage(_currentTime, clipSrc->getCanonicalRod(_currentTime)) );	//scoped pointer of current source clip

	// Compatibility tests
	if( !src.get() ) // source isn't accessible
	{
		_isComputing = false;
		std::cout << "src is not accessible" << std::endl;
		return;
	}

	if( src->getRowBytes() == 0 )//if source is wrong
	{
		BOOST_THROW_EXCEPTION( exception::WrongRowBytes() );
	}
	OfxRectI srcPixelRod = clipSrc->getPixelRod( _currentTime, renderScale ); //get current RoD
	if( (clipSrc->getPixelDepth() != OFX::eBitDepthFloat) ||
		(!clipSrc->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_COUT_WARNING( "Image RoD and image bounds are not the same (rod=" << srcPixelRod << " , bounds:" << src->getBounds() << ")." );
		return;
	}
	
	// Compute if source is OK
	SView srcView = tuttle::plugin::getView<SView>( src.get(), srcPixelRod );	// get current view from source clip
	
	OfxPointI imgSize;
	imgSize.x = srcView.width();
	imgSize.y = srcView.height();
	
	if( isImageSizeModified( imgSize ) )
	{
		clearAll( imgSize );
	}
	//Compute histogram buffer
	Pixel_compute_histograms funct( _imgBool,_curveFromSelection, true);			//functor declaration
	terry::algorithm::transform_pixels( srcView, funct );		//(USED functor reference)
	
	this->correctHistogramBufferData(_curveFromSelection);				//correct Histogram data to make up for discretization (average)
}
Example #2
0
MemoryPool::~MemoryPool()
{
	TUTTLE_TCOUT_X( 20, "-" );
	TUTTLE_TCOUT( "~MemoryPool()" );
	if( !_dataUsed.empty() )
	{
		TUTTLE_COUT_WARNING( "Error inside memory pool. Some data always mark used at the destruction (nb elements:" << _dataUsed.size() << ")" );
	}
	TUTTLE_TCOUT_VAR( _dataUsed.size() );
	TUTTLE_TCOUT_VAR( _dataUnused.size() );
	TUTTLE_TCOUT_VAR( _allDatas.size() );
	TUTTLE_TCOUT_VAR( _memoryAuthorized );
	TUTTLE_TCOUT( "" );
	TUTTLE_TCOUT_VAR( getUsedMemorySize() );
	TUTTLE_TCOUT_VAR( getAllocatedMemorySize() );
	TUTTLE_TCOUT_VAR( getMaxMemorySize() );
	TUTTLE_TCOUT_VAR( getAvailableMemorySize() );
	TUTTLE_TCOUT_VAR( getWastedMemorySize() );
	TUTTLE_TCOUT_X( 20, "-" );
}
Example #3
0
/**
 * Compute full data (averages,histograms buffer and selection buffer)
 * @param clipSrc	source of the plugin
 * @param time	current time
 * @param renderScale	current renderScale
 */
void OverlayData::computeFullData( OFX::Clip* clipSrc, const OfxTime time, const OfxPointD& renderScale, const bool selectionOnly )
{
	_isComputing = true;
	resetHistogramData();
	resetHistogramSelectionData();
	
	if( ! clipSrc->isConnected() )
	{	
		_isComputing = false;
		return;
	}
	
	//TUTTLE_TCOUT_INFOS;
	//TUTTLE_TCOUT_VAR( "computeHistogramBufferData - fetchImage " << time );
	boost::scoped_ptr<OFX::Image> src( clipSrc->fetchImage(time, clipSrc->getCanonicalRod(time)) );	//scoped pointer of current source clip
	//TUTTLE_TCOUT_INFOS;
	
	//TUTTLE_TCOUT_VAR( clipSrc->getPixelRod(time, renderScale) );
	//TUTTLE_TCOUT_VAR( clipSrc->getCanonicalRod(time, renderScale) );
	
	// Compatibility tests
	if( !src.get() ) // source isn't accessible
	{
		_isComputing = false;
		std::cout << "src is not accessible" << std::endl;
		return;
	}
	
//	TUTTLE_TCOUT_VAR( src->getBounds() );
//	TUTTLE_TCOUT_VAR( src->getRegionOfDefinition() );

	if( src->getRowBytes() == 0 )//if source is wrong
	{
		BOOST_THROW_EXCEPTION( exception::WrongRowBytes() );
	}
	OfxRectI srcPixelRod = clipSrc->getPixelRod( time, renderScale ); //get current RoD
	if( (clipSrc->getPixelDepth() != OFX::eBitDepthFloat) ||
		(!clipSrc->getPixelComponents()) )
	{
		BOOST_THROW_EXCEPTION( exception::Unsupported()	<< exception::user() + "Can't compute histogram data with the actual input clip format." );
        return;
	}
	
//	TUTTLE_TCOUT_INFOS;
//	BOOST_ASSERT( srcPixelRod == src->getBounds() );
	if( srcPixelRod != src->getBounds() )
	{
		// the host does bad things !
		// remove overlay... but do not crash.
		TUTTLE_COUT_WARNING( "Image RoD and image bounds are not the same (rod=" << srcPixelRod << " , bounds:" << src->getBounds() << ")." );
		return;
	}
//	BOOST_ASSERT( srcPixelRod.x1 == src->getBounds().x1 );
//	BOOST_ASSERT( srcPixelRod.y1 == src->getBounds().y1 );
//	BOOST_ASSERT( srcPixelRod.x2 == src->getBounds().x2 );
//	BOOST_ASSERT( srcPixelRod.y2 == src->getBounds().y2 );
	
	// Compute if source is OK
	SView srcView = tuttle::plugin::getView<SView>( src.get(), srcPixelRod );	// get current view from source clip
	
	OfxPointI imgSize;
	imgSize.x = srcView.width();
	imgSize.y = srcView.height();
	
//	TUTTLE_TCOUT_INFOS;
	if( isImageSizeModified( imgSize ) )
	{
		//TUTTLE_TCOUT_INFOS;
		clearAll( imgSize );
	}
	
	//TUTTLE_TCOUT_INFOS;
	//Compute histogram buffer
	this->computeHistogramBufferData( _data, srcView, time);
	
	//TUTTLE_TCOUT_INFOS;
	//Compute selection histogram buffer
	this->computeHistogramBufferData( _selectionData, srcView, time, true );
	
	//TUTTLE_TCOUT_INFOS;
	//Compute averages
	this->computeAverages();
	_isComputing = false;
	
	_currentTime = time;
	//TUTTLE_TCOUT_INFOS;
}