[Hdrflow-svn] SF.net SVN: hdrflow: [91] lib/openlibraries
Status: Pre-Alpha
Brought to you by:
glslang
|
From: <gl...@us...> - 2007-04-21 19:15:03
|
Revision: 91
http://hdrflow.svn.sourceforge.net/hdrflow/?rev=91&view=rev
Author: glslang
Date: 2007-04-21 12:15:00 -0700 (Sat, 21 Apr 2007)
Log Message:
-----------
+ fast math support
Modified Paths:
--------------
lib/openlibraries/src/openimagelib/il/utility.cpp
lib/openlibraries/src/openimagelib/plugins/tiff/tiff_vc8.vcproj
lib/openlibraries/src/openpluginlib/pl/pl_vc8.vcproj
lib/openlibraries/test/openeffectslib/tm_bench/tm_bench.cpp
lib/openlibraries/test/openeffectslib/tm_bench/tm_bench_vc8.vcproj
Added Paths:
-----------
lib/openlibraries/src/openpluginlib/pl/fast_math.cpp
lib/openlibraries/src/openpluginlib/pl/fast_math.hpp
Modified: lib/openlibraries/src/openimagelib/il/utility.cpp
===================================================================
--- lib/openlibraries/src/openimagelib/il/utility.cpp 2007-04-21 16:40:23 UTC (rev 90)
+++ lib/openlibraries/src/openimagelib/il/utility.cpp 2007-04-21 19:15:00 UTC (rev 91)
@@ -11,9 +11,10 @@
using namespace std;
+#include <openpluginlib/pl/fast_math.hpp>
+#include <openpluginlib/pl/utf8_utils.hpp>
#include <openimagelib/il/il.hpp>
-#include <openpluginlib/pl/utf8_utils.hpp>
namespace opl = olib::openpluginlib;
namespace olib { namespace openimagelib { namespace il {
@@ -1877,9 +1878,15 @@
{
while( width-- )
{
+/*
*( dst + 2 ) = static_cast<unsigned char>( *src++ );
*( dst + 1 ) = static_cast<unsigned char>( *src++ );
*( dst + 0 ) = static_cast<unsigned char>( *src++ );
+*/
+ *( dst + 2 ) = static_cast<unsigned char>( opl::fast_floorf( *src++ ) );
+ *( dst + 1 ) = static_cast<unsigned char>( opl::fast_floorf( *src++ ) );
+ *( dst + 0 ) = static_cast<unsigned char>( opl::fast_floorf( *src++ ) );
+
*( dst + 3 ) = 255;
dst += 4;
@@ -3241,6 +3248,10 @@
// range is the difference the maximum and minimum luminance values.
float range = maxval - minval;
+ if( range < 1e-6f )
+ return dst_img;
+
+ float one_over_range = 1.0f / range;
// reset the src image pointer.
src = ( const float* ) im->data( );
@@ -3251,9 +3262,9 @@
{
for( size_type j = 0; j < width; ++j )
{
- float r = output_range * ( ( *src++ - minval ) / range );
- float g = output_range * ( ( *src++ - minval ) / range );
- float b = output_range * ( ( *src++ - minval ) / range );
+ float r = output_range * ( ( *src++ - minval ) * one_over_range );
+ float g = output_range * ( ( *src++ - minval ) * one_over_range );
+ float b = output_range * ( ( *src++ - minval ) * one_over_range );
r < 0.0f ? *dst++ = 0.0f : r > output_range ? *dst++ = output_range : *dst++ = r;
g < 0.0f ? *dst++ = 0.0f : g > output_range ? *dst++ = output_range : *dst++ = g;
@@ -3357,13 +3368,15 @@
const float* sptr = src;
float* dptr = dst;
+ const float one_over_gamma = 1.0f / gamma;
+
while( height-- )
{
while( width-- )
{
- *dst++ = powf( *src++, 1.0f / gamma );
- *dst++ = powf( *src++, 1.0f / gamma );
- *dst++ = powf( *src++, 1.0f / gamma );
+ *dst++ = opl::fast_powf( *src++, one_over_gamma );
+ *dst++ = opl::fast_powf( *src++, one_over_gamma );
+ *dst++ = opl::fast_powf( *src++, one_over_gamma );
}
dst = dptr += dst_pitch;
Modified: lib/openlibraries/src/openimagelib/plugins/tiff/tiff_vc8.vcproj
===================================================================
--- lib/openlibraries/src/openimagelib/plugins/tiff/tiff_vc8.vcproj 2007-04-21 16:40:23 UTC (rev 90)
+++ lib/openlibraries/src/openimagelib/plugins/tiff/tiff_vc8.vcproj 2007-04-21 19:15:00 UTC (rev 91)
@@ -151,7 +151,7 @@
OutputFile="$(OutDir)\openimagelib_tiff-vc80-r-0_4_0.dll"
LinkIncremental="1"
AdditionalLibraryDirectories="C:\Boost\lib;$(SolutionDir)\src\openpluginlib\pl\$(ConfigurationName);C:\libtiff\lib"
- IgnoreDefaultLibraryNames="msvcrt.lib"
+ IgnoreDefaultLibraryNames=""
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
Added: lib/openlibraries/src/openpluginlib/pl/fast_math.cpp
===================================================================
--- lib/openlibraries/src/openpluginlib/pl/fast_math.cpp (rev 0)
+++ lib/openlibraries/src/openpluginlib/pl/fast_math.cpp 2007-04-21 19:15:00 UTC (rev 91)
@@ -0,0 +1,52 @@
+
+// openpluginlib - A plugin interface to openlibraries.
+
+// Copyright (C) 2007 VM Inc.
+// Released under the LGPL.
+// For more information, see http://www.openlibraries.org.
+
+#include <openpluginlib/pl/fast_math.hpp>
+
+namespace olib { namespace openpluginlib {
+
+// precomputed constants.
+const float two_to_pow_23 = 1 << 23;
+const float one_over_two_to_pow_23 = 1.0f / ( 1 << 23 );
+
+int fast_floorf( float x )
+{
+ double y = ( x + 68719476736.0 * 1.5 );
+
+ return ( int ) ( ( *( ( long long* ) &y ) ) >> 16 );
+}
+
+float fast_log2f( float v )
+{
+ float x = ( float ) *( int* ) &v;
+ x *= one_over_two_to_pow_23;
+ x = x - 127.0f;
+
+ float y = x - fast_floorf( x );
+ y = ( y - y * y ) * 0.346607f;
+
+ return x + y;
+}
+
+float fast_exp2f( float v )
+{
+ float y = v - fast_floorf( v );
+ y = ( y - y * y ) * 0.33971f;
+
+ float x = v + 127.0f - y;
+ x *= two_to_pow_23;
+ *( int* ) &x = ( int ) x;
+
+ return x;
+}
+
+float fast_powf( float x, float y )
+{
+ return fast_exp2f( y * fast_log2f( x ) );
+}
+
+} }
Property changes on: lib/openlibraries/src/openpluginlib/pl/fast_math.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
Added: lib/openlibraries/src/openpluginlib/pl/fast_math.hpp
===================================================================
--- lib/openlibraries/src/openpluginlib/pl/fast_math.hpp (rev 0)
+++ lib/openlibraries/src/openpluginlib/pl/fast_math.hpp 2007-04-21 19:15:00 UTC (rev 91)
@@ -0,0 +1,22 @@
+
+// openpluginlib - A plugin interface to openlibraries.
+
+// Copyright (C) 2007 VM Inc.
+// Released under the LGPL.
+// For more information, see http://www.openlibraries.org.
+
+#ifndef FAST_MATH_INC_
+#define FAST_MATH_INC_
+
+#include <openpluginlib/pl/config.hpp>
+
+namespace olib { namespace openpluginlib {
+
+OPENPLUGINLIB_DECLSPEC float fast_log2f( float x );
+OPENPLUGINLIB_DECLSPEC float fast_exp2f( float x );
+OPENPLUGINLIB_DECLSPEC float fast_powf( float x, float y );
+OPENPLUGINLIB_DECLSPEC int fast_floorf( float x );
+
+} }
+
+#endif
Property changes on: lib/openlibraries/src/openpluginlib/pl/fast_math.hpp
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: lib/openlibraries/src/openpluginlib/pl/pl_vc8.vcproj
===================================================================
--- lib/openlibraries/src/openpluginlib/pl/pl_vc8.vcproj 2007-04-21 16:40:23 UTC (rev 90)
+++ lib/openlibraries/src/openpluginlib/pl/pl_vc8.vcproj 2007-04-21 19:15:00 UTC (rev 91)
@@ -211,6 +211,10 @@
>
</File>
<File
+ RelativePath=".\fast_math.cpp"
+ >
+ </File>
+ <File
RelativePath=".\GL_utility.cpp"
>
</File>
@@ -305,6 +309,10 @@
>
</File>
<File
+ RelativePath=".\fast_math.hpp"
+ >
+ </File>
+ <File
RelativePath=".\flex_string.h"
>
</File>
@@ -365,11 +373,11 @@
>
</File>
<File
- RelativePath=".\property.hpp"
+ RelativePath=".\pcos\property.hpp"
>
</File>
<File
- RelativePath=".\pcos\property.hpp"
+ RelativePath=".\property.hpp"
>
</File>
<File
Modified: lib/openlibraries/test/openeffectslib/tm_bench/tm_bench.cpp
===================================================================
--- lib/openlibraries/test/openeffectslib/tm_bench/tm_bench.cpp 2007-04-21 16:40:23 UTC (rev 90)
+++ lib/openlibraries/test/openeffectslib/tm_bench/tm_bench.cpp 2007-04-21 19:15:00 UTC (rev 91)
@@ -28,8 +28,11 @@
if( input && filter )
{
- filter->connect( input );
- filter->fetch( );
+ for( int i = 0; i < 10; ++i )
+ {
+ filter->connect( input );
+ filter->fetch( );
+ }
}
r.stop( );
Modified: lib/openlibraries/test/openeffectslib/tm_bench/tm_bench_vc8.vcproj
===================================================================
--- lib/openlibraries/test/openeffectslib/tm_bench/tm_bench_vc8.vcproj 2007-04-21 16:40:23 UTC (rev 90)
+++ lib/openlibraries/test/openeffectslib/tm_bench/tm_bench_vc8.vcproj 2007-04-21 19:15:00 UTC (rev 91)
@@ -149,6 +149,7 @@
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
+ FixedBaseAddress="1"
/>
<Tool
Name="VCALinkTool"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|