]> git.sesse.net Git - mlt/commitdiff
add mlt_frame_original_position()
authorDan Dennedy <dan@dennedy.org>
Sun, 9 Sep 2012 03:53:44 +0000 (20:53 -0700)
committerDan Dennedy <dan@dennedy.org>
Sun, 9 Sep 2012 05:09:01 +0000 (22:09 -0700)
src/framework/mlt_frame.c
src/framework/mlt_frame.h

index c05aebb18ab81c938858b8648b1caf45fc3fb7e5..36cba041aaf63cde956903874fea50346ef247c7 100644 (file)
@@ -131,10 +131,15 @@ int mlt_frame_set_aspect_ratio( mlt_frame self, double value )
 }
 
 /** Get the time position of this frame.
+ *
+ * This position is not necessarily the position as the original
+ * producer knows it. It could be the position that the playlist,
+ * multitrack, or tractor producer set.
  *
  * \public \memberof mlt_frame_s
  * \param self a frame
  * \return the position
+ * \see mlt_frame_original_position
  */
 
 mlt_position mlt_frame_get_position( mlt_frame self )
@@ -143,6 +148,21 @@ mlt_position mlt_frame_get_position( mlt_frame self )
        return pos < 0 ? 0 : pos;
 }
 
+/** Get the original time position of this frame.
+ *
+ * This is the position that the original producer set on the frame.
+ *
+ * \public \memberof mlt_frame_s
+ * \param self a frame
+ * \return the position
+ */
+
+mlt_position mlt_frame_original_position( mlt_frame self )
+{
+       int pos = mlt_properties_get_position( MLT_FRAME_PROPERTIES( self ), "original_position" );
+       return pos < 0 ? 0 : pos;
+}
+
 /** Set the time position of this frame.
  *
  * \public \memberof mlt_frame_s
@@ -153,6 +173,9 @@ mlt_position mlt_frame_get_position( mlt_frame self )
 
 int mlt_frame_set_position( mlt_frame self, mlt_position value )
 {
+       // Only set the original_position the first time.
+       if ( ! mlt_properties_get( MLT_FRAME_PROPERTIES( self ), "original_position" ) )
+               mlt_properties_set_position( MLT_FRAME_PROPERTIES( self ), "original_position", value );
        return mlt_properties_set_position( MLT_FRAME_PROPERTIES( self ), "_position", value );
 }
 
index 144d867d0a2fd529e293a96c00eeba4a1b81cef8..74e63b8007143d32b1ab6fba2c72827e08cdd012 100644 (file)
@@ -115,6 +115,7 @@ extern int mlt_frame_is_test_audio( mlt_frame self );
 extern double mlt_frame_get_aspect_ratio( mlt_frame self );
 extern int mlt_frame_set_aspect_ratio( mlt_frame self, double value );
 extern mlt_position mlt_frame_get_position( mlt_frame self );
+extern mlt_position mlt_frame_original_position( mlt_frame self );
 extern int mlt_frame_set_position( mlt_frame self, mlt_position value );
 extern int mlt_frame_set_image( mlt_frame self, uint8_t *image, int size, mlt_destructor destroy );
 extern int mlt_frame_set_alpha( mlt_frame self, uint8_t *alpha, int size, mlt_destructor destroy );