]> git.sesse.net Git - mlt/commitdiff
int64 based comms and more unit functionality
authorlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Fri, 9 Jan 2004 14:21:38 +0000 (14:21 +0000)
committerlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Fri, 9 Jan 2004 14:21:38 +0000 (14:21 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@46 d19143bc-622f-0410-bfdd-b5b2a6649095

34 files changed:
mlt/src/framework/mlt_playlist.c
mlt/src/framework/mlt_playlist.h
mlt/src/framework/mlt_producer.c
mlt/src/framework/mlt_producer.h
mlt/src/framework/mlt_property.c
mlt/src/framework/mlt_property.h
mlt/src/humperdink/client.c
mlt/src/humperdink/remote.c
mlt/src/miracle/miracle_local.c
mlt/src/miracle/miracle_unit.c
mlt/src/miracle/miracle_unit.h
mlt/src/miracle/miracle_unit_commands.c
mlt/src/modules/dv/producer_libdv.c
mlt/src/valerie/valerie.c
mlt/src/valerie/valerie.h
mlt/src/valerie/valerie_status.c
mlt/src/valerie/valerie_status.h
src/framework/mlt_playlist.c
src/framework/mlt_playlist.h
src/framework/mlt_producer.c
src/framework/mlt_producer.h
src/framework/mlt_property.c
src/framework/mlt_property.h
src/humperdink/client.c
src/humperdink/remote.c
src/miracle/miracle_local.c
src/miracle/miracle_unit.c
src/miracle/miracle_unit.h
src/miracle/miracle_unit_commands.c
src/modules/dv/producer_libdv.c
src/valerie/valerie.c
src/valerie/valerie.h
src/valerie/valerie_status.c
src/valerie/valerie_status.h

index 168bf62a87281dd053d37ae3ebb19209e572c67b..c28705bf1d54598c59e8696c9b6fc78647024317 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 /** 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.
 */
 
index 8a5ff317355b4379d5f89e56cfefd2a634fd2a16..48b4a55a35f8f98b2012108b8ce19044ebfbaf8b 100644 (file)
 
 #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
index 751e19a9e3066309fd03efd267743c15325a6e97..277db6912ff0bbb6f82b9ef3e4a7d0ac06b0d9ee 100644 (file)
@@ -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.
 */
 
index a59a82d248eb21fa4fb1f6585b42dffc1ea96d4c..888c3bc55e86c10f3e54ec8929a0429a2bc6edaf 100644 (file)
@@ -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 );
index 22e43c8b38572badf3968207059570f3aef09f09..f471b180eda698132dbf073300d63ed2597991e9 100644 (file)
@@ -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;
index 8fb209c464dd423138912f2656743b96a28edf33..6b0def55d781c7dbf0d50342843a05c1a328aa3c 100644 (file)
@@ -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 );
index 1f0ff3d7ddce116498fe0933f44d3e861fd22596..0705c1466b9dff899a9ccea0c23845b240f8b3a2 100644 (file)
@@ -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 );
index 18ac5a56204bf1e9a0849ddd3bddba98d0bc5fe6..9306b21577237f26474331fa065522cffc964745 100644 (file)
@@ -20,6 +20,7 @@
 
 /* System header files */
 #include <stdio.h>
+#include <stdint.h>
 
 /* dv1394d header files */
 #include <valerie/valerie_remote.h>
index e9ef50e186010612f7371fdc14a0cd0df2385722..501487a4925946422dcb6d280735b22d890af8ce 100644 (file)
@@ -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( );
 }
index f7d5509e9d9f5d583f0c46c08cadd3e395f71dcc..bc90d69b9a85bd27187605e701783afcdd379c3e 100644 (file)
@@ -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.
index 1acb9496310a4ba79d9efa8e34a33de8718f1aca..7670b457d8234812b7ae51abdb06ef9cf0f7d3bd 100644 (file)
@@ -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 );
index c85aff05b75c77f208c4d0e78f3943f323707e7e..e0f60031ea2f010d3be2f8ab11681f2bdebc81e0 100644 (file)
@@ -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;
 }
 
index 4e2e9f7055c0fd3bae6991f4a1e4978be0291eb5..8c139df6c663884cac83b3e9eda9d7b5e91e4e12 100644 (file)
@@ -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 );
index 4157284b8006ab45645c1158075caf04d27cab6b..f2731539e00d11f0d74c0316d589921e130d74f4 100644 (file)
@@ -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 );
index fc3b059bc60caaa5bdb18cb7e48226bfbef8440e..658ef9a6b042fe8c1dae883009fe119734d54ef7 100644 (file)
@@ -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;
 
index 5725b0c452ba8e91ada057b9938d228ce978c86c..5e4cbd20771d86ecc136a14023f83cfd8e9aa456 100644 (file)
@@ -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,
index d0e45a94e5ae6b5eabbd5a489098efdfdb91f9fd..5da74971c0f01be4cabcf611b3c128d60ea97c12 100644 (file)
@@ -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;
index 168bf62a87281dd053d37ae3ebb19209e572c67b..c28705bf1d54598c59e8696c9b6fc78647024317 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 /** 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.
 */
 
index 8a5ff317355b4379d5f89e56cfefd2a634fd2a16..48b4a55a35f8f98b2012108b8ce19044ebfbaf8b 100644 (file)
 
 #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
index 751e19a9e3066309fd03efd267743c15325a6e97..277db6912ff0bbb6f82b9ef3e4a7d0ac06b0d9ee 100644 (file)
@@ -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.
 */
 
index a59a82d248eb21fa4fb1f6585b42dffc1ea96d4c..888c3bc55e86c10f3e54ec8929a0429a2bc6edaf 100644 (file)
@@ -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 );
index 22e43c8b38572badf3968207059570f3aef09f09..f471b180eda698132dbf073300d63ed2597991e9 100644 (file)
@@ -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;
index 8fb209c464dd423138912f2656743b96a28edf33..6b0def55d781c7dbf0d50342843a05c1a328aa3c 100644 (file)
@@ -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 );
index 1f0ff3d7ddce116498fe0933f44d3e861fd22596..0705c1466b9dff899a9ccea0c23845b240f8b3a2 100644 (file)
@@ -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 );
index 18ac5a56204bf1e9a0849ddd3bddba98d0bc5fe6..9306b21577237f26474331fa065522cffc964745 100644 (file)
@@ -20,6 +20,7 @@
 
 /* System header files */
 #include <stdio.h>
+#include <stdint.h>
 
 /* dv1394d header files */
 #include <valerie/valerie_remote.h>
index e9ef50e186010612f7371fdc14a0cd0df2385722..501487a4925946422dcb6d280735b22d890af8ce 100644 (file)
@@ -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( );
 }
index f7d5509e9d9f5d583f0c46c08cadd3e395f71dcc..bc90d69b9a85bd27187605e701783afcdd379c3e 100644 (file)
@@ -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.
index 1acb9496310a4ba79d9efa8e34a33de8718f1aca..7670b457d8234812b7ae51abdb06ef9cf0f7d3bd 100644 (file)
@@ -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 );
index c85aff05b75c77f208c4d0e78f3943f323707e7e..e0f60031ea2f010d3be2f8ab11681f2bdebc81e0 100644 (file)
@@ -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;
 }
 
index 4e2e9f7055c0fd3bae6991f4a1e4978be0291eb5..8c139df6c663884cac83b3e9eda9d7b5e91e4e12 100644 (file)
@@ -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 );
index 4157284b8006ab45645c1158075caf04d27cab6b..f2731539e00d11f0d74c0316d589921e130d74f4 100644 (file)
@@ -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 );
index fc3b059bc60caaa5bdb18cb7e48226bfbef8440e..658ef9a6b042fe8c1dae883009fe119734d54ef7 100644 (file)
@@ -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;
 
index 5725b0c452ba8e91ada057b9938d228ce978c86c..5e4cbd20771d86ecc136a14023f83cfd8e9aa456 100644 (file)
@@ -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,
index d0e45a94e5ae6b5eabbd5a489098efdfdb91f9fd..5da74971c0f01be4cabcf611b3c128d60ea97c12 100644 (file)
@@ -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;