return error;
}
+/** Get a real number associated to the name at a frame position.
+ *
+ * \public \memberof mlt_properties_s
+ * \param self a properties list
+ * \param name the property to get
+ * \return The real number, 0 if not found (which may also be a legitimate value)
+ */
+
+double mlt_properties_anim_get_double( mlt_properties self, const char *name, int position, int length )
+{
+ mlt_profile profile = mlt_properties_get_data( self, "_profile", NULL );
+ double fps = mlt_profile_fps( profile );
+ property_list *list = self->local;
+ mlt_property value = mlt_properties_find( self, name );
+ return value == NULL ? 0.0 : mlt_property_anim_get_double( value, fps, list->locale, position, length );
+}
+
+/** Set a property to a real number at a frame position.
+ *
+ * \public \memberof mlt_properties_s
+ * \param self a properties list
+ * \param name the property to set
+ * \param value the real number
+ * \return true if error
+ */
+
+int mlt_properties_anim_set_double( mlt_properties self, const char *name, double value,
+ mlt_keyframe_type keyframe_type, int position, int length )
+{
+ int error = 1;
+
+ if ( !self || !name ) return error;
+
+ // Fetch the property to work with
+ mlt_property property = mlt_properties_fetch( self, name );
+
+ // Set it if not NULL
+ if ( property != NULL )
+ {
+ mlt_profile profile = mlt_properties_get_data( self, "_profile", NULL );
+ double fps = mlt_profile_fps( profile );
+ property_list *list = self->local;
+ error = mlt_property_anim_set_double( property, value, fps, list->locale, keyframe_type, position, length );
+ mlt_properties_do_mirror( self, name );
+ }
+
+ mlt_events_fire( self, "property-changed", name, NULL );
+
+ return error;
+}
+
/** Set a property to a rectangle value.
*
* \public \memberof mlt_properties_s
extern int mlt_properties_anim_get_int( mlt_properties self, const char *name, int position, int length );
extern int mlt_properties_anim_set_int( mlt_properties self, const char *name, int value, mlt_keyframe_type keyframe_type, int position, int length );
+extern double mlt_properties_anim_get_double( mlt_properties self, const char *name, int position, int length );
+extern int mlt_properties_anim_set_double( mlt_properties self, const char *name, double value, mlt_keyframe_type keyframe_type, int position, int length );
extern int mlt_properties_set_rect( mlt_properties self, const char *name, mlt_rect value );
extern mlt_rect mlt_properties_get_rect( mlt_properties self, const char *name );
-
extern int mlt_properties_anim_set_rect( mlt_properties self, const char *name, mlt_rect value, mlt_keyframe_type keyframe_type, int position, int length );
extern mlt_rect mlt_properties_anim_get_rect( mlt_properties self, const char *name, int position, int length );
{
self->types |= mlt_prop_string;
self->prop_string = malloc( 32 );
- sprintf( self->prop_string, "%f", self->prop_double );
+ sprintf( self->prop_string, "%g", self->prop_double );
}
else if ( self->types & mlt_prop_position )
{
{
self->types |= mlt_prop_string;
self->prop_string = malloc( 32 );
- sprintf( self->prop_string, "%f", self->prop_double );
+ sprintf( self->prop_string, "%g", self->prop_double );
}
else if ( self->types & mlt_prop_position )
{
return mlt_properties_anim_set_int( get_properties(), name, value, keyframe_type, position, length );
}
+double Properties::anim_get_double(const char *name, int position, int length)
+{
+ return mlt_properties_anim_get_double( get_properties(), name, position, length );
+}
+
+int Properties::anim_set(const char *name, double value, int position, int length, mlt_keyframe_type keyframe_type)
+{
+ return mlt_properties_anim_set_double( get_properties(), name, value, keyframe_type, position, length );
+}
+
int Properties::set( const char *name, mlt_rect value )
{
return mlt_properties_set_rect( get_properties(), name, value );
int anim_get_int( const char *name, int position, int length );
int anim_set( const char *name, int value, int position, int length,
mlt_keyframe_type keyframe_type = mlt_keyframe_linear );
+ double anim_get_double( const char *name, int position, int length );
+ int anim_set( const char *name, double value, int position, int length,
+ mlt_keyframe_type keyframe_type = mlt_keyframe_linear );
+
int set( const char *name, mlt_rect value );
int set( const char *name, double x, double y, double w, double h, double opacity = 1.0 );
mlt_rect get_rect( const char* name );
void DoubleFromString()
{
Properties p;
- const char *s = "-1.234567";
- double d = -1.234567;
+ const char *s = "-1.23456";
+ double d = -1.23456;
p.set("key", d);
QCOMPARE(p.get("key"), s);
p.set("key", s);
QCOMPARE(p.anim_get_int("foo", 50, len), 200);
}
+ void PropertiesAnimDouble()
+ {
+ int len = 50;
+ Properties p;
+ p.set_lcnumeric("POSIX");
+
+ // Construct animation from scratch
+ p.anim_set("foo", 0.0, 0, len);
+ p.anim_set("foo", 100.0, 50, len, mlt_keyframe_smooth);
+ QCOMPARE(p.anim_get_double("foo", 0, len), 0.0);
+ QCOMPARE(p.anim_get_double("foo", 25, len), 50.0);
+ QCOMPARE(p.anim_get_double("foo", 50, len), 100.0);
+ QCOMPARE(p.get("foo"), "0=0;50~=100");
+
+ // Animation from string value
+ p.set("foo", "10=100.2;20=200.8");
+ QCOMPARE(p.anim_get_double("foo", 0, len), 100.2);
+ QCOMPARE(p.anim_get_double("foo", 15, len), 150.5);
+ QCOMPARE(p.anim_get_double("foo", 20, len), 200.8);
+
+ // Animation from string using time clock values
+ // Need to set a profile so fps can be used to convert time to frames.
+ Profile profile("dv_pal");
+ p.set("_profile", profile.get_profile(), 0);
+ p.set("foo", ":0.0=100; :2.0=200");
+ QCOMPARE(p.anim_get_double("foo", 0, len), 100.0);
+ QCOMPARE(p.anim_get_double("foo", 25, len), 150.0);
+ QCOMPARE(p.anim_get_double("foo", 50, len), 200.0);
+ }
+
void test_mlt_rect()
{
mlt_property p = mlt_property_init();