Fixed crashes in cinematic code

This commit is contained in:
RobertBeckebans 2014-04-06 12:15:27 +02:00
parent 899982b0b2
commit 647a3ebad8
2 changed files with 14 additions and 8 deletions

View file

@ -1188,6 +1188,8 @@ if(MSVC)
endif() endif()
if(FFMPEG) if(FFMPEG)
add_definitions(-DUSE_FFMPEG)
if(CMAKE_CL_64) if(CMAKE_CL_64)
include_directories(libs/ffmpeg-win64/include) include_directories(libs/ffmpeg-win64/include)
include_directories(libs/ffmpeg-win64/include/libswscale) include_directories(libs/ffmpeg-win64/include/libswscale)
@ -1322,7 +1324,9 @@ else()
if(UNIX) if(UNIX)
if(FFMPEG) if(FFMPEG)
find_package(FFMPEG) find_package(FFMPEG REQUIRED)
add_definitions(-DUSE_FFMPEG)
include_directories(${FFMPEG_INCLUDE_DIR}) include_directories(${FFMPEG_INCLUDE_DIR})
link_directories(${FFMPEG_LIBRARIES_DIRS}) link_directories(${FFMPEG_LIBRARIES_DIRS})
endif() endif()

View file

@ -375,7 +375,7 @@ idCinematicLocal::idCinematicLocal()
#if defined(USE_FFMPEG) #if defined(USE_FFMPEG)
// Carl: ffmpeg stuff, for bink and normal video files: // Carl: ffmpeg stuff, for bink and normal video files:
isRoQ = false; isRoQ = false;
fmt_ctx = avformat_alloc_context(); // fmt_ctx = avformat_alloc_context();
frame = avcodec_alloc_frame(); frame = avcodec_alloc_frame();
frame2 = avcodec_alloc_frame(); frame2 = avcodec_alloc_frame();
dec_ctx = NULL; dec_ctx = NULL;
@ -462,11 +462,6 @@ bool idCinematicLocal::InitFromFFMPEGFile( const char* qpath, bool amilooping )
CIN_WIDTH = DEFAULT_CIN_WIDTH; CIN_WIDTH = DEFAULT_CIN_WIDTH;
idStr fullpath = fileSystem->RelativePathToOSPath( qpath, "fs_basepath" ); idStr fullpath = fileSystem->RelativePathToOSPath( qpath, "fs_basepath" );
if( !fmt_ctx )
{
return false;
}
if( ( ret = avformat_open_input( &fmt_ctx, fullpath, NULL, NULL ) ) < 0 ) if( ( ret = avformat_open_input( &fmt_ctx, fullpath, NULL, NULL ) ) < 0 )
{ {
common->Warning( "idCinematic: Cannot open FFMPEG video file: '%s', %d\n", qpath, looping ); common->Warning( "idCinematic: Cannot open FFMPEG video file: '%s', %d\n", qpath, looping );
@ -561,7 +556,7 @@ bool idCinematicLocal::InitFromFile( const char* qpath, bool amilooping )
Close(); Close();
inMemory = 0; inMemory = 0;
animationLength = 15000; //Carl: We can't tell how long an RoQ file is, so say it's 15 seconds animationLength = 100000;
// Carl: if no folder is specified, look in the video folder // Carl: if no folder is specified, look in the video folder
if( strstr( qpath, "/" ) == NULL && strstr( qpath, "\\" ) == NULL ) if( strstr( qpath, "/" ) == NULL && strstr( qpath, "\\" ) == NULL )
@ -596,6 +591,7 @@ bool idCinematicLocal::InitFromFile( const char* qpath, bool amilooping )
idLib::Warning( "New filename: '%s'\n", fileName.c_str() ); idLib::Warning( "New filename: '%s'\n", fileName.c_str() );
return InitFromFFMPEGFile( fileName.c_str(), amilooping ); return InitFromFFMPEGFile( fileName.c_str(), amilooping );
#else #else
animationLength = 0;
return false; return false;
#endif #endif
} }
@ -722,6 +718,12 @@ cinData_t idCinematicLocal::ImageForTime( int thisTime )
return cinData; return cinData;
} }
if( !iFile )
{
// RB: neither .bik or .roq found
return cinData;
}
if( status == FMV_EOF || status == FMV_IDLE ) if( status == FMV_EOF || status == FMV_IDLE )
{ {
return cinData; return cinData;