From 42bd0aedb6d3d65bedb98479adcdbaeb326dfee9 Mon Sep 17 00:00:00 2001 From: lilo_booter Date: Thu, 5 Feb 2004 12:27:01 +0000 Subject: [PATCH] westley/libxml2 mods, mcdv/mpeg release integration git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@114 d19143bc-622f-0410-bfdd-b5b2a6649095 --- docs/services.txt | 31 +++++++++- setenv | 4 +- src/framework/mlt_frame.c | 8 +- src/framework/mlt_multitrack.c | 4 +- src/framework/mlt_producer.c | 20 +++--- src/framework/mlt_transition.c | 1 - src/miracle/miracle_unit.c | 108 +++++++++++++++++-------------- src/modules/dv/producer_libdv.c | 3 - src/modules/ffmpeg/consumer_ffmpeg.c | 2 +- src/modules/ffmpeg/producer_ffmpeg.c | 4 +- src/modules/resample/filter_resample.c | 6 +- src/modules/sdl/consumer_sdl.c | 2 +- src/modules/westley/consumer_westley.c | 7 ++- src/modules/westley/producer_westley.c | 28 +++++++- 14 files changed, 142 insertions(+), 86 deletions(-) diff --git a/docs/services.txt b/docs/services.txt index 3a442f6..27864d3 100644 --- a/docs/services.txt +++ b/docs/services.txt @@ -43,8 +43,6 @@ Producers Audio sync discrepancy with some content. Not all libavformat supported formats are seekable. ogg is currently broken. - Multiple mp3 uses in a single instance causes crash (patch - available on request - submitted to ffmpeg mailing list). mpeg seeking is inaccurate - doesn't seek to i-frames so you may get junk for a few frames. @@ -478,6 +476,35 @@ Filters none + obscure + + Description + + Obscuring filter. + + Constructor Argument + + none + + Initialisation Properties + + string start - in the format X,Y:WxH[:PWxPY] + string end - in the format X,Y:WxH[:PWxPY] + int in - in point + int out - out point + + Read Only Properties + + none + + Dependencies + + none + + Known Bugs + + none + resize Description diff --git a/setenv b/setenv index 809cb1c..fe41a89 100644 --- a/setenv +++ b/setenv @@ -9,8 +9,8 @@ export LD_LIBRARY_PATH=\ `pwd`/src/miracle:\ `pwd`/src/modules/bluefish:\ `pwd`/../bluefish/lib:\ -`pwd`/../mpeg_sdk_demo/bin:\ -`pwd`/../dv_sdk +`pwd`/../mpeg_sdk_release/bin:\ +`pwd`/../dv_sdk_release export PATH=\ `pwd`/src/albino:\ diff --git a/src/framework/mlt_frame.c b/src/framework/mlt_frame.c index 880cdef..b576aeb 100644 --- a/src/framework/mlt_frame.c +++ b/src/framework/mlt_frame.c @@ -53,7 +53,7 @@ mlt_frame mlt_frame_init( ) mlt_properties_init( properties, this ); // Set default properties on the frame - mlt_properties_set_position( properties, "position", 0.0 ); + mlt_properties_set_position( properties, "_position", 0.0 ); mlt_properties_set_data( properties, "image", NULL, 0, NULL, NULL ); mlt_properties_set_int( properties, "width", 720 ); mlt_properties_set_int( properties, "height", 576 ); @@ -109,7 +109,7 @@ int mlt_frame_set_aspect_ratio( mlt_frame this, double value ) mlt_position mlt_frame_get_position( mlt_frame this ) { - return mlt_properties_get_position( mlt_frame_properties( this ), "position" ); + return mlt_properties_get_position( mlt_frame_properties( this ), "_position" ); } /** Set the position of this frame. @@ -117,7 +117,7 @@ mlt_position mlt_frame_get_position( mlt_frame this ) int mlt_frame_set_position( mlt_frame this, mlt_position value ) { - return mlt_properties_set_position( mlt_frame_properties( this ), "position", value ); + return mlt_properties_set_position( mlt_frame_properties( this ), "_position", value ); } /** Stack a get_image callback. @@ -721,7 +721,7 @@ int mlt_frame_mix_audio( mlt_frame this, mlt_frame that, float weight, int16_t * double d = 0, s = 0; mlt_frame_get_audio( this, &p_dest, format, &frequency_dest, &channels_dest, &samples_dest ); - //fprintf( stderr, "frame dest samples %d channels %d position %lld\n", samples_dest, channels_dest, mlt_properties_get_position( mlt_frame_properties( this ), "position" ) ); + //fprintf( stderr, "frame dest samples %d channels %d position %lld\n", samples_dest, channels_dest, mlt_properties_get_position( mlt_frame_properties( this ), "_position" ) ); mlt_frame_get_audio( that, &p_src, format, &frequency_src, &channels_src, &samples_src ); //fprintf( stderr, "frame src samples %d channels %d\n", samples_src, channels_src ); src = p_src; diff --git a/src/framework/mlt_multitrack.c b/src/framework/mlt_multitrack.c index ef7a1be..c9ea81c 100644 --- a/src/framework/mlt_multitrack.c +++ b/src/framework/mlt_multitrack.c @@ -371,9 +371,9 @@ static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int ind // Indicate speed of this producer mlt_properties producer_properties = mlt_producer_properties( parent ); - double speed = mlt_properties_get_double( producer_properties, "speed" ); + double speed = mlt_properties_get_double( producer_properties, "_speed" ); mlt_properties properties = mlt_frame_properties( *frame ); - mlt_properties_set_double( properties, "speed", speed ); + mlt_properties_set_double( properties, "_speed", speed ); } else { diff --git a/src/framework/mlt_producer.c b/src/framework/mlt_producer.c index 2a5b60e..1921783 100644 --- a/src/framework/mlt_producer.c +++ b/src/framework/mlt_producer.c @@ -59,10 +59,10 @@ int mlt_producer_init( mlt_producer this, void *child ) // Set the default properties mlt_properties_set( properties, "mlt_type", "mlt_producer" ); - mlt_properties_set_position( properties, "position", 0.0 ); - mlt_properties_set_double( properties, "frame", 0 ); + mlt_properties_set_position( properties, "_position", 0.0 ); + mlt_properties_set_double( properties, "_frame", 0 ); mlt_properties_set_double( properties, "fps", 25.0 ); - mlt_properties_set_double( properties, "speed", 1.0 ); + mlt_properties_set_double( properties, "_speed", 1.0 ); mlt_properties_set_position( properties, "in", 0 ); mlt_properties_set_position( properties, "out", 1799999 ); mlt_properties_set_position( properties, "length", 1800000 ); @@ -109,10 +109,10 @@ int mlt_producer_seek( mlt_producer this, mlt_position position ) position = mlt_producer_get_playtime( this ) - 1; // Set the position - mlt_properties_set_position( mlt_producer_properties( this ), "position", position ); + mlt_properties_set_position( mlt_producer_properties( this ), "_position", position ); // Calculate the absolute frame - mlt_properties_set_position( mlt_producer_properties( this ), "frame", mlt_producer_get_in( this ) + position ); + mlt_properties_set_position( mlt_producer_properties( this ), "_frame", mlt_producer_get_in( this ) + position ); return 0; } @@ -122,7 +122,7 @@ int mlt_producer_seek( mlt_producer this, mlt_position position ) mlt_position mlt_producer_position( mlt_producer this ) { - return mlt_properties_get_position( mlt_producer_properties( this ), "position" ); + return mlt_properties_get_position( mlt_producer_properties( this ), "_position" ); } /** Get the current position (relative to start of producer). @@ -130,7 +130,7 @@ mlt_position mlt_producer_position( mlt_producer this ) mlt_position mlt_producer_frame( mlt_producer this ) { - return mlt_properties_get_position( mlt_producer_properties( this ), "frame" ); + return mlt_properties_get_position( mlt_producer_properties( this ), "_frame" ); } /** Set the playing speed. @@ -138,7 +138,7 @@ mlt_position mlt_producer_frame( mlt_producer this ) int mlt_producer_set_speed( mlt_producer this, double speed ) { - return mlt_properties_set_double( mlt_producer_properties( this ), "speed", speed ); + return mlt_properties_set_double( mlt_producer_properties( this ), "_speed", speed ); } /** Get the playing speed. @@ -146,7 +146,7 @@ int mlt_producer_set_speed( mlt_producer this, double speed ) double mlt_producer_get_speed( mlt_producer this ) { - return mlt_properties_get_double( mlt_producer_properties( this ), "speed" ); + return mlt_properties_get_double( mlt_producer_properties( this ), "_speed" ); } /** Get the frames per second. @@ -261,7 +261,7 @@ static int producer_get_frame( mlt_service service, mlt_frame_ptr frame, int ind mlt_properties properties = mlt_frame_properties( *frame ); mlt_properties_set_double( properties, "fps", mlt_producer_get_fps( this ) ); double speed = mlt_producer_get_speed( this ); - mlt_properties_set_double( properties, "speed", speed ); + mlt_properties_set_double( properties, "_speed", speed ); return 0; } diff --git a/src/framework/mlt_transition.c b/src/framework/mlt_transition.c index 9eb0c46..10d2aee 100644 --- a/src/framework/mlt_transition.c +++ b/src/framework/mlt_transition.c @@ -170,7 +170,6 @@ static int transition_get_frame( mlt_service service, mlt_frame_ptr frame, int i mlt_position in = mlt_properties_get_position( properties, "in" ); mlt_position out = mlt_properties_get_position( properties, "out" ); - // Fetch a and b frames together... if ( ( index == a_track || index == b_track ) && !( this->a_held || this->b_held ) ) { mlt_service_get_frame( this->producer, &this->a_frame, a_track ); diff --git a/src/miracle/miracle_unit.c b/src/miracle/miracle_unit.c index b10179b..0469ae5 100644 --- a/src/miracle/miracle_unit.c +++ b/src/miracle/miracle_unit.c @@ -127,10 +127,59 @@ void miracle_unit_set_notifier( miracle_unit this, valerie_notifier notifier, ch miracle_unit_status_communicate( this ); } +static mlt_producer create_producer( char *file ) +{ + mlt_producer result = NULL; + + // 1st Line preferences + if ( strstr( file, ".inigo" ) ) + result = mlt_factory_producer( "inigo_file", file ); + else if ( strstr( file, ".westley" ) ) + result = mlt_factory_producer( "westley", file ); + else if ( strstr( file, ".mpg" ) ) + result = mlt_factory_producer( "mcmpeg", file ); + else if ( strstr( file, ".mpeg" ) ) + result = mlt_factory_producer( "mcmpeg", file ); + else if ( strstr( file, ".dv" ) ) + result = mlt_factory_producer( "mcdv", file ); + else if ( strstr( file, ".dif" ) ) + result = mlt_factory_producer( "mcdv", file ); + else if ( strstr( file, ".jpg" ) ) + result = mlt_factory_producer( "pixbuf", file ); + else if ( strstr( file, ".JPG" ) ) + result = mlt_factory_producer( "pixbuf", file ); + else if ( strstr( file, ".jpeg" ) ) + result = mlt_factory_producer( "pixbuf", file ); + else if ( strstr( file, ".png" ) ) + result = mlt_factory_producer( "pixbuf", file ); + else if ( strstr( file, ".tga" ) ) + result = mlt_factory_producer( "pixbuf", file ); + else if ( strstr( file, ".txt" ) ) + result = mlt_factory_producer( "pango", file ); + else if ( strstr( file, ".ogg" ) ) + result = mlt_factory_producer( "vorbis", file ); + + // 2nd Line fallbacks + if ( result == NULL && strstr( file, ".dv" ) ) + result = mlt_factory_producer( "libdv", file ); + else if ( result == NULL && strstr( file, ".dif" ) ) + result = mlt_factory_producer( "libdv", file ); + + // 3rd line fallbacks + if ( result == NULL ) + result = mlt_factory_producer( "avformat", file ); + + // 4th line fallbacks + if ( result == NULL ) + result = mlt_factory_producer( "ffmpeg", file ); + + return result; +} + /** Create or locate a producer for the file specified. */ -static mlt_producer create_producer( miracle_unit unit, char *file ) +static mlt_producer locate_producer( miracle_unit unit, char *file ) { // Get the unit properties mlt_properties properties = unit->producers; @@ -140,50 +189,12 @@ static mlt_producer create_producer( miracle_unit unit, char *file ) if ( result == NULL ) { - // 1st Line preferences - if ( strstr( file, ".inigo" ) ) - result = mlt_factory_producer( "inigo_file", file ); - else if ( strstr( file, ".westley" ) ) - result = mlt_factory_producer( "westley", file ); - else if ( strstr( file, ".mpg" ) ) - result = mlt_factory_producer( "mcmpeg", file ); - else if ( strstr( file, ".mpeg" ) ) - result = mlt_factory_producer( "mcmpeg", file ); - else if ( strstr( file, ".dv" ) ) - result = mlt_factory_producer( "mcdv", file ); - else if ( strstr( file, ".dif" ) ) - result = mlt_factory_producer( "mcdv", file ); - else if ( strstr( file, ".jpg" ) ) - result = mlt_factory_producer( "pixbuf", file ); - else if ( strstr( file, ".JPG" ) ) - result = mlt_factory_producer( "pixbuf", file ); - else if ( strstr( file, ".jpeg" ) ) - result = mlt_factory_producer( "pixbuf", file ); - else if ( strstr( file, ".png" ) ) - result = mlt_factory_producer( "pixbuf", file ); - else if ( strstr( file, ".tga" ) ) - result = mlt_factory_producer( "pixbuf", file ); - else if ( strstr( file, ".txt" ) ) - result = mlt_factory_producer( "pango", file ); - else if ( strstr( file, ".ogg" ) ) - result = mlt_factory_producer( "vorbis", file ); - - // 2nd Line fallbacks - if ( result == NULL && strstr( file, ".dv" ) ) - result = mlt_factory_producer( "libdv", file ); - else if ( result == NULL && strstr( file, ".dif" ) ) - result = mlt_factory_producer( "libdv", file ); - - // 3rd line fallbacks - if ( result == NULL ) - result = mlt_factory_producer( "avformat", file ); - - // 4th line fallbacks - if ( result == NULL ) - result = mlt_factory_producer( "ffmpeg", file ); + // Create the producer + result = create_producer( file ); // Now store the result - mlt_properties_set_data( properties, file, result, 0, ( mlt_destructor )mlt_producer_close, NULL ); + if ( result != NULL ) + mlt_properties_set_data( properties, file, result, 0, ( mlt_destructor )mlt_producer_close, NULL ); } return result; @@ -256,15 +267,14 @@ void miracle_unit_report_list( miracle_unit unit, valerie_response response ) valerie_error_code miracle_unit_load( miracle_unit unit, char *clip, int64_t in, int64_t out, int flush ) { - // Have to clear the unit first - clear_unit( unit ); - // Now try to create an producer - mlt_producer instance = create_producer( unit, clip ); + mlt_producer instance = create_producer( clip ); if ( instance != NULL ) { + clear_unit( unit ); mlt_properties properties = unit->properties; + mlt_properties_set_data( unit->producers, clip, instance, 0, ( mlt_destructor )mlt_producer_close, NULL ); mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); mlt_playlist_append_io( playlist, instance, in, out ); miracle_log( LOG_DEBUG, "loaded clip %s", clip ); @@ -277,7 +287,7 @@ valerie_error_code miracle_unit_load( miracle_unit unit, char *clip, int64_t in, valerie_error_code miracle_unit_insert( miracle_unit unit, char *clip, int index, int64_t in, int64_t out ) { - mlt_producer instance = create_producer( unit, clip ); + mlt_producer instance = locate_producer( unit, clip ); if ( instance != NULL ) { @@ -334,7 +344,7 @@ valerie_error_code miracle_unit_move( miracle_unit unit, int src, int dest ) valerie_error_code miracle_unit_append( miracle_unit unit, char *clip, int64_t in, int64_t out ) { - mlt_producer instance = create_producer( unit, clip ); + mlt_producer instance = locate_producer( unit, clip ); if ( instance != NULL ) { diff --git a/src/modules/dv/producer_libdv.c b/src/modules/dv/producer_libdv.c index b82a0e6..24d70bb 100644 --- a/src/modules/dv/producer_libdv.c +++ b/src/modules/dv/producer_libdv.c @@ -138,9 +138,6 @@ static int producer_collect_info( producer_libdv this ) // Parse the header for meta info dv_parse_header( this->dv_decoder, dv_data ); mlt_properties_set_double( properties, "aspect_ratio", dv_format_wide( this->dv_decoder ) ? 16.0/9.0 : 4.0/3.0 ); - - // Set the speed to normal - mlt_properties_set_double( properties, "speed", 1 ); } free( dv_data ); diff --git a/src/modules/ffmpeg/consumer_ffmpeg.c b/src/modules/ffmpeg/consumer_ffmpeg.c index 11f72b7..da11800 100644 --- a/src/modules/ffmpeg/consumer_ffmpeg.c +++ b/src/modules/ffmpeg/consumer_ffmpeg.c @@ -170,7 +170,7 @@ static int consumer_play_audio( consumer_ffmpeg this, mlt_frame frame, int init_ while ( bytes > ( sizeof( this->audio_buffer) - this->audio_avail ) ) pthread_cond_wait( &this->audio_cond, &this->audio_mutex ); mlt_properties properties = mlt_frame_properties( frame ); - if ( mlt_properties_get_double( properties, "speed" ) == 1 ) + if ( mlt_properties_get_double( properties, "_speed" ) == 1 ) memcpy( &this->audio_buffer[ this->audio_avail ], pcm, bytes ); else memset( &this->audio_buffer[ this->audio_avail ], 0, bytes ); diff --git a/src/modules/ffmpeg/producer_ffmpeg.c b/src/modules/ffmpeg/producer_ffmpeg.c index 15b1c89..2432529 100644 --- a/src/modules/ffmpeg/producer_ffmpeg.c +++ b/src/modules/ffmpeg/producer_ffmpeg.c @@ -517,11 +517,11 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i // Get the additional properties double aspect_ratio = mlt_properties_get_double( producer_properties, "aspect_ratio" ); - double speed = mlt_properties_get_double( producer_properties, "speed" ); + double speed = mlt_producer_get_speed( producer ); // Set them on the frame mlt_properties_set_double( properties, "aspect_ratio", aspect_ratio ); - mlt_properties_set_double( properties, "speed", speed ); + mlt_properties_set_double( properties, "_speed", speed ); // Set the out point on the producer if ( this->end_of_video && this->end_of_audio ) diff --git a/src/modules/resample/filter_resample.c b/src/modules/resample/filter_resample.c index 402a278..d4a87e1 100644 --- a/src/modules/resample/filter_resample.c +++ b/src/modules/resample/filter_resample.c @@ -87,8 +87,8 @@ static int resample_get_audio( mlt_frame frame, int16_t **buffer, mlt_audio_form (*buffer)[ i ] = lrint( 32768.0 * sample ); } } - else - fprintf( stderr, "resample_get_audio: %s\n", src_strerror( i ) ); + //else + //fprintf( stderr, "resample_get_audio: %s\n", src_strerror( i ) ); return 0; } @@ -144,7 +144,7 @@ mlt_filter filter_resample_init( char *arg ) } else { - fprintf( stderr, "filter_resample_init: %s\n", src_strerror( error ) ); + //fprintf( stderr, "filter_resample_init: %s\n", src_strerror( error ) ); } } return this; diff --git a/src/modules/sdl/consumer_sdl.c b/src/modules/sdl/consumer_sdl.c index 4fd2068..7ee177d 100644 --- a/src/modules/sdl/consumer_sdl.c +++ b/src/modules/sdl/consumer_sdl.c @@ -303,7 +303,7 @@ static int consumer_play_audio( consumer_sdl this, mlt_frame frame, int init_aud while ( bytes > ( sizeof( this->audio_buffer) - this->audio_avail ) ) pthread_cond_wait( &this->audio_cond, &this->audio_mutex ); mlt_properties properties = mlt_frame_properties( frame ); - if ( mlt_properties_get_double( properties, "speed" ) == 1 ) + if ( mlt_properties_get_double( properties, "_speed" ) == 1 ) memcpy( &this->audio_buffer[ this->audio_avail ], pcm, bytes ); else memset( &this->audio_buffer[ this->audio_avail ], 0, bytes ); diff --git a/src/modules/westley/consumer_westley.c b/src/modules/westley/consumer_westley.c index 3b37440..be075e8 100644 --- a/src/modules/westley/consumer_westley.c +++ b/src/modules/westley/consumer_westley.c @@ -88,8 +88,11 @@ static inline void serialise_properties( mlt_properties properties, xmlNode *nod // Enumerate the properties for ( i = 0; i < mlt_properties_count( properties ); i++ ) { - if ( mlt_properties_get_value( properties, i ) != NULL && - strcmp( mlt_properties_get_name( properties, i ), "westley" ) != 0 ) + char *name = mlt_properties_get_name( properties, i ); + if ( name != NULL && + name[ 0 ] != '_' && + mlt_properties_get_value( properties, i ) != NULL && + strcmp( name, "westley" ) != 0 ) { #if 0 p = xmlNewChild( node, NULL, "prop", NULL ); diff --git a/src/modules/westley/producer_westley.c b/src/modules/westley/producer_westley.c index 8c7d9ca..265475a 100644 --- a/src/modules/westley/producer_westley.c +++ b/src/modules/westley/producer_westley.c @@ -75,12 +75,21 @@ static void track_service( mlt_properties properties, void *service, mlt_destruc static void on_start_tractor( deserialise_context context, const xmlChar *name, const xmlChar **atts) { mlt_service service = mlt_tractor_service( mlt_tractor_init() ); + mlt_properties properties = mlt_service_properties( service ); track_service( context->destructors, service, (mlt_destructor) mlt_tractor_close ); + mlt_properties_set_position( properties, "length", 0 ); + for ( ; atts != NULL && *atts != NULL; atts += 2 ) mlt_properties_set( mlt_service_properties( service ), (char*) atts[0], (char*) atts[1] ); + if ( mlt_properties_get_position( properties, "length" ) < mlt_properties_get_position( properties, "out" ) ) + { + mlt_position length = mlt_properties_get_position( properties, "out" ) + 1; + mlt_properties_set_position( properties, "length", length ); + } + context_push_service( context, service ); } @@ -103,12 +112,20 @@ static void on_start_playlist( deserialise_context context, const xmlChar *name, track_service( context->destructors, service, (mlt_destructor) mlt_playlist_close ); + mlt_properties_set_position( properties, "length", 0 ); + for ( ; atts != NULL && *atts != NULL; atts += 2 ) mlt_properties_set( properties, (char*) atts[0], (char*) atts[1] ); if ( mlt_properties_get( properties, "id" ) != NULL ) mlt_properties_set_data( context->producer_map, mlt_properties_get( properties, "id" ), service, 0, NULL, NULL ); + if ( mlt_properties_get_position( properties, "length" ) < mlt_properties_get_position( properties, "out" ) ) + { + mlt_position length = mlt_properties_get_position( properties, "out" ) + 1; + mlt_properties_set_position( properties, "length", length ); + } + context_push_service( context, service ); } @@ -163,7 +180,7 @@ static void on_start_blank( deserialise_context context, const xmlChar *name, co } // Append a blank to the playlist - mlt_playlist_blank( MLT_PLAYLIST( service ), length ); + mlt_playlist_blank( MLT_PLAYLIST( service ), length - 1 ); // Push the playlist back onto the stack context_push_service( context, service ); @@ -419,11 +436,10 @@ mlt_producer producer_westley_init( char *filename ) if ( !init ) { xmlInitParser(); - init = 1; + //init = 1; } xmlSAXUserParseFile( sax, context, filename ); - free( sax ); // Need the complete producer list for various reasons properties = context->destructors; @@ -466,7 +482,11 @@ mlt_producer producer_westley_init( char *filename ) free( context->stack_service ); mlt_properties_close( context->producer_map ); - free( context ); + //free( context ); + free( sax ); + xmlCleanupParser(); + xmlMemoryDump( ); + return MLT_PRODUCER( service ); } -- 1.7.4.4