[Hdrflow-svn] SF.net SVN: hdrflow: [116] lib/openlibraries/src/openmedialib/plugins/ofx/ ofx_plugin
Status: Pre-Alpha
Brought to you by:
glslang
|
From: <gl...@us...> - 2007-05-10 18:02:30
|
Revision: 116
http://hdrflow.svn.sourceforge.net/hdrflow/?rev=116&view=rev
Author: glslang
Date: 2007-05-10 11:02:27 -0700 (Thu, 10 May 2007)
Log Message:
-----------
+ OFX bindings wrap-ups
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-09 22:07:06 UTC (rev 115)
+++ lib/openlibraries/src/openmedialib/plugins/ofx/ofx_plugin.cpp 2007-05-10 18:02:27 UTC (rev 116)
@@ -439,18 +439,46 @@
{
public:
explicit rgb_param_descriptor( )
- { }
+ : rgb_param_descriptor_param_prop_default_( pcos::key::from_string( kOfxParamPropDefault ) )
+ {
+ set_rgb_param_descriptor_properties( );
+ }
virtual param* create_instance( );
+
+ private:
+ void set_rgb_param_descriptor_properties( )
+ {
+ property_container_ptr param_props_ = get_property_set( );
+
+ param_props_->append( rgb_param_descriptor_param_prop_default_ = pcos::double_vec( 3, 0.0 ) );
+ }
+
+ private:
+ pcos::property rgb_param_descriptor_param_prop_default_;
};
class rgba_param_descriptor : public value_param_descriptor
{
public:
explicit rgba_param_descriptor( )
- { }
+ : rgba_param_descriptor_param_prop_default_( pcos::key::from_string( kOfxParamPropDefault ) )
+ {
+ set_rgba_param_descriptor_properties( );
+ }
virtual param* create_instance( );
+
+ private:
+ void set_rgba_param_descriptor_properties( )
+ {
+ property_container_ptr param_props_ = get_property_set( );
+
+ param_props_->append( rgba_param_descriptor_param_prop_default_ = pcos::double_vec( 4, 0.0 ) );
+ }
+
+ private:
+ pcos::property rgba_param_descriptor_param_prop_default_;
};
class boolean_param_descriptor : public value_param_descriptor
@@ -1150,14 +1178,33 @@
public:
explicit rgb_param( rgb_param_descriptor& vpd )
: value_param( vpd )
- , rgb_param_value_( pcos::key::from_string( "value" ) )
- { }
+ , rgb_param_prop_value_( pcos::key::from_string( "value" ) )
+ , rgb_param_prop_default_( pcos::key::from_string( kOfxParamPropDefault ) )
+ {
+ set_rgb_param_properties( vpd );
+ }
- virtual pcos::property get_value( ) { return rgb_param_value_; }
+ virtual pcos::property get_value( ) { return rgb_param_prop_value_; }
virtual pl::string get_type( ) { return kOfxParamTypeRGB; }
private:
- pcos::property rgb_param_value_;
+ // assign the instance properties from the descriptor. do not assign properties since
+ // they have shallow copy semantics and clone will cause a leak.
+ // therefore extract all the values and assign those. descriptors and instances are
+ // meant to be separate entities and values should not be shared.
+ void set_rgb_param_properties( rgb_param_descriptor& vpd )
+ {
+ property_container_ptr param_props_ = get_property_set( );
+ property_container_ptr vpd_set = vpd.get_property_set( );
+
+ pcos::double_vec def = vpd_set->get_property_with_key( pcos::key::from_string( kOfxParamPropDefault ) ).value<pcos::double_vec>( );
+ param_props_->append( rgb_param_prop_value_ = def );
+ param_props_->append( rgb_param_prop_default_ = def );
+ }
+
+ private:
+ pcos::property rgb_param_prop_value_;
+ pcos::property rgb_param_prop_default_;
};
class rgba_param : public value_param
@@ -1165,14 +1212,33 @@
public:
explicit rgba_param( rgba_param_descriptor& vpd )
: value_param( vpd )
- , rgba_param_value_( pcos::key::from_string( "value" ) )
- { }
+ , rgba_param_prop_value_( pcos::key::from_string( "value" ) )
+ , rgba_param_prop_default_( pcos::key::from_string( kOfxParamPropDefault ) )
+ {
+ set_rgba_param_properties( vpd );
+ }
- virtual pcos::property get_value( ) { return rgba_param_value_; }
+ virtual pcos::property get_value( ) { return rgba_param_prop_value_; }
virtual pl::string get_type( ) { return kOfxParamTypeRGBA; }
+
+ private:
+ // assign the instance properties from the descriptor. do not assign properties since
+ // they have shallow copy semantics and clone will cause a leak.
+ // therefore extract all the values and assign those. descriptors and instances are
+ // meant to be separate entities and values should not be shared.
+ void set_rgba_param_properties( rgba_param_descriptor& vpd )
+ {
+ property_container_ptr param_props_ = get_property_set( );
+ property_container_ptr vpd_set = vpd.get_property_set( );
+
+ pcos::double_vec def = vpd_set->get_property_with_key( pcos::key::from_string( kOfxParamPropDefault ) ).value<pcos::double_vec>( );
+ param_props_->append( rgba_param_prop_value_ = def );
+ param_props_->append( rgba_param_prop_default_ = def );
+ }
private:
- pcos::property rgba_param_value_;
+ pcos::property rgba_param_prop_value_;
+ pcos::property rgba_param_prop_default_;
};
class boolean_param : public value_param
@@ -2024,20 +2090,24 @@
, clip_preferences_prop_field_order_( pcos::key::from_string( kOfxImageClipPropFieldOrder ) )
, clip_preferences_prop_premultiplication_( pcos::key::from_string( kOfxImageEffectPropPreMultiplication ) )
, clip_preferences_prop_continuous_samples_( pcos::key::from_string( kOfxImageClipPropContinuousSamples ) )
- , clip_preferences_prop_frame_varying_( pcos::key::from_string( kOfxImageEffectPropFrameRate ) )
+ , clip_preferences_prop_frame_varying_( pcos::key::from_string( kOfxImageEffectFrameVarying ) )
+ , apply_clip_prefs_( false )
{
+ // set host properties and suite functions.
set_host( );
set_suites( );
set_host_parameters( );
+ // load and describe the plugin.
plug_->mainEntry( kOfxActionLoad, 0, 0, 0 );
plug_->mainEntry( kOfxActionDescribe, &image_effect_descriptor_, 0, 0 );
describe_in_context( );
- // create instance from descriptor
+ // create instance from descriptor.
image_effect_instance_.init( image_effect_descriptor_ );
+ // create any overlay instances if exist.
if( ( interact_main_ = image_effect_descriptor_.overlay_interact( ) ) != 0 )
{
interact_main_( kOfxActionDescribe, &overlay_interact_descriptor_, 0, 0 );
@@ -2048,8 +2118,10 @@
if( interact_main_ )
interact_main_( kOfxActionCreateInstance, &overlay_interact_instance_, 0, 0 );
+ // get plugin preferences.
set_clip_prefs_ctx( );
- plug_->mainEntry( kOfxImageEffectActionGetClipPreferences, &image_effect_instance_, 0, ( OfxPropertySetHandle ) &clip_preferences_props_filter_ );
+ if( plug_->mainEntry( kOfxImageEffectActionGetClipPreferences, &image_effect_instance_, 0, ( OfxPropertySetHandle ) &clip_preferences_props_filter_ ) == kOfxStatOK )
+ apply_clip_prefs_ = true;
}
virtual ~ofx_filter( )
@@ -2071,8 +2143,14 @@
frame_type_ptr result = fetch_from_slot( );
if( result && result->get_image( ) )
{
- il::image_type_ptr src = il::convert( result->get_image( ), L"r8g8b8a8" );
+ il::image_type_ptr src = result->get_image( );
+ il::image_type_ptr dst;
+ if( apply_clip_prefs_ )
+ apply_clip_prefs_filter_ctx( src, dst );
+ else
+ dst = il::allocate( src->pf( ), src->width( ), src->height( ) );
+
pcos::property_container render_in_args;
pcos::property_container render_out_args;
@@ -2080,32 +2158,26 @@
render_win[ 2 ] = src->width( );
render_win[ 3 ] = src->height( );
- pcos::int_vec render_scale( 2, 1 );
-
render_in_args.append( render_prop_time_ = 0.0 );
render_in_args.append( render_prop_field_to_render_ = pl::string( kOfxImageFieldNone ) );
render_in_args.append( render_prop_render_window_ = render_win );
- render_in_args.append( render_prop_render_scale_ = render_scale );
+ render_in_args.append( render_prop_render_scale_ = pcos::int_vec( 2, 1 ) );
render_out_args.append( render_prop_name_ );
render_out_args.append( render_prop_time_ = 0.0 );
- src = il::convert( result->get_image( ), L"r8g8b8a8" );
image_effect_instance_.set_source( src );
+ image_effect_instance_.set_output( dst );
OfxStatus is_identity = plug_->mainEntry( kOfxImageEffectActionIsIdentity, &image_effect_instance_,
( OfxPropertySetHandle ) &render_in_args, ( OfxPropertySetHandle ) &render_out_args );
if( is_identity == kOfxStatReplyDefault )
{
- il::image_type_ptr dst = 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 ) );
+ sequence_in_args.append( sequence_prop_frame_range_ = pcos::double_vec( 2, 1.0 ) );
sequence_in_args.append( sequence_prop_frame_step_ = 1.0 );
sequence_in_args.append( sequence_prop_is_interactive_ = 0 );
- sequence_in_args.append( sequence_prop_render_scale_ = pcos::double_vec( 2 ) );
+ sequence_in_args.append( sequence_prop_render_scale_ = pcos::double_vec( 2, 1.0 ) );
plug_->mainEntry( kOfxImageEffectActionBeginSequenceRender, &image_effect_instance_, ( OfxPropertySetHandle ) &sequence_in_args, 0 );
plug_->mainEntry( kOfxImageEffectActionRender, &image_effect_instance_, ( OfxPropertySetHandle ) &render_in_args, 0 );
@@ -2234,6 +2306,7 @@
return plug_->mainEntry( kOfxImageEffectActionDescribeInContext, &image_effect_descriptor_, ( OfxPropertySetHandle ) &in_args, 0 ) == kOfxStatOK;
}
+private:
void set_clip_prefs_filter_ctx( )
{
clip_preferences_props_filter_.append( clip_preferences_prop_components_source_ );
@@ -2242,11 +2315,6 @@
clip_preferences_props_filter_.append( clip_preferences_prop_depth_output_ );
clip_preferences_props_filter_.append( clip_preferences_prop_par_source_ );
clip_preferences_props_filter_.append( clip_preferences_prop_par_output_ );
- clip_preferences_props_filter_.append( clip_preferences_prop_frame_rate_ );
- clip_preferences_props_filter_.append( clip_preferences_prop_field_order_ );
- clip_preferences_props_filter_.append( clip_preferences_prop_premultiplication_ );
- clip_preferences_props_filter_.append( clip_preferences_prop_continuous_samples_ );
- clip_preferences_props_filter_.append( clip_preferences_prop_frame_varying_ );
}
void set_clip_prefs_generator_ctx( )
@@ -2255,11 +2323,38 @@
void set_clip_prefs_ctx( )
{
+ clip_preferences_props_filter_.append( clip_preferences_prop_frame_rate_ );
+ clip_preferences_props_filter_.append( clip_preferences_prop_field_order_ );
+ clip_preferences_props_filter_.append( clip_preferences_prop_premultiplication_ );
+ clip_preferences_props_filter_.append( clip_preferences_prop_continuous_samples_ );
+ clip_preferences_props_filter_.append( clip_preferences_prop_frame_varying_ );
+
if( context_ == FILTER ) set_clip_prefs_filter_ctx( );
else if( context_ == GENERATOR ) set_clip_prefs_generator_ctx( );
}
private:
+ void apply_clip_prefs_filter_ctx( il::image_type_ptr& src, il::image_type_ptr& dst )
+ {
+ int source_depth = clip_preferences_prop_depth_source_.value<int>( );
+ int output_depth = clip_preferences_prop_depth_output_.value<int>( );
+
+ if( source_depth == 8 )
+ src = il::convert( src, L"r8g8b8a8" );
+ else if( source_depth == 16 )
+ src = il::convert( src, L"r16g16b16a16" );
+ else if( source_depth == 32 )
+ src = il::convert( src, L"r32g32b32a32f" );
+
+ if( output_depth == 8 )
+ dst = il::allocate( L"r8g8b8a8", src->width( ), src->height( ) );
+ else if( output_depth == 16 )
+ dst = il::allocate( L"r16g16b16a16", src->width( ), src->height( ) );
+ else if( output_depth == 32 )
+ dst = il::allocate( L"r32g32b32a32f", src->width( ), src->height( ) );
+ }
+
+private:
OfxPlugin* plug_;
ofx_context context_;
@@ -2340,6 +2435,7 @@
pcos::property clip_preferences_prop_premultiplication_;
pcos::property clip_preferences_prop_continuous_samples_;
pcos::property clip_preferences_prop_frame_varying_;
+ bool apply_clip_prefs_;
};
namespace
@@ -2497,9 +2593,9 @@
pcos::property src = prop_set->get_property_with_string( property );
if( src.is_a<pl::string_vec>( ) )
{
- pl::string_vec val = src.value<pl::string_vec>( );
+ pl::string_vec* val = src.pointer<pl::string_vec>( );
for( int i = 0; i < count; ++i )
- value[ i ] = const_cast<char*>( src.value<opl::string>( ).c_str( ) );
+ value[ i ] = const_cast<char*>( ( *val )[ i ].c_str( ) );
}
return kOfxStatOK;
@@ -2544,6 +2640,11 @@
return kOfxStatOK;
}
+ OfxStatus prop_reset( OfxPropertySetHandle properties, const char* property )
+ {
+ return kOfxStatOK;
+ }
+
// Memory Suite.
OfxStatus memory_alloc( void* handle, size_t nbytes, void** allocated_data )
{
@@ -3113,7 +3214,7 @@
property_suite.propGetStringN = prop_get_stringN;
property_suite.propGetDoubleN = prop_get_doubleN;
property_suite.propGetIntN = prop_get_intN;
- //property_suite.propReset = prop_reset;
+ property_suite.propReset = prop_reset;
property_suite.propGetDimension = prop_get_dimension;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|