mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-02 23:41:51 +00:00
Merge branch 'master' into glew
This commit is contained in:
commit
60ccf3567b
10 changed files with 213 additions and 75 deletions
|
@ -48,6 +48,8 @@ If you have questions concerning this license or the applicable additional terms
|
||||||
|
|
||||||
#include "../sys/sys_savegame.h"
|
#include "../sys/sys_savegame.h"
|
||||||
|
|
||||||
|
#include "idlib/sys/sys_defines.h"
|
||||||
|
|
||||||
#if defined( _DEBUG )
|
#if defined( _DEBUG )
|
||||||
#define BUILD_DEBUG "-debug"
|
#define BUILD_DEBUG "-debug"
|
||||||
#else
|
#else
|
||||||
|
@ -113,8 +115,8 @@ idGameEdit* gameEdit = NULL;
|
||||||
idCommonLocal commonLocal;
|
idCommonLocal commonLocal;
|
||||||
idCommon* common = &commonLocal;
|
idCommon* common = &commonLocal;
|
||||||
|
|
||||||
|
// RB: defaulted this to 1 because we don't have a sound for the intro .bik video
|
||||||
idCVar com_skipIntroVideos( "com_skipIntroVideos", "0", CVAR_BOOL , "skips intro videos" );
|
idCVar com_skipIntroVideos( "com_skipIntroVideos", "1", CVAR_BOOL , "skips intro videos" );
|
||||||
|
|
||||||
// For doom classic
|
// For doom classic
|
||||||
struct Globals;
|
struct Globals;
|
||||||
|
@ -900,14 +902,101 @@ void idCommonLocal::RenderBink( const char* path )
|
||||||
material->Parse( materialText.c_str(), materialText.Length(), false );
|
material->Parse( materialText.c_str(), materialText.Length(), false );
|
||||||
material->ResetCinematicTime( Sys_Milliseconds() );
|
material->ResetCinematicTime( Sys_Milliseconds() );
|
||||||
|
|
||||||
while( Sys_Milliseconds() <= material->GetCinematicStartTime() + material->CinematicLength() )
|
// RB: FFmpeg might return the wrong play length so I changed the intro video to play max 30 seconds until finished
|
||||||
|
int cinematicLength = 30000; //material->CinematicLength();
|
||||||
|
int mouseEvents[MAX_MOUSE_EVENTS][2];
|
||||||
|
|
||||||
|
bool escapeEvent = false;
|
||||||
|
while( ( Sys_Milliseconds() <= ( material->GetCinematicStartTime() + cinematicLength ) ) && material->CinematicIsPlaying() )
|
||||||
{
|
{
|
||||||
renderSystem->DrawStretchPic( chop, 0, imageWidth, renderSystem->GetVirtualHeight(), 0, 0, 1, 1, material );
|
renderSystem->DrawStretchPic( chop, 0, imageWidth, renderSystem->GetVirtualHeight(), 0, 0, 1, 1, material );
|
||||||
const emptyCommand_t* cmd = renderSystem->SwapCommandBuffers( &time_frontend, &time_backend, &time_shadows, &time_gpu );
|
const emptyCommand_t* cmd = renderSystem->SwapCommandBuffers( &time_frontend, &time_backend, &time_shadows, &time_gpu );
|
||||||
renderSystem->RenderCommandBuffers( cmd );
|
renderSystem->RenderCommandBuffers( cmd );
|
||||||
|
|
||||||
Sys_GenerateEvents();
|
Sys_GenerateEvents();
|
||||||
|
|
||||||
|
// queue system events ready for polling
|
||||||
|
Sys_GetEvent();
|
||||||
|
|
||||||
|
// RB: allow to escape video by pressing anything
|
||||||
|
int numKeyEvents = Sys_PollKeyboardInputEvents();
|
||||||
|
if( numKeyEvents > 0 )
|
||||||
|
{
|
||||||
|
for( int i = 0; i < numKeyEvents; i++ )
|
||||||
|
{
|
||||||
|
int key;
|
||||||
|
bool state;
|
||||||
|
|
||||||
|
if( Sys_ReturnKeyboardInputEvent( i, key, state ) )
|
||||||
|
{
|
||||||
|
if( key == K_ESCAPE && state == true )
|
||||||
|
{
|
||||||
|
escapeEvent = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Sys_EndKeyboardInputEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
int numMouseEvents = Sys_PollMouseInputEvents( mouseEvents );
|
||||||
|
if( numMouseEvents > 0 )
|
||||||
|
{
|
||||||
|
for( int i = 0; i < numMouseEvents; i++ )
|
||||||
|
{
|
||||||
|
int action = mouseEvents[i][0];
|
||||||
|
switch( action )
|
||||||
|
{
|
||||||
|
case M_ACTION1:
|
||||||
|
case M_ACTION2:
|
||||||
|
case M_ACTION3:
|
||||||
|
case M_ACTION4:
|
||||||
|
case M_ACTION5:
|
||||||
|
case M_ACTION6:
|
||||||
|
case M_ACTION7:
|
||||||
|
case M_ACTION8:
|
||||||
|
escapeEvent = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: // some other undefined button
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int numJoystickEvents = Sys_PollJoystickInputEvents( 0 );
|
||||||
|
if( numJoystickEvents > 0 )
|
||||||
|
{
|
||||||
|
for( int i = 0; i < numJoystickEvents; i++ )
|
||||||
|
{
|
||||||
|
int action;
|
||||||
|
int value;
|
||||||
|
|
||||||
|
if( Sys_ReturnJoystickInputEvent( i, action, value ) )
|
||||||
|
{
|
||||||
|
if( action >= J_ACTION1 && action <= J_ACTION_MAX )
|
||||||
|
{
|
||||||
|
if( value != 0 )
|
||||||
|
{
|
||||||
|
escapeEvent = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Sys_EndJoystickInputEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
if( escapeEvent )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
Sys_Sleep( 10 );
|
Sys_Sleep( 10 );
|
||||||
}
|
}
|
||||||
|
// RB end
|
||||||
|
|
||||||
material->MakeDefault();
|
material->MakeDefault();
|
||||||
}
|
}
|
||||||
|
@ -1933,12 +2022,7 @@ CONSOLE_COMMAND( testSIMD, "test SIMD code", NULL )
|
||||||
// RB begin
|
// RB begin
|
||||||
CONSOLE_COMMAND( testFormattingSizes, "test printf format security", 0 )
|
CONSOLE_COMMAND( testFormattingSizes, "test printf format security", 0 )
|
||||||
{
|
{
|
||||||
#ifdef _MSC_VER
|
common->Printf( " sizeof( int32 ): %" PRIuSIZE " bytes\n", sizeof( int32 ) );
|
||||||
common->Printf( " sizeof( int32 ): %Iu bytes\n", sizeof( int32 ) );
|
common->Printf( " sizeof( int64 ): %" PRIuSIZE " bytes\n", sizeof( int64 ) );
|
||||||
common->Printf( " sizeof( int64 ): %Iu bytes\n", sizeof( int64 ) );
|
|
||||||
#else
|
|
||||||
common->Printf( " sizeof( int32 ): %zu bytes\n", sizeof( int32 ) );
|
|
||||||
common->Printf( " sizeof( int64 ): %zu bytes\n", sizeof( int64 ) );
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
// RB end
|
// RB end
|
||||||
|
|
|
@ -31,6 +31,7 @@ If you have questions concerning this license or the applicable additional terms
|
||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
|
|
||||||
#include "Unzip.h"
|
#include "Unzip.h"
|
||||||
|
#include "idlib/sys/sys_defines.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=================
|
=================
|
||||||
|
@ -844,11 +845,7 @@ int idFile_Memory::Write( const void* buffer, int len )
|
||||||
{
|
{
|
||||||
if( maxSize != 0 )
|
if( maxSize != 0 )
|
||||||
{
|
{
|
||||||
#ifdef _MSC_VER
|
common->Error( "idFile_Memory::Write: exceeded maximum size %" PRIuSIZE "", maxSize );
|
||||||
common->Error( "idFile_Memory::Write: exceeded maximum size %Iu", maxSize );
|
|
||||||
#else
|
|
||||||
common->Error( "idFile_Memory::Write: exceeded maximum size %zu", maxSize );
|
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int extra = granularity * ( 1 + alloc / granularity );
|
int extra = granularity * ( 1 + alloc / granularity );
|
||||||
|
@ -934,13 +931,7 @@ void idFile_Memory::PreAllocate( size_t len )
|
||||||
{
|
{
|
||||||
if( maxSize != 0 )
|
if( maxSize != 0 )
|
||||||
{
|
{
|
||||||
// RB begin
|
idLib::Error( "idFile_Memory::SetLength: exceeded maximum size %" PRIuSIZE "", maxSize );
|
||||||
#ifdef _MSC_VER
|
|
||||||
idLib::Error( "idFile_Memory::SetLength: exceeded maximum size %Iu", maxSize );
|
|
||||||
#else
|
|
||||||
idLib::Error( "idFile_Memory::SetLength: exceeded maximum size %zu", maxSize );
|
|
||||||
#endif
|
|
||||||
// RB end
|
|
||||||
}
|
}
|
||||||
char* newPtr = ( char* )Mem_Alloc( len, TAG_IDFILE );
|
char* newPtr = ( char* )Mem_Alloc( len, TAG_IDFILE );
|
||||||
if( allocated > 0 )
|
if( allocated > 0 )
|
||||||
|
@ -1126,13 +1117,7 @@ void idFile_Memory::TruncateData( size_t len )
|
||||||
{
|
{
|
||||||
if( len > allocated )
|
if( len > allocated )
|
||||||
{
|
{
|
||||||
// RB begin
|
idLib::Error( "idFile_Memory::TruncateData: len (%" PRIuSIZE ") exceeded allocated size (%" PRIuSIZE ")", len, allocated );
|
||||||
#ifdef _MSV_VER
|
|
||||||
idLib::Error( "idFile_Memory::TruncateData: len (%Iu) exceeded allocated size (%Iu)", len, allocated );
|
|
||||||
#else
|
|
||||||
idLib::Error( "idFile_Memory::TruncateData: len (%zu) exceeded allocated size (%zu)", len, allocated );
|
|
||||||
#endif
|
|
||||||
// RB end
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2126,5 +2111,3 @@ CONSOLE_COMMAND( testEndianNessReset, "Tests the read/write compatibility betwee
|
||||||
{
|
{
|
||||||
fileSystem->RemoveFile( testEndianNessFilename );
|
fileSystem->RemoveFile( testEndianNessFilename );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ Contains external code for building ZipFiles.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Zip.h"
|
#include "Zip.h"
|
||||||
|
#include "idlib/sys/sys_defines.h"
|
||||||
|
|
||||||
// #undef STDC
|
// #undef STDC
|
||||||
|
|
||||||
|
@ -504,13 +505,7 @@ bool idZipBuilder::CreateZipFileFromFiles( const idList< idFile_Memory* >& srcFi
|
||||||
errcode = zipWriteInFileInZip( zf, buffer.Ptr(), ( unsigned int )bytesRead );
|
errcode = zipWriteInFileInZip( zf, buffer.Ptr(), ( unsigned int )bytesRead );
|
||||||
if( errcode != ZIP_OK )
|
if( errcode != ZIP_OK )
|
||||||
{
|
{
|
||||||
// RB begin
|
idLib::Warning( "Error writing to zipfile (%" PRIuSIZE " bytes)!", bytesRead );
|
||||||
#ifdef _MSC_VER
|
|
||||||
idLib::Warning( "Error writing to zipfile (%Iu bytes)!", bytesRead );
|
|
||||||
#else
|
|
||||||
idLib::Warning( "Error writing to zipfile (%zu bytes)!", bytesRead );
|
|
||||||
#endif
|
|
||||||
// RB end
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -618,13 +613,7 @@ bool idZipBuilder::AddFile( zipFile zf, idFile_Memory* src, bool deleteFile )
|
||||||
errcode = zipWriteInFileInZip( zf, buffer.Ptr(), ( unsigned int )bytesRead );
|
errcode = zipWriteInFileInZip( zf, buffer.Ptr(), ( unsigned int )bytesRead );
|
||||||
if( errcode != ZIP_OK )
|
if( errcode != ZIP_OK )
|
||||||
{
|
{
|
||||||
// RB begin
|
idLib::Warning( "Error writing to zipfile (%" PRIuSIZE " bytes)!", bytesRead );
|
||||||
#ifdef _MSC_VER
|
|
||||||
idLib::Warning( "Error writing to zipfile (%Iu bytes)!", bytesRead );
|
|
||||||
#else
|
|
||||||
idLib::Warning( "Error writing to zipfile (%zu bytes)!", bytesRead );
|
|
||||||
#endif
|
|
||||||
// RB end
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,3 +257,22 @@ extern volatile int ignoredReturnValue;
|
||||||
#define MIN_UNSIGNED_TYPE( x ) 0
|
#define MIN_UNSIGNED_TYPE( x ) 0
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Macros for format conversion specifications for integer arguments of type
|
||||||
|
* size_t or ssize_t.
|
||||||
|
*/
|
||||||
|
#ifdef _MSV_VER
|
||||||
|
|
||||||
|
#define PRIiSIZE "Ii"
|
||||||
|
#define PRIuSIZE "Iu"
|
||||||
|
#define PRIxSIZE "Ix"
|
||||||
|
|
||||||
|
#else // ifdef _MSV_VER
|
||||||
|
|
||||||
|
#define PRIiSIZE "zi"
|
||||||
|
#define PRIuSIZE "zu"
|
||||||
|
#define PRIxSIZE "zx"
|
||||||
|
|
||||||
|
#endif // ifdef _MSV_VER
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
/* #define GEN_TREES_H */
|
/* #define GEN_TREES_H */
|
||||||
|
|
||||||
#include "deflate.h"
|
#include "deflate.h"
|
||||||
|
#include "idlib/sys/sys_defines.h"
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
# include <ctype.h>
|
# include <ctype.h>
|
||||||
|
@ -940,17 +941,9 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
||||||
/* Determine the best encoding. Compute the block lengths in bytes. */
|
/* Determine the best encoding. Compute the block lengths in bytes. */
|
||||||
opt_lenb = (s->opt_len+3+7)>>3;
|
opt_lenb = (s->opt_len+3+7)>>3;
|
||||||
static_lenb = (s->static_len+3+7)>>3;
|
static_lenb = (s->static_len+3+7)>>3;
|
||||||
// RB begin
|
Tracev((stderr, "\nopt %" PRIuSIZE "(%" PRIuSIZE ") stat %" PRIuSIZE "(%" PRIuSIZE ") stored %" PRIuSIZE " lit %u ",
|
||||||
#ifdef _MSC_VER
|
|
||||||
Tracev((stderr, "\nopt %Iu(%Iu) stat %Iu(%Iu) stored %Iu lit %u ",
|
|
||||||
opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
|
opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
|
||||||
s->last_lit));
|
s->last_lit));
|
||||||
#else
|
|
||||||
Tracev((stderr, "\nopt %zu(%zu) stat %zu(%zu) stored %zu lit %u ",
|
|
||||||
opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
|
|
||||||
s->last_lit));
|
|
||||||
#endif
|
|
||||||
// RB end
|
|
||||||
if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
|
if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -1009,7 +1002,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
||||||
Tracev((stderr,"\ncomprlen %Iu(%Iu) ", s->compressed_len>>3,
|
Tracev((stderr,"\ncomprlen %Iu(%Iu) ", s->compressed_len>>3,
|
||||||
s->compressed_len-7*last));
|
s->compressed_len-7*last));
|
||||||
#else
|
#else
|
||||||
Tracev((stderr,"\ncomprlen %zu(%zu) ", s->compressed_len>>3,
|
Tracev((stderr,"\ncomprlen %" PRIuSIZE "(%" PRIuSIZE ") ", s->compressed_len>>3,
|
||||||
s->compressed_len-7*last));
|
s->compressed_len-7*last));
|
||||||
#endif
|
#endif
|
||||||
// RB end
|
// RB end
|
||||||
|
|
|
@ -75,6 +75,9 @@ public:
|
||||||
virtual bool InitFromFile( const char* qpath, bool looping );
|
virtual bool InitFromFile( const char* qpath, bool looping );
|
||||||
virtual cinData_t ImageForTime( int milliseconds );
|
virtual cinData_t ImageForTime( int milliseconds );
|
||||||
virtual int AnimationLength();
|
virtual int AnimationLength();
|
||||||
|
// RB begin
|
||||||
|
bool IsPlaying() const;
|
||||||
|
// RB end
|
||||||
virtual void Close();
|
virtual void Close();
|
||||||
virtual void ResetTime( int time );
|
virtual void ResetTime( int time );
|
||||||
|
|
||||||
|
@ -89,7 +92,7 @@ private:
|
||||||
AVCodecContext* dec_ctx;
|
AVCodecContext* dec_ctx;
|
||||||
SwsContext* img_convert_ctx;
|
SwsContext* img_convert_ctx;
|
||||||
bool hasFrame;
|
bool hasFrame;
|
||||||
long FramePos;
|
long framePos;
|
||||||
|
|
||||||
cinData_t ImageForTimeFFMPEG( int milliseconds );
|
cinData_t ImageForTimeFFMPEG( int milliseconds );
|
||||||
bool InitFromFFMPEGFile( const char* qpath, bool looping );
|
bool InitFromFFMPEGFile( const char* qpath, bool looping );
|
||||||
|
@ -359,6 +362,13 @@ void idCinematic::Close()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RB begin
|
||||||
|
bool idCinematic::IsPlaying() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// RB end
|
||||||
|
|
||||||
|
|
||||||
//===========================================
|
//===========================================
|
||||||
|
|
||||||
|
@ -511,19 +521,25 @@ bool idCinematicLocal::InitFromFFMPEGFile( const char* qpath, bool amilooping )
|
||||||
float durationSec = static_cast<double>( fmt_ctx->streams[video_stream_index]->duration ) * static_cast<double>( ticksPerFrame ) / static_cast<double>( avr.den );
|
float durationSec = static_cast<double>( fmt_ctx->streams[video_stream_index]->duration ) * static_cast<double>( ticksPerFrame ) / static_cast<double>( avr.den );
|
||||||
animationLength = durationSec * 1000;
|
animationLength = durationSec * 1000;
|
||||||
frameRate = av_q2d( fmt_ctx->streams[video_stream_index]->r_frame_rate );
|
frameRate = av_q2d( fmt_ctx->streams[video_stream_index]->r_frame_rate );
|
||||||
startTime = 0;
|
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
hasFrame = false;
|
hasFrame = false;
|
||||||
FramePos = -1;
|
framePos = -1;
|
||||||
common->Warning( "%dx%d, %f FPS, %f sec", CIN_WIDTH, CIN_HEIGHT, frameRate, durationSec );
|
common->Warning( "%dx%d, %f FPS, %f sec", CIN_WIDTH, CIN_HEIGHT, frameRate, durationSec );
|
||||||
image = ( byte* )Mem_Alloc( CIN_WIDTH * CIN_HEIGHT * 4 * 2, TAG_CINEMATIC );
|
image = ( byte* )Mem_Alloc( CIN_WIDTH * CIN_HEIGHT * 4 * 2, TAG_CINEMATIC );
|
||||||
avpicture_fill( ( AVPicture* )frame2, image, PIX_FMT_BGR32, CIN_WIDTH, CIN_HEIGHT );
|
avpicture_fill( ( AVPicture* )frame2, image, PIX_FMT_BGR32, CIN_WIDTH, CIN_HEIGHT );
|
||||||
if( img_convert_ctx )
|
if( img_convert_ctx )
|
||||||
|
{
|
||||||
sws_freeContext( img_convert_ctx );
|
sws_freeContext( img_convert_ctx );
|
||||||
|
}
|
||||||
img_convert_ctx = sws_getContext( dec_ctx->width, dec_ctx->height, dec_ctx->pix_fmt, CIN_WIDTH, CIN_HEIGHT, PIX_FMT_BGR32, SWS_BICUBIC, NULL, NULL, NULL );
|
img_convert_ctx = sws_getContext( dec_ctx->width, dec_ctx->height, dec_ctx->pix_fmt, CIN_WIDTH, CIN_HEIGHT, PIX_FMT_BGR32, SWS_BICUBIC, NULL, NULL, NULL );
|
||||||
status = FMV_PLAY;
|
status = FMV_PLAY;
|
||||||
|
|
||||||
|
startTime = 0;
|
||||||
ImageForTime( 0 );
|
ImageForTime( 0 );
|
||||||
status = ( looping ) ? FMV_PLAY : FMV_IDLE;
|
status = ( looping ) ? FMV_PLAY : FMV_IDLE;
|
||||||
|
|
||||||
|
//startTime = Sys_Milliseconds();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -536,10 +552,19 @@ idCinematicLocal::FFMPEGReset
|
||||||
#if defined(USE_FFMPEG)
|
#if defined(USE_FFMPEG)
|
||||||
void idCinematicLocal::FFMPEGReset()
|
void idCinematicLocal::FFMPEGReset()
|
||||||
{
|
{
|
||||||
startTime = 0;
|
// RB: don't reset startTime here because that breaks video replays in the PDAs
|
||||||
FramePos = -1;
|
//startTime = 0;
|
||||||
av_seek_frame( fmt_ctx, video_stream_index, 0, 0 );
|
|
||||||
status = FMV_LOOPED;
|
framePos = -1;
|
||||||
|
|
||||||
|
if( av_seek_frame( fmt_ctx, video_stream_index, 0, 0 ) >= 0 )
|
||||||
|
{
|
||||||
|
status = FMV_LOOPED;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status = FMV_EOF;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -683,6 +708,13 @@ int idCinematicLocal::AnimationLength()
|
||||||
return animationLength;
|
return animationLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RB begin
|
||||||
|
bool idCinematicLocal::IsPlaying() const
|
||||||
|
{
|
||||||
|
return ( status == FMV_PLAY );
|
||||||
|
}
|
||||||
|
// RB end
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==============
|
==============
|
||||||
idCinematicLocal::ResetTime
|
idCinematicLocal::ResetTime
|
||||||
|
@ -840,6 +872,12 @@ cinData_t idCinematicLocal::ImageForTimeFFMPEG( int thisTime )
|
||||||
return cinData;
|
return cinData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( !fmt_ctx )
|
||||||
|
{
|
||||||
|
// RB: .bik requested but not found
|
||||||
|
return cinData;
|
||||||
|
}
|
||||||
|
|
||||||
if( ( !hasFrame ) || startTime == -1 )
|
if( ( !hasFrame ) || startTime == -1 )
|
||||||
{
|
{
|
||||||
if( startTime == -1 )
|
if( startTime == -1 )
|
||||||
|
@ -849,10 +887,18 @@ cinData_t idCinematicLocal::ImageForTimeFFMPEG( int thisTime )
|
||||||
startTime = thisTime;
|
startTime = thisTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
long DesiredFrame = ( ( thisTime - startTime ) * frameRate ) / 1000;
|
long desiredFrame = ( ( thisTime - startTime ) * frameRate ) / 1000;
|
||||||
if( DesiredFrame < 0 ) DesiredFrame = 0;
|
if( desiredFrame < 0 )
|
||||||
if( DesiredFrame < FramePos ) FFMPEGReset();
|
{
|
||||||
if( hasFrame && DesiredFrame == FramePos )
|
desiredFrame = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( desiredFrame < framePos )
|
||||||
|
{
|
||||||
|
FFMPEGReset();
|
||||||
|
}
|
||||||
|
|
||||||
|
if( hasFrame && desiredFrame == framePos )
|
||||||
{
|
{
|
||||||
cinData.imageWidth = CIN_WIDTH;
|
cinData.imageWidth = CIN_WIDTH;
|
||||||
cinData.imageHeight = CIN_HEIGHT;
|
cinData.imageHeight = CIN_HEIGHT;
|
||||||
|
@ -862,22 +908,23 @@ cinData_t idCinematicLocal::ImageForTimeFFMPEG( int thisTime )
|
||||||
}
|
}
|
||||||
|
|
||||||
AVPacket packet;
|
AVPacket packet;
|
||||||
while( FramePos < DesiredFrame )
|
while( framePos < desiredFrame )
|
||||||
{
|
{
|
||||||
int frameFinished = 0;
|
int frameFinished = 0;
|
||||||
//Do a single frame by getting packets until we have a full frame
|
|
||||||
|
// Do a single frame by getting packets until we have a full frame
|
||||||
while( !frameFinished )
|
while( !frameFinished )
|
||||||
{
|
{
|
||||||
//if we got to the end or failed
|
// if we got to the end or failed
|
||||||
if( av_read_frame( fmt_ctx, &packet ) < 0 )
|
if( av_read_frame( fmt_ctx, &packet ) < 0 )
|
||||||
{
|
{
|
||||||
//can't read any more, set to EOF
|
// can't read any more, set to EOF
|
||||||
status = FMV_EOF;
|
status = FMV_EOF;
|
||||||
if( looping )
|
if( looping )
|
||||||
{
|
{
|
||||||
DesiredFrame = 0;
|
desiredFrame = 0;
|
||||||
FFMPEGReset();
|
FFMPEGReset();
|
||||||
FramePos = -1;
|
framePos = -1;
|
||||||
startTime = thisTime;
|
startTime = thisTime;
|
||||||
if( av_read_frame( fmt_ctx, &packet ) < 0 )
|
if( av_read_frame( fmt_ctx, &packet ) < 0 )
|
||||||
{
|
{
|
||||||
|
@ -901,8 +948,10 @@ cinData_t idCinematicLocal::ImageForTimeFFMPEG( int thisTime )
|
||||||
// Free the packet that was allocated by av_read_frame
|
// Free the packet that was allocated by av_read_frame
|
||||||
av_free_packet( &packet );
|
av_free_packet( &packet );
|
||||||
}
|
}
|
||||||
FramePos++;
|
|
||||||
|
framePos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have reached the desired frame
|
// We have reached the desired frame
|
||||||
// Convert the image from its native format to RGB
|
// Convert the image from its native format to RGB
|
||||||
sws_scale( img_convert_ctx, frame->data, frame->linesize, 0, dec_ctx->height, frame2->data, frame2->linesize );
|
sws_scale( img_convert_ctx, frame->data, frame->linesize, 0, dec_ctx->height, frame2->data, frame2->linesize );
|
||||||
|
@ -912,6 +961,7 @@ cinData_t idCinematicLocal::ImageForTimeFFMPEG( int thisTime )
|
||||||
img->UploadScratch( image, CIN_WIDTH, CIN_HEIGHT );
|
img->UploadScratch( image, CIN_WIDTH, CIN_HEIGHT );
|
||||||
hasFrame = true;
|
hasFrame = true;
|
||||||
cinData.image = img;
|
cinData.image = img;
|
||||||
|
|
||||||
return cinData;
|
return cinData;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -89,6 +89,10 @@ public:
|
||||||
// returns the length of the animation in milliseconds
|
// returns the length of the animation in milliseconds
|
||||||
virtual int AnimationLength();
|
virtual int AnimationLength();
|
||||||
|
|
||||||
|
// RB: let us know wether this video went EOF or is still active
|
||||||
|
virtual bool IsPlaying() const;
|
||||||
|
// RB end
|
||||||
|
|
||||||
// the pointers in cinData_t will remain valid until the next UpdateForTime() call
|
// the pointers in cinData_t will remain valid until the next UpdateForTime() call
|
||||||
virtual cinData_t ImageForTime( int milliseconds );
|
virtual cinData_t ImageForTime( int milliseconds );
|
||||||
|
|
||||||
|
|
|
@ -3157,6 +3157,18 @@ int idMaterial::GetCinematicStartTime() const
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RB: added because we can't rely on the FFmpeg feedback how long a video really is
|
||||||
|
bool idMaterial::CinematicIsPlaying() const
|
||||||
|
{
|
||||||
|
if( !stages || !stages[0].texture.cinematic )
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return stages[0].texture.cinematic->IsPlaying();
|
||||||
|
}
|
||||||
|
// RB end
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==================
|
==================
|
||||||
idMaterial::CheckForConstantRegisters
|
idMaterial::CheckForConstantRegisters
|
||||||
|
|
|
@ -739,6 +739,10 @@ public:
|
||||||
|
|
||||||
void UpdateCinematic( int time ) const;
|
void UpdateCinematic( int time ) const;
|
||||||
|
|
||||||
|
// RB: added because we can't rely on the FFmpeg feedback how long a video really is
|
||||||
|
bool CinematicIsPlaying() const;
|
||||||
|
// RB end
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
// gets an image for the editor to use
|
// gets an image for the editor to use
|
||||||
|
|
|
@ -295,7 +295,7 @@ static void R_CheckPortableExtensions()
|
||||||
}
|
}
|
||||||
|
|
||||||
// RB: Mesa support
|
// RB: Mesa support
|
||||||
if( idStr::Icmpn( glConfig.renderer_string, "Mesa", 4 ) == 0 || idStr::Icmpn( glConfig.renderer_string, "X.org", 4 ) == 0 )
|
if( idStr::Icmpn( glConfig.renderer_string, "Mesa", 4 ) == 0 || idStr::Icmpn( glConfig.renderer_string, "X.org", 5 ) == 0 )
|
||||||
{
|
{
|
||||||
glConfig.driverType = GLDRV_OPENGL_MESA;
|
glConfig.driverType = GLDRV_OPENGL_MESA;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue