From: lilo_booter Date: Mon, 2 Feb 2004 23:14:44 +0000 (+0000) Subject: added deque, api design for manager, minor affine tweaks, experimental destructor... X-Git-Url: http://research.m1stereo.tv/gitweb?a=commitdiff_plain;h=15a23435c82ba0435061a35611c6afbe24d09e32;p=melted added deque, api design for manager, minor affine tweaks, experimental destructor work git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@105 d19143bc-622f-0410-bfdd-b5b2a6649095 --- diff --git a/src/framework/Makefile b/src/framework/Makefile index 6d80401..562698e 100644 --- a/src/framework/Makefile +++ b/src/framework/Makefile @@ -2,6 +2,7 @@ TARGET = libmlt.so OBJS = mlt_frame.o \ + mlt_deque.o \ mlt_property.o \ mlt_properties.o \ mlt_service.o \ diff --git a/src/framework/mlt.h b/src/framework/mlt.h index 3ad47a0..f7f802e 100644 --- a/src/framework/mlt.h +++ b/src/framework/mlt.h @@ -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 index 0000000..c048310 --- /dev/null +++ b/src/framework/mlt_deque.c @@ -0,0 +1,145 @@ +/* + * mlt_deque.c -- double ended queue + * Copyright (C) 2003-2004 Ushodaya Enterprises Limited + * Author: Charles Yates + * + * 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 +#include + +/** 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 index 0000000..b798949 --- /dev/null +++ b/src/framework/mlt_deque.h @@ -0,0 +1,36 @@ +/* + * mlt_deque.h -- double ended queue + * Copyright (C) 2003-2004 Ushodaya Enterprises Limited + * Author: Charles Yates + * + * 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 diff --git a/src/framework/mlt_factory.c b/src/framework/mlt_factory.c index 9223178..02c60c1 100644 --- a/src/framework/mlt_factory.c +++ b/src/framework/mlt_factory.c @@ -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; } } diff --git a/src/framework/mlt_field.c b/src/framework/mlt_field.c index 8a7f51f..3730d5e 100644 --- a/src/framework/mlt_field.c +++ b/src/framework/mlt_field.c @@ -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 ); } diff --git a/src/framework/mlt_frame.c b/src/framework/mlt_frame.c index a598f4e..86920c8 100644 --- a/src/framework/mlt_frame.c +++ b/src/framework/mlt_frame.c @@ -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 diff --git a/src/framework/mlt_manager.h b/src/framework/mlt_manager.h index 1567e64..769be7e 100644 --- a/src/framework/mlt_manager.h +++ b/src/framework/mlt_manager.h @@ -21,6 +21,27 @@ #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 diff --git a/src/framework/mlt_repository.c b/src/framework/mlt_repository.c index 9c25b21..cba5818 100644 --- a/src/framework/mlt_repository.c +++ b/src/framework/mlt_repository.c @@ -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 ); } } diff --git a/src/framework/mlt_types.h b/src/framework/mlt_types.h index 26bae3d..36c83df 100644 --- a/src/framework/mlt_types.h +++ b/src/framework/mlt_types.h @@ -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 );