bool TurboJpegReaderPlugin::getRegionOfDefinition( const OFX::RegionOfDefinitionArguments& args, OfxRectD& rod )
{
	try
	{
		FILE *file = NULL;
		unsigned char *jpegbuf = NULL;
		unsigned long jpgbufsize = 0;

		file = fopen( getAbsoluteFilenameAt( args.time ).c_str(), "rb" );
		if( file == NULL )
		{
			BOOST_THROW_EXCEPTION( exception::File()
				<< exception::user( "TurboJpeg: Unable to open file" )
				<< exception::filename( getAbsoluteFilenameAt( args.time ) ) );
		}
		
		fseek( file, 0, SEEK_END );
		jpgbufsize = ftell( file );
		jpegbuf = new unsigned char[ jpgbufsize ];
		
		fseek(file, 0, SEEK_SET);
		fread( jpegbuf, jpgbufsize, 1, file );

		const tjhandle jpeghandle = tjInitDecompress();
		int width = 0;
		int height = 0;
		int jpegsubsamp = -1;
		
		int ret = tjDecompressHeader2( jpeghandle, jpegbuf, jpgbufsize, &width, &height, &jpegsubsamp );
		
		if( ret != 0 )
		{
			BOOST_THROW_EXCEPTION( exception::FileNotExist()
				<< exception::user( tjGetErrorStr() )
				<< exception::filename( getAbsoluteFilenameAt( args.time ) ) );
		}
		
		tjDestroy( jpeghandle );
		//free(jpegbuf);
		delete[] jpegbuf;
		jpegbuf = NULL;
		
		fclose(file);
		file=NULL;
		
		rod.x1 = 0;
		rod.x2 = width * this->_clipDst->getPixelAspectRatio();
		rod.y1 = 0;
		rod.y2 = height;
		//TUTTLE_COUT_VAR( rod );
	}
	catch( std::exception& e )
	{
		BOOST_THROW_EXCEPTION( exception::FileNotExist()
			<< exception::user( "TurboJpeg: Unable to open file" )
			<< exception::filename( getAbsoluteFilenameAt( args.time ) ) );
	}
	
	return true;
}
Beispiel #2
0
void WriterPlugin::render( const OFX::RenderArguments& args )
{
	_oneRender = false;

	TUTTLE_COUT( "        --> " << getAbsoluteFilenameAt( args.time ) );

	boost::scoped_ptr<OFX::Image> src( _clipSrc->fetchImage( args.time ) );
	boost::scoped_ptr<OFX::Image> dst( _clipDst->fetchImage( args.time ) );
	
	// Copy buffer
	const OfxRectI bounds = dst->getBounds();
	TUTTLE_TCOUT_VAR( bounds );
	if( src->isLinearBuffer() && dst->isLinearBuffer() )
	{
		TUTTLE_TCOUT( "isLinearBuffer" );
		const std::size_t imageDataBytes = dst->getBoundsImageDataBytes();
		TUTTLE_TCOUT_VAR( imageDataBytes );
		if( imageDataBytes )
		{
			void* dataSrcPtr = src->getPixelAddress( bounds.x1, bounds.y1 );
			void* dataDstPtr = dst->getPixelAddress( bounds.x1, bounds.y1 );
			memcpy( dataDstPtr, dataSrcPtr, imageDataBytes );
		}
	}
	else
	{
		const std::size_t rowBytesToCopy = dst->getBoundsRowDataBytes();
		for( int y = bounds.y1; y < bounds.y2; ++y )
		{
			void* dataSrcPtr = src->getPixelAddress( bounds.x1, y );
			void* dataDstPtr = dst->getPixelAddress( bounds.x1, y );
			memcpy( dataDstPtr, dataSrcPtr, rowBytesToCopy );
		}
	}
}
Beispiel #3
0
bool PngReaderPlugin::getRegionOfDefinition( const OFX::RegionOfDefinitionArguments& args, OfxRectD& rod )
{
    const std::string filename( getAbsoluteFilenameAt( args.time ) );
    if( ! boost::filesystem::exists( filename ) )
    {
        BOOST_THROW_EXCEPTION( exception::FileInSequenceNotExist()
                               << exception::user( "PNG: Unable to open file" )
                               << exception::filename( filename ) );
    }

    try
    {
        point2<ptrdiff_t> pngDims = png_read_dimensions( filename );
        rod.x1 = 0;
        rod.x2 = pngDims.x * this->_clipDst->getPixelAspectRatio();
        rod.y1 = 0;
        rod.y2 = pngDims.y;
        TUTTLE_TLOG_VAR( TUTTLE_INFO, rod );
    }
    catch( std::exception& e )
    {
        BOOST_THROW_EXCEPTION( exception::FileNotExist()
                               << exception::user( "PNG: Unable to open file" )
                               << exception::dev( e.what() )
                               << exception::filename( filename ) );
    }
    return true;
}
Beispiel #4
0
PngReaderProcessParams PngReaderPlugin::getProcessParams( const OfxTime time )
{
    PngReaderProcessParams params;

    params._filepath = getAbsoluteFilenameAt( time );
    return params;
}
TurboJpegReaderProcessParams TurboJpegReaderPlugin::getProcessParams(const OfxTime time) const
{
    TurboJpegReaderProcessParams params;
    params.filepath = getAbsoluteFilenameAt(time);
    params.optimization = static_cast<ETurboJpegOptimization>(_optimization->getValue());
    params.fastUpsampling = _fastUpsampling->getValue();
    return params;
}
Beispiel #6
0
std::vector<boost::filesystem::path> Sequence::getFiles() const
{
	std::vector<boost::filesystem::path> allPaths;
	for( Time t = getFirstTime(); t <= getLastTime(); t += getStep() )
	{
		allPaths.push_back( getAbsoluteFilenameAt( t ) );
	}
	return allPaths;
}
ImageMagickWriterProcessParams ImageMagickWriterPlugin::getProcessParams(const OfxTime time)
{
    ImageMagickWriterProcessParams params;

    params._filepath = getAbsoluteFilenameAt(time);
    params._quality = this->_quality->getValue();
    params._premult = this->_premult->getValue();
    return params;
}
Beispiel #8
0
bool WriterPlugin::isIdentity( const OFX::RenderArguments& args, OFX::Clip*& identityClip, OfxTime& identityTime )
{
	EParamWriterExistingFile existingFile = static_cast<EParamWriterExistingFile>(_paramExistingFile->getValue());
	if( existingFile != eParamWriterExistingFile_overwrite )
	{
		const std::string filepath = getAbsoluteFilenameAt( args.time );
		const bool fileExists = bfs::exists( filepath );

		switch( existingFile )
		{
			case eParamWriterExistingFile_error:
			{
				if( fileExists )
					BOOST_THROW_EXCEPTION( exception::FileExist(filepath) );
				break;
			}
			case eParamWriterExistingFile_reader:
			{
				BOOST_ASSERT(false);
				// Not implemented
			}
			case eParamWriterExistingFile_skip:
			{
				if( fileExists )
				{
					// We declare an empty clip as identity to disable the process of this node.
					// This is not in the OpenFX standard. So this option only exist on TuttleOFX host.
					identityClip = NULL;
					identityTime = 0;
					TUTTLE_LOG_TRACE("[Plugin Writer] Identity node: " << this->getName() << " at time: " << args.time  << ", file already exist:" << filepath);
					return true;
				}
				break;
			}
			case eParamWriterExistingFile_overwrite:
				BOOST_ASSERT(false);
		}
	}
	
	// little hack for the push button Render
	if( _oneRender && _oneRenderAtTime == args.time )
	{
		return false;
	}
	if( OFX::getImageEffectHostDescription( )->hostIsBackground )
	{
		return false;
	}
	if( _paramRenderAlways->getValue( ) )
	{
		return false;
	}
	identityClip = _clipSrc;
	identityTime = args.time;
	return true;
}
Beispiel #9
0
void ReaderPlugin::render( const OFX::RenderArguments& args )
{
	const std::string filename( getAbsoluteFilenameAt( args.time ) );
	if( ! boost::filesystem::exists( filename ) )
	{
		BOOST_THROW_EXCEPTION( exception::File()
			<< exception::user( "Unable to open file." )
			<< exception::filename( filename ) );
		BOOST_THROW_EXCEPTION( exception::FileNotExist( filename ) );

	}
	
}
Beispiel #10
0
void ReaderPlugin::render(const OFX::RenderArguments& args)
{
    std::string filename = getAbsoluteFilenameAt(args.time);
    TUTTLE_LOG_INFO("        >-- " << filename);
}