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

Pts diff computation is now properly done.

A bit more refactoring for the same price.
parent a91f733b
......@@ -100,21 +100,15 @@ void AudioClipWorkflow::unlock( AudioClipWorkflow* cw, uint8_t* pcm_buffe
Q_UNUSED( rate );
Q_UNUSED( bits_per_sample );
Q_UNUSED( size );
static qint64 previous_pts = pts;
static qint64 current_pts = pts;
cw->m_renderLock->unlock();
cw->m_stateLock->lockForWrite();
previous_pts = current_pts;
current_pts = pts;
current_pts = qMax( current_pts, previous_pts );
cw->computePtsDiff( pts );
if ( cw->m_buffer->buff != NULL )
{
cw->m_buffer->nbSample = nb_samples;
cw->m_buffer->nbChannels = channels;
cw->m_buffer->ptsDiff = current_pts - previous_pts;
cw->m_buffer->ptsDiff = cw->m_currentPts - cw->m_previousPts;
}
cw->commonUnlock();
......
......@@ -80,6 +80,8 @@ void ClipWorkflow::initialize( bool preloading /*= false*/ )
m_vlcMedia = new LibVLCpp::Media( "fake:///" + m_clip->getParent()->getFileInfo()->absoluteFilePath() );
else
m_vlcMedia = new LibVLCpp::Media( "file:///" + m_clip->getParent()->getFileInfo()->absoluteFilePath() );
m_currentPts = -1;
m_previousPts = -1;
initVlcOutput();
m_mediaPlayer = Pool<LibVLCpp::MediaPlayer>::getInstance()->get();
m_mediaPlayer->setMedia( m_vlcMedia );
......@@ -329,6 +331,8 @@ WaitCondition* ClipWorkflow::getRenderCondWait()
void ClipWorkflow::commonUnlock()
{
m_stateLock->lockForWrite();
if ( m_state == Rendering )
{
QMutexLocker lock( m_condMutex );
......@@ -357,3 +361,13 @@ void ClipWorkflow::commonUnlock()
// qDebug() << '[' << (void*)this << "] ClipWorkflow::unlock";
checkStateChange();
}
void ClipWorkflow::computePtsDiff( qint64 pts )
{
if ( m_previousPts == -1 )
m_previousPts = pts;
if ( m_currentPts == -1 )
m_currentPts = pts;
m_previousPts = m_currentPts;
m_currentPts = qMax( pts, m_previousPts );
}
......@@ -164,6 +164,7 @@ class ClipWorkflow : public QObject
void adjustBegin();
protected:
void computePtsDiff( qint64 pts );
void commonUnlock();
private:
......@@ -196,6 +197,8 @@ class ClipWorkflow : public QObject
WaitCondition* m_renderWaitCond;
QWaitCondition* m_waitCond;
bool m_fullSpeedRender;
qint64 m_previousPts;
qint64 m_currentPts;
/**
* \brief The VLC media used to render
*/
......@@ -203,7 +206,7 @@ class ClipWorkflow : public QObject
protected:
/**
* Don't ever call this method from anywhere else than the unlock() method
* \warning Don't ever call this method from anywhere else than the unlock() method
*/
void checkStateChange();
......
......@@ -100,17 +100,11 @@ void VideoClipWorkflow::unlock( VideoClipWorkflow* cw, void* buffer, int widt
Q_UNUSED( height );
Q_UNUSED( bpp );
Q_UNUSED( size );
static qint64 previous_pts = pts;
static qint64 current_pts = pts;
cw->m_renderLock->unlock();
cw->m_stateLock->lockForWrite();
previous_pts = current_pts;
current_pts = pts;
current_pts = qMax( current_pts, previous_pts );
(*(cw->m_buffer))->ptsDiff = current_pts - previous_pts;
cw->computePtsDiff( pts );
(*(cw->m_buffer))->ptsDiff = cw->m_currentPts - cw->m_previousPts;
cw->commonUnlock();
}
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