]> git.sesse.net Git - mlt/commitdiff
64 bit fix and deque int holding
authorlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Tue, 1 Feb 2005 09:37:33 +0000 (09:37 +0000)
committerlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Tue, 1 Feb 2005 09:37:33 +0000 (09:37 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@651 d19143bc-622f-0410-bfdd-b5b2a6649095

src/framework/mlt_deque.c
src/framework/mlt_deque.h
src/framework/mlt_frame.c
src/framework/mlt_frame.h

index 4d5a2bdb2e495bbb83f448755ae475b252d70f61..d5ec8d807b179a2a7deaece42290b94d37276c70 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 
+typedef union
+{
+       void *addr;
+       int value;
+}
+deque_entry;
+
 /** Private structure.
 */
 
 struct mlt_deque_s
 {
-       void **list;
+       deque_entry *list;
        int size;
        int count;
 };
@@ -65,7 +72,7 @@ static int mlt_deque_allocate( mlt_deque this )
 {
        if ( this->count == this->size )
        {
-               this->list = realloc( this->list, sizeof( void * ) * ( this->size + 20 ) );
+               this->list = realloc( this->list, sizeof( deque_entry ) * ( this->size + 20 ) );
                this->size += 20;
        }
        return this->list == NULL;
@@ -79,7 +86,7 @@ int mlt_deque_push_back( mlt_deque this, void *item )
        int error = mlt_deque_allocate( this );
 
        if ( error == 0 )
-               this->list[ this->count ++ ] = item;
+               this->list[ this->count ++ ].addr = item;
 
        return error;
 }
@@ -89,7 +96,7 @@ int mlt_deque_push_back( mlt_deque this, void *item )
 
 void *mlt_deque_pop_back( mlt_deque this )
 {
-       return this->count > 0 ? this->list[ -- this->count ] : NULL;
+       return this->count > 0 ? this->list[ -- this->count ].addr : NULL;
 }
 
 /** Queue an item at the start.
@@ -101,8 +108,8 @@ int mlt_deque_push_front( mlt_deque this, void *item )
 
        if ( error == 0 )
        {
-               memmove( &this->list[ 1 ], this->list, ( this->count ++ ) * sizeof( void * ) );
-               this->list[ 0 ] = item;
+               memmove( &this->list[ 1 ], this->list, ( this->count ++ ) * sizeof( deque_entry ) );
+               this->list[ 0 ].addr = item;
        }
 
        return error;
@@ -117,8 +124,8 @@ void *mlt_deque_pop_front( mlt_deque this )
 
        if ( this->count > 0 )
        {
-               item = this->list[ 0 ];
-               memmove( this->list, &this->list[ 1 ], ( -- this->count ) * sizeof( void * ) );
+               item = this->list[ 0 ].addr;
+               memmove( this->list, &this->list[ 1 ], ( -- this->count ) * sizeof( deque_entry ) );
        }
 
        return item;
@@ -129,7 +136,7 @@ void *mlt_deque_pop_front( mlt_deque this )
 
 void *mlt_deque_peek_back( mlt_deque this )
 {
-       return this->count > 0 ? this->list[ this->count - 1 ] : NULL;
+       return this->count > 0 ? this->list[ this->count - 1 ].addr : NULL;
 }
 
 /** Inquire on item at front of deque but don't remove.
@@ -137,7 +144,76 @@ void *mlt_deque_peek_back( mlt_deque this )
 
 void *mlt_deque_peek_front( mlt_deque this )
 {
-       return this->count > 0 ? this->list[ 0 ] : NULL;
+       return this->count > 0 ? this->list[ 0 ].addr : NULL;
+}
+
+/** Push an item to the end.
+*/
+
+int mlt_deque_push_back_int( mlt_deque this, int item )
+{
+       int error = mlt_deque_allocate( this );
+
+       if ( error == 0 )
+               this->list[ this->count ++ ].value = item;
+
+       return error;
+}
+
+/** Pop an item.
+*/
+
+int mlt_deque_pop_back_int( mlt_deque this )
+{
+       return this->count > 0 ? this->list[ -- this->count ].value : 0;
+}
+
+/** Queue an item at the start.
+*/
+
+int mlt_deque_push_front_int( mlt_deque this, int item )
+{
+       int error = mlt_deque_allocate( this );
+
+       if ( error == 0 )
+       {
+               memmove( &this->list[ 1 ], this->list, ( this->count ++ ) * sizeof( deque_entry ) );
+               this->list[ 0 ].value = item;
+       }
+
+       return error;
+}
+
+/** Remove an item from the start.
+*/
+
+int mlt_deque_pop_front_int( mlt_deque this )
+{
+       int item = 0;
+
+       if ( this->count > 0 )
+       {
+               item = this->list[ 0 ].value;
+               memmove( this->list, &this->list[ 1 ], ( -- this->count ) * sizeof( deque_entry ) );
+       }
+
+       return item;
+}
+
+/** Inquire on item at back of deque but don't remove.
+*/
+
+int mlt_deque_peek_back_int( mlt_deque this )
+{
+       return this->count > 0 ? this->list[ this->count - 1 ].value : 0;
+}
+
+/** Inquire on item at front of deque but don't remove.
+*/
+
+int mlt_deque_peek_front_int( mlt_deque this )
+{
+       return this->count > 0 ? this->list[ 0 ].value : 0;
 }
 
 /** Close the queue.
@@ -149,4 +225,3 @@ void mlt_deque_close( mlt_deque this )
        free( this );
 }
 
-
index fd168153d6cb0be6a56853cf5136fcfc3dd9eecb..f70a3901017742127a75b4641532d339f8c6e247 100644 (file)
@@ -31,6 +31,14 @@ extern int mlt_deque_push_front( mlt_deque self, void *item );
 extern void *mlt_deque_pop_front( mlt_deque self );
 extern void *mlt_deque_peek_back( mlt_deque self );
 extern void *mlt_deque_peek_front( mlt_deque self );
+
+extern int mlt_deque_push_back_int( mlt_deque self, int item );
+extern int mlt_deque_pop_back_int( mlt_deque self );
+extern int mlt_deque_push_front_int( mlt_deque self, int item );
+extern int mlt_deque_pop_front_int( mlt_deque self );
+extern int mlt_deque_peek_back_int( mlt_deque self );
+extern int mlt_deque_peek_front_int( mlt_deque self );
+
 extern void mlt_deque_close( mlt_deque self );
 
 #endif
index 660f3c1de4ffe3ce00be55c7e8c4e2d8e8aa9647..1637dad3580094998cf02b6ecb0c19faff9b02de 100644 (file)
@@ -181,6 +181,22 @@ void *mlt_frame_pop_service( mlt_frame this )
        return mlt_deque_pop_back( this->stack_image );
 }
 
+/** Push a service.
+*/
+
+int mlt_frame_push_service_int( mlt_frame this, int that )
+{
+       return mlt_deque_push_back_int( this->stack_image, that );
+}
+
+/** Pop a service.
+*/
+
+int mlt_frame_pop_service_int( mlt_frame this )
+{
+       return mlt_deque_pop_back_int( this->stack_image );
+}
+
 /** Push an audio item on the stack.
 */
 
index 899b0d23bb00611ae505240f269da75654f8182f..77ca012c1012ec93d680360baf2f144e07d57044 100644 (file)
@@ -63,6 +63,8 @@ extern int mlt_frame_push_frame( mlt_frame self, mlt_frame that );
 extern mlt_frame mlt_frame_pop_frame( mlt_frame self );
 extern int mlt_frame_push_service( mlt_frame self, void *that );
 extern void *mlt_frame_pop_service( mlt_frame self );
+extern int mlt_frame_push_service_int( mlt_frame self, int that );
+extern int mlt_frame_pop_service_int( mlt_frame self );
 extern int mlt_frame_push_audio( mlt_frame self, void *that );
 extern void *mlt_frame_pop_audio( mlt_frame self );
 extern mlt_deque mlt_frame_service_stack( mlt_frame self );