From a0798f3d5e1b4886853817607f4d4f973532710a Mon Sep 17 00:00:00 2001 From: Dan Dennedy Date: Mon, 28 Feb 2011 21:02:00 -0800 Subject: [PATCH] Rename this to self in the framework. This makes doxygen output better match the headers, and it improves life within a code-parsing IDE like Qt Creator. --- src/framework/mlt_consumer.c | 650 ++++++++++++------------- src/framework/mlt_deque.c | 198 ++++---- src/framework/mlt_events.c | 124 ++--- src/framework/mlt_factory.c | 12 +- src/framework/mlt_field.c | 94 ++-- src/framework/mlt_filter.c | 106 ++--- src/framework/mlt_frame.c | 252 +++++----- src/framework/mlt_geometry.c | 148 +++--- src/framework/mlt_multitrack.c | 146 +++--- src/framework/mlt_parser.c | 138 +++--- src/framework/mlt_playlist.c | 848 ++++++++++++++++----------------- src/framework/mlt_pool.c | 66 +-- src/framework/mlt_producer.c | 380 +++++++-------- src/framework/mlt_profile.c | 46 +- src/framework/mlt_properties.c | 366 +++++++------- src/framework/mlt_property.c | 330 ++++++------- src/framework/mlt_property.h | 2 +- src/framework/mlt_repository.c | 64 +-- src/framework/mlt_service.c | 254 +++++----- src/framework/mlt_tokeniser.h | 10 +- src/framework/mlt_tractor.c | 158 +++--- src/framework/mlt_transition.c | 140 +++--- 22 files changed, 2266 insertions(+), 2266 deletions(-) diff --git a/src/framework/mlt_consumer.c b/src/framework/mlt_consumer.c index 1c17fd5a..c1bfaa4f 100644 --- a/src/framework/mlt_consumer.c +++ b/src/framework/mlt_consumer.c @@ -43,32 +43,32 @@ */ pthread_mutex_t mlt_sdl_mutex = PTHREAD_MUTEX_INITIALIZER; -static void mlt_consumer_frame_render( mlt_listener listener, mlt_properties owner, mlt_service this, void **args ); -static void mlt_consumer_frame_show( mlt_listener listener, mlt_properties owner, mlt_service this, void **args ); -static void mlt_consumer_property_changed( mlt_properties owner, mlt_consumer this, char *name ); -static void apply_profile_properties( mlt_consumer this, mlt_profile profile, mlt_properties properties ); -static void on_consumer_frame_show( mlt_properties owner, mlt_consumer this, mlt_frame frame ); +static void mlt_consumer_frame_render( mlt_listener listener, mlt_properties owner, mlt_service self, void **args ); +static void mlt_consumer_frame_show( mlt_listener listener, mlt_properties owner, mlt_service self, void **args ); +static void mlt_consumer_property_changed( mlt_properties owner, mlt_consumer self, char *name ); +static void apply_profile_properties( mlt_consumer self, mlt_profile profile, mlt_properties properties ); +static void on_consumer_frame_show( mlt_properties owner, mlt_consumer self, mlt_frame frame ); /** Initialize a consumer service. * * \public \memberof mlt_consumer_s - * \param this the consumer to initialize + * \param self the consumer to initialize * \param child a pointer to the object for the subclass * \param profile the \p mlt_profile_s to use (optional but recommended, - * uses the environment variable MLT if this is NULL) + * uses the environment variable MLT if self is NULL) * \return true if there was an error */ -int mlt_consumer_init( mlt_consumer this, void *child, mlt_profile profile ) +int mlt_consumer_init( mlt_consumer self, void *child, mlt_profile profile ) { int error = 0; - memset( this, 0, sizeof( struct mlt_consumer_s ) ); - this->child = child; - error = mlt_service_init( &this->parent, this ); + memset( self, 0, sizeof( struct mlt_consumer_s ) ); + self->child = child; + error = mlt_service_init( &self->parent, self ); if ( error == 0 ) { // Get the properties from the service - mlt_properties properties = MLT_SERVICE_PROPERTIES( &this->parent ); + mlt_properties properties = MLT_SERVICE_PROPERTIES( &self->parent ); // Apply profile to properties if ( profile == NULL ) @@ -76,10 +76,10 @@ int mlt_consumer_init( mlt_consumer this, void *child, mlt_profile profile ) // Normally the application creates the profile and controls its lifetime // This is the fallback exception handling profile = mlt_profile_init( NULL ); - mlt_properties properties = MLT_CONSUMER_PROPERTIES( this ); + mlt_properties properties = MLT_CONSUMER_PROPERTIES( self ); mlt_properties_set_data( properties, "_profile", profile, 0, (mlt_destructor)mlt_profile_close, NULL ); } - apply_profile_properties( this, profile, properties ); + apply_profile_properties( self, profile, properties ); // Default rescaler for all consumers mlt_properties_set( properties, "rescale", "bilinear" ); @@ -98,20 +98,20 @@ int mlt_consumer_init( mlt_consumer this, void *child, mlt_profile profile ) mlt_properties_set( properties, "test_card", mlt_environment( "MLT_TEST_CARD" ) ); // Hmm - default all consumers to yuv422 :-/ - this->format = mlt_image_yuv422; + self->format = mlt_image_yuv422; mlt_events_register( properties, "consumer-frame-show", ( mlt_transmitter )mlt_consumer_frame_show ); mlt_events_register( properties, "consumer-frame-render", ( mlt_transmitter )mlt_consumer_frame_render ); mlt_events_register( properties, "consumer-stopped", NULL ); - mlt_events_listen( properties, this, "consumer-frame-show", ( mlt_listener )on_consumer_frame_show ); + mlt_events_listen( properties, self, "consumer-frame-show", ( mlt_listener )on_consumer_frame_show ); // Register a property-changed listener to handle the profile property - // subsequent properties can override the profile - this->event_listener = mlt_events_listen( properties, this, "property-changed", ( mlt_listener )mlt_consumer_property_changed ); + self->event_listener = mlt_events_listen( properties, self, "property-changed", ( mlt_listener )mlt_consumer_property_changed ); // Create the push mutex and condition - pthread_mutex_init( &this->put_mutex, NULL ); - pthread_cond_init( &this->put_cond, NULL ); + pthread_mutex_init( &self->put_mutex, NULL ); + pthread_cond_init( &self->put_cond, NULL ); } return error; @@ -120,14 +120,14 @@ int mlt_consumer_init( mlt_consumer this, void *child, mlt_profile profile ) /** Convert the profile into properties on the consumer. * * \private \memberof mlt_consumer_s - * \param this a consumer + * \param self a consumer * \param profile a profile * \param properties a properties list (typically, the consumer's) */ -static void apply_profile_properties( mlt_consumer this, mlt_profile profile, mlt_properties properties ) +static void apply_profile_properties( mlt_consumer self, mlt_profile profile, mlt_properties properties ) { - mlt_event_block( this->event_listener ); + mlt_event_block( self->event_listener ); mlt_properties_set_double( properties, "fps", mlt_profile_fps( profile ) ); mlt_properties_set_int( properties, "frame_rate_num", profile->frame_rate_num ); mlt_properties_set_int( properties, "frame_rate_den", profile->frame_rate_den ); @@ -141,26 +141,26 @@ static void apply_profile_properties( mlt_consumer this, mlt_profile profile, ml mlt_properties_set_int( properties, "display_aspect_num", profile->display_aspect_num ); mlt_properties_set_int( properties, "display_aspect_num", profile->display_aspect_num ); mlt_properties_set_int( properties, "colorspace", profile->colorspace ); - mlt_event_unblock( this->event_listener ); + mlt_event_unblock( self->event_listener ); } /** The property-changed event listener * * \private \memberof mlt_consumer_s * \param owner the events object - * \param this the consumer + * \param self the consumer * \param name the name of the property that changed */ -static void mlt_consumer_property_changed( mlt_properties owner, mlt_consumer this, char *name ) +static void mlt_consumer_property_changed( mlt_properties owner, mlt_consumer self, char *name ) { if ( !strcmp( name, "profile" ) ) { // Get the properies - mlt_properties properties = MLT_CONSUMER_PROPERTIES( this ); + mlt_properties properties = MLT_CONSUMER_PROPERTIES( self ); // Get the current profile - mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( this ) ); + mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( self ) ); // Load the new profile mlt_profile new_profile = mlt_profile_init( mlt_properties_get( properties, name ) ); @@ -181,13 +181,13 @@ static void mlt_consumer_property_changed( mlt_properties owner, mlt_consumer th } // Apply to properties - apply_profile_properties( this, profile, properties ); + apply_profile_properties( self, profile, properties ); } } else if ( !strcmp( name, "frame_rate_num" ) ) { - mlt_properties properties = MLT_CONSUMER_PROPERTIES( this ); - mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( this ) ); + mlt_properties properties = MLT_CONSUMER_PROPERTIES( self ); + mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( self ) ); if ( profile ) { profile->frame_rate_num = mlt_properties_get_int( properties, "frame_rate_num" ); @@ -196,8 +196,8 @@ static void mlt_consumer_property_changed( mlt_properties owner, mlt_consumer th } else if ( !strcmp( name, "frame_rate_den" ) ) { - mlt_properties properties = MLT_CONSUMER_PROPERTIES( this ); - mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( this ) ); + mlt_properties properties = MLT_CONSUMER_PROPERTIES( self ); + mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( self ) ); if ( profile ) { profile->frame_rate_den = mlt_properties_get_int( properties, "frame_rate_den" ); @@ -206,45 +206,45 @@ static void mlt_consumer_property_changed( mlt_properties owner, mlt_consumer th } else if ( !strcmp( name, "width" ) ) { - mlt_properties properties = MLT_CONSUMER_PROPERTIES( this ); - mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( this ) ); + mlt_properties properties = MLT_CONSUMER_PROPERTIES( self ); + mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( self ) ); if ( profile ) profile->width = mlt_properties_get_int( properties, "width" ); } else if ( !strcmp( name, "height" ) ) { - mlt_properties properties = MLT_CONSUMER_PROPERTIES( this ); - mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( this ) ); + mlt_properties properties = MLT_CONSUMER_PROPERTIES( self ); + mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( self ) ); if ( profile ) profile->height = mlt_properties_get_int( properties, "height" ); } else if ( !strcmp( name, "progressive" ) ) { - mlt_properties properties = MLT_CONSUMER_PROPERTIES( this ); - mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( this ) ); + mlt_properties properties = MLT_CONSUMER_PROPERTIES( self ); + mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( self ) ); if ( profile ) profile->progressive = mlt_properties_get_int( properties, "progressive" ); } else if ( !strcmp( name, "sample_aspect_num" ) ) { - mlt_properties properties = MLT_CONSUMER_PROPERTIES( this ); - mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( this ) ); + mlt_properties properties = MLT_CONSUMER_PROPERTIES( self ); + mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( self ) ); profile->sample_aspect_num = mlt_properties_get_int( properties, "sample_aspect_num" ); if ( profile ) mlt_properties_set_double( properties, "aspect_ratio", mlt_profile_sar( profile ) ); } else if ( !strcmp( name, "sample_aspect_den" ) ) { - mlt_properties properties = MLT_CONSUMER_PROPERTIES( this ); - mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( this ) ); + mlt_properties properties = MLT_CONSUMER_PROPERTIES( self ); + mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( self ) ); profile->sample_aspect_den = mlt_properties_get_int( properties, "sample_aspect_den" ); if ( profile ) mlt_properties_set_double( properties, "aspect_ratio", mlt_profile_sar( profile ) ); } else if ( !strcmp( name, "display_aspect_num" ) ) { - mlt_properties properties = MLT_CONSUMER_PROPERTIES( this ); - mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( this ) ); + mlt_properties properties = MLT_CONSUMER_PROPERTIES( self ); + mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( self ) ); if ( profile ) { profile->display_aspect_num = mlt_properties_get_int( properties, "display_aspect_num" ); @@ -253,8 +253,8 @@ static void mlt_consumer_property_changed( mlt_properties owner, mlt_consumer th } else if ( !strcmp( name, "display_aspect_den" ) ) { - mlt_properties properties = MLT_CONSUMER_PROPERTIES( this ); - mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( this ) ); + mlt_properties properties = MLT_CONSUMER_PROPERTIES( self ); + mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( self ) ); if ( profile ) { profile->display_aspect_den = mlt_properties_get_int( properties, "display_aspect_den" ); @@ -263,8 +263,8 @@ static void mlt_consumer_property_changed( mlt_properties owner, mlt_consumer th } else if ( !strcmp( name, "colorspace" ) ) { - mlt_properties properties = MLT_CONSUMER_PROPERTIES( this ); - mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( this ) ); + mlt_properties properties = MLT_CONSUMER_PROPERTIES( self ); + mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( self ) ); if ( profile ) profile->colorspace = mlt_properties_get_int( properties, "colorspace" ); } @@ -277,14 +277,14 @@ static void mlt_consumer_property_changed( mlt_properties owner, mlt_consumer th * \private \memberof mlt_consumer_s * \param listener a function pointer that will be invoked * \param owner the events object that will be passed to \p listener - * \param this a service that will be passed to \p listener + * \param self a service that will be passed to \p listener * \param args an array of pointers - the first entry is passed as a string to \p listener */ -static void mlt_consumer_frame_show( mlt_listener listener, mlt_properties owner, mlt_service this, void **args ) +static void mlt_consumer_frame_show( mlt_listener listener, mlt_properties owner, mlt_service self, void **args ) { if ( listener != NULL ) - listener( owner, this, ( mlt_frame )args[ 0 ] ); + listener( owner, self, ( mlt_frame )args[ 0 ] ); } /** The transmitter for the consumer-frame-render event @@ -294,14 +294,14 @@ static void mlt_consumer_frame_show( mlt_listener listener, mlt_properties owner * \private \memberof mlt_consumer_s * \param listener a function pointer that will be invoked * \param owner the events object that will be passed to \p listener - * \param this a service that will be passed to \p listener + * \param self a service that will be passed to \p listener * \param args an array of pointers - the first entry is passed as a string to \p listener */ -static void mlt_consumer_frame_render( mlt_listener listener, mlt_properties owner, mlt_service this, void **args ) +static void mlt_consumer_frame_render( mlt_listener listener, mlt_properties owner, mlt_service self, void **args ) { if ( listener != NULL ) - listener( owner, this, ( mlt_frame )args[ 0 ] ); + listener( owner, self, ( mlt_frame )args[ 0 ] ); } /** A listener on the consumer-frame-show event @@ -330,46 +330,46 @@ static void on_consumer_frame_show( mlt_properties owner, mlt_consumer consumer, mlt_consumer mlt_consumer_new( mlt_profile profile ) { // Create the memory for the structure - mlt_consumer this = malloc( sizeof( struct mlt_consumer_s ) ); + mlt_consumer self = malloc( sizeof( struct mlt_consumer_s ) ); // Initialise it - if ( this != NULL ) - mlt_consumer_init( this, NULL, profile ); + if ( self != NULL ) + mlt_consumer_init( self, NULL, profile ); // Return it - return this; + return self; } /** Get the parent service object. * * \public \memberof mlt_consumer_s - * \param this a consumer + * \param self a consumer * \return the parent service class * \see MLT_CONSUMER_SERVICE */ -mlt_service mlt_consumer_service( mlt_consumer this ) +mlt_service mlt_consumer_service( mlt_consumer self ) { - return this != NULL ? &this->parent : NULL; + return self != NULL ? &self->parent : NULL; } /** Get the consumer properties. * * \public \memberof mlt_consumer_s - * \param this a consumer + * \param self a consumer * \return the consumer's properties list * \see MLT_CONSUMER_PROPERTIES */ -mlt_properties mlt_consumer_properties( mlt_consumer this ) +mlt_properties mlt_consumer_properties( mlt_consumer self ) { - return this != NULL ? MLT_SERVICE_PROPERTIES( &this->parent ) : NULL; + return self != NULL ? MLT_SERVICE_PROPERTIES( &self->parent ) : NULL; } /** Connect the consumer to the producer. * * \public \memberof mlt_consumer_s - * \param this a consumer + * \param self a consumer * \param producer a producer * \return > 0 warning, == 0 success, < 0 serious error, * 1 = this service does not accept input, @@ -377,32 +377,32 @@ mlt_properties mlt_consumer_properties( mlt_consumer this ) * 3 = the producer is already registered with this consumer */ -int mlt_consumer_connect( mlt_consumer this, mlt_service producer ) +int mlt_consumer_connect( mlt_consumer self, mlt_service producer ) { - return mlt_service_connect_producer( &this->parent, producer, 0 ); + return mlt_service_connect_producer( &self->parent, producer, 0 ); } /** Start the consumer. * * \public \memberof mlt_consumer_s - * \param this a consumer + * \param self a consumer * \return true if there was an error */ -int mlt_consumer_start( mlt_consumer this ) +int mlt_consumer_start( mlt_consumer self ) { // Stop listening to the property-changed event - mlt_event_block( this->event_listener ); + mlt_event_block( self->event_listener ); // Get the properies - mlt_properties properties = MLT_CONSUMER_PROPERTIES( this ); + mlt_properties properties = MLT_CONSUMER_PROPERTIES( self ); // Determine if there's a test card producer char *test_card = mlt_properties_get( properties, "test_card" ); // Just to make sure nothing is hanging around... - this->put = NULL; - this->put_active = 1; + self->put = NULL; + self->put_active = 1; // Deal with it now. if ( test_card != NULL ) @@ -410,7 +410,7 @@ int mlt_consumer_start( mlt_consumer this ) if ( mlt_properties_get_data( properties, "test_card_producer", NULL ) == NULL ) { // Create a test card producer - mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( this ) ); + mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( self ) ); mlt_producer producer = mlt_factory_producer( profile, NULL, test_card ); // Do we have a producer @@ -440,18 +440,18 @@ int mlt_consumer_start( mlt_consumer this ) // Check and run an ante command if ( mlt_properties_get( properties, "ante" ) ) if ( system( mlt_properties_get( properties, "ante" ) ) == -1 ) - mlt_log( MLT_CONSUMER_SERVICE( this ), MLT_LOG_ERROR, "system(%s) failed!\n", mlt_properties_get( properties, "ante" ) ); + mlt_log( MLT_CONSUMER_SERVICE( self ), MLT_LOG_ERROR, "system(%s) failed!\n", mlt_properties_get( properties, "ante" ) ); // Set the real_time preference - this->real_time = mlt_properties_get_int( properties, "real_time" ); + self->real_time = mlt_properties_get_int( properties, "real_time" ); // For worker threads implementation, buffer must be at least # threads - if ( abs( this->real_time ) > 1 && mlt_properties_get_int( properties, "buffer" ) <= abs( this->real_time ) ) - mlt_properties_set_int( properties, "buffer", abs( this->real_time ) + 1 ); + if ( abs( self->real_time ) > 1 && mlt_properties_get_int( properties, "buffer" ) <= abs( self->real_time ) ) + mlt_properties_set_int( properties, "buffer", abs( self->real_time ) + 1 ); // Start the service - if ( this->start != NULL ) - return this->start( this ); + if ( self->start != NULL ) + return self->start( self ); return 0; } @@ -461,36 +461,36 @@ int mlt_consumer_start( mlt_consumer this ) * Only valid if the consumer itself is not connected. * * \public \memberof mlt_consumer_s - * \param this a consumer + * \param self a consumer * \param frame a frame - * \return true (ignore this for now) + * \return true (ignore self for now) */ -int mlt_consumer_put_frame( mlt_consumer this, mlt_frame frame ) +int mlt_consumer_put_frame( mlt_consumer self, mlt_frame frame ) { int error = 1; // Get the service assoicated to the consumer - mlt_service service = MLT_CONSUMER_SERVICE( this ); + mlt_service service = MLT_CONSUMER_SERVICE( self ); if ( mlt_service_producer( service ) == NULL ) { struct timeval now; struct timespec tm; - pthread_mutex_lock( &this->put_mutex ); - while ( this->put_active && this->put != NULL ) + pthread_mutex_lock( &self->put_mutex ); + while ( self->put_active && self->put != NULL ) { gettimeofday( &now, NULL ); tm.tv_sec = now.tv_sec + 1; tm.tv_nsec = now.tv_usec * 1000; - pthread_cond_timedwait( &this->put_cond, &this->put_mutex, &tm ); + pthread_cond_timedwait( &self->put_cond, &self->put_mutex, &tm ); } - if ( this->put_active && this->put == NULL ) - this->put = frame; + if ( self->put_active && self->put == NULL ) + self->put = frame; else mlt_frame_close( frame ); - pthread_cond_broadcast( &this->put_cond ); - pthread_mutex_unlock( &this->put_mutex ); + pthread_cond_broadcast( &self->put_cond ); + pthread_mutex_unlock( &self->put_mutex ); } else { @@ -503,38 +503,38 @@ int mlt_consumer_put_frame( mlt_consumer this, mlt_frame frame ) /** Protected method for consumer to get frames from connected service * * \public \memberof mlt_consumer_s - * \param this a consumer + * \param self a consumer * \return a frame */ -mlt_frame mlt_consumer_get_frame( mlt_consumer this ) +mlt_frame mlt_consumer_get_frame( mlt_consumer self ) { // Frame to return mlt_frame frame = NULL; // Get the service assoicated to the consumer - mlt_service service = MLT_CONSUMER_SERVICE( this ); + mlt_service service = MLT_CONSUMER_SERVICE( self ); // Get the consumer properties - mlt_properties properties = MLT_CONSUMER_PROPERTIES( this ); + mlt_properties properties = MLT_CONSUMER_PROPERTIES( self ); // Get the frame if ( mlt_service_producer( service ) == NULL && mlt_properties_get_int( properties, "put_mode" ) ) { struct timeval now; struct timespec tm; - pthread_mutex_lock( &this->put_mutex ); - while ( this->put_active && this->put == NULL ) + pthread_mutex_lock( &self->put_mutex ); + while ( self->put_active && self->put == NULL ) { gettimeofday( &now, NULL ); tm.tv_sec = now.tv_sec + 1; tm.tv_nsec = now.tv_usec * 1000; - pthread_cond_timedwait( &this->put_cond, &this->put_mutex, &tm ); + pthread_cond_timedwait( &self->put_cond, &self->put_mutex, &tm ); } - frame = this->put; - this->put = NULL; - pthread_cond_broadcast( &this->put_cond ); - pthread_mutex_unlock( &this->put_mutex ); + frame = self->put; + self->put = NULL; + pthread_cond_broadcast( &self->put_cond ); + pthread_mutex_unlock( &self->put_mutex ); if ( frame != NULL ) mlt_service_apply_filters( service, frame, 0 ); } @@ -598,10 +598,10 @@ static inline long time_difference( struct timeval *time1 ) static void *consumer_read_ahead_thread( void *arg ) { // The argument is the consumer - mlt_consumer this = arg; + mlt_consumer self = arg; // Get the properties of the consumer - mlt_properties properties = MLT_CONSUMER_PROPERTIES( this ); + mlt_properties properties = MLT_CONSUMER_PROPERTIES( self ); // Get the width and height int width = mlt_properties_get_int( properties, "width" ); @@ -643,16 +643,16 @@ static void *consumer_read_ahead_thread( void *arg ) int skip_next = 0; if ( preview_off && preview_format != 0 ) - this->format = preview_format; + self->format = preview_format; // Get the first frame - frame = mlt_consumer_get_frame( this ); + frame = mlt_consumer_get_frame( self ); // Get the image of the first frame if ( !video_off ) { - mlt_events_fire( MLT_CONSUMER_PROPERTIES( this ), "consumer-frame-render", frame, NULL ); - mlt_frame_get_image( frame, &image, &this->format, &width, &height, 0 ); + mlt_events_fire( MLT_CONSUMER_PROPERTIES( self ), "consumer-frame-render", frame, NULL ); + mlt_frame_get_image( frame, &image, &self->format, &width, &height, 0 ); } if ( !audio_off ) @@ -668,24 +668,24 @@ static void *consumer_read_ahead_thread( void *arg ) gettimeofday( &ante, NULL ); // Continue to read ahead - while ( this->ahead ) + while ( self->ahead ) { // Fetch width/height again width = mlt_properties_get_int( properties, "width" ); height = mlt_properties_get_int( properties, "height" ); // Put the current frame into the queue - pthread_mutex_lock( &this->queue_mutex ); - while( this->ahead && mlt_deque_count( this->queue ) >= buffer ) - pthread_cond_wait( &this->queue_cond, &this->queue_mutex ); - mlt_deque_push_back( this->queue, frame ); - pthread_cond_broadcast( &this->queue_cond ); - pthread_mutex_unlock( &this->queue_mutex ); + pthread_mutex_lock( &self->queue_mutex ); + while( self->ahead && mlt_deque_count( self->queue ) >= buffer ) + pthread_cond_wait( &self->queue_cond, &self->queue_mutex ); + mlt_deque_push_back( self->queue, frame ); + pthread_cond_broadcast( &self->queue_cond ); + pthread_mutex_unlock( &self->queue_mutex ); time_wait += time_difference( &ante ); // Get the next frame - frame = mlt_consumer_get_frame( this ); + frame = mlt_consumer_get_frame( self ); time_frame += time_difference( &ante ); // If there's no frame, we're probably stopped... @@ -710,13 +710,13 @@ static void *consumer_read_ahead_thread( void *arg ) } // Get the image - if ( !skip_next || this->real_time == -1 ) + if ( !skip_next || self->real_time == -1 ) { // Get the image, mark as rendered and time it if ( !video_off ) { - mlt_events_fire( MLT_CONSUMER_PROPERTIES( this ), "consumer-frame-render", frame, NULL ); - mlt_frame_get_image( frame, &image, &this->format, &width, &height, 0 ); + mlt_events_fire( MLT_CONSUMER_PROPERTIES( self ), "consumer-frame-render", frame, NULL ); + mlt_frame_get_image( frame, &image, &self->format, &width, &height, 0 ); } mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "rendered", 1 ); } @@ -744,11 +744,11 @@ static void *consumer_read_ahead_thread( void *arg ) mlt_frame_get_audio( frame, &audio, &afmt, &frequency, &channels, &samples ); } - // Increment the time take for this frame + // Increment the time take for self frame time_process += time_difference( &ante ); // Determine if the next frame should be skipped - if ( mlt_deque_count( this->queue ) <= 5 ) + if ( mlt_deque_count( self->queue ) <= 5 ) { int frame_duration = mlt_properties_get_int( properties, "frame_duration" ); if ( ( ( time_wait + time_frame + time_process ) / count ) > frame_duration ) @@ -774,14 +774,14 @@ static void *consumer_read_ahead_thread( void *arg ) * ahead of the playout point (queue head). * * \private \memberof mlt_consumer_s - * \param this a consumer + * \param self a consumer * \return an index into the queue */ -static inline int first_unprocessed_frame( mlt_consumer this ) +static inline int first_unprocessed_frame( mlt_consumer self ) { - int index = this->real_time <= 0 ? 0 : this->process_head; - while ( index < mlt_deque_count( this->queue ) && MLT_FRAME( mlt_deque_peek( this->queue, index ) )->is_processing ) + int index = self->real_time <= 0 ? 0 : self->process_head; + while ( index < mlt_deque_count( self->queue ) && MLT_FRAME( mlt_deque_peek( self->queue, index ) )->is_processing ) index++; return index; } @@ -795,15 +795,15 @@ static inline int first_unprocessed_frame( mlt_consumer this ) static void *consumer_worker_thread( void *arg ) { // The argument is the consumer - mlt_consumer this = arg; + mlt_consumer self = arg; // Get the properties of the consumer - mlt_properties properties = MLT_CONSUMER_PROPERTIES( this ); + mlt_properties properties = MLT_CONSUMER_PROPERTIES( self ); // Get the width and height int width = mlt_properties_get_int( properties, "width" ); int height = mlt_properties_get_int( properties, "height" ); - mlt_image_format format = this->format; + mlt_image_format format = self->format; // See if video is turned off int video_off = mlt_properties_get_int( properties, "video_off" ); @@ -818,29 +818,29 @@ static void *consumer_worker_thread( void *arg ) format = preview_format; // Continue to read ahead - while ( this->ahead ) + while ( self->ahead ) { // Get the next unprocessed frame from the work queue - pthread_mutex_lock( &this->queue_mutex ); - int index = first_unprocessed_frame( this ); - while ( this->ahead && index >= mlt_deque_count( this->queue ) ) + pthread_mutex_lock( &self->queue_mutex ); + int index = first_unprocessed_frame( self ); + while ( self->ahead && index >= mlt_deque_count( self->queue ) ) { - mlt_log_debug( MLT_CONSUMER_SERVICE(this), "waiting in worker index = %d queue count = %d\n", - index, mlt_deque_count( this->queue ) ); - pthread_cond_wait( &this->queue_cond, &this->queue_mutex ); - index = first_unprocessed_frame( this ); + mlt_log_debug( MLT_CONSUMER_SERVICE(self), "waiting in worker index = %d queue count = %d\n", + index, mlt_deque_count( self->queue ) ); + pthread_cond_wait( &self->queue_cond, &self->queue_mutex ); + index = first_unprocessed_frame( self ); } // Mark the frame for processing - frame = mlt_deque_peek( this->queue, index ); + frame = mlt_deque_peek( self->queue, index ); if ( frame ) { - mlt_log_debug( MLT_CONSUMER_SERVICE(this), "worker processing index = %d frame %d queue count = %d\n", - index, mlt_frame_get_position(frame), mlt_deque_count( this->queue ) ); + mlt_log_debug( MLT_CONSUMER_SERVICE(self), "worker processing index = %d frame %d queue count = %d\n", + index, mlt_frame_get_position(frame), mlt_deque_count( self->queue ) ); frame->is_processing = 1; mlt_properties_inc_ref( MLT_FRAME_PROPERTIES( frame ) ); } - pthread_mutex_unlock( &this->queue_mutex ); + pthread_mutex_unlock( &self->queue_mutex ); // If there's no frame, we're probably stopped... if ( frame == NULL ) @@ -858,16 +858,16 @@ static void *consumer_worker_thread( void *arg ) // Fetch width/height again width = mlt_properties_get_int( properties, "width" ); height = mlt_properties_get_int( properties, "height" ); - mlt_events_fire( MLT_CONSUMER_PROPERTIES( this ), "consumer-frame-render", frame, NULL ); + mlt_events_fire( MLT_CONSUMER_PROPERTIES( self ), "consumer-frame-render", frame, NULL ); mlt_frame_get_image( frame, &image, &format, &width, &height, 0 ); } mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "rendered", 1 ); mlt_frame_close( frame ); // Tell a waiting thread (non-realtime main consumer thread) that we are done. - pthread_mutex_lock( &this->done_mutex ); - pthread_cond_broadcast( &this->done_cond ); - pthread_mutex_unlock( &this->done_mutex ); + pthread_mutex_lock( &self->done_mutex ); + pthread_cond_broadcast( &self->done_cond ); + pthread_mutex_unlock( &self->done_mutex ); } return NULL; @@ -876,88 +876,88 @@ static void *consumer_worker_thread( void *arg ) /** Start the read/render thread. * * \private \memberof mlt_consumer_s - * \param this a consumer + * \param self a consumer */ -static void consumer_read_ahead_start( mlt_consumer this ) +static void consumer_read_ahead_start( mlt_consumer self ) { // We're running now - this->ahead = 1; + self->ahead = 1; // Create the frame queue - this->queue = mlt_deque_init( ); + self->queue = mlt_deque_init( ); // Create the queue mutex - pthread_mutex_init( &this->queue_mutex, NULL ); + pthread_mutex_init( &self->queue_mutex, NULL ); // Create the condition - pthread_cond_init( &this->queue_cond, NULL ); + pthread_cond_init( &self->queue_cond, NULL ); // Create the read ahead - if ( mlt_properties_get( MLT_CONSUMER_PROPERTIES( this ), "priority" ) ) + if ( mlt_properties_get( MLT_CONSUMER_PROPERTIES( self ), "priority" ) ) { struct sched_param priority; - priority.sched_priority = mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( this ), "priority" ); + priority.sched_priority = mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( self ), "priority" ); pthread_attr_t thread_attributes; pthread_attr_init( &thread_attributes ); pthread_attr_setschedpolicy( &thread_attributes, SCHED_OTHER ); pthread_attr_setschedparam( &thread_attributes, &priority ); pthread_attr_setinheritsched( &thread_attributes, PTHREAD_EXPLICIT_SCHED ); pthread_attr_setscope( &thread_attributes, PTHREAD_SCOPE_SYSTEM ); - if ( pthread_create( &this->ahead_thread, &thread_attributes, consumer_read_ahead_thread, this ) < 0 ) - pthread_create( &this->ahead_thread, NULL, consumer_read_ahead_thread, this ); + if ( pthread_create( &self->ahead_thread, &thread_attributes, consumer_read_ahead_thread, self ) < 0 ) + pthread_create( &self->ahead_thread, NULL, consumer_read_ahead_thread, self ); pthread_attr_destroy( &thread_attributes ); } else { - pthread_create( &this->ahead_thread, NULL, consumer_read_ahead_thread, this ); + pthread_create( &self->ahead_thread, NULL, consumer_read_ahead_thread, self ); } - this->started = 1; + self->started = 1; } /** Start the worker threads. * * \private \memberof mlt_consumer_s - * \param this a consumer + * \param self a consumer */ -static void consumer_work_start( mlt_consumer this ) +static void consumer_work_start( mlt_consumer self ) { - int n = abs( this->real_time ); + int n = abs( self->real_time ); pthread_t *thread = calloc( 1, sizeof( pthread_t ) ); // We're running now - this->ahead = 1; + self->ahead = 1; // These keep track of the accelleration of frame dropping or recovery. - this->consecutive_dropped = 0; - this->consecutive_rendered = 0; + self->consecutive_dropped = 0; + self->consecutive_rendered = 0; // This is the position in the queue from which to look for a frame to process. // If we always start from the head, then we may likely not complete processing // before the frame is played out. - this->process_head = 0; + self->process_head = 0; // Create the queues - this->queue = mlt_deque_init(); - this->worker_threads = mlt_deque_init(); + self->queue = mlt_deque_init(); + self->worker_threads = mlt_deque_init(); // Create the mutexes - pthread_mutex_init( &this->queue_mutex, NULL ); - pthread_mutex_init( &this->done_mutex, NULL ); + pthread_mutex_init( &self->queue_mutex, NULL ); + pthread_mutex_init( &self->done_mutex, NULL ); // Create the conditions - pthread_cond_init( &this->queue_cond, NULL ); - pthread_cond_init( &this->done_cond, NULL ); + pthread_cond_init( &self->queue_cond, NULL ); + pthread_cond_init( &self->done_cond, NULL ); // Create the read ahead - if ( mlt_properties_get( MLT_CONSUMER_PROPERTIES( this ), "priority" ) ) + if ( mlt_properties_get( MLT_CONSUMER_PROPERTIES( self ), "priority" ) ) { struct sched_param priority; pthread_attr_t thread_attributes; - priority.sched_priority = mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( this ), "priority" ); + priority.sched_priority = mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( self ), "priority" ); pthread_attr_init( &thread_attributes ); pthread_attr_setschedpolicy( &thread_attributes, SCHED_OTHER ); pthread_attr_setschedparam( &thread_attributes, &priority ); @@ -966,9 +966,9 @@ static void consumer_work_start( mlt_consumer this ) while ( n-- ) { - if ( pthread_create( thread, &thread_attributes, consumer_read_ahead_thread, this ) < 0 ) - if ( pthread_create( thread, NULL, consumer_read_ahead_thread, this ) == 0 ) - mlt_deque_push_back( this->worker_threads, thread ); + if ( pthread_create( thread, &thread_attributes, consumer_read_ahead_thread, self ) < 0 ) + if ( pthread_create( thread, NULL, consumer_read_ahead_thread, self ) == 0 ) + mlt_deque_push_back( self->worker_threads, thread ); } pthread_attr_destroy( &thread_attributes ); } @@ -977,223 +977,223 @@ static void consumer_work_start( mlt_consumer this ) { while ( n-- ) { - if ( pthread_create( thread, NULL, consumer_worker_thread, this ) == 0 ) - mlt_deque_push_back( this->worker_threads, thread ); + if ( pthread_create( thread, NULL, consumer_worker_thread, self ) == 0 ) + mlt_deque_push_back( self->worker_threads, thread ); } } - this->started = 1; + self->started = 1; } /** Stop the read/render thread. * * \private \memberof mlt_consumer_s - * \param this a consumer + * \param self a consumer */ -static void consumer_read_ahead_stop( mlt_consumer this ) +static void consumer_read_ahead_stop( mlt_consumer self ) { // Make sure we're running - if ( this->started ) + if ( self->started ) { // Inform thread to stop - this->ahead = 0; + self->ahead = 0; // Broadcast to the condition in case it's waiting - pthread_mutex_lock( &this->queue_mutex ); - pthread_cond_broadcast( &this->queue_cond ); - pthread_mutex_unlock( &this->queue_mutex ); + pthread_mutex_lock( &self->queue_mutex ); + pthread_cond_broadcast( &self->queue_cond ); + pthread_mutex_unlock( &self->queue_mutex ); // Broadcast to the put condition in case it's waiting - pthread_mutex_lock( &this->put_mutex ); - pthread_cond_broadcast( &this->put_cond ); - pthread_mutex_unlock( &this->put_mutex ); + pthread_mutex_lock( &self->put_mutex ); + pthread_cond_broadcast( &self->put_cond ); + pthread_mutex_unlock( &self->put_mutex ); // Join the thread - pthread_join( this->ahead_thread, NULL ); - this->started = 0; + pthread_join( self->ahead_thread, NULL ); + self->started = 0; // Destroy the frame queue mutex - pthread_mutex_destroy( &this->queue_mutex ); + pthread_mutex_destroy( &self->queue_mutex ); // Destroy the condition - pthread_cond_destroy( &this->queue_cond ); + pthread_cond_destroy( &self->queue_cond ); // Wipe the queue - while ( mlt_deque_count( this->queue ) ) - mlt_frame_close( mlt_deque_pop_back( this->queue ) ); + while ( mlt_deque_count( self->queue ) ) + mlt_frame_close( mlt_deque_pop_back( self->queue ) ); // Close the queue - mlt_deque_close( this->queue ); + mlt_deque_close( self->queue ); } } /** Stop the worker threads. * * \private \memberof mlt_consumer_s - * \param this a consumer + * \param self a consumer */ -static void consumer_work_stop( mlt_consumer this ) +static void consumer_work_stop( mlt_consumer self ) { // Make sure we're running - if ( this->started ) + if ( self->started ) { // Inform thread to stop - this->ahead = 0; + self->ahead = 0; // Broadcast to the queue condition in case it's waiting - pthread_mutex_lock( &this->queue_mutex ); - pthread_cond_broadcast( &this->queue_cond ); - pthread_mutex_unlock( &this->queue_mutex ); + pthread_mutex_lock( &self->queue_mutex ); + pthread_cond_broadcast( &self->queue_cond ); + pthread_mutex_unlock( &self->queue_mutex ); // Broadcast to the put condition in case it's waiting - pthread_mutex_lock( &this->put_mutex ); - pthread_cond_broadcast( &this->put_cond ); - pthread_mutex_unlock( &this->put_mutex ); + pthread_mutex_lock( &self->put_mutex ); + pthread_cond_broadcast( &self->put_cond ); + pthread_mutex_unlock( &self->put_mutex ); // Broadcast to the done condition in case it's waiting - pthread_mutex_lock( &this->done_mutex ); - pthread_cond_broadcast( &this->done_cond ); - pthread_mutex_unlock( &this->done_mutex ); + pthread_mutex_lock( &self->done_mutex ); + pthread_cond_broadcast( &self->done_cond ); + pthread_mutex_unlock( &self->done_mutex ); // Join the threads pthread_t *thread; - while ( ( thread = mlt_deque_pop_front( this->worker_threads ) ) ) + while ( ( thread = mlt_deque_pop_front( self->worker_threads ) ) ) pthread_join( *thread, NULL ); - this->started = 0; + self->started = 0; // Destroy the mutexes - pthread_mutex_destroy( &this->queue_mutex ); - pthread_mutex_destroy( &this->done_mutex ); + pthread_mutex_destroy( &self->queue_mutex ); + pthread_mutex_destroy( &self->done_mutex ); // Destroy the conditions - pthread_cond_destroy( &this->queue_cond ); - pthread_cond_destroy( &this->done_cond ); + pthread_cond_destroy( &self->queue_cond ); + pthread_cond_destroy( &self->done_cond ); // Wipe the queues - while ( mlt_deque_count( this->queue ) ) - mlt_frame_close( mlt_deque_pop_back( this->queue ) ); + while ( mlt_deque_count( self->queue ) ) + mlt_frame_close( mlt_deque_pop_back( self->queue ) ); // Close the queues - mlt_deque_close( this->queue ); - mlt_deque_close( this->worker_threads ); + mlt_deque_close( self->queue ); + mlt_deque_close( self->worker_threads ); } } /** Flush the read/render thread's buffer. * * \public \memberof mlt_consumer_s - * \param this a consumer + * \param self a consumer */ -void mlt_consumer_purge( mlt_consumer this ) +void mlt_consumer_purge( mlt_consumer self ) { - if ( this->ahead ) + if ( self->ahead ) { - pthread_mutex_lock( &this->queue_mutex ); - while ( mlt_deque_count( this->queue ) ) - mlt_frame_close( mlt_deque_pop_back( this->queue ) ); - pthread_cond_broadcast( &this->queue_cond ); - pthread_mutex_unlock( &this->queue_mutex ); + pthread_mutex_lock( &self->queue_mutex ); + while ( mlt_deque_count( self->queue ) ) + mlt_frame_close( mlt_deque_pop_back( self->queue ) ); + pthread_cond_broadcast( &self->queue_cond ); + pthread_mutex_unlock( &self->queue_mutex ); } } /** Use multiple worker threads and a work queue. */ -static mlt_frame worker_get_frame( mlt_consumer this, mlt_properties properties ) +static mlt_frame worker_get_frame( mlt_consumer self, mlt_properties properties ) { // Frame to return mlt_frame frame = NULL; - int size = abs( this->real_time ); + int size = abs( self->real_time ); int buffer = mlt_properties_get_int( properties, "buffer" ); // This is a heuristic to determine a suitable minimum buffer size for the number of threads. int headroom = 2 + size * size; buffer = buffer < headroom ? headroom : buffer; // Start worker threads if not already started. - if ( ! this->ahead ) + if ( ! self->ahead ) { int prefill = mlt_properties_get_int( properties, "prefill" ); prefill = prefill > 0 && prefill < buffer ? prefill : buffer; - consumer_work_start( this ); + consumer_work_start( self ); // Fill the work queue. int i = buffer; - while ( this->ahead && i-- ) + while ( self->ahead && i-- ) { - frame = mlt_consumer_get_frame( this ); + frame = mlt_consumer_get_frame( self ); if ( frame ) { - pthread_mutex_lock( &this->queue_mutex ); - mlt_deque_push_back( this->queue, frame ); - pthread_cond_signal( &this->queue_cond ); - pthread_mutex_unlock( &this->queue_mutex ); + pthread_mutex_lock( &self->queue_mutex ); + mlt_deque_push_back( self->queue, frame ); + pthread_cond_signal( &self->queue_cond ); + pthread_mutex_unlock( &self->queue_mutex ); } } // Wait for prefill - while ( this->ahead && first_unprocessed_frame( this ) < prefill ) + while ( self->ahead && first_unprocessed_frame( self ) < prefill ) { - pthread_mutex_lock( &this->done_mutex ); - pthread_cond_wait( &this->done_cond, &this->done_mutex ); - pthread_mutex_unlock( &this->done_mutex ); + pthread_mutex_lock( &self->done_mutex ); + pthread_cond_wait( &self->done_cond, &self->done_mutex ); + pthread_mutex_unlock( &self->done_mutex ); } - this->process_head = size; + self->process_head = size; } -// mlt_log_verbose( MLT_CONSUMER_SERVICE(this), "size %d done count %d work count %d process_head %d\n", -// size, first_unprocessed_frame( this ), mlt_deque_count( this->queue ), this->process_head ); +// mlt_log_verbose( MLT_CONSUMER_SERVICE(self), "size %d done count %d work count %d process_head %d\n", +// size, first_unprocessed_frame( self ), mlt_deque_count( self->queue ), self->process_head ); // Feed the work queue - while ( this->ahead && mlt_deque_count( this->queue ) < buffer ) + while ( self->ahead && mlt_deque_count( self->queue ) < buffer ) { - frame = mlt_consumer_get_frame( this ); + frame = mlt_consumer_get_frame( self ); if ( ! frame ) return frame; - pthread_mutex_lock( &this->queue_mutex ); - mlt_deque_push_back( this->queue, frame ); - pthread_cond_signal( &this->queue_cond ); - pthread_mutex_unlock( &this->queue_mutex ); + pthread_mutex_lock( &self->queue_mutex ); + mlt_deque_push_back( self->queue, frame ); + pthread_cond_signal( &self->queue_cond ); + pthread_mutex_unlock( &self->queue_mutex ); } // Wait if not realtime. - while( this->ahead && this->real_time < 0 && - ! mlt_properties_get_int( MLT_FRAME_PROPERTIES( MLT_FRAME( mlt_deque_peek_front( this->queue ) ) ), "rendered" ) ) + while( self->ahead && self->real_time < 0 && + ! mlt_properties_get_int( MLT_FRAME_PROPERTIES( MLT_FRAME( mlt_deque_peek_front( self->queue ) ) ), "rendered" ) ) { - pthread_mutex_lock( &this->done_mutex ); - pthread_cond_wait( &this->done_cond, &this->done_mutex ); - pthread_mutex_unlock( &this->done_mutex ); + pthread_mutex_lock( &self->done_mutex ); + pthread_cond_wait( &self->done_cond, &self->done_mutex ); + pthread_mutex_unlock( &self->done_mutex ); } // Get the frame from the queue. - pthread_mutex_lock( &this->queue_mutex ); - frame = mlt_deque_pop_front( this->queue ); - pthread_mutex_unlock( &this->queue_mutex ); + pthread_mutex_lock( &self->queue_mutex ); + frame = mlt_deque_pop_front( self->queue ); + pthread_mutex_unlock( &self->queue_mutex ); // Adapt the worker process head to the runtime conditions. - if ( this->real_time > 0 ) + if ( self->real_time > 0 ) { if ( mlt_properties_get_int( MLT_FRAME_PROPERTIES( frame ), "rendered" ) ) { - this->consecutive_dropped = 0; - if ( this->process_head > size && this->consecutive_rendered >= this->process_head ) - this->process_head--; + self->consecutive_dropped = 0; + if ( self->process_head > size && self->consecutive_rendered >= self->process_head ) + self->process_head--; else - this->consecutive_rendered++; + self->consecutive_rendered++; } else { - this->consecutive_rendered = 0; - if ( this->process_head < buffer - size && this->consecutive_dropped > size ) - this->process_head++; + self->consecutive_rendered = 0; + if ( self->process_head < buffer - size && self->consecutive_dropped > size ) + self->process_head++; else - this->consecutive_dropped++; + self->consecutive_dropped++; } -// mlt_log_verbose( MLT_CONSUMER_SERVICE(this), "dropped %d rendered %d process_head %d\n", -// this->consecutive_dropped, this->consecutive_rendered, this->process_head ); +// mlt_log_verbose( MLT_CONSUMER_SERVICE(self), "dropped %d rendered %d process_head %d\n", +// self->consecutive_dropped, self->consecutive_rendered, self->process_head ); } return frame; @@ -1206,50 +1206,50 @@ static mlt_frame worker_get_frame( mlt_consumer this, mlt_properties properties * You should close the frame returned from this when you are done with it. * * \public \memberof mlt_consumer_s - * \param this a consumer + * \param self a consumer * \return a frame */ -mlt_frame mlt_consumer_rt_frame( mlt_consumer this ) +mlt_frame mlt_consumer_rt_frame( mlt_consumer self ) { // Frame to return mlt_frame frame = NULL; // Get the properties - mlt_properties properties = MLT_CONSUMER_PROPERTIES( this ); + mlt_properties properties = MLT_CONSUMER_PROPERTIES( self ); // Check if the user has requested real time or not - if ( this->real_time > 1 || this->real_time < -1 ) + if ( self->real_time > 1 || self->real_time < -1 ) { // see above - return worker_get_frame( this, properties ); + return worker_get_frame( self, properties ); } - else if ( this->real_time == 1 || this->real_time == -1 ) + else if ( self->real_time == 1 || self->real_time == -1 ) { int size = 1; // Is the read ahead running? - if ( this->ahead == 0 ) + if ( self->ahead == 0 ) { int buffer = mlt_properties_get_int( properties, "buffer" ); int prefill = mlt_properties_get_int( properties, "prefill" ); - consumer_read_ahead_start( this ); + consumer_read_ahead_start( self ); if ( buffer > 1 ) size = prefill > 0 && prefill < buffer ? prefill : buffer; } // Get frame from queue - pthread_mutex_lock( &this->queue_mutex ); - while( this->ahead && mlt_deque_count( this->queue ) < size ) - pthread_cond_wait( &this->queue_cond, &this->queue_mutex ); - frame = mlt_deque_pop_front( this->queue ); - pthread_cond_broadcast( &this->queue_cond ); - pthread_mutex_unlock( &this->queue_mutex ); + pthread_mutex_lock( &self->queue_mutex ); + while( self->ahead && mlt_deque_count( self->queue ) < size ) + pthread_cond_wait( &self->queue_cond, &self->queue_mutex ); + frame = mlt_deque_pop_front( self->queue ); + pthread_cond_broadcast( &self->queue_cond ); + pthread_mutex_unlock( &self->queue_mutex ); } else // real_time == 0 { // Get the frame in non real time - frame = mlt_consumer_get_frame( this ); + frame = mlt_consumer_get_frame( self ); // This isn't true, but from the consumers perspective it is if ( frame != NULL ) @@ -1262,58 +1262,58 @@ mlt_frame mlt_consumer_rt_frame( mlt_consumer this ) /** Callback for the implementation to indicate a stopped condition. * * \public \memberof mlt_consumer_s - * \param this a consumer + * \param self a consumer */ -void mlt_consumer_stopped( mlt_consumer this ) +void mlt_consumer_stopped( mlt_consumer self ) { - mlt_properties_set_int( MLT_CONSUMER_PROPERTIES( this ), "running", 0 ); - mlt_events_fire( MLT_CONSUMER_PROPERTIES( this ), "consumer-stopped", NULL ); - mlt_event_unblock( this->event_listener ); + mlt_properties_set_int( MLT_CONSUMER_PROPERTIES( self ), "running", 0 ); + mlt_events_fire( MLT_CONSUMER_PROPERTIES( self ), "consumer-stopped", NULL ); + mlt_event_unblock( self->event_listener ); } /** Stop the consumer. * * \public \memberof mlt_consumer_s - * \param this a consumer + * \param self a consumer * \return true if there was an error */ -int mlt_consumer_stop( mlt_consumer this ) +int mlt_consumer_stop( mlt_consumer self ) { // Get the properies - mlt_properties properties = MLT_CONSUMER_PROPERTIES( this ); + mlt_properties properties = MLT_CONSUMER_PROPERTIES( self ); // Just in case... - mlt_log( MLT_CONSUMER_SERVICE( this ), MLT_LOG_DEBUG, "stopping put waiting\n" ); - pthread_mutex_lock( &this->put_mutex ); - this->put_active = 0; - pthread_cond_broadcast( &this->put_cond ); - pthread_mutex_unlock( &this->put_mutex ); + mlt_log( MLT_CONSUMER_SERVICE( self ), MLT_LOG_DEBUG, "stopping put waiting\n" ); + pthread_mutex_lock( &self->put_mutex ); + self->put_active = 0; + pthread_cond_broadcast( &self->put_cond ); + pthread_mutex_unlock( &self->put_mutex ); // Stop the consumer - mlt_log( MLT_CONSUMER_SERVICE( this ), MLT_LOG_DEBUG, "stopping consumer\n" ); + mlt_log( MLT_CONSUMER_SERVICE( self ), MLT_LOG_DEBUG, "stopping consumer\n" ); // Cancel the read ahead threads - this->ahead = 0; - if ( this->started ) + self->ahead = 0; + if ( self->started ) { // Unblock the consumer calling mlt_consumer_rt_frame - pthread_mutex_lock( &this->queue_mutex ); - pthread_cond_broadcast( &this->queue_cond ); - pthread_mutex_unlock( &this->queue_mutex ); + pthread_mutex_lock( &self->queue_mutex ); + pthread_cond_broadcast( &self->queue_cond ); + pthread_mutex_unlock( &self->queue_mutex ); } // Invoke the child callback - if ( this->stop != NULL ) - this->stop( this ); + if ( self->stop != NULL ) + self->stop( self ); // Check if the user has requested real time or not and stop if necessary - mlt_log( MLT_CONSUMER_SERVICE( this ), MLT_LOG_DEBUG, "stopping read_ahead\n" ); - if ( abs( this->real_time ) == 1 ) - consumer_read_ahead_stop( this ); - else if ( abs( this->real_time ) > 1 ) - consumer_work_stop( this ); + mlt_log( MLT_CONSUMER_SERVICE( self ), MLT_LOG_DEBUG, "stopping read_ahead\n" ); + if ( abs( self->real_time ) == 1 ) + consumer_read_ahead_stop( self ); + else if ( abs( self->real_time ) > 1 ) + consumer_work_stop( self ); // Kill the test card mlt_properties_set_data( properties, "test_card_producer", NULL, 0, NULL, NULL ); @@ -1321,9 +1321,9 @@ int mlt_consumer_stop( mlt_consumer this ) // Check and run a post command if ( mlt_properties_get( properties, "post" ) ) if (system( mlt_properties_get( properties, "post" ) ) == -1 ) - mlt_log( MLT_CONSUMER_SERVICE( this ), MLT_LOG_ERROR, "system(%s) failed!\n", mlt_properties_get( properties, "post" ) ); + mlt_log( MLT_CONSUMER_SERVICE( self ), MLT_LOG_ERROR, "system(%s) failed!\n", mlt_properties_get( properties, "post" ) ); - mlt_log( MLT_CONSUMER_SERVICE( this ), MLT_LOG_DEBUG, "stopped\n" ); + mlt_log( MLT_CONSUMER_SERVICE( self ), MLT_LOG_DEBUG, "stopped\n" ); return 0; } @@ -1331,15 +1331,15 @@ int mlt_consumer_stop( mlt_consumer this ) /** Determine if the consumer is stopped. * * \public \memberof mlt_consumer_s - * \param this a consumer + * \param self a consumer * \return true if the consumer is stopped */ -int mlt_consumer_is_stopped( mlt_consumer this ) +int mlt_consumer_is_stopped( mlt_consumer self ) { // Check if the consumer is stopped - if ( this->is_stopped != NULL ) - return this->is_stopped( this ); + if ( self->is_stopped != NULL ) + return self->is_stopped( self ); return 0; } @@ -1347,34 +1347,34 @@ int mlt_consumer_is_stopped( mlt_consumer this ) /** Close and destroy the consumer. * * \public \memberof mlt_consumer_s - * \param this a consumer + * \param self a consumer */ -void mlt_consumer_close( mlt_consumer this ) +void mlt_consumer_close( mlt_consumer self ) { - if ( this != NULL && mlt_properties_dec_ref( MLT_CONSUMER_PROPERTIES( this ) ) <= 0 ) + if ( self != NULL && mlt_properties_dec_ref( MLT_CONSUMER_PROPERTIES( self ) ) <= 0 ) { // Get the childs close function - void ( *consumer_close )( ) = this->close; + void ( *consumer_close )( ) = self->close; if ( consumer_close ) { // Just in case... - //mlt_consumer_stop( this ); + //mlt_consumer_stop( self ); - this->close = NULL; - consumer_close( this ); + self->close = NULL; + consumer_close( self ); } else { // Make sure it only gets called once - this->parent.close = NULL; + self->parent.close = NULL; // Destroy the push mutex and condition - pthread_mutex_destroy( &this->put_mutex ); - pthread_cond_destroy( &this->put_cond ); + pthread_mutex_destroy( &self->put_mutex ); + pthread_cond_destroy( &self->put_cond ); - mlt_service_close( &this->parent ); + mlt_service_close( &self->parent ); } } } diff --git a/src/framework/mlt_deque.c b/src/framework/mlt_deque.c index 844ad83b..c11c84e4 100644 --- a/src/framework/mlt_deque.c +++ b/src/framework/mlt_deque.c @@ -61,59 +61,59 @@ struct mlt_deque_s mlt_deque mlt_deque_init( ) { - mlt_deque this = malloc( sizeof( struct mlt_deque_s ) ); - if ( this != NULL ) + mlt_deque self = malloc( sizeof( struct mlt_deque_s ) ); + if ( self != NULL ) { - this->list = NULL; - this->size = 0; - this->count = 0; + self->list = NULL; + self->size = 0; + self->count = 0; } - return this; + return self; } /** Return the number of items in the deque. * * \public \memberof mlt_deque_s - * \param this a deque + * \param self a deque * \return the number of items */ -int mlt_deque_count( mlt_deque this ) +int mlt_deque_count( mlt_deque self ) { - return this->count; + return self->count; } /** Allocate space on the deque. * * \private \memberof mlt_deque_s - * \param this a deque + * \param self a deque * \return true if there was an error */ -static int mlt_deque_allocate( mlt_deque this ) +static int mlt_deque_allocate( mlt_deque self ) { - if ( this->count == this->size ) + if ( self->count == self->size ) { - this->list = realloc( this->list, sizeof( deque_entry ) * ( this->size + 20 ) ); - this->size += 20; + self->list = realloc( self->list, sizeof( deque_entry ) * ( self->size + 20 ) ); + self->size += 20; } - return this->list == NULL; + return self->list == NULL; } /** Push an item to the end. * * \public \memberof mlt_deque_s - * \param this a deque + * \param self a deque * \param item an opaque pointer * \return true if there was an error */ -int mlt_deque_push_back( mlt_deque this, void *item ) +int mlt_deque_push_back( mlt_deque self, void *item ) { - int error = mlt_deque_allocate( this ); + int error = mlt_deque_allocate( self ); if ( error == 0 ) - this->list[ this->count ++ ].addr = item; + self->list[ self->count ++ ].addr = item; return error; } @@ -121,31 +121,31 @@ int mlt_deque_push_back( mlt_deque this, void *item ) /** Pop an item. * * \public \memberof mlt_deque_s - * \param this a pointer + * \param self a pointer * \return an opaque pointer */ -void *mlt_deque_pop_back( mlt_deque this ) +void *mlt_deque_pop_back( mlt_deque self ) { - return this->count > 0 ? this->list[ -- this->count ].addr : NULL; + return self->count > 0 ? self->list[ -- self->count ].addr : NULL; } /** Queue an item at the start. * * \public \memberof mlt_deque_s - * \param this a deque + * \param self a deque * \param item an opaque pointer * \return true if there was an error */ -int mlt_deque_push_front( mlt_deque this, void *item ) +int mlt_deque_push_front( mlt_deque self, void *item ) { - int error = mlt_deque_allocate( this ); + int error = mlt_deque_allocate( self ); if ( error == 0 ) { - memmove( &this->list[ 1 ], this->list, ( this->count ++ ) * sizeof( deque_entry ) ); - this->list[ 0 ].addr = item; + memmove( &self->list[ 1 ], self->list, ( self->count ++ ) * sizeof( deque_entry ) ); + self->list[ 0 ].addr = item; } return error; @@ -154,18 +154,18 @@ int mlt_deque_push_front( mlt_deque this, void *item ) /** Remove an item from the start. * * \public \memberof mlt_deque_s - * \param this a pointer + * \param self a pointer * \return an opaque pointer */ -void *mlt_deque_pop_front( mlt_deque this ) +void *mlt_deque_pop_front( mlt_deque self ) { void *item = NULL; - if ( this->count > 0 ) + if ( self->count > 0 ) { - item = this->list[ 0 ].addr; - memmove( this->list, &this->list[ 1 ], ( -- this->count ) * sizeof( deque_entry ) ); + item = self->list[ 0 ].addr; + memmove( self->list, &self->list[ 1 ], ( -- self->count ) * sizeof( deque_entry ) ); } return item; @@ -174,38 +174,38 @@ void *mlt_deque_pop_front( mlt_deque this ) /** Inquire on item at back of deque but don't remove. * * \public \memberof mlt_deque_s - * \param this a deque + * \param self a deque * \return an opaque pointer */ -void *mlt_deque_peek_back( mlt_deque this ) +void *mlt_deque_peek_back( mlt_deque self ) { - return this->count > 0 ? this->list[ this->count - 1 ].addr : NULL; + return self->count > 0 ? self->list[ self->count - 1 ].addr : NULL; } /** Inquire on item at front of deque but don't remove. * * \public \memberof mlt_deque_s - * \param this a deque + * \param self a deque * \return an opaque pointer */ -void *mlt_deque_peek_front( mlt_deque this ) +void *mlt_deque_peek_front( mlt_deque self ) { - return this->count > 0 ? this->list[ 0 ].addr : NULL; + return self->count > 0 ? self->list[ 0 ].addr : NULL; } /** Inquire on item in deque but don't remove. * * \public \memberof mlt_deque_s - * \param this a deque + * \param self a deque * \param index the position in the deque * \return an opaque pointer */ -void *mlt_deque_peek( mlt_deque this, int index ) +void *mlt_deque_peek( mlt_deque self, int index ) { - return this->count > index ? this->list[ index ].addr : NULL; + return self->count > index ? self->list[ index ].addr : NULL; } /** Insert an item in a sorted fashion. @@ -213,25 +213,25 @@ void *mlt_deque_peek( mlt_deque this, int index ) * Optimized for the equivalent of \p mlt_deque_push_back. * * \public \memberof mlt_deque_s - * \param this a deque + * \param self a deque * \param item an opaque pointer * \param cmp a function pointer to the comparison function * \return true if there was an error */ -int mlt_deque_insert( mlt_deque this, void *item, mlt_deque_compare cmp ) +int mlt_deque_insert( mlt_deque self, void *item, mlt_deque_compare cmp ) { - int error = mlt_deque_allocate( this ); + int error = mlt_deque_allocate( self ); if ( error == 0 ) { - int n = this->count + 1; + int n = self->count + 1; while ( --n ) - if ( cmp( item, this->list[ n - 1 ].addr ) >= 0 ) + if ( cmp( item, self->list[ n - 1 ].addr ) >= 0 ) break; - memmove( &this->list[ n + 1 ], &this->list[ n ], ( this->count - n ) * sizeof( deque_entry ) ); - this->list[ n ].addr = item; - this->count++; + memmove( &self->list[ n + 1 ], &self->list[ n ], ( self->count - n ) * sizeof( deque_entry ) ); + self->list[ n ].addr = item; + self->count++; } return error; } @@ -239,17 +239,17 @@ int mlt_deque_insert( mlt_deque this, void *item, mlt_deque_compare cmp ) /** Push an integer to the end. * * \public \memberof mlt_deque_s - * \param this a deque + * \param self a deque * \param item an integer * \return true if there was an error */ -int mlt_deque_push_back_int( mlt_deque this, int item ) +int mlt_deque_push_back_int( mlt_deque self, int item ) { - int error = mlt_deque_allocate( this ); + int error = mlt_deque_allocate( self ); if ( error == 0 ) - this->list[ this->count ++ ].value = item; + self->list[ self->count ++ ].value = item; return error; } @@ -257,31 +257,31 @@ int mlt_deque_push_back_int( mlt_deque this, int item ) /** Pop an integer. * * \public \memberof mlt_deque_s - * \param this a deque + * \param self a deque * \return an integer */ -int mlt_deque_pop_back_int( mlt_deque this ) +int mlt_deque_pop_back_int( mlt_deque self ) { - return this->count > 0 ? this->list[ -- this->count ].value : 0; + return self->count > 0 ? self->list[ -- self->count ].value : 0; } /** Queue an integer at the start. * * \public \memberof mlt_deque_s - * \param this a deque + * \param self a deque * \param item an integer * \return true if there was an error */ -int mlt_deque_push_front_int( mlt_deque this, int item ) +int mlt_deque_push_front_int( mlt_deque self, int item ) { - int error = mlt_deque_allocate( this ); + int error = mlt_deque_allocate( self ); if ( error == 0 ) { - memmove( &this->list[ 1 ], this->list, ( this->count ++ ) * sizeof( deque_entry ) ); - this->list[ 0 ].value = item; + memmove( &self->list[ 1 ], self->list, ( self->count ++ ) * sizeof( deque_entry ) ); + self->list[ 0 ].value = item; } return error; @@ -290,18 +290,18 @@ int mlt_deque_push_front_int( mlt_deque this, int item ) /** Remove an integer from the start. * * \public \memberof mlt_deque_s - * \param this a deque + * \param self a deque * \return an integer */ -int mlt_deque_pop_front_int( mlt_deque this ) +int mlt_deque_pop_front_int( mlt_deque self ) { int item = 0; - if ( this->count > 0 ) + if ( self->count > 0 ) { - item = this->list[ 0 ].value; - memmove( this->list, &this->list[ 1 ], ( -- this->count ) * sizeof( deque_entry ) ); + item = self->list[ 0 ].value; + memmove( self->list, &self->list[ 1 ], ( -- self->count ) * sizeof( deque_entry ) ); } return item; @@ -310,41 +310,41 @@ int mlt_deque_pop_front_int( mlt_deque this ) /** Inquire on an integer at back of deque but don't remove. * * \public \memberof mlt_deque_s - * \param this a deque + * \param self a deque * \return an integer */ -int mlt_deque_peek_back_int( mlt_deque this ) +int mlt_deque_peek_back_int( mlt_deque self ) { - return this->count > 0 ? this->list[ this->count - 1 ].value : 0; + return self->count > 0 ? self->list[ self->count - 1 ].value : 0; } /** Inquire on an integer at front of deque but don't remove. * * \public \memberof mlt_deque_s - * \param this a deque + * \param self a deque * \return an integer */ -int mlt_deque_peek_front_int( mlt_deque this ) +int mlt_deque_peek_front_int( mlt_deque self ) { - return this->count > 0 ? this->list[ 0 ].value : 0; + return self->count > 0 ? self->list[ 0 ].value : 0; } /** Push a double float to the end. * * \public \memberof mlt_deque_s - * \param this a deque + * \param self a deque * \param item a double float * \return true if there was an error */ -int mlt_deque_push_back_double( mlt_deque this, double item ) +int mlt_deque_push_back_double( mlt_deque self, double item ) { - int error = mlt_deque_allocate( this ); + int error = mlt_deque_allocate( self ); if ( error == 0 ) - this->list[ this->count ++ ].floating = item; + self->list[ self->count ++ ].floating = item; return error; } @@ -352,31 +352,31 @@ int mlt_deque_push_back_double( mlt_deque this, double item ) /** Pop a double float. * * \public \memberof mlt_deque_s - * \param this a deque + * \param self a deque * \return a double float */ -double mlt_deque_pop_back_double( mlt_deque this ) +double mlt_deque_pop_back_double( mlt_deque self ) { - return this->count > 0 ? this->list[ -- this->count ].floating : 0; + return self->count > 0 ? self->list[ -- self->count ].floating : 0; } /** Queue a double float at the start. * * \public \memberof mlt_deque_s - * \param this a deque + * \param self a deque * \param item a double float * \return true if there was an error */ -int mlt_deque_push_front_double( mlt_deque this, double item ) +int mlt_deque_push_front_double( mlt_deque self, double item ) { - int error = mlt_deque_allocate( this ); + int error = mlt_deque_allocate( self ); if ( error == 0 ) { - memmove( &this->list[ 1 ], this->list, ( this->count ++ ) * sizeof( deque_entry ) ); - this->list[ 0 ].floating = item; + memmove( &self->list[ 1 ], self->list, ( self->count ++ ) * sizeof( deque_entry ) ); + self->list[ 0 ].floating = item; } return error; @@ -385,18 +385,18 @@ int mlt_deque_push_front_double( mlt_deque this, double item ) /** Remove a double float from the start. * * \public \memberof mlt_deque_s - * \param this a deque + * \param self a deque * \return a double float */ -double mlt_deque_pop_front_double( mlt_deque this ) +double mlt_deque_pop_front_double( mlt_deque self ) { double item = 0; - if ( this->count > 0 ) + if ( self->count > 0 ) { - item = this->list[ 0 ].floating; - memmove( this->list, &this->list[ 1 ], ( -- this->count ) * sizeof( deque_entry ) ); + item = self->list[ 0 ].floating; + memmove( self->list, &self->list[ 1 ], ( -- self->count ) * sizeof( deque_entry ) ); } return item; @@ -405,35 +405,35 @@ double mlt_deque_pop_front_double( mlt_deque this ) /** Inquire on a double float at back of deque but don't remove. * * \public \memberof mlt_deque_s - * \param this a deque + * \param self a deque * \return a double float */ -double mlt_deque_peek_back_double( mlt_deque this ) +double mlt_deque_peek_back_double( mlt_deque self ) { - return this->count > 0 ? this->list[ this->count - 1 ].floating : 0; + return self->count > 0 ? self->list[ self->count - 1 ].floating : 0; } /** Inquire on a double float at front of deque but don't remove. * * \public \memberof mlt_deque_s - * \param this a deque + * \param self a deque * \return a double float */ -double mlt_deque_peek_front_double( mlt_deque this ) +double mlt_deque_peek_front_double( mlt_deque self ) { - return this->count > 0 ? this->list[ 0 ].floating : 0; + return self->count > 0 ? self->list[ 0 ].floating : 0; } /** Destroy the queue. * * \public \memberof mlt_deque_s - * \param this a deque + * \param self a deque */ -void mlt_deque_close( mlt_deque this ) +void mlt_deque_close( mlt_deque self ) { - free( this->list ); - free( this ); + free( self->list ); + free( self ); } diff --git a/src/framework/mlt_events.c b/src/framework/mlt_events.c index 5c841901..3161d337 100644 --- a/src/framework/mlt_events.c +++ b/src/framework/mlt_events.c @@ -67,60 +67,60 @@ struct mlt_event_struct void *service; }; -/** Increment the reference count on this event. +/** Increment the reference count on self event. * * \public \memberof mlt_event_struct - * \param this an event + * \param self an event */ -void mlt_event_inc_ref( mlt_event this ) +void mlt_event_inc_ref( mlt_event self ) { - if ( this != NULL ) - this->ref_count ++; + if ( self != NULL ) + self->ref_count ++; } -/** Increment the block count on this event. +/** Increment the block count on self event. * * \public \memberof mlt_event_struct - * \param this an event + * \param self an event */ -void mlt_event_block( mlt_event this ) +void mlt_event_block( mlt_event self ) { - if ( this != NULL && this->owner != NULL ) - this->block_count ++; + if ( self != NULL && self->owner != NULL ) + self->block_count ++; } -/** Decrement the block count on this event. +/** Decrement the block count on self event. * * \public \memberof mlt_event_struct - * \param this an event + * \param self an event */ -void mlt_event_unblock( mlt_event this ) +void mlt_event_unblock( mlt_event self ) { - if ( this != NULL && this->owner != NULL ) - this->block_count --; + if ( self != NULL && self->owner != NULL ) + self->block_count --; } -/** Close this event. +/** Close self event. * * \public \memberof mlt_event_struct - * \param this an event + * \param self an event */ -void mlt_event_close( mlt_event this ) +void mlt_event_close( mlt_event self ) { - if ( this != NULL ) + if ( self != NULL ) { - if ( -- this->ref_count == 1 ) - this->owner = NULL; - if ( this->ref_count <= 0 ) + if ( -- self->ref_count == 1 ) + self->owner = NULL; + if ( self->ref_count <= 0 ) { #ifdef _MLT_EVENT_CHECKS_ mlt_log( NULL, MLT_LOG_DEBUG, "Events created %d, destroyed %d\n", events_created, ++events_destroyed ); #endif - free( this ); + free( self ); } } } @@ -135,33 +135,33 @@ static void mlt_events_close( mlt_events ); /** Initialise the events structure. * * \public \memberof mlt_events_struct - * \param this a properties list + * \param self a properties list */ -void mlt_events_init( mlt_properties this ) +void mlt_events_init( mlt_properties self ) { - mlt_events events = mlt_events_fetch( this ); + mlt_events events = mlt_events_fetch( self ); if ( events == NULL ) { events = malloc( sizeof( struct mlt_events_struct ) ); events->list = mlt_properties_new( ); - mlt_events_store( this, events ); + mlt_events_store( self, events ); } } /** Register an event and transmitter. * * \public \memberof mlt_events_struct - * \param this a properties list + * \param self a properties list * \param id the name of an event * \param transmitter the callback function to send an event message * \return true if there was an error */ -int mlt_events_register( mlt_properties this, const char *id, mlt_transmitter transmitter ) +int mlt_events_register( mlt_properties self, const char *id, mlt_transmitter transmitter ) { int error = 1; - mlt_events events = mlt_events_fetch( this ); + mlt_events events = mlt_events_fetch( self ); if ( events != NULL ) { mlt_properties list = events->list; @@ -179,13 +179,13 @@ int mlt_events_register( mlt_properties this, const char *id, mlt_transmitter tr * This takes a variable number of arguments to supply to the listener. * \public \memberof mlt_events_struct - * \param this a properties list + * \param self a properties list * \param id the name of an event */ -void mlt_events_fire( mlt_properties this, const char *id, ... ) +void mlt_events_fire( mlt_properties self, const char *id, ... ) { - mlt_events events = mlt_events_fetch( this ); + mlt_events events = mlt_events_fetch( self ); if ( events != NULL ) { int i = 0; @@ -224,17 +224,17 @@ void mlt_events_fire( mlt_properties this, const char *id, ... ) /** Register a listener. * * \public \memberof mlt_events_struct - * \param this a properties list + * \param self a properties list * \param service an opaque pointer * \param id the name of the event to listen for * \param listener the callback to receive an event message * \return */ -mlt_event mlt_events_listen( mlt_properties this, void *service, const char *id, mlt_listener listener ) +mlt_event mlt_events_listen( mlt_properties self, void *service, const char *id, mlt_listener listener ) { mlt_event event = NULL; - mlt_events events = mlt_events_fetch( this ); + mlt_events events = mlt_events_fetch( self ); if ( events != NULL ) { mlt_properties list = events->list; @@ -287,13 +287,13 @@ mlt_event mlt_events_listen( mlt_properties this, void *service, const char *id, /** Block all events for a given service. * * \public \memberof mlt_events_struct - * \param this a properties list + * \param self a properties list * \param service an opaque pointer */ -void mlt_events_block( mlt_properties this, void *service ) +void mlt_events_block( mlt_properties self, void *service ) { - mlt_events events = mlt_events_fetch( this ); + mlt_events events = mlt_events_fetch( self ); if ( events != NULL ) { int i = 0, j = 0; @@ -318,13 +318,13 @@ void mlt_events_block( mlt_properties this, void *service ) /** Unblock all events for a given service. * * \public \memberof mlt_events_struct - * \param this a properties list + * \param self a properties list * \param service an opaque pointer */ -void mlt_events_unblock( mlt_properties this, void *service ) +void mlt_events_unblock( mlt_properties self, void *service ) { - mlt_events events = mlt_events_fetch( this ); + mlt_events events = mlt_events_fetch( self ); if ( events != NULL ) { int i = 0, j = 0; @@ -349,13 +349,13 @@ void mlt_events_unblock( mlt_properties this, void *service ) /** Disconnect all events for a given service. * * \public \memberof mlt_events_struct - * \param this a properties list + * \param self a properties list * \param service an opaque pointer */ -void mlt_events_disconnect( mlt_properties this, void *service ) +void mlt_events_disconnect( mlt_properties self, void *service ) { - mlt_events events = mlt_events_fetch( this ); + mlt_events events = mlt_events_fetch( self ); if ( events != NULL ) { int i = 0, j = 0; @@ -391,11 +391,11 @@ condition_pair; /** The event listener callback for the wait functions. * * \private \memberof mlt_events_struct - * \param this a properties list + * \param self a properties list * \param pair a condition pair */ -static void mlt_events_listen_for( mlt_properties this, condition_pair *pair ) +static void mlt_events_listen_for( mlt_properties self, condition_pair *pair ) { pthread_mutex_lock( &pair->mutex ); if ( pair->done == 0 ) @@ -408,29 +408,29 @@ static void mlt_events_listen_for( mlt_properties this, condition_pair *pair ) /** Prepare to wait for an event. * * \public \memberof mlt_events_struct - * \param this a properties list + * \param self a properties list * \param id the name of the event to wait for * \return an event */ -mlt_event mlt_events_setup_wait_for( mlt_properties this, const char *id ) +mlt_event mlt_events_setup_wait_for( mlt_properties self, const char *id ) { condition_pair *pair = malloc( sizeof( condition_pair ) ); pair->done = 0; pthread_cond_init( &pair->cond, NULL ); pthread_mutex_init( &pair->mutex, NULL ); pthread_mutex_lock( &pair->mutex ); - return mlt_events_listen( this, pair, id, ( mlt_listener )mlt_events_listen_for ); + return mlt_events_listen( self, pair, id, ( mlt_listener )mlt_events_listen_for ); } /** Wait for an event. * * \public \memberof mlt_events_struct - * \param this a properties list + * \param self a properties list * \param event an event */ -void mlt_events_wait_for( mlt_properties this, mlt_event event ) +void mlt_events_wait_for( mlt_properties self, mlt_event event ) { if ( event != NULL ) { @@ -442,11 +442,11 @@ void mlt_events_wait_for( mlt_properties this, mlt_event event ) /** Cleanup after waiting for an event. * * \public \memberof mlt_events_struct - * \param this a properties list + * \param self a properties list * \param event an event */ -void mlt_events_close_wait_for( mlt_properties this, mlt_event event ) +void mlt_events_close_wait_for( mlt_properties self, mlt_event event ) { if ( event != NULL ) { @@ -462,29 +462,29 @@ void mlt_events_close_wait_for( mlt_properties this, mlt_event event ) /** Fetch the events object. * * \private \memberof mlt_events_struct - * \param this a properties list + * \param self a properties list * \return an events object */ -static mlt_events mlt_events_fetch( mlt_properties this ) +static mlt_events mlt_events_fetch( mlt_properties self ) { mlt_events events = NULL; - if ( this != NULL ) - events = mlt_properties_get_data( this, "_events", NULL ); + if ( self != NULL ) + events = mlt_properties_get_data( self, "_events", NULL ); return events; } /** Store the events object. * * \private \memberof mlt_events_struct - * \param this a properties list + * \param self a properties list * \param events an events object */ -static void mlt_events_store( mlt_properties this, mlt_events events ) +static void mlt_events_store( mlt_properties self, mlt_events events ) { - if ( this != NULL && events != NULL ) - mlt_properties_set_data( this, "_events", events, 0, ( mlt_destructor )mlt_events_close, NULL ); + if ( self != NULL && events != NULL ) + mlt_properties_set_data( self, "_events", events, 0, ( mlt_destructor )mlt_events_close, NULL ); } /** Close the events object. diff --git a/src/framework/mlt_factory.c b/src/framework/mlt_factory.c index ebfc1076..8fa24ae8 100644 --- a/src/framework/mlt_factory.c +++ b/src/framework/mlt_factory.c @@ -57,28 +57,28 @@ static int unique_id = 0; * * \param listener * \param owner - * \param this + * \param self * \param args */ -static void mlt_factory_create_request( mlt_listener listener, mlt_properties owner, mlt_service this, void **args ) +static void mlt_factory_create_request( mlt_listener listener, mlt_properties owner, mlt_service self, void **args ) { if ( listener != NULL ) - listener( owner, this, ( char * )args[ 0 ], ( char * )args[ 1 ], ( mlt_service * )args[ 2 ] ); + listener( owner, self, ( char * )args[ 0 ], ( char * )args[ 1 ], ( mlt_service * )args[ 2 ] ); } /** the -create-done event transmitter * * \param listener * \param owner - * \param this + * \param self * \param args */ -static void mlt_factory_create_done( mlt_listener listener, mlt_properties owner, mlt_service this, void **args ) +static void mlt_factory_create_done( mlt_listener listener, mlt_properties owner, mlt_service self, void **args ) { if ( listener != NULL ) - listener( owner, this, ( char * )args[ 0 ], ( char * )args[ 1 ], ( mlt_service )args[ 2 ] ); + listener( owner, self, ( char * )args[ 0 ], ( char * )args[ 1 ], ( mlt_service )args[ 2 ] ); } /** Construct the repository and factories. diff --git a/src/framework/mlt_field.c b/src/framework/mlt_field.c index c988ae6e..6dc82280 100644 --- a/src/framework/mlt_field.c +++ b/src/framework/mlt_field.c @@ -57,26 +57,26 @@ struct mlt_field_s mlt_field mlt_field_init( ) { // Initialise the field - mlt_field this = calloc( sizeof( struct mlt_field_s ), 1 ); + mlt_field self = calloc( sizeof( struct mlt_field_s ), 1 ); // Initialise it - if ( this != NULL ) + if ( self != NULL ) { // Construct a multitrack - this->multitrack = mlt_multitrack_init( ); + self->multitrack = mlt_multitrack_init( ); // Construct a tractor - this->tractor = mlt_tractor_init( ); + self->tractor = mlt_tractor_init( ); // The first plant will be connected to the mulitrack - this->producer = MLT_MULTITRACK_SERVICE( this->multitrack ); + self->producer = MLT_MULTITRACK_SERVICE( self->multitrack ); // Connect the tractor to the multitrack - mlt_tractor_connect( this->tractor, this->producer ); + mlt_tractor_connect( self->tractor, self->producer ); } - // Return this - return this; + // Return self + return self; } /** Construct a field and initialize with supplied multitrack and tractor. @@ -90,101 +90,101 @@ mlt_field mlt_field_init( ) mlt_field mlt_field_new( mlt_multitrack multitrack, mlt_tractor tractor ) { // Initialise the field - mlt_field this = calloc( sizeof( struct mlt_field_s ), 1 ); + mlt_field self = calloc( sizeof( struct mlt_field_s ), 1 ); // Initialise it - if ( this != NULL ) + if ( self != NULL ) { // Construct a multitrack - this->multitrack = multitrack; + self->multitrack = multitrack; // Construct a tractor - this->tractor = tractor; + self->tractor = tractor; // The first plant will be connected to the mulitrack - this->producer = MLT_MULTITRACK_SERVICE( this->multitrack ); + self->producer = MLT_MULTITRACK_SERVICE( self->multitrack ); // Connect the tractor to the multitrack - mlt_tractor_connect( this->tractor, this->producer ); + mlt_tractor_connect( self->tractor, self->producer ); } - // Return this - return this; + // Return self + return self; } /** Get the service associated to this field. * * \public \memberof mlt_field_s - * \param this a field + * \param self a field * \return the tractor as a service */ -mlt_service mlt_field_service( mlt_field this ) +mlt_service mlt_field_service( mlt_field self ) { - return MLT_TRACTOR_SERVICE( this->tractor ); + return MLT_TRACTOR_SERVICE( self->tractor ); } /** Get the multitrack. * * \public \memberof mlt_field_s - * \param this a field + * \param self a field * \return the multitrack */ -mlt_multitrack mlt_field_multitrack( mlt_field this ) +mlt_multitrack mlt_field_multitrack( mlt_field self ) { - return this != NULL ? this->multitrack : NULL; + return self != NULL ? self->multitrack : NULL; } /** Get the tractor. * * \public \memberof mlt_field_s - * \param this a field + * \param self a field * \return the tractor */ -mlt_tractor mlt_field_tractor( mlt_field this ) +mlt_tractor mlt_field_tractor( mlt_field self ) { - return this != NULL ? this->tractor : NULL; + return self != NULL ? self->tractor : NULL; } /** Get the properties associated to this field. * * \public \memberof mlt_field_s - * \param this a field + * \param self a field * \return a properties list */ -mlt_properties mlt_field_properties( mlt_field this ) +mlt_properties mlt_field_properties( mlt_field self ) { - return MLT_SERVICE_PROPERTIES( mlt_field_service( this ) ); + return MLT_SERVICE_PROPERTIES( mlt_field_service( self ) ); } /** Plant a filter. * * \public \memberof mlt_field_s - * \param this a field + * \param self a field * \param that a filter * \param track the track index * \return true if there was an error */ -int mlt_field_plant_filter( mlt_field this, mlt_filter that, int track ) +int mlt_field_plant_filter( mlt_field self, mlt_filter that, int track ) { // Connect the filter to the last producer - int result = mlt_filter_connect( that, this->producer, track ); + int result = mlt_filter_connect( that, self->producer, track ); // If sucessful, then we'll use this for connecting in the future if ( result == 0 ) { // This is now the new producer - this->producer = MLT_FILTER_SERVICE( that ); + self->producer = MLT_FILTER_SERVICE( that ); // Reconnect tractor to new producer - mlt_tractor_connect( this->tractor, this->producer ); + mlt_tractor_connect( self->tractor, self->producer ); // Fire an event - mlt_events_fire( mlt_field_properties( this ), "service-changed", NULL ); + mlt_events_fire( mlt_field_properties( self ), "service-changed", NULL ); } return result; @@ -193,29 +193,29 @@ int mlt_field_plant_filter( mlt_field this, mlt_filter that, int track ) /** Plant a transition. * * \public \memberof mlt_field_s - * \param this a field + * \param self a field * \param that a transition * \param a_track input A's track index * \param b_track input B's track index * \return true if there was an error */ -int mlt_field_plant_transition( mlt_field this, mlt_transition that, int a_track, int b_track ) +int mlt_field_plant_transition( mlt_field self, mlt_transition that, int a_track, int b_track ) { // Connect the transition to the last producer - int result = mlt_transition_connect( that, this->producer, a_track, b_track ); + int result = mlt_transition_connect( that, self->producer, a_track, b_track ); - // If sucessful, then we'll use this for connecting in the future + // If sucessful, then we'll use self for connecting in the future if ( result == 0 ) { // This is now the new producer - this->producer = MLT_TRANSITION_SERVICE( that ); + self->producer = MLT_TRANSITION_SERVICE( that ); // Reconnect tractor to new producer - mlt_tractor_connect( this->tractor, this->producer ); + mlt_tractor_connect( self->tractor, self->producer ); // Fire an event - mlt_events_fire( mlt_field_properties( this ), "service-changed", NULL ); + mlt_events_fire( mlt_field_properties( self ), "service-changed", NULL ); } return 0; @@ -224,16 +224,16 @@ int mlt_field_plant_transition( mlt_field this, mlt_transition that, int a_track /** Close the field. * * \public \memberof mlt_field_s - * \param this a field + * \param self a field */ -void mlt_field_close( mlt_field this ) +void mlt_field_close( mlt_field self ) { - if ( this != NULL && mlt_properties_dec_ref( mlt_field_properties( this ) ) <= 0 ) + if ( self != NULL && mlt_properties_dec_ref( mlt_field_properties( self ) ) <= 0 ) { - //mlt_tractor_close( this->tractor ); - //mlt_multitrack_close( this->multitrack ); - free( this ); + //mlt_tractor_close( self->tractor ); + //mlt_multitrack_close( self->multitrack ); + free( self ); } } diff --git a/src/framework/mlt_filter.c b/src/framework/mlt_filter.c index 9a04352e..e3de41e6 100644 --- a/src/framework/mlt_filter.c +++ b/src/framework/mlt_filter.c @@ -28,22 +28,22 @@ #include #include -static int filter_get_frame( mlt_service this, mlt_frame_ptr frame, int index ); +static int filter_get_frame( mlt_service self, mlt_frame_ptr frame, int index ); /** Initialize a new filter. * * \public \memberof mlt_filter_s - * \param this a filter + * \param self a filter * \param child the object of a subclass * \return true if there was an error */ -int mlt_filter_init( mlt_filter this, void *child ) +int mlt_filter_init( mlt_filter self, void *child ) { - mlt_service service = &this->parent; - memset( this, 0, sizeof( struct mlt_filter_s ) ); - this->child = child; - if ( mlt_service_init( service, this ) == 0 ) + mlt_service service = &self->parent; + memset( self, 0, sizeof( struct mlt_filter_s ) ); + self->child = child; + if ( mlt_service_init( service, self ) == 0 ) { mlt_properties properties = MLT_SERVICE_PROPERTIES( service ); @@ -52,7 +52,7 @@ int mlt_filter_init( mlt_filter this, void *child ) // Define the destructor service->close = ( mlt_destructor )mlt_filter_close; - service->close_object = this; + service->close_object = self; // Default in, out, track properties mlt_properties_set_position( properties, "in", 0 ); @@ -72,55 +72,55 @@ int mlt_filter_init( mlt_filter this, void *child ) mlt_filter mlt_filter_new( ) { - mlt_filter this = calloc( 1, sizeof( struct mlt_filter_s ) ); - if ( this != NULL ) - mlt_filter_init( this, NULL ); - return this; + mlt_filter self = calloc( 1, sizeof( struct mlt_filter_s ) ); + if ( self != NULL ) + mlt_filter_init( self, NULL ); + return self; } /** Get the service class interface. * * \public \memberof mlt_filter_s - * \param this a filter + * \param self a filter * \return the service parent class * \see MLT_FILTER_SERVICE */ -mlt_service mlt_filter_service( mlt_filter this ) +mlt_service mlt_filter_service( mlt_filter self ) { - return this != NULL ? &this->parent : NULL; + return self != NULL ? &self->parent : NULL; } /** Get the filter properties. * * \public \memberof mlt_filter_s - * \param this a filter + * \param self a filter * \return the properties list for the filter * \see MLT_FILTER_PROPERTIES */ -mlt_properties mlt_filter_properties( mlt_filter this ) +mlt_properties mlt_filter_properties( mlt_filter self ) { - return MLT_SERVICE_PROPERTIES( MLT_FILTER_SERVICE( this ) ); + return MLT_SERVICE_PROPERTIES( MLT_FILTER_SERVICE( self ) ); } /** Connect this filter to a producers track. Note that a filter only operates * on a single track, and by default it operates on the entirety of that track. * * \public \memberof mlt_filter_s - * \param this a filter + * \param self a filter * \param producer the producer to which to connect this filter * \param index which of potentially multiple producers to this service (0 based) */ -int mlt_filter_connect( mlt_filter this, mlt_service producer, int index ) +int mlt_filter_connect( mlt_filter self, mlt_service producer, int index ) { - int ret = mlt_service_connect_producer( &this->parent, producer, index ); + int ret = mlt_service_connect_producer( &self->parent, producer, index ); // If the connection was successful, grab the producer, track and reset in/out if ( ret == 0 ) { - mlt_properties properties = MLT_SERVICE_PROPERTIES( &this->parent ); + mlt_properties properties = MLT_SERVICE_PROPERTIES( &self->parent ); mlt_properties_set_position( properties, "in", 0 ); mlt_properties_set_position( properties, "out", 0 ); mlt_properties_set_int( properties, "track", index ); @@ -132,15 +132,15 @@ int mlt_filter_connect( mlt_filter this, mlt_service producer, int index ) /** Set the starting and ending time. * * \public \memberof mlt_filter_s - * \param this a filter + * \param self a filter * \param in the time relative to the producer at which start applying the filter * \param out the time relative to the producer at which to stop applying the filter */ -void mlt_filter_set_in_and_out( mlt_filter this, mlt_position in, mlt_position out ) +void mlt_filter_set_in_and_out( mlt_filter self, mlt_position in, mlt_position out ) { - mlt_properties properties = MLT_SERVICE_PROPERTIES( &this->parent ); + mlt_properties properties = MLT_SERVICE_PROPERTIES( &self->parent ); mlt_properties_set_position( properties, "in", in ); mlt_properties_set_position( properties, "out", out ); } @@ -148,61 +148,61 @@ void mlt_filter_set_in_and_out( mlt_filter this, mlt_position in, mlt_position o /** Return the track that this filter is operating on. * * \public \memberof mlt_filter_s - * \param this a filter + * \param self a filter * \return true on error */ -int mlt_filter_get_track( mlt_filter this ) +int mlt_filter_get_track( mlt_filter self ) { - mlt_properties properties = MLT_SERVICE_PROPERTIES( &this->parent ); + mlt_properties properties = MLT_SERVICE_PROPERTIES( &self->parent ); return mlt_properties_get_int( properties, "track" ); } /** Get the in point. * * \public \memberof mlt_filter_s - * \param this a filter + * \param self a filter * \return the start time for the filter relative to the producer */ -mlt_position mlt_filter_get_in( mlt_filter this ) +mlt_position mlt_filter_get_in( mlt_filter self ) { - mlt_properties properties = MLT_SERVICE_PROPERTIES( &this->parent ); + mlt_properties properties = MLT_SERVICE_PROPERTIES( &self->parent ); return mlt_properties_get_position( properties, "in" ); } /** Get the out point. * * \public \memberof mlt_filter_s - * \param this a filter + * \param self a filter * \return the ending time for the filter relative to the producer */ -mlt_position mlt_filter_get_out( mlt_filter this ) +mlt_position mlt_filter_get_out( mlt_filter self ) { - mlt_properties properties = MLT_SERVICE_PROPERTIES( &this->parent ); + mlt_properties properties = MLT_SERVICE_PROPERTIES( &self->parent ); return mlt_properties_get_position( properties, "out" ); } /** Process the frame. * * \public \memberof mlt_filter_s - * \param this a filter + * \param self a filter * \param frame a frame * \return a frame */ -mlt_frame mlt_filter_process( mlt_filter this, mlt_frame frame ) +mlt_frame mlt_filter_process( mlt_filter self, mlt_frame frame ) { - int disable = mlt_properties_get_int( MLT_FILTER_PROPERTIES( this ), "disable" ); - if ( disable || this->process == NULL ) + int disable = mlt_properties_get_int( MLT_FILTER_PROPERTIES( self ), "disable" ); + if ( disable || self->process == NULL ) return frame; else - return this->process( this, frame ); + return self->process( self, frame ); } /** Get a frame from this filter. @@ -217,15 +217,15 @@ mlt_frame mlt_filter_process( mlt_filter this, mlt_frame frame ) static int filter_get_frame( mlt_service service, mlt_frame_ptr frame, int index ) { - mlt_filter this = service->child; + mlt_filter self = service->child; // Get coords in/out/track - int track = mlt_filter_get_track( this ); - int in = mlt_filter_get_in( this ); - int out = mlt_filter_get_out( this ); + int track = mlt_filter_get_track( self ); + int in = mlt_filter_get_in( self ); + int out = mlt_filter_get_out( self ); // Get the producer this is connected to - mlt_service producer = mlt_service_producer( &this->parent ); + mlt_service producer = mlt_service_producer( &self->parent ); // If the frame request is for this filters track, we need to process it if ( index == track || track == -1 ) @@ -235,7 +235,7 @@ static int filter_get_frame( mlt_service service, mlt_frame_ptr frame, int index { mlt_position position = mlt_frame_get_position( *frame ); if ( position >= in && ( out == 0 || position <= out ) ) - *frame = mlt_filter_process( this, *frame ); + *frame = mlt_filter_process( self, *frame ); return 0; } else @@ -253,23 +253,23 @@ static int filter_get_frame( mlt_service service, mlt_frame_ptr frame, int index /** Close and destroy the filter. * * \public \memberof mlt_filter_s - * \param this a filter + * \param self a filter */ -void mlt_filter_close( mlt_filter this ) +void mlt_filter_close( mlt_filter self ) { - if ( this != NULL && mlt_properties_dec_ref( MLT_FILTER_PROPERTIES( this ) ) <= 0 ) + if ( self != NULL && mlt_properties_dec_ref( MLT_FILTER_PROPERTIES( self ) ) <= 0 ) { - if ( this->close != NULL ) + if ( self->close != NULL ) { - this->close( this ); + self->close( self ); } else { - this->parent.close = NULL; - mlt_service_close( &this->parent ); + self->parent.close = NULL; + mlt_service_close( &self->parent ); } - free( this ); + free( self ); } } diff --git a/src/framework/mlt_frame.c b/src/framework/mlt_frame.c index d048513e..fd28fac9 100644 --- a/src/framework/mlt_frame.c +++ b/src/framework/mlt_frame.c @@ -41,15 +41,15 @@ mlt_frame mlt_frame_init( mlt_service service ) { // Allocate a frame - mlt_frame this = calloc( sizeof( struct mlt_frame_s ), 1 ); + mlt_frame self = calloc( sizeof( struct mlt_frame_s ), 1 ); - if ( this != NULL ) + if ( self != NULL ) { mlt_profile profile = mlt_service_profile( service ); // Initialise the properties - mlt_properties properties = &this->parent; - mlt_properties_init( properties, this ); + mlt_properties properties = &self->parent; + mlt_properties_init( properties, self ); // Set default properties on the frame mlt_properties_set_position( properties, "_position", 0.0 ); @@ -63,236 +63,236 @@ mlt_frame mlt_frame_init( mlt_service service ) mlt_properties_set_data( properties, "alpha", NULL, 0, NULL, NULL ); // Construct stacks for frames and methods - this->stack_image = mlt_deque_init( ); - this->stack_audio = mlt_deque_init( ); - this->stack_service = mlt_deque_init( ); + self->stack_image = mlt_deque_init( ); + self->stack_audio = mlt_deque_init( ); + self->stack_service = mlt_deque_init( ); } - return this; + return self; } /** Get a frame's properties. * * \public \memberof mlt_frame_s - * \param this a frame + * \param self a frame * \return the frame's properties or NULL if an invalid frame is supplied */ -mlt_properties mlt_frame_properties( mlt_frame this ) +mlt_properties mlt_frame_properties( mlt_frame self ) { - return this != NULL ? &this->parent : NULL; + return self != NULL ? &self->parent : NULL; } /** Determine if the frame will produce a test card image. * * \public \memberof mlt_frame_s - * \param this a frame + * \param self a frame * \return true (non-zero) if this will produce from a test card */ -int mlt_frame_is_test_card( mlt_frame this ) +int mlt_frame_is_test_card( mlt_frame self ) { - return mlt_deque_count( this->stack_image ) == 0 || mlt_properties_get_int( MLT_FRAME_PROPERTIES( this ), "test_image" ); + return mlt_deque_count( self->stack_image ) == 0 || mlt_properties_get_int( MLT_FRAME_PROPERTIES( self ), "test_image" ); } /** Determine if the frame will produce audio from a test card. * * \public \memberof mlt_frame_s - * \param this a frame + * \param self a frame * \return true (non-zero) if this will produce from a test card */ -int mlt_frame_is_test_audio( mlt_frame this ) +int mlt_frame_is_test_audio( mlt_frame self ) { - return mlt_deque_count( this->stack_audio ) == 0 || mlt_properties_get_int( MLT_FRAME_PROPERTIES( this ), "test_audio" ); + return mlt_deque_count( self->stack_audio ) == 0 || mlt_properties_get_int( MLT_FRAME_PROPERTIES( self ), "test_audio" ); } /** Get the sample aspect ratio of the frame. * * \public \memberof mlt_frame_s - * \param this a frame + * \param self a frame * \return the aspect ratio */ -double mlt_frame_get_aspect_ratio( mlt_frame this ) +double mlt_frame_get_aspect_ratio( mlt_frame self ) { - return mlt_properties_get_double( MLT_FRAME_PROPERTIES( this ), "aspect_ratio" ); + return mlt_properties_get_double( MLT_FRAME_PROPERTIES( self ), "aspect_ratio" ); } /** Set the sample aspect ratio of the frame. * * \public \memberof mlt_frame_s - * \param this a frame + * \param self a frame * \param value the new image sample aspect ratio * \return true if error */ -int mlt_frame_set_aspect_ratio( mlt_frame this, double value ) +int mlt_frame_set_aspect_ratio( mlt_frame self, double value ) { - return mlt_properties_set_double( MLT_FRAME_PROPERTIES( this ), "aspect_ratio", value ); + return mlt_properties_set_double( MLT_FRAME_PROPERTIES( self ), "aspect_ratio", value ); } /** Get the time position of this frame. * * \public \memberof mlt_frame_s - * \param this a frame + * \param self a frame * \return the position */ -mlt_position mlt_frame_get_position( mlt_frame this ) +mlt_position mlt_frame_get_position( mlt_frame self ) { - int pos = mlt_properties_get_position( MLT_FRAME_PROPERTIES( this ), "_position" ); + int pos = mlt_properties_get_position( MLT_FRAME_PROPERTIES( self ), "_position" ); return pos < 0 ? 0 : pos; } /** Set the time position of this frame. * * \public \memberof mlt_frame_s - * \param this a frame + * \param self a frame * \param value the position * \return true if error */ -int mlt_frame_set_position( mlt_frame this, mlt_position value ) +int mlt_frame_set_position( mlt_frame self, mlt_position value ) { - return mlt_properties_set_position( MLT_FRAME_PROPERTIES( this ), "_position", value ); + return mlt_properties_set_position( MLT_FRAME_PROPERTIES( self ), "_position", value ); } /** Stack a get_image callback. * * \public \memberof mlt_frame_s - * \param this a frame + * \param self a frame * \param the get_image callback * \return true if error */ -int mlt_frame_push_get_image( mlt_frame this, mlt_get_image get_image ) +int mlt_frame_push_get_image( mlt_frame self, mlt_get_image get_image ) { - return mlt_deque_push_back( this->stack_image, get_image ); + return mlt_deque_push_back( self->stack_image, get_image ); } /** Pop a get_image callback. * * \public \memberof mlt_frame_s - * \param this a frame + * \param self a frame * \return the get_image callback */ -mlt_get_image mlt_frame_pop_get_image( mlt_frame this ) +mlt_get_image mlt_frame_pop_get_image( mlt_frame self ) { - return mlt_deque_pop_back( this->stack_image ); + return mlt_deque_pop_back( self->stack_image ); } /** Push a frame. * * \public \memberof mlt_frame_s - * \param this a frame - * \param that the frame to push onto \p this + * \param self a frame + * \param that the frame to push onto \p self * \return true if error */ -int mlt_frame_push_frame( mlt_frame this, mlt_frame that ) +int mlt_frame_push_frame( mlt_frame self, mlt_frame that ) { - return mlt_deque_push_back( this->stack_image, that ); + return mlt_deque_push_back( self->stack_image, that ); } /** Pop a frame. * * \public \memberof mlt_frame_s - * \param this a frame + * \param self a frame * \return a frame that was previously pushed */ -mlt_frame mlt_frame_pop_frame( mlt_frame this ) +mlt_frame mlt_frame_pop_frame( mlt_frame self ) { - return mlt_deque_pop_back( this->stack_image ); + return mlt_deque_pop_back( self->stack_image ); } /** Push a service. * * \public \memberof mlt_frame_s - * \param this a frame + * \param self a frame * \param that an opaque pointer * \return true if error */ -int mlt_frame_push_service( mlt_frame this, void *that ) +int mlt_frame_push_service( mlt_frame self, void *that ) { - return mlt_deque_push_back( this->stack_image, that ); + return mlt_deque_push_back( self->stack_image, that ); } /** Pop a service. * * \public \memberof mlt_frame_s - * \param this a frame + * \param self a frame * \return an opaque pointer to something previously pushed */ -void *mlt_frame_pop_service( mlt_frame this ) +void *mlt_frame_pop_service( mlt_frame self ) { - return mlt_deque_pop_back( this->stack_image ); + return mlt_deque_pop_back( self->stack_image ); } /** Push a number. * * \public \memberof mlt_frame_s - * \param this a frame + * \param self a frame * \param that an integer * \return true if error */ -int mlt_frame_push_service_int( mlt_frame this, int that ) +int mlt_frame_push_service_int( mlt_frame self, int that ) { - return mlt_deque_push_back_int( this->stack_image, that ); + return mlt_deque_push_back_int( self->stack_image, that ); } /** Pop a number. * * \public \memberof mlt_frame_s - * \param this a frame + * \param self a frame * \return an integer that was previously pushed */ -int mlt_frame_pop_service_int( mlt_frame this ) +int mlt_frame_pop_service_int( mlt_frame self ) { - return mlt_deque_pop_back_int( this->stack_image ); + return mlt_deque_pop_back_int( self->stack_image ); } /** Push an audio item on the stack. * * \public \memberof mlt_frame_s - * \param this a frame + * \param self a frame * \param that an opaque pointer * \return true if error */ -int mlt_frame_push_audio( mlt_frame this, void *that ) +int mlt_frame_push_audio( mlt_frame self, void *that ) { - return mlt_deque_push_back( this->stack_audio, that ); + return mlt_deque_push_back( self->stack_audio, that ); } /** Pop an audio item from the stack * * \public \memberof mlt_frame_s - * \param this a frame + * \param self a frame * \return an opaque pointer to something that was pushed onto the frame's audio stack */ -void *mlt_frame_pop_audio( mlt_frame this ) +void *mlt_frame_pop_audio( mlt_frame self ) { - return mlt_deque_pop_back( this->stack_audio ); + return mlt_deque_pop_back( self->stack_audio ); } /** Return the service stack * * \public \memberof mlt_frame_s - * \param this a frame + * \param self a frame * \return the service stack */ -mlt_deque mlt_frame_service_stack( mlt_frame this ) +mlt_deque mlt_frame_service_stack( mlt_frame self ) { - return this->stack_service; + return self->stack_service; } /** Replace image stack with the information provided. @@ -314,24 +314,24 @@ mlt_deque mlt_frame_service_stack( mlt_frame this ) * and the upper tracks should simply not be invited to stack... * * \public \memberof mlt_frame_s - * \param this a frame + * \param self a frame * \param image a new image * \param format the image format * \param width the width of the new image * \param height the height of the new image */ -void mlt_frame_replace_image( mlt_frame this, uint8_t *image, mlt_image_format format, int width, int height ) +void mlt_frame_replace_image( mlt_frame self, uint8_t *image, mlt_image_format format, int width, int height ) { // Remove all items from the stack - while( mlt_deque_pop_back( this->stack_image ) ) ; + while( mlt_deque_pop_back( self->stack_image ) ) ; // Update the information - mlt_properties_set_data( MLT_FRAME_PROPERTIES( this ), "image", image, 0, NULL, NULL ); - mlt_properties_set_int( MLT_FRAME_PROPERTIES( this ), "width", width ); - mlt_properties_set_int( MLT_FRAME_PROPERTIES( this ), "height", height ); - mlt_properties_set_int( MLT_FRAME_PROPERTIES( this ), "format", format ); - this->get_alpha_mask = NULL; + mlt_properties_set_data( MLT_FRAME_PROPERTIES( self ), "image", image, 0, NULL, NULL ); + mlt_properties_set_int( MLT_FRAME_PROPERTIES( self ), "width", width ); + mlt_properties_set_int( MLT_FRAME_PROPERTIES( self ), "height", height ); + mlt_properties_set_int( MLT_FRAME_PROPERTIES( self ), "format", format ); + self->get_alpha_mask = NULL; } /** Get the short name for an image format. @@ -365,7 +365,7 @@ const char * mlt_image_format_name( mlt_image_format format ) * buffer, but you should always supply the desired image format. * * \public \memberof mlt_frame_s - * \param this a frame + * \param self a frame * \param[out] buffer an image buffer * \param[in,out] format the image format * \param[in,out] width the horizontal size in pixels @@ -375,10 +375,10 @@ const char * mlt_image_format_name( mlt_image_format format ) * \todo Better describe the width and height as inputs. */ -int mlt_frame_get_image( mlt_frame this, uint8_t **buffer, mlt_image_format *format, int *width, int *height, int writable ) +int mlt_frame_get_image( mlt_frame self, uint8_t **buffer, mlt_image_format *format, int *width, int *height, int writable ) { - mlt_properties properties = MLT_FRAME_PROPERTIES( this ); - mlt_get_image get_image = mlt_frame_pop_get_image( this ); + mlt_properties properties = MLT_FRAME_PROPERTIES( self ); + mlt_get_image get_image = mlt_frame_pop_get_image( self ); mlt_producer producer = mlt_properties_get_data( properties, "test_card_producer", NULL ); mlt_image_format requested_format = *format; int error = 0; @@ -386,19 +386,19 @@ int mlt_frame_get_image( mlt_frame this, uint8_t **buffer, mlt_image_format *for if ( get_image ) { mlt_properties_set_int( properties, "image_count", mlt_properties_get_int( properties, "image_count" ) - 1 ); - error = get_image( this, buffer, format, width, height, writable ); + error = get_image( self, buffer, format, width, height, writable ); if ( !error && *buffer ) { mlt_properties_set_int( properties, "width", *width ); mlt_properties_set_int( properties, "height", *height ); - if ( this->convert_image && *buffer ) - this->convert_image( this, buffer, format, requested_format ); + if ( self->convert_image && *buffer ) + self->convert_image( self, buffer, format, requested_format ); mlt_properties_set_int( properties, "format", *format ); } else { // Cause the image to be loaded from test card or fallback (white) below. - mlt_frame_get_image( this, buffer, format, width, height, writable ); + mlt_frame_get_image( self, buffer, format, width, height, writable ); } } else if ( mlt_properties_get_data( properties, "image", NULL ) ) @@ -407,9 +407,9 @@ int mlt_frame_get_image( mlt_frame this, uint8_t **buffer, mlt_image_format *for *buffer = mlt_properties_get_data( properties, "image", NULL ); *width = mlt_properties_get_int( properties, "width" ); *height = mlt_properties_get_int( properties, "height" ); - if ( this->convert_image && *buffer ) + if ( self->convert_image && *buffer ) { - this->convert_image( this, buffer, format, requested_format ); + self->convert_image( self, buffer, format, requested_format ); mlt_properties_set_int( properties, "format", *format ); } } @@ -433,7 +433,7 @@ int mlt_frame_get_image( mlt_frame this, uint8_t **buffer, mlt_image_format *for else { mlt_properties_set_data( properties, "test_card_producer", NULL, 0, NULL, NULL ); - mlt_frame_get_image( this, buffer, format, width, height, writable ); + mlt_frame_get_image( self, buffer, format, width, height, writable ); } } else @@ -502,25 +502,25 @@ int mlt_frame_get_image( mlt_frame this, uint8_t **buffer, mlt_image_format *for /** Get the alpha channel associated to the frame. * * \public \memberof mlt_frame_s - * \param this a frame + * \param self a frame * \return the alpha channel */ -uint8_t *mlt_frame_get_alpha_mask( mlt_frame this ) +uint8_t *mlt_frame_get_alpha_mask( mlt_frame self ) { uint8_t *alpha = NULL; - if ( this != NULL ) + if ( self != NULL ) { - if ( this->get_alpha_mask != NULL ) - alpha = this->get_alpha_mask( this ); + if ( self->get_alpha_mask != NULL ) + alpha = self->get_alpha_mask( self ); if ( alpha == NULL ) - alpha = mlt_properties_get_data( &this->parent, "alpha", NULL ); + alpha = mlt_properties_get_data( &self->parent, "alpha", NULL ); if ( alpha == NULL ) { - int size = mlt_properties_get_int( &this->parent, "width" ) * mlt_properties_get_int( &this->parent, "height" ); + int size = mlt_properties_get_int( &self->parent, "width" ) * mlt_properties_get_int( &self->parent, "height" ); alpha = mlt_pool_alloc( size ); memset( alpha, 255, size ); - mlt_properties_set_data( &this->parent, "alpha", alpha, size, mlt_pool_release, NULL ); + mlt_properties_set_data( &self->parent, "alpha", alpha, size, mlt_pool_release, NULL ); } } return alpha; @@ -530,7 +530,7 @@ uint8_t *mlt_frame_get_alpha_mask( mlt_frame this ) * * You do not need to deallocate the returned string. * \public \memberof mlt_frame_s - * \param this a frame + * \param self a frame * \param format an image format enum * \return a string for the name of the image format */ @@ -559,7 +559,7 @@ const char * mlt_audio_format_name( mlt_audio_format format ) * You should use the \p mlt_sample_calculator to determine the number of samples you want. * * \public \memberof mlt_frame_s - * \param this a frame + * \param self a frame * \param[out] buffer an audio buffer * \param[in,out] format the audio format * \param[in,out] frequency the sample rate @@ -568,22 +568,22 @@ const char * mlt_audio_format_name( mlt_audio_format format ) * \return true if error */ -int mlt_frame_get_audio( mlt_frame this, void **buffer, mlt_audio_format *format, int *frequency, int *channels, int *samples ) +int mlt_frame_get_audio( mlt_frame self, void **buffer, mlt_audio_format *format, int *frequency, int *channels, int *samples ) { - mlt_get_audio get_audio = mlt_frame_pop_audio( this ); - mlt_properties properties = MLT_FRAME_PROPERTIES( this ); + mlt_get_audio get_audio = mlt_frame_pop_audio( self ); + mlt_properties properties = MLT_FRAME_PROPERTIES( self ); int hide = mlt_properties_get_int( properties, "test_audio" ); mlt_audio_format requested_format = *format; if ( hide == 0 && get_audio != NULL ) { - get_audio( this, buffer, format, frequency, channels, samples ); + get_audio( self, buffer, format, frequency, channels, samples ); mlt_properties_set_int( properties, "audio_frequency", *frequency ); mlt_properties_set_int( properties, "audio_channels", *channels ); mlt_properties_set_int( properties, "audio_samples", *samples ); mlt_properties_set_int( properties, "audio_format", *format ); - if ( this->convert_audio ) - this->convert_audio( this, buffer, format, requested_format ); + if ( self->convert_audio ) + self->convert_audio( self, buffer, format, requested_format ); } else if ( mlt_properties_get_data( properties, "audio", NULL ) ) { @@ -592,8 +592,8 @@ int mlt_frame_get_audio( mlt_frame this, void **buffer, mlt_audio_format *format *frequency = mlt_properties_get_int( properties, "audio_frequency" ); *channels = mlt_properties_get_int( properties, "audio_channels" ); *samples = mlt_properties_get_int( properties, "audio_samples" ); - if ( this->convert_audio ) - this->convert_audio( this, buffer, format, requested_format ); + if ( self->convert_audio ) + self->convert_audio( self, buffer, format, requested_format ); } else { @@ -659,7 +659,7 @@ int mlt_frame_get_audio( mlt_frame this, void **buffer, mlt_audio_format *format /** Set the audio on a frame. * * \public \memberof mlt_frame_s - * \param this a frame + * \param self a frame * \param buffer an buffer containing audio samples * \param format the format of the audio in the \p buffer * \param size the total size of the buffer (optional) @@ -667,10 +667,10 @@ int mlt_frame_get_audio( mlt_frame this, void **buffer, mlt_audio_format *format * \return true if error */ -int mlt_frame_set_audio( mlt_frame this, void *buffer, mlt_audio_format format, int size, mlt_destructor destructor ) +int mlt_frame_set_audio( mlt_frame self, void *buffer, mlt_audio_format format, int size, mlt_destructor destructor ) { - mlt_properties_set_int( MLT_FRAME_PROPERTIES( this ), "audio_format", format ); - return mlt_properties_set_data( MLT_FRAME_PROPERTIES( this ), "audio", buffer, size, destructor, NULL ); + mlt_properties_set_int( MLT_FRAME_PROPERTIES( self ), "audio_format", format ); + return mlt_properties_set_data( MLT_FRAME_PROPERTIES( self ), "audio", buffer, size, destructor, NULL ); } /** Get audio on a frame as a waveform image. @@ -681,32 +681,32 @@ int mlt_frame_set_audio( mlt_frame this, void *buffer, mlt_audio_format format, * value with \p mlt_pool_release. * * \public \memberof mlt_frame_s - * \param this a frame + * \param self a frame * \param w the width of the image * \param h the height of the image to create * \return a pointer to a new bitmap */ -unsigned char *mlt_frame_get_waveform( mlt_frame this, int w, int h ) +unsigned char *mlt_frame_get_waveform( mlt_frame self, int w, int h ) { int16_t *pcm = NULL; - mlt_properties properties = MLT_FRAME_PROPERTIES( this ); + mlt_properties properties = MLT_FRAME_PROPERTIES( self ); mlt_audio_format format = mlt_audio_s16; int frequency = 16000; int channels = 2; - mlt_producer producer = mlt_frame_get_original_producer( this ); + mlt_producer producer = mlt_frame_get_original_producer( self ); double fps = mlt_producer_get_fps( mlt_producer_cut_parent( producer ) ); - int samples = mlt_sample_calculator( fps, frequency, mlt_frame_get_position( this ) ); + int samples = mlt_sample_calculator( fps, frequency, mlt_frame_get_position( self ) ); // Increase audio resolution proportional to requested image size while ( samples < w ) { frequency += 16000; - samples = mlt_sample_calculator( fps, frequency, mlt_frame_get_position( this ) ); + samples = mlt_sample_calculator( fps, frequency, mlt_frame_get_position( self ) ); } // Get the pcm data - mlt_frame_get_audio( this, (void**)&pcm, &format, &frequency, &channels, &samples ); + mlt_frame_get_audio( self, (void**)&pcm, &format, &frequency, &channels, &samples ); // Make an 8-bit buffer large enough to hold rendering int size = w * h; @@ -750,40 +750,40 @@ unsigned char *mlt_frame_get_waveform( mlt_frame this, int w, int h ) return bitmap; } -/** Get the end service that produced this frame. +/** Get the end service that produced self frame. * * This fetches the first producer of the frame and not any producers that * encapsulate it. * * \public \memberof mlt_frame_s - * \param this a frame + * \param self a frame * \return a producer */ -mlt_producer mlt_frame_get_original_producer( mlt_frame this ) +mlt_producer mlt_frame_get_original_producer( mlt_frame self ) { - if ( this != NULL ) - return mlt_properties_get_data( MLT_FRAME_PROPERTIES( this ), "_producer", NULL ); + if ( self != NULL ) + return mlt_properties_get_data( MLT_FRAME_PROPERTIES( self ), "_producer", NULL ); return NULL; } /** Destroy the frame. * * \public \memberof mlt_frame_s - * \param this a frame + * \param self a frame */ -void mlt_frame_close( mlt_frame this ) +void mlt_frame_close( mlt_frame self ) { - if ( this != NULL && mlt_properties_dec_ref( MLT_FRAME_PROPERTIES( this ) ) <= 0 ) + if ( self != NULL && mlt_properties_dec_ref( MLT_FRAME_PROPERTIES( self ) ) <= 0 ) { - mlt_deque_close( this->stack_image ); - mlt_deque_close( this->stack_audio ); - while( mlt_deque_peek_back( this->stack_service ) ) - mlt_service_close( mlt_deque_pop_back( this->stack_service ) ); - mlt_deque_close( this->stack_service ); - mlt_properties_close( &this->parent ); - free( this ); + mlt_deque_close( self->stack_image ); + mlt_deque_close( self->stack_audio ); + while( mlt_deque_peek_back( self->stack_service ) ) + mlt_service_close( mlt_deque_pop_back( self->stack_service ) ); + mlt_deque_close( self->stack_service ); + mlt_properties_close( &self->parent ); + free( self ); } } diff --git a/src/framework/mlt_geometry.c b/src/framework/mlt_geometry.c index a764680d..f1398be0 100644 --- a/src/framework/mlt_geometry.c +++ b/src/framework/mlt_geometry.c @@ -47,23 +47,23 @@ geometry_s, *geometry; // Create a new geometry structure mlt_geometry mlt_geometry_init( ) { - mlt_geometry this = calloc( 1, sizeof( struct mlt_geometry_s ) ); - if ( this != NULL ) + mlt_geometry self = calloc( 1, sizeof( struct mlt_geometry_s ) ); + if ( self != NULL ) { - this->local = calloc( 1, sizeof( geometry_s ) ); - if ( this->local != NULL ) + self->local = calloc( 1, sizeof( geometry_s ) ); + if ( self->local != NULL ) { - geometry g = this->local; + geometry g = self->local; g->nw = 720; g->nh = 576; } else { - free( this ); - this = NULL; + free( self ); + self = NULL; } } - return this; + return self; } /** A linear step @@ -75,9 +75,9 @@ static inline double linearstep( double start, double end, double position, int return start + position * o; } -static void mlt_geometry_virtual_refresh( mlt_geometry this ) +static void mlt_geometry_virtual_refresh( mlt_geometry self ) { - geometry g = this->local; + geometry g = self->local; // Parse of all items to ensure unspecified keys are calculated correctly if ( g->item != NULL ) @@ -150,9 +150,9 @@ static void mlt_geometry_virtual_refresh( mlt_geometry this ) } } -static int mlt_geometry_drop( mlt_geometry this, geometry_item item ) +static int mlt_geometry_drop( mlt_geometry self, geometry_item item ) { - geometry g = this->local; + geometry g = self->local; if ( item == g->item ) { @@ -188,19 +188,19 @@ static int mlt_geometry_drop( mlt_geometry this, geometry_item item ) return 0; } -static void mlt_geometry_clean( mlt_geometry this ) +static void mlt_geometry_clean( mlt_geometry self ) { - geometry g = this->local; + geometry g = self->local; free( g->data ); g->data = NULL; while( g->item ) - mlt_geometry_drop( this, g->item ); + mlt_geometry_drop( self, g->item ); } // Parse the geometry specification for a given length and normalised width/height (-1 for default) // data is constructed as: [frame=]X,Y:WxH[:mix][;[frame=]X,Y:WxH[:mix]]* // and X, Y, W and H can have trailing % chars to indicate percentage of normalised size -int mlt_geometry_parse( mlt_geometry this, char *data, int length, int nw, int nh ) +int mlt_geometry_parse( mlt_geometry self, char *data, int length, int nw, int nh ) { int i = 0; @@ -208,10 +208,10 @@ int mlt_geometry_parse( mlt_geometry this, char *data, int length, int nw, int n mlt_tokeniser tokens = mlt_tokeniser_init( ); // Get the local/private structure - geometry g = this->local; + geometry g = self->local; // Clean the existing geometry - mlt_geometry_clean( this ); + mlt_geometry_clean( self ); // Update the info on the data if ( length != -1 ) @@ -237,10 +237,10 @@ int mlt_geometry_parse( mlt_geometry this, char *data, int length, int nw, int n memset( &item, 0, sizeof( struct mlt_geometry_item_s ) ); // Now parse the item - mlt_geometry_parse_item( this, &item, value ); + mlt_geometry_parse_item( self, &item, value ); // Now insert into place - mlt_geometry_insert( this, &item ); + mlt_geometry_insert( self, &item ); } // Remove the tokeniser @@ -251,42 +251,42 @@ int mlt_geometry_parse( mlt_geometry this, char *data, int length, int nw, int n } // Conditionally refresh in case of a change -int mlt_geometry_refresh( mlt_geometry this, char *data, int length, int nw, int nh ) +int mlt_geometry_refresh( mlt_geometry self, char *data, int length, int nw, int nh ) { - geometry g = this->local; + geometry g = self->local; int changed = ( length != -1 && length != g->length ); changed = changed || ( nw != -1 && nw != g->nw ); changed = changed || ( nh != -1 && nh != g->nh ); changed = changed || ( data != NULL && ( g->data == NULL || strcmp( data, g->data ) ) ); if ( changed ) - return mlt_geometry_parse( this, data, length, nw, nh ); + return mlt_geometry_parse( self, data, length, nw, nh ); return -1; } -int mlt_geometry_get_length( mlt_geometry this ) +int mlt_geometry_get_length( mlt_geometry self ) { // Get the local/private structure - geometry g = this->local; + geometry g = self->local; // return the length return g->length; } -void mlt_geometry_set_length( mlt_geometry this, int length ) +void mlt_geometry_set_length( mlt_geometry self, int length ) { // Get the local/private structure - geometry g = this->local; + geometry g = self->local; // set the length g->length = length; } -int mlt_geometry_parse_item( mlt_geometry this, mlt_geometry_item item, char *value ) +int mlt_geometry_parse_item( mlt_geometry self, mlt_geometry_item item, char *value ) { int ret = 0; // Get the local/private structure - geometry g = this->local; + geometry g = self->local; if ( value != NULL && strcmp( value, "" ) ) { @@ -309,9 +309,9 @@ int mlt_geometry_parse_item( mlt_geometry this, mlt_geometry_item item, char *va if ( item->frame < 0 ) item->frame += g->length; - // Obtain the current value at this position - this allows new + // Obtain the current value at this position - self allows new // frames to be created which don't specify all values - mlt_geometry_fetch( this, item, item->frame ); + mlt_geometry_fetch( self, item, item->frame ); // Special case - when an empty string is specified, all values are fixed // TODO: Check if this is logical - it's convenient, but it's also odd... @@ -382,10 +382,10 @@ int mlt_geometry_parse_item( mlt_geometry this, mlt_geometry_item item, char *va } // Fetch a geometry item for an absolute position -int mlt_geometry_fetch( mlt_geometry this, mlt_geometry_item item, float position ) +int mlt_geometry_fetch( mlt_geometry self, mlt_geometry_item item, float position ) { // Get the local geometry - geometry g = this->local; + geometry g = self->local; // Need to find the nearest key to the position specifed geometry_item key = g->item; @@ -446,15 +446,15 @@ int mlt_geometry_fetch( mlt_geometry this, mlt_geometry_item item, float positio } // Specify a geometry item at an absolute position -int mlt_geometry_insert( mlt_geometry this, mlt_geometry_item item ) +int mlt_geometry_insert( mlt_geometry self, mlt_geometry_item item ) { // Get the local/private geometry structure - geometry g = this->local; + geometry g = self->local; - // Create a new local item (this may be removed if a key already exists at this position) - geometry_item new = calloc( 1, sizeof( struct geometry_item_s ) ); - memcpy( &new->data, item, sizeof( struct mlt_geometry_item_s ) ); - new->data.key = 1; + // Create a new local item (this may be removed if a key already exists at self position) + geometry_item gi = calloc( 1, sizeof( struct geometry_item_s ) ); + memcpy( &gi->data, item, sizeof( struct mlt_geometry_item_s ) ); + gi->data.key = 1; // Determine if we need to insert or append to the list, or if it's a new list if ( g->item != NULL ) @@ -469,31 +469,31 @@ int mlt_geometry_insert( mlt_geometry this, mlt_geometry_item item ) if ( item->frame < place->data.frame ) { if ( place == g->item ) - g->item = new; + g->item = gi; if ( place->prev ) - place->prev->next = new; - new->next = place; - new->prev = place->prev; - place->prev = new; + place->prev->next = gi; + gi->next = place; + gi->prev = place->prev; + place->prev = gi; } else if ( item->frame > place->data.frame ) { if ( place->next ) - place->next->prev = new; - new->next = place->next; - new->prev = place; - place->next = new; + place->next->prev = gi; + gi->next = place->next; + gi->prev = place; + place->next = gi; } else { - memcpy( &place->data, &new->data, sizeof( struct mlt_geometry_item_s ) ); - free( new ); + memcpy( &place->data, &gi->data, sizeof( struct mlt_geometry_item_s ) ); + free( gi ); } } else { // Set the first item - g->item = new; + g->item = gi; // To ensure correct seeding, ensure all values are fixed g->item->data.f[0] = 1; @@ -504,19 +504,19 @@ int mlt_geometry_insert( mlt_geometry this, mlt_geometry_item item ) } // Refresh all geometries - mlt_geometry_virtual_refresh( this ); + mlt_geometry_virtual_refresh( self ); // TODO: Error checking return 0; } // Remove the key at the specified position -int mlt_geometry_remove( mlt_geometry this, int position ) +int mlt_geometry_remove( mlt_geometry self, int position ) { int ret = 1; // Get the local/private geometry structure - geometry g = this->local; + geometry g = self->local; // Get the first item geometry_item place = g->item; @@ -525,19 +525,19 @@ int mlt_geometry_remove( mlt_geometry this, int position ) place = place->next; if ( place != NULL && position == place->data.frame ) - ret = mlt_geometry_drop( this, place ); + ret = mlt_geometry_drop( self, place ); // Refresh all geometries - mlt_geometry_virtual_refresh( this ); + mlt_geometry_virtual_refresh( self ); return ret; } // Get the key at the position or the next following -int mlt_geometry_next_key( mlt_geometry this, mlt_geometry_item item, int position ) +int mlt_geometry_next_key( mlt_geometry self, mlt_geometry_item item, int position ) { // Get the local/private geometry structure - geometry g = this->local; + geometry g = self->local; // Get the first item geometry_item place = g->item; @@ -552,10 +552,10 @@ int mlt_geometry_next_key( mlt_geometry this, mlt_geometry_item item, int positi } // Get the key at the position or the previous key -int mlt_geometry_prev_key( mlt_geometry this, mlt_geometry_item item, int position ) +int mlt_geometry_prev_key( mlt_geometry self, mlt_geometry_item item, int position ) { // Get the local/private geometry structure - geometry g = this->local; + geometry g = self->local; // Get the first item geometry_item place = g->item; @@ -569,9 +569,9 @@ int mlt_geometry_prev_key( mlt_geometry this, mlt_geometry_item item, int positi return place == NULL; } -char *mlt_geometry_serialise_cut( mlt_geometry this, int in, int out ) +char *mlt_geometry_serialise_cut( mlt_geometry self, int in, int out ) { - geometry g = this->local; + geometry g = self->local; struct mlt_geometry_item_s item; char *ret = malloc( 1000 ); int used = 0; @@ -580,7 +580,7 @@ char *mlt_geometry_serialise_cut( mlt_geometry this, int in, int out ) if ( in == -1 ) in = 0; if ( out == -1 ) - out = mlt_geometry_get_length( this ); + out = mlt_geometry_get_length( self ); if ( ret != NULL ) { @@ -597,7 +597,7 @@ char *mlt_geometry_serialise_cut( mlt_geometry this, int in, int out ) // If it's the first frame, then it's not necessarily a key if ( item.frame == in ) { - if ( mlt_geometry_fetch( this, &item, item.frame ) ) + if ( mlt_geometry_fetch( self, &item, item.frame ) ) break; // If the first key is larger than the current position @@ -618,12 +618,12 @@ 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_next_key( this, &item, item.frame ) ) + if ( mlt_geometry_next_key( self, &item, item.frame ) ) break; // Special case - crop at the out point if ( item.frame > out ) - mlt_geometry_fetch( this, &item, out ); + mlt_geometry_fetch( self, &item, out ); } // We've handled the last key else @@ -673,10 +673,10 @@ char *mlt_geometry_serialise_cut( mlt_geometry this, int in, int out ) } // Serialise the current geometry -char *mlt_geometry_serialise( mlt_geometry this ) +char *mlt_geometry_serialise( mlt_geometry self ) { - geometry g = this->local; - char *ret = mlt_geometry_serialise_cut( this, 0, g->length ); + geometry g = self->local; + char *ret = mlt_geometry_serialise_cut( self, 0, g->length ); if ( ret ) { free( g->data ); @@ -686,13 +686,13 @@ char *mlt_geometry_serialise( mlt_geometry this ) } // Close the geometry -void mlt_geometry_close( mlt_geometry this ) +void mlt_geometry_close( mlt_geometry self ) { - if ( this != NULL ) + if ( self != NULL ) { - mlt_geometry_clean( this ); - free( this->local ); - free( this ); + mlt_geometry_clean( self ); + free( self->local ); + free( self ); } } diff --git a/src/framework/mlt_multitrack.c b/src/framework/mlt_multitrack.c index 8bc2e403..389d72ec 100644 --- a/src/framework/mlt_multitrack.c +++ b/src/framework/mlt_multitrack.c @@ -43,16 +43,16 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i mlt_multitrack mlt_multitrack_init( ) { // Allocate the multitrack object - mlt_multitrack this = calloc( sizeof( struct mlt_multitrack_s ), 1 ); + mlt_multitrack self = calloc( sizeof( struct mlt_multitrack_s ), 1 ); - if ( this != NULL ) + if ( self != NULL ) { - mlt_producer producer = &this->parent; - if ( mlt_producer_init( producer, this ) == 0 ) + mlt_producer producer = &self->parent; + if ( mlt_producer_init( producer, self ) == 0 ) { - mlt_properties properties = MLT_MULTITRACK_PROPERTIES( this ); + mlt_properties properties = MLT_MULTITRACK_PROPERTIES( self ); producer->get_frame = producer_get_frame; - mlt_properties_set_data( properties, "multitrack", this, 0, NULL, NULL ); + mlt_properties_set_data( properties, "multitrack", self, 0, NULL, NULL ); mlt_properties_set( properties, "log_id", "multitrack" ); mlt_properties_set( properties, "resource", "" ); mlt_properties_set_int( properties, "in", 0 ); @@ -62,81 +62,81 @@ mlt_multitrack mlt_multitrack_init( ) } else { - free( this ); - this = NULL; + free( self ); + self = NULL; } } - return this; + return self; } /** Get the producer associated to this multitrack. * * \public \memberof mlt_multitrack_s - * \param this a multitrack + * \param self a multitrack * \return the producer object * \see MLT_MULTITRACK_PRODUCER */ -mlt_producer mlt_multitrack_producer( mlt_multitrack this ) +mlt_producer mlt_multitrack_producer( mlt_multitrack self ) { - return this != NULL ? &this->parent : NULL; + return self != NULL ? &self->parent : NULL; } /** Get the service associated this multitrack. * * \public \memberof mlt_multitrack_s - * \param this a multitrack + * \param self a multitrack * \return the service object * \see MLT_MULTITRACK_SERVICE */ -mlt_service mlt_multitrack_service( mlt_multitrack this ) +mlt_service mlt_multitrack_service( mlt_multitrack self ) { - return MLT_MULTITRACK_SERVICE( this ); + return MLT_MULTITRACK_SERVICE( self ); } /** Get the properties associated this multitrack. * * \public \memberof mlt_multitrack_s - * \param this a multitrack + * \param self a multitrack * \return the multitrack's property list * \see MLT_MULTITRACK_PROPERTIES */ -mlt_properties mlt_multitrack_properties( mlt_multitrack this ) +mlt_properties mlt_multitrack_properties( mlt_multitrack self ) { - return MLT_MULTITRACK_PROPERTIES( this ); + return MLT_MULTITRACK_PROPERTIES( self ); } /** Initialize position related information. * * \public \memberof mlt_multitrack_s - * \param this a multitrack + * \param self a multitrack */ -void mlt_multitrack_refresh( mlt_multitrack this ) +void mlt_multitrack_refresh( mlt_multitrack self ) { int i = 0; // Obtain the properties of this multitrack - mlt_properties properties = MLT_MULTITRACK_PROPERTIES( this ); + mlt_properties properties = MLT_MULTITRACK_PROPERTIES( self ); // We need to ensure that the multitrack reports the longest track as its length mlt_position length = 0; // Obtain stats on all connected services - for ( i = 0; i < this->count; i ++ ) + for ( i = 0; i < self->count; i ++ ) { // Get the producer from this index - mlt_track track = this->list[ i ]; + mlt_track track = self->list[ i ]; mlt_producer producer = track->producer; // If it's allocated then, update our stats if ( producer != NULL ) { // If we have more than 1 track, we must be in continue mode - if ( this->count > 1 ) + if ( self->count > 1 ) mlt_properties_set( MLT_PRODUCER_PROPERTIES( producer ), "eof", "continue" ); // Determine the longest length @@ -156,12 +156,12 @@ void mlt_multitrack_refresh( mlt_multitrack this ) * * \private \memberof mlt_multitrack_s * \param producer a producer - * \param this a multitrack + * \param self a multitrack */ -static void mlt_multitrack_listener( mlt_producer producer, mlt_multitrack this ) +static void mlt_multitrack_listener( mlt_producer producer, mlt_multitrack self ) { - mlt_multitrack_refresh( this ); + mlt_multitrack_refresh( self ); } /** Connect a producer to a given track. @@ -170,52 +170,52 @@ static void mlt_multitrack_listener( mlt_producer producer, mlt_multitrack this * of playlist in clip point determination below. * * \public \memberof mlt_multitrack_s - * \param this a multitrack + * \param self a multitrack * \param producer the producer to connect to the multitrack producer * \param track the 0-based index of the track on which to connect the multitrack * \return true on error */ -int mlt_multitrack_connect( mlt_multitrack this, mlt_producer producer, int track ) +int mlt_multitrack_connect( mlt_multitrack self, mlt_producer producer, int track ) { // Connect to the producer to ourselves at the specified track - int result = mlt_service_connect_producer( MLT_MULTITRACK_SERVICE( this ), MLT_PRODUCER_SERVICE( producer ), track ); + int result = mlt_service_connect_producer( MLT_MULTITRACK_SERVICE( self ), MLT_PRODUCER_SERVICE( producer ), track ); if ( result == 0 ) { // Resize the producer list if need be - if ( track >= this->size ) + if ( track >= self->size ) { int i; - this->list = realloc( this->list, ( track + 10 ) * sizeof( mlt_track ) ); - for ( i = this->size; i < track + 10; i ++ ) - this->list[ i ] = NULL; - this->size = track + 10; + self->list = realloc( self->list, ( track + 10 ) * sizeof( mlt_track ) ); + for ( i = self->size; i < track + 10; i ++ ) + self->list[ i ] = NULL; + self->size = track + 10; } - if ( this->list[ track ] != NULL ) + if ( self->list[ track ] != NULL ) { - mlt_event_close( this->list[ track ]->event ); - mlt_producer_close( this->list[ track ]->producer ); + mlt_event_close( self->list[ track ]->event ); + mlt_producer_close( self->list[ track ]->producer ); } else { - this->list[ track ] = malloc( sizeof( struct mlt_track_s ) ); + self->list[ track ] = malloc( sizeof( struct mlt_track_s ) ); } // Assign the track in our list here - this->list[ track ]->producer = producer; - this->list[ track ]->event = mlt_events_listen( MLT_PRODUCER_PROPERTIES( producer ), this, + self->list[ track ]->producer = producer; + self->list[ track ]->event = mlt_events_listen( MLT_PRODUCER_PROPERTIES( producer ), self, "producer-changed", ( mlt_listener )mlt_multitrack_listener ); mlt_properties_inc_ref( MLT_PRODUCER_PROPERTIES( producer ) ); - mlt_event_inc_ref( this->list[ track ]->event ); + mlt_event_inc_ref( self->list[ track ]->event ); // Increment the track count if need be - if ( track >= this->count ) - this->count = track + 1; + if ( track >= self->count ) + self->count = track + 1; // Refresh our stats - mlt_multitrack_refresh( this ); + mlt_multitrack_refresh( self ); } return result; @@ -224,29 +224,29 @@ int mlt_multitrack_connect( mlt_multitrack this, mlt_producer producer, int trac /** Get the number of tracks. * * \public \memberof mlt_multitrack_s - * \param this a multitrack + * \param self a multitrack * \return the number of tracks */ -int mlt_multitrack_count( mlt_multitrack this ) +int mlt_multitrack_count( mlt_multitrack self ) { - return this->count; + return self->count; } /** Get an individual track as a producer. * * \public \memberof mlt_multitrack_s - * \param this a multitrack + * \param self a multitrack * \param track the 0-based index of the producer to get * \return the producer or NULL if not valid */ -mlt_producer mlt_multitrack_track( mlt_multitrack this, int track ) +mlt_producer mlt_multitrack_track( mlt_multitrack self, int track ) { mlt_producer producer = NULL; - if ( this->list != NULL && track < this->count ) - producer = this->list[ track ]->producer; + if ( self->list != NULL && track < self->count ) + producer = self->list[ track ]->producer; return producer; } @@ -306,13 +306,13 @@ static int add_unique( mlt_position *array, int size, mlt_position position ) * * * \public \memberof mlt_multitrack_s - * \param this a multitrack + * \param self a multitrack * \param whence from where to extract * \param index the 0-based index of which clip to extract * \return the position of clip \p index relative to \p whence */ -mlt_position mlt_multitrack_clip( mlt_multitrack this, mlt_whence whence, int index ) +mlt_position mlt_multitrack_clip( mlt_multitrack self, mlt_whence whence, int index ) { mlt_position position = 0; int i = 0; @@ -320,10 +320,10 @@ mlt_position mlt_multitrack_clip( mlt_multitrack this, mlt_whence whence, int in mlt_position *map = malloc( 1000 * sizeof( mlt_position ) ); int count = 0; - for ( i = 0; i < this->count; i ++ ) + for ( i = 0; i < self->count; i ++ ) { // Get the producer for this track - mlt_producer producer = this->list[ i ]->producer; + mlt_producer producer = self->list[ i ]->producer; // If it's assigned and not a hidden track if ( producer != NULL ) @@ -363,7 +363,7 @@ mlt_position mlt_multitrack_clip( mlt_multitrack this, mlt_whence whence, int in break; case mlt_whence_relative_current: - position = mlt_producer_position( MLT_MULTITRACK_PRODUCER( this ) ); + position = mlt_producer_position( MLT_MULTITRACK_PRODUCER( self ) ); for ( i = 0; i < count - 2; i ++ ) if ( position >= map[ i ] && position < map[ i + 1 ] ) break; @@ -426,13 +426,13 @@ mlt_position mlt_multitrack_clip( mlt_multitrack this, mlt_whence whence, int in static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int index ) { // Get the mutiltrack object - mlt_multitrack this = parent->child; + mlt_multitrack self = parent->child; // Check if we have a track for this index - if ( index < this->count && this->list[ index ] != NULL ) + if ( index < self->count && self->list[ index ] != NULL ) { // Get the producer for this track - mlt_producer producer = this->list[ index ]->producer; + mlt_producer producer = self->list[ index ]->producer; // Get the track hide property int hide = mlt_properties_get_int( MLT_PRODUCER_PROPERTIES( mlt_producer_cut_parent( producer ) ), "hide" ); @@ -467,7 +467,7 @@ static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int ind mlt_frame_set_position( *frame, mlt_producer_position( parent ) ); // Move on to the next frame - if ( index >= this->count ) + if ( index >= self->count ) { // Let tractor know if we've reached the end mlt_properties_set_int( MLT_FRAME_PROPERTIES( *frame ), "last_track", 1 ); @@ -483,32 +483,32 @@ static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int ind /** Close this instance and free its resources. * * \public \memberof mlt_multitrack_s - * \param this a multitrack + * \param self a multitrack */ -void mlt_multitrack_close( mlt_multitrack this ) +void mlt_multitrack_close( mlt_multitrack self ) { - if ( this != NULL && mlt_properties_dec_ref( MLT_MULTITRACK_PROPERTIES( this ) ) <= 0 ) + if ( self != NULL && mlt_properties_dec_ref( MLT_MULTITRACK_PROPERTIES( self ) ) <= 0 ) { int i = 0; - for ( i = 0; i < this->count; i ++ ) + for ( i = 0; i < self->count; i ++ ) { - if ( this->list[ i ] != NULL ) + if ( self->list[ i ] != NULL ) { - mlt_event_close( this->list[ i ]->event ); - mlt_producer_close( this->list[ i ]->producer ); - free( this->list[ i ] ); + mlt_event_close( self->list[ i ]->event ); + mlt_producer_close( self->list[ i ]->producer ); + free( self->list[ i ] ); } } // Close the producer - this->parent.close = NULL; - mlt_producer_close( &this->parent ); + self->parent.close = NULL; + mlt_producer_close( &self->parent ); // Free the list - free( this->list ); + free( self->list ); // Free the object - free( this ); + free( self ); } } diff --git a/src/framework/mlt_parser.c b/src/framework/mlt_parser.c index c5dd4ec3..5312a617 100644 --- a/src/framework/mlt_parser.c +++ b/src/framework/mlt_parser.c @@ -24,206 +24,206 @@ #include "mlt.h" #include -static int on_invalid( mlt_parser this, mlt_service object ) +static int on_invalid( mlt_parser self, mlt_service object ) { return 0; } -static int on_unknown( mlt_parser this, mlt_service object ) +static int on_unknown( mlt_parser self, mlt_service object ) { return 0; } -static int on_start_producer( mlt_parser this, mlt_producer object ) +static int on_start_producer( mlt_parser self, mlt_producer object ) { return 0; } -static int on_end_producer( mlt_parser this, mlt_producer object ) +static int on_end_producer( mlt_parser self, mlt_producer object ) { return 0; } -static int on_start_playlist( mlt_parser this, mlt_playlist object ) +static int on_start_playlist( mlt_parser self, mlt_playlist object ) { return 0; } -static int on_end_playlist( mlt_parser this, mlt_playlist object ) +static int on_end_playlist( mlt_parser self, mlt_playlist object ) { return 0; } -static int on_start_tractor( mlt_parser this, mlt_tractor object ) +static int on_start_tractor( mlt_parser self, mlt_tractor object ) { return 0; } -static int on_end_tractor( mlt_parser this, mlt_tractor object ) +static int on_end_tractor( mlt_parser self, mlt_tractor object ) { return 0; } -static int on_start_multitrack( mlt_parser this, mlt_multitrack object ) +static int on_start_multitrack( mlt_parser self, mlt_multitrack object ) { return 0; } -static int on_end_multitrack( mlt_parser this, mlt_multitrack object ) +static int on_end_multitrack( mlt_parser self, mlt_multitrack object ) { return 0; } -static int on_start_track( mlt_parser this ) +static int on_start_track( mlt_parser self ) { return 0; } -static int on_end_track( mlt_parser this ) +static int on_end_track( mlt_parser self ) { return 0; } -static int on_start_filter( mlt_parser this, mlt_filter object ) +static int on_start_filter( mlt_parser self, mlt_filter object ) { return 0; } -static int on_end_filter( mlt_parser this, mlt_filter object ) +static int on_end_filter( mlt_parser self, mlt_filter object ) { return 0; } -static int on_start_transition( mlt_parser this, mlt_transition object ) +static int on_start_transition( mlt_parser self, mlt_transition object ) { return 0; } -static int on_end_transition( mlt_parser this, mlt_transition object ) +static int on_end_transition( mlt_parser self, mlt_transition object ) { return 0; } mlt_parser mlt_parser_new( ) { - mlt_parser this = calloc( 1, sizeof( struct mlt_parser_s ) ); - if ( this != NULL && mlt_properties_init( &this->parent, this ) == 0 ) + mlt_parser self = calloc( 1, sizeof( struct mlt_parser_s ) ); + if ( self != NULL && mlt_properties_init( &self->parent, self ) == 0 ) { - this->on_invalid = on_invalid; - this->on_unknown = on_unknown; - this->on_start_producer = on_start_producer; - this->on_end_producer = on_end_producer; - this->on_start_playlist = on_start_playlist; - this->on_end_playlist = on_end_playlist; - this->on_start_tractor = on_start_tractor; - this->on_end_tractor = on_end_tractor; - this->on_start_multitrack = on_start_multitrack; - this->on_end_multitrack = on_end_multitrack; - this->on_start_track = on_start_track; - this->on_end_track = on_end_track; - this->on_start_filter = on_start_filter; - this->on_end_filter = on_end_filter; - this->on_start_transition = on_start_transition; - this->on_end_transition = on_end_transition; + self->on_invalid = on_invalid; + self->on_unknown = on_unknown; + self->on_start_producer = on_start_producer; + self->on_end_producer = on_end_producer; + self->on_start_playlist = on_start_playlist; + self->on_end_playlist = on_end_playlist; + self->on_start_tractor = on_start_tractor; + self->on_end_tractor = on_end_tractor; + self->on_start_multitrack = on_start_multitrack; + self->on_end_multitrack = on_end_multitrack; + self->on_start_track = on_start_track; + self->on_end_track = on_end_track; + self->on_start_filter = on_start_filter; + self->on_end_filter = on_end_filter; + self->on_start_transition = on_start_transition; + self->on_end_transition = on_end_transition; } - return this; + return self; } -mlt_properties mlt_parser_properties( mlt_parser this ) +mlt_properties mlt_parser_properties( mlt_parser self ) { - return &this->parent; + return &self->parent; } -int mlt_parser_start( mlt_parser this, mlt_service object ) +int mlt_parser_start( mlt_parser self, mlt_service object ) { int error = 0; mlt_service_type type = mlt_service_identify( object ); switch( type ) { case invalid_type: - error = this->on_invalid( this, object ); + error = self->on_invalid( self, object ); break; case unknown_type: - error = this->on_unknown( this, object ); + error = self->on_unknown( self, object ); break; case producer_type: if ( mlt_producer_is_cut( ( mlt_producer )object ) ) - error = mlt_parser_start( this, ( mlt_service )mlt_producer_cut_parent( ( mlt_producer )object ) ); - error = this->on_start_producer( this, ( mlt_producer )object ); + error = mlt_parser_start( self, ( mlt_service )mlt_producer_cut_parent( ( mlt_producer )object ) ); + error = self->on_start_producer( self, ( mlt_producer )object ); if ( error == 0 ) { int i = 0; while ( error == 0 && mlt_producer_filter( ( mlt_producer )object, i ) != NULL ) - error = mlt_parser_start( this, ( mlt_service )mlt_producer_filter( ( mlt_producer )object, i ++ ) ); + error = mlt_parser_start( self, ( mlt_service )mlt_producer_filter( ( mlt_producer )object, i ++ ) ); } - error = this->on_end_producer( this, ( mlt_producer )object ); + error = self->on_end_producer( self, ( mlt_producer )object ); break; case playlist_type: - error = this->on_start_playlist( this, ( mlt_playlist )object ); + error = self->on_start_playlist( self, ( mlt_playlist )object ); if ( error == 0 ) { int i = 0; while ( error == 0 && i < mlt_playlist_count( ( mlt_playlist )object ) ) - mlt_parser_start( this, ( mlt_service )mlt_playlist_get_clip( ( mlt_playlist )object, i ++ ) ); + mlt_parser_start( self, ( mlt_service )mlt_playlist_get_clip( ( mlt_playlist )object, i ++ ) ); i = 0; while ( error == 0 && mlt_producer_filter( ( mlt_producer )object, i ) != NULL ) - error = mlt_parser_start( this, ( mlt_service )mlt_producer_filter( ( mlt_producer )object, i ++ ) ); + error = mlt_parser_start( self, ( mlt_service )mlt_producer_filter( ( mlt_producer )object, i ++ ) ); } - error = this->on_end_playlist( this, ( mlt_playlist )object ); + error = self->on_end_playlist( self, ( mlt_playlist )object ); break; case tractor_type: - error = this->on_start_tractor( this, ( mlt_tractor )object ); + error = self->on_start_tractor( self, ( mlt_tractor )object ); if ( error == 0 ) { int i = 0; mlt_service next = mlt_service_producer( object ); - mlt_parser_start( this, ( mlt_service )mlt_tractor_multitrack( ( mlt_tractor )object ) ); + mlt_parser_start( self, ( mlt_service )mlt_tractor_multitrack( ( mlt_tractor )object ) ); while ( next != ( mlt_service )mlt_tractor_multitrack( ( mlt_tractor )object ) ) { - mlt_parser_start( this, next ); + mlt_parser_start( self, next ); next = mlt_service_producer( next ); } while ( error == 0 && mlt_producer_filter( ( mlt_producer )object, i ) != NULL ) - error = mlt_parser_start( this, ( mlt_service )mlt_producer_filter( ( mlt_producer )object, i ++ ) ); + error = mlt_parser_start( self, ( mlt_service )mlt_producer_filter( ( mlt_producer )object, i ++ ) ); } - error = this->on_end_tractor( this, ( mlt_tractor )object ); + error = self->on_end_tractor( self, ( mlt_tractor )object ); break; case multitrack_type: - error = this->on_start_multitrack( this, ( mlt_multitrack )object ); + error = self->on_start_multitrack( self, ( mlt_multitrack )object ); if ( error == 0 ) { int i = 0; while ( i < mlt_multitrack_count( ( mlt_multitrack )object ) ) { - this->on_start_track( this ); - mlt_parser_start( this, ( mlt_service )mlt_multitrack_track( ( mlt_multitrack )object , i ++ ) ); - this->on_end_track( this ); + self->on_start_track( self ); + mlt_parser_start( self, ( mlt_service )mlt_multitrack_track( ( mlt_multitrack )object , i ++ ) ); + self->on_end_track( self ); } i = 0; while ( error == 0 && mlt_producer_filter( ( mlt_producer )object, i ) != NULL ) - error = mlt_parser_start( this, ( mlt_service )mlt_producer_filter( ( mlt_producer )object, i ++ ) ); + error = mlt_parser_start( self, ( mlt_service )mlt_producer_filter( ( mlt_producer )object, i ++ ) ); } - error = this->on_end_multitrack( this, ( mlt_multitrack )object ); + error = self->on_end_multitrack( self, ( mlt_multitrack )object ); break; case filter_type: - error = this->on_start_filter( this, ( mlt_filter )object ); + error = self->on_start_filter( self, ( mlt_filter )object ); if ( error == 0 ) { int i = 0; while ( error == 0 && mlt_producer_filter( ( mlt_producer )object, i ) != NULL ) - error = mlt_parser_start( this, ( mlt_service )mlt_producer_filter( ( mlt_producer )object, i ++ ) ); + error = mlt_parser_start( self, ( mlt_service )mlt_producer_filter( ( mlt_producer )object, i ++ ) ); } - error = this->on_end_filter( this, ( mlt_filter )object ); + error = self->on_end_filter( self, ( mlt_filter )object ); break; case transition_type: - error = this->on_start_transition( this, ( mlt_transition )object ); + error = self->on_start_transition( self, ( mlt_transition )object ); if ( error == 0 ) { int i = 0; while ( error == 0 && mlt_producer_filter( ( mlt_producer )object, i ) != NULL ) - error = mlt_parser_start( this, ( mlt_service )mlt_producer_filter( ( mlt_producer )object, i ++ ) ); + error = mlt_parser_start( self, ( mlt_service )mlt_producer_filter( ( mlt_producer )object, i ++ ) ); } - error = this->on_end_transition( this, ( mlt_transition )object ); + error = self->on_end_transition( self, ( mlt_transition )object ); break; case field_type: break; @@ -233,12 +233,12 @@ int mlt_parser_start( mlt_parser this, mlt_service object ) return error; } -void mlt_parser_close( mlt_parser this ) +void mlt_parser_close( mlt_parser self ) { - if ( this != NULL ) + if ( self != NULL ) { - mlt_properties_close( &this->parent ); - free( this ); + mlt_properties_close( &self->parent ); + free( self ); } } diff --git a/src/framework/mlt_playlist.c b/src/framework/mlt_playlist.c index 25f540a4..f40b8b93 100644 --- a/src/framework/mlt_playlist.c +++ b/src/framework/mlt_playlist.c @@ -51,8 +51,8 @@ struct playlist_entry_s */ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int index ); -static int mlt_playlist_unmix( mlt_playlist this, int clip ); -static int mlt_playlist_resize_mix( mlt_playlist this, int clip, int in, int out ); +static int mlt_playlist_unmix( mlt_playlist self, int clip ); +static int mlt_playlist_resize_mix( mlt_playlist self, int clip, int in, int out ); /** Construct a playlist. * @@ -64,133 +64,133 @@ static int mlt_playlist_resize_mix( mlt_playlist this, int clip, int in, int out mlt_playlist mlt_playlist_init( ) { - mlt_playlist this = calloc( sizeof( struct mlt_playlist_s ), 1 ); - if ( this != NULL ) + mlt_playlist self = calloc( sizeof( struct mlt_playlist_s ), 1 ); + if ( self != NULL ) { - mlt_producer producer = &this->parent; + mlt_producer producer = &self->parent; // Construct the producer - mlt_producer_init( producer, this ); + mlt_producer_init( producer, self ); // Override the producer get_frame producer->get_frame = producer_get_frame; // Define the destructor producer->close = ( mlt_destructor )mlt_playlist_close; - producer->close_object = this; + producer->close_object = self; // Initialise blank - mlt_producer_init( &this->blank, NULL ); - mlt_properties_set( MLT_PRODUCER_PROPERTIES( &this->blank ), "mlt_service", "blank" ); - mlt_properties_set( MLT_PRODUCER_PROPERTIES( &this->blank ), "resource", "blank" ); + mlt_producer_init( &self->blank, NULL ); + mlt_properties_set( MLT_PRODUCER_PROPERTIES( &self->blank ), "mlt_service", "blank" ); + mlt_properties_set( MLT_PRODUCER_PROPERTIES( &self->blank ), "resource", "blank" ); // Indicate that this producer is a playlist - mlt_properties_set_data( MLT_PLAYLIST_PROPERTIES( this ), "playlist", this, 0, NULL, NULL ); + mlt_properties_set_data( MLT_PLAYLIST_PROPERTIES( self ), "playlist", self, 0, NULL, NULL ); // Specify the eof condition - mlt_properties_set( MLT_PLAYLIST_PROPERTIES( this ), "eof", "pause" ); - mlt_properties_set( MLT_PLAYLIST_PROPERTIES( this ), "resource", "" ); - mlt_properties_set( MLT_PLAYLIST_PROPERTIES( this ), "mlt_type", "mlt_producer" ); - mlt_properties_set_position( MLT_PLAYLIST_PROPERTIES( this ), "in", 0 ); - mlt_properties_set_position( MLT_PLAYLIST_PROPERTIES( this ), "out", -1 ); - mlt_properties_set_position( MLT_PLAYLIST_PROPERTIES( this ), "length", 0 ); - - this->size = 10; - this->list = malloc( this->size * sizeof( playlist_entry * ) ); + mlt_properties_set( MLT_PLAYLIST_PROPERTIES( self ), "eof", "pause" ); + mlt_properties_set( MLT_PLAYLIST_PROPERTIES( self ), "resource", "" ); + mlt_properties_set( MLT_PLAYLIST_PROPERTIES( self ), "mlt_type", "mlt_producer" ); + mlt_properties_set_position( MLT_PLAYLIST_PROPERTIES( self ), "in", 0 ); + mlt_properties_set_position( MLT_PLAYLIST_PROPERTIES( self ), "out", -1 ); + mlt_properties_set_position( MLT_PLAYLIST_PROPERTIES( self ), "length", 0 ); + + self->size = 10; + self->list = malloc( self->size * sizeof( playlist_entry * ) ); } - return this; + return self; } /** Get the producer associated to this playlist. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \return the producer interface * \see MLT_PLAYLIST_PRODUCER */ -mlt_producer mlt_playlist_producer( mlt_playlist this ) +mlt_producer mlt_playlist_producer( mlt_playlist self ) { - return this != NULL ? &this->parent : NULL; + return self != NULL ? &self->parent : NULL; } /** Get the service associated to this playlist. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \return the service interface * \see MLT_PLAYLIST_SERVICE */ -mlt_service mlt_playlist_service( mlt_playlist this ) +mlt_service mlt_playlist_service( mlt_playlist self ) { - return MLT_PRODUCER_SERVICE( &this->parent ); + return MLT_PRODUCER_SERVICE( &self->parent ); } /** Get the properties associated to this playlist. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \return the playlist's properties list * \see MLT_PLAYLIST_PROPERTIES */ -mlt_properties mlt_playlist_properties( mlt_playlist this ) +mlt_properties mlt_playlist_properties( mlt_playlist self ) { - return MLT_PRODUCER_PROPERTIES( &this->parent ); + return MLT_PRODUCER_PROPERTIES( &self->parent ); } /** Refresh the playlist after a clip has been changed. * * \private \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \return false */ -static int mlt_playlist_virtual_refresh( mlt_playlist this ) +static int mlt_playlist_virtual_refresh( mlt_playlist self ) { // Obtain the properties - mlt_properties properties = MLT_PLAYLIST_PROPERTIES( this ); + mlt_properties properties = MLT_PLAYLIST_PROPERTIES( self ); int i = 0; mlt_position frame_count = 0; - for ( i = 0; i < this->count; i ++ ) + for ( i = 0; i < self->count; i ++ ) { // Get the producer - mlt_producer producer = this->list[ i ]->producer; + mlt_producer producer = self->list[ i ]->producer; if ( producer ) { int current_length = mlt_producer_get_out( producer ) - mlt_producer_get_in( producer ) + 1; // Check if the length of the producer has changed - if ( this->list[ i ]->frame_in != mlt_producer_get_in( producer ) || - this->list[ i ]->frame_out != mlt_producer_get_out( producer ) ) + if ( self->list[ i ]->frame_in != mlt_producer_get_in( producer ) || + self->list[ i ]->frame_out != mlt_producer_get_out( producer ) ) { // This clip should be removed... if ( current_length < 1 ) { - this->list[ i ]->frame_in = 0; - this->list[ i ]->frame_out = -1; - this->list[ i ]->frame_count = 0; + self->list[ i ]->frame_in = 0; + self->list[ i ]->frame_out = -1; + self->list[ i ]->frame_count = 0; } else { - this->list[ i ]->frame_in = mlt_producer_get_in( producer ); - this->list[ i ]->frame_out = mlt_producer_get_out( producer ); - this->list[ i ]->frame_count = current_length; + self->list[ i ]->frame_in = mlt_producer_get_in( producer ); + self->list[ i ]->frame_out = mlt_producer_get_out( producer ); + self->list[ i ]->frame_count = current_length; } // Update the producer_length - this->list[ i ]->producer_length = current_length; + self->list[ i ]->producer_length = current_length; } } // Calculate the frame_count - this->list[ i ]->frame_count = ( this->list[ i ]->frame_out - this->list[ i ]->frame_in + 1 ) * this->list[ i ]->repeat; + self->list[ i ]->frame_count = ( self->list[ i ]->frame_out - self->list[ i ]->frame_in + 1 ) * self->list[ i ]->repeat; - // Update the frame_count for this clip - frame_count += this->list[ i ]->frame_count; + // Update the frame_count for self clip + frame_count += self->list[ i ]->frame_count; } // Refresh all properties @@ -207,25 +207,25 @@ static int mlt_playlist_virtual_refresh( mlt_playlist this ) * Refreshes the playlist whenever an entry receives producer-changed. * \private \memberof mlt_playlist_s * \param producer a producer - * \param this a playlist + * \param self a playlist */ -static void mlt_playlist_listener( mlt_producer producer, mlt_playlist this ) +static void mlt_playlist_listener( mlt_producer producer, mlt_playlist self ) { - mlt_playlist_virtual_refresh( this ); + mlt_playlist_virtual_refresh( self ); } /** Append to the virtual playlist. * * \private \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param source a producer * \param in the producer's starting time * \param out the producer's ending time * \return true if there was an error */ -static int mlt_playlist_virtual_append( mlt_playlist this, mlt_producer source, mlt_position in, mlt_position out ) +static int mlt_playlist_virtual_append( mlt_playlist self, mlt_producer source, mlt_position in, mlt_position out ) { mlt_producer producer = NULL; mlt_properties properties = NULL; @@ -235,22 +235,22 @@ static int mlt_playlist_virtual_append( mlt_playlist this, mlt_producer source, if ( mlt_producer_is_blank( source ) ) { // Make sure the blank is long enough to accomodate the length specified - if ( out - in + 1 > mlt_producer_get_length( &this->blank ) ) + if ( out - in + 1 > mlt_producer_get_length( &self->blank ) ) { - mlt_properties blank_props = MLT_PRODUCER_PROPERTIES( &this->blank ); + mlt_properties blank_props = MLT_PRODUCER_PROPERTIES( &self->blank ); mlt_events_block( blank_props, blank_props ); - mlt_producer_set_in_and_out( &this->blank, in, out ); + mlt_producer_set_in_and_out( &self->blank, in, out ); mlt_events_unblock( blank_props, blank_props ); } - // Now make sure the cut comes from this this->blank + // Now make sure the cut comes from this self->blank if ( source == NULL ) { - producer = mlt_producer_cut( &this->blank, in, out ); + producer = mlt_producer_cut( &self->blank, in, out ); } - else if ( !mlt_producer_is_cut( source ) || mlt_producer_cut_parent( source ) != &this->blank ) + else if ( !mlt_producer_is_cut( source ) || mlt_producer_cut_parent( source ) != &self->blank ) { - producer = mlt_producer_cut( &this->blank, in, out ); + producer = mlt_producer_cut( &self->blank, in, out ); } else { @@ -297,67 +297,67 @@ static int mlt_playlist_virtual_append( mlt_playlist this, mlt_producer source, } // Check that we have room - if ( this->count >= this->size ) + if ( self->count >= self->size ) { int i; - this->list = realloc( this->list, ( this->size + 10 ) * sizeof( playlist_entry * ) ); - for ( i = this->size; i < this->size + 10; i ++ ) this->list[ i ] = NULL; - this->size += 10; + self->list = realloc( self->list, ( self->size + 10 ) * sizeof( playlist_entry * ) ); + for ( i = self->size; i < self->size + 10; i ++ ) self->list[ i ] = NULL; + self->size += 10; } // Create the entry - this->list[ this->count ] = calloc( sizeof( playlist_entry ), 1 ); - if ( this->list[ this->count ] != NULL ) + self->list[ self->count ] = calloc( sizeof( playlist_entry ), 1 ); + if ( self->list[ self->count ] != NULL ) { - this->list[ this->count ]->producer = producer; - this->list[ this->count ]->frame_in = in; - this->list[ this->count ]->frame_out = out; - this->list[ this->count ]->frame_count = out - in + 1; - this->list[ this->count ]->repeat = 1; - this->list[ this->count ]->producer_length = mlt_producer_get_out( producer ) - mlt_producer_get_in( producer ) + 1; - this->list[ this->count ]->event = mlt_events_listen( parent, this, "producer-changed", ( mlt_listener )mlt_playlist_listener ); - mlt_event_inc_ref( this->list[ this->count ]->event ); + self->list[ self->count ]->producer = producer; + self->list[ self->count ]->frame_in = in; + self->list[ self->count ]->frame_out = out; + self->list[ self->count ]->frame_count = out - in + 1; + self->list[ self->count ]->repeat = 1; + self->list[ self->count ]->producer_length = mlt_producer_get_out( producer ) - mlt_producer_get_in( producer ) + 1; + self->list[ self->count ]->event = mlt_events_listen( parent, self, "producer-changed", ( mlt_listener )mlt_playlist_listener ); + mlt_event_inc_ref( self->list[ self->count ]->event ); mlt_properties_set( properties, "eof", "pause" ); mlt_producer_set_speed( producer, 0 ); - this->count ++; + self->count ++; } - return mlt_playlist_virtual_refresh( this ); + return mlt_playlist_virtual_refresh( self ); } /** Locate a producer by index. * * \private \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param[in, out] position the time at which to locate the producer, returns the time relative to the producer's starting point * \param[out] clip the index of the playlist entry * \param[out] total the duration of the playlist up to and including this producer * \return a producer or NULL if not found */ -static mlt_producer mlt_playlist_locate( mlt_playlist this, mlt_position *position, int *clip, int *total ) +static mlt_producer mlt_playlist_locate( mlt_playlist self, mlt_position *position, int *clip, int *total ) { // Default producer to NULL mlt_producer producer = NULL; // Loop for each producer until found - for ( *clip = 0; *clip < this->count; *clip += 1 ) + for ( *clip = 0; *clip < self->count; *clip += 1 ) { // Increment the total - *total += this->list[ *clip ]->frame_count; + *total += self->list[ *clip ]->frame_count; // Check if the position indicates that we have found the clip // Note that 0 length clips get skipped automatically - if ( *position < this->list[ *clip ]->frame_count ) + if ( *position < self->list[ *clip ]->frame_count ) { // Found it, now break - producer = this->list[ *clip ]->producer; + producer = self->list[ *clip ]->producer; break; } else { - // Decrement position by length of this entry - *position -= this->list[ *clip ]->frame_count; + // Decrement position by length of self entry + *position -= self->list[ *clip ]->frame_count; } } @@ -371,16 +371,16 @@ static mlt_producer mlt_playlist_locate( mlt_playlist this, mlt_position *positi * closing producers previous to the preceding playlist if the autoclose * property is set. * \private \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param[out] progressive true if the producer should be displayed progressively * \return the service interface of the producer at the play head * \see producer_get_frame */ -static mlt_service mlt_playlist_virtual_seek( mlt_playlist this, int *progressive ) +static mlt_service mlt_playlist_virtual_seek( mlt_playlist self, int *progressive ) { // Map playlist position to real producer in virtual playlist - mlt_position position = mlt_producer_frame( &this->parent ); + mlt_position position = mlt_producer_frame( &self->parent ); // Keep the original position since we change it while iterating through the list mlt_position original = position; @@ -390,10 +390,10 @@ static mlt_service mlt_playlist_virtual_seek( mlt_playlist this, int *progressiv int total = 0; // Locate the producer for the position - mlt_producer producer = mlt_playlist_locate( this, &position, &i, &total ); + mlt_producer producer = mlt_playlist_locate( self, &position, &i, &total ); // Get the properties - mlt_properties properties = MLT_PLAYLIST_PROPERTIES( this ); + mlt_properties properties = MLT_PLAYLIST_PROPERTIES( self ); // Automatically close previous producers if requested if ( i > 1 // keep immediate previous in case app wants to get info about what just finished @@ -404,11 +404,11 @@ static mlt_service mlt_playlist_virtual_seek( mlt_playlist this, int *progressiv // They might have jumped ahead! for ( j = 0; j < i - 1; j++ ) { - mlt_service_lock( MLT_PRODUCER_SERVICE( this->list[ j ]->producer ) ); - mlt_producer p = this->list[ j ]->producer; + mlt_service_lock( MLT_PRODUCER_SERVICE( self->list[ j ]->producer ) ); + mlt_producer p = self->list[ j ]->producer; if ( p ) { - this->list[ j ]->producer = NULL; + self->list[ j ]->producer = NULL; mlt_service_unlock( MLT_PRODUCER_SERVICE( p ) ); mlt_producer_close( p ); } @@ -422,33 +422,33 @@ static mlt_service mlt_playlist_virtual_seek( mlt_playlist this, int *progressiv // Seek in real producer to relative position if ( producer != NULL ) { - int count = this->list[ i ]->frame_count / this->list[ i ]->repeat; + int count = self->list[ i ]->frame_count / self->list[ i ]->repeat; *progressive = count == 1; mlt_producer_seek( producer, (int)position % count ); } else if ( !strcmp( eof, "pause" ) && total > 0 ) { - playlist_entry *entry = this->list[ this->count - 1 ]; + playlist_entry *entry = self->list[ self->count - 1 ]; int count = entry->frame_count / entry->repeat; - mlt_producer this_producer = MLT_PLAYLIST_PRODUCER( this ); - mlt_producer_seek( this_producer, original - 1 ); + mlt_producer self_producer = MLT_PLAYLIST_PRODUCER( self ); + mlt_producer_seek( self_producer, original - 1 ); producer = entry->producer; mlt_producer_seek( producer, (int)entry->frame_out % count ); - mlt_producer_set_speed( this_producer, 0 ); + mlt_producer_set_speed( self_producer, 0 ); mlt_producer_set_speed( producer, 0 ); *progressive = count == 1; } else if ( !strcmp( eof, "loop" ) && total > 0 ) { - playlist_entry *entry = this->list[ 0 ]; - mlt_producer this_producer = MLT_PLAYLIST_PRODUCER( this ); - mlt_producer_seek( this_producer, 0 ); + playlist_entry *entry = self->list[ 0 ]; + mlt_producer self_producer = MLT_PLAYLIST_PRODUCER( self ); + mlt_producer_seek( self_producer, 0 ); producer = entry->producer; mlt_producer_seek( producer, 0 ); } else { - producer = &this->blank; + producer = &self->blank; } return MLT_PRODUCER_SERVICE( producer ); @@ -457,46 +457,46 @@ static mlt_service mlt_playlist_virtual_seek( mlt_playlist this, int *progressiv /** Invoked when a producer indicates that it has prematurely reached its end. * * \private \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \return a producer * \see producer_get_frame */ -static mlt_producer mlt_playlist_virtual_set_out( mlt_playlist this ) +static mlt_producer mlt_playlist_virtual_set_out( mlt_playlist self ) { // Default producer to blank - mlt_producer producer = &this->blank; + mlt_producer producer = &self->blank; // Map playlist position to real producer in virtual playlist - mlt_position position = mlt_producer_frame( &this->parent ); + mlt_position position = mlt_producer_frame( &self->parent ); // Loop through the virtual playlist int i = 0; - for ( i = 0; i < this->count; i ++ ) + for ( i = 0; i < self->count; i ++ ) { - if ( position < this->list[ i ]->frame_count ) + if ( position < self->list[ i ]->frame_count ) { // Found it, now break - producer = this->list[ i ]->producer; + producer = self->list[ i ]->producer; break; } else { // Decrement position by length of this entry - position -= this->list[ i ]->frame_count; + position -= self->list[ i ]->frame_count; } } // Seek in real producer to relative position - if ( i < this->count && this->list[ i ]->frame_out != position ) + if ( i < self->count && self->list[ i ]->frame_out != position ) { // Update the frame_count for the changed clip (hmmm) - this->list[ i ]->frame_out = position; - this->list[ i ]->frame_count = this->list[ i ]->frame_out - this->list[ i ]->frame_in + 1; + self->list[ i ]->frame_out = position; + self->list[ i ]->frame_count = self->list[ i ]->frame_out - self->list[ i ]->frame_in + 1; // Refresh the playlist - mlt_playlist_virtual_refresh( this ); + mlt_playlist_virtual_refresh( self ); } return producer; @@ -505,21 +505,21 @@ static mlt_producer mlt_playlist_virtual_set_out( mlt_playlist this ) /** Obtain the current clips index. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \return the index of the playlist entry at the current position */ -int mlt_playlist_current_clip( mlt_playlist this ) +int mlt_playlist_current_clip( mlt_playlist self ) { // Map playlist position to real producer in virtual playlist - mlt_position position = mlt_producer_frame( &this->parent ); + mlt_position position = mlt_producer_frame( &self->parent ); // Loop through the virtual playlist int i = 0; - for ( i = 0; i < this->count; i ++ ) + for ( i = 0; i < self->count; i ++ ) { - if ( position < this->list[ i ]->frame_count ) + if ( position < self->list[ i ]->frame_count ) { // Found it, now break break; @@ -527,7 +527,7 @@ int mlt_playlist_current_clip( mlt_playlist this ) else { // Decrement position by length of this entry - position -= this->list[ i ]->frame_count; + position -= self->list[ i ]->frame_count; } } @@ -537,30 +537,30 @@ int mlt_playlist_current_clip( mlt_playlist this ) /** Obtain the current clips producer. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \return the producer at the current position */ -mlt_producer mlt_playlist_current( mlt_playlist this ) +mlt_producer mlt_playlist_current( mlt_playlist self ) { - int i = mlt_playlist_current_clip( this ); - if ( i < this->count ) - return this->list[ i ]->producer; + int i = mlt_playlist_current_clip( self ); + if ( i < self->count ) + return self->list[ i ]->producer; else - return &this->blank; + return &self->blank; } /** Get the position which corresponds to the start of the next clip. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param whence the location from which to make the index relative: * start of playlist, end of playlist, or current position * \param index the playlist entry index relative to whence * \return the time at which the referenced clip starts */ -mlt_position mlt_playlist_clip( mlt_playlist this, mlt_whence whence, int index ) +mlt_position mlt_playlist_clip( mlt_playlist self, mlt_whence whence, int index ) { mlt_position position = 0; int absolute_clip = index; @@ -574,23 +574,23 @@ mlt_position mlt_playlist_clip( mlt_playlist this, mlt_whence whence, int index break; case mlt_whence_relative_current: - absolute_clip = mlt_playlist_current_clip( this ) + index; + absolute_clip = mlt_playlist_current_clip( self ) + index; break; case mlt_whence_relative_end: - absolute_clip = this->count - index; + absolute_clip = self->count - index; break; } // Check that we're in a valid range if ( absolute_clip < 0 ) absolute_clip = 0; - else if ( absolute_clip > this->count ) - absolute_clip = this->count; + else if ( absolute_clip > self->count ) + absolute_clip = self->count; // Now determine the position for ( i = 0; i < absolute_clip; i ++ ) - position += this->list[ i ]->frame_count; + position += self->list[ i ]->frame_count; return position; } @@ -598,29 +598,29 @@ mlt_position mlt_playlist_clip( mlt_playlist this, mlt_whence whence, int index /** Get all the info about the clip specified. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param info a clip info struct * \param index a playlist entry index * \return true if there was an error */ -int mlt_playlist_get_clip_info( mlt_playlist this, mlt_playlist_clip_info *info, int index ) +int mlt_playlist_get_clip_info( mlt_playlist self, mlt_playlist_clip_info *info, int index ) { - int error = index < 0 || index >= this->count || this->list[ index ]->producer == NULL; + int error = index < 0 || index >= self->count || self->list[ index ]->producer == NULL; memset( info, 0, sizeof( mlt_playlist_clip_info ) ); if ( !error ) { - mlt_producer producer = mlt_producer_cut_parent( this->list[ index ]->producer ); + mlt_producer producer = mlt_producer_cut_parent( self->list[ index ]->producer ); mlt_properties properties = MLT_PRODUCER_PROPERTIES( producer ); info->clip = index; info->producer = producer; - info->cut = this->list[ index ]->producer; - info->start = mlt_playlist_clip( this, mlt_whence_relative_start, index ); + info->cut = self->list[ index ]->producer; + info->start = mlt_playlist_clip( self, mlt_whence_relative_start, index ); info->resource = mlt_properties_get( properties, "resource" ); - info->frame_in = this->list[ index ]->frame_in; - info->frame_out = this->list[ index ]->frame_out; - info->frame_count = this->list[ index ]->frame_count; - info->repeat = this->list[ index ]->repeat; + info->frame_in = self->list[ index ]->frame_in; + info->frame_out = self->list[ index ]->frame_out; + info->frame_count = self->list[ index ]->frame_count; + info->repeat = self->list[ index ]->repeat; info->length = mlt_producer_get_length( producer ); info->fps = mlt_producer_get_fps( producer ); } @@ -631,80 +631,80 @@ int mlt_playlist_get_clip_info( mlt_playlist this, mlt_playlist_clip_info *info, /** Get number of clips in the playlist. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \return the number of playlist entries */ -int mlt_playlist_count( mlt_playlist this ) +int mlt_playlist_count( mlt_playlist self ) { - return this->count; + return self->count; } /** Clear the playlist. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \return true if there was an error */ -int mlt_playlist_clear( mlt_playlist this ) +int mlt_playlist_clear( mlt_playlist self ) { int i; - for ( i = 0; i < this->count; i ++ ) + for ( i = 0; i < self->count; i ++ ) { - mlt_event_close( this->list[ i ]->event ); - mlt_producer_close( this->list[ i ]->producer ); + mlt_event_close( self->list[ i ]->event ); + mlt_producer_close( self->list[ i ]->producer ); } - this->count = 0; - return mlt_playlist_virtual_refresh( this ); + self->count = 0; + return mlt_playlist_virtual_refresh( self ); } /** Append a producer to the playlist. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param producer the producer to append * \return true if there was an error */ -int mlt_playlist_append( mlt_playlist this, mlt_producer producer ) +int mlt_playlist_append( mlt_playlist self, mlt_producer producer ) { // Append to virtual list - return mlt_playlist_virtual_append( this, producer, 0, mlt_producer_get_playtime( producer ) - 1 ); + return mlt_playlist_virtual_append( self, producer, 0, mlt_producer_get_playtime( producer ) - 1 ); } /** Append a producer to the playlist with in/out points. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param producer the producer to append * \param in the starting point on the producer; a negative value is the same as 0 * \param out the ending point on the producer; a negative value is the same as producer length - 1 * \return true if there was an error */ -int mlt_playlist_append_io( mlt_playlist this, mlt_producer producer, mlt_position in, mlt_position out ) +int mlt_playlist_append_io( mlt_playlist self, mlt_producer producer, mlt_position in, mlt_position out ) { // Append to virtual list if ( in < 0 && out < 0 ) - return mlt_playlist_append( this, producer ); + return mlt_playlist_append( self, producer ); else - return mlt_playlist_virtual_append( this, producer, in, out ); + return mlt_playlist_virtual_append( self, producer, in, out ); } /** Append a blank to the playlist of a given length. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param length the ending time of the blank entry, not its duration * \return true if there was an error */ -int mlt_playlist_blank( mlt_playlist this, mlt_position length ) +int mlt_playlist_blank( mlt_playlist self, mlt_position length ) { // Append to the virtual list if (length >= 0) - return mlt_playlist_virtual_append( this, &this->blank, 0, length ); + return mlt_playlist_virtual_append( self, &self->blank, 0, length ); else return 1; } @@ -712,7 +712,7 @@ int mlt_playlist_blank( mlt_playlist this, mlt_position length ) /** Insert a producer into the playlist. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param producer the producer to insert * \param where the producer's playlist entry index * \param in the starting point on the producer @@ -720,57 +720,57 @@ int mlt_playlist_blank( mlt_playlist this, mlt_position length ) * \return true if there was an error */ -int mlt_playlist_insert( mlt_playlist this, mlt_producer producer, int where, mlt_position in, mlt_position out ) +int mlt_playlist_insert( mlt_playlist self, mlt_producer producer, int where, mlt_position in, mlt_position out ) { // Append to end - mlt_events_block( MLT_PLAYLIST_PROPERTIES( this ), this ); - mlt_playlist_append_io( this, producer, in, out ); + mlt_events_block( MLT_PLAYLIST_PROPERTIES( self ), self ); + mlt_playlist_append_io( self, producer, in, out ); // Move to the position specified - mlt_playlist_move( this, this->count - 1, where ); - mlt_events_unblock( MLT_PLAYLIST_PROPERTIES( this ), this ); + mlt_playlist_move( self, self->count - 1, where ); + mlt_events_unblock( MLT_PLAYLIST_PROPERTIES( self ), self ); - return mlt_playlist_virtual_refresh( this ); + return mlt_playlist_virtual_refresh( self ); } /** Remove an entry in the playlist. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param where the playlist entry index * \return true if there was an error */ -int mlt_playlist_remove( mlt_playlist this, int where ) +int mlt_playlist_remove( mlt_playlist self, int where ) { - int error = where < 0 || where >= this->count; - if ( error == 0 && mlt_playlist_unmix( this, where ) != 0 ) + int error = where < 0 || where >= self->count; + if ( error == 0 && mlt_playlist_unmix( self, where ) != 0 ) { // We need to know the current clip and the position within the playlist - int current = mlt_playlist_current_clip( this ); - mlt_position position = mlt_producer_position( MLT_PLAYLIST_PRODUCER( this ) ); + int current = mlt_playlist_current_clip( self ); + mlt_position position = mlt_producer_position( MLT_PLAYLIST_PRODUCER( self ) ); // We need all the details about the clip we're removing mlt_playlist_clip_info where_info; - playlist_entry *entry = this->list[ where ]; + playlist_entry *entry = self->list[ where ]; mlt_properties properties = MLT_PRODUCER_PROPERTIES( entry->producer ); // Loop variable int i = 0; // Get the clip info - mlt_playlist_get_clip_info( this, &where_info, where ); + mlt_playlist_get_clip_info( self, &where_info, where ); // Make sure the clip to be removed is valid and correct if necessary if ( where < 0 ) where = 0; - if ( where >= this->count ) - where = this->count - 1; + if ( where >= self->count ) + where = self->count - 1; // Reorganise the list - for ( i = where + 1; i < this->count; i ++ ) - this->list[ i - 1 ] = this->list[ i ]; - this->count --; + for ( i = where + 1; i < self->count; i ++ ) + self->list[ i - 1 ] = self->list[ i ]; + self->count --; if ( entry->preservation_hack == 0 ) { @@ -796,17 +796,17 @@ int mlt_playlist_remove( mlt_playlist this, int where ) // Correct position if ( where == current ) - mlt_producer_seek( MLT_PLAYLIST_PRODUCER( this ), where_info.start ); - else if ( where < current && this->count > 0 ) - mlt_producer_seek( MLT_PLAYLIST_PRODUCER( this ), position - where_info.frame_count ); - else if ( this->count == 0 ) - mlt_producer_seek( MLT_PLAYLIST_PRODUCER( this ), 0 ); + mlt_producer_seek( MLT_PLAYLIST_PRODUCER( self ), where_info.start ); + else if ( where < current && self->count > 0 ) + mlt_producer_seek( MLT_PLAYLIST_PRODUCER( self ), position - where_info.frame_count ); + else if ( self->count == 0 ) + mlt_producer_seek( MLT_PLAYLIST_PRODUCER( self ), 0 ); // Free the entry free( entry ); // Refresh the playlist - mlt_playlist_virtual_refresh( this ); + mlt_playlist_virtual_refresh( self ); } return error; @@ -815,37 +815,37 @@ int mlt_playlist_remove( mlt_playlist this, int where ) /** Move an entry in the playlist. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param src an entry index * \param dest an entry index * \return false */ -int mlt_playlist_move( mlt_playlist this, int src, int dest ) +int mlt_playlist_move( mlt_playlist self, int src, int dest ) { int i; /* We need to ensure that the requested indexes are valid and correct it as necessary */ if ( src < 0 ) src = 0; - if ( src >= this->count ) - src = this->count - 1; + if ( src >= self->count ) + src = self->count - 1; if ( dest < 0 ) dest = 0; - if ( dest >= this->count ) - dest = this->count - 1; + if ( dest >= self->count ) + dest = self->count - 1; - if ( src != dest && this->count > 1 ) + if ( src != dest && self->count > 1 ) { - int current = mlt_playlist_current_clip( this ); - mlt_position position = mlt_producer_position( MLT_PLAYLIST_PRODUCER( this ) ); + int current = mlt_playlist_current_clip( self ); + mlt_position position = mlt_producer_position( MLT_PLAYLIST_PRODUCER( self ) ); playlist_entry *src_entry = NULL; // We need all the details about the current clip mlt_playlist_clip_info current_info; - mlt_playlist_get_clip_info( this, ¤t_info, current ); + mlt_playlist_get_clip_info( self, ¤t_info, current ); position -= current_info.start; if ( current == src ) @@ -855,22 +855,22 @@ int mlt_playlist_move( mlt_playlist this, int src, int dest ) else if ( current == dest ) current = src; - src_entry = this->list[ src ]; + src_entry = self->list[ src ]; if ( src > dest ) { for ( i = src; i > dest; i -- ) - this->list[ i ] = this->list[ i - 1 ]; + self->list[ i ] = self->list[ i - 1 ]; } else { for ( i = src; i < dest; i ++ ) - this->list[ i ] = this->list[ i + 1 ]; + self->list[ i ] = self->list[ i + 1 ]; } - this->list[ dest ] = src_entry; + self->list[ dest ] = src_entry; - mlt_playlist_get_clip_info( this, ¤t_info, current ); - mlt_producer_seek( MLT_PLAYLIST_PRODUCER( this ), current_info.start + position ); - mlt_playlist_virtual_refresh( this ); + mlt_playlist_get_clip_info( self, ¤t_info, current ); + mlt_producer_seek( MLT_PLAYLIST_PRODUCER( self ), current_info.start + position ); + mlt_playlist_virtual_refresh( self ); } return 0; @@ -879,20 +879,20 @@ int mlt_playlist_move( mlt_playlist this, int src, int dest ) /** Repeat the specified clip n times. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param clip a playlist entry index * \param repeat the number of times to repeat the clip * \return true if there was an error */ -int mlt_playlist_repeat_clip( mlt_playlist this, int clip, int repeat ) +int mlt_playlist_repeat_clip( mlt_playlist self, int clip, int repeat ) { - int error = repeat < 1 || clip < 0 || clip >= this->count; + int error = repeat < 1 || clip < 0 || clip >= self->count; if ( error == 0 ) { - playlist_entry *entry = this->list[ clip ]; + playlist_entry *entry = self->list[ clip ]; entry->repeat = repeat; - mlt_playlist_virtual_refresh( this ); + mlt_playlist_virtual_refresh( self ); } return error; } @@ -900,33 +900,33 @@ int mlt_playlist_repeat_clip( mlt_playlist this, int clip, int repeat ) /** Resize the specified clip. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param clip the index of the playlist entry * \param in the new starting time on the clip's producer; a negative value is the same as 0 * \param out the new ending time on the clip's producer; a negative value is the same as length - 1 * \return true if there was an error */ -int mlt_playlist_resize_clip( mlt_playlist this, int clip, mlt_position in, mlt_position out ) +int mlt_playlist_resize_clip( mlt_playlist self, int clip, mlt_position in, mlt_position out ) { - int error = clip < 0 || clip >= this->count; - if ( error == 0 && mlt_playlist_resize_mix( this, clip, in, out ) != 0 ) + int error = clip < 0 || clip >= self->count; + if ( error == 0 && mlt_playlist_resize_mix( self, clip, in, out ) != 0 ) { - playlist_entry *entry = this->list[ clip ]; + playlist_entry *entry = self->list[ clip ]; mlt_producer producer = entry->producer; - mlt_properties properties = MLT_PLAYLIST_PROPERTIES( this ); + mlt_properties properties = MLT_PLAYLIST_PROPERTIES( self ); mlt_events_block( properties, properties ); if ( mlt_producer_is_blank( producer ) ) { // Make sure the blank is long enough to accomodate the length specified - if ( out - in + 1 > mlt_producer_get_length( &this->blank ) ) + if ( out - in + 1 > mlt_producer_get_length( &self->blank ) ) { - mlt_properties blank_props = MLT_PRODUCER_PROPERTIES( &this->blank ); + mlt_properties blank_props = MLT_PRODUCER_PROPERTIES( &self->blank ); mlt_properties_set_int( blank_props, "length", out - in + 1 ); mlt_properties_set_int( MLT_PRODUCER_PROPERTIES( producer ), "length", out - in + 1 ); - mlt_producer_set_in_and_out( &this->blank, 0, out - in ); + mlt_producer_set_in_and_out( &self->blank, 0, out - in ); } } @@ -944,7 +944,7 @@ int mlt_playlist_resize_clip( mlt_playlist this, int clip, mlt_position in, mlt_ mlt_producer_set_in_and_out( producer, in, out ); mlt_events_unblock( properties, properties ); - mlt_playlist_virtual_refresh( this ); + mlt_playlist_virtual_refresh( self ); } return error; } @@ -953,32 +953,32 @@ int mlt_playlist_resize_clip( mlt_playlist this, int clip, mlt_position in, mlt_ * * This splits after the specified frame. * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param clip the index of the playlist entry * \param position the time at which to split relative to the beginning of the clip or its end if negative * \return true if there was an error */ -int mlt_playlist_split( mlt_playlist this, int clip, mlt_position position ) +int mlt_playlist_split( mlt_playlist self, int clip, mlt_position position ) { - int error = clip < 0 || clip >= this->count; + int error = clip < 0 || clip >= self->count; if ( error == 0 ) { - playlist_entry *entry = this->list[ clip ]; + playlist_entry *entry = self->list[ clip ]; position = position < 0 ? entry->frame_count + position - 1 : position; if ( position >= 0 && position < entry->frame_count - 1 ) { int in = entry->frame_in; int out = entry->frame_out; - mlt_events_block( MLT_PLAYLIST_PROPERTIES( this ), this ); - mlt_playlist_resize_clip( this, clip, in, in + position ); + mlt_events_block( MLT_PLAYLIST_PROPERTIES( self ), self ); + mlt_playlist_resize_clip( self, clip, in, in + position ); if ( !mlt_producer_is_blank( entry->producer ) ) { int i = 0; mlt_properties entry_properties = MLT_PRODUCER_PROPERTIES( entry->producer ); mlt_producer split = mlt_producer_cut( entry->producer, in + position + 1, out ); mlt_properties split_properties = MLT_PRODUCER_PROPERTIES( split ); - mlt_playlist_insert( this, split, clip + 1, 0, -1 ); + mlt_playlist_insert( self, split, clip + 1, 0, -1 ); for ( i = 0; i < mlt_properties_count( entry_properties ); i ++ ) { char *name = mlt_properties_get_name( entry_properties, i ); @@ -989,10 +989,10 @@ int mlt_playlist_split( mlt_playlist this, int clip, mlt_position position ) } else { - mlt_playlist_insert( this, &this->blank, clip + 1, 0, out - position - 1 ); + mlt_playlist_insert( self, &self->blank, clip + 1, 0, out - position - 1 ); } - mlt_events_unblock( MLT_PLAYLIST_PROPERTIES( this ), this ); - mlt_playlist_virtual_refresh( this ); + mlt_events_unblock( MLT_PLAYLIST_PROPERTIES( self ), self ); + mlt_playlist_virtual_refresh( self ); } else { @@ -1005,26 +1005,26 @@ int mlt_playlist_split( mlt_playlist this, int clip, mlt_position position ) /** Split the playlist at the absolute position. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param position the time at which to split relative to the beginning of the clip * \param left true to split before the frame starting at position * \return true if there was an error */ -int mlt_playlist_split_at( mlt_playlist this, mlt_position position, int left ) +int mlt_playlist_split_at( mlt_playlist self, mlt_position position, int left ) { - int result = this == NULL ? -1 : 0; + int result = self == NULL ? -1 : 0; if ( !result ) { - if ( position >= 0 && position < mlt_producer_get_playtime( MLT_PLAYLIST_PRODUCER( this ) ) ) + if ( position >= 0 && position < mlt_producer_get_playtime( MLT_PLAYLIST_PRODUCER( self ) ) ) { - int clip = mlt_playlist_get_clip_index_at( this, position ); + int clip = mlt_playlist_get_clip_index_at( self, position ); mlt_playlist_clip_info info; - mlt_playlist_get_clip_info( this, &info, clip ); + mlt_playlist_get_clip_info( self, &info, clip ); if ( left && position != info.start ) - mlt_playlist_split( this, clip, position - info.start - 1 ); + mlt_playlist_split( self, clip, position - info.start - 1 ); else if ( !left ) - mlt_playlist_split( this, clip, position - info.start ); + mlt_playlist_split( self, clip, position - info.start ); result = position; } else if ( position <= 0 ) @@ -1033,7 +1033,7 @@ int mlt_playlist_split_at( mlt_playlist this, mlt_position position, int left ) } else { - result = mlt_producer_get_playtime( MLT_PLAYLIST_PRODUCER( this ) ); + result = mlt_producer_get_playtime( MLT_PLAYLIST_PRODUCER( self ) ); } } return result; @@ -1042,33 +1042,33 @@ int mlt_playlist_split_at( mlt_playlist this, mlt_position position, int left ) /** Join 1 or more consecutive clips. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param clip the starting playlist entry index * \param count the number of entries to merge * \param merge ignored * \return true if there was an error */ -int mlt_playlist_join( mlt_playlist this, int clip, int count, int merge ) +int mlt_playlist_join( mlt_playlist self, int clip, int count, int merge ) { - int error = clip < 0 || clip >= this->count; + int error = clip < 0 || clip >= self->count; if ( error == 0 ) { int i = clip; mlt_playlist new_clip = mlt_playlist_init( ); - mlt_events_block( MLT_PLAYLIST_PROPERTIES( this ), this ); - if ( clip + count >= this->count ) - count = this->count - clip - 1; + mlt_events_block( MLT_PLAYLIST_PROPERTIES( self ), self ); + if ( clip + count >= self->count ) + count = self->count - clip - 1; for ( i = 0; i <= count; i ++ ) { - playlist_entry *entry = this->list[ clip ]; + playlist_entry *entry = self->list[ clip ]; mlt_playlist_append( new_clip, entry->producer ); mlt_playlist_repeat_clip( new_clip, i, entry->repeat ); entry->preservation_hack = 1; - mlt_playlist_remove( this, clip ); + mlt_playlist_remove( self, clip ); } - mlt_events_unblock( MLT_PLAYLIST_PROPERTIES( this ), this ); - mlt_playlist_insert( this, MLT_PLAYLIST_PRODUCER( new_clip ), clip, 0, -1 ); + mlt_events_unblock( MLT_PLAYLIST_PROPERTIES( self ), self ); + mlt_playlist_insert( self, MLT_PLAYLIST_PRODUCER( new_clip ), clip, 0, -1 ); mlt_playlist_close( new_clip ); } return error; @@ -1077,24 +1077,24 @@ int mlt_playlist_join( mlt_playlist this, int clip, int count, int merge ) /** Mix consecutive clips for a specified length and apply transition if specified. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param clip the index of the playlist entry * \param length the number of frames over which to create the mix * \param transition the transition to use for the mix * \return true if there was an error */ -int mlt_playlist_mix( mlt_playlist this, int clip, int length, mlt_transition transition ) +int mlt_playlist_mix( mlt_playlist self, int clip, int length, mlt_transition transition ) { - int error = ( clip < 0 || clip + 1 >= this->count ); + int error = ( clip < 0 || clip + 1 >= self->count ); if ( error == 0 ) { - playlist_entry *clip_a = this->list[ clip ]; - playlist_entry *clip_b = this->list[ clip + 1 ]; + playlist_entry *clip_a = self->list[ clip ]; + playlist_entry *clip_b = self->list[ clip + 1 ]; mlt_producer track_a = NULL; mlt_producer track_b = NULL; mlt_tractor tractor = mlt_tractor_new( ); - mlt_events_block( MLT_PLAYLIST_PROPERTIES( this ), this ); + mlt_events_block( MLT_PLAYLIST_PROPERTIES( self ), self ); // Check length is valid for both clips and resize if necessary. int max_size = clip_a->frame_count > clip_b->frame_count ? clip_a->frame_count : clip_b->frame_count; @@ -1116,7 +1116,7 @@ int mlt_playlist_mix( mlt_playlist this, int clip, int length, mlt_transition tr mlt_tractor_set_track( tractor, track_b, 1 ); // Insert the mix object into the playlist - mlt_playlist_insert( this, MLT_TRACTOR_PRODUCER( tractor ), clip + 1, -1, -1 ); + mlt_playlist_insert( self, MLT_TRACTOR_PRODUCER( tractor ), clip + 1, -1, -1 ); mlt_properties_set_data( MLT_TRACTOR_PROPERTIES( tractor ), "mlt_mix", tractor, 0, NULL, NULL ); // Attach the transition @@ -1137,41 +1137,41 @@ int mlt_playlist_mix( mlt_playlist this, int clip, int length, mlt_transition tr if ( track_b == clip_b->producer ) { clip_b->preservation_hack = 1; - mlt_playlist_remove( this, clip + 2 ); + mlt_playlist_remove( self, clip + 2 ); } else if ( clip_b->frame_out - clip_b->frame_in > length ) { - mlt_playlist_resize_clip( this, clip + 2, clip_b->frame_in + length, clip_b->frame_out ); + mlt_playlist_resize_clip( self, clip + 2, clip_b->frame_in + length, clip_b->frame_out ); mlt_properties_set_data( MLT_PRODUCER_PROPERTIES( clip_b->producer ), "mix_in", tractor, 0, NULL, NULL ); mlt_properties_set_data( MLT_TRACTOR_PROPERTIES( tractor ), "mix_out", clip_b->producer, 0, NULL, NULL ); } else { mlt_producer_clear( clip_b->producer ); - mlt_playlist_remove( this, clip + 2 ); + mlt_playlist_remove( self, clip + 2 ); } // Check if we have anything left on the left hand clip if ( track_a == clip_a->producer ) { clip_a->preservation_hack = 1; - mlt_playlist_remove( this, clip ); + mlt_playlist_remove( self, clip ); } else if ( clip_a->frame_out - clip_a->frame_in > length ) { - mlt_playlist_resize_clip( this, clip, clip_a->frame_in, clip_a->frame_out - length ); + mlt_playlist_resize_clip( self, clip, clip_a->frame_in, clip_a->frame_out - length ); mlt_properties_set_data( MLT_PRODUCER_PROPERTIES( clip_a->producer ), "mix_out", tractor, 0, NULL, NULL ); mlt_properties_set_data( MLT_TRACTOR_PROPERTIES( tractor ), "mix_in", clip_a->producer, 0, NULL, NULL ); } else { mlt_producer_clear( clip_a->producer ); - mlt_playlist_remove( this, clip ); + mlt_playlist_remove( self, clip ); } // Unblock and force a fire off of change events to listeners - mlt_events_unblock( MLT_PLAYLIST_PROPERTIES( this ), this ); - mlt_playlist_virtual_refresh( this ); + mlt_events_unblock( MLT_PLAYLIST_PROPERTIES( self ), self ); + mlt_playlist_virtual_refresh( self ); mlt_tractor_close( tractor ); } return error; @@ -1180,15 +1180,15 @@ int mlt_playlist_mix( mlt_playlist this, int clip, int length, mlt_transition tr /** Add a transition to an existing mix. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param clip the index of the playlist entry * \param transition a transition * \return true if there was an error */ -int mlt_playlist_mix_add( mlt_playlist this, int clip, mlt_transition transition ) +int mlt_playlist_mix_add( mlt_playlist self, int clip, mlt_transition transition ) { - mlt_producer producer = mlt_producer_cut_parent( mlt_playlist_get_clip( this, clip ) ); + mlt_producer producer = mlt_producer_cut_parent( mlt_playlist_get_clip( self, clip ) ); mlt_properties properties = producer != NULL ? MLT_PRODUCER_PROPERTIES( producer ) : NULL; mlt_tractor tractor = properties != NULL ? mlt_properties_get_data( properties, "mlt_mix", NULL ) : NULL; int error = transition == NULL || tractor == NULL; @@ -1196,7 +1196,7 @@ int mlt_playlist_mix_add( mlt_playlist this, int clip, mlt_transition transition { mlt_field field = mlt_tractor_field( tractor ); mlt_field_plant_transition( field, transition, 0, 1 ); - mlt_transition_set_in_and_out( transition, 0, this->list[ clip ]->frame_count - 1 ); + mlt_transition_set_in_and_out( transition, 0, self->list[ clip ]->frame_count - 1 ); } return error; } @@ -1204,58 +1204,58 @@ int mlt_playlist_mix_add( mlt_playlist this, int clip, mlt_transition transition /** Return the clip at the clip index. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param clip the index of a playlist entry * \return a producer or NULL if there was an error */ -mlt_producer mlt_playlist_get_clip( mlt_playlist this, int clip ) +mlt_producer mlt_playlist_get_clip( mlt_playlist self, int clip ) { - if ( clip >= 0 && clip < this->count ) - return this->list[ clip ]->producer; + if ( clip >= 0 && clip < self->count ) + return self->list[ clip ]->producer; return NULL; } /** Return the clip at the specified position. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param position a time relative to the beginning of the playlist * \return a producer or NULL if not found */ -mlt_producer mlt_playlist_get_clip_at( mlt_playlist this, mlt_position position ) +mlt_producer mlt_playlist_get_clip_at( mlt_playlist self, mlt_position position ) { int index = 0, total = 0; - return mlt_playlist_locate( this, &position, &index, &total ); + return mlt_playlist_locate( self, &position, &index, &total ); } /** Return the clip index of the specified position. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param position a time relative to the beginning of the playlist * \return the index of the playlist entry */ -int mlt_playlist_get_clip_index_at( mlt_playlist this, mlt_position position ) +int mlt_playlist_get_clip_index_at( mlt_playlist self, mlt_position position ) { int index = 0, total = 0; - mlt_playlist_locate( this, &position, &index, &total ); + mlt_playlist_locate( self, &position, &index, &total ); return index; } /** Determine if the clip is a mix. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param clip the index of the playlist entry * \return true if the producer is a mix */ -int mlt_playlist_clip_is_mix( mlt_playlist this, int clip ) +int mlt_playlist_clip_is_mix( mlt_playlist self, int clip ) { - mlt_producer producer = mlt_producer_cut_parent( mlt_playlist_get_clip( this, clip ) ); + mlt_producer producer = mlt_producer_cut_parent( mlt_playlist_get_clip( self, clip ) ); mlt_properties properties = producer != NULL ? MLT_PRODUCER_PROPERTIES( producer ) : NULL; mlt_tractor tractor = properties != NULL ? mlt_properties_get_data( properties, "mlt_mix", NULL ) : NULL; return tractor != NULL; @@ -1265,33 +1265,33 @@ int mlt_playlist_clip_is_mix( mlt_playlist this, int clip ) * back correctly on to the playlist. * * \private \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param clip the index of the playlist entry * \return true if there was an error */ -static int mlt_playlist_unmix( mlt_playlist this, int clip ) +static int mlt_playlist_unmix( mlt_playlist self, int clip ) { - int error = ( clip < 0 || clip >= this->count ); + int error = ( clip < 0 || clip >= self->count ); // Ensure that the clip request is actually a mix if ( error == 0 ) { - mlt_producer producer = mlt_producer_cut_parent( this->list[ clip ]->producer ); + mlt_producer producer = mlt_producer_cut_parent( self->list[ clip ]->producer ); mlt_properties properties = MLT_PRODUCER_PROPERTIES( producer ); error = mlt_properties_get_data( properties, "mlt_mix", NULL ) == NULL || - this->list[ clip ]->preservation_hack; + self->list[ clip ]->preservation_hack; } if ( error == 0 ) { - playlist_entry *mix = this->list[ clip ]; + playlist_entry *mix = self->list[ clip ]; mlt_tractor tractor = ( mlt_tractor )mlt_producer_cut_parent( mix->producer ); mlt_properties properties = MLT_TRACTOR_PROPERTIES( tractor ); mlt_producer clip_a = mlt_properties_get_data( properties, "mix_in", NULL ); mlt_producer clip_b = mlt_properties_get_data( properties, "mix_out", NULL ); int length = mlt_producer_get_playtime( MLT_TRACTOR_PRODUCER( tractor ) ); - mlt_events_block( MLT_PLAYLIST_PROPERTIES( this ), this ); + mlt_events_block( MLT_PLAYLIST_PROPERTIES( self ), self ); if ( clip_a != NULL ) { @@ -1300,7 +1300,7 @@ static int mlt_playlist_unmix( mlt_playlist this, int clip ) else { mlt_producer cut = mlt_tractor_get_track( tractor, 0 ); - mlt_playlist_insert( this, cut, clip, -1, -1 ); + mlt_playlist_insert( self, cut, clip, -1, -1 ); clip ++; } @@ -1311,13 +1311,13 @@ static int mlt_playlist_unmix( mlt_playlist this, int clip ) else { mlt_producer cut = mlt_tractor_get_track( tractor, 1 ); - mlt_playlist_insert( this, cut, clip + 1, -1, -1 ); + mlt_playlist_insert( self, cut, clip + 1, -1, -1 ); } mlt_properties_set_data( properties, "mlt_mix", NULL, 0, NULL, NULL ); - mlt_playlist_remove( this, clip ); - mlt_events_unblock( MLT_PLAYLIST_PROPERTIES( this ), this ); - mlt_playlist_virtual_refresh( this ); + mlt_playlist_remove( self, clip ); + mlt_events_unblock( MLT_PLAYLIST_PROPERTIES( self ), self ); + mlt_playlist_virtual_refresh( self ); } return error; } @@ -1325,28 +1325,28 @@ static int mlt_playlist_unmix( mlt_playlist this, int clip ) /** Resize a mix clip. * * \private \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param clip the index of the playlist entry * \param in the new starting point * \param out the new ending point * \return true if there was an error */ -static int mlt_playlist_resize_mix( mlt_playlist this, int clip, int in, int out ) +static int mlt_playlist_resize_mix( mlt_playlist self, int clip, int in, int out ) { - int error = ( clip < 0 || clip >= this->count ); + int error = ( clip < 0 || clip >= self->count ); // Ensure that the clip request is actually a mix if ( error == 0 ) { - mlt_producer producer = mlt_producer_cut_parent( this->list[ clip ]->producer ); + mlt_producer producer = mlt_producer_cut_parent( self->list[ clip ]->producer ); mlt_properties properties = MLT_PRODUCER_PROPERTIES( producer ); error = mlt_properties_get_data( properties, "mlt_mix", NULL ) == NULL; } if ( error == 0 ) { - playlist_entry *mix = this->list[ clip ]; + playlist_entry *mix = self->list[ clip ]; mlt_tractor tractor = ( mlt_tractor )mlt_producer_cut_parent( mix->producer ); mlt_properties properties = MLT_TRACTOR_PROPERTIES( tractor ); mlt_producer clip_a = mlt_properties_get_data( properties, "mix_in", NULL ); @@ -1355,7 +1355,7 @@ static int mlt_playlist_resize_mix( mlt_playlist this, int clip, int in, int out mlt_producer track_b = mlt_tractor_get_track( tractor, 1 ); int length = out - in + 1; int length_diff = length - mlt_producer_get_playtime( MLT_TRACTOR_PRODUCER( tractor ) ); - mlt_events_block( MLT_PLAYLIST_PROPERTIES( this ), this ); + mlt_events_block( MLT_PLAYLIST_PROPERTIES( self ), self ); if ( clip_a != NULL ) mlt_producer_set_in_and_out( clip_a, mlt_producer_get_in( clip_a ), mlt_producer_get_out( clip_a ) - length_diff ); @@ -1370,8 +1370,8 @@ static int mlt_playlist_resize_mix( mlt_playlist this, int clip, int in, int out mlt_properties_set_position( MLT_PRODUCER_PROPERTIES( mix->producer ), "length", out - in + 1 ); mlt_producer_set_in_and_out( mix->producer, in, out ); - mlt_events_unblock( MLT_PLAYLIST_PROPERTIES( this ), this ); - mlt_playlist_virtual_refresh( this ); + mlt_events_unblock( MLT_PLAYLIST_PROPERTIES( self ), self ); + mlt_playlist_virtual_refresh( self ); } return error; } @@ -1379,93 +1379,93 @@ static int mlt_playlist_resize_mix( mlt_playlist this, int clip, int in, int out /** Consolidate adjacent blank producers. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param keep_length set false to remove the last entry if it is blank */ -void mlt_playlist_consolidate_blanks( mlt_playlist this, int keep_length ) +void mlt_playlist_consolidate_blanks( mlt_playlist self, int keep_length ) { - if ( this != NULL ) + if ( self != NULL ) { int i = 0; - mlt_properties properties = MLT_PLAYLIST_PROPERTIES( this ); + mlt_properties properties = MLT_PLAYLIST_PROPERTIES( self ); mlt_events_block( properties, properties ); - for ( i = 1; i < this->count; i ++ ) + for ( i = 1; i < self->count; i ++ ) { - playlist_entry *left = this->list[ i - 1 ]; - playlist_entry *right = this->list[ i ]; + playlist_entry *left = self->list[ i - 1 ]; + playlist_entry *right = self->list[ i ]; if ( mlt_producer_is_blank( left->producer ) && mlt_producer_is_blank( right->producer ) ) { - mlt_playlist_resize_clip( this, i - 1, 0, left->frame_count + right->frame_count - 1 ); - mlt_playlist_remove( this, i -- ); + mlt_playlist_resize_clip( self, i - 1, 0, left->frame_count + right->frame_count - 1 ); + mlt_playlist_remove( self, i -- ); } } - if ( !keep_length && this->count > 0 ) + if ( !keep_length && self->count > 0 ) { - playlist_entry *last = this->list[ this->count - 1 ]; + playlist_entry *last = self->list[ self->count - 1 ]; if ( mlt_producer_is_blank( last->producer ) ) - mlt_playlist_remove( this, this->count - 1 ); + mlt_playlist_remove( self, self->count - 1 ); } mlt_events_unblock( properties, properties ); - mlt_playlist_virtual_refresh( this ); + mlt_playlist_virtual_refresh( self ); } } /** Determine if the specified clip index is a blank. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param clip the index of the playlist entry * \return true if there was an error */ -int mlt_playlist_is_blank( mlt_playlist this, int clip ) +int mlt_playlist_is_blank( mlt_playlist self, int clip ) { - return this == NULL || mlt_producer_is_blank( mlt_playlist_get_clip( this, clip ) ); + return self == NULL || mlt_producer_is_blank( mlt_playlist_get_clip( self, clip ) ); } /** Determine if the specified position is a blank. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param position a time relative to the start or end (negative) of the playlist * \return true if there was an error */ -int mlt_playlist_is_blank_at( mlt_playlist this, mlt_position position ) +int mlt_playlist_is_blank_at( mlt_playlist self, mlt_position position ) { - return this == NULL || mlt_producer_is_blank( mlt_playlist_get_clip_at( this, position ) ); + return self == NULL || mlt_producer_is_blank( mlt_playlist_get_clip_at( self, position ) ); } /** Replace the specified clip with a blank and return the clip. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param clip the index of the playlist entry * \return a producer or NULL if there was an error */ -mlt_producer mlt_playlist_replace_with_blank( mlt_playlist this, int clip ) +mlt_producer mlt_playlist_replace_with_blank( mlt_playlist self, int clip ) { mlt_producer producer = NULL; - if ( !mlt_playlist_is_blank( this, clip ) ) + if ( !mlt_playlist_is_blank( self, clip ) ) { - playlist_entry *entry = this->list[ clip ]; + playlist_entry *entry = self->list[ clip ]; int in = entry->frame_in; int out = entry->frame_out; - mlt_properties properties = MLT_PLAYLIST_PROPERTIES( this ); + mlt_properties properties = MLT_PLAYLIST_PROPERTIES( self ); producer = entry->producer; mlt_properties_inc_ref( MLT_PRODUCER_PROPERTIES( producer ) ); mlt_events_block( properties, properties ); - mlt_playlist_remove( this, clip ); - mlt_playlist_blank( this, out - in ); - mlt_playlist_move( this, this->count - 1, clip ); + mlt_playlist_remove( self, clip ); + mlt_playlist_blank( self, out - in ); + mlt_playlist_move( self, self->count - 1, clip ); mlt_events_unblock( properties, properties ); - mlt_playlist_virtual_refresh( this ); + mlt_playlist_virtual_refresh( self ); mlt_producer_set_in_and_out( producer, in, out ); } return producer; @@ -1474,124 +1474,124 @@ mlt_producer mlt_playlist_replace_with_blank( mlt_playlist this, int clip ) /** Insert blank space. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param clip the index of the new blank section * \param length the ending time of the new blank section (duration - 1) */ -void mlt_playlist_insert_blank( mlt_playlist this, int clip, int length ) +void mlt_playlist_insert_blank( mlt_playlist self, int clip, int length ) { - if ( this != NULL && length >= 0 ) + if ( self != NULL && length >= 0 ) { - mlt_properties properties = MLT_PLAYLIST_PROPERTIES( this ); + mlt_properties properties = MLT_PLAYLIST_PROPERTIES( self ); mlt_events_block( properties, properties ); - mlt_playlist_blank( this, length ); - mlt_playlist_move( this, this->count - 1, clip ); + mlt_playlist_blank( self, length ); + mlt_playlist_move( self, self->count - 1, clip ); mlt_events_unblock( properties, properties ); - mlt_playlist_virtual_refresh( this ); + mlt_playlist_virtual_refresh( self ); } } /** Resize a blank entry. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param position the time at which the blank entry exists relative to the start or end (negative) of the playlist. * \param length the additional amount of blank frames to add * \param find true to fist locate the blank after the clip at position */ -void mlt_playlist_pad_blanks( mlt_playlist this, mlt_position position, int length, int find ) +void mlt_playlist_pad_blanks( mlt_playlist self, mlt_position position, int length, int find ) { - if ( this != NULL && length != 0 ) + if ( self != NULL && length != 0 ) { - int clip = mlt_playlist_get_clip_index_at( this, position ); - mlt_properties properties = MLT_PLAYLIST_PROPERTIES( this ); + int clip = mlt_playlist_get_clip_index_at( self, position ); + mlt_properties properties = MLT_PLAYLIST_PROPERTIES( self ); mlt_events_block( properties, properties ); - if ( find && clip < this->count && !mlt_playlist_is_blank( this, clip ) ) + if ( find && clip < self->count && !mlt_playlist_is_blank( self, clip ) ) clip ++; - if ( clip < this->count && mlt_playlist_is_blank( this, clip ) ) + if ( clip < self->count && mlt_playlist_is_blank( self, clip ) ) { mlt_playlist_clip_info info; - mlt_playlist_get_clip_info( this, &info, clip ); + mlt_playlist_get_clip_info( self, &info, clip ); if ( info.frame_out + length > info.frame_in ) - mlt_playlist_resize_clip( this, clip, info.frame_in, info.frame_out + length ); + mlt_playlist_resize_clip( self, clip, info.frame_in, info.frame_out + length ); else - mlt_playlist_remove( this, clip ); + mlt_playlist_remove( self, clip ); } - else if ( find && clip < this->count && length > 0 ) + else if ( find && clip < self->count && length > 0 ) { - mlt_playlist_insert_blank( this, clip, length ); + mlt_playlist_insert_blank( self, clip, length ); } mlt_events_unblock( properties, properties ); - mlt_playlist_virtual_refresh( this ); + mlt_playlist_virtual_refresh( self ); } } /** Insert a clip at a specific time. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param position the time at which to insert * \param producer the producer to insert * \param mode true if you want to overwrite any blank section * \return true if there was an error */ -int mlt_playlist_insert_at( mlt_playlist this, mlt_position position, mlt_producer producer, int mode ) +int mlt_playlist_insert_at( mlt_playlist self, mlt_position position, mlt_producer producer, int mode ) { - int ret = this == NULL || position < 0 || producer == NULL; + int ret = self == NULL || position < 0 || producer == NULL; if ( ret == 0 ) { - mlt_properties properties = MLT_PLAYLIST_PROPERTIES( this ); + mlt_properties properties = MLT_PLAYLIST_PROPERTIES( self ); int length = mlt_producer_get_playtime( producer ); - int clip = mlt_playlist_get_clip_index_at( this, position ); + int clip = mlt_playlist_get_clip_index_at( self, position ); mlt_playlist_clip_info info; - mlt_playlist_get_clip_info( this, &info, clip ); - mlt_events_block( properties, this ); - if ( clip < this->count && mlt_playlist_is_blank( this, clip ) ) + mlt_playlist_get_clip_info( self, &info, clip ); + mlt_events_block( properties, self ); + if ( clip < self->count && mlt_playlist_is_blank( self, clip ) ) { // Split and move to new clip if need be - if ( position != info.start && mlt_playlist_split( this, clip, position - info.start - 1 ) == 0 ) - mlt_playlist_get_clip_info( this, &info, ++ clip ); + if ( position != info.start && mlt_playlist_split( self, clip, position - info.start - 1 ) == 0 ) + mlt_playlist_get_clip_info( self, &info, ++ clip ); // Split again if need be if ( length < info.frame_count ) - mlt_playlist_split( this, clip, length - 1 ); + mlt_playlist_split( self, clip, length - 1 ); // Remove - mlt_playlist_remove( this, clip ); + mlt_playlist_remove( self, clip ); // Insert - mlt_playlist_insert( this, producer, clip, -1, -1 ); + mlt_playlist_insert( self, producer, clip, -1, -1 ); ret = clip; } - else if ( clip < this->count ) + else if ( clip < self->count ) { if ( position > info.start + info.frame_count / 2 ) clip ++; - if ( mode == 1 && clip < this->count && mlt_playlist_is_blank( this, clip ) ) + if ( mode == 1 && clip < self->count && mlt_playlist_is_blank( self, clip ) ) { - mlt_playlist_get_clip_info( this, &info, clip ); + mlt_playlist_get_clip_info( self, &info, clip ); if ( length < info.frame_count ) - mlt_playlist_split( this, clip, length ); - mlt_playlist_remove( this, clip ); + mlt_playlist_split( self, clip, length ); + mlt_playlist_remove( self, clip ); } - mlt_playlist_insert( this, producer, clip, -1, -1 ); + mlt_playlist_insert( self, producer, clip, -1, -1 ); ret = clip; } else { if ( mode == 1 ) { if ( position == info.start ) - mlt_playlist_remove( this, clip ); + mlt_playlist_remove( self, clip ); else - mlt_playlist_blank( this, position - mlt_properties_get_int( properties, "length" ) - 1 ); + mlt_playlist_blank( self, position - mlt_properties_get_int( properties, "length" ) - 1 ); } - mlt_playlist_append( this, producer ); - ret = this->count - 1; + mlt_playlist_append( self, producer ); + ret = self->count - 1; } - mlt_events_unblock( properties, this ); - mlt_playlist_virtual_refresh( this ); + mlt_events_unblock( properties, self ); + mlt_playlist_virtual_refresh( self ); } else { @@ -1603,31 +1603,31 @@ int mlt_playlist_insert_at( mlt_playlist this, mlt_position position, mlt_produc /** Get the time at which the clip starts relative to the playlist. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param clip the index of the playlist entry * \return the starting time */ -int mlt_playlist_clip_start( mlt_playlist this, int clip ) +int mlt_playlist_clip_start( mlt_playlist self, int clip ) { mlt_playlist_clip_info info; - if ( mlt_playlist_get_clip_info( this, &info, clip ) == 0 ) + if ( mlt_playlist_get_clip_info( self, &info, clip ) == 0 ) return info.start; - return clip < 0 ? 0 : mlt_producer_get_playtime( MLT_PLAYLIST_PRODUCER( this ) ); + return clip < 0 ? 0 : mlt_producer_get_playtime( MLT_PLAYLIST_PRODUCER( self ) ); } /** Get the playable duration of the clip. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param clip the index of the playlist entry * \return the duration of the playlist entry */ -int mlt_playlist_clip_length( mlt_playlist this, int clip ) +int mlt_playlist_clip_length( mlt_playlist self, int clip ) { mlt_playlist_clip_info info; - if ( mlt_playlist_get_clip_info( this, &info, clip ) == 0 ) + if ( mlt_playlist_get_clip_info( self, &info, clip ) == 0 ) return info.frame_count; return 0; } @@ -1635,27 +1635,27 @@ int mlt_playlist_clip_length( mlt_playlist this, int clip ) /** Get the duration of a blank space. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param clip the index of the playlist entry * \param bounded the maximum number of blank entries or 0 for all * \return the duration of a blank section */ -int mlt_playlist_blanks_from( mlt_playlist this, int clip, int bounded ) +int mlt_playlist_blanks_from( mlt_playlist self, int clip, int bounded ) { int count = 0; mlt_playlist_clip_info info; - if ( this != NULL && clip < this->count ) + if ( self != NULL && clip < self->count ) { - mlt_playlist_get_clip_info( this, &info, clip ); - if ( mlt_playlist_is_blank( this, clip ) ) + mlt_playlist_get_clip_info( self, &info, clip ); + if ( mlt_playlist_is_blank( self, clip ) ) count += info.frame_count; if ( bounded == 0 ) - bounded = this->count; - for ( clip ++; clip < this->count && bounded >= 0; clip ++ ) + bounded = self->count; + for ( clip ++; clip < self->count && bounded >= 0; clip ++ ) { - mlt_playlist_get_clip_info( this, &info, clip ); - if ( mlt_playlist_is_blank( this, clip ) ) + mlt_playlist_get_clip_info( self, &info, clip ); + if ( mlt_playlist_is_blank( self, clip ) ) count += info.frame_count; else bounded --; @@ -1667,44 +1667,44 @@ int mlt_playlist_blanks_from( mlt_playlist this, int clip, int bounded ) /** Remove a portion of the playlist by time. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist * \param position the starting time * \param length the duration of time to remove * \return the new entry index at the position */ -int mlt_playlist_remove_region( mlt_playlist this, mlt_position position, int length ) +int mlt_playlist_remove_region( mlt_playlist self, mlt_position position, int length ) { - int index = mlt_playlist_get_clip_index_at( this, position ); - if ( index >= 0 && index < this->count ) + int index = mlt_playlist_get_clip_index_at( self, position ); + if ( index >= 0 && index < self->count ) { - mlt_properties properties = MLT_PLAYLIST_PROPERTIES( this ); - int clip_start = mlt_playlist_clip_start( this, index ); - int list_length = mlt_producer_get_playtime( MLT_PLAYLIST_PRODUCER( this ) ); - mlt_events_block( properties, this ); + mlt_properties properties = MLT_PLAYLIST_PROPERTIES( self ); + int clip_start = mlt_playlist_clip_start( self, index ); + int list_length = mlt_producer_get_playtime( MLT_PLAYLIST_PRODUCER( self ) ); + mlt_events_block( properties, self ); if ( position + length > list_length ) length -= ( position + length - list_length ); if ( clip_start < position ) { - mlt_playlist_split( this, index ++, position - clip_start - 1 ); + mlt_playlist_split( self, index ++, position - clip_start - 1 ); } while( length > 0 ) { - if ( mlt_playlist_clip_length( this, index ) > length ) - mlt_playlist_split( this, index, length - 1 ); - length -= mlt_playlist_clip_length( this, index ); - mlt_playlist_remove( this, index ); + if ( mlt_playlist_clip_length( self, index ) > length ) + mlt_playlist_split( self, index, length - 1 ); + length -= mlt_playlist_clip_length( self, index ); + mlt_playlist_remove( self, index ); } - mlt_playlist_consolidate_blanks( this, 0 ); - mlt_events_unblock( properties, this ); - mlt_playlist_virtual_refresh( this ); + mlt_playlist_consolidate_blanks( self, 0 ); + mlt_events_unblock( properties, self ); + mlt_playlist_virtual_refresh( self ); // Just to be sure, we'll get the clip index again... - index = mlt_playlist_get_clip_index_at( this, position ); + index = mlt_playlist_get_clip_index_at( self, position ); } return index; } @@ -1713,16 +1713,16 @@ int mlt_playlist_remove_region( mlt_playlist this, mlt_position position, int le * * \deprecated not implemented * \public \memberof mlt_playlist_s - * \param this + * \param self * \param position * \param length * \param new_position * \return */ -int mlt_playlist_move_region( mlt_playlist this, mlt_position position, int length, int new_position ) +int mlt_playlist_move_region( mlt_playlist self, mlt_position position, int length, int new_position ) { - if ( this != NULL ) + if ( self != NULL ) { } return 0; @@ -1748,13 +1748,13 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i } // Get this mlt_playlist - mlt_playlist this = producer->child; + mlt_playlist self = producer->child; // Need to ensure the frame is deinterlaced when repeating 1 frame int progressive = 0; // Get the real producer - mlt_service real = mlt_playlist_virtual_seek( this, &progressive ); + mlt_service real = mlt_playlist_virtual_seek( self, &progressive ); // Check that we have a producer if ( real == NULL ) @@ -1784,7 +1784,7 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i // Check if we're at the end of the clip mlt_properties properties = MLT_FRAME_PROPERTIES( *frame ); if ( mlt_properties_get_int( properties, "end_of_clip" ) ) - mlt_playlist_virtual_set_out( this ); + mlt_playlist_virtual_set_out( self ); // Set the consumer progressive property if ( progressive ) @@ -1814,24 +1814,24 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i /** Close the playlist. * * \public \memberof mlt_playlist_s - * \param this a playlist + * \param self a playlist */ -void mlt_playlist_close( mlt_playlist this ) +void mlt_playlist_close( mlt_playlist self ) { - if ( this != NULL && mlt_properties_dec_ref( MLT_PLAYLIST_PROPERTIES( this ) ) <= 0 ) + if ( self != NULL && mlt_properties_dec_ref( MLT_PLAYLIST_PROPERTIES( self ) ) <= 0 ) { int i = 0; - this->parent.close = NULL; - for ( i = 0; i < this->count; i ++ ) + self->parent.close = NULL; + for ( i = 0; i < self->count; i ++ ) { - mlt_event_close( this->list[ i ]->event ); - mlt_producer_close( this->list[ i ]->producer ); - free( this->list[ i ] ); + mlt_event_close( self->list[ i ]->event ); + mlt_producer_close( self->list[ i ]->producer ); + free( self->list[ i ] ); } - mlt_producer_close( &this->blank ); - mlt_producer_close( &this->parent ); - free( this->list ); - free( this ); + mlt_producer_close( &self->blank ); + mlt_producer_close( &self->parent ); + free( self->list ); + free( self ); } } diff --git a/src/framework/mlt_pool.c b/src/framework/mlt_pool.c index f1f843a5..980e0397 100644 --- a/src/framework/mlt_pool.c +++ b/src/framework/mlt_pool.c @@ -72,48 +72,48 @@ typedef struct __attribute__ ((aligned (16))) mlt_release_s static mlt_pool pool_init( int size ) { // Create the pool - mlt_pool this = calloc( 1, sizeof( struct mlt_pool_s ) ); + mlt_pool self = calloc( 1, sizeof( struct mlt_pool_s ) ); // Initialise it - if ( this != NULL ) + if ( self != NULL ) { // Initialise the mutex - pthread_mutex_init( &this->lock, NULL ); + pthread_mutex_init( &self->lock, NULL ); // Create the stack - this->stack = mlt_deque_init( ); + self->stack = mlt_deque_init( ); // Assign the size - this->size = size; + self->size = size; } // Return it - return this; + return self; } /** Get an item from the pool. * * \private \memberof mlt_pool_s - * \param this a pool + * \param self a pool * \return an opaque pointer */ -static void *pool_fetch( mlt_pool this ) +static void *pool_fetch( mlt_pool self ) { // We will generate a release object void *ptr = NULL; // Sanity check - if ( this != NULL ) + if ( self != NULL ) { // Lock the pool - pthread_mutex_lock( &this->lock ); + pthread_mutex_lock( &self->lock ); // Check if the stack is empty - if ( mlt_deque_count( this->stack ) != 0 ) + if ( mlt_deque_count( self->stack ) != 0 ) { // Pop the top of the stack - ptr = mlt_deque_pop_back( this->stack ); + ptr = mlt_deque_pop_back( self->stack ); // Assign the reference ( ( mlt_release )ptr )->references = 1; @@ -122,19 +122,19 @@ static void *pool_fetch( mlt_pool this ) { // We need to generate a release item #ifdef linux - mlt_release release = memalign( 16, this->size ); + mlt_release release = memalign( 16, self->size ); #else - mlt_release release = malloc( this->size ); + mlt_release release = malloc( self->size ); #endif // Initialise it if ( release != NULL ) { // Increment the number of items allocated to this pool - this->count ++; + self->count ++; // Assign the pool - release->pool = this; + release->pool = self; // Assign the reference release->references = 1; @@ -145,7 +145,7 @@ static void *pool_fetch( mlt_pool this ) } // Unlock the pool - pthread_mutex_unlock( &this->lock ); + pthread_mutex_unlock( &self->lock ); } // Return the generated release object @@ -167,18 +167,18 @@ static void pool_return( void *ptr ) mlt_release that = ( void * )(( char * )ptr - sizeof( struct mlt_release_s )); // Get the pool - mlt_pool this = that->pool; + mlt_pool self = that->pool; - if ( this != NULL ) + if ( self != NULL ) { // Lock the pool - pthread_mutex_lock( &this->lock ); + pthread_mutex_lock( &self->lock ); // Push the that back back on to the stack - mlt_deque_push_back( this->stack, ptr ); + mlt_deque_push_back( self->stack, ptr ); // Unlock the pool - pthread_mutex_unlock( &this->lock ); + pthread_mutex_unlock( &self->lock ); // Ensure that we don't clean up ptr = NULL; @@ -196,31 +196,31 @@ static void pool_return( void *ptr ) /** Destroy a pool. * * \private \memberof mlt_pool_s - * \param this a pool + * \param self a pool */ -static void pool_close( mlt_pool this ) +static void pool_close( mlt_pool self ) { - if ( this != NULL ) + if ( self != NULL ) { // We need to free up all items in the pool void *release = NULL; // Iterate through the stack until depleted - while ( ( release = mlt_deque_pop_back( this->stack ) ) != NULL ) + while ( ( release = mlt_deque_pop_back( self->stack ) ) != NULL ) { // We'll free this item now free( ( char * )release - sizeof( struct mlt_release_s ) ); } // We can now close the stack - mlt_deque_close( this->stack ); + mlt_deque_close( self->stack ); // Destroy the mutex - pthread_mutex_destroy( &this->lock ); + pthread_mutex_destroy( &self->lock ); // Close the pool - free( this ); + free( self ); } } @@ -339,20 +339,20 @@ void mlt_pool_purge( ) for ( i = 0; i < mlt_properties_count( pools ); i ++ ) { // Get the pool - mlt_pool this = mlt_properties_get_data_at( pools, i, NULL ); + mlt_pool self = mlt_properties_get_data_at( pools, i, NULL ); // Pointer to unused memory void *release = NULL; // Lock the pool - pthread_mutex_lock( &this->lock ); + pthread_mutex_lock( &self->lock ); // We'll free all unused items now - while ( ( release = mlt_deque_pop_back( this->stack ) ) != NULL ) + while ( ( release = mlt_deque_pop_back( self->stack ) ) != NULL ) free( ( char * )release - sizeof( struct mlt_release_s ) ); // Unlock the pool - pthread_mutex_unlock( &this->lock ); + pthread_mutex_unlock( &self->lock ); } } diff --git a/src/framework/mlt_producer.c b/src/framework/mlt_producer.c index 0f947b8c..e49f1395 100644 --- a/src/framework/mlt_producer.c +++ b/src/framework/mlt_producer.c @@ -34,9 +34,9 @@ /* Forward references. */ -static int producer_get_frame( mlt_service this, mlt_frame_ptr frame, int index ); -static void mlt_producer_property_changed( mlt_service owner, mlt_producer this, char *name ); -static void mlt_producer_service_changed( mlt_service owner, mlt_producer this ); +static int producer_get_frame( mlt_service self, mlt_frame_ptr frame, int index ); +static void mlt_producer_property_changed( mlt_service owner, mlt_producer self, char *name ); +static void mlt_producer_service_changed( mlt_service owner, mlt_producer self ); /* for debugging */ //#define _MLT_PRODUCER_CHECKS_ 1 @@ -48,15 +48,15 @@ static int producers_destroyed = 0; /** Initialize a producer service. * * \public \memberof mlt_producer_s - * \param this the producer structure to initialize + * \param self the producer structure to initialize * \param child a pointer to the child object for the subclass * \return true if there was an error */ -int mlt_producer_init( mlt_producer this, void *child ) +int mlt_producer_init( mlt_producer self, void *child ) { // Check that we haven't received NULL - int error = this == NULL; + int error = self == NULL; // Continue if no error if ( error == 0 ) @@ -66,23 +66,23 @@ int mlt_producer_init( mlt_producer this, void *child ) #endif // Initialise the producer - memset( this, 0, sizeof( struct mlt_producer_s ) ); + memset( self, 0, sizeof( struct mlt_producer_s ) ); // Associate with the child - this->child = child; + self->child = child; // Initialise the service - if ( mlt_service_init( &this->parent, this ) == 0 ) + if ( mlt_service_init( &self->parent, self ) == 0 ) { // The parent is the service - mlt_service parent = &this->parent; + mlt_service parent = &self->parent; // Define the parent close parent->close = ( mlt_destructor )mlt_producer_close; - parent->close_object = this; + parent->close_object = self; - // For convenience, we'll assume the close_object is this - this->close_object = this; + // For convenience, we'll assume the close_object is self + self->close_object = self; // Get the properties of the parent mlt_properties properties = MLT_SERVICE_PROPERTIES( parent ); @@ -101,8 +101,8 @@ int mlt_producer_init( mlt_producer this, void *child ) // Override service get_frame parent->get_frame = producer_get_frame; - mlt_events_listen( properties, this, "service-changed", ( mlt_listener )mlt_producer_service_changed ); - mlt_events_listen( properties, this, "property-changed", ( mlt_listener )mlt_producer_property_changed ); + mlt_events_listen( properties, self, "service-changed", ( mlt_listener )mlt_producer_service_changed ); + mlt_events_listen( properties, self, "property-changed", ( mlt_listener )mlt_producer_property_changed ); mlt_events_register( properties, "producer-changed", NULL ); } } @@ -116,14 +116,14 @@ int mlt_producer_init( mlt_producer this, void *child ) * * \private \memberof mlt_producer_s * \param owner a service (ignored) - * \param this the producer + * \param self the producer * \param name the property that changed */ -static void mlt_producer_property_changed( mlt_service owner, mlt_producer this, char *name ) +static void mlt_producer_property_changed( mlt_service owner, mlt_producer self, char *name ) { if ( !strcmp( name, "in" ) || !strcmp( name, "out" ) || !strcmp( name, "length" ) ) - mlt_events_fire( MLT_PRODUCER_PROPERTIES( mlt_producer_cut_parent( this ) ), "producer-changed", NULL ); + mlt_events_fire( MLT_PRODUCER_PROPERTIES( mlt_producer_cut_parent( self ) ), "producer-changed", NULL ); } /** Listener for service changes. @@ -132,12 +132,12 @@ static void mlt_producer_property_changed( mlt_service owner, mlt_producer this, * * \private \memberof mlt_producer_s * \param owner a service (ignored) - * \param this the producer + * \param self the producer */ -static void mlt_producer_service_changed( mlt_service owner, mlt_producer this ) +static void mlt_producer_service_changed( mlt_service owner, mlt_producer self ) { - mlt_events_fire( MLT_PRODUCER_PROPERTIES( mlt_producer_cut_parent( this ) ), "producer-changed", NULL ); + mlt_events_fire( MLT_PRODUCER_PROPERTIES( mlt_producer_cut_parent( self ) ), "producer-changed", NULL ); } /** Create and initialize a new producer. @@ -148,42 +148,42 @@ static void mlt_producer_service_changed( mlt_service owner, mlt_producer this ) mlt_producer mlt_producer_new( mlt_profile profile ) { - mlt_producer this = malloc( sizeof( struct mlt_producer_s ) ); - if ( this ) + mlt_producer self = malloc( sizeof( struct mlt_producer_s ) ); + if ( self ) { - if ( mlt_producer_init( this, NULL ) == 0 ) + if ( mlt_producer_init( self, NULL ) == 0 ) { - mlt_properties_set_data( MLT_PRODUCER_PROPERTIES( this ), "_profile", profile, 0, NULL, NULL ); - mlt_properties_set_double( MLT_PRODUCER_PROPERTIES( this ), "aspect_ratio", mlt_profile_sar( profile ) ); + mlt_properties_set_data( MLT_PRODUCER_PROPERTIES( self ), "_profile", profile, 0, NULL, NULL ); + mlt_properties_set_double( MLT_PRODUCER_PROPERTIES( self ), "aspect_ratio", mlt_profile_sar( profile ) ); } } - return this; + return self; } /** Determine if producer is a cut. * * \public \memberof mlt_producer_s - * \param this a producer - * \return true if \p this is a "cut" producer + * \param self a producer + * \return true if \p self is a "cut" producer * \see mlt_producer_cut */ -int mlt_producer_is_cut( mlt_producer this ) +int mlt_producer_is_cut( mlt_producer self ) { - return mlt_properties_get_int( MLT_PRODUCER_PROPERTIES( this ), "_cut" ); + return mlt_properties_get_int( MLT_PRODUCER_PROPERTIES( self ), "_cut" ); } /** Determine if producer is a mix. * * \public \memberof mlt_producer_s - * \param this a producer - * \return true if this is a "mix" producer + * \param self a producer + * \return true if \p self is a "mix" producer * \todo Define a mix producer. */ -int mlt_producer_is_mix( mlt_producer this ) +int mlt_producer_is_mix( mlt_producer self ) { - mlt_properties properties = this != NULL ? MLT_PRODUCER_PROPERTIES( this ) : NULL; + mlt_properties properties = self != NULL ? MLT_PRODUCER_PROPERTIES( self ) : NULL; mlt_tractor tractor = properties != NULL ? mlt_properties_get_data( properties, "mlt_mix", NULL ) : NULL; return tractor != NULL; } @@ -192,30 +192,30 @@ int mlt_producer_is_mix( mlt_producer this ) * * Blank producers should only appear as an item in a playlist. * \public \memberof mlt_producer_s - * \param this a producer - * \return true if this is a "blank" producer + * \param self a producer + * \return true if \p self is a "blank" producer * \see mlt_playlist_insert_blank */ -int mlt_producer_is_blank( mlt_producer this ) +int mlt_producer_is_blank( mlt_producer self ) { - return this == NULL || !strcmp( mlt_properties_get( MLT_PRODUCER_PROPERTIES( mlt_producer_cut_parent( this ) ), "resource" ), "blank" ); + return self == NULL || !strcmp( mlt_properties_get( MLT_PRODUCER_PROPERTIES( mlt_producer_cut_parent( self ) ), "resource" ), "blank" ); } /** Obtain the parent producer. * * \public \memberof mlt_producer_s - * \param this a producer - * \return either the parent producer if this is a "cut" producer or \p this otherwise. + * \param self a producer + * \return either the parent producer if \p self is a "cut" producer or \p self otherwise. */ -mlt_producer mlt_producer_cut_parent( mlt_producer this ) +mlt_producer mlt_producer_cut_parent( mlt_producer self ) { - mlt_properties properties = MLT_PRODUCER_PROPERTIES( this ); - if ( mlt_producer_is_cut( this ) ) + mlt_properties properties = MLT_PRODUCER_PROPERTIES( self ); + if ( mlt_producer_is_cut( self ) ) return mlt_properties_get_data( properties, "_cut_parent", NULL ); else - return this; + return self; } /** Create a cut of this producer. @@ -223,17 +223,17 @@ mlt_producer mlt_producer_cut_parent( mlt_producer this ) * A "cut" is a portion of another (parent) producer. * * \public \memberof mlt_producer_s - * \param this a producer + * \param self a producer * \param in the beginning * \param out the end * \return the new producer * \todo Expand on the value of a cut. */ -mlt_producer mlt_producer_cut( mlt_producer this, int in, int out ) +mlt_producer mlt_producer_cut( mlt_producer self, int in, int out ) { - mlt_producer result = mlt_producer_new( mlt_service_profile( MLT_PRODUCER_SERVICE( this ) ) ); - mlt_producer parent = mlt_producer_cut_parent( this ); + mlt_producer result = mlt_producer_new( mlt_service_profile( MLT_PRODUCER_SERVICE( self ) ) ); + mlt_producer parent = mlt_producer_cut_parent( self ); mlt_properties properties = MLT_PRODUCER_PROPERTIES( result ); mlt_properties parent_props = MLT_PRODUCER_PROPERTIES( parent ); @@ -241,7 +241,7 @@ mlt_producer mlt_producer_cut( mlt_producer this, int in, int out ) // Special case - allow for a cut of the entire producer (this will squeeze all other cuts to 0) if ( in <= 0 ) in = 0; - if ( ( out < 0 || out >= mlt_producer_get_length( parent ) ) && !mlt_producer_is_blank( this ) ) + if ( ( out < 0 || out >= mlt_producer_get_length( parent ) ) && !mlt_producer_is_blank( self ) ) out = mlt_producer_get_length( parent ) - 1; mlt_properties_inc_ref( parent_props ); @@ -257,70 +257,70 @@ mlt_producer mlt_producer_cut( mlt_producer this, int in, int out ) /** Get the parent service object. * * \public \memberof mlt_producer_s - * \param this a producer + * \param self a producer * \return the service parent class * \see MLT_PRODUCER_SERVICE */ -mlt_service mlt_producer_service( mlt_producer this ) +mlt_service mlt_producer_service( mlt_producer self ) { - return this != NULL ? &this->parent : NULL; + return self != NULL ? &self->parent : NULL; } /** Get the producer properties. * * \public \memberof mlt_producer_s - * \param this a producer + * \param self a producer * \return the producer's property list * \see MLT_PRODUCER_PROPERTIES */ -mlt_properties mlt_producer_properties( mlt_producer this ) +mlt_properties mlt_producer_properties( mlt_producer self ) { - return MLT_SERVICE_PROPERTIES( &this->parent ); + return MLT_SERVICE_PROPERTIES( &self->parent ); } /** Seek to a specified position. * * \public \memberof mlt_producer_s - * \param this a producer + * \param self a producer * \param position set the "play head" position of the producer * \return false * \todo Document how the properties affect behavior. */ -int mlt_producer_seek( mlt_producer this, mlt_position position ) +int mlt_producer_seek( mlt_producer self, mlt_position position ) { // Determine eof handling - mlt_properties properties = MLT_PRODUCER_PROPERTIES( this ); + mlt_properties properties = MLT_PRODUCER_PROPERTIES( self ); char *eof = mlt_properties_get( properties, "eof" ); int use_points = 1 - mlt_properties_get_int( properties, "ignore_points" ); // Recursive behaviour for cuts - repositions parent and then repositions cut // hence no return on this condition - if ( mlt_producer_is_cut( this ) ) - mlt_producer_seek( mlt_producer_cut_parent( this ), position + mlt_producer_get_in( this ) ); + if ( mlt_producer_is_cut( self ) ) + mlt_producer_seek( mlt_producer_cut_parent( self ), position + mlt_producer_get_in( self ) ); // Check bounds - if ( position < 0 || mlt_producer_get_playtime( this ) == 0 ) + if ( position < 0 || mlt_producer_get_playtime( self ) == 0 ) { position = 0; } - else if ( use_points && ( eof == NULL || !strcmp( eof, "pause" ) ) && position >= mlt_producer_get_playtime( this ) ) + else if ( use_points && ( eof == NULL || !strcmp( eof, "pause" ) ) && position >= mlt_producer_get_playtime( self ) ) { - mlt_producer_set_speed( this, 0 ); - position = mlt_producer_get_playtime( this ) - 1; + mlt_producer_set_speed( self, 0 ); + position = mlt_producer_get_playtime( self ) - 1; } - else if ( use_points && !strcmp( eof, "loop" ) && position >= mlt_producer_get_playtime( this ) ) + else if ( use_points && !strcmp( eof, "loop" ) && position >= mlt_producer_get_playtime( self ) ) { - position = (int)position % (int)mlt_producer_get_playtime( this ); + position = (int)position % (int)mlt_producer_get_playtime( self ); } // Set the position - mlt_properties_set_position( MLT_PRODUCER_PROPERTIES( this ), "_position", position ); + mlt_properties_set_position( MLT_PRODUCER_PROPERTIES( self ), "_position", position ); // Calculate the absolute frame - mlt_properties_set_position( MLT_PRODUCER_PROPERTIES( this ), "_frame", use_points * mlt_producer_get_in( this ) + position ); + mlt_properties_set_position( MLT_PRODUCER_PROPERTIES( self ), "_frame", use_points * mlt_producer_get_in( self ) + position ); return 0; } @@ -328,50 +328,50 @@ int mlt_producer_seek( mlt_producer this, mlt_position position ) /** Get the current position (relative to in point). * * \public \memberof mlt_producer_s - * \param this a producer + * \param self a producer * \return the position of the "play head" relative to its beginning */ -mlt_position mlt_producer_position( mlt_producer this ) +mlt_position mlt_producer_position( mlt_producer self ) { - return mlt_properties_get_position( MLT_PRODUCER_PROPERTIES( this ), "_position" ); + return mlt_properties_get_position( MLT_PRODUCER_PROPERTIES( self ), "_position" ); } /** Get the current position (relative to start of producer). * * \public \memberof mlt_producer_s - * \param this a producer + * \param self a producer * \return the position of the "play head" regardless of the in point */ -mlt_position mlt_producer_frame( mlt_producer this ) +mlt_position mlt_producer_frame( mlt_producer self ) { - return mlt_properties_get_position( MLT_PRODUCER_PROPERTIES( this ), "_frame" ); + return mlt_properties_get_position( MLT_PRODUCER_PROPERTIES( self ), "_frame" ); } /** Set the playing speed. * * \public \memberof mlt_producer_s - * \param this a producer + * \param self a producer * \param speed the new speed as a relative factor (1.0 = normal) * \return */ -int mlt_producer_set_speed( mlt_producer this, double speed ) +int mlt_producer_set_speed( mlt_producer self, double speed ) { - return mlt_properties_set_double( MLT_PRODUCER_PROPERTIES( this ), "_speed", speed ); + return mlt_properties_set_double( MLT_PRODUCER_PROPERTIES( self ), "_speed", speed ); } /** Get the playing speed. * * \public \memberof mlt_producer_s - * \param this a producer + * \param self a producer * \return the speed as a relative factor (1.0 = normal) */ -double mlt_producer_get_speed( mlt_producer this ) +double mlt_producer_get_speed( mlt_producer self ) { - return mlt_properties_get_double( MLT_PRODUCER_PROPERTIES( this ), "_speed" ); + return mlt_properties_get_double( MLT_PRODUCER_PROPERTIES( self ), "_speed" ); } /** Get the frames per second. @@ -379,13 +379,13 @@ double mlt_producer_get_speed( mlt_producer this ) * This is determined by the producer's profile. * * \public \memberof mlt_producer_s - * \param this a producer + * \param self a producer * \return the video refresh rate */ -double mlt_producer_get_fps( mlt_producer this ) +double mlt_producer_get_fps( mlt_producer self ) { - mlt_profile profile = mlt_service_profile( MLT_PRODUCER_SERVICE( this ) ); + mlt_profile profile = mlt_service_profile( MLT_PRODUCER_SERVICE( self ) ); return mlt_profile_fps( profile ); } @@ -398,26 +398,26 @@ double mlt_producer_get_fps( mlt_producer this ) * sample. * * \public \memberof mlt_producer_s - * \param this a producer + * \param self a producer * \param in the relative starting time; a negative value is the same as 0 * \param out the relative ending time; a negative value is the same as length - 1 * \return false */ -int mlt_producer_set_in_and_out( mlt_producer this, mlt_position in, mlt_position out ) +int mlt_producer_set_in_and_out( mlt_producer self, mlt_position in, mlt_position out ) { - mlt_properties properties = MLT_PRODUCER_PROPERTIES( this ); + mlt_properties properties = MLT_PRODUCER_PROPERTIES( self ); // Correct ins and outs if necessary if ( in < 0 ) in = 0; - else if ( in >= mlt_producer_get_length( this ) ) - in = mlt_producer_get_length( this ) - 1; + else if ( in >= mlt_producer_get_length( self ) ) + in = mlt_producer_get_length( self ) - 1; - if ( ( out < 0 || out >= mlt_producer_get_length( this ) ) && !mlt_producer_is_blank( this ) ) - out = mlt_producer_get_length( this ) - 1; - else if ( ( out < 0 || out >= mlt_producer_get_length( this ) ) && mlt_producer_is_blank( this ) ) - mlt_properties_set_position( MLT_PRODUCER_PROPERTIES( this ), "length", out + 1 ); + if ( ( out < 0 || out >= mlt_producer_get_length( self ) ) && !mlt_producer_is_blank( self ) ) + out = mlt_producer_get_length( self ) - 1; + else if ( ( out < 0 || out >= mlt_producer_get_length( self ) ) && mlt_producer_is_blank( self ) ) + mlt_properties_set_position( MLT_PRODUCER_PROPERTIES( self ), "length", out + 1 ); else if ( out < 0 ) out = 0; @@ -442,15 +442,15 @@ int mlt_producer_set_in_and_out( mlt_producer this, mlt_position in, mlt_positio * Essentially, all 0 length cuts should be immediately removed by containers. * * \public \memberof mlt_producer_s - * \param this a producer + * \param self a producer * \return false */ -int mlt_producer_clear( mlt_producer this ) +int mlt_producer_clear( mlt_producer self ) { - if ( this != NULL ) + if ( self != NULL ) { - mlt_properties properties = MLT_PRODUCER_PROPERTIES( this ); + mlt_properties properties = MLT_PRODUCER_PROPERTIES( self ); mlt_events_block( properties, properties ); mlt_properties_set_position( properties, "in", 0 ); mlt_events_unblock( properties, properties ); @@ -462,37 +462,37 @@ int mlt_producer_clear( mlt_producer this ) /** Get the in point. * * \public \memberof mlt_producer_s - * \param this a producer + * \param self a producer * \return the in point */ -mlt_position mlt_producer_get_in( mlt_producer this ) +mlt_position mlt_producer_get_in( mlt_producer self ) { - return mlt_properties_get_position( MLT_PRODUCER_PROPERTIES( this ), "in" ); + return mlt_properties_get_position( MLT_PRODUCER_PROPERTIES( self ), "in" ); } /** Get the out point. * * \public \memberof mlt_producer_s - * \param this a producer + * \param self a producer * \return the out point */ -mlt_position mlt_producer_get_out( mlt_producer this ) +mlt_position mlt_producer_get_out( mlt_producer self ) { - return mlt_properties_get_position( MLT_PRODUCER_PROPERTIES( this ), "out" ); + return mlt_properties_get_position( MLT_PRODUCER_PROPERTIES( self ), "out" ); } /** Get the total play time. * * \public \memberof mlt_producer_s - * \param this a producer + * \param self a producer * \return the playable (based on in and out points) duration */ -mlt_position mlt_producer_get_playtime( mlt_producer this ) +mlt_position mlt_producer_get_playtime( mlt_producer self ) { - return mlt_producer_get_out( this ) - mlt_producer_get_in( this ) + 1; + return mlt_producer_get_out( self ) - mlt_producer_get_in( self ) + 1; } /** Get the total, unedited length of the producer. @@ -500,13 +500,13 @@ mlt_position mlt_producer_get_playtime( mlt_producer this ) * The value returned by a live streaming producer is unknown. * * \public \memberof mlt_producer_s - * \param this a producer + * \param self a producer * \return the duration of the producer regardless of in and out points */ -mlt_position mlt_producer_get_length( mlt_producer this ) +mlt_position mlt_producer_get_length( mlt_producer self ) { - return mlt_properties_get_position( MLT_PRODUCER_PROPERTIES( this ), "length" ); + return mlt_properties_get_position( MLT_PRODUCER_PROPERTIES( self ), "length" ); } /** Prepare for next frame. @@ -515,13 +515,13 @@ mlt_position mlt_producer_get_length( mlt_producer this ) * move the play out position in the reverse direction. * * \public \memberof mlt_producer_s - * \param this a producer + * \param self a producer */ -void mlt_producer_prepare_next( mlt_producer this ) +void mlt_producer_prepare_next( mlt_producer self ) { - if ( mlt_producer_get_speed( this ) != 0 ) - mlt_producer_seek( this, mlt_producer_position( this ) + mlt_producer_get_speed( this ) ); + if ( mlt_producer_get_speed( self ) != 0 ) + mlt_producer_seek( self, mlt_producer_position( self ) + mlt_producer_get_speed( self ) ); } /** Get a frame. @@ -543,45 +543,45 @@ void mlt_producer_prepare_next( mlt_producer this ) static int producer_get_frame( mlt_service service, mlt_frame_ptr frame, int index ) { int result = 1; - mlt_producer this = service != NULL ? service->child : NULL; + mlt_producer self = service != NULL ? service->child : NULL; - if ( this != NULL && !mlt_producer_is_cut( this ) ) + if ( self != NULL && !mlt_producer_is_cut( self ) ) { // Get the properties of this producer - mlt_properties properties = MLT_PRODUCER_PROPERTIES( this ); + mlt_properties properties = MLT_PRODUCER_PROPERTIES( self ); // Determine eof handling - char *eof = mlt_properties_get( MLT_PRODUCER_PROPERTIES( this ), "eof" ); + char *eof = mlt_properties_get( MLT_PRODUCER_PROPERTIES( self ), "eof" ); // Get the speed of the producer - double speed = mlt_producer_get_speed( this ); + double speed = mlt_producer_get_speed( self ); // We need to use the clone if it's specified mlt_producer clone = mlt_properties_get_data( properties, "use_clone", NULL ); - // If no clone is specified, use this - clone = clone == NULL ? this : clone; + // If no clone is specified, use self + clone = clone == NULL ? self : clone; // A properly instatiated producer will have a get_frame method... - if ( this->get_frame == NULL || ( !strcmp( eof, "continue" ) && mlt_producer_position( this ) > mlt_producer_get_out( this ) ) ) + if ( self->get_frame == NULL || ( !strcmp( eof, "continue" ) && mlt_producer_position( self ) > mlt_producer_get_out( self ) ) ) { // Generate a test frame *frame = mlt_frame_init( service ); // Set the position - result = mlt_frame_set_position( *frame, mlt_producer_position( this ) ); + result = mlt_frame_set_position( *frame, mlt_producer_position( self ) ); // Mark as a test card mlt_properties_set_int( MLT_FRAME_PROPERTIES( *frame ), "test_image", 1 ); mlt_properties_set_int( MLT_FRAME_PROPERTIES( *frame ), "test_audio", 1 ); // Calculate the next position - mlt_producer_prepare_next( this ); + mlt_producer_prepare_next( self ); } else { // Get the frame from the implementation - result = this->get_frame( clone, frame, index ); + result = self->get_frame( clone, frame, index ); } // Copy the fps and speed of the producer onto the frame @@ -592,33 +592,33 @@ static int producer_get_frame( mlt_service service, mlt_frame_ptr frame, int ind if ( mlt_properties_get_data( properties, "_producer", NULL ) == NULL ) mlt_properties_set_data( properties, "_producer", service, 0, NULL, NULL ); } - else if ( this != NULL ) + else if ( self != NULL ) { // Get the speed of the cut - double speed = mlt_producer_get_speed( this ); + double speed = mlt_producer_get_speed( self ); - // Get the parent of this cut - mlt_producer parent = mlt_producer_cut_parent( this ); + // Get the parent of the cut + mlt_producer parent = mlt_producer_cut_parent( self ); // Get the properties of the parent mlt_properties parent_properties = MLT_PRODUCER_PROPERTIES( parent ); // Get the properties of the cut - mlt_properties properties = MLT_PRODUCER_PROPERTIES( this ); + mlt_properties properties = MLT_PRODUCER_PROPERTIES( self ); // Determine the clone index int clone_index = mlt_properties_get_int( properties, "_clone" ); // Determine the clone to use - mlt_producer clone = this; + mlt_producer clone = self; if ( clone_index > 0 ) { char key[ 25 ]; sprintf( key, "_clone.%d", clone_index - 1 ); - clone = mlt_properties_get_data( MLT_PRODUCER_PROPERTIES( mlt_producer_cut_parent( this ) ), key, NULL ); + clone = mlt_properties_get_data( MLT_PRODUCER_PROPERTIES( mlt_producer_cut_parent( self ) ), key, NULL ); if ( clone == NULL ) mlt_log( service, MLT_LOG_ERROR, "requested clone doesn't exist %d\n", clone_index ); - clone = clone == NULL ? this : clone; + clone = clone == NULL ? self : clone; } else { @@ -626,7 +626,7 @@ static int producer_get_frame( mlt_service service, mlt_frame_ptr frame, int ind } // We need to seek to the correct position in the clone - mlt_producer_seek( clone, mlt_producer_get_in( this ) + mlt_properties_get_int( properties, "_position" ) ); + mlt_producer_seek( clone, mlt_producer_get_in( self ) + mlt_properties_get_int( properties, "_position" ) ); // Assign the clone property to the parent mlt_properties_set_data( parent_properties, "use_clone", clone, 0, NULL, NULL ); @@ -639,10 +639,10 @@ static int producer_get_frame( mlt_service service, mlt_frame_ptr frame, int ind // This is useful and required by always_active transitions to determine in/out points of the cut if ( mlt_properties_get_data( MLT_FRAME_PROPERTIES( *frame ), "_producer", NULL ) == MLT_PRODUCER_SERVICE( parent ) ) - mlt_properties_set_data( MLT_FRAME_PROPERTIES( *frame ), "_producer", this, 0, NULL, NULL ); + mlt_properties_set_data( MLT_FRAME_PROPERTIES( *frame ), "_producer", self, 0, NULL, NULL ); mlt_properties_set_double( MLT_FRAME_PROPERTIES( *frame ), "_speed", speed ); - mlt_producer_prepare_next( this ); + mlt_producer_prepare_next( self ); } else { @@ -651,10 +651,10 @@ static int producer_get_frame( mlt_service service, mlt_frame_ptr frame, int ind } // Pass on all meta properties from the producer/cut on to the frame - if ( *frame != NULL && this != NULL ) + if ( *frame != NULL && self != NULL ) { int i = 0; - mlt_properties p_props = MLT_PRODUCER_PROPERTIES( this ); + mlt_properties p_props = MLT_PRODUCER_PROPERTIES( self ); mlt_properties f_props = MLT_FRAME_PROPERTIES( *frame ); int count = mlt_properties_count( p_props ); for ( i = 0; i < count; i ++ ) @@ -673,57 +673,57 @@ static int producer_get_frame( mlt_service service, mlt_frame_ptr frame, int ind /** Attach a filter. * * \public \memberof mlt_producer_s - * \param this a producer + * \param self a producer * \param filter the filter to attach * \return true if there was an error */ -int mlt_producer_attach( mlt_producer this, mlt_filter filter ) +int mlt_producer_attach( mlt_producer self, mlt_filter filter ) { - return mlt_service_attach( MLT_PRODUCER_SERVICE( this ), filter ); + return mlt_service_attach( MLT_PRODUCER_SERVICE( self ), filter ); } /** Detach a filter. * * \public \memberof mlt_producer_s - * \param this a service + * \param self a service * \param filter the filter to detach * \return true if there was an error */ -int mlt_producer_detach( mlt_producer this, mlt_filter filter ) +int mlt_producer_detach( mlt_producer self, mlt_filter filter ) { - return mlt_service_detach( MLT_PRODUCER_SERVICE( this ), filter ); + return mlt_service_detach( MLT_PRODUCER_SERVICE( self ), filter ); } /** Retrieve a filter. * * \public \memberof mlt_producer_s - * \param this a service + * \param self a service * \param index which filter to retrieve * \return the filter or null if there was an error */ -mlt_filter mlt_producer_filter( mlt_producer this, int index ) +mlt_filter mlt_producer_filter( mlt_producer self, int index ) { - return mlt_service_filter( MLT_PRODUCER_SERVICE( this ), index ); + return mlt_service_filter( MLT_PRODUCER_SERVICE( self ), index ); } -/** Clone this producer. +/** Clone self producer. * * \private \memberof mlt_producer_s - * \param this a producer - * \return a new producer that is a copy of \p this + * \param self a producer + * \return a new producer that is a copy of \p self * \see mlt_producer_set_clones */ -static mlt_producer mlt_producer_clone( mlt_producer this ) +static mlt_producer mlt_producer_clone( mlt_producer self ) { mlt_producer clone = NULL; - mlt_properties properties = MLT_PRODUCER_PROPERTIES( this ); + mlt_properties properties = MLT_PRODUCER_PROPERTIES( self ); char *resource = mlt_properties_get( properties, "resource" ); char *service = mlt_properties_get( properties, "mlt_service" ); - mlt_profile profile = mlt_service_profile( MLT_PRODUCER_SERVICE( this ) ); + mlt_profile profile = mlt_service_profile( MLT_PRODUCER_SERVICE( self ) ); mlt_events_block( mlt_factory_event_object( ), mlt_factory_event_object( ) ); @@ -744,14 +744,14 @@ static mlt_producer mlt_producer_clone( mlt_producer this ) /** Create clones. * * \private \memberof mlt_producer_s - * \param this a producer + * \param self a producer * \param clones the number of copies to make * \see mlt_producer_optimise */ -static void mlt_producer_set_clones( mlt_producer this, int clones ) +static void mlt_producer_set_clones( mlt_producer self, int clones ) { - mlt_producer parent = mlt_producer_cut_parent( this ); + mlt_producer parent = mlt_producer_cut_parent( self ); mlt_properties properties = MLT_PRODUCER_PROPERTIES( parent ); int existing = mlt_properties_get_int( properties, "_clones" ); int i = 0; @@ -821,9 +821,9 @@ static int intersect( clip_references *a, clip_references *b ) return diff >= 0 && diff < ( a->end - a->start + 1 ); } -static int push( mlt_parser this, int multitrack, int track, int position ) +static int push( mlt_parser self, int multitrack, int track, int position ) { - mlt_properties properties = mlt_parser_properties( this ); + mlt_properties properties = mlt_parser_properties( self ); mlt_deque stack = mlt_properties_get_data( properties, "stack", NULL ); track_info *info = malloc( sizeof( track_info ) ); info->multitrack = multitrack; @@ -834,37 +834,37 @@ static int push( mlt_parser this, int multitrack, int track, int position ) return mlt_deque_push_back( stack, info ); } -static track_info *pop( mlt_parser this ) +static track_info *pop( mlt_parser self ) { - mlt_properties properties = mlt_parser_properties( this ); + mlt_properties properties = mlt_parser_properties( self ); mlt_deque stack = mlt_properties_get_data( properties, "stack", NULL ); return mlt_deque_pop_back( stack ); } -static track_info *peek( mlt_parser this ) +static track_info *peek( mlt_parser self ) { - mlt_properties properties = mlt_parser_properties( this ); + mlt_properties properties = mlt_parser_properties( self ); mlt_deque stack = mlt_properties_get_data( properties, "stack", NULL ); return mlt_deque_peek_back( stack ); } -static int on_start_multitrack( mlt_parser this, mlt_multitrack object ) +static int on_start_multitrack( mlt_parser self, mlt_multitrack object ) { - track_info *info = peek( this ); - return push( this, info->multitrack ++, info->track, info->position ); + track_info *info = peek( self ); + return push( self, info->multitrack ++, info->track, info->position ); } -static int on_start_track( mlt_parser this ) +static int on_start_track( mlt_parser self ) { - track_info *info = peek( this ); + track_info *info = peek( self ); info->position -= info->offset; info->length -= info->offset; - return push( this, info->multitrack, info->track ++, info->position ); + return push( self, info->multitrack, info->track ++, info->position ); } -static int on_start_producer( mlt_parser this, mlt_producer object ) +static int on_start_producer( mlt_parser self, mlt_producer object ) { - mlt_properties properties = mlt_parser_properties( this ); + mlt_properties properties = mlt_parser_properties( self ); mlt_properties producers = mlt_properties_get_data( properties, "producers", NULL ); mlt_producer parent = mlt_producer_cut_parent( object ); if ( mlt_service_identify( ( mlt_service )mlt_producer_cut_parent( object ) ) == producer_type && mlt_producer_is_cut( object ) ) @@ -874,7 +874,7 @@ static int on_start_producer( mlt_parser this, mlt_producer object ) clip_references *refs = NULL; char key[ 50 ]; int count = 0; - track_info *info = peek( this ); + track_info *info = peek( self ); sprintf( key, "%p", parent ); mlt_properties_get_data( producers, key, &count ); mlt_properties_set_data( producers, key, parent, ++ count, NULL, NULL ); @@ -893,10 +893,10 @@ static int on_start_producer( mlt_parser this, mlt_producer object ) return 0; } -static int on_end_track( mlt_parser this ) +static int on_end_track( mlt_parser self ) { - track_info *track = pop( this ); - track_info *multi = peek( this ); + track_info *track = pop( self ); + track_info *multi = peek( self ); multi->length += track->length; multi->position += track->length; multi->offset = track->length; @@ -904,10 +904,10 @@ static int on_end_track( mlt_parser this ) return 0; } -static int on_end_multitrack( mlt_parser this, mlt_multitrack object ) +static int on_end_multitrack( mlt_parser self, mlt_multitrack object ) { - track_info *multi = pop( this ); - track_info *track = peek( this ); + track_info *multi = pop( self ); + track_info *track = peek( self ); track->position += multi->length; track->length += multi->length; free( multi ); @@ -918,11 +918,11 @@ static int on_end_multitrack( mlt_parser this, mlt_multitrack object ) * * \todo learn more about this * \public \memberof mlt_producer_s - * \param this a producer + * \param self a producer * \return true if there was an error */ -int mlt_producer_optimise( mlt_producer this ) +int mlt_producer_optimise( mlt_producer self ) { int error = 1; mlt_parser parser = mlt_parser_new( ); @@ -940,7 +940,7 @@ int mlt_producer_optimise( mlt_producer this ) parser->on_start_multitrack = on_start_multitrack; parser->on_end_multitrack = on_end_multitrack; push( parser, 0, 0, 0 ); - mlt_parser_start( parser, MLT_PRODUCER_SERVICE( this ) ); + mlt_parser_start( parser, MLT_PRODUCER_SERVICE( self ) ); free( pop( parser ) ); for ( k = 0; k < mlt_properties_count( producers ); k ++ ) { @@ -1000,37 +1000,37 @@ int mlt_producer_optimise( mlt_producer this ) * function to NULL prior to calling this to avoid circular calls. * * \public \memberof mlt_producer_s - * \param this a producer + * \param self a producer */ -void mlt_producer_close( mlt_producer this ) +void mlt_producer_close( mlt_producer self ) { - if ( this != NULL && mlt_properties_dec_ref( MLT_PRODUCER_PROPERTIES( this ) ) <= 0 ) + if ( self != NULL && mlt_properties_dec_ref( MLT_PRODUCER_PROPERTIES( self ) ) <= 0 ) { - this->parent.close = NULL; + self->parent.close = NULL; - if ( this->close != NULL ) + if ( self->close != NULL ) { - this->close( this->close_object ); + self->close( self->close_object ); } else { - int destroy = mlt_producer_is_cut( this ); + int destroy = mlt_producer_is_cut( self ); #if _MLT_PRODUCER_CHECKS_ == 1 // Show debug info - mlt_properties_debug( MLT_PRODUCER_PROPERTIES( this ), "Producer closing", stderr ); + mlt_properties_debug( MLT_PRODUCER_PROPERTIES( self ), "Producer closing", stderr ); #endif #ifdef _MLT_PRODUCER_CHECKS_ // Show current stats - these should match when the app is closed - mlt_log( MLT_PRODUCER_SERVICE( this ), MLT_LOG_DEBUG, "Producers created %d, destroyed %d\n", producers_created, ++producers_destroyed ); + mlt_log( MLT_PRODUCER_SERVICE( self ), MLT_LOG_DEBUG, "Producers created %d, destroyed %d\n", producers_created, ++producers_destroyed ); #endif - mlt_service_close( &this->parent ); + mlt_service_close( &self->parent ); if ( destroy ) - free( this ); + free( self ); } } } diff --git a/src/framework/mlt_profile.c b/src/framework/mlt_profile.c index 3baab0ef..06083894 100644 --- a/src/framework/mlt_profile.c +++ b/src/framework/mlt_profile.c @@ -90,9 +90,9 @@ static mlt_profile mlt_profile_select( const char *name ) * This will never return NULL as it uses the dv_pal settings as hard-coded fallback default. * * \public \memberof mlt_profile_s - * @param name the name of a profile settings file located in the standard location or + * \param name the name of a profile settings file located in the standard location or * the full path name to a profile settings file - * @return a profile + * \return a profile */ mlt_profile mlt_profile_init( const char *name ) @@ -163,8 +163,8 @@ static void set_mlt_normalisation( const char *profile_name ) /** Load a profile from specific file. * * \public \memberof mlt_profile_s - * @param file the full path name to a properties file - * @return a profile or NULL on error + * \param file the full path name to a properties file + * \return a profile or NULL on error */ mlt_profile mlt_profile_load_file( const char *file ) @@ -198,8 +198,8 @@ mlt_profile mlt_profile_load_file( const char *file ) /** Load a profile from a properties object. * * \public \memberof mlt_profile_s - * @param properties a properties list - * @return a profile or NULL if out of memory + * \param properties a properties list + * \return a profile or NULL if out of memory */ mlt_profile mlt_profile_load_properties( mlt_properties properties ) @@ -228,8 +228,8 @@ mlt_profile mlt_profile_load_properties( mlt_properties properties ) /** Load an anonymous profile from string. * * \public \memberof mlt_profile_s - * @param string a newline-delimited list of properties as name=value pairs - * @return a profile or NULL if out of memory + * \param string a newline-delimited list of properties as name=value pairs + * \return a profile or NULL if out of memory */ mlt_profile mlt_profile_load_string( const char *string ) @@ -252,14 +252,14 @@ mlt_profile mlt_profile_load_string( const char *string ) /** Get the video frame rate as a floating point value. * * \public \memberof mlt_profile_s - * @param aprofile a profile + * @param profile a profile * @return the frame rate */ -double mlt_profile_fps( mlt_profile aprofile ) +double mlt_profile_fps( mlt_profile profile ) { - if ( aprofile ) - return ( double ) aprofile->frame_rate_num / aprofile->frame_rate_den; + if ( profile ) + return ( double ) profile->frame_rate_num / profile->frame_rate_den; else return 0; } @@ -267,14 +267,14 @@ double mlt_profile_fps( mlt_profile aprofile ) /** Get the sample aspect ratio as a floating point value. * * \public \memberof mlt_profile_s - * @param aprofile a profile - * @return the pixel aspect ratio + * \param profile a profile + * \return the pixel aspect ratio */ -double mlt_profile_sar( mlt_profile aprofile ) +double mlt_profile_sar( mlt_profile profile ) { - if ( aprofile ) - return ( double ) aprofile->sample_aspect_num / aprofile->sample_aspect_den; + if ( profile ) + return ( double ) profile->sample_aspect_num / profile->sample_aspect_den; else return 0; } @@ -282,14 +282,14 @@ double mlt_profile_sar( mlt_profile aprofile ) /** Get the display aspect ratio as floating point value. * * \public \memberof mlt_profile_s - * @param aprofile a profile - * @return the image aspect ratio + * \param profile a profile + * \return the image aspect ratio */ -double mlt_profile_dar( mlt_profile aprofile ) +double mlt_profile_dar( mlt_profile profile ) { - if ( aprofile ) - return ( double ) aprofile->display_aspect_num / aprofile->display_aspect_den; + if ( profile ) + return ( double ) profile->display_aspect_num / profile->display_aspect_den; else return 0; } @@ -297,7 +297,7 @@ double mlt_profile_dar( mlt_profile aprofile ) /** Free up the global profile resources. * * \public \memberof mlt_profile_s - * @param profile a profile + * \param profile a profile */ void mlt_profile_close( mlt_profile profile ) diff --git a/src/framework/mlt_properties.c b/src/framework/mlt_properties.c index fb353a57..9278cf99 100644 --- a/src/framework/mlt_properties.c +++ b/src/framework/mlt_properties.c @@ -64,14 +64,14 @@ static int properties_destroyed = 0; * * This does allocate its ::property_list, and it adds a reference count. * \public \memberof mlt_properties_s - * \param this the properties structure to initialize + * \param self the properties structure to initialize * \param child an opaque pointer to a subclass object * \return true if failed */ -int mlt_properties_init( mlt_properties this, void *child ) +int mlt_properties_init( mlt_properties self, void *child ) { - if ( this != NULL ) + if ( self != NULL ) { #ifdef _MLT_PROPERTY_CHECKS_ // Increment number of properties created @@ -79,21 +79,21 @@ int mlt_properties_init( mlt_properties this, void *child ) #endif // NULL all methods - memset( this, 0, sizeof( struct mlt_properties_s ) ); + memset( self, 0, sizeof( struct mlt_properties_s ) ); // Assign the child of the object - this->child = child; + self->child = child; // Allocate the local structure - this->local = calloc( sizeof( property_list ), 1 ); + self->local = calloc( sizeof( property_list ), 1 ); // Increment the ref count - ( ( property_list * )this->local )->ref_count = 1; - pthread_mutex_init( &( ( property_list * )this->local )->mutex, NULL );; + ( ( property_list * )self->local )->ref_count = 1; + pthread_mutex_init( &( ( property_list * )self->local )->mutex, NULL );; } // Check that initialisation was successful - return this != NULL && this->local == NULL; + return self != NULL && self->local == NULL; } /** Create a properties object. @@ -107,13 +107,13 @@ int mlt_properties_init( mlt_properties this, void *child ) mlt_properties mlt_properties_new( ) { // Construct a standalone properties object - mlt_properties this = calloc( sizeof( struct mlt_properties_s ), 1 ); + mlt_properties self = calloc( sizeof( struct mlt_properties_s ), 1 ); - // Initialise this - mlt_properties_init( this, NULL ); + // Initialise self + mlt_properties_init( self, NULL ); // Return the pointer - return this; + return self; } /** Create a properties object by reading a .properties text file. @@ -128,9 +128,9 @@ mlt_properties mlt_properties_new( ) mlt_properties mlt_properties_load( const char *filename ) { // Construct a standalone properties object - mlt_properties this = mlt_properties_new( ); + mlt_properties self = mlt_properties_new( ); - if ( this != NULL ) + if ( self != NULL ) { // Open the file FILE *file = fopen( filename, "r" ); @@ -163,7 +163,7 @@ mlt_properties mlt_properties_load( const char *filename ) // Parse and set the property if ( strcmp( temp, "" ) && temp[ 0 ] != '#' ) - mlt_properties_parse( this, temp ); + mlt_properties_parse( self, temp ); } // Close the file @@ -172,7 +172,7 @@ mlt_properties mlt_properties_load( const char *filename ) } // Return the pointer - return this; + return self; } /** Generate a hash key. @@ -191,22 +191,22 @@ static inline int generate_hash( const char *name ) return hash; } -/** Copy a serializable property to properties list that is mirroring this one. +/** Copy a serializable property to a properties list that is mirroring this one. * * Special case - when a container (such as loader) is protecting another * producer, we need to ensure that properties are passed through to the * real producer. * \private \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \param name the name of the property to copy */ -static inline void mlt_properties_do_mirror( mlt_properties this, const char *name ) +static inline void mlt_properties_do_mirror( mlt_properties self, const char *name ) { - property_list *list = this->local; + property_list *list = self->local; if ( list->mirror != NULL ) { - char *value = mlt_properties_get( this, name ); + char *value = mlt_properties_get( self, name ); if ( value != NULL ) mlt_properties_set( list->mirror, name, value ); } @@ -215,16 +215,16 @@ static inline void mlt_properties_do_mirror( mlt_properties this, const char *na /** Increment the reference count. * * \public \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \return the new reference count */ -int mlt_properties_inc_ref( mlt_properties this ) +int mlt_properties_inc_ref( mlt_properties self ) { int result = 0; - if ( this != NULL ) + if ( self != NULL ) { - property_list *list = this->local; + property_list *list = self->local; pthread_mutex_lock( &list->mutex ); result = ++ list->ref_count; pthread_mutex_unlock( &list->mutex ); @@ -235,16 +235,16 @@ int mlt_properties_inc_ref( mlt_properties this ) /** Decrement the reference count. * * \public \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \return the new reference count */ -int mlt_properties_dec_ref( mlt_properties this ) +int mlt_properties_dec_ref( mlt_properties self ) { int result = 0; - if ( this != NULL ) + if ( self != NULL ) { - property_list *list = this->local; + property_list *list = self->local; pthread_mutex_lock( &list->mutex ); result = -- list->ref_count; pthread_mutex_unlock( &list->mutex ); @@ -255,15 +255,15 @@ int mlt_properties_dec_ref( mlt_properties this ) /** Get the reference count. * * \public \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \return the current reference count */ -int mlt_properties_ref_count( mlt_properties this ) +int mlt_properties_ref_count( mlt_properties self ) { - if ( this != NULL ) + if ( self != NULL ) { - property_list *list = this->local; + property_list *list = self->local; return list->ref_count; } return 0; @@ -275,24 +275,24 @@ int mlt_properties_ref_count( mlt_properties this ) * call this before setting the properties that you wish to copy. * \public \memberof mlt_properties_s * \param that the properties which will receive copies of the properties as they are set. - * \param this the properties to mirror + * \param self the properties to mirror */ -void mlt_properties_mirror( mlt_properties this, mlt_properties that ) +void mlt_properties_mirror( mlt_properties self, mlt_properties that ) { - property_list *list = this->local; + property_list *list = self->local; list->mirror = that; } /** Copy all serializable properties to another properties list. * * \public \memberof mlt_properties_s - * \param this The properties to copy to + * \param self The properties to copy to * \param that The properties to copy from * \return false */ -int mlt_properties_inherit( mlt_properties this, mlt_properties that ) +int mlt_properties_inherit( mlt_properties self, mlt_properties that ) { int count = mlt_properties_count( that ); int i = 0; @@ -302,7 +302,7 @@ int mlt_properties_inherit( mlt_properties this, mlt_properties that ) if ( value != NULL ) { char *name = mlt_properties_get_name( that, i ); - mlt_properties_set( this, name, value ); + mlt_properties_set( self, name, value ); } } return 0; @@ -311,13 +311,13 @@ int mlt_properties_inherit( mlt_properties this, mlt_properties that ) /** Pass all serializable properties that match a prefix to another properties object * * \public \memberof mlt_properties_s - * \param this the properties to copy to + * \param self the properties to copy to * \param that The properties to copy from * \param prefix the property names to match (required) * \return false */ -int mlt_properties_pass( mlt_properties this, mlt_properties that, const char *prefix ) +int mlt_properties_pass( mlt_properties self, mlt_properties that, const char *prefix ) { int count = mlt_properties_count( that ); int length = strlen( prefix ); @@ -329,7 +329,7 @@ int mlt_properties_pass( mlt_properties this, mlt_properties that, const char *p { char *value = mlt_properties_get_value( that, i ); if ( value != NULL ) - mlt_properties_set( this, name + length, value ); + mlt_properties_set( self, name + length, value ); } } return 0; @@ -338,14 +338,14 @@ int mlt_properties_pass( mlt_properties this, mlt_properties that, const char *p /** Locate a property by name. * * \private \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \param name the property to lookup by name * \return the property or NULL for failure */ -static inline mlt_property mlt_properties_find( mlt_properties this, const char *name ) +static inline mlt_property mlt_properties_find( mlt_properties self, const char *name ) { - property_list *list = this->local; + property_list *list = self->local; mlt_property value = NULL; int key = generate_hash( name ); int i = list->hash[ key ] - 1; @@ -370,14 +370,14 @@ static inline mlt_property mlt_properties_find( mlt_properties this, const char /** Add a new property. * * \private \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \param name the name of the new property * \return the new property */ -static mlt_property mlt_properties_add( mlt_properties this, const char *name ) +static mlt_property mlt_properties_add( mlt_properties self, const char *name ) { - property_list *list = this->local; + property_list *list = self->local; int key = generate_hash( name ); // Check that we have space and resize if necessary @@ -403,19 +403,19 @@ static mlt_property mlt_properties_add( mlt_properties this, const char *name ) /** Fetch a property by name and add one if not found. * * \private \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \param name the property to lookup or add * \return the property */ -static mlt_property mlt_properties_fetch( mlt_properties this, const char *name ) +static mlt_property mlt_properties_fetch( mlt_properties self, const char *name ) { // Try to find an existing property first - mlt_property property = mlt_properties_find( this, name ); + mlt_property property = mlt_properties_find( self, name ); // If it wasn't found, create one if ( property == NULL ) - property = mlt_properties_add( this, name ); + property = mlt_properties_add( self, name ); // Return the property return property; @@ -425,19 +425,19 @@ static mlt_property mlt_properties_fetch( mlt_properties this, const char *name * * \public \memberof mlt_properties_s * \author Zach - * \param this the properties to copy to + * \param self the properties to copy to * \param that the properties to copy from * \param name the name of the property to copy */ -void mlt_properties_pass_property( mlt_properties this, mlt_properties that, const char *name ) +void mlt_properties_pass_property( mlt_properties self, mlt_properties that, const char *name ) { // Make sure the source property isn't null. mlt_property that_prop = mlt_properties_find( that, name ); if( that_prop == NULL ) return; - mlt_property_pass( mlt_properties_fetch( this, name ), that_prop ); + mlt_property_pass( mlt_properties_fetch( self, name ), that_prop ); } /** Copy all properties specified in a comma-separated list to another properties list. @@ -445,14 +445,14 @@ void mlt_properties_pass_property( mlt_properties this, mlt_properties that, con * White space is also a delimiter. * \public \memberof mlt_properties_s * \author Zach - * \param this the properties to copy to + * \param self the properties to copy to * \param that the properties to copy from * \param list a delimited list of property names * \return false */ -int mlt_properties_pass_list( mlt_properties this, mlt_properties that, const char *list ) +int mlt_properties_pass_list( mlt_properties self, mlt_properties that, const char *list ) { char *props = strdup( list ); char *ptr = props; @@ -468,7 +468,7 @@ int mlt_properties_pass_list( mlt_properties this, mlt_properties that, const ch else ptr[count] = '\0'; // Make it a real string - mlt_properties_pass_property( this, that, ptr ); + mlt_properties_pass_property( self, that, ptr ); ptr += count + 1; ptr += strspn( ptr, delim ); @@ -484,18 +484,18 @@ int mlt_properties_pass_list( mlt_properties this, mlt_properties that, const ch * * This makes a copy of the string value you supply. * \public \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \param name the property to set * \param value the property's new value * \return true if error */ -int mlt_properties_set( mlt_properties this, const char *name, const char *value ) +int mlt_properties_set( mlt_properties self, const char *name, const char *value ) { int error = 1; // Fetch the property to work with - mlt_property property = mlt_properties_fetch( this, name ); + mlt_property property = mlt_properties_fetch( self, name ); // Set it if not NULL if ( property == NULL ) @@ -505,12 +505,12 @@ int mlt_properties_set( mlt_properties this, const char *name, const char *value else if ( value == NULL ) { error = mlt_property_set_string( property, value ); - mlt_properties_do_mirror( this, name ); + mlt_properties_do_mirror( self, name ); } else if ( *value != '@' ) { error = mlt_property_set_string( property, value ); - mlt_properties_do_mirror( this, name ); + mlt_properties_do_mirror( self, name ); } else if ( value[ 0 ] == '@' ) { @@ -534,7 +534,7 @@ int mlt_properties_set( mlt_properties this, const char *name, const char *value if ( isdigit( id[ 0 ] ) ) current = atof( id ); else - current = mlt_properties_get_double( this, id ); + current = mlt_properties_get_double( self, id ); // Apply the operation switch( op ) @@ -558,10 +558,10 @@ int mlt_properties_set( mlt_properties this, const char *name, const char *value } error = mlt_property_set_double( property, total ); - mlt_properties_do_mirror( this, name ); + mlt_properties_do_mirror( self, name ); } - mlt_events_fire( this, "property-changed", name, NULL ); + mlt_events_fire( self, "property-changed", name, NULL ); return error; } @@ -570,16 +570,16 @@ int mlt_properties_set( mlt_properties this, const char *name, const char *value * * This makes a copy of the string value you supply. * \public \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \param name the property to set * \param value the string value to set or NULL to use the default * \param def the default string if value is NULL * \return true if error */ -int mlt_properties_set_or_default( mlt_properties this, const char *name, const char *value, const char *def ) +int mlt_properties_set_or_default( mlt_properties self, const char *name, const char *value, const char *def ) { - return mlt_properties_set( this, name, value == NULL ? def : value ); + return mlt_properties_set( self, name, value == NULL ? def : value ); } /** Get a string value by name. @@ -587,14 +587,14 @@ int mlt_properties_set_or_default( mlt_properties this, const char *name, const * Do not free the returned string. It's lifetime is controlled by the property * and this properties object. * \public \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \param name the property to get * \return the property's string value or NULL if it does not exist */ -char *mlt_properties_get( mlt_properties this, const char *name ) +char *mlt_properties_get( mlt_properties self, const char *name ) { - mlt_property value = mlt_properties_find( this, name ); + mlt_property value = mlt_properties_find( self, name ); return value == NULL ? NULL : mlt_property_get_string( value ); } @@ -602,14 +602,14 @@ char *mlt_properties_get( mlt_properties this, const char *name ) * * Do not free the returned string. * \public \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \param index the numeric index of the property * \return the name of the property or NULL if index is out of range */ -char *mlt_properties_get_name( mlt_properties this, int index ) +char *mlt_properties_get_name( mlt_properties self, int index ) { - property_list *list = this->local; + property_list *list = self->local; if ( index >= 0 && index < list->count ) return list->name[ index ]; return NULL; @@ -619,14 +619,14 @@ char *mlt_properties_get_name( mlt_properties this, int index ) * * Do not free the returned string. * \public \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \param index the numeric index of the property * \return the property value as a string or NULL if the index is out of range */ -char *mlt_properties_get_value( mlt_properties this, int index ) +char *mlt_properties_get_value( mlt_properties self, int index ) { - property_list *list = this->local; + property_list *list = self->local; if ( index >= 0 && index < list->count ) return mlt_property_get_string( list->value[ index ] ); return NULL; @@ -637,14 +637,14 @@ char *mlt_properties_get_value( mlt_properties this, int index ) * Do not free the returned pointer if you supplied a destructor function when you * set this property. * \public \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \param index the numeric index of the property * \param[out] size the size of the binary data in bytes or NULL if the index is out of range */ -void *mlt_properties_get_data_at( mlt_properties this, int index, int *size ) +void *mlt_properties_get_data_at( mlt_properties self, int index, int *size ) { - property_list *list = this->local; + property_list *list = self->local; if ( index >= 0 && index < list->count ) return mlt_property_get_data( list->value[ index ], size ); return NULL; @@ -653,25 +653,25 @@ void *mlt_properties_get_data_at( mlt_properties this, int index, int *size ) /** Return the number of items in the list. * * \public \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \return the number of property objects */ -int mlt_properties_count( mlt_properties this ) +int mlt_properties_count( mlt_properties self ) { - property_list *list = this->local; + property_list *list = self->local; return list->count; } /** Set a value by parsing a name=value string. * * \public \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \param namevalue a string containing name and value delimited by '=' * \return true if there was an error */ -int mlt_properties_parse( mlt_properties this, const char *namevalue ) +int mlt_properties_parse( mlt_properties self, const char *namevalue ) { char *name = strdup( namevalue ); char *value = NULL; @@ -699,7 +699,7 @@ int mlt_properties_parse( mlt_properties this, const char *namevalue ) value = strdup( "" ); } - error = mlt_properties_set( this, name, value ); + error = mlt_properties_set( self, name, value ); free( name ); free( value ); @@ -710,41 +710,41 @@ int mlt_properties_parse( mlt_properties this, const char *namevalue ) /** Get an integer associated to the name. * * \public \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \param name the property to get * \return The integer value, 0 if not found (which may also be a legitimate value) */ -int mlt_properties_get_int( mlt_properties this, const char *name ) +int mlt_properties_get_int( mlt_properties self, const char *name ) { - mlt_property value = mlt_properties_find( this, name ); + mlt_property value = mlt_properties_find( self, name ); return value == NULL ? 0 : mlt_property_get_int( value ); } /** Set a property to an integer value. * * \public \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \param name the property to set * \param value the integer * \return true if error */ -int mlt_properties_set_int( mlt_properties this, const char *name, int value ) +int mlt_properties_set_int( mlt_properties self, const char *name, int value ) { int error = 1; // Fetch the property to work with - mlt_property property = mlt_properties_fetch( this, name ); + mlt_property property = mlt_properties_fetch( self, name ); // Set it if not NULL if ( property != NULL ) { error = mlt_property_set_int( property, value ); - mlt_properties_do_mirror( this, name ); + mlt_properties_do_mirror( self, name ); } - mlt_events_fire( this, "property-changed", name, NULL ); + mlt_events_fire( self, "property-changed", name, NULL ); return error; } @@ -752,41 +752,41 @@ int mlt_properties_set_int( mlt_properties this, const char *name, int value ) /** Get a 64-bit integer associated to the name. * * \public \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \param name the property to get * \return the integer value, 0 if not found (which may also be a legitimate value) */ -int64_t mlt_properties_get_int64( mlt_properties this, const char *name ) +int64_t mlt_properties_get_int64( mlt_properties self, const char *name ) { - mlt_property value = mlt_properties_find( this, name ); + mlt_property value = mlt_properties_find( self, name ); return value == NULL ? 0 : mlt_property_get_int64( value ); } /** Set a property to a 64-bit integer value. * * \public \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \param name the property to set * \param value the integer * \return true if error */ -int mlt_properties_set_int64( mlt_properties this, const char *name, int64_t value ) +int mlt_properties_set_int64( mlt_properties self, const char *name, int64_t value ) { int error = 1; // Fetch the property to work with - mlt_property property = mlt_properties_fetch( this, name ); + mlt_property property = mlt_properties_fetch( self, name ); // Set it if not NULL if ( property != NULL ) { error = mlt_property_set_int64( property, value ); - mlt_properties_do_mirror( this, name ); + mlt_properties_do_mirror( self, name ); } - mlt_events_fire( this, "property-changed", name, NULL ); + mlt_events_fire( self, "property-changed", name, NULL ); return error; } @@ -794,41 +794,41 @@ int mlt_properties_set_int64( mlt_properties this, const char *name, int64_t val /** Get a floating point value associated to the name. * * \public \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \param name the property to get * \return the floating point, 0 if not found (which may also be a legitimate value) */ -double mlt_properties_get_double( mlt_properties this, const char *name ) +double mlt_properties_get_double( mlt_properties self, const char *name ) { - mlt_property value = mlt_properties_find( this, name ); + mlt_property value = mlt_properties_find( self, name ); return value == NULL ? 0 : mlt_property_get_double( value ); } /** Set a property to a floating point value. * * \public \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \param name the property to set * \param value the floating point value * \return true if error */ -int mlt_properties_set_double( mlt_properties this, const char *name, double value ) +int mlt_properties_set_double( mlt_properties self, const char *name, double value ) { int error = 1; // Fetch the property to work with - mlt_property property = mlt_properties_fetch( this, name ); + mlt_property property = mlt_properties_fetch( self, name ); // Set it if not NULL if ( property != NULL ) { error = mlt_property_set_double( property, value ); - mlt_properties_do_mirror( this, name ); + mlt_properties_do_mirror( self, name ); } - mlt_events_fire( this, "property-changed", name, NULL ); + mlt_events_fire( self, "property-changed", name, NULL ); return error; } @@ -836,41 +836,41 @@ int mlt_properties_set_double( mlt_properties this, const char *name, double val /** Get a position value associated to the name. * * \public \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \param name the property to get * \return the position, 0 if not found (which may also be a legitimate value) */ -mlt_position mlt_properties_get_position( mlt_properties this, const char *name ) +mlt_position mlt_properties_get_position( mlt_properties self, const char *name ) { - mlt_property value = mlt_properties_find( this, name ); + mlt_property value = mlt_properties_find( self, name ); return value == NULL ? 0 : mlt_property_get_position( value ); } /** Set a property to a position value. * * \public \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \param name the property to get * \param value the position * \return true if error */ -int mlt_properties_set_position( mlt_properties this, const char *name, mlt_position value ) +int mlt_properties_set_position( mlt_properties self, const char *name, mlt_position value ) { int error = 1; // Fetch the property to work with - mlt_property property = mlt_properties_fetch( this, name ); + mlt_property property = mlt_properties_fetch( self, name ); // Set it if not NULL if ( property != NULL ) { error = mlt_property_set_position( property, value ); - mlt_properties_do_mirror( this, name ); + mlt_properties_do_mirror( self, name ); } - mlt_events_fire( this, "property-changed", name, NULL ); + mlt_events_fire( self, "property-changed", name, NULL ); return error; } @@ -880,21 +880,21 @@ int mlt_properties_set_position( mlt_properties this, const char *name, mlt_posi * Do not free the returned pointer if you supplied a destructor function * when you set this property. * \public \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \param name the property to get * \param[out] length The size of the binary data in bytes, if available (often it is not, you should know) */ -void *mlt_properties_get_data( mlt_properties this, const char *name, int *length ) +void *mlt_properties_get_data( mlt_properties self, const char *name, int *length ) { - mlt_property value = mlt_properties_find( this, name ); + mlt_property value = mlt_properties_find( self, name ); return value == NULL ? NULL : mlt_property_get_data( value, length ); } /** Store binary data as a property. * * \public \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \param name the property to set * \param value an opaque pointer to binary data * \param length the size of the binary data in bytes (optional) @@ -903,18 +903,18 @@ void *mlt_properties_get_data( mlt_properties this, const char *name, int *lengt * \return true if error */ -int mlt_properties_set_data( mlt_properties this, const char *name, void *value, int length, mlt_destructor destroy, mlt_serialiser serialise ) +int mlt_properties_set_data( mlt_properties self, const char *name, void *value, int length, mlt_destructor destroy, mlt_serialiser serialise ) { int error = 1; // Fetch the property to work with - mlt_property property = mlt_properties_fetch( this, name ); + mlt_property property = mlt_properties_fetch( self, name ); // Set it if not NULL if ( property != NULL ) error = mlt_property_set_data( property, value, length, destroy, serialise ); - mlt_events_fire( this, "property-changed", name, NULL ); + mlt_events_fire( self, "property-changed", name, NULL ); return error; } @@ -922,19 +922,19 @@ int mlt_properties_set_data( mlt_properties this, const char *name, void *value, /** Rename a property. * * \public \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \param source the property to rename * \param dest the new name * \return true if the name is already in use */ -int mlt_properties_rename( mlt_properties this, const char *source, const char *dest ) +int mlt_properties_rename( mlt_properties self, const char *source, const char *dest ) { - mlt_property value = mlt_properties_find( this, dest ); + mlt_property value = mlt_properties_find( self, dest ); if ( value == NULL ) { - property_list *list = this->local; + property_list *list = self->local; int i = 0; // Locate the item @@ -956,41 +956,41 @@ int mlt_properties_rename( mlt_properties this, const char *source, const char * /** Dump the properties to a file handle. * * \public \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \param output a file handle */ -void mlt_properties_dump( mlt_properties this, FILE *output ) +void mlt_properties_dump( mlt_properties self, FILE *output ) { - property_list *list = this->local; + property_list *list = self->local; int i = 0; for ( i = 0; i < list->count; i ++ ) - if ( mlt_properties_get( this, list->name[ i ] ) != NULL ) - fprintf( output, "%s=%s\n", list->name[ i ], mlt_properties_get( this, list->name[ i ] ) ); + if ( mlt_properties_get( self, list->name[ i ] ) != NULL ) + fprintf( output, "%s=%s\n", list->name[ i ], mlt_properties_get( self, list->name[ i ] ) ); } /** Output the properties to a file handle. * * This version includes reference counts and does not put each property on a new line. * \public \memberof mlt_properties_s - * \param this a properties pointer + * \param self a properties pointer * \param title a string to preface the output * \param output a file handle */ -void mlt_properties_debug( mlt_properties this, const char *title, FILE *output ) +void mlt_properties_debug( mlt_properties self, const char *title, FILE *output ) { if ( output == NULL ) output = stderr; fprintf( output, "%s: ", title ); - if ( this != NULL ) + if ( self != NULL ) { - property_list *list = this->local; + property_list *list = self->local; int i = 0; fprintf( output, "[ ref=%d", list->ref_count ); for ( i = 0; i < list->count; i ++ ) - if ( mlt_properties_get( this, list->name[ i ] ) != NULL ) - fprintf( output, ", %s=%s", list->name[ i ], mlt_properties_get( this, list->name[ i ] ) ); + if ( mlt_properties_get( self, list->name[ i ] ) != NULL ) + fprintf( output, ", %s=%s", list->name[ i ], mlt_properties_get( self, list->name[ i ] ) ); else - fprintf( output, ", %s=%p", list->name[ i ], mlt_properties_get_data( this, list->name[ i ], NULL ) ); + fprintf( output, ", %s=%p", list->name[ i ], mlt_properties_get_data( self, list->name[ i ], NULL ) ); fprintf( output, " ]" ); } fprintf( output, "\n" ); @@ -1000,18 +1000,18 @@ void mlt_properties_debug( mlt_properties this, const char *title, FILE *output * * This uses the dump format - one line per property. * \public \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \param filename the name of a file to create or overwrite * \return true if there was an error */ -int mlt_properties_save( mlt_properties this, const char *filename ) +int mlt_properties_save( mlt_properties self, const char *filename ) { int error = 1; FILE *f = fopen( filename, "w" ); if ( f != NULL ) { - mlt_properties_dump( this, f ); + mlt_properties_dump( self, f ); fclose( f ); error = 0; } @@ -1066,14 +1066,14 @@ static int mlt_fnmatch( const char *wild, const char *file ) /** Compare the string or serialized value of two properties. * * \private \memberof mlt_properties_s - * \param this a property + * \param self a property * \param that a property - * \return < 0 if 'this' less than 'that', 0 if equal, or > 0 if 'this' is greater than 'that' + * \return < 0 if \p self less than \p that, 0 if equal, or > 0 if \p self is greater than \p that */ -static int mlt_compare( const void *this, const void *that ) +static int mlt_compare( const void *self, const void *that ) { - return strcmp( mlt_property_get_string( *( const mlt_property * )this ), mlt_property_get_string( *( const mlt_property * )that ) ); + return strcmp( mlt_property_get_string( *( const mlt_property * )self ), mlt_property_get_string( *( const mlt_property * )that ) ); } /** Get the contents of a directory. @@ -1082,14 +1082,14 @@ static int mlt_compare( const void *this, const void *that ) * Entries in the list have a numeric name (running from 0 to count - 1). Only values change * position if sort is enabled. Designed to be posix compatible (linux, os/x, mingw etc). * \public \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \param dirname the name of the directory * \param pattern a wildcard pattern to filter the directory listing * \param sort Do you want to sort the directory listing? * \return the number of items in the directory listing */ -int mlt_properties_dir_list( mlt_properties this, const char *dirname, const char *pattern, int sort ) +int mlt_properties_dir_list( mlt_properties self, const char *dirname, const char *pattern, int sort ) { DIR *dir = opendir( dirname ); @@ -1100,50 +1100,50 @@ int mlt_properties_dir_list( mlt_properties this, const char *dirname, const cha char fullname[ 1024 ]; while( de != NULL ) { - sprintf( key, "%d", mlt_properties_count( this ) ); + sprintf( key, "%d", mlt_properties_count( self ) ); snprintf( fullname, 1024, "%s/%s", dirname, de->d_name ); if ( pattern == NULL ) - mlt_properties_set( this, key, fullname ); + mlt_properties_set( self, key, fullname ); else if ( de->d_name[ 0 ] != '.' && mlt_fnmatch( pattern, de->d_name ) ) - mlt_properties_set( this, key, fullname ); + mlt_properties_set( self, key, fullname ); de = readdir( dir ); } closedir( dir ); } - if ( sort && mlt_properties_count( this ) ) + if ( sort && mlt_properties_count( self ) ) { - property_list *list = this->local; - qsort( list->value, mlt_properties_count( this ), sizeof( mlt_property ), mlt_compare ); + property_list *list = self->local; + qsort( list->value, mlt_properties_count( self ), sizeof( mlt_property ), mlt_compare ); } - return mlt_properties_count( this ); + return mlt_properties_count( self ); } /** Close a properties object. * * Deallocates the properties object and everything it contains. * \public \memberof mlt_properties_s - * \param this a properties object + * \param self a properties object */ -void mlt_properties_close( mlt_properties this ) +void mlt_properties_close( mlt_properties self ) { - if ( this != NULL && mlt_properties_dec_ref( this ) <= 0 ) + if ( self != NULL && mlt_properties_dec_ref( self ) <= 0 ) { - if ( this->close != NULL ) + if ( self->close != NULL ) { - this->close( this->close_object ); + self->close( self->close_object ); } else { - property_list *list = this->local; + property_list *list = self->local; int index = 0; #if _MLT_PROPERTY_CHECKS_ == 1 // Show debug info - mlt_properties_debug( this, "Closing", stderr ); + mlt_properties_debug( self, "Closing", stderr ); #endif #ifdef _MLT_PROPERTY_CHECKS_ @@ -1167,9 +1167,9 @@ void mlt_properties_close( mlt_properties this ) free( list->value ); free( list ); - // Free this now if this has no child - if ( this->child == NULL ) - free( this ); + // Free self now if self has no child + if ( self->child == NULL ) + free( self ); } } } @@ -1480,9 +1480,9 @@ static int parse_yaml( yaml_parser context, const char *namevalue ) mlt_properties mlt_properties_parse_yaml( const char *filename ) { // Construct a standalone properties object - mlt_properties this = mlt_properties_new( ); + mlt_properties self = mlt_properties_new( ); - if ( this ) + if ( self ) { // Open the file FILE *file = fopen( filename, "r" ); @@ -1497,7 +1497,7 @@ mlt_properties mlt_properties_parse_yaml( const char *filename ) // Parser context yaml_parser context = calloc( 1, sizeof( struct yaml_parser_context ) ); context->stack = mlt_deque_init(); - mlt_deque_push_front( context->stack, this ); + mlt_deque_push_front( context->stack, self ); // Read each string from the file while( fgets( temp, 1024, file ) ) @@ -1525,7 +1525,7 @@ mlt_properties mlt_properties_parse_yaml( const char *filename ) } // Return the pointer - return this; + return self; } /* @@ -1647,15 +1647,15 @@ static void output_yaml_block_literal( strbuf output, const char *value, int ind /** Recursively serialize a properties list into a string buffer as YAML Tiny. * * \private \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \param output a string buffer to hold the serialized YAML Tiny * \param indent the number of spaces to indent (for recursion, initialize to 0) - * \param is_parent_sequence Is 'this' properties list really just a sequence (for recursion, initialize to 0)? + * \param is_parent_sequence Is this properties list really just a sequence (for recursion, initialize to 0)? */ -static void serialise_yaml( mlt_properties this, strbuf output, int indent, int is_parent_sequence ) +static void serialise_yaml( mlt_properties self, strbuf output, int indent, int is_parent_sequence ) { - property_list *list = this->local; + property_list *list = self->local; int i = 0; for ( i = 0; i < list->count; i ++ ) @@ -1664,7 +1664,7 @@ static void serialise_yaml( mlt_properties this, strbuf output, int indent, int // Unfortunately, we do not have run time type identification. mlt_properties child = mlt_property_get_data( list->value[ i ], NULL ); - if ( mlt_properties_is_sequence( this ) ) + if ( mlt_properties_is_sequence( self ) ) { // Ignore hidden/non-serialisable items if ( list->name[ i ][ 0 ] != '_' ) @@ -1674,7 +1674,7 @@ static void serialise_yaml( mlt_properties this, strbuf output, int indent, int strbuf_printf( output, "- " ); // If the value can be represented as a string - const char *value = mlt_properties_get( this, list->name[ i ] ); + const char *value = mlt_properties_get( self, list->name[ i ] ); if ( value && strcmp( value, "" ) ) { // Determine if this is an unfolded block literal @@ -1696,7 +1696,7 @@ static void serialise_yaml( mlt_properties this, strbuf output, int indent, int else { // Assume this is a normal map-oriented properties list - const char *value = mlt_properties_get( this, list->name[ i ] ); + const char *value = mlt_properties_get( self, list->name[ i ] ); // Ignore hidden/non-serialisable items // If the value can be represented as a string @@ -1738,15 +1738,15 @@ static void serialise_yaml( mlt_properties this, strbuf output, int indent, int * This operates on properties containing properties as a hierarchical data * structure. * \public \memberof mlt_properties_s - * \param this a properties list + * \param self a properties list * \return a string containing YAML Tiny that represents the properties list */ -char *mlt_properties_serialise_yaml( mlt_properties this ) +char *mlt_properties_serialise_yaml( mlt_properties self ) { strbuf b = strbuf_new(); strbuf_printf( b, "---\n" ); - serialise_yaml( this, b, 0, 0 ); + serialise_yaml( self, b, 0, 0 ); strbuf_printf( b, "...\n" ); char *ret = b->string; strbuf_close( b ); diff --git a/src/framework/mlt_property.c b/src/framework/mlt_property.c index ec6b1671..7334e975 100644 --- a/src/framework/mlt_property.c +++ b/src/framework/mlt_property.c @@ -76,82 +76,82 @@ struct mlt_property_s mlt_property mlt_property_init( ) { - mlt_property this = malloc( sizeof( struct mlt_property_s ) ); - if ( this != NULL ) + mlt_property self = malloc( sizeof( struct mlt_property_s ) ); + if ( self != NULL ) { - this->types = 0; - this->prop_int = 0; - this->prop_position = 0; - this->prop_double = 0; - this->prop_int64 = 0; - this->prop_string = NULL; - this->data = NULL; - this->length = 0; - this->destructor = NULL; - this->serialiser = NULL; + self->types = 0; + self->prop_int = 0; + self->prop_position = 0; + self->prop_double = 0; + self->prop_int64 = 0; + self->prop_string = NULL; + self->data = NULL; + self->length = 0; + self->destructor = NULL; + self->serialiser = NULL; } - return this; + return self; } /** Clear (0/null) a property. * * Frees up any associated resources in the process. * \private \memberof mlt_property_s - * \param this a property + * \param self a property */ -static inline void mlt_property_clear( mlt_property this ) +static inline void mlt_property_clear( mlt_property self ) { // Special case data handling - if ( this->types & mlt_prop_data && this->destructor != NULL ) - this->destructor( this->data ); + if ( self->types & mlt_prop_data && self->destructor != NULL ) + self->destructor( self->data ); // Special case string handling - if ( this->types & mlt_prop_string ) - free( this->prop_string ); + if ( self->types & mlt_prop_string ) + free( self->prop_string ); // Wipe stuff - this->types = 0; - this->prop_int = 0; - this->prop_position = 0; - this->prop_double = 0; - this->prop_int64 = 0; - this->prop_string = NULL; - this->data = NULL; - this->length = 0; - this->destructor = NULL; - this->serialiser = NULL; + self->types = 0; + self->prop_int = 0; + self->prop_position = 0; + self->prop_double = 0; + self->prop_int64 = 0; + self->prop_string = NULL; + self->data = NULL; + self->length = 0; + self->destructor = NULL; + self->serialiser = NULL; } /** Set the property to an integer value. * * \public \memberof mlt_property_s - * \param this a property + * \param self a property * \param value an integer * \return false */ -int mlt_property_set_int( mlt_property this, int value ) +int mlt_property_set_int( mlt_property self, int value ) { - mlt_property_clear( this ); - this->types = mlt_prop_int; - this->prop_int = value; + mlt_property_clear( self ); + self->types = mlt_prop_int; + self->prop_int = value; return 0; } /** Set the property to a floating point value. * * \public \memberof mlt_property_s - * \param this a property + * \param self a property * \param value a double precision floating point value * \return false */ -int mlt_property_set_double( mlt_property this, double value ) +int mlt_property_set_double( mlt_property self, double value ) { - mlt_property_clear( this ); - this->types = mlt_prop_double; - this->prop_double = value; + mlt_property_clear( self ); + self->types = mlt_prop_double; + self->prop_double = value; return 0; } @@ -159,16 +159,16 @@ int mlt_property_set_double( mlt_property this, double value ) * * Position is a relative time value in frame units. * \public \memberof mlt_property_s - * \param this a property + * \param self a property * \param value a position value * \return false */ -int mlt_property_set_position( mlt_property this, mlt_position value ) +int mlt_property_set_position( mlt_property self, mlt_position value ) { - mlt_property_clear( this ); - this->types = mlt_prop_position; - this->prop_position = value; + mlt_property_clear( self ); + self->types = mlt_prop_position; + self->prop_position = value; return 0; } @@ -177,40 +177,40 @@ int mlt_property_set_position( mlt_property this, mlt_position value ) * This makes a copy of the string you supply so you do not need to track * a new reference to it. * \public \memberof mlt_property_s - * \param this a property + * \param self a property * \param value the string to copy to the property * \return true if it failed */ -int mlt_property_set_string( mlt_property this, const char *value ) +int mlt_property_set_string( mlt_property self, const char *value ) { - if ( value != this->prop_string ) + if ( value != self->prop_string ) { - mlt_property_clear( this ); - this->types = mlt_prop_string; + mlt_property_clear( self ); + self->types = mlt_prop_string; if ( value != NULL ) - this->prop_string = strdup( value ); + self->prop_string = strdup( value ); } else { - this->types = mlt_prop_string; + self->types = mlt_prop_string; } - return this->prop_string == NULL; + return self->prop_string == NULL; } /** Set the property to a 64-bit integer value. * * \public \memberof mlt_property_s - * \param this a property + * \param self a property * \param value a 64-bit integer * \return false */ -int mlt_property_set_int64( mlt_property this, int64_t value ) +int mlt_property_set_int64( mlt_property self, int64_t value ) { - mlt_property_clear( this ); - this->types = mlt_prop_int64; - this->prop_int64 = value; + mlt_property_clear( self ); + self->types = mlt_prop_int64; + self->prop_int64 = value; return 0; } @@ -221,7 +221,7 @@ int mlt_property_set_int64( mlt_property this, int64_t value ) * the lifetime of the data. Otherwise, pass NULL for the destructor * function and control the lifetime yourself. * \public \memberof mlt_property_s - * \param this a property + * \param self a property * \param value an opaque pointer * \param length the number of bytes pointed to by value (optional) * \param destructor a function to use to destroy this binary data (optional, assuming you manage the resource) @@ -229,16 +229,16 @@ int mlt_property_set_int64( mlt_property this, int64_t value ) * \return false */ -int mlt_property_set_data( mlt_property this, void *value, int length, mlt_destructor destructor, mlt_serialiser serialiser ) +int mlt_property_set_data( mlt_property self, void *value, int length, mlt_destructor destructor, mlt_serialiser serialiser ) { - if ( this->data == value ) - this->destructor = NULL; - mlt_property_clear( this ); - this->types = mlt_prop_data; - this->data = value; - this->length = length; - this->destructor = destructor; - this->serialiser = serialiser; + if ( self->data == value ) + self->destructor = NULL; + mlt_property_clear( self ); + self->types = mlt_prop_data; + self->data = value; + self->length = length; + self->destructor = destructor; + self->serialiser = serialiser; return 0; } @@ -285,44 +285,44 @@ static inline int mlt_property_atoi( const char *value ) /** Get the property as an integer. * * \public \memberof mlt_property_s - * \param this a property + * \param self a property * \return an integer value */ -int mlt_property_get_int( mlt_property this ) +int mlt_property_get_int( mlt_property self ) { - if ( this->types & mlt_prop_int ) - return this->prop_int; - else if ( this->types & mlt_prop_double ) - return ( int )this->prop_double; - else if ( this->types & mlt_prop_position ) - return ( int )this->prop_position; - else if ( this->types & mlt_prop_int64 ) - return ( int )this->prop_int64; - else if ( ( this->types & mlt_prop_string ) && this->prop_string ) - return mlt_property_atoi( this->prop_string ); + if ( self->types & mlt_prop_int ) + return self->prop_int; + else if ( self->types & mlt_prop_double ) + return ( int )self->prop_double; + else if ( self->types & mlt_prop_position ) + return ( int )self->prop_position; + else if ( self->types & mlt_prop_int64 ) + return ( int )self->prop_int64; + else if ( ( self->types & mlt_prop_string ) && self->prop_string ) + return mlt_property_atoi( self->prop_string ); return 0; } /** Get the property as a floating point. * * \public \memberof mlt_property_s - * \param this a property + * \param self a property * \return a floating point value */ -double mlt_property_get_double( mlt_property this ) +double mlt_property_get_double( mlt_property self ) { - if ( this->types & mlt_prop_double ) - return this->prop_double; - else if ( this->types & mlt_prop_int ) - return ( double )this->prop_int; - else if ( this->types & mlt_prop_position ) - return ( double )this->prop_position; - else if ( this->types & mlt_prop_int64 ) - return ( double )this->prop_int64; - else if ( ( this->types & mlt_prop_string ) && this->prop_string ) - return atof( this->prop_string ); + if ( self->types & mlt_prop_double ) + return self->prop_double; + else if ( self->types & mlt_prop_int ) + return ( double )self->prop_int; + else if ( self->types & mlt_prop_position ) + return ( double )self->prop_position; + else if ( self->types & mlt_prop_int64 ) + return ( double )self->prop_int64; + else if ( ( self->types & mlt_prop_string ) && self->prop_string ) + return atof( self->prop_string ); return 0; } @@ -330,22 +330,22 @@ double mlt_property_get_double( mlt_property this ) * * A position is an offset time in terms of frame units. * \public \memberof mlt_property_s - * \param this a property + * \param self a property * \return the position in frames */ -mlt_position mlt_property_get_position( mlt_property this ) +mlt_position mlt_property_get_position( mlt_property self ) { - if ( this->types & mlt_prop_position ) - return this->prop_position; - else if ( this->types & mlt_prop_int ) - return ( mlt_position )this->prop_int; - else if ( this->types & mlt_prop_double ) - return ( mlt_position )this->prop_double; - else if ( this->types & mlt_prop_int64 ) - return ( mlt_position )this->prop_int64; - else if ( ( this->types & mlt_prop_string ) && this->prop_string ) - return ( mlt_position )atol( this->prop_string ); + if ( self->types & mlt_prop_position ) + return self->prop_position; + else if ( self->types & mlt_prop_int ) + return ( mlt_position )self->prop_int; + else if ( self->types & mlt_prop_double ) + return ( mlt_position )self->prop_double; + else if ( self->types & mlt_prop_int64 ) + return ( mlt_position )self->prop_int64; + else if ( ( self->types & mlt_prop_string ) && self->prop_string ) + return ( mlt_position )atol( self->prop_string ); return 0; } @@ -370,22 +370,22 @@ static inline int64_t mlt_property_atoll( const char *value ) /** Get the property as a signed integer. * * \public \memberof mlt_property_s - * \param this a property + * \param self a property * \return a 64-bit integer */ -int64_t mlt_property_get_int64( mlt_property this ) +int64_t mlt_property_get_int64( mlt_property self ) { - if ( this->types & mlt_prop_int64 ) - return this->prop_int64; - else if ( this->types & mlt_prop_int ) - return ( int64_t )this->prop_int; - else if ( this->types & mlt_prop_double ) - return ( int64_t )this->prop_double; - else if ( this->types & mlt_prop_position ) - return ( int64_t )this->prop_position; - else if ( ( this->types & mlt_prop_string ) && this->prop_string ) - return mlt_property_atoll( this->prop_string ); + if ( self->types & mlt_prop_int64 ) + return self->prop_int64; + else if ( self->types & mlt_prop_int ) + return ( int64_t )self->prop_int; + else if ( self->types & mlt_prop_double ) + return ( int64_t )self->prop_double; + else if ( self->types & mlt_prop_position ) + return ( int64_t )self->prop_position; + else if ( ( self->types & mlt_prop_string ) && self->prop_string ) + return mlt_property_atoll( self->prop_string ); return 0; } @@ -396,48 +396,48 @@ int64_t mlt_property_get_int64( mlt_property this ) * This tries its hardest to convert the property to string including using * a serialization function for binary data, if supplied. * \public \memberof mlt_property_s - * \param this a property + * \param self a property * \return a string representation of the property or NULL if failed */ -char *mlt_property_get_string( mlt_property this ) +char *mlt_property_get_string( mlt_property self ) { // Construct a string if need be - if ( ! ( this->types & mlt_prop_string ) ) + if ( ! ( self->types & mlt_prop_string ) ) { - if ( this->types & mlt_prop_int ) + if ( self->types & mlt_prop_int ) { - this->types |= mlt_prop_string; - this->prop_string = malloc( 32 ); - sprintf( this->prop_string, "%d", this->prop_int ); + self->types |= mlt_prop_string; + self->prop_string = malloc( 32 ); + sprintf( self->prop_string, "%d", self->prop_int ); } - else if ( this->types & mlt_prop_double ) + else if ( self->types & mlt_prop_double ) { - this->types |= mlt_prop_string; - this->prop_string = malloc( 32 ); - sprintf( this->prop_string, "%f", this->prop_double ); + self->types |= mlt_prop_string; + self->prop_string = malloc( 32 ); + sprintf( self->prop_string, "%f", self->prop_double ); } - else if ( this->types & mlt_prop_position ) + else if ( self->types & mlt_prop_position ) { - this->types |= mlt_prop_string; - this->prop_string = malloc( 32 ); - sprintf( this->prop_string, "%d", (int)this->prop_position ); /* I don't know if this is wanted. -Zach */ + self->types |= mlt_prop_string; + self->prop_string = malloc( 32 ); + sprintf( self->prop_string, "%d", (int)self->prop_position ); /* I don't know if self is wanted. -Zach */ } - else if ( this->types & mlt_prop_int64 ) + else if ( self->types & mlt_prop_int64 ) { - this->types |= mlt_prop_string; - this->prop_string = malloc( 32 ); - sprintf( this->prop_string, "%lld", (long long int)this->prop_int64 ); + self->types |= mlt_prop_string; + self->prop_string = malloc( 32 ); + sprintf( self->prop_string, "%lld", (long long int)self->prop_int64 ); } - else if ( this->types & mlt_prop_data && this->serialiser != NULL ) + else if ( self->types & mlt_prop_data && self->serialiser != NULL ) { - this->types |= mlt_prop_string; - this->prop_string = this->serialiser( this->data, this->length ); + self->types |= mlt_prop_string; + self->prop_string = self->serialiser( self->data, self->length ); } } // Return the string (may be NULL) - return this->prop_string; + return self->prop_string; } /** Get the binary data from a property. @@ -449,31 +449,31 @@ char *mlt_property_get_string( mlt_property this ) * Therefore, only free the returned pointer if you did not supply a * destructor function. * \public \memberof mlt_property_s - * \param this a property + * \param self a property * \param[out] length the size of the binary object in bytes (optional) * \return an opaque data pointer or NULL if not available */ -void *mlt_property_get_data( mlt_property this, int *length ) +void *mlt_property_get_data( mlt_property self, int *length ) { // Assign length if not NULL if ( length != NULL ) - *length = this->length; + *length = self->length; // Return the data (note: there is no conversion here) - return this->data; + return self->data; } /** Destroy a property and free all related resources. * * \public \memberof mlt_property_s - * \param this a property + * \param self a property */ -void mlt_property_close( mlt_property this ) +void mlt_property_close( mlt_property self ) { - mlt_property_clear( this ); - free( this ); + mlt_property_clear( self ); + free( self ); } /** Copy a property. @@ -482,31 +482,31 @@ void mlt_property_close( mlt_property this ) * function was supplied when you set the Property. * \public \memberof mlt_property_s * \author Zach - * \param this a property + * \param self a property * \param that another property */ -void mlt_property_pass( mlt_property this, mlt_property that ) +void mlt_property_pass( mlt_property self, mlt_property that ) { - mlt_property_clear( this ); - - this->types = that->types; - - if ( this->types & mlt_prop_int64 ) - this->prop_int64 = that->prop_int64; - else if ( this->types & mlt_prop_int ) - this->prop_int = that->prop_int; - else if ( this->types & mlt_prop_double ) - this->prop_double = that->prop_double; - else if ( this->types & mlt_prop_position ) - this->prop_position = that->prop_position; - else if ( this->types & mlt_prop_string ) + mlt_property_clear( self ); + + self->types = that->types; + + if ( self->types & mlt_prop_int64 ) + self->prop_int64 = that->prop_int64; + else if ( self->types & mlt_prop_int ) + self->prop_int = that->prop_int; + else if ( self->types & mlt_prop_double ) + self->prop_double = that->prop_double; + else if ( self->types & mlt_prop_position ) + self->prop_position = that->prop_position; + else if ( self->types & mlt_prop_string ) { if ( that->prop_string != NULL ) - this->prop_string = strdup( that->prop_string ); + self->prop_string = strdup( that->prop_string ); } - else if ( this->types & mlt_prop_data && this->serialiser != NULL ) + else if ( self->types & mlt_prop_data && self->serialiser != NULL ) { - this->types = mlt_prop_string; - this->prop_string = this->serialiser( this->data, this->length ); + self->types = mlt_prop_string; + self->prop_string = self->serialiser( self->data, self->length ); } } diff --git a/src/framework/mlt_property.h b/src/framework/mlt_property.h index f33aa882..ecc9f4ee 100644 --- a/src/framework/mlt_property.h +++ b/src/framework/mlt_property.h @@ -41,6 +41,6 @@ extern char *mlt_property_get_string( mlt_property self ); extern void *mlt_property_get_data( mlt_property self, int *length ); extern void mlt_property_close( mlt_property self ); -extern void mlt_property_pass( mlt_property this, mlt_property that ); +extern void mlt_property_pass( mlt_property self, mlt_property that ); #endif diff --git a/src/framework/mlt_repository.c b/src/framework/mlt_repository.c index c843ecb2..3d75bcbe 100644 --- a/src/framework/mlt_repository.c +++ b/src/framework/mlt_repository.c @@ -63,12 +63,12 @@ mlt_repository mlt_repository_init( const char *directory ) return NULL; // Construct the repository - mlt_repository this = calloc( sizeof( struct mlt_repository_s ), 1 ); - mlt_properties_init( &this->parent, this ); - this->consumers = mlt_properties_new(); - this->filters = mlt_properties_new(); - this->producers = mlt_properties_new(); - this->transitions = mlt_properties_new(); + mlt_repository self = calloc( sizeof( struct mlt_repository_s ), 1 ); + mlt_properties_init( &self->parent, self ); + self->consumers = mlt_properties_new(); + self->filters = mlt_properties_new(); + self->producers = mlt_properties_new(); + self->transitions = mlt_properties_new(); // Get the directory list mlt_properties dir = mlt_properties_new(); @@ -96,10 +96,10 @@ mlt_repository mlt_repository_init( const char *directory ) // Call the registration function if ( symbol_ptr != NULL ) { - symbol_ptr( this ); + symbol_ptr( self ); // Register the object file for closure - mlt_properties_set_data( &this->parent, object_name, object, 0, ( mlt_destructor )dlclose, NULL ); + mlt_properties_set_data( &self->parent, object_name, object, 0, ( mlt_destructor )dlclose, NULL ); } else { @@ -114,7 +114,7 @@ mlt_repository mlt_repository_init( const char *directory ) mlt_properties_close( dir ); - return this; + return self; } /** Create a properties list for a service holding a function pointer to its constructor function. @@ -136,28 +136,28 @@ static mlt_properties new_service( void *symbol ) * Typically, this is invoked by a module within its mlt_register(). * * \public \memberof mlt_repository_s - * \param this a repository + * \param self a repository * \param service_type a service class * \param service the name of a service * \param symbol a pointer to a function to create the service */ -void mlt_repository_register( mlt_repository this, mlt_service_type service_type, const char *service, mlt_register_callback symbol ) +void mlt_repository_register( mlt_repository self, mlt_service_type service_type, const char *service, mlt_register_callback symbol ) { // Add the entry point to the corresponding service list switch ( service_type ) { case consumer_type: - mlt_properties_set_data( this->consumers, service, new_service( symbol ), 0, ( mlt_destructor )mlt_properties_close, NULL ); + mlt_properties_set_data( self->consumers, service, new_service( symbol ), 0, ( mlt_destructor )mlt_properties_close, NULL ); break; case filter_type: - mlt_properties_set_data( this->filters, service, new_service( symbol ), 0, ( mlt_destructor )mlt_properties_close, NULL ); + mlt_properties_set_data( self->filters, service, new_service( symbol ), 0, ( mlt_destructor )mlt_properties_close, NULL ); break; case producer_type: - mlt_properties_set_data( this->producers, service, new_service( symbol ), 0, ( mlt_destructor )mlt_properties_close, NULL ); + mlt_properties_set_data( self->producers, service, new_service( symbol ), 0, ( mlt_destructor )mlt_properties_close, NULL ); break; case transition_type: - mlt_properties_set_data( this->transitions, service, new_service( symbol ), 0, ( mlt_destructor )mlt_properties_close, NULL ); + mlt_properties_set_data( self->transitions, service, new_service( symbol ), 0, ( mlt_destructor )mlt_properties_close, NULL ); break; default: break; @@ -167,13 +167,13 @@ void mlt_repository_register( mlt_repository this, mlt_service_type service_type /** Get the repository properties for particular service class. * * \private \memberof mlt_repository_s - * \param this a repository + * \param self a repository * \param type a service class * \param service the name of a service * \return a properties list or NULL if error */ -static mlt_properties get_service_properties( mlt_repository this, mlt_service_type type, const char *service ) +static mlt_properties get_service_properties( mlt_repository self, mlt_service_type type, const char *service ) { mlt_properties service_properties = NULL; @@ -181,16 +181,16 @@ static mlt_properties get_service_properties( mlt_repository this, mlt_service_t switch ( type ) { case consumer_type: - service_properties = mlt_properties_get_data( this->consumers, service, NULL ); + service_properties = mlt_properties_get_data( self->consumers, service, NULL ); break; case filter_type: - service_properties = mlt_properties_get_data( this->filters, service, NULL ); + service_properties = mlt_properties_get_data( self->filters, service, NULL ); break; case producer_type: - service_properties = mlt_properties_get_data( this->producers, service, NULL ); + service_properties = mlt_properties_get_data( self->producers, service, NULL ); break; case transition_type: - service_properties = mlt_properties_get_data( this->transitions, service, NULL ); + service_properties = mlt_properties_get_data( self->transitions, service, NULL ); break; default: break; @@ -201,16 +201,16 @@ static mlt_properties get_service_properties( mlt_repository this, mlt_service_t /** Construct a new instance of a service. * * \public \memberof mlt_repository_s - * \param this a repository + * \param self a repository * \param profile a \p mlt_profile to give the service * \param type a service class * \param service the name of the service * \param input an optional argument to the service constructor */ -void *mlt_repository_create( mlt_repository this, mlt_profile profile, mlt_service_type type, const char *service, const void *input ) +void *mlt_repository_create( mlt_repository self, mlt_profile profile, mlt_service_type type, const char *service, const void *input ) { - mlt_properties properties = get_service_properties( this, type, service ); + mlt_properties properties = get_service_properties( self, type, service ); if ( properties != NULL ) { mlt_register_callback symbol_ptr = mlt_properties_get_data( properties, "symbol", NULL ); @@ -224,17 +224,17 @@ void *mlt_repository_create( mlt_repository this, mlt_profile profile, mlt_servi /** Destroy a repository and free its resources. * * \public \memberof mlt_repository_s - * \param this a repository + * \param self a repository */ -void mlt_repository_close( mlt_repository this ) +void mlt_repository_close( mlt_repository self ) { - mlt_properties_close( this->consumers ); - mlt_properties_close( this->filters ); - mlt_properties_close( this->producers ); - mlt_properties_close( this->transitions ); - mlt_properties_close( &this->parent ); - free( this ); + mlt_properties_close( self->consumers ); + mlt_properties_close( self->filters ); + mlt_properties_close( self->producers ); + mlt_properties_close( self->transitions ); + mlt_properties_close( &self->parent ); + free( self ); } /** Get the list of registered consumers. diff --git a/src/framework/mlt_service.c b/src/framework/mlt_service.c index c9f781f2..e07a29a3 100644 --- a/src/framework/mlt_service.c +++ b/src/framework/mlt_service.c @@ -63,46 +63,46 @@ mlt_service_base; /* Private methods */ -static void mlt_service_disconnect( mlt_service this ); -static void mlt_service_connect( mlt_service this, mlt_service that ); -static int service_get_frame( mlt_service this, mlt_frame_ptr frame, int index ); -static void mlt_service_property_changed( mlt_listener, mlt_properties owner, mlt_service this, void **args ); +static void mlt_service_disconnect( mlt_service self ); +static void mlt_service_connect( mlt_service self, mlt_service that ); +static int service_get_frame( mlt_service self, mlt_frame_ptr frame, int index ); +static void mlt_service_property_changed( mlt_listener, mlt_properties owner, mlt_service self, void **args ); /** Initialize a service. * * \public \memberof mlt_service_s - * \param this the service structure to initialize + * \param self the service structure to initialize * \param child pointer to the child object for the subclass * \return true if there was an error */ -int mlt_service_init( mlt_service this, void *child ) +int mlt_service_init( mlt_service self, void *child ) { int error = 0; // Initialise everything to NULL - memset( this, 0, sizeof( struct mlt_service_s ) ); + memset( self, 0, sizeof( struct mlt_service_s ) ); // Assign the child - this->child = child; + self->child = child; // Generate local space - this->local = calloc( sizeof( mlt_service_base ), 1 ); + self->local = calloc( sizeof( mlt_service_base ), 1 ); // Associate the methods - this->get_frame = service_get_frame; + self->get_frame = service_get_frame; // Initialise the properties - error = mlt_properties_init( &this->parent, this ); + error = mlt_properties_init( &self->parent, self ); if ( error == 0 ) { - this->parent.close = ( mlt_destructor )mlt_service_close; - this->parent.close_object = this; + self->parent.close = ( mlt_destructor )mlt_service_close; + self->parent.close_object = self; - mlt_events_init( &this->parent ); - mlt_events_register( &this->parent, "service-changed", NULL ); - mlt_events_register( &this->parent, "property-changed", ( mlt_transmitter )mlt_service_property_changed ); - pthread_mutex_init( &( ( mlt_service_base * )this->local )->mutex, NULL ); + mlt_events_init( &self->parent ); + mlt_events_register( &self->parent, "service-changed", NULL ); + mlt_events_register( &self->parent, "property-changed", ( mlt_transmitter )mlt_service_property_changed ); + pthread_mutex_init( &( ( mlt_service_base * )self->local )->mutex, NULL ); } return error; @@ -115,53 +115,53 @@ int mlt_service_init( mlt_service this, void *child ) * \private \memberof mlt_service_s * \param listener a function pointer that will be invoked * \param owner a properties list that will be passed to \p listener - * \param this a service that will be passed to \p listener + * \param self a service that will be passed to \p listener * \param args an array of pointers - the first entry is passed as a string to \p listener */ -static void mlt_service_property_changed( mlt_listener listener, mlt_properties owner, mlt_service this, void **args ) +static void mlt_service_property_changed( mlt_listener listener, mlt_properties owner, mlt_service self, void **args ) { if ( listener != NULL ) - listener( owner, this, ( char * )args[ 0 ] ); + listener( owner, self, ( char * )args[ 0 ] ); } /** Acquire a mutual exclusion lock on this service. * * \public \memberof mlt_service_s - * \param this the service to lock + * \param self the service to lock */ -void mlt_service_lock( mlt_service this ) +void mlt_service_lock( mlt_service self ) { - if ( this != NULL ) - pthread_mutex_lock( &( ( mlt_service_base * )this->local )->mutex ); + if ( self != NULL ) + pthread_mutex_lock( &( ( mlt_service_base * )self->local )->mutex ); } /** Release a mutual exclusion lock on this service. * * \public \memberof mlt_service_s - * \param this the service to unlock + * \param self the service to unlock */ -void mlt_service_unlock( mlt_service this ) +void mlt_service_unlock( mlt_service self ) { - if ( this != NULL ) - pthread_mutex_unlock( &( ( mlt_service_base * )this->local )->mutex ); + if ( self != NULL ) + pthread_mutex_unlock( &( ( mlt_service_base * )self->local )->mutex ); } /** Identify the subclass of the service. * * \public \memberof mlt_service_s - * \param this a service + * \param self a service * \return the subclass */ -mlt_service_type mlt_service_identify( mlt_service this ) +mlt_service_type mlt_service_identify( mlt_service self ) { mlt_service_type type = invalid_type; - if ( this != NULL ) + if ( self != NULL ) { - mlt_properties properties = MLT_SERVICE_PROPERTIES( this ); + mlt_properties properties = MLT_SERVICE_PROPERTIES( self ); char *mlt_type = mlt_properties_get( properties, "mlt_type" ); char *resource = mlt_properties_get( properties, "resource" ); if ( mlt_type == NULL ) @@ -189,21 +189,21 @@ mlt_service_type mlt_service_identify( mlt_service this ) /** Connect a producer to the service. * * \public \memberof mlt_service_s - * \param this a service + * \param self a service * \param producer a producer * \param index which of potentially multiple producers to this service (0 based) * \return > 0 warning, == 0 success, < 0 serious error, * 1 = this service does not accept input, * 2 = the producer is invalid, - * 3 = the producer is already registered with this consumer + * 3 = the producer is already registered with self consumer */ -int mlt_service_connect_producer( mlt_service this, mlt_service producer, int index ) +int mlt_service_connect_producer( mlt_service self, mlt_service producer, int index ) { int i = 0; // Get the service base - mlt_service_base *base = this->local; + mlt_service_base *base = self->local; // Special case 'track' index - only works for last filter(s) in a particular chain // but allows a filter to apply to the output frame regardless of which track it comes from @@ -249,7 +249,7 @@ int mlt_service_connect_producer( mlt_service this, mlt_service producer, int in base->count = index + 1; // Now we connect the producer to its connected consumer - mlt_service_connect( producer, this ); + mlt_service_connect( producer, self ); // Close the current service mlt_service_close( current ); @@ -263,70 +263,70 @@ int mlt_service_connect_producer( mlt_service this, mlt_service producer, int in } } -/** Disconnect this service from its consumer. +/** Disconnect a service from its consumer. * * \public \memberof mlt_service_s - * \param this a service + * \param self a service */ -static void mlt_service_disconnect( mlt_service this ) +static void mlt_service_disconnect( mlt_service self ) { - if ( this != NULL ) + if ( self != NULL ) { // Get the service base - mlt_service_base *base = this->local; + mlt_service_base *base = self->local; // Disconnect base->out = NULL; } } -/** Obtain the consumer this service is connected to. +/** Obtain the consumer a service is connected to. * * \public \memberof mlt_service_s - * \param this a service + * \param self a service * \return the consumer */ -mlt_service mlt_service_consumer( mlt_service this ) +mlt_service mlt_service_consumer( mlt_service self ) { // Get the service base - mlt_service_base *base = this->local; + mlt_service_base *base = self->local; // Return the connected consumer return base->out; } -/** Obtain the producer this service is connected to. +/** Obtain the producer a service is connected to. * * \public \memberof mlt_service_s - * \param this a service + * \param self a service * \return the last-most producer */ -mlt_service mlt_service_producer( mlt_service this ) +mlt_service mlt_service_producer( mlt_service self ) { // Get the service base - mlt_service_base *base = this->local; + mlt_service_base *base = self->local; // Return the connected producer return base->count > 0 ? base->in[ base->count - 1 ] : NULL; } -/** Associate this service to a consumer. +/** Associate a service to a consumer. * * Overwrites connection to any existing consumer. * \private \memberof mlt_service_s - * \param this a service + * \param self a service * \param that a consumer */ -static void mlt_service_connect( mlt_service this, mlt_service that ) +static void mlt_service_connect( mlt_service self, mlt_service that ) { - if ( this != NULL ) + if ( self != NULL ) { // Get the service base - mlt_service_base *base = this->local; + mlt_service_base *base = self->local; // There's a bit more required here... base->out = that; @@ -336,16 +336,16 @@ static void mlt_service_connect( mlt_service this, mlt_service that ) /** Get the first connected producer. * * \public \memberof mlt_service_s - * \param this a service + * \param self a service * \return the first producer */ -mlt_service mlt_service_get_producer( mlt_service this ) +mlt_service mlt_service_get_producer( mlt_service self ) { mlt_service producer = NULL; // Get the service base - mlt_service_base *base = this->local; + mlt_service_base *base = self->local; if ( base->in != NULL ) producer = base->in[ 0 ]; @@ -356,54 +356,54 @@ mlt_service mlt_service_get_producer( mlt_service this ) /** Default implementation of the get_frame virtual function. * * \private \memberof mlt_service_s - * \param this a service + * \param self a service * \param[out] frame a frame by reference * \param index as determined by the producer * \return false */ -static int service_get_frame( mlt_service this, mlt_frame_ptr frame, int index ) +static int service_get_frame( mlt_service self, mlt_frame_ptr frame, int index ) { - mlt_service_base *base = this->local; + mlt_service_base *base = self->local; if ( index < base->count ) { mlt_service producer = base->in[ index ]; if ( producer != NULL ) return mlt_service_get_frame( producer, frame, index ); } - *frame = mlt_frame_init( this ); + *frame = mlt_frame_init( self ); return 0; } /** Return the properties object. * * \public \memberof mlt_service_s - * \param this a service + * \param self a service * \return the properties */ -mlt_properties mlt_service_properties( mlt_service this ) +mlt_properties mlt_service_properties( mlt_service self ) { - return this != NULL ? &this->parent : NULL; + return self != NULL ? &self->parent : NULL; } /** Recursively apply attached filters. * * \public \memberof mlt_service_s - * \param this a service + * \param self a service * \param frame a frame * \param index used to track depth of recursion, top caller should supply 0 */ -void mlt_service_apply_filters( mlt_service this, mlt_frame frame, int index ) +void mlt_service_apply_filters( mlt_service self, mlt_frame frame, int index ) { int i; mlt_properties frame_properties = MLT_FRAME_PROPERTIES( frame ); - mlt_properties service_properties = MLT_SERVICE_PROPERTIES( this ); - mlt_service_base *base = this->local; + mlt_properties service_properties = MLT_SERVICE_PROPERTIES( self ); + mlt_service_base *base = self->local; mlt_position position = mlt_frame_get_position( frame ); - mlt_position this_in = mlt_properties_get_position( service_properties, "in" ); - mlt_position this_out = mlt_properties_get_position( service_properties, "out" ); + mlt_position self_in = mlt_properties_get_position( service_properties, "in" ); + mlt_position self_out = mlt_properties_get_position( service_properties, "out" ); if ( index == 0 || mlt_properties_get_int( service_properties, "_filter_private" ) == 0 ) { @@ -417,8 +417,8 @@ void mlt_service_apply_filters( mlt_service this, mlt_frame frame, int index ) int disable = mlt_properties_get_int( MLT_FILTER_PROPERTIES( base->filters[ i ] ), "disable" ); if ( !disable && ( ( in == 0 && out == 0 ) || ( position >= in && ( position <= out || out == 0 ) ) ) ) { - mlt_properties_set_position( frame_properties, "in", in == 0 ? this_in : in ); - mlt_properties_set_position( frame_properties, "out", out == 0 ? this_out : out ); + mlt_properties_set_position( frame_properties, "in", in == 0 ? self_in : in ); + mlt_properties_set_position( frame_properties, "out", out == 0 ? self_out : out ); mlt_filter_process( base->filters[ i ], frame ); mlt_service_apply_filters( MLT_FILTER_SERVICE( base->filters[ i ] ), frame, index + 1 ); } @@ -430,31 +430,31 @@ void mlt_service_apply_filters( mlt_service this, mlt_frame frame, int index ) /** Obtain a frame. * * \public \memberof mlt_service_s - * \param this a service + * \param self a service * \param[out] frame a frame by reference * \param index as determined by the producer * \return true if there was an error */ -int mlt_service_get_frame( mlt_service this, mlt_frame_ptr frame, int index ) +int mlt_service_get_frame( mlt_service self, mlt_frame_ptr frame, int index ) { int result = 0; // Lock the service - mlt_service_lock( this ); + mlt_service_lock( self ); // Ensure that the frame is NULL *frame = NULL; // Only process if we have a valid service - if ( this != NULL && this->get_frame != NULL ) + if ( self != NULL && self->get_frame != NULL ) { - mlt_properties properties = MLT_SERVICE_PROPERTIES( this ); + mlt_properties properties = MLT_SERVICE_PROPERTIES( self ); mlt_position in = mlt_properties_get_position( properties, "in" ); mlt_position out = mlt_properties_get_position( properties, "out" ); - mlt_position position = mlt_service_identify( this ) == producer_type ? mlt_producer_position( MLT_PRODUCER( this ) ) : -1; + mlt_position position = mlt_service_identify( self ) == producer_type ? mlt_producer_position( MLT_PRODUCER( self ) ) : -1; - result = this->get_frame( this, frame, index ); + result = self->get_frame( self, frame, index ); if ( result == 0 ) { @@ -466,27 +466,27 @@ int mlt_service_get_frame( mlt_service this, mlt_frame_ptr frame, int index ) mlt_properties_set_position( properties, "in", in ); mlt_properties_set_position( properties, "out", out ); } - mlt_service_apply_filters( this, *frame, 1 ); - mlt_deque_push_back( MLT_FRAME_SERVICE_STACK( *frame ), this ); + mlt_service_apply_filters( self, *frame, 1 ); + mlt_deque_push_back( MLT_FRAME_SERVICE_STACK( *frame ), self ); - if ( mlt_service_identify( this ) == producer_type && - mlt_properties_get_int( MLT_SERVICE_PROPERTIES( this ), "_need_previous_next" ) ) + if ( mlt_service_identify( self ) == producer_type && + mlt_properties_get_int( MLT_SERVICE_PROPERTIES( self ), "_need_previous_next" ) ) { - // Save the new position from this->get_frame - mlt_position new_position = mlt_producer_position( MLT_PRODUCER( this ) ); + // Save the new position from self->get_frame + mlt_position new_position = mlt_producer_position( MLT_PRODUCER( self ) ); // Get the preceding frame, unfiltered mlt_frame previous_frame; - mlt_producer_seek( MLT_PRODUCER(this), position - 1 ); - result = this->get_frame( this, &previous_frame, index ); + mlt_producer_seek( MLT_PRODUCER(self), position - 1 ); + result = self->get_frame( self, &previous_frame, index ); if ( !result ) mlt_properties_set_data( properties, "previous frame", previous_frame, 0, ( mlt_destructor ) mlt_frame_close, NULL ); // Get the following frame, unfiltered mlt_frame next_frame; - mlt_producer_seek( MLT_PRODUCER(this), position + 1 ); - result = this->get_frame( this, &next_frame, index ); + mlt_producer_seek( MLT_PRODUCER(self), position + 1 ); + result = self->get_frame( self, &next_frame, index ); if ( !result ) { mlt_properties_set_data( properties, "next frame", @@ -494,17 +494,17 @@ int mlt_service_get_frame( mlt_service this, mlt_frame_ptr frame, int index ) } // Restore the new position - mlt_producer_seek( MLT_PRODUCER(this), new_position ); + mlt_producer_seek( MLT_PRODUCER(self), new_position ); } } } // Make sure we return a frame if ( *frame == NULL ) - *frame = mlt_frame_init( this ); + *frame = mlt_frame_init( self ); // Unlock the service - mlt_service_unlock( this ); + mlt_service_unlock( self ); return result; } @@ -513,30 +513,30 @@ int mlt_service_get_frame( mlt_service this, mlt_frame_ptr frame, int index ) * * \private \memberof mlt_service_s * \param owner ignored - * \param this the service on which the "service-changed" event is fired + * \param self the service on which the "service-changed" event is fired */ -static void mlt_service_filter_changed( mlt_service owner, mlt_service this ) +static void mlt_service_filter_changed( mlt_service owner, mlt_service self ) { - mlt_events_fire( MLT_SERVICE_PROPERTIES( this ), "service-changed", NULL ); + mlt_events_fire( MLT_SERVICE_PROPERTIES( self ), "service-changed", NULL ); } /** Attach a filter. * * \public \memberof mlt_service_s - * \param this a service + * \param self a service * \param filter the filter to attach * \return true if there was an error */ -int mlt_service_attach( mlt_service this, mlt_filter filter ) +int mlt_service_attach( mlt_service self, mlt_filter filter ) { - int error = this == NULL || filter == NULL; + int error = self == NULL || filter == NULL; if ( error == 0 ) { int i = 0; - mlt_properties properties = MLT_SERVICE_PROPERTIES( this ); - mlt_service_base *base = this->local; + mlt_properties properties = MLT_SERVICE_PROPERTIES( self ); + mlt_service_base *base = self->local; for ( i = 0; error == 0 && i < base->filter_count; i ++ ) if ( base->filters[ i ] == filter ) @@ -555,11 +555,11 @@ int mlt_service_attach( mlt_service this, mlt_filter filter ) mlt_properties props = MLT_FILTER_PROPERTIES( filter ); mlt_properties_inc_ref( MLT_FILTER_PROPERTIES( filter ) ); base->filters[ base->filter_count ++ ] = filter; - mlt_properties_set_data( props, "service", this, 0, NULL, NULL ); + mlt_properties_set_data( props, "service", self, 0, NULL, NULL ); mlt_events_fire( properties, "service-changed", NULL ); mlt_events_fire( props, "service-changed", NULL ); - mlt_events_listen( props, this, "service-changed", ( mlt_listener )mlt_service_filter_changed ); - mlt_events_listen( props, this, "property-changed", ( mlt_listener )mlt_service_filter_changed ); + mlt_events_listen( props, self, "service-changed", ( mlt_listener )mlt_service_filter_changed ); + mlt_events_listen( props, self, "property-changed", ( mlt_listener )mlt_service_filter_changed ); } else { @@ -573,19 +573,19 @@ int mlt_service_attach( mlt_service this, mlt_filter filter ) /** Detach a filter. * * \public \memberof mlt_service_s - * \param this a service + * \param self a service * \param filter the filter to detach * \return true if there was an error */ -int mlt_service_detach( mlt_service this, mlt_filter filter ) +int mlt_service_detach( mlt_service self, mlt_filter filter ) { - int error = this == NULL || filter == NULL; + int error = self == NULL || filter == NULL; if ( error == 0 ) { int i = 0; - mlt_service_base *base = this->local; - mlt_properties properties = MLT_SERVICE_PROPERTIES( this ); + mlt_service_base *base = self->local; + mlt_properties properties = MLT_SERVICE_PROPERTIES( self ); for ( i = 0; i < base->filter_count; i ++ ) if ( base->filters[ i ] == filter ) @@ -597,7 +597,7 @@ int mlt_service_detach( mlt_service this, mlt_filter filter ) for ( i ++ ; i < base->filter_count; i ++ ) base->filters[ i - 1 ] = base->filters[ i ]; base->filter_count --; - mlt_events_disconnect( MLT_FILTER_PROPERTIES( filter ), this ); + mlt_events_disconnect( MLT_FILTER_PROPERTIES( filter ), self ); mlt_filter_close( filter ); mlt_events_fire( properties, "service-changed", NULL ); } @@ -608,17 +608,17 @@ int mlt_service_detach( mlt_service this, mlt_filter filter ) /** Retrieve a filter. * * \public \memberof mlt_service_s - * \param this a service + * \param self a service * \param index which one of potentially multiple filters * \return the filter or null if there was an error */ -mlt_filter mlt_service_filter( mlt_service this, int index ) +mlt_filter mlt_service_filter( mlt_service self, int index ) { mlt_filter filter = NULL; - if ( this != NULL ) + if ( self != NULL ) { - mlt_service_base *base = this->local; + mlt_service_base *base = self->local; if ( index >= 0 && index < base->filter_count ) filter = base->filters[ index ]; } @@ -628,46 +628,46 @@ mlt_filter mlt_service_filter( mlt_service this, int index ) /** Retrieve the profile. * * \public \memberof mlt_service_s - * \param this a service + * \param self a service * \return the profile */ -mlt_profile mlt_service_profile( mlt_service this ) +mlt_profile mlt_service_profile( mlt_service self ) { - return this? mlt_properties_get_data( MLT_SERVICE_PROPERTIES( this ), "_profile", NULL ) : NULL; + return self? mlt_properties_get_data( MLT_SERVICE_PROPERTIES( self ), "_profile", NULL ) : NULL; } /** Destroy a service. * * \public \memberof mlt_service_s - * \param this the service to destroy + * \param self the service to destroy */ -void mlt_service_close( mlt_service this ) +void mlt_service_close( mlt_service self ) { - if ( this != NULL && mlt_properties_dec_ref( MLT_SERVICE_PROPERTIES( this ) ) <= 0 ) + if ( self != NULL && mlt_properties_dec_ref( MLT_SERVICE_PROPERTIES( self ) ) <= 0 ) { - if ( this->close != NULL ) + if ( self->close != NULL ) { - this->close( this->close_object ); + self->close( self->close_object ); } else { - mlt_service_base *base = this->local; + mlt_service_base *base = self->local; int i = 0; int count = base->filter_count; - mlt_events_block( MLT_SERVICE_PROPERTIES( this ), this ); + mlt_events_block( MLT_SERVICE_PROPERTIES( self ), self ); while( count -- ) - mlt_service_detach( this, base->filters[ 0 ] ); + mlt_service_detach( self, base->filters[ 0 ] ); free( base->filters ); for ( i = 0; i < base->count; i ++ ) if ( base->in[ i ] != NULL ) mlt_service_close( base->in[ i ] ); - this->parent.close = NULL; + self->parent.close = NULL; free( base->in ); pthread_mutex_destroy( &base->mutex ); free( base ); - mlt_properties_close( &this->parent ); + mlt_properties_close( &self->parent ); } } } diff --git a/src/framework/mlt_tokeniser.h b/src/framework/mlt_tokeniser.h index d4715af5..9aa66317 100644 --- a/src/framework/mlt_tokeniser.h +++ b/src/framework/mlt_tokeniser.h @@ -41,10 +41,10 @@ typedef struct */ extern mlt_tokeniser mlt_tokeniser_init( ); -extern int mlt_tokeniser_parse_new( mlt_tokeniser self, char *text, const char *delimiter ); -extern char *mlt_tokeniser_get_input( mlt_tokeniser self ); -extern int mlt_tokeniser_count( mlt_tokeniser self ); -extern char *mlt_tokeniser_get_string( mlt_tokeniser self, int index ); -extern void mlt_tokeniser_close( mlt_tokeniser self ); +extern int mlt_tokeniser_parse_new( mlt_tokeniser tokeniser, char *text, const char *delimiter ); +extern char *mlt_tokeniser_get_input( mlt_tokeniser tokeniser ); +extern int mlt_tokeniser_count( mlt_tokeniser tokeniser ); +extern char *mlt_tokeniser_get_string( mlt_tokeniser tokeniser, int index ); +extern void mlt_tokeniser_close( mlt_tokeniser tokeniser ); #endif diff --git a/src/framework/mlt_tractor.c b/src/framework/mlt_tractor.c index 80f94307..235bbe01 100644 --- a/src/framework/mlt_tractor.c +++ b/src/framework/mlt_tractor.c @@ -36,7 +36,7 @@ */ static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int track ); -static void mlt_tractor_listener( mlt_multitrack tracks, mlt_tractor this ); +static void mlt_tractor_listener( mlt_multitrack tracks, mlt_tractor self ); /** Construct a tractor without a field or multitrack. * @@ -49,11 +49,11 @@ static void mlt_tractor_listener( mlt_multitrack tracks, mlt_tractor this ); mlt_tractor mlt_tractor_init( ) { - mlt_tractor this = calloc( sizeof( struct mlt_tractor_s ), 1 ); - if ( this != NULL ) + mlt_tractor self = calloc( sizeof( struct mlt_tractor_s ), 1 ); + if ( self != NULL ) { - mlt_producer producer = &this->parent; - if ( mlt_producer_init( producer, this ) == 0 ) + mlt_producer producer = &self->parent; + if ( mlt_producer_init( producer, self ) == 0 ) { mlt_properties properties = MLT_PRODUCER_PROPERTIES( producer ); @@ -66,15 +66,15 @@ mlt_tractor mlt_tractor_init( ) producer->get_frame = producer_get_frame; producer->close = ( mlt_destructor )mlt_tractor_close; - producer->close_object = this; + producer->close_object = self; } else { - free( this ); - this = NULL; + free( self ); + self = NULL; } } - return this; + return self; } /** Construct a tractor as well as a field and multitrack. @@ -88,14 +88,14 @@ mlt_tractor mlt_tractor_init( ) mlt_tractor mlt_tractor_new( ) { - mlt_tractor this = calloc( sizeof( struct mlt_tractor_s ), 1 ); - if ( this != NULL ) + mlt_tractor self = calloc( sizeof( struct mlt_tractor_s ), 1 ); + if ( self != NULL ) { - mlt_producer producer = &this->parent; - if ( mlt_producer_init( producer, this ) == 0 ) + mlt_producer producer = &self->parent; + if ( mlt_producer_init( producer, self ) == 0 ) { mlt_multitrack multitrack = mlt_multitrack_init( ); - mlt_field field = mlt_field_new( multitrack, this ); + mlt_field field = mlt_field_new( multitrack, self ); mlt_properties props = MLT_PRODUCER_PROPERTIES( producer ); mlt_properties_set( props, "resource", "" ); @@ -107,125 +107,125 @@ mlt_tractor mlt_tractor_new( ) mlt_properties_set_data( props, "multitrack", multitrack, 0, ( mlt_destructor )mlt_multitrack_close, NULL ); mlt_properties_set_data( props, "field", field, 0, ( mlt_destructor )mlt_field_close, NULL ); - mlt_events_listen( MLT_MULTITRACK_PROPERTIES( multitrack ), this, "producer-changed", ( mlt_listener )mlt_tractor_listener ); + mlt_events_listen( MLT_MULTITRACK_PROPERTIES( multitrack ), self, "producer-changed", ( mlt_listener )mlt_tractor_listener ); producer->get_frame = producer_get_frame; producer->close = ( mlt_destructor )mlt_tractor_close; - producer->close_object = this; + producer->close_object = self; } else { - free( this ); - this = NULL; + free( self ); + self = NULL; } } - return this; + return self; } /** Get the service object associated to the tractor. * * \public \memberof mlt_tractor_s - * \param this a tractor + * \param self a tractor * \return the parent service object * \see MLT_TRACTOR_SERVICE */ -mlt_service mlt_tractor_service( mlt_tractor this ) +mlt_service mlt_tractor_service( mlt_tractor self ) { - return MLT_PRODUCER_SERVICE( &this->parent ); + return MLT_PRODUCER_SERVICE( &self->parent ); } /** Get the producer object associated to the tractor. * * \public \memberof mlt_tractor_s - * \param this a tractor + * \param self a tractor * \return the parent producer object * \see MLT_TRACTOR_PRODUCER */ -mlt_producer mlt_tractor_producer( mlt_tractor this ) +mlt_producer mlt_tractor_producer( mlt_tractor self ) { - return this != NULL ? &this->parent : NULL; + return self != NULL ? &self->parent : NULL; } /** Get the properties object associated to the tractor. * * \public \memberof mlt_tractor_s - * \param this a tractor + * \param self a tractor * \return the tractor's property list * \see MLT_TRACTOR_PROPERTIES */ -mlt_properties mlt_tractor_properties( mlt_tractor this ) +mlt_properties mlt_tractor_properties( mlt_tractor self ) { - return MLT_PRODUCER_PROPERTIES( &this->parent ); + return MLT_PRODUCER_PROPERTIES( &self->parent ); } -/** Get the field this tractor is harvesting. +/** Get the field self tractor is harvesting. * * \public \memberof mlt_tractor_s - * \param this a tractor + * \param self a tractor * \return a field or NULL if there is no field for this tractor */ -mlt_field mlt_tractor_field( mlt_tractor this ) +mlt_field mlt_tractor_field( mlt_tractor self ) { - return mlt_properties_get_data( MLT_TRACTOR_PROPERTIES( this ), "field", NULL ); + return mlt_properties_get_data( MLT_TRACTOR_PROPERTIES( self ), "field", NULL ); } -/** Get the multitrack this tractor is pulling. +/** Get the multitrack a tractor is pulling. * * \public \memberof mlt_tractor_s - * \param this a tractor + * \param self a tractor * \return a multitrack or NULL if there is none */ -mlt_multitrack mlt_tractor_multitrack( mlt_tractor this ) +mlt_multitrack mlt_tractor_multitrack( mlt_tractor self ) { - return mlt_properties_get_data( MLT_TRACTOR_PROPERTIES( this ), "multitrack", NULL ); + return mlt_properties_get_data( MLT_TRACTOR_PROPERTIES( self ), "multitrack", NULL ); } /** Ensure the tractors in/out points match the multitrack. * * \public \memberof mlt_tractor_s - * \param this a tractor + * \param self a tractor */ -void mlt_tractor_refresh( mlt_tractor this ) +void mlt_tractor_refresh( mlt_tractor self ) { - mlt_multitrack multitrack = mlt_tractor_multitrack( this ); - mlt_properties properties = MLT_MULTITRACK_PROPERTIES( multitrack ); - mlt_properties self = MLT_TRACTOR_PROPERTIES( this ); - mlt_events_block( properties, self ); - mlt_events_block( self, self ); + mlt_multitrack multitrack = mlt_tractor_multitrack( self ); + mlt_properties multitrack_props = MLT_MULTITRACK_PROPERTIES( multitrack ); + mlt_properties properties = MLT_TRACTOR_PROPERTIES( self ); + mlt_events_block( multitrack_props, properties ); + mlt_events_block( properties, properties ); mlt_multitrack_refresh( multitrack ); - mlt_properties_set_position( self, "in", 0 ); - mlt_properties_set_position( self, "out", mlt_properties_get_position( properties, "out" ) ); - mlt_events_unblock( self, self ); - mlt_events_unblock( properties, self ); - mlt_properties_set_position( self, "length", mlt_properties_get_position( properties, "length" ) ); + mlt_properties_set_position( properties, "in", 0 ); + mlt_properties_set_position( properties, "out", mlt_properties_get_position( multitrack_props, "out" ) ); + mlt_events_unblock( properties, properties ); + mlt_events_unblock( multitrack_props, properties ); + mlt_properties_set_position( properties, "length", mlt_properties_get_position( multitrack_props, "length" ) ); } -static void mlt_tractor_listener( mlt_multitrack tracks, mlt_tractor this ) +static void mlt_tractor_listener( mlt_multitrack tracks, mlt_tractor self ) { - mlt_tractor_refresh( this ); + mlt_tractor_refresh( self ); } /** Connect the tractor. * * \public \memberof mlt_tractor_s - * \param this a tractor + * \param self a tractor * \param producer a producer * \return true on error */ -int mlt_tractor_connect( mlt_tractor this, mlt_service producer ) +int mlt_tractor_connect( mlt_tractor self, mlt_service producer ) { - int ret = mlt_service_connect_producer( MLT_TRACTOR_SERVICE( this ), producer, 0 ); + int ret = mlt_service_connect_producer( MLT_TRACTOR_SERVICE( self ), producer, 0 ); // This is the producer we're going to connect to if ( ret == 0 ) - this->producer = producer; + self->producer = producer; return ret; } @@ -233,36 +233,36 @@ int mlt_tractor_connect( mlt_tractor this, mlt_service producer ) /** Set the producer for a specific track. * * \public \memberof mlt_tractor_s - * \param this a tractor + * \param self a tractor * \param producer a producer * \param index the 0-based track index * \return true on error */ -int mlt_tractor_set_track( mlt_tractor this, mlt_producer producer, int index ) +int mlt_tractor_set_track( mlt_tractor self, mlt_producer producer, int index ) { - return mlt_multitrack_connect( mlt_tractor_multitrack( this ), producer, index ); + return mlt_multitrack_connect( mlt_tractor_multitrack( self ), producer, index ); } /** Get the producer for a specific track. * * \public \memberof mlt_tractor_s - * \param this a tractor + * \param self a tractor * \param index the 0-based track index * \return the producer for track \p index */ -mlt_producer mlt_tractor_get_track( mlt_tractor this, int index ) +mlt_producer mlt_tractor_get_track( mlt_tractor self, int index ) { - return mlt_multitrack_track( mlt_tractor_multitrack( this ), index ); + return mlt_multitrack_track( mlt_tractor_multitrack( self ), index ); } -static int producer_get_image( mlt_frame this, uint8_t **buffer, mlt_image_format *format, int *width, int *height, int writable ) +static int producer_get_image( mlt_frame self, uint8_t **buffer, mlt_image_format *format, int *width, int *height, int writable ) { uint8_t *data = NULL; int size = 0; - mlt_properties properties = MLT_FRAME_PROPERTIES( this ); - mlt_frame frame = mlt_frame_pop_service( this ); + mlt_properties properties = MLT_FRAME_PROPERTIES( self ); + mlt_frame frame = mlt_frame_pop_service( self ); mlt_properties frame_properties = MLT_FRAME_PROPERTIES( frame ); mlt_properties_set( frame_properties, "rescale.interp", mlt_properties_get( properties, "rescale.interp" ) ); mlt_properties_set_int( frame_properties, "resize_alpha", mlt_properties_get_int( properties, "resize_alpha" ) ); @@ -285,15 +285,15 @@ static int producer_get_image( mlt_frame this, uint8_t **buffer, mlt_image_forma data = mlt_frame_get_alpha_mask( frame ); mlt_properties_get_data( frame_properties, "alpha", &size ); mlt_properties_set_data( properties, "alpha", data, size, NULL, NULL ); - this->convert_image = frame->convert_image; - this->convert_audio = frame->convert_audio; + self->convert_image = frame->convert_image; + self->convert_audio = frame->convert_audio; return 0; } -static int producer_get_audio( mlt_frame this, void **buffer, mlt_audio_format *format, int *frequency, int *channels, int *samples ) +static int producer_get_audio( mlt_frame self, void **buffer, mlt_audio_format *format, int *frequency, int *channels, int *samples ) { - mlt_properties properties = MLT_FRAME_PROPERTIES( this ); - mlt_frame frame = mlt_frame_pop_audio( this ); + mlt_properties properties = MLT_FRAME_PROPERTIES( self ); + mlt_frame frame = mlt_frame_pop_audio( self ); mlt_frame_get_audio( frame, buffer, format, frequency, channels, samples ); mlt_properties_set_data( properties, "audio", *buffer, 0, NULL, NULL ); mlt_properties_set_int( properties, "frequency", *frequency ); @@ -328,10 +328,10 @@ static void destroy_data_queue( void *arg ) static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int track ) { - mlt_tractor this = parent->child; + mlt_tractor self = parent->child; // We only respond to the first track requests - if ( track == 0 && this->producer != NULL ) + if ( track == 0 && self->producer != NULL ) { int i = 0; int done = 0; @@ -389,7 +389,7 @@ static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int tra for ( i = 0; !done; i ++ ) { // Get a frame from the producer - mlt_service_get_frame( this->producer, &temp, i ); + mlt_service_get_frame( self->producer, &temp, i ); // Get the temporary properties temp_properties = MLT_FRAME_PROPERTIES( temp ); @@ -521,12 +521,12 @@ static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int tra { mlt_producer_seek( producer, mlt_producer_frame( parent ) ); mlt_producer_set_speed( producer, mlt_producer_get_speed( parent ) ); - mlt_service_get_frame( this->producer, frame, track ); + mlt_service_get_frame( self->producer, frame, track ); } else { mlt_log( MLT_PRODUCER_SERVICE( parent ), MLT_LOG_ERROR, "tractor without a multitrack!!\n" ); - mlt_service_get_frame( this->producer, frame, track ); + mlt_service_get_frame( self->producer, frame, track ); } // Prepare the next frame @@ -546,16 +546,16 @@ static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int tra /** Close the tractor and free its resources. * * \public \memberof mlt_tractor_s - * \param this a tractor + * \param self a tractor */ -void mlt_tractor_close( mlt_tractor this ) +void mlt_tractor_close( mlt_tractor self ) { - if ( this != NULL && mlt_properties_dec_ref( MLT_TRACTOR_PROPERTIES( this ) ) <= 0 ) + if ( self != NULL && mlt_properties_dec_ref( MLT_TRACTOR_PROPERTIES( self ) ) <= 0 ) { - this->parent.close = NULL; - mlt_producer_close( &this->parent ); - free( this ); + self->parent.close = NULL; + mlt_producer_close( &self->parent ); + free( self ); } } diff --git a/src/framework/mlt_transition.c b/src/framework/mlt_transition.c index 7784e741..01fc2d83 100644 --- a/src/framework/mlt_transition.c +++ b/src/framework/mlt_transition.c @@ -31,28 +31,28 @@ /* Forward references */ -static int transition_get_frame( mlt_service this, mlt_frame_ptr frame, int index ); +static int transition_get_frame( mlt_service self, mlt_frame_ptr frame, int index ); /** Initialize a new transition. * * \public \memberof mlt_transition_s - * \param this a transition + * \param self a transition * \param child the object of a subclass * \return true on error */ -int mlt_transition_init( mlt_transition this, void *child ) +int mlt_transition_init( mlt_transition self, void *child ) { - mlt_service service = &this->parent; - memset( this, 0, sizeof( struct mlt_transition_s ) ); - this->child = child; - if ( mlt_service_init( service, this ) == 0 ) + mlt_service service = &self->parent; + memset( self, 0, sizeof( struct mlt_transition_s ) ); + self->child = child; + if ( mlt_service_init( service, self ) == 0 ) { - mlt_properties properties = MLT_TRANSITION_PROPERTIES( this ); + mlt_properties properties = MLT_TRANSITION_PROPERTIES( self ); service->get_frame = transition_get_frame; service->close = ( mlt_destructor )mlt_transition_close; - service->close_object = this; + service->close_object = self; mlt_properties_set_position( properties, "in", 0 ); mlt_properties_set_position( properties, "out", 0 ); @@ -72,55 +72,55 @@ int mlt_transition_init( mlt_transition this, void *child ) mlt_transition mlt_transition_new( ) { - mlt_transition this = calloc( 1, sizeof( struct mlt_transition_s ) ); - if ( this != NULL ) - mlt_transition_init( this, NULL ); - return this; + mlt_transition self = calloc( 1, sizeof( struct mlt_transition_s ) ); + if ( self != NULL ) + mlt_transition_init( self, NULL ); + return self; } /** Get the service class interface. * * \public \memberof mlt_transition_s - * \param this a transition + * \param self a transition * \return the service class * \see MLT_TRANSITION_SERVICE */ -mlt_service mlt_transition_service( mlt_transition this ) +mlt_service mlt_transition_service( mlt_transition self ) { - return this != NULL ? &this->parent : NULL; + return self != NULL ? &self->parent : NULL; } /** Get the properties interface. * * \public \memberof mlt_transition_s - * \param this a transition + * \param self a transition * \return the transition's properties * \see MLT_TRANSITION_PROPERTIES */ -mlt_properties mlt_transition_properties( mlt_transition this ) +mlt_properties mlt_transition_properties( mlt_transition self ) { - return MLT_TRANSITION_PROPERTIES( this ); + return MLT_TRANSITION_PROPERTIES( self ); } -/** Connect this transition with a producers a and b tracks. +/** Connect a transition with a producer's a and b tracks. * * \public \memberof mlt_transition_s - * \param this a transition + * \param self a transition * \param producer a producer * \param a_track the track index of the first input * \param b_track the track index of the second index * \return true on error */ -int mlt_transition_connect( mlt_transition this, mlt_service producer, int a_track, int b_track ) +int mlt_transition_connect( mlt_transition self, mlt_service producer, int a_track, int b_track ) { - int ret = mlt_service_connect_producer( &this->parent, producer, a_track ); + int ret = mlt_service_connect_producer( &self->parent, producer, a_track ); if ( ret == 0 ) { - mlt_properties properties = MLT_TRANSITION_PROPERTIES( this ); - this->producer = producer; + mlt_properties properties = MLT_TRANSITION_PROPERTIES( self ); + self->producer = producer; mlt_properties_set_int( properties, "a_track", a_track ); mlt_properties_set_int( properties, "b_track", b_track ); } @@ -130,14 +130,14 @@ int mlt_transition_connect( mlt_transition this, mlt_service producer, int a_tra /** Set the starting and ending time for when the transition is active. * * \public \memberof mlt_transition_s - * \param this a transition + * \param self a transition * \param in the starting time * \param out the ending time */ -void mlt_transition_set_in_and_out( mlt_transition this, mlt_position in, mlt_position out ) +void mlt_transition_set_in_and_out( mlt_transition self, mlt_position in, mlt_position out ) { - mlt_properties properties = MLT_TRANSITION_PROPERTIES( this ); + mlt_properties properties = MLT_TRANSITION_PROPERTIES( self ); mlt_properties_set_position( properties, "in", in ); mlt_properties_set_position( properties, "out", out ); } @@ -145,49 +145,49 @@ void mlt_transition_set_in_and_out( mlt_transition this, mlt_position in, mlt_po /** Get the index of the a track. * * \public \memberof mlt_transition_s - * \param this a transition + * \param self a transition * \return the 0-based index of the track of the first producer */ -int mlt_transition_get_a_track( mlt_transition this ) +int mlt_transition_get_a_track( mlt_transition self ) { - return mlt_properties_get_int( MLT_TRANSITION_PROPERTIES( this ), "a_track" ); + return mlt_properties_get_int( MLT_TRANSITION_PROPERTIES( self ), "a_track" ); } /** Get the index of the b track. * * \public \memberof mlt_transition_s - * \param this a transition + * \param self a transition * \return the 0-based index of the track of the second producer */ -int mlt_transition_get_b_track( mlt_transition this ) +int mlt_transition_get_b_track( mlt_transition self ) { - return mlt_properties_get_int( MLT_TRANSITION_PROPERTIES( this ), "b_track" ); + return mlt_properties_get_int( MLT_TRANSITION_PROPERTIES( self ), "b_track" ); } /** Get the in point. * * \public \memberof mlt_transition_s - * \param this a transition + * \param self a transition * \return the starting time */ -mlt_position mlt_transition_get_in( mlt_transition this ) +mlt_position mlt_transition_get_in( mlt_transition self ) { - return mlt_properties_get_position( MLT_TRANSITION_PROPERTIES( this ), "in" ); + return mlt_properties_get_position( MLT_TRANSITION_PROPERTIES( self ), "in" ); } /** Get the out point. * * \public \memberof mlt_transition_s - * \param this a transition + * \param self a transition * \return the ending time */ -mlt_position mlt_transition_get_out( mlt_transition this ) +mlt_position mlt_transition_get_out( mlt_transition self ) { - return mlt_properties_get_position( MLT_TRANSITION_PROPERTIES( this ), "out" ); + return mlt_properties_get_position( MLT_TRANSITION_PROPERTIES( self ), "out" ); } /** Process the frame. @@ -195,21 +195,21 @@ mlt_position mlt_transition_get_out( mlt_transition this ) * If we have no process method (unlikely), we simply return the a_frame unmolested. * * \public \memberof mlt_transition_s - * \param this a transition + * \param self a transition * \param a_frame a frame from the first producer * \param b_frame a frame from the second producer * \return a frame */ -mlt_frame mlt_transition_process( mlt_transition this, mlt_frame a_frame, mlt_frame b_frame ) +mlt_frame mlt_transition_process( mlt_transition self, mlt_frame a_frame, mlt_frame b_frame ) { - if ( this->process == NULL ) + if ( self->process == NULL ) return a_frame; else - return this->process( this, a_frame, b_frame ); + return self->process( self, a_frame, b_frame ); } -/** Get a frame from this transition. +/** Get a frame from a transition. The logic is complex here. A transition is typically applied to frames on the a and b tracks specified in the connect method above and only if both contain valid info @@ -250,9 +250,9 @@ mlt_frame mlt_transition_process( mlt_transition this, mlt_frame a_frame, mlt_fr static int transition_get_frame( mlt_service service, mlt_frame_ptr frame, int index ) { int error = 0; - mlt_transition this = service->child; + mlt_transition self = service->child; - mlt_properties properties = MLT_TRANSITION_PROPERTIES( this ); + mlt_properties properties = MLT_TRANSITION_PROPERTIES( self ); int accepts_blanks = mlt_properties_get_int( properties, "accepts_blanks" ); int a_track = mlt_properties_get_int( properties, "a_track" ); @@ -272,7 +272,7 @@ static int transition_get_frame( mlt_service service, mlt_frame_ptr frame, int i } // Only act on this operation once per multitrack iteration from the tractor - if ( !this->held ) + if ( !self->held ) { int active = 0; int i = 0; @@ -282,15 +282,15 @@ static int transition_get_frame( mlt_service service, mlt_frame_ptr frame, int i int ( *invalid )( mlt_frame ) = type == 1 ? mlt_frame_is_test_card : mlt_frame_is_test_audio; // Initialise temporary store - if ( this->frames == NULL ) - this->frames = calloc( sizeof( mlt_frame ), b_track + 1 ); + if ( self->frames == NULL ) + self->frames = calloc( sizeof( mlt_frame ), b_track + 1 ); // Get all frames between a and b for( i = a_track; i <= b_track; i ++ ) - mlt_service_get_frame( this->producer, &this->frames[ i ], i ); + mlt_service_get_frame( self->producer, &self->frames[ i ], i ); // We're holding these frames until the last_track frame property is received - this->held = 1; + self->held = 1; // When we need to locate the a_frame switch( type ) @@ -304,11 +304,11 @@ static int transition_get_frame( mlt_service service, mlt_frame_ptr frame, int i if ( !active ) { // Hunt for the a_frame - while( a_frame <= b_frame && invalid( this->frames[ a_frame ] ) ) + while( a_frame <= b_frame && invalid( self->frames[ a_frame ] ) ) a_frame ++; // Determine if we're active now - active = a_frame != b_frame && !invalid( this->frames[ b_frame ] ); + active = a_frame != b_frame && !invalid( self->frames[ b_frame ] ); } break; @@ -321,7 +321,7 @@ static int transition_get_frame( mlt_service service, mlt_frame_ptr frame, int i if ( active && !always_active ) { // For non-always-active transitions, we need the current position of the a frame - position = mlt_frame_get_position( this->frames[ a_frame ] ); + position = mlt_frame_get_position( self->frames[ a_frame ] ); // If a is in range, we're active active = position >= in && ( out == 0 || position <= out ); @@ -330,14 +330,14 @@ static int transition_get_frame( mlt_service service, mlt_frame_ptr frame, int i // Finally, process the a and b frames if ( active ) { - mlt_frame a_frame_ptr = this->frames[ !reverse_order ? a_frame : b_frame ]; - mlt_frame b_frame_ptr = this->frames[ !reverse_order ? b_frame : a_frame ]; + mlt_frame a_frame_ptr = self->frames[ !reverse_order ? a_frame : b_frame ]; + mlt_frame b_frame_ptr = self->frames[ !reverse_order ? b_frame : a_frame ]; int a_hide = mlt_properties_get_int( MLT_FRAME_PROPERTIES( a_frame_ptr ), "hide" ); int b_hide = mlt_properties_get_int( MLT_FRAME_PROPERTIES( b_frame_ptr ), "hide" ); if ( !( a_hide & type ) && !( b_hide & type ) ) { // Process the transition - *frame = mlt_transition_process( this, a_frame_ptr, b_frame_ptr ); + *frame = mlt_transition_process( self, a_frame_ptr, b_frame_ptr ); // We need to ensure that the tractor doesn't consider this frame for output if ( *frame == a_frame_ptr ) @@ -353,12 +353,12 @@ static int transition_get_frame( mlt_service service, mlt_frame_ptr frame, int i // Obtain the frame from the cache or the producer we're attached to if ( index >= a_track && index <= b_track ) - *frame = this->frames[ index ]; + *frame = self->frames[ index ]; else - error = mlt_service_get_frame( this->producer, frame, index ); + error = mlt_service_get_frame( self->producer, frame, index ); // Determine if that was the last track - this->held = !mlt_properties_get_int( MLT_FRAME_PROPERTIES( *frame ), "last_track" ); + self->held = !mlt_properties_get_int( MLT_FRAME_PROPERTIES( *frame ), "last_track" ); return error; } @@ -366,23 +366,23 @@ static int transition_get_frame( mlt_service service, mlt_frame_ptr frame, int i /** Close and destroy the transition. * * \public \memberof mlt_transition_s - * \param this a transition + * \param self a transition */ -void mlt_transition_close( mlt_transition this ) +void mlt_transition_close( mlt_transition self ) { - if ( this != NULL && mlt_properties_dec_ref( MLT_TRANSITION_PROPERTIES( this ) ) <= 0 ) + if ( self != NULL && mlt_properties_dec_ref( MLT_TRANSITION_PROPERTIES( self ) ) <= 0 ) { - this->parent.close = NULL; - if ( this->close != NULL ) + self->parent.close = NULL; + if ( self->close != NULL ) { - this->close( this ); + self->close( self ); } else { - mlt_service_close( &this->parent ); - free( this->frames ); - free( this ); + mlt_service_close( &self->parent ); + free( self->frames ); + free( self ); } } } -- 2.39.2