Cleanup license declarations and remove dv1394d references.
[melted] / src / framework / mlt_playlist.c
index a78ad6d..eac0642 100644 (file)
@@ -3,19 +3,19 @@
  * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
  * Author: Charles Yates <charles.yates@pandora.be>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
  *
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include "config.h"
@@ -263,6 +263,19 @@ static int mlt_playlist_virtual_append( mlt_playlist this, mlt_producer source,
        // Fetch the cuts parent properties
        parent = MLT_PRODUCER_PROPERTIES( mlt_producer_cut_parent( producer ) );
 
+       // Remove fezzik normalisers for fx cuts
+       if ( mlt_properties_get_int( parent, "meta.fx_cut" ) )
+       {
+               mlt_service service = MLT_PRODUCER_SERVICE( mlt_producer_cut_parent( producer ) );
+               mlt_filter filter = mlt_service_filter( service, 0 );
+               while ( filter != NULL && mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "_fezzik" ) )
+               {
+                       mlt_service_detach( service, filter );
+                       filter = mlt_service_filter( service, 0 );
+               }
+               mlt_properties_set_int( MLT_PRODUCER_PROPERTIES( producer ), "meta.fx_cut", 1 );
+       }
+
        // Check that we have room
        if ( this->count >= this->size )
        {
@@ -350,7 +363,7 @@ static mlt_service mlt_playlist_virtual_seek( mlt_playlist this, int *progressiv
        {
                int count = this->list[ i ]->frame_count / this->list[ i ]->repeat;
                *progressive = count == 1;
-               mlt_producer_seek( producer, position % count );
+               mlt_producer_seek( producer, (int)position % count );
        }
        else if ( !strcmp( eof, "pause" ) && total > 0 )
        {
@@ -359,7 +372,7 @@ static mlt_service mlt_playlist_virtual_seek( mlt_playlist this, int *progressiv
                mlt_producer this_producer = MLT_PLAYLIST_PRODUCER( this );
                mlt_producer_seek( this_producer, original - 1 );
                producer = entry->producer;
-               mlt_producer_seek( producer, entry->frame_out % count );
+               mlt_producer_seek( producer, (int)entry->frame_out % count );
                mlt_producer_set_speed( this_producer, 0 );
                mlt_producer_set_speed( producer, 0 );
                *progressive = count == 1;
@@ -872,14 +885,14 @@ int mlt_playlist_split_at( mlt_playlist this, mlt_position position, int left )
 
 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 ];
@@ -1022,7 +1035,7 @@ mlt_producer mlt_playlist_get_clip( mlt_playlist this, int clip )
 /** Return the clip at the specified position.
 */
 
-mlt_producer mlt_playlist_get_clip_at( mlt_playlist this, int position )
+mlt_producer mlt_playlist_get_clip_at( mlt_playlist this, mlt_position position )
 {
        int index = 0, total = 0;
        return mlt_playlist_locate( this, &position, &index, &total );
@@ -1031,7 +1044,7 @@ mlt_producer mlt_playlist_get_clip_at( mlt_playlist this, int position )
 /** Return the clip index of the specified position.
 */
 
-int mlt_playlist_get_clip_index_at( mlt_playlist this, int position )
+int mlt_playlist_get_clip_index_at( mlt_playlist this, mlt_position position )
 {
        int index = 0, total = 0;
        mlt_playlist_locate( this, &position, &index, &total );
@@ -1172,7 +1185,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 ) )
@@ -1192,6 +1205,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, mlt_position 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.
 */
 
@@ -1230,7 +1251,7 @@ void mlt_playlist_insert_blank( mlt_playlist this, int clip, int length )
        }
 }
 
-void mlt_playlist_pad_blanks( mlt_playlist this, int position, int length, int find )
+void mlt_playlist_pad_blanks( mlt_playlist this, mlt_position position, int length, int find )
 {
        if ( this != NULL && length != 0 )
        {
@@ -1257,7 +1278,7 @@ void mlt_playlist_pad_blanks( mlt_playlist this, int position, int length, int f
        }
 }
 
-int mlt_playlist_insert_at( mlt_playlist this, int position, mlt_producer producer, int mode )
+int mlt_playlist_insert_at( mlt_playlist this, mlt_position position, mlt_producer producer, int mode )
 {
        int ret = this == NULL || position < 0 || producer == NULL;
        if ( ret == 0 )
@@ -1321,7 +1342,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 )
@@ -1355,7 +1376,7 @@ int mlt_playlist_blanks_from( mlt_playlist this, int clip, int bounded )
        return count;
 }
 
-int mlt_playlist_remove_region( mlt_playlist this, int position, int length )
+int mlt_playlist_remove_region( mlt_playlist this, mlt_position position, int length )
 {
        int index = mlt_playlist_get_clip_index_at( this, position );
        if ( index >= 0 && index < this->count )
@@ -1393,7 +1414,7 @@ int mlt_playlist_remove_region( mlt_playlist this, int position, int length )
        return index;
 }
 
-int mlt_playlist_move_region( mlt_playlist this, int position, int length, int new_position )
+int mlt_playlist_move_region( mlt_playlist this, mlt_position position, int length, int new_position )
 {
        if ( this != NULL )
        {
@@ -1430,7 +1451,22 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i
        }
 
        // Get the frame
-       mlt_service_get_frame( real, frame, index );
+       if ( !mlt_properties_get_int( MLT_SERVICE_PROPERTIES( real ), "meta.fx_cut" ) )
+       {
+               mlt_service_get_frame( real, frame, index );
+       }
+       else
+       {
+               mlt_producer parent = mlt_producer_cut_parent( ( mlt_producer )real );
+               *frame = mlt_frame_init( );
+               mlt_properties_set_int( MLT_FRAME_PROPERTIES( *frame ), "fx_cut", 1 );
+               mlt_frame_push_service( *frame, NULL );
+               mlt_frame_push_audio( *frame, NULL );
+               mlt_service_apply_filters( MLT_PRODUCER_SERVICE( parent ), *frame, 0 );
+               mlt_service_apply_filters( real, *frame, 0 );
+               mlt_deque_pop_front( MLT_FRAME_IMAGE_STACK( *frame ) );
+               mlt_deque_pop_front( MLT_FRAME_AUDIO_STACK( *frame ) );
+       }
 
        // Check if we're at the end of the clip
        mlt_properties properties = MLT_FRAME_PROPERTIES( *frame );