[Hdrflow-svn] SF.net SVN: hdrflow: [105] lib/openlibraries/src
Status: Pre-Alpha
Brought to you by:
glslang
|
From: <gl...@us...> - 2007-04-27 22:05:42
|
Revision: 105
http://hdrflow.svn.sourceforge.net/hdrflow/?rev=105&view=rev
Author: glslang
Date: 2007-04-27 15:05:41 -0700 (Fri, 27 Apr 2007)
Log Message:
-----------
+ rgbe native colour space
+ greg ward's hdr store
+ colour conversion for rgbe
+ more ofx implementation (very far from complete)
Modified Paths:
--------------
lib/openlibraries/src/openeffectslib/plugins/tonemap/tonemap_plugin.cpp
lib/openlibraries/src/openimagelib/il/float_traits.hpp
lib/openlibraries/src/openimagelib/il/utility.cpp
lib/openlibraries/src/openimagelib/plugins/hdr/hdr_plugin.cpp
lib/openlibraries/src/openimagelib/plugins/jpg/jpg_plugin.opl
lib/openlibraries/src/openmedialib/plugins/ofx/ofx_plugin.cpp
lib/openlibraries/src/openpluginlib/pl/openpluginlib.cpp
Modified: lib/openlibraries/src/openeffectslib/plugins/tonemap/tonemap_plugin.cpp
===================================================================
--- lib/openlibraries/src/openeffectslib/plugins/tonemap/tonemap_plugin.cpp 2007-04-24 22:56:51 UTC (rev 104)
+++ lib/openlibraries/src/openeffectslib/plugins/tonemap/tonemap_plugin.cpp 2007-04-27 22:05:41 UTC (rev 105)
@@ -173,11 +173,12 @@
image_type_ptr tm_ilm_exr( const image_type_ptr& im, float exposure, float defog, float kneeLow, float kneeHigh )
{
- image_type_ptr dst_img = im;
+ image_type_ptr src_img = convert( im, L"r32g32b32f" );
+ image_type_ptr dst_img = src_img;
- if( im->pf( ) == L"r16g16b16f" || im->pf( ) == L"r32g32b32f" )
+ if( src_img->pf( ) == L"r16g16b16f" || src_img->pf( ) == L"r32g32b32f" )
{
- image_type_ptr half_im = convert_to_half( im );
+ image_type_ptr half_im = convert_to_half( src_img );
float fog_r, fog_g, fog_b;
compute_fog_color( half_im, fog_r, fog_g, fog_b );
@@ -186,8 +187,8 @@
halfFunction<float> g_gamma( gamma( exposure, defog * fog_g, kneeLow, kneeHigh ), -HALF_MAX, HALF_MAX );
halfFunction<float> b_gamma( gamma( exposure, defog * fog_b, kneeLow, kneeHigh ), -HALF_MAX, HALF_MAX );
- size_type width = im->width( );
- size_type height = im->height( );
+ size_type width = src_img->width( );
+ size_type height = src_img->height( );
dst_img = il::allocate( L"b8g8r8a8", width, height );
@@ -245,98 +246,94 @@
image_type_ptr tm_ferwerda( image_type_ptr im, float factor, float Ldmax )
{
- image_type_ptr dst_img = im;
+ image_type_ptr src_img = convert( im, L"r32g32b32f" );
+ image_type_ptr dst_img = il::allocate( L"r32g32b32f", im->width( ), im->height( ) );
- if( im->pf( ) == L"r32g32b32f" )
- {
- dst_img = il::allocate( im->pf( ), im->width( ), im->height( ) );
+ size_type width = src_img->width( );
+ size_type height = src_img->height( );
- size_type width = im->width( );
- size_type height = im->height( );
+ const float* src = ( const float* ) src_img->data( );
+ size_type src_pitch = src_img->pitch( );
- const float* src = ( const float* ) im->data( );
- size_type src_pitch = im->pitch( );
+ float* dst = ( float* ) dst_img->data( );
+ size_type dst_pitch = dst_img->pitch( );
- float* dst = ( float* ) dst_img->data( );
- size_type dst_pitch = dst_img->pitch( );
+ const float* sptr = src;
+ float* dptr = dst;
- const float* sptr = src;
- float* dptr = dst;
-
- // apply linear scaling factor.
- for( int i = 0; i < height; ++i )
+ // apply linear scaling factor.
+ for( int i = 0; i < height; ++i )
+ {
+ for( int j = 0; j < width; ++j )
{
- for( int j = 0; j < width; ++j )
- {
- *dst++ = *src++ * factor;
- *dst++ = *src++ * factor;
- *dst++ = *src++ * factor;
- }
-
- dst = dptr += dst_pitch;
- src = sptr += src_pitch;
+ *dst++ = *src++ * factor;
+ *dst++ = *src++ * factor;
+ *dst++ = *src++ * factor;
}
+
+ dst = dptr += dst_pitch;
+ src = sptr += src_pitch;
+ }
- // reset the pointer.
- dst = ( float* ) dst_img->data( );
- dptr = dst;
+ // reset the pointer.
+ dst = ( float* ) dst_img->data( );
+ dptr = dst;
- float Lmax = 0.0f;
+ float Lmax = 0.0f;
- // calculate maximum luminance value.
- for( int i = 0; i < height; ++i )
+ // calculate maximum luminance value.
+ for( int i = 0; i < height; ++i )
+ {
+ for( int j = 0; j < width; ++j )
{
- for( int j = 0; j < width; ++j )
- {
- float r = *dst++;
- float g = *dst++;
- float b = *dst++;
+ float r = *dst++;
+ float g = *dst++;
+ float b = *dst++;
- float lum = r * 0.2125f + g * 0.7154f + b * 0.0721f;
+ float lum = r * 0.2125f + g * 0.7154f + b * 0.0721f;
- if( lum > Lmax )
- Lmax = lum;
- }
-
- dst = dptr += dst_pitch;
+ if( lum > Lmax )
+ Lmax = lum;
}
+
+ dst = dptr += dst_pitch;
+ }
- float Lwa = Lmax * 0.5f;
- float log_Lwa = log10f( Lwa );
- float log_Lda = log10f( Ldmax * 0.5f );
+ float Lwa = Lmax * 0.5f;
+ float log_Lwa = log10f( Lwa );
+ float log_Lda = log10f( Ldmax * 0.5f );
- // calculate photopic and scotopic factors.
- float mp = powf( 10.0f, tp( log_Lda ) - tp( log_Lwa ) );
- float ms = powf( 10.0f, ts( log_Lda ) - ts( log_Lwa ) );
- float df = Lmax / Ldmax;
+ // calculate photopic and scotopic factors.
+ float mp = powf( 10.0f, tp( log_Lda ) - tp( log_Lwa ) );
+ float ms = powf( 10.0f, ts( log_Lda ) - ts( log_Lwa ) );
+ float df = Lmax / Ldmax;
- // reset the dst pointer.
- dst = ( float* ) dst_img->data( );
- dptr = dst;
+ // reset the dst pointer.
+ dst = ( float* ) dst_img->data( );
+ dptr = dst;
- // tonemap
- for( int i = 0; i < height; ++i )
+ // tonemap
+ for( int i = 0; i < height; ++i )
+ {
+ for( int j = 0; j < width; ++j )
{
- for( int j = 0; j < width; ++j )
- {
- float r = *( dst + 0 );
- float g = *( dst + 1 );
- float b = *( dst + 2 );
+ float r = *( dst + 0 );
+ float g = *( dst + 1 );
+ float b = *( dst + 2 );
- float lum = r * 0.2125f + g * 0.7154f + b * 0.0721f;
- float sf = ms * lum;
+ float lum = r * 0.2125f + g * 0.7154f + b * 0.0721f;
+ float sf = ms * lum;
- float dr = df * ( mp * r + sf );
- float dg = df * ( mp * g + sf );
- float db = df * ( mp * b + sf );
+ float dr = df * ( mp * r + sf );
+ float dg = df * ( mp * g + sf );
+ float db = df * ( mp * b + sf );
- *dst++ = dr > Ldmax ? Ldmax : dr;
- *dst++ = dg > Ldmax ? Ldmax : dg;
- *dst++ = db > Ldmax ? Ldmax : db;
- }
-
- dst = dptr += dst_pitch;
+ *dst++ = dr > Ldmax ? Ldmax : dr;
+ *dst++ = dg > Ldmax ? Ldmax : dg;
+ *dst++ = db > Ldmax ? Ldmax : db;
}
+
+ dst = dptr += dst_pitch;
}
return dst_img;
Modified: lib/openlibraries/src/openimagelib/il/float_traits.hpp
===================================================================
--- lib/openlibraries/src/openimagelib/il/float_traits.hpp 2007-04-24 22:56:51 UTC (rev 104)
+++ lib/openlibraries/src/openimagelib/il/float_traits.hpp 2007-04-27 22:05:41 UTC (rev 105)
@@ -22,7 +22,7 @@
typedef typename surface_format<T, storage>::size_type size_type;
private:
- static const size_type bs = 3;
+ static const size_type bs = 4;
public:
explicit rgbe( size_type width,
@@ -42,7 +42,7 @@
public:
virtual size_type allocsize( size_type width, size_type height, size_type depth ) const
- { return sizeof( float ) * detail::rgb_Allocate_size<T>( )( bs, width, height, depth ); }
+ { return detail::rgb_Allocate_size<T>( )( bs, width, height, depth ); }
virtual rgbe* clone( size_type w, size_type h )
{ return new rgbe( *this, w, h ); }
Modified: lib/openlibraries/src/openimagelib/il/utility.cpp
===================================================================
--- lib/openlibraries/src/openimagelib/il/utility.cpp 2007-04-24 22:56:51 UTC (rev 104)
+++ lib/openlibraries/src/openimagelib/il/utility.cpp 2007-04-27 22:05:41 UTC (rev 105)
@@ -73,6 +73,44 @@
lut[ i ] = static_cast<unsigned short>( floorf( val + 0.5f ) );
}
}
+
+ void float2rgbe( float red, float green, float blue, unsigned char rgbe[ 4 ] )
+ {
+ float v = red;
+ if( v < green ) v = green;
+ if( v < blue ) v = blue;
+
+ if( v < ( std::numeric_limits<float>::min )( ) )
+ {
+ rgbe[ 0 ] = rgbe[ 1 ] = rgbe[ 2 ] = rgbe[ 3 ] = 0;
+ }
+ else
+ {
+ int exponent;
+ v = frexp( v, &exponent ) * 256.0f / v;
+
+ rgbe[ 0 ] = static_cast<unsigned char>( red * v );
+ rgbe[ 1 ] = static_cast<unsigned char>( green * v );
+ rgbe[ 2 ] = static_cast<unsigned char>( blue * v );
+ rgbe[ 3 ] = static_cast<unsigned char>( exponent + 128 );
+ }
+ }
+
+ void rgbe2float( unsigned char rgbe[ 4 ], float& red, float& green, float& blue )
+ {
+ if( rgbe[ 3 ] )
+ {
+ float f = ldexp( 1.0f, rgbe[ 3 ] - ( 128 + 8 ) );
+
+ red = rgbe[ 0 ] * f;
+ green = rgbe[ 1 ] * f;
+ blue = rgbe[ 2 ] * f;
+ }
+ else
+ {
+ red = green = blue = 0.0f;
+ }
+ }
}
// The following private functions are a bit rough and shouldn't be exposed publicly
@@ -115,6 +153,7 @@
typedef image< unsigned char, r16g16b16a16log > r16g16b16a16log_image_type;
typedef image< unsigned char, r32g32b32f > r32g32b32f_image_type;
typedef image< unsigned char, r32g32b32a32f > r32g32b32a32f_image_type;
+typedef image< unsigned char, rgbe > rgbe_image_type;
typedef image< unsigned char, yuv444 > yuv444_image_type;
typedef image< unsigned char, yuv422 > yuv422_image_type;
typedef image< unsigned char, yuv422p > yuv422p_image_type;
@@ -194,6 +233,8 @@
dst_img = image_type_ptr( new image_type( r32g32b32f_image_type( width, height, 1 ) ) );
else if( pf == L"r32g32b32a32f" )
dst_img = image_type_ptr( new image_type( r32g32b32a32f_image_type( width, height, 1 ) ) );
+ else if( pf == L"rgbe" )
+ dst_img = image_type_ptr( new image_type( rgbe_image_type( width, height, 1 ) ) );
else if ( pf == L"yuv444" )
dst_img = image_type_ptr( new image_type( yuv444_image_type( width, height, 1 ) ) );
else if ( pf == L"yuv422" )
@@ -914,7 +955,6 @@
size_type src_pitch0 = 2 * src_img->pitch( 0 ) - src_img->linesize( 0 );
size_type src_pitch1 = src_img->pitch( 1 ) - src_img->linesize( 1 );
size_type src_pitch2 = src_img->pitch( 2 ) - src_img->linesize( 2 );
- size_type chroma_pitch = src_img->pitch( 1 );
pointer dst0 = dst_img->data( );
pointer dst1 = dst_img->data( ) + dst_img->pitch( );
@@ -1890,7 +1930,6 @@
*( 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;
@@ -1905,6 +1944,80 @@
return dst_img;
}
+static image_type_ptr rgbe_to_r32g32b32f( image_type_ptr src_img, const std::wstring &format )
+{
+ size_type width = src_img->width( );
+ size_type height = src_img->height( );
+
+ image_type_ptr dst_img = allocate( src_img, format );
+ if( dst_img != 0 )
+ {
+ pointer src = src_img->data( );
+ size_type src_pitch = src_img->pitch( );
+ float* dst = ( float* ) dst_img->data( );
+ size_type dst_pitch = dst_img->pitch( );
+
+ pointer sptr = src;
+ float* dptr = dst;
+
+ size_type orig_width = width;
+
+ while( height-- )
+ {
+ while( width-- )
+ {
+ rgbe2float( src, *( dst + 0 ), *( dst + 1 ), *( dst + 2 ) );
+
+ dst += 3;
+ src += 4;
+ }
+
+ dst = dptr += dst_pitch;
+ src = sptr += src_pitch;
+ width = orig_width;
+ }
+ }
+
+ return dst_img;
+}
+
+static image_type_ptr r32g32b32f_to_rgbe( image_type_ptr src_img, const std::wstring &format )
+{
+ size_type width = src_img->width( );
+ size_type height = src_img->height( );
+
+ image_type_ptr dst_img = allocate( src_img, format );
+ if( dst_img != 0 )
+ {
+ float* src = ( float* )src_img->data( );
+ size_type src_pitch = src_img->pitch( );
+ pointer dst = dst_img->data( );
+ size_type dst_pitch = dst_img->pitch( );
+
+ float* sptr = src;
+ pointer dptr = dst;
+
+ size_type orig_width = width;
+
+ while( height-- )
+ {
+ while( width-- )
+ {
+ float2rgbe( *( src + 0 ), *( src + 1 ), *( src + 2 ), dst );
+
+ dst += 4;
+ src += 3;
+ }
+
+ dst = dptr += dst_pitch;
+ src = sptr += src_pitch;
+ width = orig_width;
+ }
+ }
+
+ return dst_img;
+}
+
static image_type_ptr yuv420p_to_yuv411p( const image_type_ptr &src_img, const std::wstring &format )
{
size_type width = src_img->width( );
@@ -2488,9 +2601,18 @@
{
if( dst_pf == L"b8g8r8a8" )
return tm_linear( src );
+ else if( dst_pf == L"rgbe" )
+ return r32g32b32f_to_rgbe( src, L"rgbe" );
else if( dst_pf == L"ldr8" ) // stub colour space for straight truncation to LDR data.
return r32g32b32f_to_b8g8r8a8( src, L"b8g8r8a8" );
}
+ else if( src_pf == L"rgbe" )
+ {
+ if( dst_pf == L"b8g8r8a8" )
+ return tm_linear( rgbe_to_r32g32b32f( src, L"r32g32b32f" ) );
+ else if( dst_pf == L"r32g32b32f" )
+ return rgbe_to_r32g32b32f( src, L"r32g32b32f" );
+ }
else if ( src_pf == L"yuv444" )
{
if ( dst_pf == L"r8g8b8" )
Modified: lib/openlibraries/src/openimagelib/plugins/hdr/hdr_plugin.cpp
===================================================================
--- lib/openlibraries/src/openimagelib/plugins/hdr/hdr_plugin.cpp 2007-04-24 22:56:51 UTC (rev 104)
+++ lib/openlibraries/src/openimagelib/plugins/hdr/hdr_plugin.cpp 2007-04-27 22:05:41 UTC (rev 105)
@@ -7,19 +7,11 @@
#ifdef WIN32
#include <windows.h>
-#include <gdiplus.h>
-
-#ifdef min
-# undef min
#endif
-#endif // WIN32
#include <cmath>
-#include <cstdio>
-#include <cstdlib>
#include <limits>
#include <vector>
-#include <string>
#include <boost/filesystem/fstream.hpp>
@@ -45,9 +37,6 @@
char format[ 16 ];
};
- void destroy( il::image_type* im )
- { delete im; }
-
bool Read_s( fs::ifstream& file, char* s, std::streamsize size, std::streamsize max )
{
#if _MSC_VER >= 1400
@@ -59,57 +48,15 @@
return !file.fail( );
}
- void float2rgbe( float red, float green, float blue, unsigned char rgbe[ 4 ] )
+ bool read_rgbe_pixels_raw( fs::ifstream& file, unsigned char* data, int width, int height )
{
- float v = red;
- if( v < green ) v = green;
- if( v < blue ) v = blue;
-
- if( v < std::numeric_limits<float>::min( ) )
- {
- rgbe[ 0 ] = rgbe[ 1 ] = rgbe[ 2 ] = rgbe[ 3 ] = 0;
- }
- else
- {
- int exponent;
- v = frexp( v, &exponent );
-
- rgbe[ 0 ] = static_cast<unsigned char>( red * v );
- rgbe[ 1 ] = static_cast<unsigned char>( green * v );
- rgbe[ 2 ] = static_cast<unsigned char>( blue * v );
- rgbe[ 3 ] = exponent + 128;
- }
- }
-
- void rgbe2float( unsigned char rgbe[ 4 ], float& red, float& green, float& blue )
- {
- if( rgbe[ 3 ] )
- {
- float f = ldexp( 1.0f, rgbe[ 3 ] - ( 128 + 8 ) );
-
- red = rgbe[ 0 ] * f;
- green = rgbe[ 1 ] * f;
- blue = rgbe[ 2 ] * f;
- }
- else
- {
- red = green = blue = 0.0f;
- }
- }
-
- bool read_rgbe_pixels_raw( fs::ifstream& file, float* data, int width, int height )
- {
- char rgbe[ 4 ];
-
int numpixels = width * height;
while( numpixels-- )
{
- if( !Read_s( file, rgbe, sizeof( rgbe ), sizeof( rgbe ) ) )
+ if( !Read_s( file, ( char* ) data, 4, 4 ) )
return false;
- rgbe2float( ( unsigned char* ) rgbe, data[ 0 ], data[ 1 ], data[ 2 ] );
-
- data += 3;
+ data += 4;
}
return true;
@@ -117,13 +64,13 @@
bool read_rgbe_pixels( fs::ifstream& file, il::image_type_ptr im, int width, int height )
{
- float* data = reinterpret_cast<float*>( im->data( ) );
+ il::image_type::pointer data = im->data( );
if( width < 8 || width > 0x7FFF )
return read_rgbe_pixels_raw( file, data, width, height );
std::vector<unsigned char> line;
- line.resize( width * 4 * sizeof( float ) );
+ line.resize( width * 4 * 4 );
unsigned char rgbe[ 4 ];
for( int i = 0; i < height; ++i )
@@ -133,9 +80,12 @@
if( ( rgbe[ 0 ] != 2 ) || ( rgbe[ 1 ] != 2 ) || ( rgbe[ 2 ] & 0x80 ) )
{
- rgbe2float( rgbe, data[ 0 ], data[ 1 ], data[ 2 ] );
+ data[ 0 ] = rgbe[ 0 ];
+ data[ 1 ] = rgbe[ 1 ];
+ data[ 2 ] = rgbe[ 2 ];
+ data[ 3 ] = rgbe[ 3 ];
- data += 3;
+ data += 4;
return read_rgbe_pixels_raw( file, data, width, height );
}
@@ -186,14 +136,12 @@
for( int k = 0; k < width; ++k )
{
- rgbe[ 0 ] = line[ k + 0 * width ];
- rgbe[ 1 ] = line[ k + 1 * width ];
- rgbe[ 2 ] = line[ k + 2 * width ];
- rgbe[ 3 ] = line[ k + 3 * width ];
-
- rgbe2float( rgbe, data[ 0 ], data[ 1 ], data[ 2 ] );
-
- data += 3;
+ data[ 0 ] = line[ k + 0 * width ];
+ data[ 1 ] = line[ k + 1 * width ];
+ data[ 2 ] = line[ k + 2 * width ];
+ data[ 3 ] = line[ k + 3 * width ];
+
+ data += 4;
}
data += im->pitch( ) - im->linesize( );
@@ -202,13 +150,6 @@
return true;
}
- il::image_type_ptr rgbe_to_image_type( int width, int height )
- {
- typedef il::image<unsigned char, il::r32g32b32f> r32g32b32f_image_type;
-
- return il::image_type_ptr( new il::image_type( r32g32b32f_image_type( width, height, 1 ) ), destroy );
- }
-
bool read_hdr_header( fs::ifstream& file, RgbeInfo& info, int& width, int& height )
{
info.valid = 0;
@@ -297,7 +238,7 @@
if( !read_hdr_header( file, rgbe_info, width, height ) )
return il::image_type_ptr( );
- il::image_type_ptr image = rgbe_to_image_type( width, height );
+ il::image_type_ptr image = il::allocate( L"rgbe", width, height );
if( !image )
return il::image_type_ptr( );
@@ -306,12 +247,41 @@
return image;
}
-}
+
+ bool store_hdr( const fs::path& path, const il::image_type_ptr& im )
+ {
+ fs::ofstream file( path, std::ios::out | std::ios::binary );
+ if( !file.is_open( ) )
+ return false;
+
+ il::image_type_ptr dst = il::convert( im, L"rgbe" );
+ if( dst )
+ {
+ il::image_type::size_type width = dst->width( );
+ il::image_type::size_type height = dst->height( );
+
+ // write header.
+ file << "#?RGBE\nGAMMA=1.0\nEXPOSURE=1.0\nFORMAT=32-bit_rle_rgbe\n\n";
+ file << "-Y " << height << "+X " << width << "\n";
+ il::image_type::const_pointer data = dst->data( );
+ il::image_type::size_type pitch = dst->pitch( );
+
+ while( height-- )
+ {
+ file.write( ( char* ) data, dst->linesize( ) );
+ data += pitch;
+ }
+ }
+
+ return true;
+ }
+}
+
il::image_type_ptr HDR_plugin::load( const fs::path& path )
-{ return il::image_type_ptr( load_hdr( path ) ); }
+{ return load_hdr( path ); }
-bool HDR_plugin::store( const fs::path&, const il::image_type_ptr& )
-{ return false; }
+bool HDR_plugin::store( const fs::path& path, const il::image_type_ptr& im )
+{ return store_hdr( path, im ); }
} } } }
Modified: lib/openlibraries/src/openimagelib/plugins/jpg/jpg_plugin.opl
===================================================================
--- lib/openlibraries/src/openimagelib/plugins/jpg/jpg_plugin.opl 2007-04-24 22:56:51 UTC (rev 104)
+++ lib/openlibraries/src/openimagelib/plugins/jpg/jpg_plugin.opl 2007-04-27 22:05:41 UTC (rev 105)
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<openlibraries version="1.0">
- <!-- plugins go here -->
- <openimagelib name="oil" version="0.2.0">
- <plugin name="OpenLibraries JPG plugin" type="input" extension='".*\.jpg"' merit="80" filename='"libopenimagelib_jpg.so", "openimagelib_jpg-vc80-d-0_4_0.dll" "openimagelib_jpg-vc80-r-0_4_0.dll"'/>
- <plugin name="OpenLibraries JPG plugin" type="output" extension='".*\.jpg"' merit="80" filename='"libopenimagelib_jpg.so", "libopenimagelib_jpg.dylib", "openimagelib_jpg-vc80-d-0_4_0.dll" "openimagelib_jpg-vc80-r-0_4_0.dll"'/>
- </openimagelib>
+ <!-- plugins go here -->
+ <openimagelib name="oil" version="0.2.0">
+ <plugin name="OpenLibraries JPG plugin" type="input" in_filter="*.jpg" extension='".*\.jpg"' merit="80" filename='"libopenimagelib_jpg.so", "libopenimagelib_jpg.dylib", "openimagelib_jpg-vc80-d-0_4_0.dll", "openimagelib_jpg-vc80-r-0_4_0.dll"'/>
+ <plugin name="OpenLibraries JPG plugin" type="output" in_filter="*.jpg" extension='".*\.jpg"' merit="80" filename='"libopenimagelib_jpg.so", "libopenimagelib_jpg.dylib", "openimagelib_jpg-vc80-d-0_4_0.dll", "openimagelib_jpg-vc80-r-0_4_0.dll"'/>
+ </openimagelib>
</openlibraries>
Modified: lib/openlibraries/src/openmedialib/plugins/ofx/ofx_plugin.cpp
===================================================================
--- lib/openlibraries/src/openmedialib/plugins/ofx/ofx_plugin.cpp 2007-04-24 22:56:51 UTC (rev 104)
+++ lib/openlibraries/src/openmedialib/plugins/ofx/ofx_plugin.cpp 2007-04-27 22:05:41 UTC (rev 105)
@@ -5,6 +5,13 @@
// Released under the LGPL.
// For more information, see http://www.openlibraries.org.
+#if _MSC_VER >= 1400
+#include <hash_map>
+#else
+#include <map>
+#endif
+
+#include <cstdarg>
#include <cstring>
#include <new>
#include <vector>
@@ -52,52 +59,995 @@
virtual property_container_ptr get_property_set( ) = 0;
};
- class image_instance : public Ofx_base
+ class param_descriptor : public Ofx_base
{
public:
- explicit image_instance( )
- : image_instance_prop_type_( pcos::key::from_string( kOfxPropType ) )
- , image_instance_prop_pixel_depth_( pcos::key::from_string( kOfxImageEffectPropPixelDepth ) )
- , image_instance_prop_components_( pcos::key::from_string( kOfxImageEffectPropComponents ) )
- , image_instance_prop_premultiplication_( pcos::key::from_string( kOfxImageEffectPropPreMultiplication ) )
- , image_instance_prop_render_scale_( pcos::key::from_string( kOfxImageEffectPropRenderScale ) )
- , image_instance_prop_pixel_aspect_ratio_( pcos::key::from_string( kOfxImagePropPixelAspectRatio ) )
- , image_instance_prop_data_( pcos::key::from_string( kOfxImagePropData ) )
- , image_instance_prop_bounds_( pcos::key::from_string( kOfxImagePropBounds ) )
- , image_instance_prop_region_of_definition_( pcos::key::from_string( kOfxImagePropRegionOfDefinition ) )
- , image_instance_prop_row_bytes_( pcos::key::from_string( kOfxImagePropRowBytes ) )
- , image_instance_prop_field_( pcos::key::from_string( kOfxImagePropField ) )
- , image_instance_prop_unique_identifier_( pcos::key::from_string( kOfxImagePropUniqueIdentifier ) )
+ explicit param_descriptor( )
+ : param_descriptor_prop_type_( pcos::key::from_string( kOfxPropType ) )
+ , param_descriptor_prop_name_( pcos::key::from_string( kOfxPropName ) )
+ , param_descriptor_prop_label_( pcos::key::from_string( kOfxPropLabel ) )
+ , param_descriptor_prop_short_label_( pcos::key::from_string( kOfxPropShortLabel ) )
+ , param_descriptor_prop_long_label_( pcos::key::from_string( kOfxPropLongLabel ) )
+ , param_descriptor_prop_param_prop_type_( pcos::key::from_string( kOfxParamPropType ) )
+ , param_descriptor_prop_param_prop_secret_( pcos::key::from_string( kOfxParamPropSecret ) )
+ , param_descriptor_prop_param_prop_can_undo_( pcos::key::from_string( kOfxParamPropCanUndo ) )
+ , param_descriptor_prop_param_prop_hint_( pcos::key::from_string( kOfxParamPropHint ) )
+ , param_descriptor_prop_param_prop_script_name_( pcos::key::from_string( kOfxParamPropScriptName ) )
+ , param_descriptor_prop_param_prop_parent_( pcos::key::from_string( kOfxParamPropParent ) )
+ , param_descriptor_prop_param_prop_enabled_( pcos::key::from_string( kOfxParamPropEnabled ) )
+ , param_descriptor_prop_param_prop_data_ptr_( pcos::key::from_string( kOfxParamPropDataPtr ) )
{ }
virtual property_container_ptr get_property_set( )
- { return &image_instance_props_; }
+ { return ¶m_descriptor_props_; }
+
+ private:
+ pcos::property_container param_descriptor_props_;
+ pcos::property param_descriptor_prop_type_;
+ pcos::property param_descriptor_prop_name_;
+ pcos::property param_descriptor_prop_label_;
+ pcos::property param_descriptor_prop_short_label_;
+ pcos::property param_descriptor_prop_long_label_;
+ pcos::property param_descriptor_prop_param_prop_type_;
+ pcos::property param_descriptor_prop_param_prop_secret_;
+ pcos::property param_descriptor_prop_param_prop_can_undo_;
+ pcos::property param_descriptor_prop_param_prop_hint_;
+ pcos::property param_descriptor_prop_param_prop_script_name_;
+ pcos::property param_descriptor_prop_param_prop_parent_;
+ pcos::property param_descriptor_prop_param_prop_enabled_;
+ pcos::property param_descriptor_prop_param_prop_data_ptr_;
+ };
+
+ class value_param_descriptor : public param_descriptor
+ {
+ public:
+ explicit value_param_descriptor( )
+ : value_param_descriptor_param_prop_default_( pcos::key::from_string( kOfxParamPropDefault ) )
+ , value_param_descriptor_param_prop_animates_( pcos::key::from_string( kOfxParamPropAnimates ) )
+ , value_param_descriptor_param_prop_is_animating_( pcos::key::from_string( kOfxParamPropIsAnimating ) )
+ , value_param_descriptor_param_prop_is_auto_keying_( pcos::key::from_string( kOfxParamPropIsAutoKeying ) )
+ , value_param_descriptor_param_prop_persistant_( pcos::key::from_string( kOfxParamPropPersistant ) )
+ , value_param_descriptor_param_prop_evaluate_on_change_( pcos::key::from_string( kOfxParamPropEvaluateOnChange ) )
+ , value_param_descriptor_param_prop_plugin_may_write_( pcos::key::from_string( kOfxParamPropPluginMayWrite ) )
+ , value_param_descriptor_param_prop_cache_invalidation_( pcos::key::from_string( kOfxParamPropCacheInvalidation ) )
+ { }
- void set_image_ptr( image_type_ptr im )
+ private:
+ pcos::property value_param_descriptor_param_prop_default_;
+ pcos::property value_param_descriptor_param_prop_animates_;
+ pcos::property value_param_descriptor_param_prop_is_animating_;
+ pcos::property value_param_descriptor_param_prop_is_auto_keying_;
+ pcos::property value_param_descriptor_param_prop_persistant_;
+ pcos::property value_param_descriptor_param_prop_evaluate_on_change_;
+ pcos::property value_param_descriptor_param_prop_plugin_may_write_;
+ pcos::property value_param_descriptor_param_prop_cache_invalidation_;
+ };
+
+ class string_param_descriptor : public value_param_descriptor
+ {
+ public:
+ explicit string_param_descriptor( )
+ : string_param_descriptor_param_prop_string_mode_( pcos::key::from_string( kOfxParamPropStringMode ) )
+ , string_param_descriptor_param_prop_string_file_path_exists_( pcos::key::from_string( kOfxParamPropStringFilePathExists ) )
+ { }
+
+ private:
+ pcos::property string_param_descriptor_param_prop_string_mode_;
+ pcos::property string_param_descriptor_param_prop_string_file_path_exists_;
+ };
+
+ class int_param_descriptor : public value_param_descriptor
+ {
+ public:
+ explicit int_param_descriptor( )
+ : int_param_descriptor_param_prop_min_( pcos::key::from_string( kOfxParamPropMin ) )
+ , int_param_descriptor_param_prop_max_( pcos::key::from_string( kOfxParamPropMax ) )
+ , int_param_descriptor_param_prop_display_min_( pcos::key::from_string( kOfxParamPropDisplayMin ) )
+ , int_param_descriptor_param_prop_display_max_( pcos::key::from_string( kOfxParamPropDisplayMax ) )
+ { }
+
+ private:
+ pcos::property int_param_descriptor_param_prop_min_;
+ pcos::property int_param_descriptor_param_prop_max_;
+ pcos::property int_param_descriptor_param_prop_display_min_;
+ pcos::property int_param_descriptor_param_prop_display_max_;
+ };
+
+ class int2D_param_descriptor : public value_param_descriptor
+ {
+ public:
+ explicit int2D_param_descriptor( )
+ : int2D_param_descriptor_param_prop_min_( pcos::key::from_string( kOfxParamPropMin ) )
+ , int2D_param_descriptor_param_prop_max_( pcos::key::from_string( kOfxParamPropMax ) )
+ , int2D_param_descriptor_param_prop_display_min_( pcos::key::from_string( kOfxParamPropDisplayMin ) )
+ , int2D_param_descriptor_param_prop_display_max_( pcos::key::from_string( kOfxParamPropDisplayMax ) )
+ , int2D_param_descriptor_param_prop_dimension_label_( pcos::key::from_string( kOfxParamPropDimensionLabel ) )
+ { }
+
+ private:
+ pcos::property int2D_param_descriptor_param_prop_min_;
+ pcos::property int2D_param_descriptor_param_prop_max_;
+ pcos::property int2D_param_descriptor_param_prop_display_min_;
+ pcos::property int2D_param_descriptor_param_prop_display_max_;
+ pcos::property int2D_param_descriptor_param_prop_dimension_label_;
+ };
+
+ class int3D_param_descriptor : public value_param_descriptor
+ {
+ public:
+ explicit int3D_param_descriptor( )
+ : int3D_param_descriptor_param_prop_min_( pcos::key::from_string( kOfxParamPropMin ) )
+ , int3D_param_descriptor_param_prop_max_( pcos::key::from_string( kOfxParamPropMax ) )
+ , int3D_param_descriptor_param_prop_display_min_( pcos::key::from_string( kOfxParamPropDisplayMin ) )
+ , int3D_param_descriptor_param_prop_display_max_( pcos::key::from_string( kOfxParamPropDisplayMax ) )
+ , int3D_param_descriptor_param_prop_dimension_label_( pcos::key::from_string( kOfxParamPropDimensionLabel ) )
+ { }
+
+ private:
+ pcos::property int3D_param_descriptor_param_prop_min_;
+ pcos::property int3D_param_descriptor_param_prop_max_;
+ pcos::property int3D_param_descriptor_param_prop_display_min_;
+ pcos::property int3D_param_descriptor_param_prop_display_max_;
+ pcos::property int3D_param_descriptor_param_prop_dimension_label_;
+ };
+
+ class base_double_param_descriptor : public value_param_descriptor
+ {
+ public:
+ explicit base_double_param_descriptor( )
+ : base_double_param_descriptor_param_prop_increment_( pcos::key::from_string( kOfxParamPropIncrement ) )
+ , base_double_param_descriptor_param_prop_digits_( pcos::key::from_string( kOfxParamPropDigits ) )
+ { }
+
+ private:
+ pcos::property base_double_param_descriptor_param_prop_increment_;
+ pcos::property base_double_param_descriptor_param_prop_digits_;
+ };
+
+ class double_param_descriptor : public value_param_descriptor
+ {
+ public:
+ explicit double_param_descriptor( )
+ : double_param_descriptor_param_prop_min_( pcos::key::from_string( kOfxParamPropMin ) )
+ , double_param_descriptor_param_prop_max_( pcos::key::from_string( kOfxParamPropMax ) )
+ , double_param_descriptor_param_prop_display_min_( pcos::key::from_string( kOfxParamPropDisplayMin ) )
+ , double_param_descriptor_param_prop_display_max_( pcos::key::from_string( kOfxParamPropDisplayMax ) )
+ , double_param_descriptor_param_prop_show_time_marker_( pcos::key::from_string( kOfxParamPropShowTimeMarker ) )
+ { }
+
+ private:
+ pcos::property double_param_descriptor_param_prop_min_;
+ pcos::property double_param_descriptor_param_prop_max_;
+ pcos::property double_param_descriptor_param_prop_display_min_;
+ pcos::property double_param_descriptor_param_prop_display_max_;
+ pcos::property double_param_descriptor_param_prop_show_time_marker_;
+ };
+
+ class double2D_param_descriptor : public value_param_descriptor
+ {
+ public:
+ explicit double2D_param_descriptor( )
+ : double2D_param_descriptor_param_prop_min_( pcos::key::from_string( kOfxParamPropMin ) )
+ , double2D_param_descriptor_param_prop_max_( pcos::key::from_string( kOfxParamPropMax ) )
+ , double2D_param_descriptor_param_prop_display_min_( pcos::key::from_string( kOfxParamPropDisplayMin ) )
+ , double2D_param_descriptor_param_prop_display_max_( pcos::key::from_string( kOfxParamPropDisplayMax ) )
+ , double2D_param_descriptor_param_prop_dimension_label_( pcos::key::from_string( kOfxParamPropDimensionLabel ) )
+ { }
+
+ private:
+ pcos::property double2D_param_descriptor_param_prop_min_;
+ pcos::property double2D_param_descriptor_param_prop_max_;
+ pcos::property double2D_param_descriptor_param_prop_display_min_;
+ pcos::property double2D_param_descriptor_param_prop_display_max_;
+ pcos::property double2D_param_descriptor_param_prop_dimension_label_;
+ };
+
+ class double3D_param_descriptor : public value_param_descriptor
+ {
+ public:
+ explicit double3D_param_descriptor( )
+ : double3D_param_descriptor_param_prop_min_( pcos::key::from_string( kOfxParamPropMin ) )
+ , double3D_param_descriptor_param_prop_max_( pcos::key::from_string( kOfxParamPropMax ) )
+ , double3D_param_descriptor_param_prop_display_min_( pcos::key::from_string( kOfxParamPropDisplayMin ) )
+ , double3D_param_descriptor_param_prop_display_max_( pcos::key::from_string( kOfxParamPropDisplayMax ) )
+ , double3D_param_descriptor_param_prop_dimension_label_( pcos::key::from_string( kOfxParamPropDimensionLabel ) )
+ { }
+
+ private:
+ pcos::property double3D_param_descriptor_param_prop_min_;
+ pcos::property double3D_param_descriptor_param_prop_max_;
+ pcos::property double3D_param_descriptor_param_prop_display_min_;
+ pcos::property double3D_param_descriptor_param_prop_display_max_;
+ pcos::property double3D_param_descriptor_param_prop_dimension_label_;
+ };
+
+ class rgb_param_descriptor : public value_param_descriptor
+ {
+ public:
+ explicit rgb_param_descriptor( )
+ { }
+ };
+
+ class rgba_param_descriptor : public value_param_descriptor
+ {
+ public:
+ explicit rgba_param_descriptor( )
+ { }
+ };
+
+ class boolean_param_descriptor : public value_param_descriptor
+ {
+ public:
+ explicit boolean_param_descriptor( )
+ { }
+ };
+
+ class choice_param_descriptor : public value_param_descriptor
+ {
+ public:
+ explicit choice_param_descriptor( )
+ { }
+ };
+
+ class group_param_descriptor : public value_param_descriptor
+ {
+ public:
+ explicit group_param_descriptor( )
+ { }
+ };
+
+ class page_param_descriptor : public value_param_descriptor
+ {
+ public:
+ explicit page_param_descriptor( )
+ { }
+ };
+
+ class push_button_param_descriptor : public value_param_descriptor
+ {
+ public:
+ explicit push_button_param_descriptor( )
+ { }
+ };
+
+ class custom_param_descriptor : public value_param_descriptor
+ {
+ public:
+ explicit custom_param_descriptor( )
+ { }
+ };
+
+ class param_set_descriptor
+ {
+ public:
+ typedef pl::string key_type;
+ typedef boost::shared_ptr<param_descriptor> param_descriptor_ptr;
+
+#if _MSC_VER >= 1400
+ typedef stdext::hash_map<key_type, param_descriptor_ptr> container;
+#else
+ typedef std::map<key_type, param_descriptor_ptr> container;
+#endif
+
+ public:
+ explicit param_set_descriptor( )
+ { }
+
+ OfxStatus define( const pl::string& param_type, const pl::string& name )
{
+ typedef container::const_iterator const_iterator;
+
+ const_iterator I;
+ if( ( I = params_.find( name ) ) == params_.end( ) )
+ {
+ if( param_type == kOfxParamTypeInteger )
+ {
+ params_.insert( container::value_type( name, param_descriptor_ptr( new int_param_descriptor( ) ) ) );
+ }
+ else if( param_type == kOfxParamTypeInteger2D )
+ {
+ params_.insert( container::value_type( name, param_descriptor_ptr( new int2D_param_descriptor( ) ) ) );
+ }
+ else if( param_type == kOfxParamTypeInteger3D )
+ {
+ params_.insert( container::value_type( name, param_descriptor_ptr( new int3D_param_descriptor( ) ) ) );
+ }
+ else if( param_type == kOfxParamTypeDouble )
+ {
+ params_.insert( container::value_type( name, param_descriptor_ptr( new double_param_descriptor( ) ) ) );
+ }
+ else if( param_type == kOfxParamTypeDouble2D )
+ {
+ params_.insert( container::value_type( name, param_descriptor_ptr( new double2D_param_descriptor( ) ) ) );
+ }
+ else if( param_type == kOfxParamTypeDouble3D )
+ {
+ params_.insert( container::value_type( name, param_descriptor_ptr( new double3D_param_descriptor( ) ) ) );
+ }
+ else if( param_type == kOfxParamTypeRGB )
+ {
+ params_.insert( container::value_type( name, param_descriptor_ptr( new rgb_param_descriptor( ) ) ) );
+ }
+ else if( param_type == kOfxParamTypeRGBA )
+ {
+ params_.insert( container::value_type( name, param_descriptor_ptr( new rgba_param_descriptor( ) ) ) );
+ }
+ else if( param_type == kOfxParamTypeBoolean )
+ {
+ params_.insert( container::value_type( name, param_descriptor_ptr( new boolean_param_descriptor( ) ) ) );
+ }
+ else if( param_type == kOfxParamTypeChoice )
+ {
+ params_.insert( container::value_type( name, param_descriptor_ptr( new choice_param_descriptor( ) ) ) );
+ }
+ else if( param_type == kOfxParamTypeGroup )
+ {
+ params_.insert( container::value_type( name, param_descriptor_ptr( new group_param_descriptor( ) ) ) );
+ }
+ else if( param_type == kOfxParamTypePage )
+ {
+ params_.insert( container::value_type( name, param_descriptor_ptr( new page_param_descriptor( ) ) ) );
+ }
+ else if( param_type == kOfxParamTypeCustom )
+ {
+ params_.insert( container::value_type( name, param_descriptor_ptr( new custom_param_descriptor( ) ) ) );
+ }
+ else if( param_type == kOfxParamTypePushButton )
+ {
+ params_.insert( container::value_type( name, param_descriptor_ptr( new push_button_param_descriptor( ) ) ) );
+ }
+ else if( param_type == kOfxParamTypeString )
+ {
+ params_.insert( container::value_type( name, param_descriptor_ptr( new string_param_descriptor( ) ) ) );
+ }
+ }
+ else
+ {
+ // parameter already exists. if the type is the same return success. otherwise flag as an error.
+ }
+
+ return kOfxStatOK;
}
+
+ property_container_ptr find_property_set( const pl::string& name )
+ {
+ typedef container::const_iterator const_iterator;
+
+ const_iterator I;
+ if( ( I = params_.find( name ) ) != params_.end( ) )
+ return I->second->get_property_set( );
+
+ return 0;
+ }
- // Image instance properties.
private:
- pcos::property_container image_instance_props_;
- pcos::property image_instance_prop_type_;
- pcos::property image_instance_prop_pixel_depth_;
- pcos::property image_instance_prop_components_;
- pcos::property image_instance_prop_premultiplication_;
- pcos::property image_instance_prop_render_scale_;
- pcos::property image_instance_prop_pixel_aspect_ratio_;
- pcos::property image_instance_prop_data_;
- pcos::property image_instance_prop_bounds_;
- pcos::property image_instance_prop_region_of_definition_;
- pcos::property image_instance_prop_row_bytes_;
- pcos::property image_instance_prop_field_;
- pcos::property image_instance_prop_unique_identifier_;
+ container params_;
};
+ class param : public Ofx_base
+ {
+ public:
+ explicit param( )
+ : param_prop_type_( pcos::key::from_string( kOfxPropType ) )
+ , param_prop_name_( pcos::key::from_string( kOfxPropName ) )
+ , param_prop_label_( pcos::key::from_string( kOfxPropLabel ) )
+ , param_prop_short_label_( pcos::key::from_string( kOfxPropShortLabel ) )
+ , param_prop_long_label_( pcos::key::from_string( kOfxPropLongLabel ) )
+ , param_prop_param_prop_type_( pcos::key::from_string( kOfxParamPropType ) )
+ , param_prop_param_prop_secret_( pcos::key::from_string( kOfxParamPropSecret ) )
+ , param_prop_param_prop_can_undo_( pcos::key::from_string( kOfxParamPropCanUndo ) )
+ , param_prop_param_prop_hint_( pcos::key::from_string( kOfxParamPropHint ) )
+ , param_prop_param_prop_script_name_( pcos::key::from_string( kOfxParamPropScriptName ) )
+ , param_prop_param_prop_parent_( pcos::key::from_string( kOfxParamPropParent ) )
+ , param_prop_param_prop_enabled_( pcos::key::from_string( kOfxParamPropEnabled ) )
+ , param_prop_param_prop_data_ptr_( pcos::key::from_string( kOfxParamPropDataPtr ) )
+ { }
+
+ virtual property_container_ptr get_property_set( )
+ { return ¶m_props_; }
+
+ virtual pcos::property get_value( ) = 0;
+ virtual pl::string get_type( ) = 0;
+
+ private:
+ pcos::property_container param_props_;
+ pcos::property param_prop_type_;
+ pcos::property param_prop_name_;
+ pcos::property param_prop_label_;
+ pcos::property param_prop_short_label_;
+ pcos::property param_prop_long_label_;
+ pcos::property param_prop_param_prop_type_;
+ pcos::property param_prop_param_prop_secret_;
+ pcos::property param_prop_param_prop_can_undo_;
+ pcos::property param_prop_param_prop_hint_;
+ pcos::property param_prop_param_prop_script_name_;
+ pcos::property param_prop_param_prop_parent_;
+ pcos::property param_prop_param_prop_enabled_;
+ pcos::property param_prop_param_prop_data_ptr_;
+ };
+
+ class value_param : public param
+ {
+ public:
+ explicit value_param( )
+ : value_param_prop_default_( pcos::key::from_string( kOfxParamPropDefault ) )
+ , value_param_prop_animates_( pcos::key::from_string( kOfxParamPropAnimates ) )
+ , value_param_prop_is_animating_( pcos::key::from_string( kOfxParamPropIsAnimating ) )
+ , value_param_prop_is_auto_keying_( pcos::key::from_string( kOfxParamPropIsAutoKeying ) )
+ , value_param_prop_persistant_( pcos::key::from_string( kOfxParamPropPersistant ) )
+ , value_param_prop_evaluate_on_change_( pcos::key::from_string( kOfxParamPropEvaluateOnChange ) )
+ , value_param_prop_plugin_may_write_( pcos::key::from_string( kOfxParamPropPluginMayWrite ) )
+ , value_param_prop_cache_invalidation_( pcos::key::from_string( kOfxParamPropCacheInvalidation ) )
+ { }
+
+ private:
+ pcos::property value_param_prop_default_;
+ pcos::property value_param_prop_animates_;
+ pcos::property value_param_prop_is_animating_;
+ pcos::property value_param_prop_is_auto_keying_;
+ pcos::property value_param_prop_persistant_;
+ pcos::property value_param_prop_evaluate_on_change_;
+ pcos::property value_param_prop_plugin_may_write_;
+ pcos::property value_param_prop_cache_invalidation_;
+ };
+
+ class string_param : public value_param
+ {
+ public:
+ explicit string_param( )
+ : string_param_value_( pcos::key::from_string( "value" ) )
+ , string_param_prop_string_mode_( pcos::key::from_string( kOfxParamPropStringMode ) )
+ , string_param_prop_string_file_path_exists_( pcos::key::from_string( kOfxParamPropStringFilePathExists ) )
+ { }
+
+ virtual pcos::property get_value( )
+ {
+ return string_param_value_;
+ }
+
+ virtual pl::string get_type( )
+ {
+ return kOfxParamTypeString;
+ }
+
+ private:
+ pcos::property string_param_value_;
+ pcos::property string_param_prop_string_mode_;
+ pcos::property string_param_prop_string_file_path_exists_;
+ };
+
+ class int_param : public value_param
+ {
+ public:
+ explicit int_param( )
+ : int_param_value_( pcos::key::from_string( "value" ) )
+ , int_param_prop_min_( pcos::key::from_string( kOfxParamPropMin ) )
+ , int_param_prop_max_( pcos::key::from_string( kOfxParamPropMax ) )
+ , int_param_prop_display_min_( pcos::key::from_string( kOfxParamPropDisplayMin ) )
+ , int_param_prop_display_max_( pcos::key::from_string( kOfxParamPropDisplayMax ) )
+ { }
+
+ virtual pcos::property get_value( )
+ {
+ return int_param_value_;
+ }
+
+ virtual pl::string get_type( )
+ {
+ return kOfxParamTypeInteger;
+ }
+
+ private:
+ pcos::property int_param_value_;
+ pcos::property int_param_prop_min_;
+ pcos::property int_param_prop_max_;
+ pcos::property int_param_prop_display_min_;
+ pcos::property int_param_prop_display_max_;
+ };
+
+ class int2D_param : public value_param
+ {
+ public:
+ explicit int2D_param( )
+ : int2D_param_value_( pcos::key::from_string( "value" ) )
+ , int2D_param_prop_min_( pcos::key::from_string( kOfxParamPropMin ) )
+ , int2D_param_prop_max_( pcos::key::from_string( kOfxParamPropMax ) )
+ , int2D_param_prop_display_min_( pcos::key::from_string( kOfxParamPropDisplayMin ) )
+ , int2D_param_prop_display_max_( pcos::key::from_string( kOfxParamPropDisplayMax ) )
+ , int2D_param_prop_dimension_label_( pcos::key::from_string( kOfxParamPropDimensionLabel ) )
+ { }
+
+ virtual pcos::property get_value( )
+ {
+ return int2D_param_value_;
+ }
+
+ virtual pl::string get_type( )
+ {
+ return kOfxParamTypeInteger2D;
+ }
+
+ private:
+ pcos::property int2D_param_value_;
+ pcos::property int2D_param_prop_min_;
+ pcos::property int2D_param_prop_max_;
+ pcos::property int2D_param_prop_display_min_;
+ pcos::property int2D_param_prop_display_max_;
+ pcos::property int2D_param_prop_dimension_label_;
+ };
+
+ class int3D_param : public value_param
+ {
+ public:
+ explicit int3D_param( )
+ : int3D_param_value_( pcos::key::from_string( "value" ) )
+ , int3D_param_param_prop_min_( pcos::key::from_string( kOfxParamPropMin ) )
+ , int3D_param_param_prop_max_( pcos::key::from_string( kOfxParamPropMax ) )
+ , int3D_param_param_prop_display_min_( pcos::key::from_string( kOfxParamPropDisplayMin ) )
+ , int3D_param_param_prop_display_max_( pcos::key::from_string( kOfxParamPropDisplayMax ) )
+ , int3D_param_param_prop_dimension_label_( pcos::key::from_string( kOfxParamPropDimensionLabel ) )
+ { }
+
+ virtual pcos::property get_value( )
+ {
+ return int3D_param_value_;
+ }
+
+ virtual pl::string get_type( )
+ {
+ return kOfxParamTypeInteger3D;
+ }
+
+ private:
+ pcos::property int3D_param_value_;
+ pcos::property int3D_param_param_prop_min_;
+ pcos::property int3D_param_param_prop_max_;
+ pcos::property int3D_param_param_prop_display_min_;
+ pcos::property int3D_param_param_prop_display_max_;
+ pcos::property int3D_param_param_prop_dimension_label_;
+ };
+
+ class base_double_param : public value_param
+ {
+ public:
+ explicit base_double_param( )
+ : base_double_param_prop_increment_( pcos::key::from_string( kOfxParamPropIncrement ) )
+ , base_double_param_prop_digits_( pcos::key::from_string( kOfxParamPropDigits ) )
+ { }
+
+ private:
+ pcos::property base_double_param_prop_increment_;
+ pcos::property base_double_param_prop_digits_;
+ };
+
+ class double_param : public value_param
+ {
+ public:
+ explicit double_param( )
+ : double_param_value_( pcos::key::from_string( "value" ) )
+ , double_param_param_prop_min_( pcos::key::from_string( kOfxParamPropMin ) )
+ , double_param_param_prop_max_( pcos::key::from_string( kOfxParamPropMax ) )
+ , double_param_param_prop_display_min_( pcos::key::from_string( kOfxParamPropDisplayMin ) )
+ , double_param_param_prop_display_max_( pcos::key::from_string( kOfxParamPropDisplayMax ) )
+ , double_param_param_prop_show_time_marker_( pcos::key::from_string( kOfxParamPropShowTimeMarker ) )
+ { }
+
+ virtual pcos::property get_value( )
+ {
+ return double_param_value_;
+ }
+
+ virtual pl::string get_type( )
+ {
+ return kOfxParamTypeDouble;
+ }
+
+ private:
+ pcos::property double_param_value_;
+ pcos::property double_param_param_prop_min_;
+ pcos::property double_param_param_prop_max_;
+ pcos::property double_param_param_prop_display_min_;
+ pcos::property double_param_param_prop_display_max_;
+ pcos::property double_param_param_prop_show_time_marker_;
+ };
+
+ class double2D_param : public value_param
+ {
+ public:
+ explicit double2D_param( )
+ : double2D_param_value_( pcos::key::from_string( "value" ) )
+ , double2D_param_param_prop_min_( pcos::key::from_string( kOfxParamPropMin ) )
+ , double2D_param_param_prop_max_( pcos::key::from_string( kOfxParamPropMax ) )
+ , double2D_param_param_prop_display_min_( pcos::key::from_string( kOfxParamPropDisplayMin ) )
+ , double2D_param_param_prop_display_max_( pcos::key::from_string( kOfxParamPropDisplayMax ) )
+ , double2D_param_param_prop_dimension_label_( pcos::key::from_string( kOfxParamPropDimensionLabel ) )
+ { }
+
+ virtual pcos::property get_value( )
+ {
+ return double2D_param_value_;
+ }
+
+ virtual pl::string get_type( )
+ {
+ return kOfxParamTypeDouble2D;
+ }
+
+ private:
+ pcos::property double2D_param_value_;
+ pcos::property double2D_param_param_prop_min_;
+ pcos::property double2D_param_param_prop_max_;
+ pcos::property double2D_param_param_prop_display_min_;
+ pcos::property double2D_param_param_prop_display_max_;
+ pcos::property double2D_param_param_prop_dimension_label_;
+ };
+
+ class double3D_param : public value_param
+ {
+ public:
+ explicit double3D_param( )
+ : double3D_param_value_( pcos::key::from_string( "value" ) )
+ , double3D_param_param_prop_min_( pcos::key::from_string( kOfxParamPropMin ) )
+ , double3D_param_param_prop_max_( pcos::key::from_string( kOfxParamPropMax ) )
+ , double3D_param_param_prop_display_min_( pcos::key::from_string( kOfxParamPropDisplayMin ) )
+ , double3D_param_param_prop_display_max_( pcos::key::from_string( kOfxParamPropDisplayMax ) )
+ , double3D_param_param_prop_dimension_label_( pcos::key::from_string( kOfxParamPropDimensionLabel ) )
+ { }
+
+ virtual pcos::property get_value( )
+ {
+ return double3D_param_value_;
+ }
+
+ virtual pl::string get_type( )
+ {
+ return kOfxParamTypeDouble3D;
+ }
+
+ private:
+ pcos::property double3D_param_value_;
+ pcos::property double3D_param_param_prop_min_;
+ pcos::property double3D_param_param_prop_max_;
+ pcos::property double3D_param_param_prop_display_min_;
+ pcos::property double3D_param_param_prop_display_max_;
+ pcos::property double3D_param_param_prop_dimension_label_;
+ };
+
+ class rgb_param : public value_param
+ {
+ public:
+ explicit rgb_param( )
+ : rgb_param_value_( pcos::key::from_string( "value" ) )
+ { }
+
+ virtual pcos::property get_value( )
+ {
+ return rgb_param_value_;
+ }
+
+ virtual pl::string get_type( )
+ {
+ return kOfxParamTypeRGB;
+ }
+
+ private:
+ pcos::property rgb_param_value_;
+ };
+
+ class rgba_param : public value_param
+ {
+ public:
+ explicit rgba_param( )
+ : rgba_param_value_( pcos::key::from_string( "value" ) )
+ { }
+
+ virtual pcos::property get_value( )
+ {
+ return rgba_param_value_;
+ }
+
+ virtual pl::string get_type( )
+ {
+ return kOfxParamTypeRGBA;
+ }
+
+ private:
+ pcos::property rgba_param_value_;
+ };
+
+ class boolean_param : public value_param
+ {
+ public:
+ explicit boolean_param( )
+ : boolean_param_value_( pcos::key::from_string( "value" ) )
+ { }
+
+ virtual pcos::property get_value( )
+ {
+ return boolean_param_value_;
+ }
+
+ virtual pl::string get_type( )
+ {
+ return kOfxParamTypeBoolean;
+ }
+
+ private:
+ pcos::property boolean_param_value_;
+ };
+
+ class choice_param : public value_param
+ {
+ public:
+ explicit choice_param( )
+ : choice_param_value_( pcos::key::from_string( "value" ) )
+ { }
+
+ virtual pcos::property get_value( )
+ {
+ return choice_param_value_;
+ }
+
+ virtual pl::string get_type( )
+ {
+ return kOfxParamTypeChoice;
+ }
+
+ private:
+ pcos::property choice_param_value_;
+ };
+
+ class group_param : public value_param
+ {
+ public:
+ explicit group_param( )
+ : group_param_value_( pcos::key::from_string( "value" ) )
+ { }
+
+ virtual pcos::property get_value( )
+ {
+ return group_param_value_;
+ }
+
+ virtual pl::string get_type( )
+ {
+ return kOfxParamTypeGroup;
+ }
+
+ private:
+ pcos::property group_param_value_;
+ };
+
+ class page_param : public value_param
+ {
+ public:
+ explicit page_param( )
+ : page_param_value_( pcos::key::from_string( "value" ) )
+ { }
+
+ virtual pcos::property get_value( )
+ {
+ return page_param_value_;
+ }
+
+ virtual pl::string get_type( )
+ {
+ return kOfxParamTypePage;
+ }
+
+ private:
+ pcos::property page_param_value_;
+ };
+
+ class push_button_param : public value_param
+ {
+ public:
+ explicit push_button_param( )
+ : push_button_param_value_( pcos::key::from_string( "value" ) )
+ { }
+
+ virtual pcos::property get_value( )
+ {
+ return push_button_param_value_;
+ }
+
+ virtual pl::string get_type( )
+ {
+ return kOfxParamTypePushButton;
+ }
+
+ private:
+ pcos::property push_button_param_value_;
+ };
+
+ class custom_param : public value_param
+ {
+ public:
+ explicit custom_param( )
+ : custom_param_value_( pcos::key::from_string( "value" ) )
+ { }
+
+ virtual pcos::property get_value( )
+ {
+ return custom_param_value_;
+ }
+
+ virtual pl::string get_type( )
+ {
+ return kOfxParamTypeCustom;
+ }
+
+ private:
+ pcos::property custom_param_value_;
+ };
+
+ class param_set : public Ofx_base
+ {
+ public:
+ typedef pl::string key_type;
+ typedef boost::shared_ptr<param> param_ptr;
+
+#if _MSC_VER >= 1400
+ typedef stdext::hash_map<key_type, param_ptr> container;
+#else
+ typedef std::map<key_type, param_ptr> container;
+#endif
+
+ public:
+ explicit param_set( )
+ { }
+
+ OfxStatus define( const pl::string& param_type, const pl::string& name )
+ {
+ typedef container::const_iterator const_iterator;
+
+ const_iterator I;
+ if( ( I = params_.find( name ) ) == params_.end( ) )
+ {
+ if( param_type == kOfxParamTypeInteger )
+ {
+ params_.insert( container::value_type( name, param_ptr( new int_param( ) ) ) );
+ }
+ else if( param_type == kOfxParamTypeInteger2D )
+ {
+ params_.insert( container::value_type( name, param_ptr( new int2D_param( ) ) ) );
+ }
+ else if( param_type == kOfxParamTypeInteger3D )
+ {
+ params_.insert( container::value_type( name, param_ptr( new int3D_param( ) ) ) );
+ }
+ else if( param_type == kOfxParamTypeDouble )
+ {
+ params_.insert( container::value_type( name, param_ptr( new double_param( ) ) ) );
+ }
+ else if( param_type == kOfxParamTypeDouble2D )
+ {
+ params_.insert( container::value_type( name, param_ptr( new double2D_param( ) ) ) );
+ }
+ else if( param_type == kOfxParamTypeDouble3D )
+ {
+ params_.insert( container::value_type( name, param_ptr( new double3D_param( ) ) ) );
+ }
+ else if( param_type == kOfxParamTypeRGB )
+ {
+ params_.insert( container::value_type( name, param_ptr( new rgb_param( ) ) ) );
+ }
+ else if( param_type == kOfxParamTypeRGBA )
+ {
+ params_.insert( container::value_type( name, param_ptr( new rgba_param( ) ) ) );
+ }
+ else if( param_type == kOfxParamTypeBoolean )
+ {
+ params_.insert( container::value_type( name, param_ptr( new boolean_param( ) ) ) );
+ }
+ else if( param_type == kOfxParamTypeChoice )
+ {
+ params_.insert( container::value_type( name, param_ptr( new choice_param( ) ) ) );
+ }
+ else if( param_type == kOfxParamTypeGroup )
+ {
+ params_.insert( container::value_type( name, param_ptr( new group_param( ) ) ) );
+ }
+ else if( param_type == kOfxParamTypePage )
+ {
+ params_.insert( container::value_type( name, param_ptr( new page_param( ) ) ) );
+ }
+ else if( param_type == kOfxParamTypeCustom )
+ {
+ params_.insert( container::value_type( name, param_ptr( new custom_param( ) ) ) );
+ }
+ else if( param_type == kOfxParamTypePushButton )
+ {
+ params_.insert( container::value_type( name, param_ptr( new push_button_param( ) ) ) );
+ }
+ else if( param_type == kOfxParamTypeString )
+ {
+ params_.insert( container::value_type( name, param_ptr( new string_param( ) ) ) );
+ }
+ }
+ else
+ {
+ // parameter already exists. if the type is the same return success. otherwise flag as an error.
+ }
+
+ return kOfxStatOK;
+ }
+
+ virtual property_container_ptr get_property_set( )
+ { return ¶m_set_props_; }
+
+ param* find_param( const pl::string& name )
+ {
+ typedef container::const_iterator const_iterator;
+
+ const_iterator I;
+ if( ( I = params_.find( name ) ) != params_.end( ) )
+ return I->second.get( );
+
+ return 0;
+ }
+
+ private:
+ container params_;
+ pcos::property_container param_set_props_;
+ };
+
+ class image : public Ofx_base
+ {
+ public:
+ explicit image( )
+ : image_prop_type_( pcos::key::from_string( kOfxPropType ) )
+ , image_effect_prop_pixel_depth_( pcos::key::from_string( kOfxImageEffectPropPixelDepth ) )
+ , image_effect_prop_components_( pcos::key::from_string( kOfxImageEffectPropComponents ) )
+ , image_effect_prop_pre_multiplication_( pcos::key::from_string( kOfxImageEffectPropPreMultiplication ) )
+ , image_effect_prop_render_scale_( pcos::key::from_string( kOfxImageEffectPropRenderScale ) )
+ , image_effect_prop_pixel_aspect_ratio_( pcos::key::from_string( kOfxImagePropPixelAspectRatio ) )
+ , image_effect_prop_data_( pcos::key::from_string( kOfxImagePropData ) )
+ , image_effect_prop_bounds_( pcos::key::from_string( kOfxImagePropBounds ) )
+ , image_effect_prop_region_of_definition_( pcos::key::from_string( kOfxImagePropRegionOfDefinition ) )
+ , image_effect_prop_row_bytes_( pcos::key::from_string( kOfxImagePropRowBytes ) )
+ , image_effect_prop_field_( pcos::key::from_string( kOfxImagePropField ) )
+ , image_effect_prop_unique_identifier_( pcos::key::from_string( kOfxImagePropUniqueIdentifier ) )
+ {
+ image_props_.append( image_prop_type_ = kOfxTypeImage );
+ }
+
+ virtual property_container_ptr get_property_set( )
+ { return &image_props_; }
+
+ bool set_image( il::image_type_ptr im )
+ {
+ il::image_type_ptr dst_img = il::convert( im, L"r8g8b8a8" );
+ if( dst_img )
+ {
+
+
+ return true;
+ }
+
+ return false;
+ }
+
+ private:
+ pcos::property_container image_props_;
+ pcos::property image_prop_type_;
+ pcos::property image_effect_prop_pixel_depth_;
+ pcos::property image_effect_prop_components_;
+ pcos::property image_effect_prop_pre_multiplication_;
+ pcos::property image_effect_prop_render_scale_;
+ pcos::property image_effect_prop_pixel_aspect_ratio_;
+ pcos::property image_effect_prop_data_;
+ pcos::property image_effect_prop_bounds_;
+ pcos::property image_effect_prop_region_of_definition_;
+ pcos::property image_effect_prop_row_bytes_;
+ pcos::property image_effect_prop_field_;
+ pcos::property image_effect_prop_unique_identifier_;
+ };
+
class clip_descriptor : public Ofx_base
{
public:
- explicit clip_descriptor( const pl::string& name )
+ explicit clip_descriptor( )
: clip_descriptor_prop_type_( pcos::key::from_string( kOfxPropType ) )
, clip_descriptor_prop_name_( pcos::key::from_string( kOfxPropName ) )
, clip_descriptor_prop_label_( pcos::key::from_string( kOfxPropLabel ) )
@@ -109,7 +1059,6 @@
, clip_descriptor_prop_field_extraction_( pcos::key::from_string( kOfxImageClipPropFieldExtraction ) )
, clip_descriptor_prop_is_mask_( pcos::key::from_string( kOfxImageClipPropIsMask ) )
, clip_descriptor_prop_supports_tiles_( pcos::key::from_string( kOfxImageEffectPropSupportsTiles ) )
- , name_( name )
{
set_clip_descriptor_properties( );
}
@@ -147,13 +1096,12 @@
pcos::property clip_descriptor_prop_field_extraction_;
pcos::property clip_descriptor_prop_is_mask_;
pcos::property clip_descriptor_prop_supports_tiles_;
- pl::string name_;
};
class clip_instance : public Ofx_base
{
public:
- explicit clip_instance( const pl::string& name )
+ explicit clip_instance( )
: clip_instance_prop_type_( pcos::key::from_string( kOfxPropType ) )
, clip_instance_prop_name_( pcos::key::from_string( kOfxPropName ) )
, clip_instance_prop_label_( pcos::key::from_string( kOfxPropLabel ) )
@@ -178,7 +1126,6 @@
, clip_instance_prop_unmapped_frame_range_( pcos::key::from_string( kOfxImageEffectPropUnmappedFrameRange ) )
, clip_instance_prop_unmapped_frame_rate_( pcos::key::from_string( kOfxImageEffectPropUnmappedFrameRate ) )
, clip_instance_prop_continuous_samples_( pcos::key::from_string( kOfxImageClipPropContinuousSamples ) )
- , name_( name )
{
set_clip_instance_properties( );
}
@@ -186,9 +1133,6 @@
virtual property_container_ptr get_property_set( )
{ return &clip_instance_props_; }
- pl::string name( ) const
- { return name_; }
-
private:
void set_clip_instance_properties( )
{
@@ -245,14 +1189,21 @@
pcos::property clip_instance_prop_unmapped_frame_range_;
pcos::property clip_instance_prop_unmapped_frame_rate_;
pcos::property clip_instance_prop_continuous_samples_;
-
- private:
- pl::string name_;
};
- class image_effect_descriptor : public Ofx_base
+ class image_effect_descriptor : public param_set_descriptor
{
public:
+ typedef pl::string key_type;
+ typedef boost::shared_ptr<clip_descriptor> clip_descriptor_ptr;
+
+#if _MSC_VER >= 1400
+ typedef stdext::hash_map<key_type, clip_descriptor_ptr> container;
+#else
+ typedef std::map<key_type, clip_descriptor_ptr> container;
+#endif
+
+ public:
explicit image_effect_descriptor( )
: image_effect_prop_type_( pcos::key::from_string( kOfxPropType ) )
, image_effect_prop_label_( pcos::key::from_string( kOfxPropLabel ) )
@@ -279,15 +1230,23 @@
virtual property_container_ptr get_property_set( )
{ return &effect_descriptor_props_; }
-
+
void clip_define( const pl::string& name, OfxPropertySetHandle* props )
{
- clip_descriptor desc( name );
+ typedef container::const_iterator const_iterator;
- if( *props )
- *props = ( OfxPropertySetHandle ) desc.get_property_set( );
-
- clip_descriptor_.push_back( desc );
+ const_iterator I = clip_desc_....
[truncated message content] |