]> git.sesse.net Git - mlt/commitdiff
Next/Prev key extraction
authorlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Mon, 3 Jan 2005 20:15:00 +0000 (20:15 +0000)
committerlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Mon, 3 Jan 2005 20:15:00 +0000 (20:15 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@603 d19143bc-622f-0410-bfdd-b5b2a6649095

src/framework/mlt_geometry.c
src/framework/mlt_geometry.h

index 7a9944c5c7be40c88a1f93c17239882164e06716..2bfbe777bd82348351d8d8be7fd0e7cb8221f695 100644 (file)
@@ -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
index 357543a0543c5c6b7c00deabe8a4432da9aec44c..41cd0132edd76fdae0bd502fe04b249b5c23a187 100644 (file)
@@ -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 );