Ticket #8948: mpeg2-removal.patch

File mpeg2-removal.patch, 17.0 KB (added by bluegr, 15 years ago)

Patch by eriktorbjorn

  • engines/sword1/sword1.cpp

     
    476476        // make the demo flag depend on the Gamesettings for now, and not on what the datafiles look like
    477477        _systemVars.isDemo = (_features & GF_DEMO) != 0;
    478478        _systemVars.cutscenePackVersion = 0;
    479 #ifdef USE_MPEG2
     479#ifdef USE_ZLIB
    480480        if (Common::File::exists("intro.snd")) {
    481481                _systemVars.cutscenePackVersion = 1;
    482482        }
  • engines/sword1/animation.h

     
    134134
    135135#endif
    136136
    137 #ifdef USE_MPEG2
    138 
    139 class AnimationState : public Graphics::BaseAnimationState {
    140 private:
    141         MoviePlayer *_player;
    142         Screen *_screen;
    143 
    144 public:
    145         AnimationState(MoviePlayer *player, Screen *screen, OSystem *system);
    146         ~AnimationState(void);
    147         OverlayColor *giveRgbBuffer(void);
    148 
    149 private:
    150         void drawYUV(int width, int height, byte *const *dat);
    151 
    152 #ifdef BACKEND_8BIT
    153         void setPalette(byte *pal);
    154 #endif
    155 
    156 protected:
    157         virtual Audio::AudioStream *createAudioStream(const char *name, void *arg);
    158 };
    159 
    160 class MoviePlayerMPEG : public MoviePlayer {
    161 public:
    162         MoviePlayerMPEG(SwordEngine *vm, Screen *screen, Text *textMan, Audio::Mixer *snd, OSystem *system);
    163         virtual ~MoviePlayerMPEG(void);
    164         bool load(uint32 id);
    165 protected:
    166         void insertOverlay(OverlayColor *buf, uint8 *ovl, OverlayColor *pal);
    167         AnimationState *_anim;
    168         OverlayColor *_introPal;
    169         uint8 *_logoOvls[INTRO_LOGO_OVLS];
    170 
    171         bool initOverlays(uint32 id);
    172         bool decodeFrame(void);
    173         void processFrame(void);
    174         void updateScreen(void);
    175         void handleScreenChanged(void);
    176 };
    177 
    178 #endif
    179 
    180137struct FileQueue {
    181138        Audio::AudioStream *stream;
    182139        FileQueue *next;
  • engines/sword1/screen.h

     
    9696        void fnFlash(uint8 color);
    9797        void fnBorder(uint8 color);
    9898
    99 #ifdef BACKEND_8BIT
    100         void plotYUV(byte *lut, int width, int height, byte *const *dat);
    101 #endif
    102 
    10399private:
    104100        // for router debugging
    105101        void drawLine(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
  • engines/sword1/screen.cpp

     
    3636#include "sword1/menu.h"
    3737#include "sword1/sword1.h"
    3838
    39 #ifdef BACKEND_8BIT
    40 #include "sword1/animation.h"
    41 #endif
    42 
    4339namespace Sword1 {
    4440
    4541#define SCROLL_FRACTION 16
     
    968964        }
    969965}
    970966
    971 #ifdef BACKEND_8BIT
    972 void Screen::plotYUV(byte *lut, int width, int height, byte *const *dat) {
    973 
    974         byte * buf = (uint8*)malloc(width * height);
    975 
    976         int x, y;
    977 
    978         int ypos = 0;
    979         int cpos = 0;
    980         int linepos = 0;
    981 
    982         for (y = 0; y < height; y += 2) {
    983                 for (x = 0; x < width; x += 2) {
    984                         int i = ((((dat[2][cpos] + ROUNDADD) >> SHIFT) * (BITDEPTH+1)) + ((dat[1][cpos] + ROUNDADD)>>SHIFT)) * (BITDEPTH+1);
    985                         cpos++;
    986 
    987                         buf[linepos          ] = lut[i + ((dat[0][        ypos  ] + ROUNDADD) >> SHIFT)];
    988                         buf[width + linepos++] = lut[i + ((dat[0][width + ypos++] + ROUNDADD) >> SHIFT)];
    989                         buf[linepos          ] = lut[i + ((dat[0][        ypos  ] + ROUNDADD) >> SHIFT)];
    990                         buf[width + linepos++] = lut[i + ((dat[0][width + ypos++] + ROUNDADD) >> SHIFT)];
    991                 }
    992                 linepos += (2 * width - width);
    993                 ypos += width;
    994         }
    995 
    996         _system->copyRectToScreen(buf, width, (640-width)/2, (480-height)/2, width, height);
    997         _system->updateScreen();
    998 
    999         free(buf);
    1000 
    1001 }
    1002 #endif
    1003 
    1004 
    1005 
    1006967} // End of namespace Sword1
  • engines/sword1/animation.cpp

     
    3636#include "common/str.h"
    3737#include "common/events.h"
    3838#include "common/system.h"
     39#include "gui/message.h"
    3940#include "graphics/surface.h"
    4041
    4142namespace Sword1 {
     
    480481
    481482#endif
    482483
    483 #ifdef USE_MPEG2
    484 
    485484///////////////////////////////////////////////////////////////////////////////
    486 // Movie player for the old MPEG movies
    487 ///////////////////////////////////////////////////////////////////////////////
    488 
    489 MoviePlayerMPEG::MoviePlayerMPEG(SwordEngine *vm, Screen *screen, Text *textMan, Audio::Mixer *snd, OSystem *system)
    490         : MoviePlayer(vm, screen, textMan, snd, system) {
    491 #ifdef BACKEND_8BIT
    492         debug(0, "Creating MPEG cutscene player (8-bit)");
    493 #else
    494         debug(0, "Creating MPEG cutscene player (16-bit)");
    495 #endif
    496         for (uint8 cnt = 0; cnt < INTRO_LOGO_OVLS; cnt++)
    497                 _logoOvls[cnt] = NULL;
    498         _introPal = NULL;
    499         _anim = NULL;
    500 }
    501 
    502 MoviePlayerMPEG::~MoviePlayerMPEG(void) {
    503         free(_introPal);
    504         for (uint8 cnt = 0; cnt < INTRO_LOGO_OVLS; cnt++)
    505                 free(_logoOvls[cnt]);
    506         delete _anim;
    507 }
    508 
    509 void MoviePlayerMPEG::handleScreenChanged(void) {
    510         _anim->handleScreenChanged();
    511 }
    512 
    513 void MoviePlayerMPEG::insertOverlay(OverlayColor *buf, uint8 *ovl, OverlayColor *pal) {
    514         if (ovl != NULL)
    515                 for (uint32 cnt = 0; cnt < 640 * 400; cnt++)
    516                         if (ovl[cnt])
    517                                 buf[cnt] = pal[ovl[cnt]];
    518 }
    519 
    520 bool MoviePlayerMPEG::load(uint32 id) {
    521         if (MoviePlayer::load(id)) {
    522                 _anim = new AnimationState(this, _screen, _system);
    523                 return _anim->init(sequenceList[id]);
    524         }
    525         return false;
    526 }
    527 
    528 bool MoviePlayerMPEG::initOverlays(uint32 id) {
    529         if (id == SEQ_INTRO) {
    530                 ArcFile ovlFile;
    531                 if (!ovlFile.open("intro.dat")) {
    532                         warning("\"intro.dat\" not found");
    533                         return false;
    534                 }
    535                 ovlFile.enterPath(SwordEngine::_systemVars.language);
    536                 for (uint8 fcnt = 0; fcnt < 12; fcnt++) {
    537                         _logoOvls[fcnt] = ovlFile.decompressFile(fcnt);
    538                         if (fcnt > 0)
    539                                 for (uint32 cnt = 0; cnt < 640 * 400; cnt++)
    540                                         if (_logoOvls[fcnt - 1][cnt] && !_logoOvls[fcnt][cnt])
    541                                                 _logoOvls[fcnt][cnt] = _logoOvls[fcnt - 1][cnt];
    542                 }
    543                 uint8 *pal = ovlFile.fetchFile(12);
    544                 _introPal = (OverlayColor *)malloc(256 * sizeof(OverlayColor));
    545                 Graphics::PixelFormat format = _system->getOverlayFormat();
    546                 for (uint16 cnt = 0; cnt < 256; cnt++)
    547                         _introPal[cnt] = Graphics::RGBToColor(pal[cnt * 3 + 0], pal[cnt * 3 + 1], pal[cnt * 3 + 2], format);
    548         }
    549 
    550         return true;
    551 }
    552 
    553 bool MoviePlayerMPEG::decodeFrame(void) {
    554         return _anim->decodeFrame();
    555 }
    556 
    557 void MoviePlayerMPEG::updateScreen(void) {
    558         _anim->updateScreen();
    559 }
    560 
    561 void MoviePlayerMPEG::processFrame(void) {
    562 #ifndef BACKEND_8BIT
    563         if ((_id != 4) || (SwordEngine::_systemVars.cutscenePackVersion == 0))
    564                 return;
    565         OverlayColor *buf = _anim->giveRgbBuffer();
    566         if ((_currentFrame > 397) && (_currentFrame < 444)) { // Broken Sword Logo
    567                 if (_currentFrame <= 403)
    568                         insertOverlay(buf, _logoOvls[_currentFrame - 398], _introPal); // fade up
    569                 else if (_currentFrame <= 437)
    570                         insertOverlay(buf, _logoOvls[(_currentFrame - 404) % 6 + 6], _introPal); // animation
    571                 else {
    572                         insertOverlay(buf, _logoOvls[5 - (_currentFrame - 438)], _introPal); // fade down
    573                 }
    574         }
    575 #endif
    576 }
    577 
    578 AnimationState::AnimationState(MoviePlayer *player, Screen *screen, OSystem *system)
    579         : BaseAnimationState(system, 640, 400), _player(player), _screen(screen) {
    580 }
    581 
    582 AnimationState::~AnimationState(void) {
    583 }
    584 
    585 #ifdef BACKEND_8BIT
    586 void AnimationState::setPalette(byte *pal) {
    587         _player->updatePalette(pal, false);
    588 }
    589 #endif
    590 
    591 void AnimationState::drawYUV(int width, int height, byte *const *dat) {
    592         _frameWidth = width;
    593         _frameHeight = height;
    594 
    595 #ifdef BACKEND_8BIT
    596         _screen->plotYUV(_lut, width, height, dat);
    597 #else
    598         plotYUV(width, height, dat);
    599 #endif
    600 }
    601 
    602 OverlayColor *AnimationState::giveRgbBuffer(void) {
    603 #ifdef BACKEND_8BIT
    604         return NULL;
    605 #else
    606         return _overlay;
    607 #endif
    608 }
    609 
    610 Audio::AudioStream *AnimationState::createAudioStream(const char *name, void *arg) {
    611         if (arg)
    612                 return (Audio::AudioStream*)arg;
    613         else
    614                 return Audio::AudioStream::openStreamFile(name);
    615 }
    616 
    617 #endif
    618 
    619 ///////////////////////////////////////////////////////////////////////////////
    620485// Factory function for creating the appropriate cutscene player
    621486///////////////////////////////////////////////////////////////////////////////
    622487
    623488MoviePlayer *makeMoviePlayer(uint32 id, SwordEngine *vm, Screen *screen, Text *textMan, Audio::Mixer *snd, OSystem *system) {
    624 #if defined(USE_ZLIB) || defined(USE_MPEG2)
    625489        char filename[20];
    626 #endif
    627490
    628491#ifdef USE_ZLIB
    629492        snprintf(filename, sizeof(filename), "%s.dxa", sequenceList[id]);
     
    633496        }
    634497#endif
    635498
    636 #ifdef USE_MPEG2
    637499        snprintf(filename, sizeof(filename), "%s.mp2", sequenceList[id]);
    638500
    639501        if (Common::File::exists(filename)) {
    640                 return new MoviePlayerMPEG(vm, screen, textMan, snd, system);
     502                GUI::MessageDialog dialog(
     503                        "MPEG cutscenes are no longer supported by ScummVM. Please use the\n"
     504                        "DXA cutscenes available from www.scummvm.org instead.", "Ok");
     505                dialog.runModal();
    641506        }
    642 #endif
    643507
    644508        return NULL;
    645509}
  • engines/sword2/animation.h

     
    148148        bool load();
    149149};
    150150
    151 #ifdef USE_MPEG2
    152 class AnimationState : public ::Graphics::BaseAnimationState {
    153 private:
    154         Sword2Engine *_vm;
    155         MoviePlayer *_player;
    156 
    157 public:
    158         AnimationState(Sword2Engine *vm, MoviePlayer *player);
    159         ~AnimationState();
    160 
    161 #ifndef BACKEND_8BIT
    162         void drawTextObject(SpriteInfo *s, byte *src);
    163 #endif
    164 
    165         void clearFrame();
    166 
    167 private:
    168         void drawYUV(int width, int height, byte *const *dat);
    169 
    170 #ifdef BACKEND_8BIT
    171         void setPalette(byte *pal);
    172 #endif
    173 };
    174 
    175 class MoviePlayerMPEG : public MoviePlayer {
    176 protected:
    177         AnimationState *_anim;
    178 
    179         virtual bool decodeFrame();
    180 
    181 #ifndef BACKEND_8BIT
    182         void handleScreenChanged();
    183         void clearFrame();
    184         void drawFrame();
    185         void updateScreen();
    186         void drawTextObject();
    187         void undrawTextObject();
    188 #endif
    189 
    190 public:
    191         MoviePlayerMPEG(Sword2Engine *vm, const char *name);
    192         ~MoviePlayerMPEG();
    193 
    194         bool load();
    195 };
    196 #endif
    197 
    198151#ifdef USE_ZLIB
    199152class MoviePlayerDXA : public MoviePlayer, ::Graphics::DXAPlayer {
    200153protected:
  • engines/sword2/animation.cpp

     
    3131#include "common/events.h"
    3232#include "common/system.h"
    3333
     34#include "gui/message.h"
     35
    3436#include "sword2/sword2.h"
    3537#include "sword2/defs.h"
    3638#include "sword2/header.h"
     
    566568
    567569#endif
    568570
    569 #ifdef USE_MPEG2
    570 
    571571///////////////////////////////////////////////////////////////////////////////
    572 // Movie player for the old MPEG movies
    573 ///////////////////////////////////////////////////////////////////////////////
    574 
    575 MoviePlayerMPEG::MoviePlayerMPEG(Sword2Engine *vm, const char *name)
    576         : MoviePlayer(vm, name) {
    577 #ifdef BACKEND_8BIT
    578         debug(0, "Creating MPEG cutscene player (8-bit)");
    579 #else
    580         debug(0, "Creating MPEG cutscene player (16-bit)");
    581 #endif
    582 }
    583 
    584 MoviePlayerMPEG::~MoviePlayerMPEG() {
    585         delete _anim;
    586         _anim = NULL;
    587 }
    588 
    589 bool MoviePlayerMPEG::load() {
    590         if (!MoviePlayer::load())
    591                 return false;
    592 
    593         _anim = new AnimationState(_vm, this);
    594 
    595         if (!_anim->init(_name)) {
    596                 delete _anim;
    597                 _anim = NULL;
    598                 return false;
    599         }
    600 
    601 #ifdef BACKEND_8BIT
    602         _frameBuffer = _vm->_screen->getScreen();
    603 #endif
    604 
    605         return true;
    606 }
    607 
    608 bool MoviePlayerMPEG::decodeFrame() {
    609         bool result = _anim->decodeFrame();
    610 
    611 #ifdef BACKEND_8BIT
    612         _frameWidth = _anim->getFrameWidth();
    613         _frameHeight = _anim->getFrameHeight();
    614 
    615         _frameX = (_vm->_screen->getScreenWide() - _frameWidth) / 2;
    616         _frameY = (_vm->_screen->getScreenDeep() - _frameHeight) / 2;
    617 #endif
    618 
    619         return result;
    620 }
    621 
    622 AnimationState::AnimationState(Sword2Engine *vm, MoviePlayer *player)
    623         : BaseAnimationState(vm->_system, 640, 480) {
    624         _vm = vm;
    625         _player = player;
    626 }
    627 
    628 AnimationState::~AnimationState() {
    629 }
    630 
    631 #ifdef BACKEND_8BIT
    632 
    633 void AnimationState::setPalette(byte *pal) {
    634         _player->updatePalette(pal, false);
    635 }
    636 
    637 #else
    638 
    639 void MoviePlayerMPEG::handleScreenChanged() {
    640         _anim->handleScreenChanged();
    641 }
    642 
    643 void MoviePlayerMPEG::clearFrame() {
    644         _anim->clearFrame();
    645 }
    646 
    647 void MoviePlayerMPEG::drawFrame() {
    648 }
    649 
    650 void MoviePlayerMPEG::updateScreen() {
    651         _anim->updateScreen();
    652 }
    653 
    654 void MoviePlayerMPEG::drawTextObject() {
    655         if (_textObject.textMem && _textSurface) {
    656                 _anim->drawTextObject(&_textObject.textSprite, _textSurface);
    657         }
    658 }
    659 
    660 void MoviePlayerMPEG::undrawTextObject() {
    661         // As long as we only have subtitles for full-sized cutscenes, we don't
    662         // really need to implement this function.
    663 }
    664 
    665 void AnimationState::drawTextObject(SpriteInfo *s, byte *src) {
    666         int moviePitch = _movieScale * _movieWidth;
    667         int textX = _movieScale * s->x;
    668         int textY = _movieScale * (_frameHeight - s->h - 12);
    669 
    670         OverlayColor *dst = _overlay + textY * moviePitch + textX;
    671 
    672         Graphics::PixelFormat format = _sys->getOverlayFormat();
    673         OverlayColor pen = Graphics::RGBToColor(255, 255, 255, format);
    674         OverlayColor border = Graphics::RGBToColor(0, 0, 0, format);
    675 
    676         // TODO: Use the AdvMame scalers for the text? Pre-scale it?
    677 
    678         for (int y = 0; y < s->h; y++) {
    679                 OverlayColor *ptr = dst;
    680 
    681                 for (int x = 0; x < s->w; x++) {
    682                         switch (src[x]) {
    683                         case 1:
    684                                 *ptr++ = border;
    685                                 if (_movieScale > 1) {
    686                                         *ptr++ = border;
    687                                         if (_movieScale > 2)
    688                                                 *ptr++ = border;
    689                                 }
    690                                 break;
    691                         case 255:
    692                                 *ptr++ = pen;
    693                                 if (_movieScale > 1) {
    694                                         *ptr++ = pen;
    695                                         if (_movieScale > 2)
    696                                                 *ptr++ = pen;
    697                                 }
    698                                 break;
    699                         default:
    700                                 ptr += _movieScale;
    701                                 break;
    702                         }
    703                 }
    704 
    705                 if (_movieScale > 1) {
    706                         memcpy(dst + moviePitch, dst, _movieScale * s->w * sizeof(OverlayColor));
    707                         if (_movieScale > 2)
    708                                 memcpy(dst + 2 * moviePitch, dst, _movieScale * s->w * sizeof(OverlayColor));
    709                 }
    710 
    711                 dst += _movieScale * moviePitch;
    712                 src += s->w;
    713         }
    714 }
    715 #endif
    716 
    717 void AnimationState::clearFrame() {
    718 #ifdef BACKEND_8BIT
    719         memset(_vm->_screen->getScreen(), 0, _movieWidth * _movieHeight);
    720 #else
    721         Graphics::PixelFormat format = _sys->getOverlayFormat();
    722         OverlayColor black = Graphics::RGBToColor(0, 0, 0, format);
    723 
    724         for (int i = 0; i < _movieScale * _movieWidth * _movieScale * _movieHeight; i++)
    725                 _overlay[i] = black;
    726 #endif
    727 }
    728 
    729 void AnimationState::drawYUV(int width, int height, byte *const *dat) {
    730         _frameWidth = width;
    731         _frameHeight = height;
    732 
    733 #ifdef BACKEND_8BIT
    734         byte *buf = _vm->_screen->getScreen() + ((480 - height) / 2) * RENDERWIDE + (640 - width) / 2;
    735 
    736         int x, y;
    737 
    738         int ypos = 0;
    739         int cpos = 0;
    740         int linepos = 0;
    741 
    742         for (y = 0; y < height; y += 2) {
    743                 for (x = 0; x < width; x += 2) {
    744                         int i = ((((dat[2][cpos] + ROUNDADD) >> SHIFT) * (BITDEPTH + 1)) + ((dat[1][cpos] + ROUNDADD) >> SHIFT)) * (BITDEPTH + 1);
    745                         cpos++;
    746 
    747                         buf[linepos               ] = _lut[i + ((dat[0][        ypos  ] + ROUNDADD) >> SHIFT)];
    748                         buf[RENDERWIDE + linepos++] = _lut[i + ((dat[0][width + ypos++] + ROUNDADD) >> SHIFT)];
    749                         buf[linepos               ] = _lut[i + ((dat[0][        ypos  ] + ROUNDADD) >> SHIFT)];
    750                         buf[RENDERWIDE + linepos++] = _lut[i + ((dat[0][width + ypos++] + ROUNDADD) >> SHIFT)];
    751                 }
    752                 linepos += (2 * RENDERWIDE - width);
    753                 ypos += width;
    754         }
    755 #else
    756         plotYUV(width, height, dat);
    757 #endif
    758 }
    759 
    760 #endif
    761 
    762 ///////////////////////////////////////////////////////////////////////////////
    763572// Dummy player for subtitled speech only
    764573///////////////////////////////////////////////////////////////////////////////
    765574
     
    802611
    803612                byte msgNoCutscenesRU[] = "Po\344uk - to\344\345ko pev\345: hagmute k\344abuwy Ucke\343n, u\344u nocetute ca\343t npoekta u ckava\343te budeo po\344uku";
    804613
    805 #if defined(USE_MPEG2) || defined(USE_ZLIB)
     614#if defined(USE_ZLIB)
    806615                byte msgNoCutscenes[] = "Cutscene - Narration Only: Press ESC to exit, or visit www.scummvm.org to download cutscene videos";
    807616#else
    808                 byte msgNoCutscenes[] = "Cutscene - Narration Only: Press ESC to exit, or recompile ScummVM with MPEG2 or ZLib support";
     617                byte msgNoCutscenes[] = "Cutscene - Narration Only: Press ESC to exit, or recompile ScummVM with ZLib support";
    809618#endif
    810619
    811620                byte *msg;
     
    893702        }
    894703#endif
    895704
    896 #ifdef USE_MPEG2
    897705        snprintf(filename, sizeof(filename), "%s.mp2", name);
    898706
    899707        if (Common::File::exists(filename)) {
    900                 return new MoviePlayerMPEG(vm, name);
     708                GUI::MessageDialog dialog(
     709                        "MPEG cutscenes are no longer supported by ScummVM. Please use the\n"
     710                        "DXA cutscenes available from www.scummvm.org instead.", "Ok");
     711                dialog.runModal();
    901712        }
    902 #endif
    903713
    904714        return new MoviePlayerDummy(vm, name);
    905715}