From 660e2957873c44cfab53eb2b6bcd165894afe747 Mon Sep 17 00:00:00 2001 From: lilo_booter Date: Mon, 3 Jan 2005 20:15:00 +0000 Subject: [PATCH] Next/Prev key extraction git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@603 d19143bc-622f-0410-bfdd-b5b2a6649095 --- src/framework/mlt_geometry.c | 30 ++++++++++++++++++++++++++---- src/framework/mlt_geometry.h | 3 ++- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/framework/mlt_geometry.c b/src/framework/mlt_geometry.c index 7a9944c..2bfbe77 100644 --- a/src/framework/mlt_geometry.c +++ b/src/framework/mlt_geometry.c @@ -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 ); @@ -520,7 +524,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 +537,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,6 +554,24 @@ 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 ) { struct mlt_geometry_item_s item; @@ -590,7 +612,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 diff --git a/src/framework/mlt_geometry.h b/src/framework/mlt_geometry.h index 357543a..41cd013 100644 --- a/src/framework/mlt_geometry.h +++ b/src/framework/mlt_geometry.h @@ -61,7 +61,8 @@ extern int mlt_geometry_insert( mlt_geometry self, mlt_geometry_item item ); // Remove the key at the specified position extern int mlt_geometry_remove( mlt_geometry self, int position ); // Get the key at the position or the next following -extern int mlt_geometry_key( mlt_geometry self, mlt_geometry_item item, int position ); +extern int mlt_geometry_next_key( mlt_geometry self, mlt_geometry_item item, int position ); +extern int mlt_geometry_prev_key( mlt_geometry self, mlt_geometry_item item, int position ); // Serialise the current geometry extern char *mlt_geometry_serialise_cut( mlt_geometry self, int in, int out ); extern char *mlt_geometry_serialise( mlt_geometry self ); -- 1.7.4.4