X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fframework%2Fmlt_geometry.c;h=87a9623251086876e53a83b02690836da3b68efd;hb=ae748aa4403b44430bbf57b49aa6f386f15d8407;hp=7a9944c5c7be40c88a1f93c17239882164e06716;hpb=8ccc2d1a7455217e06eca83901e705fb589715c6;p=melted diff --git a/src/framework/mlt_geometry.c b/src/framework/mlt_geometry.c index 7a9944c..87a9623 100644 --- a/src/framework/mlt_geometry.c +++ b/src/framework/mlt_geometry.c @@ -1,5 +1,5 @@ /* - * mlt_geometry.h -- provides the geometry API + * mlt_geometry.c -- provides the geometry API * Copyright (C) 2004-2005 Ushodaya Enterprises Limited * Author: Charles Yates * @@ -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; @@ -173,6 +173,11 @@ static int mlt_geometry_drop( mlt_geometry this, geometry_item item ) self->item->data.f[4] = 1; } } + else if ( item->next != NULL && item->prev != NULL ) + { + item->prev->next = item->next; + item->next->prev = item->prev; + } else if ( item->next != NULL ) { item->next->prev = item->prev; @@ -180,7 +185,6 @@ static int mlt_geometry_drop( mlt_geometry this, geometry_item item ) else if ( item->prev != NULL ) { item->prev->next = item->next; - item->next->prev = item->prev; } free( item ); @@ -277,7 +281,7 @@ void mlt_geometry_set_length( mlt_geometry this, int length ) // Get the local/private structure geometry self = this->local; - // return the length + // set the length self->length = length; } @@ -438,6 +442,7 @@ int mlt_geometry_fetch( mlt_geometry this, mlt_geometry_item item, float positio else { memset( item, 0, sizeof( struct mlt_geometry_item_s ) ); + item->frame = position; item->mix = 100; } @@ -520,7 +525,7 @@ int mlt_geometry_remove( mlt_geometry this, int position ) // Get the first item geometry_item place = self->item; - while( place != NULL && position < place->data.frame ) + while( place != NULL && position != place->data.frame ) place = place->next; if ( place != NULL && position == place->data.frame ) @@ -533,7 +538,7 @@ int mlt_geometry_remove( mlt_geometry this, int position ) } // Get the key at the position or the next following -int mlt_geometry_key( mlt_geometry this, mlt_geometry_item item, int position ) +int mlt_geometry_next_key( mlt_geometry this, mlt_geometry_item item, int position ) { // Get the local/private geometry structure geometry self = this->local; @@ -550,8 +555,27 @@ int mlt_geometry_key( mlt_geometry this, mlt_geometry_item item, int position ) return place == NULL; } +// Get the key at the position or the previous key +int mlt_geometry_prev_key( mlt_geometry this, mlt_geometry_item item, int position ) +{ + // Get the local/private geometry structure + geometry self = this->local; + + // Get the first item + geometry_item place = self->item; + + while( place != NULL && place->next != NULL && position >= place->next->data.frame ) + place = place->next; + + if ( place != NULL ) + memcpy( item, &place->data, sizeof( struct mlt_geometry_item_s ) ); + + return place == NULL; +} + char *mlt_geometry_serialise_cut( mlt_geometry this, int in, int out ) { + geometry self = this->local; struct mlt_geometry_item_s item; char *ret = malloc( 1000 ); int used = 0; @@ -580,6 +604,14 @@ char *mlt_geometry_serialise_cut( mlt_geometry this, int in, int out ) if ( mlt_geometry_fetch( this, &item, item.frame ) ) break; + // If the first key is larger than the current position + // then do nothing here + if ( self->item->data.frame > item.frame ) + { + item.frame ++; + continue; + } + // To ensure correct seeding, ensure all values are fixed item.f[0] = 1; item.f[1] = 1; @@ -590,7 +622,7 @@ char *mlt_geometry_serialise_cut( mlt_geometry this, int in, int out ) // Typically, we move from key to key else if ( item.frame < out ) { - if ( mlt_geometry_key( this, &item, item.frame ) ) + if ( mlt_geometry_next_key( this, &item, item.frame ) ) break; // Special case - crop at the out point