aboutsummaryrefslogtreecommitdiff
path: root/video
diff options
context:
space:
mode:
authorMatthew Hoops2013-06-23 19:35:47 -0400
committerMatthew Hoops2015-04-11 14:36:18 -0400
commitf6d7c5e176a08c32702cdfb80ec8a626c25ead67 (patch)
tree20bb5ebab9f80174b3a11610573b3d761c86f759 /video
parentec03857d7dd7614675b41cfc412be20b733b469a (diff)
downloadscummvm-rg350-f6d7c5e176a08c32702cdfb80ec8a626c25ead67.tar.gz
scummvm-rg350-f6d7c5e176a08c32702cdfb80ec8a626c25ead67.tar.bz2
scummvm-rg350-f6d7c5e176a08c32702cdfb80ec8a626c25ead67.zip
IMAGE: Add functions to allow for videos to be dithered
Diffstat (limited to 'video')
-rw-r--r--video/video_decoder.cpp20
-rw-r--r--video/video_decoder.h32
2 files changed, 52 insertions, 0 deletions
diff --git a/video/video_decoder.cpp b/video/video_decoder.cpp
index a4bc5b81a2..217b4c8456 100644
--- a/video/video_decoder.cpp
+++ b/video/video_decoder.cpp
@@ -47,6 +47,7 @@ VideoDecoder::VideoDecoder() {
_endTimeSet = false;
_nextVideoTrack = 0;
_mainAudioTrack = 0;
+ _canSetDither = true;
// Find the best format for output
_defaultHighColorFormat = g_system->getScreenFormat();
@@ -77,6 +78,7 @@ void VideoDecoder::close() {
_endTimeSet = false;
_nextVideoTrack = 0;
_mainAudioTrack = 0;
+ _canSetDither = true;
}
bool VideoDecoder::loadFile(const Common::String &filename) {
@@ -171,6 +173,7 @@ Graphics::PixelFormat VideoDecoder::getPixelFormat() const {
const Graphics::Surface *VideoDecoder::decodeNextFrame() {
_needsUpdate = false;
+ _canSetDither = false;
readNextPacket();
@@ -488,6 +491,23 @@ bool VideoDecoder::seekIntern(const Audio::Timestamp &time) {
return true;
}
+bool VideoDecoder::setDitheringPalette(const byte *palette) {
+ // If a frame was already decoded, we can't set it now.
+ if (!_canSetDither)
+ return false;
+
+ bool result = false;
+
+ for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++) {
+ if ((*it)->getTrackType() == Track::kTrackTypeVideo && ((VideoTrack *)*it)->canDither()) {
+ ((VideoTrack *)*it)->setDither(palette);
+ result = true;
+ }
+ }
+
+ return result;
+}
+
VideoDecoder::Track::Track() {
_paused = false;
}
diff --git a/video/video_decoder.h b/video/video_decoder.h
index c3879e9144..eca15e7265 100644
--- a/video/video_decoder.h
+++ b/video/video_decoder.h
@@ -377,6 +377,25 @@ public:
*/
bool setReverse(bool reverse);
+ /**
+ * Tell the video to dither to a palette.
+ *
+ * By default, VideoDecoder will return surfaces in native, or in the case
+ * of YUV-based videos, the format set by setDefaultHighColorFormat().
+ * For video formats or codecs that support it, this will start outputting
+ * its surfaces in 8bpp with this palette.
+ *
+ * This should be called after loadStream(), but before a decodeNextFrame()
+ * call. This is enforced.
+ *
+ * The palette will be copied, so you do not need to worry about the pointer
+ * going out-of-scope.
+ *
+ * @param palette The palette to use for dithering
+ * @return true on success, false otherwise
+ */
+ bool setDitheringPalette(const byte *palette);
+
/////////////////////////////////////////
// Audio Control
/////////////////////////////////////////
@@ -604,6 +623,16 @@ protected:
* Is the video track set to play in reverse?
*/
virtual bool isReversed() const { return false; }
+
+ /**
+ * Can the video track dither?
+ */
+ virtual bool canDither() const { return false; }
+
+ /**
+ * Activate dithering mode with a palette
+ */
+ virtual void setDither(const byte *palette) {}
};
/**
@@ -901,6 +930,9 @@ private:
mutable bool _dirtyPalette;
const byte *_palette;
+ // Enforcement of not being able to set dither
+ bool _canSetDither;
+
// Default PixelFormat settings
Graphics::PixelFormat _defaultHighColorFormat;