From: lilo_booter Date: Fri, 9 Jan 2004 14:21:38 +0000 (+0000) Subject: int64 based comms and more unit functionality X-Git-Url: http://research.m1stereo.tv/gitweb?a=commitdiff_plain;h=80a5c8297b313b09add80814a637a71ba9e0fa05;p=melted int64 based comms and more unit functionality git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@46 d19143bc-622f-0410-bfdd-b5b2a6649095 --- diff --git a/mlt/src/framework/mlt_playlist.c b/mlt/src/framework/mlt_playlist.c index 168bf62..c28705b 100644 --- a/mlt/src/framework/mlt_playlist.c +++ b/mlt/src/framework/mlt_playlist.c @@ -25,6 +25,7 @@ #include #include +#include /** Virtual playlist entry. */ @@ -139,7 +140,7 @@ static int mlt_playlist_virtual_refresh( mlt_playlist this ) // Refresh all properties mlt_properties_set_double( mlt_playlist_properties( this ), "first_fps", fps ); - mlt_properties_set_double( mlt_playlist_properties( this ), "fps", fps ); + mlt_properties_set_double( mlt_playlist_properties( this ), "fps", fps == 0 ? 25 : fps ); mlt_properties_set_timecode( mlt_playlist_properties( this ), "length", playtime ); mlt_properties_set_timecode( mlt_playlist_properties( this ), "out", playtime ); @@ -149,7 +150,7 @@ static int mlt_playlist_virtual_refresh( mlt_playlist this ) /** Append to the virtual playlist. */ -static int mlt_playlist_virtual_append( mlt_playlist this, mlt_producer producer, mlt_timecode in, mlt_timecode out ) +static int mlt_playlist_virtual_append( mlt_playlist this, mlt_producer producer, mlt_timecode in, mlt_timecode playtime ) { // Check that we have room if ( this->count >= this->size ) @@ -164,7 +165,7 @@ static int mlt_playlist_virtual_append( mlt_playlist this, mlt_producer producer this->list[ this->count ] = calloc( sizeof( playlist_entry ), 1 ); this->list[ this->count ]->producer = producer; this->list[ this->count ]->in = in; - this->list[ this->count ]->playtime = out - in; + this->list[ this->count ]->playtime = playtime; this->count ++; @@ -327,6 +328,8 @@ int mlt_playlist_get_clip_info( mlt_playlist this, mlt_playlist_clip_info *info, { mlt_producer producer = this->list[ index ]->producer; mlt_properties properties = mlt_producer_properties( producer ); + info->producer = producer; + info->start = mlt_playlist_clip( this, mlt_whence_relative_start, index ); info->resource = mlt_properties_get( properties, "resource" ); info->in = this->list[ index ]->in; info->out = this->list[ index ]->in + this->list[ index ]->playtime; @@ -403,6 +406,33 @@ int mlt_playlist_move( mlt_playlist this, int from, int to ) return 0; } +int mlt_playlist_resize_clip( mlt_playlist this, int clip, mlt_timecode in, mlt_timecode out ) +{ + int error = clip < 0 || clip >= this->count; + if ( error == 0 ) + { + playlist_entry *entry = this->list[ clip ]; + mlt_producer producer = entry->producer; + + if ( in <= -1 ) + in = 0; + if ( out <= -1 || out >= mlt_producer_get_out( producer ) ) + out = mlt_producer_get_out( producer ); + + if ( out < in ) + { + mlt_timecode t = in; + in = out; + out = t; + } + + entry->in = in; + entry->playtime = out - in; + mlt_playlist_virtual_refresh( this ); + } + return error; +} + /** Get the current frame. */ diff --git a/mlt/src/framework/mlt_playlist.h b/mlt/src/framework/mlt_playlist.h index 8a5ff31..48b4a55 100644 --- a/mlt/src/framework/mlt_playlist.h +++ b/mlt/src/framework/mlt_playlist.h @@ -23,16 +23,18 @@ #include "mlt_producer.h" -/** Structur for returning clip information. +/** Structure for returning clip information. */ typedef struct { + mlt_producer producer; + mlt_timecode start; char *resource; - double in; - double out; - double playtime; - double length; + mlt_timecode in; + mlt_timecode out; + mlt_timecode playtime; + mlt_timecode length; float fps; } mlt_playlist_clip_info; @@ -56,6 +58,7 @@ extern int mlt_playlist_get_clip_info( mlt_playlist this, mlt_playlist_clip_info extern int mlt_playlist_insert( mlt_playlist this, mlt_producer producer, int where, mlt_timecode in, mlt_timecode out ); extern int mlt_playlist_remove( mlt_playlist this, int where ); extern int mlt_playlist_move( mlt_playlist this, int from, int to ); +extern int mlt_playlist_resize_clip( mlt_playlist this, int clip, mlt_timecode in, mlt_timecode out ); extern void mlt_playlist_close( mlt_playlist this ); #endif diff --git a/mlt/src/framework/mlt_producer.c b/mlt/src/framework/mlt_producer.c index 751e19a..277db69 100644 --- a/mlt/src/framework/mlt_producer.c +++ b/mlt/src/framework/mlt_producer.c @@ -87,6 +87,28 @@ mlt_properties mlt_producer_properties( mlt_producer this ) return mlt_service_properties( &this->parent ); } +/** Convert frame position to timecode. +*/ + +mlt_timecode mlt_producer_time( mlt_producer this, int64_t frame ) +{ + if ( frame < 0 ) + return -1; + else + return ( mlt_timecode )frame / mlt_producer_get_fps( this ); +} + +/** Convert timecode to frame position. +*/ + +int64_t mlt_producer_frame_position( mlt_producer this, mlt_timecode position ) +{ + if ( position < 0 ) + return -1; + else + return ( int64_t )( floor( position * mlt_producer_get_fps( this ) + 0.5 ) ); +} + /** Seek to a specified time code. */ diff --git a/mlt/src/framework/mlt_producer.h b/mlt/src/framework/mlt_producer.h index a59a82d..888c3bc 100644 --- a/mlt/src/framework/mlt_producer.h +++ b/mlt/src/framework/mlt_producer.h @@ -46,6 +46,8 @@ struct mlt_producer_s extern int mlt_producer_init( mlt_producer this, void *child ); extern mlt_service mlt_producer_service( mlt_producer this ); extern mlt_properties mlt_producer_properties( mlt_producer this ); +extern mlt_timecode mlt_producer_time( mlt_producer this, int64_t frame ); +extern int64_t mlt_producer_frame_position( mlt_producer this, mlt_timecode position ); extern int mlt_producer_seek( mlt_producer this, mlt_timecode timecode ); extern int mlt_producer_seek_frame( mlt_producer this, uint64_t frame ); extern mlt_timecode mlt_producer_position( mlt_producer this ); diff --git a/mlt/src/framework/mlt_property.c b/mlt/src/framework/mlt_property.c index 22e43c8..f471b18 100644 --- a/mlt/src/framework/mlt_property.c +++ b/mlt/src/framework/mlt_property.c @@ -96,6 +96,17 @@ int mlt_property_set_string( mlt_property this, char *value ) return this->prop_string != NULL; } +/** Set an int64 on this property. +*/ + +int mlt_property_set_int64( mlt_property this, int64_t value ) +{ + mlt_property_clear( this ); + this->types = mlt_prop_int64; + this->prop_int64 = value; + return 0; +} + /** Set a data on this property. */ @@ -123,6 +134,8 @@ int mlt_property_get_int( mlt_property this ) return ( int )this->prop_double; else if ( this->types & mlt_prop_timecode ) return ( int )this->prop_timecode; + else if ( this->types & mlt_prop_int64 ) + return ( int )this->prop_int64; else if ( this->types & mlt_prop_string ) return atoi( this->prop_string ); return 0; @@ -139,6 +152,8 @@ double mlt_property_get_double( mlt_property this ) return ( double )this->prop_int; else if ( this->types & mlt_prop_timecode ) return ( double )this->prop_timecode; + else if ( this->types & mlt_prop_int64 ) + return ( double )this->prop_int64; else if ( this->types & mlt_prop_string ) return atof( this->prop_string ); return 0; @@ -155,11 +170,31 @@ mlt_timecode mlt_property_get_timecode( mlt_property this ) return ( mlt_timecode )this->prop_int; else if ( this->types & mlt_prop_double ) return ( mlt_timecode )this->prop_double; + else if ( this->types & mlt_prop_int64 ) + return ( mlt_timecode )this->prop_int64; else if ( this->types & mlt_prop_string ) return ( mlt_timecode )atof( this->prop_string ); return 0; } +/** Get an int64 from this property. +*/ + +int64_t mlt_property_get_int64( mlt_property this ) +{ + 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_timecode ) + return ( int64_t )this->prop_timecode; + else if ( this->types & mlt_prop_string ) + return ( int64_t )atof( this->prop_string ); + return 0; +} + /** Get a string from this property. */ @@ -186,6 +221,12 @@ char *mlt_property_get_string( mlt_property this ) this->prop_string = malloc( 32 ); sprintf( this->prop_string, "%e", this->prop_timecode ); } + else if ( this->types & mlt_prop_int64 ) + { + this->types |= mlt_prop_string; + this->prop_string = malloc( 32 ); + sprintf( this->prop_string, "%lld", this->prop_int64 ); + } else if ( this->types & mlt_prop_data && this->serialiser != NULL ) { this->types |= mlt_prop_string; diff --git a/mlt/src/framework/mlt_property.h b/mlt/src/framework/mlt_property.h index 8fb209c..6b0def5 100644 --- a/mlt/src/framework/mlt_property.h +++ b/mlt/src/framework/mlt_property.h @@ -33,7 +33,8 @@ typedef enum mlt_prop_string = 2, mlt_prop_timecode = 4, mlt_prop_double = 8, - mlt_prop_data = 16 + mlt_prop_data = 16, + mlt_prop_int64 = 32 } mlt_property_type; @@ -49,6 +50,7 @@ typedef struct mlt_property_s int prop_int; mlt_timecode prop_timecode; double prop_double; + int64_t prop_int64; // String handling char *prop_string; @@ -69,11 +71,13 @@ extern void mlt_property_clear( mlt_property this ); extern int mlt_property_set_int( mlt_property this, int value ); extern int mlt_property_set_double( mlt_property this, double value ); extern int mlt_property_set_timecode( mlt_property this, mlt_timecode value ); +extern int mlt_property_set_uint64( mlt_property this, uint64_t value ); extern int mlt_property_set_string( mlt_property this, char *value ); extern int mlt_property_set_data( mlt_property this, void *value, int length, mlt_destructor destructor, mlt_serialiser serialiser ); extern int mlt_property_get_int( mlt_property this ); extern double mlt_property_get_double( mlt_property this ); extern mlt_timecode mlt_property_get_timecode( mlt_property this ); +extern int64_t mlt_property_get_int64( mlt_property this ); extern char *mlt_property_get_string( mlt_property this ); extern void *mlt_property_get_data( mlt_property this, int *length ); extern void mlt_property_close( mlt_property this ); diff --git a/mlt/src/humperdink/client.c b/mlt/src/humperdink/client.c index 1f0ff3d..0705c14 100644 --- a/mlt/src/humperdink/client.c +++ b/mlt/src/humperdink/client.c @@ -147,7 +147,7 @@ void dv_demo_show_status( dv_demo demo, valerie_status status ) break; } - sprintf( temp + strlen( temp ), " %9.2f %9.2f %9.2f ", status->in, status->position, status->out ); + sprintf( temp + strlen( temp ), " %9lld %9lld %9lld ", status->in, status->position, status->out ); strcat( temp, status->clip ); printf( "%-80.80s\r", temp ); diff --git a/mlt/src/humperdink/remote.c b/mlt/src/humperdink/remote.c index 18ac5a5..9306b21 100644 --- a/mlt/src/humperdink/remote.c +++ b/mlt/src/humperdink/remote.c @@ -20,6 +20,7 @@ /* System header files */ #include +#include /* dv1394d header files */ #include diff --git a/mlt/src/miracle/miracle_local.c b/mlt/src/miracle/miracle_local.c index e9ef50e..501487a 100644 --- a/mlt/src/miracle/miracle_local.c +++ b/mlt/src/miracle/miracle_local.c @@ -455,5 +455,5 @@ static void miracle_local_close( miracle_local local ) pthread_kill_other_threads_np(); miracle_log( LOG_DEBUG, "Clean shutdown." ); free( local ); - mlt_factory_close( ); + //mlt_factory_close( ); } diff --git a/mlt/src/miracle/miracle_unit.c b/mlt/src/miracle/miracle_unit.c index f7d5509..bc90d69 100644 --- a/mlt/src/miracle/miracle_unit.c +++ b/mlt/src/miracle/miracle_unit.c @@ -184,6 +184,9 @@ static void update_generation( miracle_unit unit ) mlt_properties_set_int( properties, "generation", ++ generation ); } +/** Wipe all clips on the playlist for this unit. +*/ + static void clear_unit( miracle_unit unit ) { mlt_properties properties = unit->properties; @@ -210,6 +213,7 @@ void miracle_unit_report_list( miracle_unit unit, valerie_response response ) mlt_properties properties = unit->properties; int generation = mlt_properties_get_int( properties, "generation" ); mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); + mlt_producer producer = mlt_playlist_producer( playlist ); valerie_response_printf( response, 1024, "%d\n", generation ); @@ -217,8 +221,13 @@ void miracle_unit_report_list( miracle_unit unit, valerie_response response ) { mlt_playlist_clip_info info; mlt_playlist_get_clip_info( playlist , &info, i ); - valerie_response_printf( response, 10240, "%d \"%s\" %e %e %e %e %.2f\n", - i, info.resource, info.in, info.out, info.playtime, info.length, info.fps ); + valerie_response_printf( response, 10240, "%d \"%s\" %lld %lld %lld %lld %.2f\n", + i, info.resource, + mlt_producer_frame_position( producer, info.in ), + mlt_producer_frame_position( producer, info.out ), + mlt_producer_frame_position( producer, info.playtime ), + mlt_producer_frame_position( producer, info.length ), + info.fps ); } } @@ -231,7 +240,7 @@ void miracle_unit_report_list( miracle_unit unit, valerie_response response ) \param out The ending frame (-1 for maximum) */ -valerie_error_code miracle_unit_load( miracle_unit unit, char *clip, double in, double out, int flush ) +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 ); @@ -243,7 +252,7 @@ valerie_error_code miracle_unit_load( miracle_unit unit, char *clip, double in, { mlt_properties properties = unit->properties; mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); - mlt_playlist_append_io( playlist, instance, in, out ); + mlt_playlist_append_io( playlist, instance, mlt_producer_time( instance, in ), mlt_producer_time( instance, out ) ); miracle_log( LOG_DEBUG, "loaded clip %s", clip ); miracle_unit_status_communicate( unit ); return valerie_ok; @@ -252,7 +261,7 @@ valerie_error_code miracle_unit_load( miracle_unit unit, char *clip, double in, return valerie_invalid_file; } -valerie_error_code miracle_unit_insert( miracle_unit unit, char *clip, int index, double in, double out ) +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 ); @@ -260,8 +269,9 @@ valerie_error_code miracle_unit_insert( miracle_unit unit, char *clip, int index { mlt_properties properties = unit->properties; mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); - mlt_playlist_insert( playlist, instance, index, in, out ); + mlt_playlist_insert( playlist, instance, index, mlt_producer_time( instance, in ), mlt_producer_time( instance, out ) ); miracle_log( LOG_DEBUG, "inserted clip %s at %d", clip, index ); + update_generation( unit ); miracle_unit_status_communicate( unit ); return valerie_ok; } @@ -275,6 +285,7 @@ valerie_error_code miracle_unit_remove( miracle_unit unit, int index ) mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); mlt_playlist_remove( playlist, index ); miracle_log( LOG_DEBUG, "removed clip at %d", index ); + update_generation( unit ); miracle_unit_status_communicate( unit ); return valerie_ok; } @@ -292,6 +303,7 @@ valerie_error_code miracle_unit_move( miracle_unit unit, int src, int dest ) mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); mlt_playlist_move( playlist, src, dest ); miracle_log( LOG_DEBUG, "moved clip %d to %d", src, dest ); + update_generation( unit ); miracle_unit_status_communicate( unit ); return valerie_ok; } @@ -305,7 +317,7 @@ valerie_error_code miracle_unit_move( miracle_unit unit, int src, int dest ) \param out The ending frame (-1 for maximum) */ -valerie_error_code miracle_unit_append( miracle_unit unit, char *clip, double in, double out ) +valerie_error_code miracle_unit_append( miracle_unit unit, char *clip, int64_t in, int64_t out ) { mlt_producer instance = create_producer( unit, clip ); @@ -313,8 +325,9 @@ valerie_error_code miracle_unit_append( miracle_unit unit, char *clip, double in { mlt_properties properties = unit->properties; mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); - mlt_playlist_append_io( playlist, instance, in, out ); + mlt_playlist_append_io( playlist, instance, mlt_producer_time( instance, in ), mlt_producer_time( instance, out ) ); miracle_log( LOG_DEBUG, "appended clip %s", clip ); + update_generation( unit ); miracle_unit_status_communicate( unit ); return valerie_ok; } @@ -404,13 +417,21 @@ int miracle_unit_get_status( miracle_unit unit, valerie_status status ) strncpy( status->clip, info.resource, sizeof( status->clip ) ); status->speed = (int)( mlt_producer_get_speed( producer ) * 1000.0 ); status->fps = mlt_producer_get_fps( producer ); - status->in = info.in; - status->out = info.in + info.playtime; - status->position = mlt_producer_position( clip ); - status->length = mlt_producer_get_length( clip ); + status->in = mlt_producer_frame_position( producer, info.in ); + status->out = mlt_producer_frame_position( producer, info.out ); + status->position = mlt_producer_frame_position( producer, mlt_producer_position( clip ) ); + status->length = mlt_producer_frame_position( producer, mlt_producer_get_length( clip ) ); + strncpy( status->tail_clip, info.resource, sizeof( status->tail_clip ) ); + status->tail_in = mlt_producer_frame_position( producer, info.in ); + status->tail_out = mlt_producer_frame_position( producer, info.out ); + status->tail_position = mlt_producer_frame_position( producer, mlt_producer_position( clip ) ); + status->tail_length = mlt_producer_frame_position( producer, mlt_producer_get_length( clip ) ); + status->clip_index = mlt_playlist_current_clip( playlist ); status->seek_flag = 1; } + status->generation = mlt_properties_get_int( properties, "generation" ); + if ( !strcmp( status->clip, "" ) ) status->status = unit_not_loaded; else if ( status->speed == 0 ) @@ -431,8 +452,40 @@ int miracle_unit_get_status( miracle_unit unit, valerie_status status ) /** Change position in the playlist. */ -void miracle_unit_change_position( miracle_unit unit, int clip, double position ) +void miracle_unit_change_position( miracle_unit unit, int clip, int64_t position ) { + mlt_properties properties = unit->properties; + mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); + mlt_producer producer = mlt_playlist_producer( playlist ); + mlt_playlist_clip_info info; + + if ( clip < 0 ) + clip = 0; + else if ( clip >= mlt_playlist_count( playlist ) ) + clip = mlt_playlist_count( playlist ); + + if ( mlt_playlist_get_clip_info( playlist, &info, clip ) == 0 ) + { + mlt_timecode relative = mlt_producer_time( info.producer, position ); + mlt_timecode absolute = relative - info.in; + int64_t frame_start = mlt_producer_frame_position( info.producer, info.start ); + int64_t frame_offset = 0; + + if ( absolute < 0 ) + frame_offset = 0; + else if ( absolute >= info.out ) + frame_offset = mlt_producer_frame_position( info.producer, info.out ) - 1; + else + frame_offset = mlt_producer_frame_position( info.producer, absolute ); + + mlt_producer_seek_frame( producer, frame_start + frame_offset ); + } + else + { + mlt_timecode out = mlt_producer_get_out( producer ); + mlt_producer_seek( producer, mlt_producer_frame_position( producer, out ) - 1 ); + } + miracle_unit_status_communicate( unit ); } @@ -450,26 +503,56 @@ int miracle_unit_get_current_clip( miracle_unit unit ) /** Set a clip's in point */ -int miracle_unit_set_clip_in( miracle_unit unit, int index, double position ) +int miracle_unit_set_clip_in( miracle_unit unit, int index, int64_t position ) { - int error = 0; + mlt_properties properties = unit->properties; + mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); + mlt_playlist_clip_info info; + int error = mlt_playlist_get_clip_info( playlist, &info, index ); + + if ( error == 0 ) + { + mlt_timecode in = mlt_producer_time( info.producer, position ); + error = mlt_playlist_resize_clip( playlist, index, in, info.out ); + update_generation( unit ); + miracle_unit_change_position( unit, index, 0 ); + } + return error; } /** Set a clip's out point. */ -int miracle_unit_set_clip_out( miracle_unit unit, int index, double position ) +int miracle_unit_set_clip_out( miracle_unit unit, int index, int64_t position ) { - int error = 0; + mlt_properties properties = unit->properties; + mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); + mlt_playlist_clip_info info; + int error = mlt_playlist_get_clip_info( playlist, &info, index ); + + if ( error == 0 ) + { + mlt_timecode out = mlt_producer_time( info.producer, position ); + error = mlt_playlist_resize_clip( playlist, index, info.in, out ); + update_generation( unit ); + miracle_unit_status_communicate( unit ); + miracle_unit_change_position( unit, index, 0 ); + } + return error; } /** Step by specified position. */ -void miracle_unit_step( miracle_unit unit, double offset ) +void miracle_unit_step( miracle_unit unit, int64_t offset ) { + mlt_properties properties = unit->properties; + mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); + mlt_producer producer = mlt_playlist_producer( playlist ); + mlt_timecode position = mlt_producer_position( producer ); + mlt_producer_seek( producer, position + mlt_producer_time( producer, offset ) ); } /** Set the unit's clip mode regarding in and out points. diff --git a/mlt/src/miracle/miracle_unit.h b/mlt/src/miracle/miracle_unit.h index 1acb949..7670b45 100644 --- a/mlt/src/miracle/miracle_unit.h +++ b/mlt/src/miracle/miracle_unit.h @@ -42,9 +42,9 @@ miracle_unit_t, *miracle_unit; extern miracle_unit miracle_unit_init( int index, char *arg ); extern void miracle_unit_report_list( miracle_unit unit, valerie_response response ); extern void miracle_unit_allow_stdin( miracle_unit unit, int flag ); -extern valerie_error_code miracle_unit_load( miracle_unit unit, char *clip, double in, double out, int flush ); -extern valerie_error_code miracle_unit_insert( miracle_unit unit, char *clip, int index, double in, double out ); -extern valerie_error_code miracle_unit_append( miracle_unit unit, char *clip, double in, double out ); +extern valerie_error_code miracle_unit_load( miracle_unit unit, char *clip, int64_t in, int64_t out, int flush ); +extern valerie_error_code miracle_unit_insert( miracle_unit unit, char *clip, int index, int64_t in, int64_t out ); +extern valerie_error_code miracle_unit_append( miracle_unit unit, char *clip, int64_t in, int64_t out ); extern valerie_error_code miracle_unit_remove( miracle_unit unit, int index ); extern valerie_error_code miracle_unit_clean( miracle_unit unit ); extern valerie_error_code miracle_unit_move( miracle_unit unit, int src, int dest ); @@ -57,15 +57,15 @@ extern int miracle_unit_get_channel( miracle_unit unit ); extern int miracle_unit_is_offline( miracle_unit unit ); extern void miracle_unit_set_notifier( miracle_unit, valerie_notifier, char * ); extern int miracle_unit_get_status( miracle_unit, valerie_status ); -extern void miracle_unit_change_position( miracle_unit, int, double position ); +extern void miracle_unit_change_position( miracle_unit, int, int64_t position ); extern void miracle_unit_change_speed( miracle_unit unit, int speed ); -extern int miracle_unit_set_clip_in( miracle_unit unit, int index, double position ); -extern int miracle_unit_set_clip_out( miracle_unit unit, int index, double position ); +extern int miracle_unit_set_clip_in( miracle_unit unit, int index, int64_t position ); +extern int miracle_unit_set_clip_out( miracle_unit unit, int index, int64_t position ); //extern void miracle_unit_set_mode( miracle_unit unit, dv_player_clip_mode mode ); //extern dv_player_clip_mode miracle_unit_get_mode( miracle_unit unit ); //extern void miracle_unit_set_eof_action( miracle_unit unit, dv_player_eof_action mode ); //extern dv_player_eof_action miracle_unit_get_eof_action( miracle_unit unit ); -extern void miracle_unit_step( miracle_unit unit, double offset ); +extern void miracle_unit_step( miracle_unit unit, int64_t offset ); extern void miracle_unit_close( miracle_unit unit ); extern void miracle_unit_suspend( miracle_unit ); extern void miracle_unit_restore( miracle_unit ); diff --git a/mlt/src/miracle/miracle_unit_commands.c b/mlt/src/miracle/miracle_unit_commands.c index c85aff0..e0f6003 100644 --- a/mlt/src/miracle/miracle_unit_commands.c +++ b/mlt/src/miracle/miracle_unit_commands.c @@ -56,11 +56,11 @@ int miracle_load( command_argument cmd_arg ) return RESPONSE_INVALID_UNIT; else { - double in = -1, out = -1; + int64_t in = -1, out = -1; if ( valerie_tokeniser_count( cmd_arg->tokeniser ) == 5 ) { - in = atof( valerie_tokeniser_get_string( cmd_arg->tokeniser, 3 ) ); - out = atof( valerie_tokeniser_get_string( cmd_arg->tokeniser, 4 ) ); + in = atol( valerie_tokeniser_get_string( cmd_arg->tokeniser, 3 ) ); + out = atol( valerie_tokeniser_get_string( cmd_arg->tokeniser, 4 ) ); } if ( miracle_unit_load( unit, fullname, in, out, flush ) != valerie_ok ) return RESPONSE_BAD_FILE; @@ -207,11 +207,11 @@ int miracle_append( command_argument cmd_arg ) return RESPONSE_INVALID_UNIT; else { - double in = -1, out = -1; + int64_t in = -1, out = -1; if ( valerie_tokeniser_count( cmd_arg->tokeniser ) == 5 ) { - in = atof( valerie_tokeniser_get_string( cmd_arg->tokeniser, 3 ) ); - out = atof( valerie_tokeniser_get_string( cmd_arg->tokeniser, 4 ) ); + in = atol( valerie_tokeniser_get_string( cmd_arg->tokeniser, 3 ) ); + out = atol( valerie_tokeniser_get_string( cmd_arg->tokeniser, 4 ) ); } switch ( miracle_unit_append( unit, fullname, in, out ) ) { @@ -311,17 +311,16 @@ int miracle_ff( command_argument cmd_arg ) int miracle_set_in_point( command_argument cmd_arg ) { - /* - dv_unit unit = miracle_get_unit(cmd_arg->unit); + miracle_unit unit = miracle_get_unit(cmd_arg->unit); int clip = parse_clip( cmd_arg, 3 ); - - if (unit == NULL || dv_unit_is_offline(unit)) + + if ( unit == NULL ) return RESPONSE_INVALID_UNIT; else { int position = *(int *) cmd_arg->argument; - switch( dv_unit_set_clip_in( unit, clip, position ) ) + switch( miracle_unit_set_clip_in( unit, clip, position ) ) { case -1: return RESPONSE_BAD_FILE; @@ -329,23 +328,21 @@ int miracle_set_in_point( command_argument cmd_arg ) return RESPONSE_OUT_OF_RANGE; } } - */ return RESPONSE_SUCCESS; } int miracle_set_out_point( command_argument cmd_arg ) { - /* - dv_unit unit = miracle_get_unit(cmd_arg->unit); + miracle_unit unit = miracle_get_unit(cmd_arg->unit); int clip = parse_clip( cmd_arg, 3 ); - if (unit == NULL || dv_unit_is_offline(unit)) + if ( unit == NULL ) return RESPONSE_INVALID_UNIT; else { int position = *(int *) cmd_arg->argument; - switch( dv_unit_set_clip_out( unit, clip, position ) ) + switch( miracle_unit_set_clip_out( unit, clip, position ) ) { case -1: return RESPONSE_BAD_FILE; @@ -353,7 +350,7 @@ int miracle_set_out_point( command_argument cmd_arg ) return RESPONSE_OUT_OF_RANGE; } } - */ + return RESPONSE_SUCCESS; } diff --git a/mlt/src/modules/dv/producer_libdv.c b/mlt/src/modules/dv/producer_libdv.c index 4e2e9f7..8c139df 100644 --- a/mlt/src/modules/dv/producer_libdv.c +++ b/mlt/src/modules/dv/producer_libdv.c @@ -134,7 +134,7 @@ static int producer_collect_info( producer_libdv this ) mlt_properties_set_double( properties, "fps", fps ); mlt_properties_set_timecode( properties, "length", length ); mlt_properties_set_timecode( properties, "in", 0.0 ); - mlt_properties_set_timecode( properties, "out", length ); + mlt_properties_set_timecode( properties, "out", ( mlt_timecode )( this->frames_in_file - 1 ) / fps ); // Parse the header for meta info dv_parse_header( this->dv_decoder, dv_data ); diff --git a/mlt/src/valerie/valerie.c b/mlt/src/valerie/valerie.c index 4157284..f273153 100644 --- a/mlt/src/valerie/valerie.c +++ b/mlt/src/valerie/valerie.c @@ -223,9 +223,9 @@ static void valerie_interpret_clip_offset( char *output, valerie_clip_offset off /** Load a file on the specified unit with the specified in/out points. */ -valerie_error_code valerie_unit_load_clipped( valerie this, int unit, char *file, double in, double out ) +valerie_error_code valerie_unit_load_clipped( valerie this, int unit, char *file, int64_t in, int64_t out ) { - return valerie_execute( this, 10240, "LOAD U%d \"%s\" %e %e", unit, file, in, out ); + return valerie_execute( this, 10240, "LOAD U%d \"%s\" %lld %lld", unit, file, in, out ); } /** Load a file on the specified unit at the end of the current pump. @@ -239,17 +239,17 @@ valerie_error_code valerie_unit_load_back( valerie this, int unit, char *file ) /** Load a file on the specified unit at the end of the pump with the specified in/out points. */ -valerie_error_code valerie_unit_load_back_clipped( valerie this, int unit, char *file, double in, double out ) +valerie_error_code valerie_unit_load_back_clipped( valerie this, int unit, char *file, int64_t in, int64_t out ) { - return valerie_execute( this, 10240, "LOAD U%d \"!%s\" %e %e", unit, file, in, out ); + return valerie_execute( this, 10240, "LOAD U%d \"!%s\" %lld %lld", unit, file, in, out ); } /** Append a file on the specified unit. */ -valerie_error_code valerie_unit_append( valerie this, int unit, char *file, double in, double out ) +valerie_error_code valerie_unit_append( valerie this, int unit, char *file, int64_t in, int64_t out ) { - return valerie_execute( this, 10240, "APND U%d \"%s\" %e %e", unit, file, in, out ); + return valerie_execute( this, 10240, "APND U%d \"%s\" %lld %lld", unit, file, in, out ); } /** Clean the unit - this function removes all but the currently playing clip. @@ -293,11 +293,11 @@ valerie_error_code valerie_unit_remove_current_clip( valerie this, int unit ) /** Insert clip at the specified position. */ -valerie_error_code valerie_unit_clip_insert( valerie this, int unit, valerie_clip_offset offset, int clip, char *file, double in, double out ) +valerie_error_code valerie_unit_clip_insert( valerie this, int unit, valerie_clip_offset offset, int clip, char *file, int64_t in, int64_t out ) { char temp[ 100 ]; valerie_interpret_clip_offset( temp, offset, clip ); - return valerie_execute( this, 1024, "INSERT U%d %s %s %e %e", unit, file, temp, in, out ); + return valerie_execute( this, 1024, "INSERT U%d %s %s %lld %lld", unit, file, temp, in, out ); } /** Play the unit at normal speed. @@ -351,63 +351,63 @@ valerie_error_code valerie_unit_fast_forward( valerie this, int unit ) /** Step by the number of frames on the specified unit. */ -valerie_error_code valerie_unit_step( valerie this, int unit, double step ) +valerie_error_code valerie_unit_step( valerie this, int unit, int64_t step ) { - return valerie_execute( this, 1024, "STEP U%d %e", unit, step ); + return valerie_execute( this, 1024, "STEP U%d %lld", unit, step ); } /** Goto the specified frame on the specified unit. */ -valerie_error_code valerie_unit_goto( valerie this, int unit, double position ) +valerie_error_code valerie_unit_goto( valerie this, int unit, int64_t position ) { - return valerie_execute( this, 1024, "GOTO U%d %e", unit, position ); + return valerie_execute( this, 1024, "GOTO U%d %lld", unit, position ); } /** Goto the specified frame in the clip on the specified unit. */ -valerie_error_code valerie_unit_clip_goto( valerie this, int unit, valerie_clip_offset offset, int clip, double position ) +valerie_error_code valerie_unit_clip_goto( valerie this, int unit, valerie_clip_offset offset, int clip, int64_t position ) { char temp[ 100 ]; valerie_interpret_clip_offset( temp, offset, clip ); - return valerie_execute( this, 1024, "GOTO U%d %e %s", unit, position, temp ); + return valerie_execute( this, 1024, "GOTO U%d %lld %s", unit, position, temp ); } /** Set the in point of the loaded file on the specified unit. */ -valerie_error_code valerie_unit_set_in( valerie this, int unit, double in ) +valerie_error_code valerie_unit_set_in( valerie this, int unit, int64_t in ) { - return valerie_execute( this, 1024, "SIN U%d %e", unit, in ); + return valerie_execute( this, 1024, "SIN U%d %lld", unit, in ); } /** Set the in point of the clip on the specified unit. */ -valerie_error_code valerie_unit_clip_set_in( valerie this, int unit, valerie_clip_offset offset, int clip, double in ) +valerie_error_code valerie_unit_clip_set_in( valerie this, int unit, valerie_clip_offset offset, int clip, int64_t in ) { char temp[ 100 ]; valerie_interpret_clip_offset( temp, offset, clip ); - return valerie_execute( this, 1024, "SIN U%d %e %s", unit, in, temp ); + return valerie_execute( this, 1024, "SIN U%d %lld %s", unit, in, temp ); } /** Set the out point of the loaded file on the specified unit. */ -valerie_error_code valerie_unit_set_out( valerie this, int unit, double out ) +valerie_error_code valerie_unit_set_out( valerie this, int unit, int64_t out ) { - return valerie_execute( this, 1024, "SOUT U%d %e", unit, out ); + return valerie_execute( this, 1024, "SOUT U%d %lld", unit, out ); } /** Set the out point of the clip on the specified unit. */ -valerie_error_code valerie_unit_clip_set_out( valerie this, int unit, valerie_clip_offset offset, int clip, double in ) +valerie_error_code valerie_unit_clip_set_out( valerie this, int unit, valerie_clip_offset offset, int clip, int64_t in ) { char temp[ 100 ]; valerie_interpret_clip_offset( temp, offset, clip ); - return valerie_execute( this, 1024, "SOUT U%d %e %s", unit, in, temp ); + return valerie_execute( this, 1024, "SOUT U%d %lld %s", unit, in, temp ); } /** Clear the in point of the loaded file on the specified unit. @@ -624,10 +624,10 @@ valerie_error_code valerie_list_get( valerie_list list, int index, valerie_list_ entry->clip = atoi( valerie_tokeniser_get_string( tokeniser, 0 ) ); valerie_util_strip( valerie_tokeniser_get_string( tokeniser, 1 ), '\"' ); strcpy( entry->full, valerie_tokeniser_get_string( tokeniser, 1 ) ); - entry->in = atof( valerie_tokeniser_get_string( tokeniser, 2 ) ); - entry->out = atof( valerie_tokeniser_get_string( tokeniser, 3 ) ); - entry->max = atof( valerie_tokeniser_get_string( tokeniser, 4 ) ); - entry->size = atof( valerie_tokeniser_get_string( tokeniser, 5 ) ); + entry->in = atol( valerie_tokeniser_get_string( tokeniser, 2 ) ); + entry->out = atol( valerie_tokeniser_get_string( tokeniser, 3 ) ); + entry->max = atol( valerie_tokeniser_get_string( tokeniser, 4 ) ); + entry->size = atol( valerie_tokeniser_get_string( tokeniser, 5 ) ); entry->fps = atof( valerie_tokeniser_get_string( tokeniser, 6 ) ); } valerie_tokeniser_close( tokeniser ); diff --git a/mlt/src/valerie/valerie.h b/mlt/src/valerie/valerie.h index fc3b059..658ef9a 100644 --- a/mlt/src/valerie/valerie.h +++ b/mlt/src/valerie/valerie.h @@ -90,28 +90,28 @@ extern valerie_error_code valerie_run( valerie, char * ); /* Unit functions */ extern valerie_error_code valerie_unit_add( valerie, char *, int * ); extern valerie_error_code valerie_unit_load( valerie, int, char * ); -extern valerie_error_code valerie_unit_load_clipped( valerie, int, char *, double, double ); +extern valerie_error_code valerie_unit_load_clipped( valerie, int, char *, int64_t, int64_t ); extern valerie_error_code valerie_unit_load_back( valerie, int, char * ); -extern valerie_error_code valerie_unit_load_back_clipped( valerie, int, char *, double, double ); -extern valerie_error_code valerie_unit_append( valerie, int, char *, double, double ); +extern valerie_error_code valerie_unit_load_back_clipped( valerie, int, char *, int64_t, int64_t ); +extern valerie_error_code valerie_unit_append( valerie, int, char *, int64_t, int64_t ); extern valerie_error_code valerie_unit_clean( valerie, int ); extern valerie_error_code valerie_unit_clip_move( valerie, int, valerie_clip_offset, int, valerie_clip_offset, int ); extern valerie_error_code valerie_unit_clip_remove( valerie, int, valerie_clip_offset, int ); extern valerie_error_code valerie_unit_remove_current_clip( valerie, int ); -extern valerie_error_code valerie_unit_clip_insert( valerie, int, valerie_clip_offset, int, char *, double, double ); +extern valerie_error_code valerie_unit_clip_insert( valerie, int, valerie_clip_offset, int, char *, int64_t, int64_t ); extern valerie_error_code valerie_unit_play( valerie, int ); extern valerie_error_code valerie_unit_play_at_speed( valerie, int, int ); extern valerie_error_code valerie_unit_stop( valerie, int ); extern valerie_error_code valerie_unit_pause( valerie, int ); extern valerie_error_code valerie_unit_rewind( valerie, int ); extern valerie_error_code valerie_unit_fast_forward( valerie, int ); -extern valerie_error_code valerie_unit_step( valerie, int, double ); -extern valerie_error_code valerie_unit_goto( valerie, int, double ); -extern valerie_error_code valerie_unit_clip_goto( valerie, int, valerie_clip_offset, int, double ); -extern valerie_error_code valerie_unit_clip_set_in( valerie, int, valerie_clip_offset, int, double ); -extern valerie_error_code valerie_unit_clip_set_out( valerie, int, valerie_clip_offset, int, double ); -extern valerie_error_code valerie_unit_set_in( valerie, int, double ); -extern valerie_error_code valerie_unit_set_out( valerie, int, double ); +extern valerie_error_code valerie_unit_step( valerie, int, int64_t ); +extern valerie_error_code valerie_unit_goto( valerie, int, int64_t ); +extern valerie_error_code valerie_unit_clip_goto( valerie, int, valerie_clip_offset, int, int64_t ); +extern valerie_error_code valerie_unit_clip_set_in( valerie, int, valerie_clip_offset, int, int64_t ); +extern valerie_error_code valerie_unit_clip_set_out( valerie, int, valerie_clip_offset, int, int64_t ); +extern valerie_error_code valerie_unit_set_in( valerie, int, int64_t ); +extern valerie_error_code valerie_unit_set_out( valerie, int, int64_t ); extern valerie_error_code valerie_unit_clear_in( valerie, int ); extern valerie_error_code valerie_unit_clear_out( valerie, int ); extern valerie_error_code valerie_unit_clear_in_out( valerie, int ); @@ -169,11 +169,11 @@ typedef struct { int clip; char full[ PATH_MAX + NAME_MAX ]; - double in; - double out; - double max; - double size; - double fps; + int64_t in; + int64_t out; + int64_t max; + int64_t size; + int64_t fps; } *valerie_list_entry, valerie_list_entry_t; diff --git a/mlt/src/valerie/valerie_status.c b/mlt/src/valerie/valerie_status.c index 5725b0c..5e4cbd2 100644 --- a/mlt/src/valerie/valerie_status.c +++ b/mlt/src/valerie/valerie_status.c @@ -38,21 +38,21 @@ void valerie_status_parse( valerie_status status, char *text ) { status->unit = atoi( valerie_tokeniser_get_string( tokeniser, 0 ) ); strncpy( status->clip, valerie_util_strip( valerie_tokeniser_get_string( tokeniser, 2 ), '\"' ), sizeof( status->clip ) ); - status->position = atof( valerie_tokeniser_get_string( tokeniser, 3 ) ); + status->position = atol( valerie_tokeniser_get_string( tokeniser, 3 ) ); status->speed = atoi( valerie_tokeniser_get_string( tokeniser, 4 ) ); status->fps = atof( valerie_tokeniser_get_string( tokeniser, 5 ) ); - status->in = atof( valerie_tokeniser_get_string( tokeniser, 6 ) ); - status->out = atof( valerie_tokeniser_get_string( tokeniser, 7 ) ); - status->length = atof( valerie_tokeniser_get_string( tokeniser, 8 ) ); + status->in = atol( valerie_tokeniser_get_string( tokeniser, 6 ) ); + status->out = atol( valerie_tokeniser_get_string( tokeniser, 7 ) ); + status->length = atol( valerie_tokeniser_get_string( tokeniser, 8 ) ); strncpy( status->tail_clip, valerie_util_strip( valerie_tokeniser_get_string( tokeniser, 9 ), '\"' ), sizeof( status->tail_clip ) ); - status->tail_position = atof( valerie_tokeniser_get_string( tokeniser, 10 ) ); - status->tail_in = atof( valerie_tokeniser_get_string( tokeniser, 11 ) ); - status->tail_out = atof( valerie_tokeniser_get_string( tokeniser, 12 ) ); - status->tail_length = atof( valerie_tokeniser_get_string( tokeniser, 13 ) ); - status->seek_flag = atof( valerie_tokeniser_get_string( tokeniser, 14 ) ); - status->generation = atof( valerie_tokeniser_get_string( tokeniser, 15 ) ); - status->clip_index = atof( valerie_tokeniser_get_string( tokeniser, 16 ) ); + status->tail_position = atol( valerie_tokeniser_get_string( tokeniser, 10 ) ); + status->tail_in = atol( valerie_tokeniser_get_string( tokeniser, 11 ) ); + status->tail_out = atol( valerie_tokeniser_get_string( tokeniser, 12 ) ); + status->tail_length = atol( valerie_tokeniser_get_string( tokeniser, 13 ) ); + status->seek_flag = atoi( valerie_tokeniser_get_string( tokeniser, 14 ) ); + status->generation = atoi( valerie_tokeniser_get_string( tokeniser, 15 ) ); + status->clip_index = atoi( valerie_tokeniser_get_string( tokeniser, 16 ) ); if ( !strcmp( valerie_tokeniser_get_string( tokeniser, 1 ), "unknown" ) ) status->status = unit_unknown; @@ -121,7 +121,7 @@ char *valerie_status_serialise( valerie_status status, char *text, int length ) break; } - snprintf( text, length, "%d %s \"%s\" %e %e %.2f %e %e %e \"%s\" %e %e %e %e %d %d %d\r\n", + snprintf( text, length, "%d %s \"%s\" %lld %d %.2f %lld %lld %lld \"%s\" %lld %lld %lld %lld %d %d %d\r\n", status->unit, status_string, status->clip, diff --git a/mlt/src/valerie/valerie_status.h b/mlt/src/valerie/valerie_status.h index d0e45a9..5da7497 100644 --- a/mlt/src/valerie/valerie_status.h +++ b/mlt/src/valerie/valerie_status.h @@ -50,17 +50,17 @@ typedef struct int unit; unit_status status; char clip[ 2048 ]; - double position; - double speed; + int64_t position; + int speed; double fps; - double in; - double out; - double length; + int64_t in; + int64_t out; + int64_t length; char tail_clip[ 2048 ]; - double tail_position; - double tail_in; - double tail_out; - double tail_length; + int64_t tail_position; + int64_t tail_in; + int64_t tail_out; + int64_t tail_length; int seek_flag; int generation; int clip_index; diff --git a/src/framework/mlt_playlist.c b/src/framework/mlt_playlist.c index 168bf62..c28705b 100644 --- a/src/framework/mlt_playlist.c +++ b/src/framework/mlt_playlist.c @@ -25,6 +25,7 @@ #include #include +#include /** Virtual playlist entry. */ @@ -139,7 +140,7 @@ static int mlt_playlist_virtual_refresh( mlt_playlist this ) // Refresh all properties mlt_properties_set_double( mlt_playlist_properties( this ), "first_fps", fps ); - mlt_properties_set_double( mlt_playlist_properties( this ), "fps", fps ); + mlt_properties_set_double( mlt_playlist_properties( this ), "fps", fps == 0 ? 25 : fps ); mlt_properties_set_timecode( mlt_playlist_properties( this ), "length", playtime ); mlt_properties_set_timecode( mlt_playlist_properties( this ), "out", playtime ); @@ -149,7 +150,7 @@ static int mlt_playlist_virtual_refresh( mlt_playlist this ) /** Append to the virtual playlist. */ -static int mlt_playlist_virtual_append( mlt_playlist this, mlt_producer producer, mlt_timecode in, mlt_timecode out ) +static int mlt_playlist_virtual_append( mlt_playlist this, mlt_producer producer, mlt_timecode in, mlt_timecode playtime ) { // Check that we have room if ( this->count >= this->size ) @@ -164,7 +165,7 @@ static int mlt_playlist_virtual_append( mlt_playlist this, mlt_producer producer this->list[ this->count ] = calloc( sizeof( playlist_entry ), 1 ); this->list[ this->count ]->producer = producer; this->list[ this->count ]->in = in; - this->list[ this->count ]->playtime = out - in; + this->list[ this->count ]->playtime = playtime; this->count ++; @@ -327,6 +328,8 @@ int mlt_playlist_get_clip_info( mlt_playlist this, mlt_playlist_clip_info *info, { mlt_producer producer = this->list[ index ]->producer; mlt_properties properties = mlt_producer_properties( producer ); + info->producer = producer; + info->start = mlt_playlist_clip( this, mlt_whence_relative_start, index ); info->resource = mlt_properties_get( properties, "resource" ); info->in = this->list[ index ]->in; info->out = this->list[ index ]->in + this->list[ index ]->playtime; @@ -403,6 +406,33 @@ int mlt_playlist_move( mlt_playlist this, int from, int to ) return 0; } +int mlt_playlist_resize_clip( mlt_playlist this, int clip, mlt_timecode in, mlt_timecode out ) +{ + int error = clip < 0 || clip >= this->count; + if ( error == 0 ) + { + playlist_entry *entry = this->list[ clip ]; + mlt_producer producer = entry->producer; + + if ( in <= -1 ) + in = 0; + if ( out <= -1 || out >= mlt_producer_get_out( producer ) ) + out = mlt_producer_get_out( producer ); + + if ( out < in ) + { + mlt_timecode t = in; + in = out; + out = t; + } + + entry->in = in; + entry->playtime = out - in; + mlt_playlist_virtual_refresh( this ); + } + return error; +} + /** Get the current frame. */ diff --git a/src/framework/mlt_playlist.h b/src/framework/mlt_playlist.h index 8a5ff31..48b4a55 100644 --- a/src/framework/mlt_playlist.h +++ b/src/framework/mlt_playlist.h @@ -23,16 +23,18 @@ #include "mlt_producer.h" -/** Structur for returning clip information. +/** Structure for returning clip information. */ typedef struct { + mlt_producer producer; + mlt_timecode start; char *resource; - double in; - double out; - double playtime; - double length; + mlt_timecode in; + mlt_timecode out; + mlt_timecode playtime; + mlt_timecode length; float fps; } mlt_playlist_clip_info; @@ -56,6 +58,7 @@ extern int mlt_playlist_get_clip_info( mlt_playlist this, mlt_playlist_clip_info extern int mlt_playlist_insert( mlt_playlist this, mlt_producer producer, int where, mlt_timecode in, mlt_timecode out ); extern int mlt_playlist_remove( mlt_playlist this, int where ); extern int mlt_playlist_move( mlt_playlist this, int from, int to ); +extern int mlt_playlist_resize_clip( mlt_playlist this, int clip, mlt_timecode in, mlt_timecode out ); extern void mlt_playlist_close( mlt_playlist this ); #endif diff --git a/src/framework/mlt_producer.c b/src/framework/mlt_producer.c index 751e19a..277db69 100644 --- a/src/framework/mlt_producer.c +++ b/src/framework/mlt_producer.c @@ -87,6 +87,28 @@ mlt_properties mlt_producer_properties( mlt_producer this ) return mlt_service_properties( &this->parent ); } +/** Convert frame position to timecode. +*/ + +mlt_timecode mlt_producer_time( mlt_producer this, int64_t frame ) +{ + if ( frame < 0 ) + return -1; + else + return ( mlt_timecode )frame / mlt_producer_get_fps( this ); +} + +/** Convert timecode to frame position. +*/ + +int64_t mlt_producer_frame_position( mlt_producer this, mlt_timecode position ) +{ + if ( position < 0 ) + return -1; + else + return ( int64_t )( floor( position * mlt_producer_get_fps( this ) + 0.5 ) ); +} + /** Seek to a specified time code. */ diff --git a/src/framework/mlt_producer.h b/src/framework/mlt_producer.h index a59a82d..888c3bc 100644 --- a/src/framework/mlt_producer.h +++ b/src/framework/mlt_producer.h @@ -46,6 +46,8 @@ struct mlt_producer_s extern int mlt_producer_init( mlt_producer this, void *child ); extern mlt_service mlt_producer_service( mlt_producer this ); extern mlt_properties mlt_producer_properties( mlt_producer this ); +extern mlt_timecode mlt_producer_time( mlt_producer this, int64_t frame ); +extern int64_t mlt_producer_frame_position( mlt_producer this, mlt_timecode position ); extern int mlt_producer_seek( mlt_producer this, mlt_timecode timecode ); extern int mlt_producer_seek_frame( mlt_producer this, uint64_t frame ); extern mlt_timecode mlt_producer_position( mlt_producer this ); diff --git a/src/framework/mlt_property.c b/src/framework/mlt_property.c index 22e43c8..f471b18 100644 --- a/src/framework/mlt_property.c +++ b/src/framework/mlt_property.c @@ -96,6 +96,17 @@ int mlt_property_set_string( mlt_property this, char *value ) return this->prop_string != NULL; } +/** Set an int64 on this property. +*/ + +int mlt_property_set_int64( mlt_property this, int64_t value ) +{ + mlt_property_clear( this ); + this->types = mlt_prop_int64; + this->prop_int64 = value; + return 0; +} + /** Set a data on this property. */ @@ -123,6 +134,8 @@ int mlt_property_get_int( mlt_property this ) return ( int )this->prop_double; else if ( this->types & mlt_prop_timecode ) return ( int )this->prop_timecode; + else if ( this->types & mlt_prop_int64 ) + return ( int )this->prop_int64; else if ( this->types & mlt_prop_string ) return atoi( this->prop_string ); return 0; @@ -139,6 +152,8 @@ double mlt_property_get_double( mlt_property this ) return ( double )this->prop_int; else if ( this->types & mlt_prop_timecode ) return ( double )this->prop_timecode; + else if ( this->types & mlt_prop_int64 ) + return ( double )this->prop_int64; else if ( this->types & mlt_prop_string ) return atof( this->prop_string ); return 0; @@ -155,11 +170,31 @@ mlt_timecode mlt_property_get_timecode( mlt_property this ) return ( mlt_timecode )this->prop_int; else if ( this->types & mlt_prop_double ) return ( mlt_timecode )this->prop_double; + else if ( this->types & mlt_prop_int64 ) + return ( mlt_timecode )this->prop_int64; else if ( this->types & mlt_prop_string ) return ( mlt_timecode )atof( this->prop_string ); return 0; } +/** Get an int64 from this property. +*/ + +int64_t mlt_property_get_int64( mlt_property this ) +{ + 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_timecode ) + return ( int64_t )this->prop_timecode; + else if ( this->types & mlt_prop_string ) + return ( int64_t )atof( this->prop_string ); + return 0; +} + /** Get a string from this property. */ @@ -186,6 +221,12 @@ char *mlt_property_get_string( mlt_property this ) this->prop_string = malloc( 32 ); sprintf( this->prop_string, "%e", this->prop_timecode ); } + else if ( this->types & mlt_prop_int64 ) + { + this->types |= mlt_prop_string; + this->prop_string = malloc( 32 ); + sprintf( this->prop_string, "%lld", this->prop_int64 ); + } else if ( this->types & mlt_prop_data && this->serialiser != NULL ) { this->types |= mlt_prop_string; diff --git a/src/framework/mlt_property.h b/src/framework/mlt_property.h index 8fb209c..6b0def5 100644 --- a/src/framework/mlt_property.h +++ b/src/framework/mlt_property.h @@ -33,7 +33,8 @@ typedef enum mlt_prop_string = 2, mlt_prop_timecode = 4, mlt_prop_double = 8, - mlt_prop_data = 16 + mlt_prop_data = 16, + mlt_prop_int64 = 32 } mlt_property_type; @@ -49,6 +50,7 @@ typedef struct mlt_property_s int prop_int; mlt_timecode prop_timecode; double prop_double; + int64_t prop_int64; // String handling char *prop_string; @@ -69,11 +71,13 @@ extern void mlt_property_clear( mlt_property this ); extern int mlt_property_set_int( mlt_property this, int value ); extern int mlt_property_set_double( mlt_property this, double value ); extern int mlt_property_set_timecode( mlt_property this, mlt_timecode value ); +extern int mlt_property_set_uint64( mlt_property this, uint64_t value ); extern int mlt_property_set_string( mlt_property this, char *value ); extern int mlt_property_set_data( mlt_property this, void *value, int length, mlt_destructor destructor, mlt_serialiser serialiser ); extern int mlt_property_get_int( mlt_property this ); extern double mlt_property_get_double( mlt_property this ); extern mlt_timecode mlt_property_get_timecode( mlt_property this ); +extern int64_t mlt_property_get_int64( mlt_property this ); extern char *mlt_property_get_string( mlt_property this ); extern void *mlt_property_get_data( mlt_property this, int *length ); extern void mlt_property_close( mlt_property this ); diff --git a/src/humperdink/client.c b/src/humperdink/client.c index 1f0ff3d..0705c14 100644 --- a/src/humperdink/client.c +++ b/src/humperdink/client.c @@ -147,7 +147,7 @@ void dv_demo_show_status( dv_demo demo, valerie_status status ) break; } - sprintf( temp + strlen( temp ), " %9.2f %9.2f %9.2f ", status->in, status->position, status->out ); + sprintf( temp + strlen( temp ), " %9lld %9lld %9lld ", status->in, status->position, status->out ); strcat( temp, status->clip ); printf( "%-80.80s\r", temp ); diff --git a/src/humperdink/remote.c b/src/humperdink/remote.c index 18ac5a5..9306b21 100644 --- a/src/humperdink/remote.c +++ b/src/humperdink/remote.c @@ -20,6 +20,7 @@ /* System header files */ #include +#include /* dv1394d header files */ #include diff --git a/src/miracle/miracle_local.c b/src/miracle/miracle_local.c index e9ef50e..501487a 100644 --- a/src/miracle/miracle_local.c +++ b/src/miracle/miracle_local.c @@ -455,5 +455,5 @@ static void miracle_local_close( miracle_local local ) pthread_kill_other_threads_np(); miracle_log( LOG_DEBUG, "Clean shutdown." ); free( local ); - mlt_factory_close( ); + //mlt_factory_close( ); } diff --git a/src/miracle/miracle_unit.c b/src/miracle/miracle_unit.c index f7d5509..bc90d69 100644 --- a/src/miracle/miracle_unit.c +++ b/src/miracle/miracle_unit.c @@ -184,6 +184,9 @@ static void update_generation( miracle_unit unit ) mlt_properties_set_int( properties, "generation", ++ generation ); } +/** Wipe all clips on the playlist for this unit. +*/ + static void clear_unit( miracle_unit unit ) { mlt_properties properties = unit->properties; @@ -210,6 +213,7 @@ void miracle_unit_report_list( miracle_unit unit, valerie_response response ) mlt_properties properties = unit->properties; int generation = mlt_properties_get_int( properties, "generation" ); mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); + mlt_producer producer = mlt_playlist_producer( playlist ); valerie_response_printf( response, 1024, "%d\n", generation ); @@ -217,8 +221,13 @@ void miracle_unit_report_list( miracle_unit unit, valerie_response response ) { mlt_playlist_clip_info info; mlt_playlist_get_clip_info( playlist , &info, i ); - valerie_response_printf( response, 10240, "%d \"%s\" %e %e %e %e %.2f\n", - i, info.resource, info.in, info.out, info.playtime, info.length, info.fps ); + valerie_response_printf( response, 10240, "%d \"%s\" %lld %lld %lld %lld %.2f\n", + i, info.resource, + mlt_producer_frame_position( producer, info.in ), + mlt_producer_frame_position( producer, info.out ), + mlt_producer_frame_position( producer, info.playtime ), + mlt_producer_frame_position( producer, info.length ), + info.fps ); } } @@ -231,7 +240,7 @@ void miracle_unit_report_list( miracle_unit unit, valerie_response response ) \param out The ending frame (-1 for maximum) */ -valerie_error_code miracle_unit_load( miracle_unit unit, char *clip, double in, double out, int flush ) +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 ); @@ -243,7 +252,7 @@ valerie_error_code miracle_unit_load( miracle_unit unit, char *clip, double in, { mlt_properties properties = unit->properties; mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); - mlt_playlist_append_io( playlist, instance, in, out ); + mlt_playlist_append_io( playlist, instance, mlt_producer_time( instance, in ), mlt_producer_time( instance, out ) ); miracle_log( LOG_DEBUG, "loaded clip %s", clip ); miracle_unit_status_communicate( unit ); return valerie_ok; @@ -252,7 +261,7 @@ valerie_error_code miracle_unit_load( miracle_unit unit, char *clip, double in, return valerie_invalid_file; } -valerie_error_code miracle_unit_insert( miracle_unit unit, char *clip, int index, double in, double out ) +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 ); @@ -260,8 +269,9 @@ valerie_error_code miracle_unit_insert( miracle_unit unit, char *clip, int index { mlt_properties properties = unit->properties; mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); - mlt_playlist_insert( playlist, instance, index, in, out ); + mlt_playlist_insert( playlist, instance, index, mlt_producer_time( instance, in ), mlt_producer_time( instance, out ) ); miracle_log( LOG_DEBUG, "inserted clip %s at %d", clip, index ); + update_generation( unit ); miracle_unit_status_communicate( unit ); return valerie_ok; } @@ -275,6 +285,7 @@ valerie_error_code miracle_unit_remove( miracle_unit unit, int index ) mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); mlt_playlist_remove( playlist, index ); miracle_log( LOG_DEBUG, "removed clip at %d", index ); + update_generation( unit ); miracle_unit_status_communicate( unit ); return valerie_ok; } @@ -292,6 +303,7 @@ valerie_error_code miracle_unit_move( miracle_unit unit, int src, int dest ) mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); mlt_playlist_move( playlist, src, dest ); miracle_log( LOG_DEBUG, "moved clip %d to %d", src, dest ); + update_generation( unit ); miracle_unit_status_communicate( unit ); return valerie_ok; } @@ -305,7 +317,7 @@ valerie_error_code miracle_unit_move( miracle_unit unit, int src, int dest ) \param out The ending frame (-1 for maximum) */ -valerie_error_code miracle_unit_append( miracle_unit unit, char *clip, double in, double out ) +valerie_error_code miracle_unit_append( miracle_unit unit, char *clip, int64_t in, int64_t out ) { mlt_producer instance = create_producer( unit, clip ); @@ -313,8 +325,9 @@ valerie_error_code miracle_unit_append( miracle_unit unit, char *clip, double in { mlt_properties properties = unit->properties; mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); - mlt_playlist_append_io( playlist, instance, in, out ); + mlt_playlist_append_io( playlist, instance, mlt_producer_time( instance, in ), mlt_producer_time( instance, out ) ); miracle_log( LOG_DEBUG, "appended clip %s", clip ); + update_generation( unit ); miracle_unit_status_communicate( unit ); return valerie_ok; } @@ -404,13 +417,21 @@ int miracle_unit_get_status( miracle_unit unit, valerie_status status ) strncpy( status->clip, info.resource, sizeof( status->clip ) ); status->speed = (int)( mlt_producer_get_speed( producer ) * 1000.0 ); status->fps = mlt_producer_get_fps( producer ); - status->in = info.in; - status->out = info.in + info.playtime; - status->position = mlt_producer_position( clip ); - status->length = mlt_producer_get_length( clip ); + status->in = mlt_producer_frame_position( producer, info.in ); + status->out = mlt_producer_frame_position( producer, info.out ); + status->position = mlt_producer_frame_position( producer, mlt_producer_position( clip ) ); + status->length = mlt_producer_frame_position( producer, mlt_producer_get_length( clip ) ); + strncpy( status->tail_clip, info.resource, sizeof( status->tail_clip ) ); + status->tail_in = mlt_producer_frame_position( producer, info.in ); + status->tail_out = mlt_producer_frame_position( producer, info.out ); + status->tail_position = mlt_producer_frame_position( producer, mlt_producer_position( clip ) ); + status->tail_length = mlt_producer_frame_position( producer, mlt_producer_get_length( clip ) ); + status->clip_index = mlt_playlist_current_clip( playlist ); status->seek_flag = 1; } + status->generation = mlt_properties_get_int( properties, "generation" ); + if ( !strcmp( status->clip, "" ) ) status->status = unit_not_loaded; else if ( status->speed == 0 ) @@ -431,8 +452,40 @@ int miracle_unit_get_status( miracle_unit unit, valerie_status status ) /** Change position in the playlist. */ -void miracle_unit_change_position( miracle_unit unit, int clip, double position ) +void miracle_unit_change_position( miracle_unit unit, int clip, int64_t position ) { + mlt_properties properties = unit->properties; + mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); + mlt_producer producer = mlt_playlist_producer( playlist ); + mlt_playlist_clip_info info; + + if ( clip < 0 ) + clip = 0; + else if ( clip >= mlt_playlist_count( playlist ) ) + clip = mlt_playlist_count( playlist ); + + if ( mlt_playlist_get_clip_info( playlist, &info, clip ) == 0 ) + { + mlt_timecode relative = mlt_producer_time( info.producer, position ); + mlt_timecode absolute = relative - info.in; + int64_t frame_start = mlt_producer_frame_position( info.producer, info.start ); + int64_t frame_offset = 0; + + if ( absolute < 0 ) + frame_offset = 0; + else if ( absolute >= info.out ) + frame_offset = mlt_producer_frame_position( info.producer, info.out ) - 1; + else + frame_offset = mlt_producer_frame_position( info.producer, absolute ); + + mlt_producer_seek_frame( producer, frame_start + frame_offset ); + } + else + { + mlt_timecode out = mlt_producer_get_out( producer ); + mlt_producer_seek( producer, mlt_producer_frame_position( producer, out ) - 1 ); + } + miracle_unit_status_communicate( unit ); } @@ -450,26 +503,56 @@ int miracle_unit_get_current_clip( miracle_unit unit ) /** Set a clip's in point */ -int miracle_unit_set_clip_in( miracle_unit unit, int index, double position ) +int miracle_unit_set_clip_in( miracle_unit unit, int index, int64_t position ) { - int error = 0; + mlt_properties properties = unit->properties; + mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); + mlt_playlist_clip_info info; + int error = mlt_playlist_get_clip_info( playlist, &info, index ); + + if ( error == 0 ) + { + mlt_timecode in = mlt_producer_time( info.producer, position ); + error = mlt_playlist_resize_clip( playlist, index, in, info.out ); + update_generation( unit ); + miracle_unit_change_position( unit, index, 0 ); + } + return error; } /** Set a clip's out point. */ -int miracle_unit_set_clip_out( miracle_unit unit, int index, double position ) +int miracle_unit_set_clip_out( miracle_unit unit, int index, int64_t position ) { - int error = 0; + mlt_properties properties = unit->properties; + mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); + mlt_playlist_clip_info info; + int error = mlt_playlist_get_clip_info( playlist, &info, index ); + + if ( error == 0 ) + { + mlt_timecode out = mlt_producer_time( info.producer, position ); + error = mlt_playlist_resize_clip( playlist, index, info.in, out ); + update_generation( unit ); + miracle_unit_status_communicate( unit ); + miracle_unit_change_position( unit, index, 0 ); + } + return error; } /** Step by specified position. */ -void miracle_unit_step( miracle_unit unit, double offset ) +void miracle_unit_step( miracle_unit unit, int64_t offset ) { + mlt_properties properties = unit->properties; + mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); + mlt_producer producer = mlt_playlist_producer( playlist ); + mlt_timecode position = mlt_producer_position( producer ); + mlt_producer_seek( producer, position + mlt_producer_time( producer, offset ) ); } /** Set the unit's clip mode regarding in and out points. diff --git a/src/miracle/miracle_unit.h b/src/miracle/miracle_unit.h index 1acb949..7670b45 100644 --- a/src/miracle/miracle_unit.h +++ b/src/miracle/miracle_unit.h @@ -42,9 +42,9 @@ miracle_unit_t, *miracle_unit; extern miracle_unit miracle_unit_init( int index, char *arg ); extern void miracle_unit_report_list( miracle_unit unit, valerie_response response ); extern void miracle_unit_allow_stdin( miracle_unit unit, int flag ); -extern valerie_error_code miracle_unit_load( miracle_unit unit, char *clip, double in, double out, int flush ); -extern valerie_error_code miracle_unit_insert( miracle_unit unit, char *clip, int index, double in, double out ); -extern valerie_error_code miracle_unit_append( miracle_unit unit, char *clip, double in, double out ); +extern valerie_error_code miracle_unit_load( miracle_unit unit, char *clip, int64_t in, int64_t out, int flush ); +extern valerie_error_code miracle_unit_insert( miracle_unit unit, char *clip, int index, int64_t in, int64_t out ); +extern valerie_error_code miracle_unit_append( miracle_unit unit, char *clip, int64_t in, int64_t out ); extern valerie_error_code miracle_unit_remove( miracle_unit unit, int index ); extern valerie_error_code miracle_unit_clean( miracle_unit unit ); extern valerie_error_code miracle_unit_move( miracle_unit unit, int src, int dest ); @@ -57,15 +57,15 @@ extern int miracle_unit_get_channel( miracle_unit unit ); extern int miracle_unit_is_offline( miracle_unit unit ); extern void miracle_unit_set_notifier( miracle_unit, valerie_notifier, char * ); extern int miracle_unit_get_status( miracle_unit, valerie_status ); -extern void miracle_unit_change_position( miracle_unit, int, double position ); +extern void miracle_unit_change_position( miracle_unit, int, int64_t position ); extern void miracle_unit_change_speed( miracle_unit unit, int speed ); -extern int miracle_unit_set_clip_in( miracle_unit unit, int index, double position ); -extern int miracle_unit_set_clip_out( miracle_unit unit, int index, double position ); +extern int miracle_unit_set_clip_in( miracle_unit unit, int index, int64_t position ); +extern int miracle_unit_set_clip_out( miracle_unit unit, int index, int64_t position ); //extern void miracle_unit_set_mode( miracle_unit unit, dv_player_clip_mode mode ); //extern dv_player_clip_mode miracle_unit_get_mode( miracle_unit unit ); //extern void miracle_unit_set_eof_action( miracle_unit unit, dv_player_eof_action mode ); //extern dv_player_eof_action miracle_unit_get_eof_action( miracle_unit unit ); -extern void miracle_unit_step( miracle_unit unit, double offset ); +extern void miracle_unit_step( miracle_unit unit, int64_t offset ); extern void miracle_unit_close( miracle_unit unit ); extern void miracle_unit_suspend( miracle_unit ); extern void miracle_unit_restore( miracle_unit ); diff --git a/src/miracle/miracle_unit_commands.c b/src/miracle/miracle_unit_commands.c index c85aff0..e0f6003 100644 --- a/src/miracle/miracle_unit_commands.c +++ b/src/miracle/miracle_unit_commands.c @@ -56,11 +56,11 @@ int miracle_load( command_argument cmd_arg ) return RESPONSE_INVALID_UNIT; else { - double in = -1, out = -1; + int64_t in = -1, out = -1; if ( valerie_tokeniser_count( cmd_arg->tokeniser ) == 5 ) { - in = atof( valerie_tokeniser_get_string( cmd_arg->tokeniser, 3 ) ); - out = atof( valerie_tokeniser_get_string( cmd_arg->tokeniser, 4 ) ); + in = atol( valerie_tokeniser_get_string( cmd_arg->tokeniser, 3 ) ); + out = atol( valerie_tokeniser_get_string( cmd_arg->tokeniser, 4 ) ); } if ( miracle_unit_load( unit, fullname, in, out, flush ) != valerie_ok ) return RESPONSE_BAD_FILE; @@ -207,11 +207,11 @@ int miracle_append( command_argument cmd_arg ) return RESPONSE_INVALID_UNIT; else { - double in = -1, out = -1; + int64_t in = -1, out = -1; if ( valerie_tokeniser_count( cmd_arg->tokeniser ) == 5 ) { - in = atof( valerie_tokeniser_get_string( cmd_arg->tokeniser, 3 ) ); - out = atof( valerie_tokeniser_get_string( cmd_arg->tokeniser, 4 ) ); + in = atol( valerie_tokeniser_get_string( cmd_arg->tokeniser, 3 ) ); + out = atol( valerie_tokeniser_get_string( cmd_arg->tokeniser, 4 ) ); } switch ( miracle_unit_append( unit, fullname, in, out ) ) { @@ -311,17 +311,16 @@ int miracle_ff( command_argument cmd_arg ) int miracle_set_in_point( command_argument cmd_arg ) { - /* - dv_unit unit = miracle_get_unit(cmd_arg->unit); + miracle_unit unit = miracle_get_unit(cmd_arg->unit); int clip = parse_clip( cmd_arg, 3 ); - - if (unit == NULL || dv_unit_is_offline(unit)) + + if ( unit == NULL ) return RESPONSE_INVALID_UNIT; else { int position = *(int *) cmd_arg->argument; - switch( dv_unit_set_clip_in( unit, clip, position ) ) + switch( miracle_unit_set_clip_in( unit, clip, position ) ) { case -1: return RESPONSE_BAD_FILE; @@ -329,23 +328,21 @@ int miracle_set_in_point( command_argument cmd_arg ) return RESPONSE_OUT_OF_RANGE; } } - */ return RESPONSE_SUCCESS; } int miracle_set_out_point( command_argument cmd_arg ) { - /* - dv_unit unit = miracle_get_unit(cmd_arg->unit); + miracle_unit unit = miracle_get_unit(cmd_arg->unit); int clip = parse_clip( cmd_arg, 3 ); - if (unit == NULL || dv_unit_is_offline(unit)) + if ( unit == NULL ) return RESPONSE_INVALID_UNIT; else { int position = *(int *) cmd_arg->argument; - switch( dv_unit_set_clip_out( unit, clip, position ) ) + switch( miracle_unit_set_clip_out( unit, clip, position ) ) { case -1: return RESPONSE_BAD_FILE; @@ -353,7 +350,7 @@ int miracle_set_out_point( command_argument cmd_arg ) return RESPONSE_OUT_OF_RANGE; } } - */ + return RESPONSE_SUCCESS; } diff --git a/src/modules/dv/producer_libdv.c b/src/modules/dv/producer_libdv.c index 4e2e9f7..8c139df 100644 --- a/src/modules/dv/producer_libdv.c +++ b/src/modules/dv/producer_libdv.c @@ -134,7 +134,7 @@ static int producer_collect_info( producer_libdv this ) mlt_properties_set_double( properties, "fps", fps ); mlt_properties_set_timecode( properties, "length", length ); mlt_properties_set_timecode( properties, "in", 0.0 ); - mlt_properties_set_timecode( properties, "out", length ); + mlt_properties_set_timecode( properties, "out", ( mlt_timecode )( this->frames_in_file - 1 ) / fps ); // Parse the header for meta info dv_parse_header( this->dv_decoder, dv_data ); diff --git a/src/valerie/valerie.c b/src/valerie/valerie.c index 4157284..f273153 100644 --- a/src/valerie/valerie.c +++ b/src/valerie/valerie.c @@ -223,9 +223,9 @@ static void valerie_interpret_clip_offset( char *output, valerie_clip_offset off /** Load a file on the specified unit with the specified in/out points. */ -valerie_error_code valerie_unit_load_clipped( valerie this, int unit, char *file, double in, double out ) +valerie_error_code valerie_unit_load_clipped( valerie this, int unit, char *file, int64_t in, int64_t out ) { - return valerie_execute( this, 10240, "LOAD U%d \"%s\" %e %e", unit, file, in, out ); + return valerie_execute( this, 10240, "LOAD U%d \"%s\" %lld %lld", unit, file, in, out ); } /** Load a file on the specified unit at the end of the current pump. @@ -239,17 +239,17 @@ valerie_error_code valerie_unit_load_back( valerie this, int unit, char *file ) /** Load a file on the specified unit at the end of the pump with the specified in/out points. */ -valerie_error_code valerie_unit_load_back_clipped( valerie this, int unit, char *file, double in, double out ) +valerie_error_code valerie_unit_load_back_clipped( valerie this, int unit, char *file, int64_t in, int64_t out ) { - return valerie_execute( this, 10240, "LOAD U%d \"!%s\" %e %e", unit, file, in, out ); + return valerie_execute( this, 10240, "LOAD U%d \"!%s\" %lld %lld", unit, file, in, out ); } /** Append a file on the specified unit. */ -valerie_error_code valerie_unit_append( valerie this, int unit, char *file, double in, double out ) +valerie_error_code valerie_unit_append( valerie this, int unit, char *file, int64_t in, int64_t out ) { - return valerie_execute( this, 10240, "APND U%d \"%s\" %e %e", unit, file, in, out ); + return valerie_execute( this, 10240, "APND U%d \"%s\" %lld %lld", unit, file, in, out ); } /** Clean the unit - this function removes all but the currently playing clip. @@ -293,11 +293,11 @@ valerie_error_code valerie_unit_remove_current_clip( valerie this, int unit ) /** Insert clip at the specified position. */ -valerie_error_code valerie_unit_clip_insert( valerie this, int unit, valerie_clip_offset offset, int clip, char *file, double in, double out ) +valerie_error_code valerie_unit_clip_insert( valerie this, int unit, valerie_clip_offset offset, int clip, char *file, int64_t in, int64_t out ) { char temp[ 100 ]; valerie_interpret_clip_offset( temp, offset, clip ); - return valerie_execute( this, 1024, "INSERT U%d %s %s %e %e", unit, file, temp, in, out ); + return valerie_execute( this, 1024, "INSERT U%d %s %s %lld %lld", unit, file, temp, in, out ); } /** Play the unit at normal speed. @@ -351,63 +351,63 @@ valerie_error_code valerie_unit_fast_forward( valerie this, int unit ) /** Step by the number of frames on the specified unit. */ -valerie_error_code valerie_unit_step( valerie this, int unit, double step ) +valerie_error_code valerie_unit_step( valerie this, int unit, int64_t step ) { - return valerie_execute( this, 1024, "STEP U%d %e", unit, step ); + return valerie_execute( this, 1024, "STEP U%d %lld", unit, step ); } /** Goto the specified frame on the specified unit. */ -valerie_error_code valerie_unit_goto( valerie this, int unit, double position ) +valerie_error_code valerie_unit_goto( valerie this, int unit, int64_t position ) { - return valerie_execute( this, 1024, "GOTO U%d %e", unit, position ); + return valerie_execute( this, 1024, "GOTO U%d %lld", unit, position ); } /** Goto the specified frame in the clip on the specified unit. */ -valerie_error_code valerie_unit_clip_goto( valerie this, int unit, valerie_clip_offset offset, int clip, double position ) +valerie_error_code valerie_unit_clip_goto( valerie this, int unit, valerie_clip_offset offset, int clip, int64_t position ) { char temp[ 100 ]; valerie_interpret_clip_offset( temp, offset, clip ); - return valerie_execute( this, 1024, "GOTO U%d %e %s", unit, position, temp ); + return valerie_execute( this, 1024, "GOTO U%d %lld %s", unit, position, temp ); } /** Set the in point of the loaded file on the specified unit. */ -valerie_error_code valerie_unit_set_in( valerie this, int unit, double in ) +valerie_error_code valerie_unit_set_in( valerie this, int unit, int64_t in ) { - return valerie_execute( this, 1024, "SIN U%d %e", unit, in ); + return valerie_execute( this, 1024, "SIN U%d %lld", unit, in ); } /** Set the in point of the clip on the specified unit. */ -valerie_error_code valerie_unit_clip_set_in( valerie this, int unit, valerie_clip_offset offset, int clip, double in ) +valerie_error_code valerie_unit_clip_set_in( valerie this, int unit, valerie_clip_offset offset, int clip, int64_t in ) { char temp[ 100 ]; valerie_interpret_clip_offset( temp, offset, clip ); - return valerie_execute( this, 1024, "SIN U%d %e %s", unit, in, temp ); + return valerie_execute( this, 1024, "SIN U%d %lld %s", unit, in, temp ); } /** Set the out point of the loaded file on the specified unit. */ -valerie_error_code valerie_unit_set_out( valerie this, int unit, double out ) +valerie_error_code valerie_unit_set_out( valerie this, int unit, int64_t out ) { - return valerie_execute( this, 1024, "SOUT U%d %e", unit, out ); + return valerie_execute( this, 1024, "SOUT U%d %lld", unit, out ); } /** Set the out point of the clip on the specified unit. */ -valerie_error_code valerie_unit_clip_set_out( valerie this, int unit, valerie_clip_offset offset, int clip, double in ) +valerie_error_code valerie_unit_clip_set_out( valerie this, int unit, valerie_clip_offset offset, int clip, int64_t in ) { char temp[ 100 ]; valerie_interpret_clip_offset( temp, offset, clip ); - return valerie_execute( this, 1024, "SOUT U%d %e %s", unit, in, temp ); + return valerie_execute( this, 1024, "SOUT U%d %lld %s", unit, in, temp ); } /** Clear the in point of the loaded file on the specified unit. @@ -624,10 +624,10 @@ valerie_error_code valerie_list_get( valerie_list list, int index, valerie_list_ entry->clip = atoi( valerie_tokeniser_get_string( tokeniser, 0 ) ); valerie_util_strip( valerie_tokeniser_get_string( tokeniser, 1 ), '\"' ); strcpy( entry->full, valerie_tokeniser_get_string( tokeniser, 1 ) ); - entry->in = atof( valerie_tokeniser_get_string( tokeniser, 2 ) ); - entry->out = atof( valerie_tokeniser_get_string( tokeniser, 3 ) ); - entry->max = atof( valerie_tokeniser_get_string( tokeniser, 4 ) ); - entry->size = atof( valerie_tokeniser_get_string( tokeniser, 5 ) ); + entry->in = atol( valerie_tokeniser_get_string( tokeniser, 2 ) ); + entry->out = atol( valerie_tokeniser_get_string( tokeniser, 3 ) ); + entry->max = atol( valerie_tokeniser_get_string( tokeniser, 4 ) ); + entry->size = atol( valerie_tokeniser_get_string( tokeniser, 5 ) ); entry->fps = atof( valerie_tokeniser_get_string( tokeniser, 6 ) ); } valerie_tokeniser_close( tokeniser ); diff --git a/src/valerie/valerie.h b/src/valerie/valerie.h index fc3b059..658ef9a 100644 --- a/src/valerie/valerie.h +++ b/src/valerie/valerie.h @@ -90,28 +90,28 @@ extern valerie_error_code valerie_run( valerie, char * ); /* Unit functions */ extern valerie_error_code valerie_unit_add( valerie, char *, int * ); extern valerie_error_code valerie_unit_load( valerie, int, char * ); -extern valerie_error_code valerie_unit_load_clipped( valerie, int, char *, double, double ); +extern valerie_error_code valerie_unit_load_clipped( valerie, int, char *, int64_t, int64_t ); extern valerie_error_code valerie_unit_load_back( valerie, int, char * ); -extern valerie_error_code valerie_unit_load_back_clipped( valerie, int, char *, double, double ); -extern valerie_error_code valerie_unit_append( valerie, int, char *, double, double ); +extern valerie_error_code valerie_unit_load_back_clipped( valerie, int, char *, int64_t, int64_t ); +extern valerie_error_code valerie_unit_append( valerie, int, char *, int64_t, int64_t ); extern valerie_error_code valerie_unit_clean( valerie, int ); extern valerie_error_code valerie_unit_clip_move( valerie, int, valerie_clip_offset, int, valerie_clip_offset, int ); extern valerie_error_code valerie_unit_clip_remove( valerie, int, valerie_clip_offset, int ); extern valerie_error_code valerie_unit_remove_current_clip( valerie, int ); -extern valerie_error_code valerie_unit_clip_insert( valerie, int, valerie_clip_offset, int, char *, double, double ); +extern valerie_error_code valerie_unit_clip_insert( valerie, int, valerie_clip_offset, int, char *, int64_t, int64_t ); extern valerie_error_code valerie_unit_play( valerie, int ); extern valerie_error_code valerie_unit_play_at_speed( valerie, int, int ); extern valerie_error_code valerie_unit_stop( valerie, int ); extern valerie_error_code valerie_unit_pause( valerie, int ); extern valerie_error_code valerie_unit_rewind( valerie, int ); extern valerie_error_code valerie_unit_fast_forward( valerie, int ); -extern valerie_error_code valerie_unit_step( valerie, int, double ); -extern valerie_error_code valerie_unit_goto( valerie, int, double ); -extern valerie_error_code valerie_unit_clip_goto( valerie, int, valerie_clip_offset, int, double ); -extern valerie_error_code valerie_unit_clip_set_in( valerie, int, valerie_clip_offset, int, double ); -extern valerie_error_code valerie_unit_clip_set_out( valerie, int, valerie_clip_offset, int, double ); -extern valerie_error_code valerie_unit_set_in( valerie, int, double ); -extern valerie_error_code valerie_unit_set_out( valerie, int, double ); +extern valerie_error_code valerie_unit_step( valerie, int, int64_t ); +extern valerie_error_code valerie_unit_goto( valerie, int, int64_t ); +extern valerie_error_code valerie_unit_clip_goto( valerie, int, valerie_clip_offset, int, int64_t ); +extern valerie_error_code valerie_unit_clip_set_in( valerie, int, valerie_clip_offset, int, int64_t ); +extern valerie_error_code valerie_unit_clip_set_out( valerie, int, valerie_clip_offset, int, int64_t ); +extern valerie_error_code valerie_unit_set_in( valerie, int, int64_t ); +extern valerie_error_code valerie_unit_set_out( valerie, int, int64_t ); extern valerie_error_code valerie_unit_clear_in( valerie, int ); extern valerie_error_code valerie_unit_clear_out( valerie, int ); extern valerie_error_code valerie_unit_clear_in_out( valerie, int ); @@ -169,11 +169,11 @@ typedef struct { int clip; char full[ PATH_MAX + NAME_MAX ]; - double in; - double out; - double max; - double size; - double fps; + int64_t in; + int64_t out; + int64_t max; + int64_t size; + int64_t fps; } *valerie_list_entry, valerie_list_entry_t; diff --git a/src/valerie/valerie_status.c b/src/valerie/valerie_status.c index 5725b0c..5e4cbd2 100644 --- a/src/valerie/valerie_status.c +++ b/src/valerie/valerie_status.c @@ -38,21 +38,21 @@ void valerie_status_parse( valerie_status status, char *text ) { status->unit = atoi( valerie_tokeniser_get_string( tokeniser, 0 ) ); strncpy( status->clip, valerie_util_strip( valerie_tokeniser_get_string( tokeniser, 2 ), '\"' ), sizeof( status->clip ) ); - status->position = atof( valerie_tokeniser_get_string( tokeniser, 3 ) ); + status->position = atol( valerie_tokeniser_get_string( tokeniser, 3 ) ); status->speed = atoi( valerie_tokeniser_get_string( tokeniser, 4 ) ); status->fps = atof( valerie_tokeniser_get_string( tokeniser, 5 ) ); - status->in = atof( valerie_tokeniser_get_string( tokeniser, 6 ) ); - status->out = atof( valerie_tokeniser_get_string( tokeniser, 7 ) ); - status->length = atof( valerie_tokeniser_get_string( tokeniser, 8 ) ); + status->in = atol( valerie_tokeniser_get_string( tokeniser, 6 ) ); + status->out = atol( valerie_tokeniser_get_string( tokeniser, 7 ) ); + status->length = atol( valerie_tokeniser_get_string( tokeniser, 8 ) ); strncpy( status->tail_clip, valerie_util_strip( valerie_tokeniser_get_string( tokeniser, 9 ), '\"' ), sizeof( status->tail_clip ) ); - status->tail_position = atof( valerie_tokeniser_get_string( tokeniser, 10 ) ); - status->tail_in = atof( valerie_tokeniser_get_string( tokeniser, 11 ) ); - status->tail_out = atof( valerie_tokeniser_get_string( tokeniser, 12 ) ); - status->tail_length = atof( valerie_tokeniser_get_string( tokeniser, 13 ) ); - status->seek_flag = atof( valerie_tokeniser_get_string( tokeniser, 14 ) ); - status->generation = atof( valerie_tokeniser_get_string( tokeniser, 15 ) ); - status->clip_index = atof( valerie_tokeniser_get_string( tokeniser, 16 ) ); + status->tail_position = atol( valerie_tokeniser_get_string( tokeniser, 10 ) ); + status->tail_in = atol( valerie_tokeniser_get_string( tokeniser, 11 ) ); + status->tail_out = atol( valerie_tokeniser_get_string( tokeniser, 12 ) ); + status->tail_length = atol( valerie_tokeniser_get_string( tokeniser, 13 ) ); + status->seek_flag = atoi( valerie_tokeniser_get_string( tokeniser, 14 ) ); + status->generation = atoi( valerie_tokeniser_get_string( tokeniser, 15 ) ); + status->clip_index = atoi( valerie_tokeniser_get_string( tokeniser, 16 ) ); if ( !strcmp( valerie_tokeniser_get_string( tokeniser, 1 ), "unknown" ) ) status->status = unit_unknown; @@ -121,7 +121,7 @@ char *valerie_status_serialise( valerie_status status, char *text, int length ) break; } - snprintf( text, length, "%d %s \"%s\" %e %e %.2f %e %e %e \"%s\" %e %e %e %e %d %d %d\r\n", + snprintf( text, length, "%d %s \"%s\" %lld %d %.2f %lld %lld %lld \"%s\" %lld %lld %lld %lld %d %d %d\r\n", status->unit, status_string, status->clip, diff --git a/src/valerie/valerie_status.h b/src/valerie/valerie_status.h index d0e45a9..5da7497 100644 --- a/src/valerie/valerie_status.h +++ b/src/valerie/valerie_status.h @@ -50,17 +50,17 @@ typedef struct int unit; unit_status status; char clip[ 2048 ]; - double position; - double speed; + int64_t position; + int speed; double fps; - double in; - double out; - double length; + int64_t in; + int64_t out; + int64_t length; char tail_clip[ 2048 ]; - double tail_position; - double tail_in; - double tail_out; - double tail_length; + int64_t tail_position; + int64_t tail_in; + int64_t tail_out; + int64_t tail_length; int seek_flag; int generation; int clip_index;