Hopefully fix "Assertion '!m_ImageWaiting || m_State == DECODER_QUIT' failed"
Fix timing issues (needs more testing)
This commit is contained in:
@@ -345,6 +345,7 @@ void MovieTexture_FFMpeg::DecoderThread()
|
|||||||
float Clock = 0;
|
float Clock = 0;
|
||||||
RageTimer Timer;
|
RageTimer Timer;
|
||||||
|
|
||||||
|
float pts = 0, last_IP_pts = 0;
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
|
|
||||||
while( m_State != DECODER_QUIT )
|
while( m_State != DECODER_QUIT )
|
||||||
@@ -414,14 +415,9 @@ void MovieTexture_FFMpeg::DecoderThread()
|
|||||||
if ( GetNextTimestamp )
|
if ( GetNextTimestamp )
|
||||||
{
|
{
|
||||||
if (pkt.pts != AV_NOPTS_VALUE)
|
if (pkt.pts != AV_NOPTS_VALUE)
|
||||||
CurrentTimestamp = (float)pkt.pts * m_fctx->pts_num / m_fctx->pts_den;
|
pts = (float)pkt.pts * m_fctx->pts_num / m_fctx->pts_den;
|
||||||
else
|
else
|
||||||
{
|
pts = -1;
|
||||||
/* If the timestamp is zero, this frame is to be played at the
|
|
||||||
* time of the last frame plus the length of the last frame. */
|
|
||||||
CurrentTimestamp += LastFrameDelay;
|
|
||||||
}
|
|
||||||
|
|
||||||
GetNextTimestamp = false;
|
GetNextTimestamp = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -457,7 +453,21 @@ void MovieTexture_FFMpeg::DecoderThread()
|
|||||||
|
|
||||||
if ( m_stream->codec.has_b_frames &&
|
if ( m_stream->codec.has_b_frames &&
|
||||||
frame.pict_type != FF_B_TYPE )
|
frame.pict_type != FF_B_TYPE )
|
||||||
swap( CurrentTimestamp, Last_IP_Timestamp );
|
{
|
||||||
|
LOG->Trace("%s BF", GetID().filename.c_str() );
|
||||||
|
swap( pts, last_IP_pts );
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pts != -1)
|
||||||
|
{
|
||||||
|
CurrentTimestamp = pts;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* If the timestamp is zero, this frame is to be played at the
|
||||||
|
* time of the last frame plus the length of the last frame. */
|
||||||
|
CurrentTimestamp += LastFrameDelay;
|
||||||
|
}
|
||||||
|
|
||||||
m_Position = CurrentTimestamp;
|
m_Position = CurrentTimestamp;
|
||||||
|
|
||||||
@@ -504,7 +514,8 @@ void MovieTexture_FFMpeg::DecoderThread()
|
|||||||
|
|
||||||
if( -Offset >= FrameSkipThreshold && !FrameSkipMode )
|
if( -Offset >= FrameSkipThreshold && !FrameSkipMode )
|
||||||
{
|
{
|
||||||
LOG->Trace( "Entering frame skip mode" );
|
LOG->Trace( "(%s) Time is %f, and the movie is at %f. Entering frame skip mode.",
|
||||||
|
GetID().filename.c_str(), CurrentTimestamp, Clock );
|
||||||
FrameSkipMode = true;
|
FrameSkipMode = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -522,8 +533,6 @@ void MovieTexture_FFMpeg::DecoderThread()
|
|||||||
(avcodec::AVPicture *) &frame, m_stream->codec.pix_fmt,
|
(avcodec::AVPicture *) &frame, m_stream->codec.pix_fmt,
|
||||||
m_stream->codec.width, m_stream->codec.height);
|
m_stream->codec.width, m_stream->codec.height);
|
||||||
|
|
||||||
ASSERT( SDL_SemValue( m_BufferFinished ) == 0 );
|
|
||||||
|
|
||||||
/* Signal the main thread to update the image on the next Update. */
|
/* Signal the main thread to update the image on the next Update. */
|
||||||
m_ImageWaiting=true;
|
m_ImageWaiting=true;
|
||||||
|
|
||||||
@@ -589,6 +598,9 @@ void MovieTexture_FFMpeg::Reload()
|
|||||||
|
|
||||||
void MovieTexture_FFMpeg::StartThread()
|
void MovieTexture_FFMpeg::StartThread()
|
||||||
{
|
{
|
||||||
|
/* If we had a frame waiting from a previous thread start, clear it. */
|
||||||
|
m_ImageWaiting = false;
|
||||||
|
|
||||||
ASSERT( m_State == DECODER_QUIT );
|
ASSERT( m_State == DECODER_QUIT );
|
||||||
m_State = PAUSE_DECODER;
|
m_State = PAUSE_DECODER;
|
||||||
m_DecoderThread.SetName( ssprintf("MovieTexture_FFMpeg(%s)", GetID().filename.c_str()) );
|
m_DecoderThread.SetName( ssprintf("MovieTexture_FFMpeg(%s)", GetID().filename.c_str()) );
|
||||||
|
|||||||
Reference in New Issue
Block a user