Commit be598092 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Added a preview when rendering.

Manual buffer copy has been replaced by memcpy in the light video frame.
parent 9b9d4161
......@@ -76,12 +76,14 @@ Commands::MainWorkflow::MoveClip::MoveClip( ::MainWorkflow* workflow, const QUui
void Commands::MainWorkflow::MoveClip::redo()
{
// qDebug() << "Moving clip from track" << m_oldTrack << "to" << m_newTrack << "at position:" << m_pos;
m_workflow->moveClip( m_uuid, m_oldTrack, m_newTrack, m_pos, m_trackType, m_undoRedoAction );
m_undoRedoAction = true;
}
void Commands::MainWorkflow::MoveClip::undo()
{
// qDebug() << "Undo moving clip from track" << m_newTrack << "to" << m_oldTrack << "at position:" << m_oldPos;
m_workflow->moveClip( m_uuid, m_newTrack, m_oldTrack, m_oldPos, m_trackType, m_undoRedoAction );
m_undoRedoAction = true;
}
......
......@@ -41,14 +41,11 @@ VideoFrame::VideoFrame(VideoFrame const & tocopy) : QSharedData( tocopy )
{
if ( tocopy.frame.octets != NULL )
{
quint32 i;
nboctets = tocopy.nboctets;
nbpixels = tocopy.nboctets / Pixel::NbComposantes;
frame.octets = new quint8[tocopy.nboctets];
for ( i = 0; i < nboctets; ++i )
frame.octets[i] = tocopy.frame.octets[i];
memcpy( frame.octets, tocopy.frame.octets, nboctets );
}
else
{
......@@ -89,15 +86,12 @@ LightVideoFrame::LightVideoFrame(quint32 nboctets)
LightVideoFrame::LightVideoFrame(quint8 const * tocopy, quint32 nboctets)
{
quint32 i;
m_videoFrame = new VideoFrame;
m_videoFrame->nboctets = nboctets;
m_videoFrame->nbpixels = nboctets / Pixel::NbComposantes;
m_videoFrame->frame.octets = new quint8[nboctets];
m_videoFrame = new VideoFrame;
m_videoFrame->nboctets = nboctets;
m_videoFrame->nbpixels = nboctets / Pixel::NbComposantes;
m_videoFrame->frame.octets = new quint8[nboctets];
for ( i = 0; i < m_videoFrame->nboctets; ++i )
m_videoFrame->frame.octets[i] = tocopy[i];
memcpy( m_videoFrame->frame.octets, tocopy, m_videoFrame->nboctets );
};
LightVideoFrame::~LightVideoFrame()
......
......@@ -241,6 +241,7 @@ void MainWindow::createStatusBar()
void MainWindow::initializeDockWidgets( void )
{
WorkflowRenderer* workflowRenderer = new WorkflowRenderer();
workflowRenderer->initializeRenderer();
m_timeline = new Timeline( workflowRenderer, this );
m_timeline->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
m_timeline->show();
......@@ -352,6 +353,7 @@ void MainWindow::on_actionRender_triggered()
if ( m_renderer )
delete m_renderer;
m_renderer = new WorkflowFileRenderer( outputFileName );
m_renderer->initializeRenderer();
m_renderer->run();
}
}
......
/*****************************************************************************
* WorkflowFileRendererDialog.cpp: Display a render feedback.
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
* Christophe Courtaut <christophe.courtaut@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "WorkflowFileRendererDialog.h"
#define VIDEOWIDTH 640
#define VIDEOHEIGHT 480
#include <QDebug>
WorkflowFileRendererDialog::WorkflowFileRendererDialog()
{
m_ui.setupUi( this );
......@@ -15,3 +43,8 @@ void WorkflowFileRendererDialog::setProgressBarValue( int val )
{
m_ui.progressBar->setValue( val );
}
void WorkflowFileRendererDialog::updatePreview( const uchar* buff )
{
m_ui.previewLabel->setPixmap( QPixmap::fromImage( QImage( buff, VIDEOWIDTH, VIDEOHEIGHT, QImage::Format_RGB888 ).rgbSwapped() ) );
}
......@@ -37,6 +37,9 @@ public:
private:
Ui::WorkflowFileRendererDialog m_ui;
public slots:
void updatePreview( const uchar* buff );
friend class WorkflowFileRenderer;
};
......
......@@ -20,14 +20,14 @@
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<item row="2" column="0">
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="2" column="0">
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="nameLabel">
......@@ -65,6 +65,13 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="previewLabel">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
......
......@@ -27,14 +27,18 @@ WorkflowFileRenderer::WorkflowFileRenderer( const QString& outputFileName ) :
WorkflowRenderer(),
m_outputFileName( outputFileName )
{
m_image = NULL;
m_timer.setSingleShot( true );
m_dialog = new WorkflowFileRendererDialog;
m_dialog->setModal( true );
m_dialog->setOutputFileName( outputFileName );
connect( m_dialog->m_ui.cancelButton, SIGNAL( clicked() ), this, SLOT( cancelButtonClicked() ) );
connect( this, SIGNAL( imageUpdated( const uchar* ) ), m_dialog, SLOT( updatePreview( const uchar* ) ) );
}
WorkflowFileRenderer::~WorkflowFileRenderer()
{
delete m_image;
}
void WorkflowFileRenderer::run()
......@@ -84,7 +88,35 @@ float WorkflowFileRenderer::getFps() const
return m_outputFps;
}
void* WorkflowFileRenderer::lock( void *datas )
{
WorkflowFileRenderer* self = reinterpret_cast<WorkflowFileRenderer*>( datas );
void* ret = WorkflowRenderer::lock( datas );
if ( self->m_timer.isActive() == false )
{
self->emit imageUpdated( (uchar*)ret );
self->m_timer.start( 1000 );
}
return ret;
}
void WorkflowFileRenderer::unlock( void *datas )
{
WorkflowRenderer::unlock( datas );
}
void WorkflowFileRenderer::__frameChanged( qint64 frame, MainWorkflow::FrameChangedReason )
{
m_dialog->setProgressBarValue( frame * 100 / m_mainWorkflow->getLengthFrame() );
}
void* WorkflowFileRenderer::getLockCallback()
{
return (void*)&WorkflowFileRenderer::lock;
}
void* WorkflowFileRenderer::getUnlockCallback()
{
return (void*)&WorkflowFileRenderer::unlock;
}
......@@ -28,6 +28,8 @@
#include "WorkflowRenderer.h"
#include "WorkflowFileRendererDialog.h"
#include <QTimer>
class WorkflowFileRenderer : public WorkflowRenderer
{
Q_OBJECT
......@@ -45,11 +47,20 @@ public:
private:
const QString m_outputFileName;
WorkflowFileRendererDialog* m_dialog;
QImage* m_image;
QTimer m_timer;
protected:
virtual void* getLockCallback();
virtual void* getUnlockCallback();
private slots:
void stop();
void cancelButtonClicked();
void __frameChanged( qint64 frame, MainWorkflow::FrameChangedReason reason );
signals:
void imageUpdated( const uchar* image );
};
#endif // WORKFLOWFILERENDERER_H
......@@ -32,9 +32,12 @@ WorkflowRenderer::WorkflowRenderer() :
m_mainWorkflow( MainWorkflow::getInstance() ),
m_stopping( false )
{
char buffer[64];
m_actionsMutex = new QMutex;
}
void WorkflowRenderer::initializeRenderer()
{
char buffer[64];
m_media = new LibVLCpp::Media( "fake://" );
sprintf( buffer, ":invmem-width=%i", VIDEOWIDTH );
......@@ -42,9 +45,9 @@ WorkflowRenderer::WorkflowRenderer() :
m_media->addOption( buffer );
sprintf( buffer, ":invmem-height=%i", VIDEOHEIGHT );
m_media->addOption( buffer );
sprintf( buffer, ":invmem-lock=%lld", (qint64)WorkflowRenderer::lock );
sprintf( buffer, ":invmem-lock=%lld", (qint64)getLockCallback() );
m_media->addOption( buffer );
sprintf( buffer, ":invmem-unlock=%lld", (qint64)WorkflowRenderer::unlock );
sprintf( buffer, ":invmem-unlock=%lld", (qint64)getUnlockCallback() );
m_media->addOption( buffer );
sprintf( buffer, ":invmem-data=%lld", (qint64)this );
m_media->addOption( buffer );
......@@ -71,7 +74,6 @@ WorkflowRenderer::WorkflowRenderer() :
this, SLOT( __frameChanged( qint64, MainWorkflow::FrameChangedReason ) ) );
}
WorkflowRenderer::~WorkflowRenderer()
{
stop();
......@@ -335,6 +337,16 @@ void WorkflowRenderer::resizeClip( Clip* clip, qint64 newBegin, qint64 newEnd
// }
}
void* WorkflowRenderer::getLockCallback()
{
return (void*)&WorkflowRenderer::lock;
}
void* WorkflowRenderer::getUnlockCallback()
{
return (void*)&WorkflowRenderer::unlock;
}
/////////////////////////////////////////////////////////////////////
/////SLOTS :
/////////////////////////////////////////////////////////////////////
......@@ -364,3 +376,4 @@ void WorkflowRenderer::__videoPaused()
{
emit paused();
}
......@@ -42,6 +42,7 @@ class WorkflowRenderer : public GenericRenderer
WorkflowRenderer();
~WorkflowRenderer();
void initializeRenderer();
virtual void togglePlayPause( bool forcePause );
virtual void stop();
virtual void nextFrame();
......@@ -79,6 +80,10 @@ class WorkflowRenderer : public GenericRenderer
virtual void startPreview();
void checkActions();
protected:
virtual void* getLockCallback();
virtual void* getUnlockCallback();
protected:
MainWorkflow* m_mainWorkflow;
LibVLCpp::Media* m_media;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment