From f0999c804841a94de8cdbe497875aaa3d70938f1 Mon Sep 17 00:00:00 2001 From: Brian Matherly Date: Wed, 15 Jan 2014 09:34:30 -0600 Subject: [PATCH] Fix animation serialization when length is not specified --- src/framework/mlt_animation.c | 2 +- src/tests/test_properties/test_properties.cpp | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/framework/mlt_animation.c b/src/framework/mlt_animation.c index 5928b0d3..94c30e1e 100644 --- a/src/framework/mlt_animation.c +++ b/src/framework/mlt_animation.c @@ -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; diff --git a/src/tests/test_properties/test_properties.cpp b/src/tests/test_properties/test_properties.cpp index d709b203..f1642325 100644 --- a/src/tests/test_properties/test_properties.cpp +++ b/src/tests/test_properties/test_properties.cpp @@ -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" + -- 2.39.2