X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fframework%2Fmlt_playlist.c;h=0433a743779b084bbafa0c415e5c148cd6e2d54e;hb=390e1559353efa011b371b66fcd2c8d3ffb84ab8;hp=22cd256b60c8147524432e120a24b8c3ea03aaf7;hpb=13a70eccf0f8b2c2b0ce1c32862c687b693710ee;p=melted diff --git a/src/framework/mlt_playlist.c b/src/framework/mlt_playlist.c index 22cd256..0433a74 100644 --- a/src/framework/mlt_playlist.c +++ b/src/framework/mlt_playlist.c @@ -800,7 +800,7 @@ int mlt_playlist_split( mlt_playlist this, int clip, mlt_position position ) { playlist_entry *entry = this->list[ clip ]; position = position < 0 ? entry->frame_count + position - 1 : position; - if ( position >= 0 && position <= entry->frame_count ) + if ( position >= 0 && position < entry->frame_count - 1 ) { int in = entry->frame_in; int out = entry->frame_out; @@ -836,19 +836,50 @@ int mlt_playlist_split( mlt_playlist this, int clip, mlt_position position ) return error; } +/** Split the playlist at the absolute position. +*/ + +int mlt_playlist_split_at( mlt_playlist this, mlt_position position, int left ) +{ + int result = this == NULL ? -1 : 0; + if ( !result ) + { + if ( position >= 0 && position < mlt_producer_get_playtime( MLT_PLAYLIST_PRODUCER( this ) ) ) + { + int clip = mlt_playlist_get_clip_index_at( this, position ); + mlt_playlist_clip_info info; + mlt_playlist_get_clip_info( this, &info, clip ); + if ( left && position != info.start ) + mlt_playlist_split( this, clip, position - info.start - 1 ); + else if ( !left ) + mlt_playlist_split( this, clip, position - info.start ); + result = position; + } + else if ( position <= 0 ) + { + result = 0; + } + else + { + result = mlt_producer_get_playtime( MLT_PLAYLIST_PRODUCER( this ) ); + } + } + return result; +} + /** Join 1 or more consecutive clips. */ int mlt_playlist_join( mlt_playlist this, int clip, int count, int merge ) { - int error = clip < 0 || ( clip ) >= this->count; + int error = clip < 0 || clip >= this->count; if ( error == 0 ) { int i = clip; mlt_playlist new_clip = mlt_playlist_init( ); mlt_events_block( MLT_PLAYLIST_PROPERTIES( this ), this ); if ( clip + count >= this->count ) - count = this->count - clip; + count = this->count - clip - 1; for ( i = 0; i <= count; i ++ ) { playlist_entry *entry = this->list[ clip ]; @@ -1141,7 +1172,7 @@ void mlt_playlist_consolidate_blanks( mlt_playlist this, int keep_length ) } } - if ( !keep_length ) + if ( !keep_length && this->count > 0 ) { playlist_entry *last = this->list[ this->count - 1 ]; if ( mlt_producer_is_blank( last->producer ) ) @@ -1161,6 +1192,14 @@ int mlt_playlist_is_blank( mlt_playlist this, int clip ) return this == NULL || mlt_producer_is_blank( mlt_playlist_get_clip( this, clip ) ); } +/** Determine if the specified position is a blank. +*/ + +int mlt_playlist_is_blank_at( mlt_playlist this, int position ) +{ + return this == NULL || mlt_producer_is_blank( mlt_playlist_get_clip_at( this, position ) ); +} + /** Replace the specified clip with a blank and return the clip. */ @@ -1188,7 +1227,7 @@ mlt_producer mlt_playlist_replace_with_blank( mlt_playlist this, int clip ) void mlt_playlist_insert_blank( mlt_playlist this, int clip, int length ) { - if ( this != NULL && length > 0 ) + if ( this != NULL && length >= 0 ) { mlt_properties properties = MLT_PLAYLIST_PROPERTIES( this ); mlt_events_block( properties, properties ); @@ -1240,7 +1279,7 @@ int mlt_playlist_insert_at( mlt_playlist this, int position, mlt_producer produc if ( clip < this->count && mlt_playlist_is_blank( this, clip ) ) { // Split and move to new clip if need be - if ( mlt_playlist_split( this, clip, position - info.start ) == 0 ) + if ( position != info.start && mlt_playlist_split( this, clip, position - info.start ) == 0 ) mlt_playlist_get_clip_info( this, &info, ++ clip ); // Split again if need be @@ -1290,7 +1329,7 @@ int mlt_playlist_clip_start( mlt_playlist this, int clip ) mlt_playlist_clip_info info; if ( mlt_playlist_get_clip_info( this, &info, clip ) == 0 ) return info.start; - return 0; + return clip < 0 ? 0 : mlt_producer_get_playtime( MLT_PLAYLIST_PRODUCER( this ) ); } int mlt_playlist_clip_length( mlt_playlist this, int clip )