]> git.sesse.net Git - mlt/commitdiff
Fix animation serialization when length is not specified
authorBrian Matherly <pez4brian@yahoo.com>
Wed, 15 Jan 2014 15:34:30 +0000 (09:34 -0600)
committerBrian Matherly <pez4brian@yahoo.com>
Wed, 15 Jan 2014 15:36:30 +0000 (09:36 -0600)
src/framework/mlt_animation.c
src/tests/test_properties/test_properties.cpp

index 5928b0d3cb1bded514866cb1254cf8eb1650ecea..94c30e1e5373667daf73ad6d5e8eac7b7f43a27b 100644 (file)
@@ -613,7 +613,7 @@ char *mlt_animation_serialize_cut( mlt_animation self, int in, int out )
                                item.is_key = 1;
                        }
                        // Typically, we move from keyframe to keyframe
-                       else if ( item.frame < out )
+                       else if ( item.frame <= out )
                        {
                                if ( mlt_animation_next_key( self, &item, item.frame ) )
                                        break;
index d709b2032c5f83fe6dd283463822544055a903ec..f1642325fe34f842ef1ad3e03f53e7ef077a761e 100644 (file)
@@ -325,6 +325,39 @@ private Q_SLOTS:
         QCOMPARE(p.get_double("key"), double(1) / double(8));
     }
 
+    void AnimationInsert()
+    {
+        double fps = 25.0;
+        mlt_animation a = mlt_animation_new();
+        struct mlt_animation_item_s item;
+
+        item.is_key = 1;
+        item.keyframe_type = mlt_keyframe_discrete;
+        item.property = mlt_property_init();
+
+        item.frame = 0;
+        mlt_property_set_string(item.property, "0");
+        mlt_animation_insert(a, &item);
+
+        item.frame = 1;
+        mlt_property_set_string(item.property, "1");
+        mlt_animation_insert(a, &item);
+
+        item.frame = 2;
+        mlt_property_set_string(item.property, "2");
+        mlt_animation_insert(a, &item);
+
+        QCOMPARE(mlt_animation_get_length(a), 2);
+
+        char *a_serialized = mlt_animation_serialize(a);
+        mlt_animation_parse(a, a_serialized, 0, fps, locale);
+        QCOMPARE(a_serialized, "0|=0;1|=1;2|=2");
+        if (a_serialized) free(a_serialized);
+
+        mlt_property_close(item.property);
+        mlt_animation_close(a);
+    }
+
     void DoubleAnimation()
     {
         double fps = 25.0;
@@ -912,3 +945,4 @@ private Q_SLOTS:
 QTEST_APPLESS_MAIN(TestProperties)
 
 #include "test_properties.moc"
+