]> git.sesse.net Git - mlt/commitdiff
Add mlt_transition_get_progress().
authorDan Dennedy <dan@dennedy.org>
Tue, 8 Mar 2011 06:34:25 +0000 (22:34 -0800)
committerDan Dennedy <dan@dennedy.org>
Fri, 11 Mar 2011 07:15:45 +0000 (23:15 -0800)
src/framework/mlt_transition.c
src/framework/mlt_transition.h
src/mlt++/MltTransition.cpp
src/mlt++/MltTransition.h

index afa9fc2c867c8e2cb73e4865ed7e58edc171680f..0ce7de095db65aac49cbce29d44e7f28f8d0ea76 100644 (file)
@@ -205,6 +205,28 @@ mlt_position mlt_transition_get_length( mlt_transition self )
        return ( out > 0 ) ? ( out - in + 1 ) : 0;
 }
 
+/** Get the relative position of a frame.
+ *
+ * \public \memberof mlt_transition_s
+ * \param self a transition
+ * \param frame a frame
+ * \return the progress in the range 0.0 to 1.0
+ */
+
+double mlt_transition_get_progress( mlt_transition self, mlt_frame frame )
+{
+       double progress = 0;
+       mlt_position out = mlt_transition_get_out( self );
+
+       if ( out != 0 )
+       {
+               mlt_position in = mlt_transition_get_in( self );
+               mlt_position position = mlt_frame_get_position( frame );
+               progress = ( double ) ( position - in ) / ( double ) ( out - in + 1 );
+       }
+       return progress;
+}
+
 /** Process the frame.
  *
  * If we have no process method (unlikely), we simply return the a_frame unmolested.
index 8bf892000074ef90b954377e40cc19c5bad6d125..96a0166e35b40151d8c843eac1e2b32813ca5c95 100644 (file)
@@ -74,6 +74,7 @@ extern int mlt_transition_get_b_track( mlt_transition self );
 extern mlt_position mlt_transition_get_in( mlt_transition self );
 extern mlt_position mlt_transition_get_out( mlt_transition self );
 extern mlt_position mlt_transition_get_length( mlt_transition self );
+extern double mlt_transition_get_progress( mlt_transition self, mlt_frame frame );
 extern mlt_frame mlt_transition_process( mlt_transition self, mlt_frame a_frame, mlt_frame b_frame );
 extern void mlt_transition_close( mlt_transition self );
 
index 4e0575fcea36468b09cb39abe7a0b78e446bdad5..04c0b87c66c40668c201a8e9718a0d0b1c0870d4 100644 (file)
@@ -121,3 +121,8 @@ int Transition::get_length( )
 {
        return mlt_transition_get_length( get_transition( ) );
 }
+
+double Transition::get_progress( Frame &frame )
+{
+       return mlt_transition_get_progress( get_transition( ), frame.get_frame( ) );
+}
index b547c048efb4ba91bd1eeeb93e924efabb990ba6..e3eb537c0d18f061baf32c77a3bec8e05cd4620b 100644 (file)
@@ -30,6 +30,7 @@ namespace Mlt
 {
        class Service;
        class Profile;
+       class Frame;
 
        class MLTPP_DECLSPEC Transition : public Service
        {
@@ -50,6 +51,7 @@ namespace Mlt
                        int get_in( );
                        int get_out( );
                        int get_length( );
+                       double get_progress( Frame &frame );
        };
 }