]> git.sesse.net Git - mlt/commitdiff
src/framework/mlt_geometry.c
authorlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Fri, 24 Jun 2005 08:36:21 +0000 (08:36 +0000)
committerlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Fri, 24 Jun 2005 08:36:21 +0000 (08:36 +0000)
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

src/framework/mlt_geometry.c
src/framework/mlt_tractor.c
src/modules/core/transition_composite.c
src/modules/sdl/consumer_sdl.c
src/modules/sdl/consumer_sdl_still.c

index 4e894fcccb3246405e7604cb43e15133e80dc82a..87a9623251086876e53a83b02690836da3b68efd 100644 (file)
@@ -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;
index 8de038be735459d537cdc92493a1e3f3137a26ba..ce678cfe6664dd3318052c42e56380db1d4400ab 100644 (file)
@@ -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
index 5e5118b05aad1aecd341d13670f22b97c99f83ab..040ac0a3319b4149ea66ae096c6f26f13dbc1bda 100644 (file)
@@ -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 );
index 62d33e78f576e8bb1100ac87d78295605853e0ea..adc60b42cd1b64fff011aa743372b885ea0b7836 100644 (file)
@@ -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;
index c0848dbec4e0b46c77bc699b6615f862df358e74..418e1c429f3d3210b9f3bda99b39351883e8b772 100644 (file)
@@ -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 )