Further simplify.
This commit is contained in:
@@ -137,7 +137,6 @@ MovieTexture_FFMpeg::MovieTexture_FFMpeg( RageTextureID ID ):
|
|||||||
|
|
||||||
CreateDecoder();
|
CreateDecoder();
|
||||||
|
|
||||||
LOG->Trace("Codec: %s", m_codec->name );
|
|
||||||
LOG->Trace("Resolution: %ix%i (%ix%i, %ix%i)",
|
LOG->Trace("Resolution: %ix%i (%ix%i, %ix%i)",
|
||||||
m_iSourceWidth, m_iSourceHeight,
|
m_iSourceWidth, m_iSourceHeight,
|
||||||
m_iImageWidth, m_iImageHeight, m_iTextureWidth, m_iTextureHeight);
|
m_iImageWidth, m_iImageHeight, m_iTextureWidth, m_iTextureHeight);
|
||||||
@@ -207,13 +206,14 @@ void MovieTexture_FFMpeg::CreateDecoder()
|
|||||||
if ( m_stream == NULL )
|
if ( m_stream == NULL )
|
||||||
RageException::Throw( averr_ssprintf(ret, "AVCodec: Couldn't find video stream") );
|
RageException::Throw( averr_ssprintf(ret, "AVCodec: Couldn't find video stream") );
|
||||||
|
|
||||||
m_codec = avcodec::avcodec_find_decoder( m_stream->codec.codec_id );
|
avcodec::AVCodec *codec = avcodec::avcodec_find_decoder( m_stream->codec.codec_id );
|
||||||
if( m_codec == NULL )
|
if( codec == NULL )
|
||||||
RageException::Throw( averr_ssprintf(ret, "AVCodec: Couldn't find decoder") );
|
RageException::Throw( averr_ssprintf(ret, "AVCodec: Couldn't find decoder") );
|
||||||
|
|
||||||
ret = avcodec::avcodec_open( &m_stream->codec, m_codec );
|
LOG->Trace("Opening codec %s", codec->name );
|
||||||
|
ret = avcodec::avcodec_open( &m_stream->codec, codec );
|
||||||
if ( ret < 0 )
|
if ( ret < 0 )
|
||||||
RageException::Throw( averr_ssprintf(ret, "AVCodec: Couldn't open decoder (%i)") );
|
RageException::Throw( averr_ssprintf(ret, "AVCodec: Couldn't open decoder") );
|
||||||
|
|
||||||
/* Cap the max texture size to the hardware max. */
|
/* Cap the max texture size to the hardware max. */
|
||||||
actualID.iMaxSize = min( actualID.iMaxSize, DISPLAY->GetMaxTextureSize() );
|
actualID.iMaxSize = min( actualID.iMaxSize, DISPLAY->GetMaxTextureSize() );
|
||||||
@@ -339,7 +339,6 @@ void MovieTexture_FFMpeg::DecoderThread()
|
|||||||
float CurrentTimestamp = 0, Last_IP_Timestamp = 0;
|
float CurrentTimestamp = 0, Last_IP_Timestamp = 0;
|
||||||
|
|
||||||
bool FrameSkipMode = false;
|
bool FrameSkipMode = false;
|
||||||
unsigned Frame = 0;
|
|
||||||
float LastFrameDelay = 0;
|
float LastFrameDelay = 0;
|
||||||
float Clock = 0;
|
float Clock = 0;
|
||||||
RageTimer Timer;
|
RageTimer Timer;
|
||||||
@@ -381,7 +380,6 @@ void MovieTexture_FFMpeg::DecoderThread()
|
|||||||
CurrentTimestamp = Last_IP_Timestamp = 0;
|
CurrentTimestamp = Last_IP_Timestamp = 0;
|
||||||
GetNextTimestamp = true;
|
GetNextTimestamp = true;
|
||||||
FrameSkipMode = false;
|
FrameSkipMode = false;
|
||||||
Frame = 0;
|
|
||||||
LastFrameDelay = 0;
|
LastFrameDelay = 0;
|
||||||
Clock = 0;
|
Clock = 0;
|
||||||
continue;
|
continue;
|
||||||
@@ -404,7 +402,6 @@ void MovieTexture_FFMpeg::DecoderThread()
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
CHECKPOINT;
|
|
||||||
|
|
||||||
/* Decode the packet. */
|
/* Decode the packet. */
|
||||||
int current_packet_offset = 0;
|
int current_packet_offset = 0;
|
||||||
@@ -426,11 +423,13 @@ void MovieTexture_FFMpeg::DecoderThread()
|
|||||||
|
|
||||||
avcodec::AVFrame frame;
|
avcodec::AVFrame frame;
|
||||||
int got_frame;
|
int got_frame;
|
||||||
|
CHECKPOINT;
|
||||||
int len = avcodec::avcodec_decode_video(
|
int len = avcodec::avcodec_decode_video(
|
||||||
&m_stream->codec,
|
&m_stream->codec,
|
||||||
&frame, &got_frame,
|
&frame, &got_frame,
|
||||||
pkt.data + current_packet_offset,
|
pkt.data + current_packet_offset,
|
||||||
pkt.size - current_packet_offset );
|
pkt.size - current_packet_offset );
|
||||||
|
CHECKPOINT;
|
||||||
|
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
{
|
{
|
||||||
@@ -443,8 +442,6 @@ void MovieTexture_FFMpeg::DecoderThread()
|
|||||||
if (!got_frame)
|
if (!got_frame)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
++Frame;
|
|
||||||
|
|
||||||
/* Length of this frame: */
|
/* Length of this frame: */
|
||||||
LastFrameDelay = (float)m_stream->codec.frame_rate_base / m_stream->codec.frame_rate;
|
LastFrameDelay = (float)m_stream->codec.frame_rate_base / m_stream->codec.frame_rate;
|
||||||
LastFrameDelay += frame.repeat_pict * (LastFrameDelay * 0.5f);
|
LastFrameDelay += frame.repeat_pict * (LastFrameDelay * 0.5f);
|
||||||
@@ -506,7 +503,7 @@ void MovieTexture_FFMpeg::DecoderThread()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( FrameSkipMode )
|
if( FrameSkipMode )
|
||||||
if( Frame % 2 )
|
if( m_stream->codec.frame_number % 2 )
|
||||||
SkipThisTextureUpdate = true;
|
SkipThisTextureUpdate = true;
|
||||||
|
|
||||||
if( m_State == PLAYING_ONE )
|
if( m_State == PLAYING_ONE )
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
avcodec::AVFormatContext *m_fctx;
|
avcodec::AVFormatContext *m_fctx;
|
||||||
avcodec::AVStream *m_stream;
|
avcodec::AVStream *m_stream;
|
||||||
avcodec::AVCodec *m_codec;
|
|
||||||
|
|
||||||
/* The time the movie is actually at: */
|
/* The time the movie is actually at: */
|
||||||
float m_Position;
|
float m_Position;
|
||||||
|
|||||||
Reference in New Issue
Block a user