From d5cb146f4ce9a0378da443f4bbc20d9f02ad6568 Mon Sep 17 00:00:00 2001 From: Sylvain Dupont Date: Fri, 21 Jan 2011 20:26:25 +0000 Subject: [PATCH] TOON: Fix all the glitches in smacker video playback Handle manually 2x scaling when it is needed now. svn-id: r55393 --- engines/toon/movie.cpp | 26 ++++++++++++++++++++------ engines/toon/movie.h | 4 +++- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/engines/toon/movie.cpp b/engines/toon/movie.cpp index 34769f028aa..8607f807fba 100644 --- a/engines/toon/movie.cpp +++ b/engines/toon/movie.cpp @@ -33,8 +33,7 @@ void ToonstruckSmackerDecoder::handleAudioTrack(byte track, uint32 chunkSize, ui if (track == 1 && chunkSize == 4) { /* uint16 width = */ _fileStream->readUint16LE(); uint16 height = _fileStream->readUint16LE(); - - _header.flags = (height == getHeight() / 2) ? 4 : 0; + _lowRes = (height == getHeight() / 2); } else Graphics::SmackerDecoder::handleAudioTrack(track, chunkSize, unpackedSize); } @@ -44,21 +43,25 @@ bool ToonstruckSmackerDecoder::loadFile(const Common::String &filename, int forc if (Graphics::SmackerDecoder::loadFile(filename)) { if (forcedflags & 0x10 || _surface->h == 200) { - - _header.flags = 4; if (_surface) { _surface->free(); delete _surface; } _surface = new Graphics::Surface(); _surface->create(640, 400, 1); + _lowRes = false; + _header.flags = 4; } + return true; } + + return false; } ToonstruckSmackerDecoder::ToonstruckSmackerDecoder(Audio::Mixer *mixer, Audio::Mixer::SoundType soundType) : Graphics::SmackerDecoder(mixer, soundType) { + _lowRes = false; } // decoder is deallocated with Movie destruction i.e. new ToonstruckSmackerDecoder is needed @@ -98,8 +101,19 @@ bool Movie::playVideo() { while (!_vm->shouldQuit() && !_decoder->endOfVideo()) { if (_decoder->needsUpdate()) { const Graphics::Surface *frame = _decoder->decodeNextFrame(); - if (frame) - _vm->getSystem()->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h); + if (frame) { + if (_decoder->isLowRes()) { + // handle manually 2x scaling here + Graphics::Surface* surf = _vm->getSystem()->lockScreen(); + for (int y = 0; y < frame->h/2; y++) { + memcpy(surf->getBasePtr(0, y*2+0), frame->getBasePtr(0, y), frame->pitch); + memcpy(surf->getBasePtr(0, y*2+1), frame->getBasePtr(0, y), frame->pitch); + } + _vm->getSystem()->unlockScreen(); + } else { + _vm->getSystem()->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h); + } + } _decoder->setSystemPalette(); _vm->getSystem()->updateScreen(); } diff --git a/engines/toon/movie.h b/engines/toon/movie.h index e89abb56c09..9abbcdf66fc 100644 --- a/engines/toon/movie.h +++ b/engines/toon/movie.h @@ -37,6 +37,9 @@ public: virtual ~ToonstruckSmackerDecoder() {} void handleAudioTrack(byte track, uint32 chunkSize, uint32 unpackedSize); bool loadFile(const Common::String &filename, int forcedflags) ; + bool isLowRes() { return _lowRes; } +protected: + bool _lowRes; }; class Movie { @@ -54,7 +57,6 @@ protected: Audio::Mixer *_mixer; ToonstruckSmackerDecoder *_decoder; bool _playing; - }; } // End of namespace Toon