[vlmc-devel] WorkflowFileRendererDialog: Simplify the calculation of the rendering progress

Yikai Lu git at videolan.org
Wed May 31 09:01:37 CEST 2017


vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Wed May 31 15:48:55 2017 +0900| [e399a1b20271851959b404e4bd4c5451edfb568e] | committer: Yikai Lu

WorkflowFileRendererDialog: Simplify the calculation of the rendering progress

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

 src/Gui/WorkflowFileRendererDialog.cpp | 20 ++++++++------------
 src/Gui/WorkflowFileRendererDialog.h   |  5 ++---
 src/Workflow/MainWorkflow.cpp          |  3 ++-
 3 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/src/Gui/WorkflowFileRendererDialog.cpp b/src/Gui/WorkflowFileRendererDialog.cpp
index 92b83527..060b73ab 100644
--- a/src/Gui/WorkflowFileRendererDialog.cpp
+++ b/src/Gui/WorkflowFileRendererDialog.cpp
@@ -34,16 +34,12 @@
 #include "Tools/RendererEventWatcher.h"
 #include "Backend/IInput.h"
 
-WorkflowFileRendererDialog::WorkflowFileRendererDialog( quint32 width, quint32 height,
-                                                        qint64 totalFrames, RendererEventWatcher* eventWatcher ) :
+WorkflowFileRendererDialog::WorkflowFileRendererDialog( quint32 width, quint32 height ) :
         m_width( width ),
-        m_height( height ),
-        m_totalFrames( totalFrames )
+        m_height( height )
 {
     m_ui.setupUi( this );
     connect( m_ui.cancelButton, SIGNAL( clicked() ), this, SLOT( cancel() ) );
-
-    connect( eventWatcher, &RendererEventWatcher::positionChanged, this, &WorkflowFileRendererDialog::frameChanged );
 }
 
 void
@@ -69,15 +65,15 @@ WorkflowFileRendererDialog::updatePreview( const uchar* buff )
 }
 
 void
-WorkflowFileRendererDialog::frameChanged( qint64 frame )
+WorkflowFileRendererDialog::frameChanged( qint64 newFrame, qint64 length  )
 {
     // Since frame is 0-indexed
-    frame++;
-    if ( frame <= m_totalFrames )
+    newFrame++;
+    if ( newFrame <= length )
     {
-        m_ui.frameCounter->setText( tr("Rendering frame %1 / %2").arg( QString::number( frame ),
-                                        QString::number( m_totalFrames ) ) );
-        setProgressBarValue( frame * 100 / m_totalFrames );
+        m_ui.frameCounter->setText( tr("Rendering frame %1 / %2").arg( QString::number( newFrame ),
+                                        QString::number( length ) ) );
+        setProgressBarValue( newFrame * 100 / length );
     }
 }
 
diff --git a/src/Gui/WorkflowFileRendererDialog.h b/src/Gui/WorkflowFileRendererDialog.h
index bc13c63c..1051a187 100644
--- a/src/Gui/WorkflowFileRendererDialog.h
+++ b/src/Gui/WorkflowFileRendererDialog.h
@@ -33,7 +33,7 @@ class   WorkflowFileRendererDialog : public QDialog
     Q_OBJECT
     Q_DISABLE_COPY( WorkflowFileRendererDialog )
 public:
-    WorkflowFileRendererDialog( quint32 width, quint32 height, qint64 totalFrames, RendererEventWatcher* eventWatcher );
+    WorkflowFileRendererDialog( quint32 width, quint32 height );
     void    setOutputFileName( const QString& filename );
     void    setProgressBarValue( int val );
 
@@ -41,16 +41,15 @@ private:
     Ui::WorkflowFileRendererDialog      m_ui;
     quint32                             m_width;
     quint32                             m_height;
-    qint64                              m_totalFrames;
 
 signals:
     void    stop();
 
 public slots:
     void    updatePreview( const uchar* buff );
+    void    frameChanged( qint64 newFrame, qint64 length );
 
 private slots:
-    void    frameChanged( qint64 );
     void    cancel();
 };
 
diff --git a/src/Workflow/MainWorkflow.cpp b/src/Workflow/MainWorkflow.cpp
index 2280a364..5c5bf673 100644
--- a/src/Workflow/MainWorkflow.cpp
+++ b/src/Workflow/MainWorkflow.cpp
@@ -335,9 +335,10 @@ MainWorkflow::startRenderToFile( const QString &outputFileName, quint32 width, q
     output.connect( *input );
 
 #ifdef HAVE_GUI
-    WorkflowFileRendererDialog  dialog( width, height, input->playableLength(), m_renderer->eventWatcher() );
+    WorkflowFileRendererDialog  dialog( width, height );
     dialog.setModal( true );
     dialog.setOutputFileName( outputFileName );
+    connect( this, &MainWorkflow::frameChanged, &dialog, &WorkflowFileRendererDialog::frameChanged );
     connect( &dialog, &WorkflowFileRendererDialog::stop, this, [&output]{ output.stop(); } );
     connect( m_renderer->eventWatcher(), &RendererEventWatcher::positionChanged, &dialog,
              [this, input, &dialog, width, height]( qint64 pos )



More information about the Vlmc-devel mailing list