Ticket #8948: mpeg2-removal.patch
File mpeg2-removal.patch, 17.0 KB (added by , 16 years ago) |
---|
-
engines/sword1/sword1.cpp
476 476 // make the demo flag depend on the Gamesettings for now, and not on what the datafiles look like 477 477 _systemVars.isDemo = (_features & GF_DEMO) != 0; 478 478 _systemVars.cutscenePackVersion = 0; 479 #ifdef USE_ MPEG2479 #ifdef USE_ZLIB 480 480 if (Common::File::exists("intro.snd")) { 481 481 _systemVars.cutscenePackVersion = 1; 482 482 } -
engines/sword1/animation.h
134 134 135 135 #endif 136 136 137 #ifdef USE_MPEG2138 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_8BIT153 void setPalette(byte *pal);154 #endif155 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 #endif179 180 137 struct FileQueue { 181 138 Audio::AudioStream *stream; 182 139 FileQueue *next; -
engines/sword1/screen.h
96 96 void fnFlash(uint8 color); 97 97 void fnBorder(uint8 color); 98 98 99 #ifdef BACKEND_8BIT100 void plotYUV(byte *lut, int width, int height, byte *const *dat);101 #endif102 103 99 private: 104 100 // for router debugging 105 101 void drawLine(uint16 x1, uint16 y1, uint16 x2, uint16 y2); -
engines/sword1/screen.cpp
36 36 #include "sword1/menu.h" 37 37 #include "sword1/sword1.h" 38 38 39 #ifdef BACKEND_8BIT40 #include "sword1/animation.h"41 #endif42 43 39 namespace Sword1 { 44 40 45 41 #define SCROLL_FRACTION 16 … … 968 964 } 969 965 } 970 966 971 #ifdef BACKEND_8BIT972 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 #endif1003 1004 1005 1006 967 } // End of namespace Sword1 -
engines/sword1/animation.cpp
36 36 #include "common/str.h" 37 37 #include "common/events.h" 38 38 #include "common/system.h" 39 #include "gui/message.h" 39 40 #include "graphics/surface.h" 40 41 41 42 namespace Sword1 { … … 480 481 481 482 #endif 482 483 483 #ifdef USE_MPEG2484 485 484 /////////////////////////////////////////////////////////////////////////////// 486 // Movie player for the old MPEG movies487 ///////////////////////////////////////////////////////////////////////////////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_8BIT492 debug(0, "Creating MPEG cutscene player (8-bit)");493 #else494 debug(0, "Creating MPEG cutscene player (16-bit)");495 #endif496 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_8BIT563 if ((_id != 4) || (SwordEngine::_systemVars.cutscenePackVersion == 0))564 return;565 OverlayColor *buf = _anim->giveRgbBuffer();566 if ((_currentFrame > 397) && (_currentFrame < 444)) { // Broken Sword Logo567 if (_currentFrame <= 403)568 insertOverlay(buf, _logoOvls[_currentFrame - 398], _introPal); // fade up569 else if (_currentFrame <= 437)570 insertOverlay(buf, _logoOvls[(_currentFrame - 404) % 6 + 6], _introPal); // animation571 else {572 insertOverlay(buf, _logoOvls[5 - (_currentFrame - 438)], _introPal); // fade down573 }574 }575 #endif576 }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_8BIT586 void AnimationState::setPalette(byte *pal) {587 _player->updatePalette(pal, false);588 }589 #endif590 591 void AnimationState::drawYUV(int width, int height, byte *const *dat) {592 _frameWidth = width;593 _frameHeight = height;594 595 #ifdef BACKEND_8BIT596 _screen->plotYUV(_lut, width, height, dat);597 #else598 plotYUV(width, height, dat);599 #endif600 }601 602 OverlayColor *AnimationState::giveRgbBuffer(void) {603 #ifdef BACKEND_8BIT604 return NULL;605 #else606 return _overlay;607 #endif608 }609 610 Audio::AudioStream *AnimationState::createAudioStream(const char *name, void *arg) {611 if (arg)612 return (Audio::AudioStream*)arg;613 else614 return Audio::AudioStream::openStreamFile(name);615 }616 617 #endif618 619 ///////////////////////////////////////////////////////////////////////////////620 485 // Factory function for creating the appropriate cutscene player 621 486 /////////////////////////////////////////////////////////////////////////////// 622 487 623 488 MoviePlayer *makeMoviePlayer(uint32 id, SwordEngine *vm, Screen *screen, Text *textMan, Audio::Mixer *snd, OSystem *system) { 624 #if defined(USE_ZLIB) || defined(USE_MPEG2)625 489 char filename[20]; 626 #endif627 490 628 491 #ifdef USE_ZLIB 629 492 snprintf(filename, sizeof(filename), "%s.dxa", sequenceList[id]); … … 633 496 } 634 497 #endif 635 498 636 #ifdef USE_MPEG2637 499 snprintf(filename, sizeof(filename), "%s.mp2", sequenceList[id]); 638 500 639 501 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(); 641 506 } 642 #endif643 507 644 508 return NULL; 645 509 } -
engines/sword2/animation.h
148 148 bool load(); 149 149 }; 150 150 151 #ifdef USE_MPEG2152 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_8BIT162 void drawTextObject(SpriteInfo *s, byte *src);163 #endif164 165 void clearFrame();166 167 private:168 void drawYUV(int width, int height, byte *const *dat);169 170 #ifdef BACKEND_8BIT171 void setPalette(byte *pal);172 #endif173 };174 175 class MoviePlayerMPEG : public MoviePlayer {176 protected:177 AnimationState *_anim;178 179 virtual bool decodeFrame();180 181 #ifndef BACKEND_8BIT182 void handleScreenChanged();183 void clearFrame();184 void drawFrame();185 void updateScreen();186 void drawTextObject();187 void undrawTextObject();188 #endif189 190 public:191 MoviePlayerMPEG(Sword2Engine *vm, const char *name);192 ~MoviePlayerMPEG();193 194 bool load();195 };196 #endif197 198 151 #ifdef USE_ZLIB 199 152 class MoviePlayerDXA : public MoviePlayer, ::Graphics::DXAPlayer { 200 153 protected: -
engines/sword2/animation.cpp
31 31 #include "common/events.h" 32 32 #include "common/system.h" 33 33 34 #include "gui/message.h" 35 34 36 #include "sword2/sword2.h" 35 37 #include "sword2/defs.h" 36 38 #include "sword2/header.h" … … 566 568 567 569 #endif 568 570 569 #ifdef USE_MPEG2570 571 571 /////////////////////////////////////////////////////////////////////////////// 572 // Movie player for the old MPEG movies573 ///////////////////////////////////////////////////////////////////////////////574 575 MoviePlayerMPEG::MoviePlayerMPEG(Sword2Engine *vm, const char *name)576 : MoviePlayer(vm, name) {577 #ifdef BACKEND_8BIT578 debug(0, "Creating MPEG cutscene player (8-bit)");579 #else580 debug(0, "Creating MPEG cutscene player (16-bit)");581 #endif582 }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_8BIT602 _frameBuffer = _vm->_screen->getScreen();603 #endif604 605 return true;606 }607 608 bool MoviePlayerMPEG::decodeFrame() {609 bool result = _anim->decodeFrame();610 611 #ifdef BACKEND_8BIT612 _frameWidth = _anim->getFrameWidth();613 _frameHeight = _anim->getFrameHeight();614 615 _frameX = (_vm->_screen->getScreenWide() - _frameWidth) / 2;616 _frameY = (_vm->_screen->getScreenDeep() - _frameHeight) / 2;617 #endif618 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_8BIT632 633 void AnimationState::setPalette(byte *pal) {634 _player->updatePalette(pal, false);635 }636 637 #else638 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't662 // 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 #endif716 717 void AnimationState::clearFrame() {718 #ifdef BACKEND_8BIT719 memset(_vm->_screen->getScreen(), 0, _movieWidth * _movieHeight);720 #else721 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 #endif727 }728 729 void AnimationState::drawYUV(int width, int height, byte *const *dat) {730 _frameWidth = width;731 _frameHeight = height;732 733 #ifdef BACKEND_8BIT734 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 #else756 plotYUV(width, height, dat);757 #endif758 }759 760 #endif761 762 ///////////////////////////////////////////////////////////////////////////////763 572 // Dummy player for subtitled speech only 764 573 /////////////////////////////////////////////////////////////////////////////// 765 574 … … 802 611 803 612 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"; 804 613 805 #if defined(USE_ MPEG2) || defined(USE_ZLIB)614 #if defined(USE_ZLIB) 806 615 byte msgNoCutscenes[] = "Cutscene - Narration Only: Press ESC to exit, or visit www.scummvm.org to download cutscene videos"; 807 616 #else 808 byte msgNoCutscenes[] = "Cutscene - Narration Only: Press ESC to exit, or recompile ScummVM with MPEG2 orZLib support";617 byte msgNoCutscenes[] = "Cutscene - Narration Only: Press ESC to exit, or recompile ScummVM with ZLib support"; 809 618 #endif 810 619 811 620 byte *msg; … … 893 702 } 894 703 #endif 895 704 896 #ifdef USE_MPEG2897 705 snprintf(filename, sizeof(filename), "%s.mp2", name); 898 706 899 707 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(); 901 712 } 902 #endif903 713 904 714 return new MoviePlayerDummy(vm, name); 905 715 }