[vlmc-devel] Resize using MLTTrack

Yikai Lu git at videolan.org
Sun Jun 26 06:01:37 CEST 2016


vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Sun Jun 19 16:12:16 2016 +0900| [a136a706bfbdbbd21252ca719b02e2a69ec15345] | committer: Yikai Lu

Resize using MLTTrack

> https://code.videolan.org/videolan/vlmc/commit/a136a706bfbdbbd21252ca719b02e2a69ec15345
---

 src/Commands/Commands.cpp      | 12 ++----------
 src/Workflow/TrackWorkflow.cpp | 16 ++++++++++++++++
 src/Workflow/TrackWorkflow.h   |  1 +
 3 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/src/Commands/Commands.cpp b/src/Commands/Commands.cpp
index 2ca19f7..800116c 100644
--- a/src/Commands/Commands.cpp
+++ b/src/Commands/Commands.cpp
@@ -221,21 +221,13 @@ Commands::Clip::Resize::retranslate()
 void
 Commands::Clip::Resize::internalRedo()
 {
-    if ( m_newBegin != m_newEnd )
-    {
-        m_trackWorkflow->moveClip( m_clip->uuid(), m_newPos );
-    }
-    m_clip->setBoundaries( m_newBegin, m_newEnd );
+    m_trackWorkflow->resizeClip( m_clip->uuid(), m_newBegin, m_newEnd );
 }
 
 void
 Commands::Clip::Resize::internalUndo()
 {
-    if ( m_oldBegin != m_newBegin )
-    {
-        m_trackWorkflow->moveClip( m_clip->uuid(), m_oldPos );
-    }
-    m_clip->setBoundaries( m_oldBegin, m_oldEnd );
+    m_trackWorkflow->resizeClip( m_clip->uuid(), m_oldBegin, m_oldEnd );
 }
 
 Commands::Clip::Split::Split( TrackWorkflow *tw, ::Clip *toSplit,
diff --git a/src/Workflow/TrackWorkflow.cpp b/src/Workflow/TrackWorkflow.cpp
index eee3f0e..681db36 100644
--- a/src/Workflow/TrackWorkflow.cpp
+++ b/src/Workflow/TrackWorkflow.cpp
@@ -147,6 +147,22 @@ TrackWorkflow::moveClip( const QUuid& id, qint64 startingFrame )
 }
 
 void
+TrackWorkflow::resizeClip( const QUuid &id, qint64 begin, qint64 end )
+{
+    QWriteLocker    lock( m_clipsLock );
+
+    for ( auto it = m_clips.begin(); it != m_clips.end(); ++it )
+    {
+        auto clip = it.value();
+        if ( clip->uuid() == id )
+        {
+            auto track = ( clip->formats().testFlag( Clip::Audio ) ) ? m_audioTrack : m_videoTrack;
+            track->resizeClip( track->clipIndexAt( it.key() ), begin, end );
+        }
+    }
+}
+
+void
 TrackWorkflow::clipDestroyed( const QUuid& id )
 {
     QWriteLocker    lock( m_clipsLock );
diff --git a/src/Workflow/TrackWorkflow.h b/src/Workflow/TrackWorkflow.h
index b115aa8..02a5a9f 100644
--- a/src/Workflow/TrackWorkflow.h
+++ b/src/Workflow/TrackWorkflow.h
@@ -60,6 +60,7 @@ class   TrackWorkflow : public QObject
         ~TrackWorkflow();
 
         void                                    moveClip( const QUuid& id, qint64 startingFrame );
+        void                                    resizeClip( const QUuid& id, qint64 begin, qint64 end );
         Clip*                                   removeClip( const QUuid& id );
         void                                    addClip( Clip*, qint64 start );
         qint64                                  getClipPosition( const QUuid& uuid ) const;



More information about the Vlmc-devel mailing list