[Hdrflow-svn] SF.net SVN: hdrflow: [395] trunk/lib
Status: Pre-Alpha
Brought to you by:
glslang
From: <gl...@us...> - 2008-01-05 21:44:00
|
Revision: 395 http://hdrflow.svn.sourceforge.net/hdrflow/?rev=395&view=rev Author: glslang Date: 2008-01-05 13:43:59 -0800 (Sat, 05 Jan 2008) Log Message: ----------- + sRGB lut Modified Paths: -------------- trunk/lib/extras/src/lut/lut.cpp trunk/lib/openlibraries/src/openimagelib/il/il.hpp trunk/lib/openlibraries/src/openimagelib/il/lut_functions.cpp trunk/lib/openlibraries/src/openimagelib/il/lut_functions.hpp Modified: trunk/lib/extras/src/lut/lut.cpp =================================================================== --- trunk/lib/extras/src/lut/lut.cpp 2008-01-05 21:00:49 UTC (rev 394) +++ trunk/lib/extras/src/lut/lut.cpp 2008-01-05 21:43:59 UTC (rev 395) @@ -9,11 +9,6 @@ #include <openlibraries_global_config.hpp> #endif -#ifdef WIN32 -#define _USE_MATH_DEFINES -#include <cmath> -#endif - #include <openmedialib/ml/openmedialib_plugin.hpp> namespace pl = olib::openpluginlib; @@ -28,8 +23,10 @@ public: explicit lut_input( ) : prop_colourspace_( pcos::key::from_string( "colourspace" ) ) + , prop_function_( pcos::key::from_string( "function" ) ) , prop_width_( pcos::key::from_string( "width" ) ) , prop_height_( pcos::key::from_string( "height" ) ) + , prop_depth_( pcos::key::from_string( "depth" ) ) , prop_fps_num_( pcos::key::from_string( "fps_num" ) ) , prop_fps_den_( pcos::key::from_string( "fps_den" ) ) , prop_sar_num_( pcos::key::from_string( "sar_num" ) ) @@ -37,8 +34,10 @@ , prop_out_( pcos::key::from_string( "out" ) ) { properties( ).append( prop_colourspace_ = pl::wstring( L"r32g32b32f" ) ); + properties( ).append( prop_function_ = pl::wstring( L"sRGB" ) ); properties( ).append( prop_width_ = 512 ); - properties( ).append( prop_height_ = 512 ); + properties( ).append( prop_height_ = 1 ); + properties( ).append( prop_depth_ = 1 ); properties( ).append( prop_fps_num_ = 24 ); properties( ).append( prop_fps_den_ = 1 ); properties( ).append( prop_sar_num_ = 1 ); @@ -82,18 +81,67 @@ virtual ml::frame_type_ptr fetch( ) { - return ml::frame_type_ptr( ); + acquire_values( ); + + il::image_type_ptr image = il::allocate( prop_colourspace_.value<pl::wstring>( ).c_str(), get_width( ), get_height( ) ); + if( image ) + fill( image ); + + ml::frame_type_ptr frame( new ml::frame_type( ) ); + frame->set_sar( prop_sar_num_.value<int>( ), prop_sar_den_.value<int>( ) ); + frame->set_fps( prop_fps_num_.value<int>( ), prop_fps_den_.value<int>( ) ); + frame->set_pts( get_position( ) * 1.0 / fps( ) ); + frame->set_duration( 1.0 / fps( ) ); + frame->set_position( get_position( ) ); + + frame->set_image( image ); + + return frame; } private: void fill( il::image_type_ptr im ) { + pl::wstring pf = prop_colourspace_.value<pl::wstring>( ); + pl::wstring fn = prop_function_.value<pl::wstring>( ); + + int width = im->width( ); + int height = im->height( ); + int depth = im->depth( ); + int pitch = im->pitch( ); + + const float sx = 1.0f / ( width - 1.0f ); + + if( fn == L"sRGB" ) + { + if( pf == L"r32g32b32f" ) + { + float* src = reinterpret_cast<float*>( im->data( ) ); + + for( int i = 0; i < depth; ++i ) + { + for( int j = 0; j < height; ++j ) + { + for( int k = 0; k < width; ++k ) + { + src[ k + 0 ] = il::to_sRGB( k * sx ); + src[ k + 1 ] = il::to_sRGB( k * sx ); + src[ k + 2 ] = il::to_sRGB( k * sx ); + } + + src += pitch; + } + } + } + } } private: pcos::property prop_colourspace_; + pcos::property prop_function_; pcos::property prop_width_; pcos::property prop_height_; + pcos::property prop_depth_; pcos::property prop_fps_num_; pcos::property prop_fps_den_; pcos::property prop_sar_num_; Modified: trunk/lib/openlibraries/src/openimagelib/il/il.hpp =================================================================== --- trunk/lib/openlibraries/src/openimagelib/il/il.hpp 2008-01-05 21:00:49 UTC (rev 394) +++ trunk/lib/openlibraries/src/openimagelib/il/il.hpp 2008-01-05 21:43:59 UTC (rev 395) @@ -14,6 +14,7 @@ #include <openimagelib/il/basic_image.hpp> #include <openimagelib/il/traits.hpp> #include <openimagelib/il/utility.hpp> +#include <openimagelib/il/lut_functions.hpp> namespace olib { namespace openimagelib { Modified: trunk/lib/openlibraries/src/openimagelib/il/lut_functions.cpp =================================================================== --- trunk/lib/openlibraries/src/openimagelib/il/lut_functions.cpp 2008-01-05 21:00:49 UTC (rev 394) +++ trunk/lib/openlibraries/src/openimagelib/il/lut_functions.cpp 2008-01-05 21:43:59 UTC (rev 395) @@ -10,7 +10,7 @@ #include <cmath> #endif -#include <openimagelib/il/lut_functions.hpp> +#include <openimagelib/il/il.hpp> namespace olib { namespace openimagelib { namespace il { Modified: trunk/lib/openlibraries/src/openimagelib/il/lut_functions.hpp =================================================================== --- trunk/lib/openlibraries/src/openimagelib/il/lut_functions.hpp 2008-01-05 21:00:49 UTC (rev 394) +++ trunk/lib/openlibraries/src/openimagelib/il/lut_functions.hpp 2008-01-05 21:43:59 UTC (rev 395) @@ -10,7 +10,7 @@ namespace olib { namespace openimagelib { namespace il { -float to_sRGB( float v ); +IL_DECLSPEC float to_sRGB( float v ); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |