HACK: Add support for playing Theora-videos from the SmushPlayer, when playback of SMUSH-fails, this should perhaps result in a new class for handling codecs dynamically (so that we can resolve both the Aspyr-logo and Theora/Smush-juggling in a consistent way). Also hack the scaling for 1080p-videos for now.

This commit is contained in:
Einar Johan Trøan Sømåen 2015-02-01 16:06:15 +01:00
parent be69f3141f
commit 1e5f5d6947
3 changed files with 66 additions and 12 deletions

View file

@ -1630,6 +1630,14 @@ void GfxOpenGL::prepareMovieFrame(Graphics::Surface *frame) {
int width = frame->w; int width = frame->w;
byte *bitmap = (byte *)frame->getPixels(); byte *bitmap = (byte *)frame->getPixels();
double scaleW = _scaleW;
double scaleH = _scaleH;
// Remastered hack, don't scale full-screen videos for now.
if (height == 1080) {
_scaleW = 1.0f;
_scaleH = 1.0f;
}
GLenum format; GLenum format;
GLenum dataType; GLenum dataType;
int bytesPerPixel = frame->format.bytesPerPixel; int bytesPerPixel = frame->format.bytesPerPixel;
@ -1692,9 +1700,18 @@ void GfxOpenGL::prepareMovieFrame(Graphics::Surface *frame) {
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
_smushWidth = (int)(width * _scaleW); _smushWidth = (int)(width * _scaleW);
_smushHeight = (int)(height * _scaleH); _smushHeight = (int)(height * _scaleH);
_scaleW = scaleW;
_scaleH = scaleH;
} }
void GfxOpenGL::drawMovieFrame(int offsetX, int offsetY) { void GfxOpenGL::drawMovieFrame(int offsetX, int offsetY) {
double scaleW = _scaleW;
double scaleH = _scaleH;
// Remastered hack, don't scale full-screen videos for now.
if (_smushHeight == 1080) {
_scaleW = 1.0f;
_scaleH = 1.0f;
}
// prepare view // prepare view
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
@ -1741,6 +1758,9 @@ void GfxOpenGL::drawMovieFrame(int offsetX, int offsetY) {
glDepthMask(GL_TRUE); glDepthMask(GL_TRUE);
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);
_scaleW = scaleW;
_scaleH = scaleH;
} }
void GfxOpenGL::releaseMovieFrame() { void GfxOpenGL::releaseMovieFrame() {

View file

@ -23,6 +23,8 @@
#include "engines/grim/movie/codecs/smush_decoder.h" #include "engines/grim/movie/codecs/smush_decoder.h"
#include "engines/grim/movie/smush.h" #include "engines/grim/movie/smush.h"
#include "video/theora_decoder.h"
#include "engines/grim/resource.h" #include "engines/grim/resource.h"
#include "engines/grim/grim.h" #include "engines/grim/grim.h"
@ -32,25 +34,49 @@ MoviePlayer *CreateSmushPlayer(bool demo) {
return new SmushPlayer(demo); return new SmushPlayer(demo);
} }
SmushPlayer::~SmushPlayer() {
delete _theoraDecoder;
}
SmushPlayer::SmushPlayer(bool demo) : MoviePlayer(), _demo(demo) { SmushPlayer::SmushPlayer(bool demo) : MoviePlayer(), _demo(demo) {
_smushDecoder = new SmushDecoder(); _smushDecoder = new SmushDecoder();
_videoDecoder = _smushDecoder; _videoDecoder = _smushDecoder;
_theoraDecoder = new Video::TheoraDecoder();
//_smushDecoder->setDemo(_demo); //_smushDecoder->setDemo(_demo);
} }
bool SmushPlayer::loadFile(const Common::String &filename) { bool SmushPlayer::loadFile(const Common::String &filename) {
warning("Play video %s\n", filename.c_str());
bool success = false;
_videoDecoder = _smushDecoder;
if (!_demo) if (!_demo)
return _videoDecoder->loadStream(g_resourceloader->openNewStreamFile(filename.c_str())); success = _videoDecoder->loadStream(g_resourceloader->openNewStreamFile(filename.c_str()));
else else
return _videoDecoder->loadFile(filename); success = _videoDecoder->loadFile(filename);
if (!success) {
Common::String theoraFilename = "MoviesHD/" + filename;
theoraFilename.erase(theoraFilename.size() - 4);
theoraFilename += ".ogv";
warning("Trying to open %s", theoraFilename.c_str());
success = _theoraDecoder->loadFile(theoraFilename);
_videoDecoder = _theoraDecoder;
_currentVideoIsTheora = true;
} else {
_videoDecoder = _smushDecoder;
_currentVideoIsTheora = false;
}
return success;
} }
void SmushPlayer::init() { void SmushPlayer::init() {
if (_demo) { if (!_currentVideoIsTheora) {
_x = _smushDecoder->getX(); if (_demo) {
_y = _smushDecoder->getY(); _x = _smushDecoder->getX();
} else { _y = _smushDecoder->getY();
_smushDecoder->setLooping(_videoLooping); } else {
_smushDecoder->setLooping(_videoLooping);
}
} }
MoviePlayer::init(); MoviePlayer::init();
} }
@ -65,21 +91,23 @@ void SmushPlayer::handleFrame() {
deinit(); deinit();
return; return;
} else { } else {
_smushDecoder->rewind(); // This doesnt handle if looping fails. if (!_currentVideoIsTheora) {
_smushDecoder->start(); _smushDecoder->rewind(); // This doesnt handle if looping fails.
_smushDecoder->start();
}
} }
} }
} }
void SmushPlayer::postHandleFrame() { void SmushPlayer::postHandleFrame() {
if (_demo) { if (_demo && !_currentVideoIsTheora) {
_x = _smushDecoder->getX(); _x = _smushDecoder->getX();
_y = _smushDecoder->getY(); _y = _smushDecoder->getY();
} }
} }
void SmushPlayer::restore(SaveGame *state) { void SmushPlayer::restore(SaveGame *state) {
if (isPlaying()) { if (isPlaying() && !_currentVideoIsTheora) {
_smushDecoder->seek((uint32)_movieTime); _smushDecoder->seek((uint32)_movieTime);
_smushDecoder->start(); _smushDecoder->start();
timerCallback(this); timerCallback(this);

View file

@ -25,6 +25,10 @@
#include "engines/grim/movie/movie.h" #include "engines/grim/movie/movie.h"
namespace Video {
class TheoraDecoder;
}
namespace Grim { namespace Grim {
class SmushDecoder; class SmushDecoder;
@ -32,7 +36,7 @@ class SmushDecoder;
class SmushPlayer : public MoviePlayer { class SmushPlayer : public MoviePlayer {
public: public:
SmushPlayer(bool demo); SmushPlayer(bool demo);
virtual ~SmushPlayer();
void restore(SaveGame *state) override; void restore(SaveGame *state) override;
private: private:
@ -41,7 +45,9 @@ private:
void postHandleFrame() override; void postHandleFrame() override;
void init() override; void init() override;
bool _demo; bool _demo;
bool _currentVideoIsTheora;
SmushDecoder *_smushDecoder; SmushDecoder *_smushDecoder;
Video::TheoraDecoder *_theoraDecoder; // HACK for now, move to other class later?
}; };
} // end of namespace Grim } // end of namespace Grim