]> git.sesse.net Git - mlt/blobdiff - src/framework/mlt_property.c
Add mlt_properties_set/get_int_pos and Properties::set/get_int.
[mlt] / src / framework / mlt_property.c
index 7d8808fb53d46e34f61584ff81ee6a513e09bc83..8604e31f1a5aa60b6c7084f4a3db0fd92bac2745 100644 (file)
@@ -971,7 +971,7 @@ int mlt_property_interpolate( mlt_property self, mlt_property p[],
        double progress, double fps, locale_t locale, mlt_keyframe_type interp )
 {
        int error = 0;
-       if ( interp != mlt_keyframe_discrete && fps > 0 &&
+       if ( interp != mlt_keyframe_discrete &&
                is_property_numeric( p[1], locale ) && is_property_numeric( p[2], locale ) )
        {
                double value;
@@ -1005,9 +1005,19 @@ static void refresh_animation( mlt_property self, double fps, locale_t locale, i
        if ( !self->animation )
        {
                self->animation = mlt_animation_new();
-               mlt_animation_parse( self->animation, self->prop_string, length, fps, locale );
+               if ( self->prop_string )
+               {
+                       mlt_animation_parse( self->animation, self->prop_string, length, fps, locale );
+               }
+               else
+               {
+                       mlt_animation_set_length( self->animation, length );
+                       self->types |= mlt_prop_data;
+                       self->data = self->animation;
+                       self->serialiser = (mlt_serialiser) mlt_animation_serialize;
+               }
        }
-       else
+       else if ( self->prop_string )
        {
                mlt_animation_refresh( self->animation, self->prop_string, length );
        }
@@ -1016,7 +1026,7 @@ static void refresh_animation( mlt_property self, double fps, locale_t locale, i
 double mlt_property_get_double_pos( mlt_property self, double fps, locale_t locale, int position, int length )
 {
        double result;
-       if ( ( self->types & mlt_prop_string ) && self->prop_string )
+       if ( self->animation || ( ( self->types & mlt_prop_string ) && self->prop_string ) )
        {
                struct mlt_animation_item_s item;
                item.property = mlt_property_init();
@@ -1037,7 +1047,7 @@ double mlt_property_get_double_pos( mlt_property self, double fps, locale_t loca
 int mlt_property_get_int_pos( mlt_property self, double fps, locale_t locale, int position, int length )
 {
        int result;
-       if ( ( self->types & mlt_prop_string ) && self->prop_string )
+       if ( self->animation || ( ( self->types & mlt_prop_string ) && self->prop_string ) )
        {
                struct mlt_animation_item_s item;
                item.property = mlt_property_init();
@@ -1067,23 +1077,18 @@ int mlt_property_set_double_pos( mlt_property self, double value, double fps, lo
        mlt_keyframe_type keyframe_type, int position, int length )
 {
        int result;
-       if ( ( self->types & mlt_prop_string ) && self->prop_string )
-       {
-               struct mlt_animation_item_s item;
-               item.property = mlt_property_init();
-               item.frame = position;
-               item.keyframe_type = keyframe_type;
-               mlt_property_set_double( item.property, value );
+       struct mlt_animation_item_s item;
+
+       item.property = mlt_property_init();
+       item.frame = position;
+       item.keyframe_type = keyframe_type;
+       mlt_property_set_double( item.property, value );
+
+       refresh_animation( self, fps, locale, length );
+       result = mlt_animation_insert( self->animation, &item );
+       mlt_animation_interpolate( self->animation );
+       mlt_property_close( item.property );
 
-               refresh_animation( self, fps, locale, length );
-               result = mlt_animation_insert( self->animation, &item );
-               mlt_animation_interpolate( self->animation );
-               mlt_property_close( item.property );
-       }
-       else
-       {
-               result = mlt_property_set_double( self, value );
-       }
        return result;
 }
 
@@ -1099,22 +1104,17 @@ int mlt_property_set_int_pos( mlt_property self, int value, double fps, locale_t
        mlt_keyframe_type keyframe_type, int position, int length )
 {
        int result;
-       if ( ( self->types & mlt_prop_string ) && self->prop_string )
-       {
-               struct mlt_animation_item_s item;
-               item.property = mlt_property_init();
-               item.frame = position;
-               item.keyframe_type = keyframe_type;
-               mlt_property_set_int( item.property, value );
+       struct mlt_animation_item_s item;
+
+       item.property = mlt_property_init();
+       item.frame = position;
+       item.keyframe_type = keyframe_type;
+       mlt_property_set_int( item.property, value );
+
+       refresh_animation( self, fps, locale, length );
+       result = mlt_animation_insert( self->animation, &item );
+       mlt_animation_interpolate( self->animation );
+       mlt_property_close( item.property );
 
-               refresh_animation( self, fps, locale, length );
-               result = mlt_animation_insert( self->animation, &item );
-               mlt_animation_interpolate( self->animation );
-               mlt_property_close( item.property );
-       }
-       else
-       {
-               result = mlt_property_set_int( self, value );
-       }
        return result;
 }