From 2a20ce75c3ca2f8e6f4a02e571e373f19a8ec115 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 22 Nov 2016 19:25:23 -0500 Subject: TITANIC: Defer creating movie frame surfaces until renderFrame --- engines/titanic/support/avi_surface.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'engines/titanic') diff --git a/engines/titanic/support/avi_surface.cpp b/engines/titanic/support/avi_surface.cpp index 79614d2c40..17a6fcf68f 100644 --- a/engines/titanic/support/avi_surface.cpp +++ b/engines/titanic/support/avi_surface.cpp @@ -227,13 +227,11 @@ void AVISurface::setupDecompressor() { return; for (int idx = 0; idx < _streamCount; ++idx) { - // Setup frame surface - _movieFrameSurface[idx] = new Graphics::ManagedSurface(_decoder->getWidth(), _decoder->getHeight(), - _decoder->getVideoTrack(idx).getPixelFormat()); - + Graphics::PixelFormat format = _decoder->getVideoTrack(idx).getPixelFormat(); + int decoderPitch = _decoder->getWidth() * format.bytesPerPixel; bool flag = false; - if (idx == 0 && _videoSurface && - _videoSurface->getPitch() == _movieFrameSurface[idx]->pitch) { + + if (idx == 0 && _videoSurface && _videoSurface->getPitch() == decoderPitch) { const uint bitCount = _decoder->getVideoTrack(0).getBitCount(); const int vDepth = _videoSurface->getPixelDepth(); @@ -314,6 +312,12 @@ bool AVISurface::renderFrame() { const Graphics::Surface *frame = (idx == 0) ? _decoder->decodeNextFrame() : _decoder->decodeNextTransparency(); + if (!_movieFrameSurface[idx]) { + // Setup frame surface + _movieFrameSurface[idx] = new Graphics::ManagedSurface(_decoder->getWidth(), _decoder->getHeight(), + _decoder->getVideoTrack(idx).getPixelFormat()); + } + if (_movieFrameSurface[idx]->format == frame->format) { _movieFrameSurface[idx]->blitFrom(*frame); } else { -- cgit v1.2.3