[Jahshaka-cvs] openlibraries/src/openmedialib/plugins/ofx ofx_plugin.cpp, 1.6, 1.7
Status: Beta
Brought to you by:
jahshaka
From: Goncalo N. M. de C. <gl...@us...> - 2007-05-12 16:42:08
|
Update of /cvsroot/openlibraries/openlibraries/src/openmedialib/plugins/ofx In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv26298 Modified Files: ofx_plugin.cpp Log Message: + OFX bindings wrap-ups (improvements to ClipPreferencesAction handling) Index: ofx_plugin.cpp =================================================================== RCS file: /cvsroot/openlibraries/openlibraries/src/openmedialib/plugins/ofx/ofx_plugin.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- ofx_plugin.cpp 10 May 2007 20:40:53 -0000 1.6 +++ ofx_plugin.cpp 12 May 2007 16:42:03 -0000 1.7 @@ -1448,11 +1448,11 @@ virtual property_container_ptr get_property_set( ) { return &image_props_; } - bool set_image( il::image_type_ptr im ) + bool set_image( il::image_type_ptr im, const pl::string& depth ) { - pcos::int_vec bounds_and_rod( 4 ); - bounds_and_rod[ 0 ] = 0; - bounds_and_rod[ 1 ] = 0; + image_effect_prop_pixel_depth_ = depth; + + pcos::int_vec bounds_and_rod( 4, 0 ); bounds_and_rod[ 2 ] = im->width( ); bounds_and_rod[ 3 ] = im->height( ); @@ -1473,7 +1473,7 @@ image_props_.append( image_prop_type_ = pl::string( kOfxTypeImage ) ); image_props_.append( image_effect_prop_pixel_depth_ = pl::string( kOfxBitDepthNone ) ); - image_props_.append( image_effect_prop_components_ = pl::string( kOfxImageComponentNone ) ); + image_props_.append( image_effect_prop_components_ = pl::string( kOfxImageComponentRGBA ) ); image_props_.append( image_effect_prop_pre_multiplication_ = pl::string( kOfxImageUnPreMultiplied ) ); image_props_.append( image_effect_prop_render_scale_ = render_scale ); image_props_.append( image_prop_pixel_aspect_ratio_ = 1.0 ); @@ -1734,9 +1734,22 @@ virtual property_container_ptr get_property_set( ) { return &clip_instance_props_; } - void set_image( il::image_type_ptr im ) { im_.set_image( im ), img_ = im; } - property_container_ptr get_image_property_set( ) { return im_.get_property_set( ); } - il::image_type_ptr get_image( ) { return img_; } + void set_image( il::image_type_ptr im ) + { + pl::string depth; + + im->bitdepth( ) == 8 ? depth = pl::string( kOfxBitDepthByte ) : + im->bitdepth( ) == 32 ? depth = pl::string( kOfxBitDepthFloat ) : depth = pl::string( kOfxBitDepthShort ); + + clip_instance_prop_unmapped_pixel_depth_ = depth; + clip_instance_prop_pixel_depth_ = depth; + + im_.set_image( im, depth ); + img_ = im; + } + + property_container_ptr get_image_property_set( ) { return im_.get_property_set( ); } + il::image_type_ptr get_image( ) { return img_; } private: void set_clip_instance_properties( clip_descriptor& cd ) @@ -1755,7 +1768,7 @@ clip_instance_props_.append( clip_instance_prop_pixel_depth_ = pl::string( kOfxBitDepthNone ) ); clip_instance_props_.append( clip_instance_prop_components_ = pl::string( kOfxImageComponentNone ) ); clip_instance_props_.append( clip_instance_prop_unmapped_pixel_depth_ = pl::string( kOfxBitDepthNone ) ); - clip_instance_props_.append( clip_instance_prop_unmapped_components_ = pl::string( kOfxImageComponentNone ) ); + clip_instance_props_.append( clip_instance_prop_unmapped_components_ = pl::string( kOfxImageComponentRGBA ) ); clip_instance_props_.append( clip_instance_prop_premultiplication_ = pl::string( kOfxImageOpaque ) ); clip_instance_props_.append( clip_instance_prop_pixel_aspect_ratio_ = 1.0 ); clip_instance_props_.append( clip_instance_prop_frame_rate_ = 0.0 ); @@ -2107,7 +2120,7 @@ // create instance from descriptor. image_effect_instance_.init( image_effect_descriptor_ ); - // create any overlay instances if exist. + // create any overlay instances... if( ( interact_main_ = image_effect_descriptor_.overlay_interact( ) ) != 0 ) { interact_main_( kOfxActionDescribe, &overlay_interact_descriptor_, 0, 0 ); @@ -2146,10 +2159,8 @@ 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( ) ); + if( context_ == FILTER ) + convert_to_filter_ctx( src, dst ); pcos::property_container render_in_args; pcos::property_container render_out_args; @@ -2333,26 +2344,43 @@ } private: - void apply_clip_prefs_filter_ctx( il::image_type_ptr& src, il::image_type_ptr& dst ) + void convert_to_filter_ctx( il::image_type_ptr& src, il::image_type_ptr& dst ) { - pl::string source_depth = clip_preferences_prop_depth_source_.value<pl::string>( ); - pl::string output_depth = clip_preferences_prop_depth_output_.value<pl::string>( ); - - if( !source_depth.empty( ) ) + if( apply_clip_prefs_ ) { - if( source_depth == kOfxBitDepthByte ) src = il::convert( src, L"r8g8b8a8" ); - else if( source_depth == kOfxBitDepthShort ) src = il::convert( src, L"r16g16b16a16" ); - else if( source_depth == kOfxBitDepthFloat ) src = il::convert( src, L"r32g32b32a32f" ); - } + pl::string source_depth = clip_preferences_prop_depth_source_.value<pl::string>( ); + pl::string output_depth = clip_preferences_prop_depth_output_.value<pl::string>( ); - if( !output_depth.empty( ) ) - { - if( output_depth == kOfxBitDepthByte ) dst = il::allocate( L"r8g8b8a8", src->width( ), src->height( ) ); - else if( output_depth == kOfxBitDepthShort ) dst = il::allocate( L"r16g16b16a16", src->width( ), src->height( ) ); - else if( output_depth == kOfxBitDepthFloat ) dst = il::allocate( L"r32g32b32a32f", src->width( ), src->height( ) ); + if( !source_depth.empty( ) ) + { + if( source_depth == kOfxBitDepthByte ) src = il::convert( src, L"r8g8b8a8" ); + else if( source_depth == kOfxBitDepthShort ) src = il::convert( src, L"r16g16b16a16" ); + else if( source_depth == kOfxBitDepthFloat ) src = il::convert( src, L"r32g32b32a32f" ); + } + + if( !output_depth.empty( ) ) + { + if( output_depth == kOfxBitDepthByte ) dst = il::allocate( L"r8g8b8a8", src->width( ), src->height( ) ); + else if( output_depth == kOfxBitDepthShort ) dst = il::allocate( L"r16g16b16a16", src->width( ), src->height( ) ); + else if( output_depth == kOfxBitDepthFloat ) dst = il::allocate( L"r32g32b32a32f", src->width( ), src->height( ) ); + } + else + { + dst = il::allocate( src->pf( ), src->width( ), src->height( ) ); + } } else { + if( src->is_float( ) ) + { + src = il::convert( src, L"r32g32b32a32f" ); + } + else + { + if( src->bitdepth( ) == 8 ) src = il::convert( src, L"r8g8b8a8" ); + else src = il::convert( src, L"r16g16b16a16" ); + } + dst = il::allocate( src->pf( ), src->width( ), src->height( ) ); } } |