]> git.sesse.net Git - mlt/commitdiff
enhance producer_westley to parse Kino 0.9.1 SMIL (clock) time values.
authorddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
Wed, 9 Aug 2006 06:55:47 +0000 (06:55 +0000)
committerddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
Wed, 9 Aug 2006 06:55:47 +0000 (06:55 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@920 d19143bc-622f-0410-bfdd-b5b2a6649095

src/modules/westley/producer_westley.c

index c9fe9bfab883e4c9feb12e53ce32bb8a1683cd8e..626be13c3e306acb535d633b077afb5e02d1a6d0 100644 (file)
@@ -433,6 +433,44 @@ static void on_start_producer( deserialise_context context, const xmlChar *name,
                mlt_properties_set( properties, (char*) atts[0], atts[1] == NULL ? "" : (char*) atts[1] );
 }
 
+// Parse a SMIL clock value (as produced by Kino 0.9.1) and return position in frames
+static mlt_position parse_clock_value( char *value, double fps )
+{
+       // This implementation expects a fully specified clock value - no optional
+       // parts (e.g. 1:05)
+       char *pos, *copy = strdup( value );
+       int hh, mm, ss, ms;
+       mlt_position result = -1;
+
+       value = copy;
+       pos = strchr( value, ':' );
+       if ( !pos )
+               return result;
+       *pos = '\0';
+       hh = atoi( value );
+       value = pos + 1;
+
+       pos = strchr( value, ':' );
+       if ( !pos )
+               return result;
+       *pos = '\0';
+       mm = atoi( value );
+       value = pos + 1;
+       
+       pos = strchr( value, '.' );
+       if ( !pos )
+               return result;
+       *pos = '\0';
+       ss = atoi( value );
+       value = pos + 1;
+       
+       ms = atoi( value );
+       free( copy );
+       result = ( fps * ( ( (hh * 3600) + (mm * 60) + ss ) * 1000  + ms ) / 1000 + 0.5 );
+       
+       return result;
+}
+
 static void on_end_producer( deserialise_context context, const xmlChar *name )
 {
        enum service_type type;
@@ -495,14 +533,29 @@ static void on_end_producer( deserialise_context context, const xmlChar *name )
                        in = mlt_properties_get_position( properties, "in" );
                // Let Kino-SMIL clipBegin be a synonym for in
                if ( mlt_properties_get( properties, "clipBegin" ) != NULL )
-                       in = mlt_properties_get_position( properties, "clipBegin" );
+               {
+                       if ( strchr( mlt_properties_get( properties, "clipBegin" ), ':' ) )
+                               // Parse clock value
+                               in = parse_clock_value( mlt_properties_get( properties, "clipBegin" ),
+                                       mlt_properties_get_double( mlt_producer_properties( MLT_PRODUCER( producer ) ), "fps" ) );
+                       else
+                               // Parse frames value
+                               in = mlt_properties_get_position( properties, "clipBegin" );
+               }
                // Get out
                if ( mlt_properties_get( properties, "out" ) != NULL )
                        out = mlt_properties_get_position( properties, "out" );
                // Let Kino-SMIL clipEnd be a synonym for out
                if ( mlt_properties_get( properties, "clipEnd" ) != NULL )
-                       out = mlt_properties_get_position( properties, "clipEnd" );
-       
+               {
+                       if ( strchr( mlt_properties_get( properties, "clipEnd" ), ':' ) )
+                               // Parse clock value
+                               out = parse_clock_value( mlt_properties_get( properties, "clipEnd" ),
+                                       mlt_properties_get_double( mlt_producer_properties( MLT_PRODUCER( producer ) ), "fps" ) );
+                       else
+                               // Parse frames value
+                               out = mlt_properties_get_position( properties, "clipEnd" );
+               }
                // Remove in and out
                mlt_properties_set( properties, "in", NULL );
                mlt_properties_set( properties, "out", NULL );