Commit db8d7434 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen
Browse files

Switched Clips begin and end to qint64

This doesn't fully work right now, but it does compile.
parent 4a12ae29
......@@ -86,7 +86,7 @@ void Commands::MainWorkflow::RemoveClips::undo()
}
Commands::MainWorkflow::ResizeClip::ResizeClip( ::MainWorkflow* mainWorkflow, const QUuid& uuid, unsigned int trackId,
float newBegin, float newEnd ) :
qint64 newBegin, qint64 newEnd ) :
m_mainWorkflow( mainWorkflow ),
m_newBegin( newBegin ),
m_newEnd( newEnd )
......
......@@ -93,15 +93,15 @@ namespace Commands
{
public:
ResizeClip( ::MainWorkflow* mainWorkflow, const QUuid& uuid, unsigned int trackId,
float newBegin, float newEnd );
qint64 newBegin, qint64 newEnd );
virtual void redo();
virtual void undo();
private:
::MainWorkflow* m_mainWorkflow;
float m_oldBegin;
float m_oldEnd;
float m_newBegin;
float m_newEnd;
qint64 m_oldBegin;
qint64 m_oldEnd;
qint64 m_newBegin;
qint64 m_newEnd;
Clip* m_clip;
};
}
......
......@@ -29,21 +29,21 @@
#include "Clip.h"
Clip::Clip( Media* parent ) : m_parent( parent ), m_begin( 0.0f ), m_end( 1.0f )
Clip::Clip( Media* parent ) : m_parent( parent ), m_begin( 0 ), m_end( -1 )
{
m_Uuid = QUuid::createUuid();
computeLength();
}
Clip::Clip( Clip* creator, float begin, float end ) : m_parent( creator->getParent() ), m_begin( begin ), m_end( end )
Clip::Clip( Clip* creator, qint64 begin, qint64 end ) : m_parent( creator->getParent() ), m_begin( begin ), m_end( end )
{
m_Uuid = QUuid::createUuid();
computeLength();
}
Clip::Clip( Media* parent, float begin, float end ) : m_parent( parent ), m_begin( begin ), m_end( end )
Clip::Clip( Media* parent, qint64 begin, qint64 end ) : m_parent( parent ), m_begin( begin ), m_end( end )
{
Q_ASSERT( parent->getInputType() == Media::File || ( begin == .0f && end == .0f ) );
Q_ASSERT( parent->getInputType() == Media::File || ( begin == 0 && end == -1 ) );
m_Uuid = QUuid::createUuid();
computeLength();
}
......@@ -60,7 +60,7 @@ Clip::Clip( Clip* clip ) :
m_Uuid = QUuid::createUuid();
}
Clip::Clip( const QUuid& uuid, float begin, float end ) :
Clip::Clip( const QUuid& uuid, qint64 begin, qint64 end ) :
m_begin( begin),
m_end( end )
{
......@@ -76,12 +76,12 @@ Clip::~Clip()
{
}
float Clip::getBegin() const
qint64 Clip::getBegin() const
{
return m_begin;
}
float Clip::getEnd() const
qint64 Clip::getEnd() const
{
return m_end;
}
......@@ -93,7 +93,7 @@ Media* Clip::getParent()
qint64 Clip::getLength() const
{
return m_length;
return m_length / 1000 * m_parent->getFps();
}
qint64 Clip::getLengthSecond() const
......@@ -105,12 +105,19 @@ void Clip::computeLength()
{
if ( m_parent->getInputType() == Media::File )
{
unsigned int fps = m_parent->getFps();
if ( fps < 0.1f )
fps = FPS;
qint64 nbMs = (qint64)( ( m_end - m_begin ) * (float)m_parent->getLength() );
m_lengthSeconds = nbMs / 1000;
m_length = (nbMs / 1000) * fps;
if ( m_end == -1 )
{
m_lengthSeconds = m_parent->getLength() / 1000;
m_length = m_parent->getnbFrames();
}
else
{
unsigned int fps = m_parent->getFps();
if ( fps < 0.1f )
fps = FPS;
m_lengthSeconds = ( m_end - m_begin ) / 1000;
m_length = m_lengthSeconds * fps;
}
emit lengthUpdated();
}
else
......@@ -160,7 +167,7 @@ const QUuid& Clip::getUuid() const
return m_Uuid;
}
void Clip::setBegin( float begin )
void Clip::setBegin( qint64 begin )
{
Q_ASSERT( begin >= .0f );
if ( begin == m_begin ) return;
......@@ -169,7 +176,7 @@ void Clip::setBegin( float begin )
emit lengthUpdated();
}
void Clip::setEnd( float end )
void Clip::setEnd( qint64 end )
{
Q_ASSERT( end <= 1.0f );
if ( end == m_end ) return;
......
......@@ -44,52 +44,39 @@ class Clip : public QObject
public:
Clip( Media* parent );
Clip( Media* parent, float begin, float end );
Clip( Clip* creator, float begin, float end );
Clip( Media* parent, qint64 begin, qint64 end );
Clip( Clip* creator, qint64 begin, qint64 end );
Clip( Clip* clip );
Clip( const QUuid& uuid, float begin = .0f, float end = 1.0f );
Clip( const QUuid& uuid, qint64 begin = 0, qint64 end = -1 );
virtual ~Clip();
/**
\brief Returns the clip starting point. This value will be in
vlc positition units (0 to 1)
\return A value between 0 and 1, where 0 is the real Media begin,
and 1 the real Media end.
*/
float getBegin() const;
qint64 getBegin() const;
qint64 getEnd() const;
/**
\brief Returns the clip ending point. This value will be in
vlc positition units (0 to 1)
\return A value between 0 and 1, where 0 is the real Media end,
and 1 the real Media end.
*/
float getEnd() const;
void setBegin( float begin );
void setEnd( float end );
void setBegin( qint64 begin );
void setEnd( qint64 end );
/**
\return Returns the clip length in frame.
\return Returns the clip length in frame.
*/
qint64 getLength() const;
qint64 getLength() const;
/**
\return Returns the clip length in seconds.
\return Returns the clip length in seconds.
*/
qint64 getLengthSecond() const;
qint64 getLengthSecond() const;
/**
\return Returns the Media that the clip was basep uppon.
\return Returns the Media that the clip was basep uppon.
*/
Media* getParent();
Media* getParent();
/**
\brief Returns an unique Uuid for this clip (which is NOT the
parent's Uuid).
\brief Returns an unique Uuid for this clip (which is NOT the
parent's Uuid).
\return The Clip's Uuid as a QUuid
\return The Clip's Uuid as a QUuid
*/
const QUuid& getUuid() const;
......@@ -119,9 +106,24 @@ class Clip : public QObject
void computeLength();
Media* m_parent;
float m_begin;
float m_end;
/**
* \brief This represents the beginning of the Clip in frames, from the
* beginning of the parent Media.
*/
qint64 m_begin;
/**
* \brief This represents the end of the Clip in frames, from the
* beginning of the parent Media.
*/
qint64 m_end;
/**
* \brief The length in frames
*/
qint64 m_length;
/**
* \brief The length in seconds (Be carreful, VLC uses MILLIseconds)
*/
qint64 m_lengthSeconds;
/**
* The Clip's timeline UUID. Used to identify the Clip in the
......
......@@ -80,12 +80,15 @@ void* WorkflowRenderer::lock( void* datas )
{
WorkflowRenderer* self = reinterpret_cast<WorkflowRenderer*>( datas );
qDebug() << "WorkflowRenderer::lock";
if ( self->m_stopping == false )
{
qDebug() << "WorkflowRenderer::lock -> rendering";
void* ret = self->m_mainWorkflow->getSynchroneOutput();
self->m_lastFrame = static_cast<unsigned char*>( ret );
return ret;
}
qDebug() << "WorkflowRenderer::endOfLock";
return self->m_lastFrame;
}
......@@ -242,13 +245,16 @@ void WorkflowRenderer::internalPlayPause( bool forcePause )
void WorkflowRenderer::stop()
{
qDebug() << "Stopping workflowrenderer";
m_isRendering = false;
m_paused = false;
m_pauseAsked = false;
m_unpauseAsked = false;
m_stopping = true;
m_mainWorkflow->cancelSynchronisation();
qDebug() << "Stopping media player";
m_mediaPlayer->stop();
qDebug() << "Media player stopped";
m_mainWorkflow->stop();
}
......@@ -258,6 +264,7 @@ void WorkflowRenderer::stop()
void WorkflowRenderer::__endReached()
{
qDebug() << "Stopping rendering";
stopPreview();
emit endReached();
}
......
......@@ -238,7 +238,10 @@ void MainWorkflow::stop()
for (unsigned int i = 0; i < m_trackCount; ++i)
{
if ( m_tracks[i].activated() == true )
{
m_tracks[i]->stop();
qDebug() << "Stopping track";
}
}
m_currentFrame = 0;
emit frameChanged( 0 );
......@@ -421,8 +424,8 @@ void MainWorkflow::loadProject( const QDomElement& project )
//Iterate over clip fields:
QDomElement clipProperty = clip.firstChild().toElement();
QUuid parent;
float begin;
float end;
qint64 begin;
qint64 end;
qint64 startPos;
while ( clipProperty.isNull() == false )
......@@ -434,7 +437,7 @@ void MainWorkflow::loadProject( const QDomElement& project )
parent = QUuid( clipProperty.text() );
else if ( tagName == "begin" )
{
begin = clipProperty.text().toFloat( &ok );
begin = clipProperty.text().toLongLong( &ok );
if ( ok == false )
{
qWarning() << "Invalid clip begin";
......@@ -443,7 +446,7 @@ void MainWorkflow::loadProject( const QDomElement& project )
}
else if ( tagName == "end" )
{
end = clipProperty.text().toFloat( &ok );
end = clipProperty.text().toLongLong( &ok );
if ( ok == false )
{
qWarning() << "Invalid clip end";
......
......@@ -152,6 +152,7 @@ INCLUDEPATH += src/LibVLCpp \
# QMAKE_CFLAGS+=-pg
# QMAKE_CXXFLAGS+=-pg
# QMAKE_LFLAGS+=-pg
# QMAKE_CXXFLAGS += -W -Wall -Wold-style-cast
LIBS = -L/usr/local/lib \
-lvlc
SUBDIRS += modules
......
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