From: lilo_booter Date: Fri, 24 Jun 2005 08:36:21 +0000 (+0000) Subject: src/framework/mlt_geometry.c X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=ae748aa4403b44430bbf57b49aa6f386f15d8407;p=mlt src/framework/mlt_geometry.c src/modules/core/transition_composite.c src/modules/sdl/consumer_sdl.c src/modules/sdl/consumer_sdl_still.c + replaced floats with doubles (attempt to avoid rounding errors?) src/framework/mlt_tractor.c + corrections for fx_cuts (allows animated fx) git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@739 d19143bc-622f-0410-bfdd-b5b2a6649095 --- diff --git a/src/framework/mlt_geometry.c b/src/framework/mlt_geometry.c index 4e894fcc..87a96232 100644 --- a/src/framework/mlt_geometry.c +++ b/src/framework/mlt_geometry.c @@ -98,9 +98,9 @@ static void mlt_geometry_virtual_refresh( mlt_geometry this ) geometry_item prev = current->prev; geometry_item next = current->next; - float prev_value = 0; - float next_value = 0; - float value = 0; + double prev_value = 0; + double next_value = 0; + double value = 0; while( prev != NULL && !prev->data.f[ i ] ) prev = prev->prev; while( next != NULL && !next->data.f[ i ] ) next = next->next; diff --git a/src/framework/mlt_tractor.c b/src/framework/mlt_tractor.c index 8de038be..ce678cfe 100644 --- a/src/framework/mlt_tractor.c +++ b/src/framework/mlt_tractor.c @@ -326,21 +326,47 @@ static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int tra // Handle fx only tracks if ( mlt_properties_get_int( temp_properties, "meta.fx_cut" ) ) { - // Take all but the first placeholding producer and dump on to the image stack + mlt_properties copy = video == NULL ? frame_properties : MLT_FRAME_PROPERTIES( video ); + int i = 0; + + for ( i = 0; i < mlt_properties_count( temp_properties ); i ++ ) + { + char *name = mlt_properties_get_name( temp_properties, i ); + char *value = mlt_properties_get_value( temp_properties, i ); + // For animated filters + if ( isdigit( name[ 0 ] ) && value != NULL ) + mlt_properties_set( copy, name, value ); + } + if ( video ) { + // Take all but the first placeholding producer and dump on to the image stack void *p = mlt_deque_pop_front( MLT_FRAME_IMAGE_STACK( temp ) ); while ( ( p = mlt_deque_pop_front( MLT_FRAME_IMAGE_STACK( temp ) ) ) != NULL ) mlt_deque_push_back( MLT_FRAME_IMAGE_STACK( video ), p ); } + else + { + void *p = NULL; + while ( ( p = mlt_deque_pop_front( MLT_FRAME_IMAGE_STACK( temp ) ) ) != NULL ) + mlt_deque_push_back( MLT_FRAME_IMAGE_STACK( *frame ), p ); + mlt_properties_set_int( frame_properties, "meta.fx_cut", 1 ); + } - // Take all but the first placeholding producer and dump on to the audio stack if ( audio ) { + // Take all but the first placeholding producer and dump on to the audio stack void *p = mlt_deque_pop_front( MLT_FRAME_AUDIO_STACK( temp ) ); while ( ( p = mlt_deque_pop_front( MLT_FRAME_AUDIO_STACK( temp ) ) ) != NULL ) mlt_deque_push_back( MLT_FRAME_AUDIO_STACK( audio ), p ); } + else + { + void *p = NULL; + while ( ( p = mlt_deque_pop_front( MLT_FRAME_AUDIO_STACK( temp ) ) ) != NULL ) + mlt_deque_push_back( MLT_FRAME_AUDIO_STACK( *frame ), p ); + mlt_properties_set_int( frame_properties, "meta.fx_cut", 1 ); + } // Ensure everything is hidden mlt_properties_set_int( temp_properties, "hide", 3 ); @@ -385,6 +411,7 @@ static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int tra audio = temp; if ( !done && !mlt_frame_is_test_card( temp ) && !( mlt_properties_get_int( temp_properties, "hide" ) & 1 ) ) video = temp; + } // Now stack callbacks diff --git a/src/modules/core/transition_composite.c b/src/modules/core/transition_composite.c index 5e5118b0..040ac0a3 100644 --- a/src/modules/core/transition_composite.c +++ b/src/modules/core/transition_composite.c @@ -70,7 +70,7 @@ static int alignment_parse( char* align ) /** Calculate real geometry. */ -static void geometry_calculate( mlt_transition this, struct geometry_s *output, float position ) +static void geometry_calculate( mlt_transition this, struct geometry_s *output, double position ) { mlt_properties properties = MLT_TRANSITION_PROPERTIES( this ); mlt_geometry geometry = mlt_properties_get_data( properties, "geometries", NULL ); @@ -191,20 +191,20 @@ static int position_calculate( mlt_transition this, mlt_position position ) /** Calculate the field delta for this frame - position between two frames. */ -static inline float delta_calculate( mlt_transition this, mlt_frame frame ) +static inline double delta_calculate( mlt_transition this, mlt_frame frame ) { // Get the in and out position mlt_position in = mlt_transition_get_in( this ); mlt_position out = mlt_transition_get_out( this ); - float length = out - in + 1; + double length = out - in + 1; // Get the position of the frame char *name = mlt_properties_get( MLT_TRANSITION_PROPERTIES( this ), "_unique_id" ); mlt_position position = mlt_properties_get_position( MLT_FRAME_PROPERTIES( frame ), name ); // Now do the calcs - float x = ( float )( position - in ) / length; - float y = ( float )( position + 1 - in ) / length; + double x = ( double )( position - in ) / length; + double y = ( double )( position + 1 - in ) / length; return length * ( y - x ) / 2.0; } @@ -769,7 +769,7 @@ static int get_b_frame_image( mlt_transition this, mlt_frame b_frame, uint8_t ** } -static mlt_geometry composite_calculate( mlt_transition this, struct geometry_s *result, mlt_frame a_frame, float position ) +static mlt_geometry composite_calculate( mlt_transition this, struct geometry_s *result, mlt_frame a_frame, double position ) { // Get the properties from the transition mlt_properties properties = MLT_TRANSITION_PROPERTIES( this ); @@ -865,7 +865,7 @@ mlt_frame composite_copy_region( mlt_transition this, mlt_frame a_frame, mlt_pos // Will need to know region to copy struct geometry_s result; - float delta = delta_calculate( this, a_frame ); + double delta = delta_calculate( this, a_frame ); // Calculate the region now composite_calculate( this, &result, a_frame, position + delta / 2 ); @@ -980,8 +980,8 @@ static int transition_get_image( mlt_frame a_frame, uint8_t **image, mlt_image_f struct geometry_s result; // Calculate the position - float position = mlt_properties_get_double( b_props, "relative_position" ); - float delta = delta_calculate( this, a_frame ); + double position = mlt_properties_get_double( b_props, "relative_position" ); + double delta = delta_calculate( this, a_frame ); // Get the image from the b frame uint8_t *image_b = NULL; @@ -1065,7 +1065,7 @@ static int transition_get_image( mlt_frame a_frame, uint8_t **image, mlt_image_f for ( field = 0; field < ( progressive ? 1 : 2 ); field++ ) { // Assume lower field (0) first - float field_position = position + field * delta; + double field_position = position + field * delta; // Do the calculation if we need to composite_calculate( this, &result, a_frame, field_position ); diff --git a/src/modules/sdl/consumer_sdl.c b/src/modules/sdl/consumer_sdl.c index 62d33e78..adc60b42 100644 --- a/src/modules/sdl/consumer_sdl.c +++ b/src/modules/sdl/consumer_sdl.c @@ -151,7 +151,7 @@ mlt_consumer consumer_sdl_init( char *arg ) } // Default window size - this->window_width = ( float )this->height * display_ratio; + this->window_width = ( double )this->height * display_ratio; this->window_height = this->height; // Set the sdl flags @@ -251,7 +251,7 @@ static void sdl_fill_audio( void *udata, uint8_t *stream, int len ) consumer_sdl this = udata; // Get the volume - float volume = mlt_properties_get_double( this->properties, "volume" ); + double volume = mlt_properties_get_double( this->properties, "volume" ); pthread_mutex_lock( &this->audio_mutex ); @@ -279,7 +279,7 @@ static void sdl_fill_audio( void *udata, uint8_t *stream, int len ) memcpy( stream, this->audio_buffer, this->audio_avail ); // Mix the audio - SDL_MixAudio( stream, stream, len, ( int )( ( float )SDL_MIX_MAXVOLUME * volume ) ); + SDL_MixAudio( stream, stream, len, ( int )( ( double )SDL_MIX_MAXVOLUME * volume ) ); // No audio left this->audio_avail = 0; @@ -460,13 +460,13 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame ) if ( this->running ) { // Determine window's new display aspect ratio - float this_aspect = ( float )this->window_width / this->window_height; + double this_aspect = ( double )this->window_width / this->window_height; // Get the display aspect ratio double display_ratio = mlt_properties_get_double( properties, "display_ratio" ); // Determine frame's display aspect ratio - float frame_aspect = mlt_frame_get_aspect_ratio( frame ) * width / height; + double frame_aspect = mlt_frame_get_aspect_ratio( frame ) * width / height; // Store the width and height received this->width = width; diff --git a/src/modules/sdl/consumer_sdl_still.c b/src/modules/sdl/consumer_sdl_still.c index c0848dbe..418e1c42 100644 --- a/src/modules/sdl/consumer_sdl_still.c +++ b/src/modules/sdl/consumer_sdl_still.c @@ -113,7 +113,7 @@ mlt_consumer consumer_sdl_still_init( char *arg ) } // Default window size - this->window_width = ( float )this->height * display_ratio; + this->window_width = ( double )this->height * display_ratio; this->window_height = this->height; // Set the sdl flags @@ -432,7 +432,7 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame ) char *rescale = mlt_properties_get( properties, "rescale" ); if ( rescale != NULL && strcmp( rescale, "none" ) ) { - float this_aspect = display_ratio / ( ( float )this->window_width / ( float )this->window_height ); + double this_aspect = display_ratio / ( ( double )this->window_width / ( double )this->window_height ); this->rect.w = this_aspect * this->window_width; this->rect.h = this->window_height; if ( this->rect.w > this->window_width ) @@ -443,7 +443,7 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame ) } else { - float frame_aspect = mlt_frame_get_aspect_ratio( frame ) * width / height; + double frame_aspect = mlt_frame_get_aspect_ratio( frame ) * width / height; this->rect.w = frame_aspect * this->window_height; this->rect.h = this->window_height; if ( this->rect.w > this->window_width )