[Hdrflow-svn] SF.net SVN: hdrflow: [113] lib/openlibraries/src/openmedialib/plugins/ofx/ ofx_plugin
Status: Pre-Alpha
Brought to you by:
glslang
|
From: <gl...@us...> - 2007-05-04 17:24:50
|
Revision: 113
http://hdrflow.svn.sourceforge.net/hdrflow/?rev=113&view=rev
Author: glslang
Date: 2007-05-04 10:24:48 -0700 (Fri, 04 May 2007)
Log Message:
-----------
+ OFX bindings M2
Modified Paths:
--------------
lib/openlibraries/src/openmedialib/plugins/ofx/ofx_plugin.cpp
Modified: lib/openlibraries/src/openmedialib/plugins/ofx/ofx_plugin.cpp
===================================================================
--- lib/openlibraries/src/openmedialib/plugins/ofx/ofx_plugin.cpp 2007-05-03 23:00:00 UTC (rev 112)
+++ lib/openlibraries/src/openmedialib/plugins/ofx/ofx_plugin.cpp 2007-05-04 17:24:48 UTC (rev 113)
@@ -1338,24 +1338,16 @@
bool set_image( il::image_type_ptr im )
{
- if( !im )
- return false;
-
- // TODO: handle bit depths properly.
- il::image_type_ptr dst_img = il::convert( im, L"r8g8b8a8" );
- if( !dst_img )
- return false;
-
pcos::int_vec bounds_and_rod( 4 );
bounds_and_rod[ 0 ] = 0;
bounds_and_rod[ 1 ] = 0;
- bounds_and_rod[ 2 ] = dst_img->width( );
- bounds_and_rod[ 3 ] = dst_img->height( );
+ bounds_and_rod[ 2 ] = im->width( );
+ bounds_and_rod[ 3 ] = im->height( );
image_prop_bounds_ = bounds_and_rod;
image_prop_region_of_definition_ = bounds_and_rod;
- image_prop_data_ = ( void* ) dst_img->data( );
- image_prop_row_bytes_ = dst_img->pitch( );
+ image_prop_data_ = ( void* ) im->data( );
+ image_prop_row_bytes_ = im->pitch( );
return true;
}
@@ -1563,12 +1555,6 @@
container clip_desc_;
};
- struct image_effect_instance_base
- {
- virtual il::image_type_ptr get_source( ) = 0;
- virtual il::image_type_ptr get_output( ) = 0;
- };
-
class clip_instance : public Ofx_base
{
public:
@@ -1667,7 +1653,7 @@
image im_;
};
- class image_effect_instance : public image_effect_instance_base
+ class image_effect_instance : public param_set_base
{
public:
typedef pl::string key_type;
@@ -1679,7 +1665,8 @@
#else
typedef std::map<key_type, clip_instance_ptr> container;
#endif
- typedef container::const_iterator const_iterator;
+ typedef container::iterator iterator;
+ typedef container::const_iterator const_iterator;
public:
explicit image_effect_instance( )
@@ -1700,7 +1687,10 @@
void init( image_effect_descriptor& id )
{
+ param_set_.reset( id.create_instance( ) );
+ for( image_effect_descriptor::const_iterator I = id.clip_begin( ); I != id.clip_end( ); ++I )
+ clip_instance_.insert( container::value_type( I->first, clip_instance_ptr( I->second->create_instance( ) ) ) );
}
virtual property_container_ptr get_property_set( ) { return &effect_instance_props_; }
@@ -1713,16 +1703,22 @@
return I->second.get( );
return 0;
}
-
- il::image_type_ptr get_source( )
- { return source_; }
- il::image_type_ptr get_output( )
- { return output_; }
- void set_source( il::image_type_ptr im )
- { source_ = im; }
- void set_output( il::image_type_ptr im )
- { output_ = im; }
+ bool set_source( il::image_type_ptr im ) { return set_clip_image( "Source", im ); }
+ bool set_output( il::image_type_ptr im ) { return set_clip_image( "Output", im ); }
+
+ private:
+ bool set_clip_image( const pl::string& name, il::image_type_ptr im )
+ {
+ iterator I = clip_instance_.find( name );
+ if( I != clip_instance_.end( ) )
+ {
+ I->second->set_image( im );
+ return true;
+ }
+
+ return false;
+ }
private:
void set_image_effect_instance_properties( )
@@ -1757,13 +1753,7 @@
private:
container clip_instance_;
-
- private:
param_set_ptr param_set_;
-
- private:
- il::image_type_ptr source_;
- il::image_type_ptr output_;
};
OfxStatus param_set_descriptor::define( const pl::string& param_type, const pl::string& name )
@@ -1917,7 +1907,9 @@
plug_->mainEntry( kOfxActionDescribe, &image_effect_descriptor_, 0, 0 );
describe_in_context( );
-
+
+ // create instance from descriptor
+ image_effect_instance_.init( image_effect_descriptor_ );
plug_->mainEntry( kOfxActionCreateInstance, &image_effect_instance_, 0, 0 );
}
@@ -1928,9 +1920,7 @@
}
virtual const opl::wstring get_uri( ) const
- {
- return pl::to_wstring( plug_->pluginIdentifier );
- }
+ { return pl::to_wstring( plug_->pluginIdentifier ); }
virtual frame_type_ptr fetch( )
{
@@ -1939,9 +1929,11 @@
frame_type_ptr result = fetch_from_slot( );
if( result && result->get_image( ) )
{
- il::image_type_ptr src = result->get_image( );
+ il::image_type_ptr src = il::convert( result->get_image( ), L"r8g8b8a8" );
+ il::image_type_ptr dst = il::allocate( src->pf( ), src->width( ), src->height( ) );
+
image_effect_instance_.set_source( src );
- image_effect_instance_.set_output( il::allocate( src->pf( ), src->width( ), src->height( ) ) );
+ image_effect_instance_.set_output( dst );
pcos::property_container sequence_in_args;
sequence_in_args.append( sequence_prop_frame_range_ = pcos::double_vec( 2 ) );
@@ -1969,7 +1961,7 @@
plug_->mainEntry( kOfxImageEffectActionRender, &image_effect_instance_, ( OfxPropertySetHandle ) &render_in_args, 0 );
plug_->mainEntry( kOfxImageEffectActionEndSequenceRender, &image_effect_instance_, ( OfxPropertySetHandle ) &sequence_in_args, 0 );
- result->set_image( image_effect_instance_.get_output( ) );
+ result->set_image( dst );
}
return result;
@@ -2398,12 +2390,12 @@
}
// Interactive Suite.
- OfxStatus interact_swap_buffers( OfxInteractHandle interact_instance )
+ OfxStatus interact_swap_buffers( OfxInteractHandle )
{
return kOfxStatOK;
}
- OfxStatus interact_redraw( OfxInteractHandle interact_instance )
+ OfxStatus interact_redraw( OfxInteractHandle )
{
return kOfxStatOK;
}
@@ -2805,8 +2797,8 @@
image_effect_descriptor* desc = ( image_effect_descriptor* ) image_effect;
clip_descriptor* clip_desc = desc->clip_get_handle( name );
- if( clip_desc )
- desc->append_clip( name );
+ if( !clip_desc )
+ clip_desc = desc->append_clip( name );
if( property_set )
*property_set = ( OfxPropertySetHandle ) clip_desc->get_property_set( );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|