more int64 frame addressing in playlist
[melted] / mlt / src / framework / mlt_producer.c
index 164ed59..278d902 100644 (file)
@@ -58,10 +58,11 @@ int mlt_producer_init( mlt_producer this, void *child )
                mlt_properties_set_double( properties, "fps", 25.0 );
                mlt_properties_set_double( properties, "speed", 1.0 );
                mlt_properties_set_timecode( properties, "in", 0.0 );
-               mlt_properties_set_timecode( properties, "out", 3600.0 );
-               mlt_properties_set_timecode( properties, "length", 3600.0 );
+               mlt_properties_set_timecode( properties, "out", 36000.0 );
+               mlt_properties_set_timecode( properties, "length", 36000.0 );
                mlt_properties_set_int( properties, "known_length", 1 );
                mlt_properties_set_double( properties, "aspect_ratio", 4.0 / 3.0 );
+               mlt_properties_set( properties, "log_id", "multitrack" );
 
                // Override service get_frame
                parent->get_frame = producer_get_frame;
@@ -86,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.
 */
 
@@ -110,13 +133,13 @@ int mlt_producer_seek( mlt_producer this, mlt_timecode timecode )
 /** Seek to a specified absolute frame.
 */
 
-int mlt_producer_seek_frame( mlt_producer this, uint64_t frame )
+int mlt_producer_seek_frame( mlt_producer this, int64_t frame )
 {
        // Calculate the time code
        double timecode = ( frame / mlt_producer_get_fps( this ) ) - mlt_producer_get_in( this );
 
        // If timecode is invalid, then seek on time
-       if ( timecode < 0 )
+       if ( frame < 0 || timecode < 0 )
        {
                // Seek to the in point
                mlt_producer_seek( this, 0 );
@@ -264,6 +287,10 @@ static int producer_get_frame( mlt_service service, mlt_frame_ptr frame, int ind
        {
                // Get the frame from the implementation
                result = this->get_frame( this, frame, index );
+
+               mlt_properties frame_properties = mlt_frame_properties( *frame );
+               double speed = mlt_producer_get_speed( this );
+               mlt_properties_set_double( frame_properties, "speed", speed );
        }
        else
        {