]> git.sesse.net Git - mlt/commitdiff
Add mlt_transition_get_progress_delta().
authorDan Dennedy <dan@dennedy.org>
Tue, 8 Mar 2011 06:58:29 +0000 (22:58 -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 0ce7de095db65aac49cbce29d44e7f28f8d0ea76..707a87891bb842a050220c28691973370448f4d2 100644 (file)
@@ -227,6 +227,31 @@ double mlt_transition_get_progress( mlt_transition self, mlt_frame frame )
        return progress;
 }
 
+/** Get the second field incremental progress.
+ *
+ * \public \memberof mlt_transition_s
+ * \param self a transition
+ * \param frame a frame
+ * \return the progress increment in the range 0.0 to 1.0
+ */
+
+double mlt_transition_get_progress_delta( 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 );
+               double length = out - in + 1;
+               double x = ( double ) ( position - in ) / length;
+               double y = ( double ) ( position + 1 - in ) / length;
+               progress = length * ( y - x ) / 2.0;
+       }
+       return progress;
+}
+
 /** Process the frame.
  *
  * If we have no process method (unlikely), we simply return the a_frame unmolested.
index 96a0166e35b40151d8c843eac1e2b32813ca5c95..340d2d706bab61dd62711d021898bda0b80dbb1b 100644 (file)
@@ -75,6 +75,7 @@ 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 double mlt_transition_get_progress_delta( 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 04c0b87c66c40668c201a8e9718a0d0b1c0870d4..527aba3e6894fbf3a4b0659a54785adffbffeb23 100644 (file)
@@ -126,3 +126,8 @@ double Transition::get_progress( Frame &frame )
 {
        return mlt_transition_get_progress( get_transition( ), frame.get_frame( ) );
 }
+
+double Transition::get_progress_delta( Frame &frame )
+{
+       return mlt_transition_get_progress_delta( get_transition( ), frame.get_frame( ) );
+}
index e3eb537c0d18f061baf32c77a3bec8e05cd4620b..51e8401a5644395bd656f7f24d750bbc3f45c725 100644 (file)
@@ -52,6 +52,7 @@ namespace Mlt
                        int get_out( );
                        int get_length( );
                        double get_progress( Frame &frame );
+                       double get_progress_delta( Frame &frame );
        };
 }