Thread: [Hdrflow-svn] SF.net SVN: hdrflow: [353] trunk/lib/openlibraries/src/openimagelib/il
Status: Pre-Alpha
Brought to you by:
glslang
From: <gl...@us...> - 2007-10-10 21:36:01
|
Revision: 353 http://hdrflow.svn.sourceforge.net/hdrflow/?rev=353&view=rev Author: glslang Date: 2007-10-10 14:22:34 -0700 (Wed, 10 Oct 2007) Log Message: ----------- + makes crop underlying element size aware Modified Paths: -------------- trunk/lib/openlibraries/src/openimagelib/il/basic_image.hpp trunk/lib/openlibraries/src/openimagelib/il/float_traits.hpp trunk/lib/openlibraries/src/openimagelib/il/rgb_traits.hpp Modified: trunk/lib/openlibraries/src/openimagelib/il/basic_image.hpp =================================================================== --- trunk/lib/openlibraries/src/openimagelib/il/basic_image.hpp 2007-10-09 21:21:59 UTC (rev 352) +++ trunk/lib/openlibraries/src/openimagelib/il/basic_image.hpp 2007-10-10 21:22:34 UTC (rev 353) @@ -215,20 +215,22 @@ bool is_flipped = ( flags & flipped ) != 0; bool is_flopped = ( flags & flopped ) != 0; + size_type element_size = bitdepth( ) / 8; + plane &p = crop[ 0 ]; p.width = w; p.height = h; p.linesize = w * block_size_; if ( !is_flipped ) - p.offset = p.pitch * y; + p.offset = p.pitch * y * element_size; else - p.offset = ( ( height_ - y - h ) * p.pitch ); + p.offset = ( ( height_ - y - h ) * p.pitch ) * element_size; if ( !is_flopped ) - p.offset += x * block_size_; + p.offset += x * block_size_ * element_size; else - p.offset += ( width_ - w - x ) * block_size_; + p.offset += ( width_ - w - x ) * block_size_ * element_size; } // Flop scan which assumes block_size_ is known and <= 4 - associated plane is @@ -350,7 +352,7 @@ // Obtain the number of planes and iterate through each size_type count = structure_->plane_count( ); - size_type sfactor = structure_->bitdepth( ) / 8; + size_type element_size = structure_->bitdepth( ) / 8; for ( size_type i = 0; i < count; i ++ ) { @@ -358,7 +360,7 @@ const_pointer src = other.data( i ); size_type src_pitch = other.pitch( i ); - src_pitch *= sfactor; + src_pitch *= element_size; // The destination plane, pitch and height pointer dst = data( i ); @@ -367,8 +369,8 @@ size_type dst_scan = linesize( i ); size_type dst_height = height( i ); - dst_scan *= sfactor; - dst_pitch *= sfactor; + dst_scan *= element_size; + dst_pitch *= element_size; // We need to orient the dest correctly if ( need_flip ) Modified: trunk/lib/openlibraries/src/openimagelib/il/float_traits.hpp =================================================================== --- trunk/lib/openlibraries/src/openimagelib/il/float_traits.hpp 2007-10-09 21:21:59 UTC (rev 352) +++ trunk/lib/openlibraries/src/openimagelib/il/float_traits.hpp 2007-10-10 21:22:34 UTC (rev 353) @@ -91,6 +91,9 @@ virtual r16g16b16f* clone( size_type w, size_type h ) { return new r16g16b16f( *this, w, h ); } + + virtual void flop_scan_line( size_t p, pointer dst, const_pointer src, size_type w ) const + { flop_scan_line_( p, ( short* ) dst, ( const unsigned short* ) src, w ); } }; template<typename T = float, class storage = default_storage<T> > @@ -131,6 +134,9 @@ virtual b16g16r16f* clone( size_type w, size_type h ) { return new b16g16r16f( *this, w, h ); } + + virtual void flop_scan_line( size_t p, pointer dst, const_pointer src, size_type w ) const + { flop_scan_line_( p, ( short* ) dst, ( const unsigned short* ) src, w ); } }; template<typename T = float, class storage = default_storage<T> > @@ -171,6 +177,9 @@ virtual r16g16b16a16f* clone( size_type w, size_type h ) { return new r16g16b16a16f( *this, w, h ); } + + virtual void flop_scan_line( size_t p, pointer dst, const_pointer src, size_type w ) const + { flop_scan_line_( p, ( short* ) dst, ( const unsigned short* ) src, w ); } }; template<typename T = float, class storage = default_storage<T> > @@ -213,9 +222,7 @@ { return new r32g32b32f( *this, w, h ); } virtual void flop_scan_line( size_t p, pointer dst, const_pointer src, size_type w ) const - { - flop_scan_line_( p, ( float* ) dst, ( const float* ) src, w ); - } + { flop_scan_line_( p, ( float* ) dst, ( const float* ) src, w ); } }; template<typename T = float, class storage = default_storage<T> > @@ -258,9 +265,7 @@ { return new r32g32b32a32f( *this, w, h ); } virtual void flop_scan_line( size_t p, pointer dst, const_pointer src, size_type w ) const - { - flop_scan_line_( p, ( float* ) dst, ( const float* ) src, w ); - } + { flop_scan_line_( p, ( float* ) dst, ( const float* ) src, w ); } }; } } } Modified: trunk/lib/openlibraries/src/openimagelib/il/rgb_traits.hpp =================================================================== --- trunk/lib/openlibraries/src/openimagelib/il/rgb_traits.hpp 2007-10-09 21:21:59 UTC (rev 352) +++ trunk/lib/openlibraries/src/openimagelib/il/rgb_traits.hpp 2007-10-10 21:22:34 UTC (rev 353) @@ -521,7 +521,7 @@ { return bs * sizeof( unsigned short ) * detail::rgb_Allocate_size<T>( )( 1, width, height, depth ); } virtual size_type bitdepth( ) const - { return 12; } + { return 16; } virtual l12a12p* clone( size_type w, size_type h ) { return new l12a12p( *this, w, h ); } @@ -684,7 +684,7 @@ { return sizeof( unsigned short ) * detail::rgb_Allocate_size<T>( )( bs, width, height, depth ); } virtual size_type bitdepth( ) const - { return 10; } + { return 16; } virtual r10g10b10* clone( size_type w, size_type h ) { return new r10g10b10( *this, w, h ); } @@ -743,7 +743,7 @@ { return sizeof( unsigned short ) * detail::rgb_Allocate_size<T>( )( bs, width, height, depth ); } virtual size_type bitdepth( ) const - { return 10; } + { return 16; } virtual r10g10b10a10* clone( size_type w, size_type h ) { return new r10g10b10a10( *this, w, h ); } @@ -803,7 +803,7 @@ { return bs * sizeof( unsigned short ) * detail::rgb_Allocate_size<T>( )( 1, width, height, depth ); } virtual size_type bitdepth( ) const - { return 10; } + { return 16; } virtual r10g10b10p* clone( size_type w, size_type h ) { return new r10g10b10p( *this, w, h ); } @@ -869,7 +869,7 @@ { return bs * sizeof( unsigned short ) * detail::rgb_Allocate_size<T>( )( 1, width, height, depth ); } virtual size_type bitdepth( ) const - { return 10; } + { return 16; } virtual r10g10b10a10p* clone( size_type w, size_type h ) { return new r10g10b10a10p( *this, w, h ); } @@ -937,7 +937,7 @@ { return sizeof( unsigned short ) * detail::rgb_Allocate_size<T>( )( bs, width, height, depth ); } virtual size_type bitdepth( ) const - { return 12; } + { return 16; } virtual r12g12b12* clone( size_type w, size_type h ) { return new r12g12b12( *this, w, h ); } @@ -996,7 +996,7 @@ { return sizeof( unsigned short ) * detail::rgb_Allocate_size<T>( )( bs, width, height, depth ); } virtual size_type bitdepth( ) const - { return 12; } + { return 16; } virtual r12g12b12a12* clone( size_type w, size_type h ) { return new r12g12b12a12( *this, w, h ); } @@ -1056,7 +1056,7 @@ { return bs * sizeof( unsigned short ) * detail::rgb_Allocate_size<T>( )( 1, width, height, depth ); } virtual size_type bitdepth( ) const - { return 12; } + { return 16; } virtual r12g12b12p* clone( size_type w, size_type h ) { return new r12g12b12p( *this, w, h ); } @@ -1122,7 +1122,7 @@ { return bs * sizeof( unsigned short ) * detail::rgb_Allocate_size<T>( )( 1, width, height, depth ); } virtual size_type bitdepth( ) const - { return 12; } + { return 16; } virtual r12g12b12a12p* clone( size_type w, size_type h ) { return new r12g12b12a12p( *this, w, h ); } @@ -1504,7 +1504,7 @@ { return sizeof( unsigned short ) * detail::rgb_Allocate_size<T>( )( bs, width, height, depth ); } virtual size_type bitdepth( ) const - { return 10; } + { return 16; } virtual r10g10b10log* clone( size_type w, size_type h ) { return new r10g10b10log( *this, w, h ); } @@ -1563,7 +1563,7 @@ { return sizeof( unsigned short ) * detail::rgb_Allocate_size<T>( )( bs, width, height, depth ); } virtual size_type bitdepth( ) const - { return 12; } + { return 16; } virtual r12g12b12log* clone( size_type w, size_type h ) { return new r12g12b12log( *this, w, h ); } @@ -1740,7 +1740,7 @@ { return sizeof( unsigned short ) * detail::rgb_Allocate_size<T>( )( bs, width, height, depth ); } virtual size_type bitdepth( ) const - { return 10; } + { return 16; } virtual r10g10b10a10log* clone( size_type w, size_type h ) { return new r10g10b10a10log( *this, w, h ); } @@ -1799,7 +1799,7 @@ { return sizeof( unsigned short ) * detail::rgb_Allocate_size<T>( )( bs, width, height, depth ); } virtual size_type bitdepth( ) const - { return 12; } + { return 16; } virtual r12g12b12a12log* clone( size_type w, size_type h ) { return new r12g12b12a12log( *this, w, h ); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gl...@us...> - 2007-10-20 20:35:42
|
Revision: 362 http://hdrflow.svn.sourceforge.net/hdrflow/?rev=362&view=rev Author: glslang Date: 2007-10-20 13:35:32 -0700 (Sat, 20 Oct 2007) Log Message: ----------- + adds initial code for swizzling and lut-based conversion. Modified Paths: -------------- trunk/lib/openlibraries/src/openimagelib/il/il.hpp trunk/lib/openlibraries/src/openimagelib/il/il_vc8.vcproj trunk/lib/openlibraries/src/openimagelib/il/utility.cpp Added Paths: ----------- trunk/lib/openlibraries/src/openimagelib/il/lut_converter.hpp Modified: trunk/lib/openlibraries/src/openimagelib/il/il.hpp =================================================================== --- trunk/lib/openlibraries/src/openimagelib/il/il.hpp 2007-10-18 21:58:43 UTC (rev 361) +++ trunk/lib/openlibraries/src/openimagelib/il/il.hpp 2007-10-20 20:35:32 UTC (rev 362) @@ -14,6 +14,7 @@ #include <openimagelib/il/basic_image.hpp> #include <openimagelib/il/traits.hpp> #include <openimagelib/il/utility.hpp> +#include <openimagelib/il/lut_converter.hpp> namespace olib { namespace openimagelib { Modified: trunk/lib/openlibraries/src/openimagelib/il/il_vc8.vcproj =================================================================== --- trunk/lib/openlibraries/src/openimagelib/il/il_vc8.vcproj 2007-10-18 21:58:43 UTC (rev 361) +++ trunk/lib/openlibraries/src/openimagelib/il/il_vc8.vcproj 2007-10-20 20:35:32 UTC (rev 362) @@ -227,6 +227,10 @@ > </File> <File + RelativePath=".\lut_converter.hpp" + > + </File> + <File RelativePath=".\openimagelib_plugin.hpp" > </File> Added: trunk/lib/openlibraries/src/openimagelib/il/lut_converter.hpp =================================================================== --- trunk/lib/openlibraries/src/openimagelib/il/lut_converter.hpp (rev 0) +++ trunk/lib/openlibraries/src/openimagelib/il/lut_converter.hpp 2007-10-20 20:35:32 UTC (rev 362) @@ -0,0 +1,44 @@ + +// il - An image library representation. + +// Copyright (C) 2007 Goncalo Nuno M. de Carvalho +// Released under the LGPL. +// For more information, see http://www.hdrflow.com. + +#ifndef LUT_CONVERTER_INC_ +#define LUT_CONVERTER_INC_ + +#include <functional> + +namespace olib { namespace openimagelib { namespace il { + +struct byte_to_byte : public std::unary_function<unsigned char, unsigned char> +{ + typedef unsigned char value_type; + typedef unsigned char convert_type; + + convert_type operator( )( value_type v ) const + { return v; } +}; + +struct byte_to_float : public std::unary_function<unsigned char, float> +{ + typedef unsigned char value_type; + typedef float convert_type; + + convert_type operator( )( value_type v ) const + { return v / 255.0f; } +}; + +struct float_to_float : public std::unary_function<float, float> +{ + typedef float value_type; + typedef float convert_type; + + convert_type operator( )( value_type v ) const + { return v; } +}; + +} } } + +#endif Property changes on: trunk/lib/openlibraries/src/openimagelib/il/lut_converter.hpp ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/lib/openlibraries/src/openimagelib/il/utility.cpp =================================================================== --- trunk/lib/openlibraries/src/openimagelib/il/utility.cpp 2007-10-18 21:58:43 UTC (rev 361) +++ trunk/lib/openlibraries/src/openimagelib/il/utility.cpp 2007-10-20 20:35:32 UTC (rev 362) @@ -1112,7 +1112,8 @@ { L"", L"", 0, { 0, 0, 0, 0 }, 0, { 0, 0, 0, 0 } } }; -static image_type_ptr rgb_to_rgb( const image_type_ptr &src_img, const std::wstring &format ) +template<typename const_pointer, typename pointer> +image_type_ptr rgb_to_rgb( const image_type_ptr &src_img, const std::wstring &format ) { size_type width = src_img->width( ); size_type height = src_img->height( ); @@ -1802,11 +1803,11 @@ else if ( src_pf == L"r8g8b8" ) { if ( dst_pf == L"b8g8r8" ) - return rgb_to_rgb( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); else if ( dst_pf == L"r8g8b8a8" ) - return rgb_to_rgb( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); else if ( dst_pf == L"b8g8r8a8" ) - return rgb_to_rgb( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); else if ( dst_pf == L"yuv444" ) return rgb_to_yuv444( src, dst_pf, 3, 0, 1, 2 ); else if ( dst_pf == L"yuv422" ) @@ -1822,11 +1823,11 @@ else if ( src_pf == L"b8g8r8" ) { if ( dst_pf == L"r8g8b8" ) - return rgb_to_rgb( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); else if ( dst_pf == L"r8g8b8a8" ) - return rgb_to_rgb( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); else if ( dst_pf == L"b8g8r8a8" ) - return rgb_to_rgb( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); else if ( dst_pf == L"yuv444" ) return rgb_to_yuv444( src, dst_pf, 3, 2, 1, 0 ); else if ( dst_pf == L"yuv422" ) @@ -1837,11 +1838,11 @@ else if ( src_pf == L"r8g8b8a8" ) { if ( dst_pf == L"r8g8b8" ) - return rgb_to_rgb( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); else if ( dst_pf == L"b8g8r8" ) - return rgb_to_rgb( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); else if ( dst_pf == L"b8g8r8a8" ) - return rgb_to_rgb( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); else if ( dst_pf == L"yuv444" ) return rgb_to_yuv444( src, dst_pf, 4, 0, 1, 2 ); else if ( dst_pf == L"yuv422" ) @@ -1857,11 +1858,11 @@ else if ( src_pf == L"b8g8r8a8" ) { if ( dst_pf == L"r8g8b8" ) - return rgb_to_rgb( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); else if ( dst_pf == L"r8g8b8a8" ) - return rgb_to_rgb( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); else if ( dst_pf == L"b8g8r8" ) - return rgb_to_rgb( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); else if ( dst_pf == L"yuv444" ) return rgb_to_yuv444( src, dst_pf, 4, 2, 1, 0 ); else if ( dst_pf == L"yuv422" ) @@ -1874,11 +1875,11 @@ else if ( src_pf == L"a8r8g8b8" ) { if( dst_pf == L"a8b8g8r8" ) - return rgb_to_rgb( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); else if( dst_pf == L"b8g8r8") - return rgb_to_rgb( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); else if( dst_pf == L"b8g8r8a8") - return rgb_to_rgb( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); else if ( dst_pf == L"yuv444" ) return rgb_to_yuv444( src, dst_pf, 4, 1, 2, 3 ); else if ( dst_pf == L"yuv422" ) @@ -1889,11 +1890,11 @@ else if( src_pf == L"a8b8g8r8" ) { if( dst_pf == L"b8g8r8a8" ) - return rgb_to_rgb( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); else if( dst_pf == L"r8g8b8a8" ) - return rgb_to_rgb( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); else if( dst_pf == L"r8g8b8" ) - return rgb_to_rgb( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); else if ( dst_pf == L"yuv444" ) return rgb_to_yuv444( src, dst_pf, 4, 3, 2, 1 ); else if ( dst_pf == L"yuv422" ) @@ -1904,12 +1905,12 @@ else if( src_pf == L"r8g8b8log" ) { if( dst_pf == L"b8g8r8a8" ) - return convert_log_to_linear( rgb_to_rgb( src, dst_pf ) ); + return convert_log_to_linear( rgb_to_rgb<const_pointer, pointer>( src, dst_pf ) ); } else if( src_pf == L"r8g8b8a8log" ) { if( dst_pf == L"b8g8r8a8" ) - return convert_log_to_linear( rgb_to_rgb( src, dst_pf ) ); + return convert_log_to_linear( rgb_to_rgb<const_pointer, pointer>( src, dst_pf ) ); } else if( src_pf == L"r10g10b10" ) { @@ -2057,11 +2058,11 @@ else if( src_pf == L"l8a8" ) { if( dst_pf == L"b8g8r8a8" ) - return rgb_to_rgb( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); else if( dst_pf == L"b8g8r8" ) - return rgb_to_rgb( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); else if( dst_pf == L"r8g8b8a8" ) - return rgb_to_rgb( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); } else if( src_pf == L"l8a8p" ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gl...@us...> - 2007-10-23 21:21:50
|
Revision: 363 http://hdrflow.svn.sourceforge.net/hdrflow/?rev=363&view=rev Author: glslang Date: 2007-10-23 14:21:48 -0700 (Tue, 23 Oct 2007) Log Message: ----------- + continuation of conversion refactoring for generic swizzle and lut support Modified Paths: -------------- trunk/lib/openlibraries/src/openimagelib/il/il.hpp trunk/lib/openlibraries/src/openimagelib/il/lut_converter.hpp trunk/lib/openlibraries/src/openimagelib/il/utility.cpp Modified: trunk/lib/openlibraries/src/openimagelib/il/il.hpp =================================================================== --- trunk/lib/openlibraries/src/openimagelib/il/il.hpp 2007-10-20 20:35:32 UTC (rev 362) +++ trunk/lib/openlibraries/src/openimagelib/il/il.hpp 2007-10-23 21:21:48 UTC (rev 363) @@ -14,7 +14,6 @@ #include <openimagelib/il/basic_image.hpp> #include <openimagelib/il/traits.hpp> #include <openimagelib/il/utility.hpp> -#include <openimagelib/il/lut_converter.hpp> namespace olib { namespace openimagelib { Modified: trunk/lib/openlibraries/src/openimagelib/il/lut_converter.hpp =================================================================== --- trunk/lib/openlibraries/src/openimagelib/il/lut_converter.hpp 2007-10-20 20:35:32 UTC (rev 362) +++ trunk/lib/openlibraries/src/openimagelib/il/lut_converter.hpp 2007-10-23 21:21:48 UTC (rev 363) @@ -10,35 +10,35 @@ #include <functional> +#include <openpluginlib/pl/fast_math.hpp> + namespace olib { namespace openimagelib { namespace il { struct byte_to_byte : public std::unary_function<unsigned char, unsigned char> { - typedef unsigned char value_type; - typedef unsigned char convert_type; - - convert_type operator( )( value_type v ) const + result_type operator( )( argument_type v ) const { return v; } }; struct byte_to_float : public std::unary_function<unsigned char, float> { - typedef unsigned char value_type; - typedef float convert_type; - - convert_type operator( )( value_type v ) const + result_type operator( )( argument_type v ) const { return v / 255.0f; } }; struct float_to_float : public std::unary_function<float, float> { - typedef float value_type; - typedef float convert_type; - - convert_type operator( )( value_type v ) const + result_type operator( )( argument_type v ) const { return v; } }; +// Assumes normalise( im, 255.0f ) has already been called. +struct float_to_byte : public std::unary_function<float, unsigned char> +{ + result_type operator( )( argument_type v ) const + { return static_cast<result_type>( openpluginlib::fast_floorf( v ) ); } +}; + } } } #endif Modified: trunk/lib/openlibraries/src/openimagelib/il/utility.cpp =================================================================== --- trunk/lib/openlibraries/src/openimagelib/il/utility.cpp 2007-10-20 20:35:32 UTC (rev 362) +++ trunk/lib/openlibraries/src/openimagelib/il/utility.cpp 2007-10-23 21:21:48 UTC (rev 363) @@ -14,6 +14,7 @@ #include <openpluginlib/pl/fast_math.hpp> #include <openpluginlib/pl/utf8_utils.hpp> #include <openimagelib/il/il.hpp> +#include <openimagelib/il/lut_converter.hpp> namespace opl = olib::openpluginlib; @@ -1112,7 +1113,7 @@ { L"", L"", 0, { 0, 0, 0, 0 }, 0, { 0, 0, 0, 0 } } }; -template<typename const_pointer, typename pointer> +template<typename const_pointer, typename pointer, class LUT> image_type_ptr rgb_to_rgb( const image_type_ptr &src_img, const std::wstring &format ) { size_type width = src_img->width( ); @@ -1122,6 +1123,8 @@ if ( dst_img != 0 ) { + LUT lut; + const_pointer src = src_img->data( ); size_type src_pitch = src_img->pitch( ); pointer dst = dst_img->data( ); @@ -1152,10 +1155,10 @@ { switch( oc ) { - case 4: *( dst + map.out[ 3 ] ) = has_alpha ? *( src + map.in[ 3 ] ) : 255; - case 3: *( dst + map.out[ 2 ] ) = *( src + map.in[ 2 ] ); - case 2: *( dst + map.out[ 1 ] ) = *( src + map.in[ 1 ] ); - case 1: *( dst + map.out[ 0 ] ) = *( src + map.in[ 0 ] ); + case 4: *( dst + map.out[ 3 ] ) = has_alpha ? lut( *( src + map.in[ 3 ] ) ) : 255; + case 3: *( dst + map.out[ 2 ] ) = lut( *( src + map.in[ 2 ] ) ); + case 2: *( dst + map.out[ 1 ] ) = lut( *( src + map.in[ 1 ] ) ); + case 1: *( dst + map.out[ 0 ] ) = lut( *( src + map.in[ 0 ] ) ); }; src += ic; @@ -1803,11 +1806,11 @@ else if ( src_pf == L"r8g8b8" ) { if ( dst_pf == L"b8g8r8" ) - return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer, byte_to_byte>( src, dst_pf ); else if ( dst_pf == L"r8g8b8a8" ) - return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer, byte_to_byte>( src, dst_pf ); else if ( dst_pf == L"b8g8r8a8" ) - return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer, byte_to_byte>( src, dst_pf ); else if ( dst_pf == L"yuv444" ) return rgb_to_yuv444( src, dst_pf, 3, 0, 1, 2 ); else if ( dst_pf == L"yuv422" ) @@ -1823,11 +1826,11 @@ else if ( src_pf == L"b8g8r8" ) { if ( dst_pf == L"r8g8b8" ) - return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer, byte_to_byte>( src, dst_pf ); else if ( dst_pf == L"r8g8b8a8" ) - return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer, byte_to_byte>( src, dst_pf ); else if ( dst_pf == L"b8g8r8a8" ) - return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer, byte_to_byte>( src, dst_pf ); else if ( dst_pf == L"yuv444" ) return rgb_to_yuv444( src, dst_pf, 3, 2, 1, 0 ); else if ( dst_pf == L"yuv422" ) @@ -1838,11 +1841,11 @@ else if ( src_pf == L"r8g8b8a8" ) { if ( dst_pf == L"r8g8b8" ) - return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer, byte_to_byte>( src, dst_pf ); else if ( dst_pf == L"b8g8r8" ) - return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer, byte_to_byte>( src, dst_pf ); else if ( dst_pf == L"b8g8r8a8" ) - return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer, byte_to_byte>( src, dst_pf ); else if ( dst_pf == L"yuv444" ) return rgb_to_yuv444( src, dst_pf, 4, 0, 1, 2 ); else if ( dst_pf == L"yuv422" ) @@ -1858,11 +1861,11 @@ else if ( src_pf == L"b8g8r8a8" ) { if ( dst_pf == L"r8g8b8" ) - return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer, byte_to_byte>( src, dst_pf ); else if ( dst_pf == L"r8g8b8a8" ) - return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer, byte_to_byte>( src, dst_pf ); else if ( dst_pf == L"b8g8r8" ) - return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer, byte_to_byte>( src, dst_pf ); else if ( dst_pf == L"yuv444" ) return rgb_to_yuv444( src, dst_pf, 4, 2, 1, 0 ); else if ( dst_pf == L"yuv422" ) @@ -1875,11 +1878,11 @@ else if ( src_pf == L"a8r8g8b8" ) { if( dst_pf == L"a8b8g8r8" ) - return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer, byte_to_byte>( src, dst_pf ); else if( dst_pf == L"b8g8r8") - return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer, byte_to_byte>( src, dst_pf ); else if( dst_pf == L"b8g8r8a8") - return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer, byte_to_byte>( src, dst_pf ); else if ( dst_pf == L"yuv444" ) return rgb_to_yuv444( src, dst_pf, 4, 1, 2, 3 ); else if ( dst_pf == L"yuv422" ) @@ -1890,11 +1893,11 @@ else if( src_pf == L"a8b8g8r8" ) { if( dst_pf == L"b8g8r8a8" ) - return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer, byte_to_byte>( src, dst_pf ); else if( dst_pf == L"r8g8b8a8" ) - return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer, byte_to_byte>( src, dst_pf ); else if( dst_pf == L"r8g8b8" ) - return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer, byte_to_byte>( src, dst_pf ); else if ( dst_pf == L"yuv444" ) return rgb_to_yuv444( src, dst_pf, 4, 3, 2, 1 ); else if ( dst_pf == L"yuv422" ) @@ -1905,12 +1908,12 @@ else if( src_pf == L"r8g8b8log" ) { if( dst_pf == L"b8g8r8a8" ) - return convert_log_to_linear( rgb_to_rgb<const_pointer, pointer>( src, dst_pf ) ); + return convert_log_to_linear( rgb_to_rgb<const_pointer, pointer, byte_to_byte>( src, dst_pf ) ); } else if( src_pf == L"r8g8b8a8log" ) { if( dst_pf == L"b8g8r8a8" ) - return convert_log_to_linear( rgb_to_rgb<const_pointer, pointer>( src, dst_pf ) ); + return convert_log_to_linear( rgb_to_rgb<const_pointer, pointer, byte_to_byte>( src, dst_pf ) ); } else if( src_pf == L"r10g10b10" ) { @@ -2058,11 +2061,11 @@ else if( src_pf == L"l8a8" ) { if( dst_pf == L"b8g8r8a8" ) - return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer, byte_to_byte>( src, dst_pf ); else if( dst_pf == L"b8g8r8" ) - return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer, byte_to_byte>( src, dst_pf ); else if( dst_pf == L"r8g8b8a8" ) - return rgb_to_rgb<const_pointer, pointer>( src, dst_pf ); + return rgb_to_rgb<const_pointer, pointer, byte_to_byte>( src, dst_pf ); } else if( src_pf == L"l8a8p" ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gl...@us...> - 2008-01-03 21:35:25
|
Revision: 393 http://hdrflow.svn.sourceforge.net/hdrflow/?rev=393&view=rev Author: glslang Date: 2008-01-03 13:35:22 -0800 (Thu, 03 Jan 2008) Log Message: ----------- + adds lut conversion of 16bpc fixed to float Modified Paths: -------------- trunk/lib/openlibraries/src/openimagelib/il/lut_converter.hpp trunk/lib/openlibraries/src/openimagelib/il/utility.cpp Modified: trunk/lib/openlibraries/src/openimagelib/il/lut_converter.hpp =================================================================== --- trunk/lib/openlibraries/src/openimagelib/il/lut_converter.hpp 2008-01-02 23:02:01 UTC (rev 392) +++ trunk/lib/openlibraries/src/openimagelib/il/lut_converter.hpp 2008-01-03 21:35:22 UTC (rev 393) @@ -39,6 +39,12 @@ { return static_cast<result_type>( openpluginlib::fast_floorf( v ) ); } }; +struct fixed16_to_float : public std::unary_function<unsigned short, float> +{ + result_type operator( )( argument_type v ) const + { return static_cast<result_type>( static_cast<short>( v ) / 8192.0f ); } +}; + } } } #endif Modified: trunk/lib/openlibraries/src/openimagelib/il/utility.cpp =================================================================== --- trunk/lib/openlibraries/src/openimagelib/il/utility.cpp 2008-01-02 23:02:01 UTC (rev 392) +++ trunk/lib/openlibraries/src/openimagelib/il/utility.cpp 2008-01-03 21:35:22 UTC (rev 393) @@ -1113,10 +1113,11 @@ { L"a8b8g8r8", L"r8g8b8", 4, { 3, 2, 1, 0 }, 3, { 0, 1, 2, 0 } }, { L"l8a8", L"b8g8r8a8", 2, { 0, 0, 0, 1 }, 4, { 2, 1, 0, 3 } }, { L"l8a8", L"b8g8r8", 2, { 0, 0, 0, 1 }, 3, { 2, 1, 0, 0 } }, + { L"r16g16b16fixed", L"r32g32b32a32f", 3, { 0, 1, 2, 0 }, 4, { 0, 1, 2, 3 } }, { L"", L"", 0, { 0, 0, 0, 0 }, 0, { 0, 0, 0, 0 } } }; -template<typename const_pointer, typename pointer, class LUT> +template<typename T, typename U, class LUT> image_type_ptr rgb_to_rgb( const image_type_ptr &src_img, const std::wstring &format ) { size_type width = src_img->width( ); @@ -1128,13 +1129,13 @@ { LUT lut; - const_pointer src = src_img->data( ); + T src = reinterpret_cast<T>( src_img->data( ) ); size_type src_pitch = src_img->pitch( ); - pointer dst = dst_img->data( ); + U dst = reinterpret_cast<U>( dst_img->data( ) ); size_type dst_pitch = dst_img->pitch( ); - const_pointer sptr = src; - pointer dptr = dst; + T sptr = src; + U dptr = dst; size_type orig_width = width; @@ -2090,6 +2091,11 @@ if( dst_pf == L"b8g8r8a8" ) return l10_l12_l16p_ushort_with_alpha_to_b8g8r8a8( src, dst_pf ); } + else if( src_pf == L"r16g16b16fixed" ) + { + if( dst_pf == L"r32g32b32a32f" ) + return rgb_to_rgb<const unsigned short*, float*, fixed16_to_float>( src, dst_pf ); + } #ifndef WIN32 fprintf( stderr, "Unknown %s to %s\n", opl::to_string( src_pf ).c_str( ), opl::to_string( dst_pf ).c_str( ) ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gl...@us...> - 2008-01-10 22:09:50
|
Revision: 400 http://hdrflow.svn.sourceforge.net/hdrflow/?rev=400&view=rev Author: glslang Date: 2008-01-10 14:09:39 -0800 (Thu, 10 Jan 2008) Log Message: ----------- + dpx log to linear transfer function Modified Paths: -------------- trunk/lib/openlibraries/src/openimagelib/il/lut_functions.cpp trunk/lib/openlibraries/src/openimagelib/il/lut_functions.hpp Modified: trunk/lib/openlibraries/src/openimagelib/il/lut_functions.cpp =================================================================== --- trunk/lib/openlibraries/src/openimagelib/il/lut_functions.cpp 2008-01-08 23:14:58 UTC (rev 399) +++ trunk/lib/openlibraries/src/openimagelib/il/lut_functions.cpp 2008-01-10 22:09:39 UTC (rev 400) @@ -10,10 +10,17 @@ #include <cmath> #endif +#include <limits> + #include <openimagelib/il/il.hpp> namespace olib { namespace openimagelib { namespace il { +namespace +{ + const float dpx_black_offset = 0.0107977516233f; +} + float to_sRGB( float v ) { if( v < ( 0.04045f / 12.92f ) ) @@ -38,4 +45,9 @@ return powf( ( v + 0.099f) / 1.099f, 1.0f / 0.45f ); } +float from_dpxLog( float v ) +{ + return ( powf( 10.0f, ( v - 685.0f ) * ( 0.002f / 0.6f )) - dpx_black_offset ) / ( 1.0f - dpx_black_offset ); +} + } } } Modified: trunk/lib/openlibraries/src/openimagelib/il/lut_functions.hpp =================================================================== --- trunk/lib/openlibraries/src/openimagelib/il/lut_functions.hpp 2008-01-08 23:14:58 UTC (rev 399) +++ trunk/lib/openlibraries/src/openimagelib/il/lut_functions.hpp 2008-01-10 22:09:39 UTC (rev 400) @@ -13,6 +13,7 @@ IL_DECLSPEC float to_sRGB( float v ); IL_DECLSPEC float to_rec709( float v ); IL_DECLSPEC float from_rec709( float v ); +IL_DECLSPEC float from_dpxLog( float v ); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gl...@us...> - 2008-01-14 21:17:57
|
Revision: 401 http://hdrflow.svn.sourceforge.net/hdrflow/?rev=401&view=rev Author: glslang Date: 2008-01-14 13:17:51 -0800 (Mon, 14 Jan 2008) Log Message: ----------- + more dpx log transfer functions Modified Paths: -------------- trunk/lib/openlibraries/src/openimagelib/il/lut_functions.cpp trunk/lib/openlibraries/src/openimagelib/il/lut_functions.hpp Modified: trunk/lib/openlibraries/src/openimagelib/il/lut_functions.cpp =================================================================== --- trunk/lib/openlibraries/src/openimagelib/il/lut_functions.cpp 2008-01-10 22:09:39 UTC (rev 400) +++ trunk/lib/openlibraries/src/openimagelib/il/lut_functions.cpp 2008-01-14 21:17:51 UTC (rev 401) @@ -16,11 +16,6 @@ namespace olib { namespace openimagelib { namespace il { -namespace -{ - const float dpx_black_offset = 0.0107977516233f; -} - float to_sRGB( float v ) { if( v < ( 0.04045f / 12.92f ) ) @@ -47,7 +42,14 @@ float from_dpxLog( float v ) { - return ( powf( 10.0f, ( v - 685.0f ) * ( 0.002f / 0.6f )) - dpx_black_offset ) / ( 1.0f - dpx_black_offset ); + const float dpx_black_offset = 0.0107977516233f; + + return ( powf( 10.0f, ( v - 685.0f ) * ( 0.002f / 0.6f ) ) - dpx_black_offset ) / ( 1.0f - dpx_black_offset ); } +float from_dpxLog_byte_scaled( float v ) +{ + return from_dpxLog( v ) * 1.0f / 1023.0f; +} + } } } Modified: trunk/lib/openlibraries/src/openimagelib/il/lut_functions.hpp =================================================================== --- trunk/lib/openlibraries/src/openimagelib/il/lut_functions.hpp 2008-01-10 22:09:39 UTC (rev 400) +++ trunk/lib/openlibraries/src/openimagelib/il/lut_functions.hpp 2008-01-14 21:17:51 UTC (rev 401) @@ -14,6 +14,7 @@ IL_DECLSPEC float to_rec709( float v ); IL_DECLSPEC float from_rec709( float v ); IL_DECLSPEC float from_dpxLog( float v ); +IL_DECLSPEC float from_dpxLog_byte_scaled( float v ); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |