diff --git a/neo/renderer/Cinematic.cpp b/neo/renderer/Cinematic.cpp index e4242b14..c142b84f 100644 --- a/neo/renderer/Cinematic.cpp +++ b/neo/renderer/Cinematic.cpp @@ -790,7 +790,9 @@ bool idCinematicLocal::InitFromFFMPEGFile( const char* qpath, bool amilooping ) frameRate = av_q2d( fmt_ctx->streams[video_stream_index]->avg_frame_rate ); common->Printf( "Loaded FFMPEG file: '%s', looping=%d, %dx%d, %f FPS, %f sec\n", qpath, looping, CIN_WIDTH, CIN_HEIGHT, frameRate, durationSec ); - image = ( byte* )Mem_Alloc( CIN_WIDTH * CIN_HEIGHT * 4 * 2, TAG_CINEMATIC ); + // SRS - Get number of image bytes needed by querying with NULL first, then allocate image and fill with correct parameters + int img_bytes = av_image_fill_arrays( frame2->data, frame2->linesize, NULL, AV_PIX_FMT_BGR32, CIN_WIDTH, CIN_HEIGHT, 1 ); + image = ( byte* )Mem_Alloc( img_bytes, TAG_CINEMATIC ); av_image_fill_arrays( frame2->data, frame2->linesize, image, AV_PIX_FMT_BGR32, CIN_WIDTH, CIN_HEIGHT, 1 ); //GK: Straight out of the FFMPEG source code if( img_convert_ctx ) { @@ -1586,7 +1588,7 @@ cinData_t idCinematicLocal::ImageForTimeBinkDec( int thisTime ) if( audioTracks > 0 ) { - audioBuffer = ( int16_t* )malloc( binkInfo.idealBufferSize ); + audioBuffer = ( int16_t* )Mem_Alloc( binkInfo.idealBufferSize, TAG_AUDIO ); num_bytes = Bink_GetAudioData( binkHandle, trackIndex, audioBuffer ); // SRS - If we have cinematic audio data, start playing it now @@ -1598,7 +1600,7 @@ cinData_t idCinematicLocal::ImageForTimeBinkDec( int thisTime ) else { // SRS - Even though we have no audio data to play, still need to free the audio buffer - free( audioBuffer ); + Mem_Free( audioBuffer ); } } diff --git a/neo/sound/OpenAL/AL_CinematicAudio.cpp b/neo/sound/OpenAL/AL_CinematicAudio.cpp index 25f23133..5b45f870 100644 --- a/neo/sound/OpenAL/AL_CinematicAudio.cpp +++ b/neo/sound/OpenAL/AL_CinematicAudio.cpp @@ -129,7 +129,7 @@ void CinematicAudio_OpenAL::PlayAudio( uint8_t* data, int size ) #if defined(USE_FFMPEG) av_freep( &tempdata ); #elif defined(USE_BINKDEC) - free( tempdata ); + Mem_Free( tempdata ); #endif alSourceQueueBuffers( alMusicSourceVoicecin, 1, &bufid ); ALenum error = alGetError(); @@ -149,7 +149,7 @@ void CinematicAudio_OpenAL::PlayAudio( uint8_t* data, int size ) #if defined(USE_FFMPEG) av_freep( &data ); #elif defined(USE_BINKDEC) - free( data ); + Mem_Free( data ); #endif offset++; if( offset == NUM_BUFFERS ) @@ -221,7 +221,7 @@ void CinematicAudio_OpenAL::ShutdownAudio() #if defined(USE_FFMPEG) av_freep( &tempdata ); #elif defined(USE_BINKDEC) - free( tempdata ); + Mem_Free( tempdata ); #endif buffersize--; } diff --git a/neo/sound/XAudio2/XA2_CinematicAudio.cpp b/neo/sound/XAudio2/XA2_CinematicAudio.cpp index ac5f1090..f1af99d5 100644 --- a/neo/sound/XAudio2/XA2_CinematicAudio.cpp +++ b/neo/sound/XAudio2/XA2_CinematicAudio.cpp @@ -52,7 +52,7 @@ public: #if defined(USE_FFMPEG) av_freep( &data ); #elif defined(USE_BINKDEC) - free( data ); + Mem_Free( data ); #endif } //Unused methods are stubs