]> git.sesse.net Git - mlt/commitdiff
added deque, api design for manager, minor affine tweaks, experimental destructor...
authorlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Mon, 2 Feb 2004 23:14:44 +0000 (23:14 +0000)
committerlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Mon, 2 Feb 2004 23:14:44 +0000 (23:14 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@105 d19143bc-622f-0410-bfdd-b5b2a6649095

src/framework/Makefile
src/framework/mlt.h
src/framework/mlt_deque.c [new file with mode: 0644]
src/framework/mlt_deque.h [new file with mode: 0644]
src/framework/mlt_factory.c
src/framework/mlt_field.c
src/framework/mlt_frame.c
src/framework/mlt_manager.h
src/framework/mlt_repository.c
src/framework/mlt_types.h

index 6d804016796e32b2236811a4aea6125612edae11..562698ebf0ace89ae43da80cf9c92551e857fe41 100644 (file)
@@ -2,6 +2,7 @@
 TARGET = libmlt.so
 
 OBJS = mlt_frame.o \
+          mlt_deque.o \
           mlt_property.o \
           mlt_properties.o \
           mlt_service.o \
index 3ad47a0ab6202c3c93dd87bd81efc5d1ee1e4eb8..f7f802e12d018cf2d70d302508937e33c046e58d 100644 (file)
@@ -28,6 +28,7 @@ extern "C"
 
 #include "mlt_factory.h"
 #include "mlt_frame.h"
+#include "mlt_deque.h"
 #include "mlt_multitrack.h"
 #include "mlt_producer.h"
 #include "mlt_transition.h"
diff --git a/src/framework/mlt_deque.c b/src/framework/mlt_deque.c
new file mode 100644 (file)
index 0000000..c048310
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+ * mlt_deque.c -- double ended queue
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Charles Yates <charles.yates@pandora.be>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+// Local header files
+#include "mlt_deque.h"
+
+// System header files
+#include <stdlib.h>
+#include <string.h>
+
+/** Private structure.
+*/
+
+struct mlt_deque_s
+{
+       void **list;
+       int size;
+       int count;
+};
+
+/** Create a deque.
+*/
+
+mlt_deque mlt_deque_init( )
+{
+       return calloc( 1, sizeof( struct mlt_deque_s ) );
+}
+
+/** Return the number of items in the deque.
+*/
+
+int mlt_deque_count( mlt_deque this )
+{
+       return this->count;
+}
+
+/** Allocate space on the deque.
+*/
+
+static int mlt_deque_allocate( mlt_deque this )
+{
+       if ( this->count == this->size )
+       {
+               this->list = realloc( this->list, sizeof( void * ) * ( this->size + 10 ) );
+               this->size += 10;
+       }
+       return this->list == NULL;
+}
+
+/** Push an item to the end.
+*/
+
+int mlt_deque_push_back( mlt_deque this, void *item )
+{
+       int error = mlt_deque_allocate( this );
+
+       if ( error == 0 )
+               this->list[ this->count ++ ] = item;
+
+       return error;
+}
+
+/** Pop an item.
+*/
+
+void *mlt_deque_pop_back( mlt_deque this )
+{
+       return this->count > 0 ? this->list[ -- this->count ] : NULL;
+}
+
+/** Queue an item at the start.
+*/
+
+int mlt_deque_push_front( mlt_deque this, void *item )
+{
+       int error = mlt_deque_allocate( this );
+
+       if ( error == 0 )
+       {
+               memmove( &this->list[ 1 ], this->list, ( this->count ++ ) * sizeof( void * ) );
+               this->list[ 0 ] = item;
+       }
+
+       return error;
+}
+
+/** Remove an item from the start.
+*/
+
+void *mlt_deque_pop_front( mlt_deque this )
+{
+       void *item = NULL;
+
+       if ( this->count > 0 )
+       {
+               item = this->list[ 0 ];
+               memmove( this->list, &this->list[ 1 ], ( -- this->count ) * sizeof( void * ) );
+       }
+
+       return item;
+}
+
+/** Inquire on item at back of deque but don't remove.
+*/
+
+void *mlt_deque_peek_back( mlt_deque this )
+{
+       return this->count > 0 ? this->list[ this->count - 1 ] : NULL;
+}
+
+/** Inquire on item at front of deque but don't remove.
+*/
+
+void *mlt_deque_peek_front( mlt_deque this )
+{
+       return this->count > 0 ? this->list[ 0 ] : NULL;
+}
+
+/** Close the queue.
+*/
+
+void mlt_deque_close( mlt_deque this )
+{
+       free( this->list );
+       free( this );
+}
+
+
diff --git a/src/framework/mlt_deque.h b/src/framework/mlt_deque.h
new file mode 100644 (file)
index 0000000..b798949
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * mlt_deque.h -- double ended queue
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Charles Yates <charles.yates@pandora.be>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _MLT_DEQUE_H_
+#define _MLT_DEQUE_H_
+
+#include "mlt_types.h"
+
+extern mlt_deque mlt_deque_init( );
+extern int mlt_deque_count( mlt_deque this );
+extern int mlt_deque_push_back( mlt_deque this, void *item );
+extern void *mlt_deque_pop_back( mlt_deque this );
+extern int mlt_deque_push_front( mlt_deque this, void *item );
+extern void *mlt_deque_pop_front( mlt_deque this );
+extern void *mlt_deque_peek_back( mlt_deque this );
+extern void *mlt_deque_peek_front( mlt_deque this );
+extern void mlt_deque_close( mlt_deque this );
+
+#endif
index 9223178994163a2542f7d7395862c80fdfd77b55..02c60c105d573b585a7ac47d31f029a57c7c8e31 100644 (file)
@@ -145,7 +145,6 @@ void mlt_factory_close( )
                mlt_repository_close( consumers );
                mlt_properties_close( object_list );
                free( mlt_prefix );
-               free( object_list );
                mlt_prefix = NULL;
        }
 }
index 8a7f51f47f2595e1c75c5fce47d63858dc6734bc..3730d5ea95aa824e785ec8b73e8e80309c188d46 100644 (file)
@@ -152,8 +152,8 @@ int mlt_field_plant_transition( mlt_field this, mlt_transition that, int a_track
 
 void mlt_field_close( mlt_field this )
 {
-       mlt_tractor_close( this->tractor );
-       mlt_multitrack_close( this->multitrack );
+       //mlt_tractor_close( this->tractor );
+       //mlt_multitrack_close( this->multitrack );
        free( this );
 }
 
index a598f4e76b226406a1099d8d2091ee6d089385d3..86920c87c6b9cc6111eca9d9449e12f00eb88493 100644 (file)
@@ -662,14 +662,14 @@ uint8_t *mlt_frame_rescale_yuv422( mlt_frame this, int owidth, int oheight )
                uint8_t *in_ptr;
 
                // Generate the affine transform scaling values
-               float scale_width = ( float )iwidth / ( float )owidth;
-               float scale_height = ( float )iheight / ( float )oheight;
+               int scale_width = ( iwidth << 16 ) / owidth;
+               int scale_height = ( iheight << 16 ) / oheight;
 
        // Loop for the entirety of our output height.
        for ( y = - out_y_range; y < out_y_range ; y ++ )
        {
                        // Calculate the derived y value
-                       dy = scale_height * y;
+                       dy = ( scale_height * y ) >> 16;
 
                // Start at the beginning of the line
                out_ptr = out_line;
@@ -681,23 +681,13 @@ uint8_t *mlt_frame_rescale_yuv422( mlt_frame this, int owidth, int oheight )
                for ( x = - out_x_range; x < out_x_range; x += 1 )
                {
                                // Calculated the derived x
-                               dx = scale_width * x;
-
-               // Check if x and y are in the valid input range.
-               if ( abs( dx ) < in_x_range && abs( dy ) < in_y_range  )
-               {
-                       // We're in the input range for this row.
-                                       in_ptr = in_line + dx * 2;
-                       *out_ptr ++ = *in_ptr ++;
-                                       in_ptr = in_line + ( ( dx >> 1 ) << 2 ) + ( ( x & 1 ) << 1 ) + 1;
-                       *out_ptr ++ = *in_ptr ++;
-               }
-               else
-               {
-                       // We're not in the input range for this row.
-                       *out_ptr ++ = 16;
-                       *out_ptr ++ = 128;
-               }
+                               dx = ( scale_width * x ) >> 16;
+
+                       // We're in the input range for this row.
+                               in_ptr = in_line + ( dx << 1 );
+                       *out_ptr ++ = *in_ptr ++;
+                               in_ptr = in_line + ( ( dx >> 1 ) << 2 ) + ( ( x & 1 ) << 1 ) + 1;
+                       *out_ptr ++ = *in_ptr;
                }
 
                // Move to next output line
index 1567e644bea41afe86f6619966ab11e95344188b..769be7eb3c7aae030ed72bd30a6e2f474f8a0702 100644 (file)
 #ifndef _MLT_MANAGER_H_
 #define _MLT_MANAGER_H_
 
-mlt_producer mlt_manager_init( char **config );
+extern mlt_manager mlt_manager_init( );
+extern mlt_producer mlt_manager_producer( mlt_manager this );
+extern mlt_producer mlt_manager_properties( mlt_manager this );
+extern int mlt_manager_track_count( mlt_manager this );
+extern int mlt_manager_clip_count( mlt_manager this, int track );
+extern int mlt_manager_append_clip( mlt_manager this, int track, mlt_producer clip );
+extern int mlt_manager_append_clip_io( mlt_manager this, int track, mlt_producer clip, mlt_position in, mlt_position out );
+extern int mlt_manager_append_blank( mlt_manager this, int track, int length );
+extern int mlt_manager_insert_clip( mlt_manager this, int track, mlt_producer clip, mlt_position position );
+extern int mlt_manager_insert_clip_io( mlt_manager this, int track, mlt_position position, mlt_producer clip, mlt_position in, mlt_position out );
+extern int mlt_manager_insert_blank( mlt_manager this, int track, mlt_position position, int length );
+extern int mlt_manager_remove_clip( mlt_manager this, int track, int index );
+extern mlt_producer mlt_manager_get_clip( mlt_manager this, int track, int index, char *type, mlt_position *in, mlt_position *out );
+extern int mlt_manager_service_count( mlt_manager this );
+extern int mlt_manager_append_filter( mlt_manager this, mlt_filter that );
+extern int mlt_manager_append_transition( mlt_manager this, int index, mlt_transition that );
+extern int mlt_manager_insert_filter( mlt_manager this, int index, mlt_filter that );
+extern int mlt_manager_insert_transition( mlt_manager this, int index, mlt_transition that );
+extern int mlt_manager_remove_service( mlt_manager this, int index );
+extern mlt_service mlt_manager_get_service( mlt_manager this, int index, char *type );
+extern int mlt_manager_set_resource( mlt_manager this, char *resource );
+extern int mlt_manager_set_type( mlt_manager this, char *type );
 
 #endif
index 9c25b2151e6d34f1bae8e32cefc31c97feb0eaf0..cba58183a479931930bd184b76a8b65b33fcaae8 100644 (file)
@@ -50,7 +50,7 @@ static char *chomp( char *input )
 
 static mlt_properties construct_object( char *prefix, char *id )
 {
-       mlt_properties output = calloc( sizeof( struct mlt_properties_s ), 1 );
+       mlt_properties output = mlt_properties_new( );
        mlt_properties_init( output, NULL );
        mlt_properties_set( output, "prefix", prefix );
        mlt_properties_set( output, "id", id );
@@ -59,7 +59,7 @@ static mlt_properties construct_object( char *prefix, char *id )
 
 static mlt_properties construct_service( mlt_properties object, char *id )
 {
-       mlt_properties output = calloc( sizeof( struct mlt_properties_s ), 1 );
+       mlt_properties output = mlt_properties_new( );
        mlt_properties_init( output, NULL );
        mlt_properties_set_data( output, "object", object, 0, NULL, NULL );
        mlt_properties_set( output, "id", id );
@@ -115,12 +115,6 @@ static void *construct_instance( mlt_properties service_properties, char *symbol
        return symbol_ptr != NULL ? symbol_ptr( service, input ) : NULL;
 }
 
-void destroy_properties( void *arg )
-{
-       mlt_properties_close( arg );
-       free( arg );
-}
-
 mlt_repository mlt_repository_init( mlt_properties object_list, char *prefix, char *data, char *symbol )
 {
        char full_file[ 512 ];
@@ -165,14 +159,14 @@ mlt_repository mlt_repository_init( mlt_properties object_list, char *prefix, ch
                                        object_properties = construct_object( prefix, object );
 
                                        // Add it to the object list
-                                       mlt_properties_set_data( object_list, object, object_properties, 0, destroy_properties, NULL );
+                                       mlt_properties_set_data( object_list, object, object_properties, 0, ( mlt_destructor )mlt_properties_close, NULL );
                                }
 
                                // Now construct a property for the service
                                mlt_properties service_properties = construct_service( object_properties, service );
 
                                // Add it to the repository
-                               mlt_properties_set_data( &this->parent, service, service_properties, 0, destroy_properties, NULL );
+                               mlt_properties_set_data( &this->parent, service, service_properties, 0, ( mlt_destructor )mlt_properties_close, NULL );
                        }
                }
 
index 26bae3dcb3de85740fd212b6024dfeb41c8cb15d..36c83dfad552540af6b4283561aa4eedf51c0c8a 100644 (file)
@@ -44,6 +44,7 @@ typedef struct mlt_transition_s *mlt_transition;
 typedef struct mlt_tractor_s *mlt_tractor;
 typedef struct mlt_field_s *mlt_field;
 typedef struct mlt_consumer_s *mlt_consumer;
+typedef struct mlt_deque_s *mlt_deque;
 
 typedef void ( *mlt_destructor )( void * );
 typedef char *( *mlt_serialiser )( void *, int length );