}
return NULL;
}
+
+/** Get an integer 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 integer value, 0 if not found (which may also be a legitimate value)
+ */
+
+int mlt_properties_get_int_pos( 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 : mlt_property_get_int_pos( value, fps, list->locale, position, length );
+}
+
+/** Set a property to an integer value at a frame position.
+ *
+ * \public \memberof mlt_properties_s
+ * \param self a properties list
+ * \param name the property to set
+ * \param value the integer
+ * \return true if error
+ */
+
+int mlt_properties_set_int_pos( mlt_properties self, const char *name, int 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_set_int_pos( 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;
+}
+
extern void mlt_properties_unlock( mlt_properties self );
extern char *mlt_properties_get_time( mlt_properties, const char* name, mlt_time_format );
+extern int mlt_properties_get_int_pos( mlt_properties self, const char *name, int position, int length );
+extern int mlt_properties_set_int_pos( mlt_properties self, const char *name, int value, mlt_keyframe_type keyframe_type, int position, int length );
+
#endif
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;
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 );
}
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();
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();
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;
}
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;
}
{
return mlt_properties_get_time( get_properties(), name, format );
}
+
+int Properties::get_int( const char *name, int position, int length )
+{
+ return mlt_properties_get_int_pos( get_properties(), name, position, length );
+}
+
+int Properties::set( const char *name, int value, int position, int length, mlt_keyframe_type keyframe_type )
+{
+ return mlt_properties_set_int_pos( get_properties(), name, value, keyframe_type, position, length );
+}
int set_lcnumeric( const char *locale );
const char *get_lcnumeric( );
char *get_time( const char *name, mlt_time_format = mlt_time_smpte );
+ int get_int( const char *name, int position, int length );
+ int set( const char *name, int value, int position, int length,
+ mlt_keyframe_type keyframe_type = mlt_keyframe_linear );
};
}
p.set("foo", "456 %");
QCOMPARE(p.get_double("foo"), 456.0);
}
+
+ void PropertiesAnimInt()
+ {
+ int len = 50;
+ Properties p;
+ p.set_lcnumeric("POSIX");
+
+ // Construct animation from scratch
+ p.set("foo", 0, 0, len);
+ p.set("foo", 100, 50, len, mlt_keyframe_smooth);
+ QCOMPARE(p.get_int("foo", 0, len), 0);
+ QCOMPARE(p.get_int("foo", 25, len), 50);
+ QCOMPARE(p.get_int("foo", 50, len), 100);
+ QCOMPARE(p.get("foo"), "0=0;50~=100");
+
+ // Animation from string value
+ p.set("foo", "10=100;20=200");
+ QCOMPARE(p.get_int("foo", 0, len), 100);
+ QCOMPARE(p.get_int("foo", 15, len), 150);
+ QCOMPARE(p.get_int("foo", 20, len), 200);
+
+ // 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.get_int("foo", 0, len), 100);
+ QCOMPARE(p.get_int("foo", 25, len), 150);
+ QCOMPARE(p.get_int("foo", 50, len), 200);
+ }
};
QTEST_APPLESS_MAIN(TestProperties)