From 0b4dd7c4593587355c1965eb0d266040c83f0382 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 11 Jan 2009 03:34:50 +0000 Subject: Committed a modified version of wjp's patch for the video player: - Split the video player from the video decoders. It's now possible to have one video player for multiple decoders - Added the palette weight calculation from the BS1 engine into VideoPlayer::setPalette. It's now possible to find the values of the white and black colors via getWhite() and getBlack() (useful for subtitle overlays) - Adapted FTA2's movie playing code to the new changes to video player - Fixed a slight bug in the DXA decoder (_videoinfo.startTime was not initialized) svn-id: r35816 --- graphics/video/video_player.h | 68 ++++++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 23 deletions(-) (limited to 'graphics/video/video_player.h') diff --git a/graphics/video/video_player.h b/graphics/video/video_player.h index 4a44349552..a32996df75 100644 --- a/graphics/video/video_player.h +++ b/graphics/video/video_player.h @@ -39,10 +39,10 @@ namespace Graphics { /** * Implementation of a generic video decoder */ -class VideoPlayer { +class VideoDecoder { public: - VideoPlayer(); - virtual ~VideoPlayer(); + VideoDecoder(); + virtual ~VideoDecoder(); /** * Returns the width of the video @@ -98,12 +98,12 @@ public: * Load a video file * @param filename the filename to load */ - virtual bool loadFile(const char *filename); + virtual bool loadFile(const char *filename) = 0; /** * Close a video file */ - virtual void closeFile(); + virtual void closeFile()=0; /** * Returns if a video file is loaded or not @@ -116,6 +116,16 @@ public: */ virtual void setPalette(byte *pal); + /** + * Return the black palette color for the current frame + */ + byte getBlack() { return _black; } + + /** + * Return the white palette color for the current frame + */ + byte getWhite() { return _white; } + /** * Copy current frame into the specified position of the destination * buffer. @@ -127,24 +137,9 @@ public: void copyFrameToBuffer(byte *dst, uint x, uint y, uint pitch); /** - * Decode the next frame - */ - virtual bool decodeNextFrame(); - - /** - * A default implementation of a video player - * Plays a non-interactive full screen video till it's stopped by a - * specific event - * @param filename the name of the file to play - * @param stopEvents a list of events that can stop the video + * Decode the next frame to _videoFrameBuffer */ - bool playVideo(const char *filename, Common::List *stopEvents); - - /** - * Perform postprocessing once the frame data is copied to the screen, - * right before the frame is drawn. Called from playVideo() - */ - virtual void performPostProcessing(byte *screen); + virtual bool decodeNextFrame() = 0; protected: struct { @@ -157,11 +152,38 @@ protected: uint32 startTime; } _videoInfo; + byte _black, _white; + Common::SeekableReadStream *_fileStream; byte *_videoFrameBuffer; +}; + +class VideoPlayer { +public: + VideoPlayer(VideoDecoder* decoder) : _skipVideo(false), _decoder(decoder) + { } + ~VideoPlayer() { } + /** + * A default implementation of a video player + * Plays a non-interactive full screen video till it's stopped by a + * specific event + * @param filename the name of the file to play + * @param stopEvents a list of events that can stop the video + * + * Returns true if the video was played to the end, false if skipped + */ + bool playVideo(Common::List *stopEvents); + +protected: + /** + * Perform postprocessing once the frame data is copied to the screen, + * right before the frame is drawn. Called by playVideo() + */ + virtual void performPostProcessing(byte *screen); + bool _skipVideo; + VideoDecoder* _decoder; -private: void processVideoEvents(Common::List *stopEvents); }; -- cgit v1.2.3