aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorFilippos Karapetis2009-05-19 17:39:03 +0000
committerFilippos Karapetis2009-05-19 17:39:03 +0000
commit4f6bc506153550a16efd02a10b0b377cce54c434 (patch)
tree554e2cac57bbe3a418419e2a68fa49e2d7e51ed6 /graphics
parent5d942f9d70d7f0da01fe3f8fefe18db67eb7e09e (diff)
downloadscummvm-rg350-4f6bc506153550a16efd02a10b0b377cce54c434.tar.gz
scummvm-rg350-4f6bc506153550a16efd02a10b0b377cce54c434.tar.bz2
scummvm-rg350-4f6bc506153550a16efd02a10b0b377cce54c434.zip
Some fixes to the video decoders, thanks to salty-horse's comments
svn-id: r40729
Diffstat (limited to 'graphics')
-rw-r--r--graphics/video/flic_player.cpp27
-rw-r--r--graphics/video/flic_player.h3
-rw-r--r--graphics/video/smk_player.h1
-rw-r--r--graphics/video/video_player.h19
4 files changed, 34 insertions, 16 deletions
diff --git a/graphics/video/flic_player.cpp b/graphics/video/flic_player.cpp
index e59466aeed..024aab0f43 100644
--- a/graphics/video/flic_player.cpp
+++ b/graphics/video/flic_player.cpp
@@ -72,8 +72,9 @@ bool FlicDecoder::loadFile(const char *fileName) {
}
_fileStream->readUint16LE(); // flags
// Note: The normal delay is a 32-bit integer (dword), whereas the overriden delay is a 16-bit integer (word)
- _videoInfo.frameDelay = _fileStream->readUint32LE() * 1000; // "speed", in milliseconds
- _videoInfo.frameRate = 1000 / _videoInfo.frameDelay;
+ // frameDelay is the FLIC "speed", in milliseconds. Our frameDelay is calculated in 1/100 ms, so we convert it here
+ _videoInfo.frameDelay = _fileStream->readUint32LE() / 100;
+ _videoInfo.frameRate = 100 * 1000 / _videoInfo.frameDelay;
_fileStream->seek(80);
_offsetFrame1 = _fileStream->readUint32LE();
@@ -206,10 +207,10 @@ bool FlicDecoder::decodeNextFrame() {
case FRAME_TYPE: {
chunkCount = _fileStream->readUint16LE();
// Note: The overriden delay is a 16-bit integer (word), whereas the normal delay is a 32-bit integer (dword)
- uint16 newFrameDelay = _fileStream->readUint16LE() * 1000; // "speed", in milliseconds
+ uint16 newFrameDelay = _fileStream->readUint16LE() / 100; // "speed", in milliseconds
if (newFrameDelay > 0) {
_videoInfo.frameDelay = newFrameDelay;
- _videoInfo.frameRate = 1000 / _videoInfo.frameDelay;
+ _videoInfo.frameRate = 100 * 1000 / _videoInfo.frameDelay;
}
_fileStream->readUint16LE(); // reserved, always 0
uint16 newWidth = _fileStream->readUint16LE();
@@ -272,27 +273,27 @@ void FlicDecoder::reset() {
_fileStream->seek(_offsetFrame1);
}
-void FlicDecoder::unpackPalette(uint8 *mem) {
- uint16 numPackets = READ_LE_UINT16(mem); mem += 2;
+void FlicDecoder::unpackPalette(uint8 *data) {
+ uint16 numPackets = READ_LE_UINT16(data); data += 2;
- if (0 == READ_LE_UINT16(mem)) { //special case
- mem += 2;
+ if (0 == READ_LE_UINT16(data)) { //special case
+ data += 2;
for (int i = 0; i < 256; ++i) {
- memcpy(_palette + i * 3, mem + i * 3, 3);
+ memcpy(_palette + i * 3, data + i * 3, 3);
}
} else {
uint8 palPos = 0;
while (numPackets--) {
- palPos += *mem++;
- uint8 change = *mem++;
+ palPos += *data++;
+ uint8 change = *data++;
for (int i = 0; i < change; ++i) {
- memcpy(_palette + (palPos + i) * 3, mem + i * 3, 3);
+ memcpy(_palette + (palPos + i) * 3, data + i * 3, 3);
}
palPos += change;
- mem += (change * 3);
+ data += (change * 3);
}
}
}
diff --git a/graphics/video/flic_player.h b/graphics/video/flic_player.h
index 4912c02884..68bf3fb688 100644
--- a/graphics/video/flic_player.h
+++ b/graphics/video/flic_player.h
@@ -66,8 +66,7 @@ public:
void clearDirtyRects() { _dirtyRects.clear(); }
void copyDirtyRectsToBuffer(uint8 *dst, uint pitch);
- byte getPixel(int offset) { return _videoFrameBuffer[offset]; }
- byte* getPalette() { _paletteChanged = false; return _palette; }
+ const byte *getPalette() { _paletteChanged = false; return _palette; }
bool paletteChanged() { return _paletteChanged; }
void reset();
diff --git a/graphics/video/smk_player.h b/graphics/video/smk_player.h
index 553575ade3..e70d0e6454 100644
--- a/graphics/video/smk_player.h
+++ b/graphics/video/smk_player.h
@@ -110,6 +110,7 @@ private:
// (bit 0) is set, it denotes a frame that contains a palette record
byte *_frameTypes;
byte *_frameData;
+ // The RGB palette
byte *_palette;
Audio::Mixer *_mixer;
diff --git a/graphics/video/video_player.h b/graphics/video/video_player.h
index 6a49448c56..da7f93d0c8 100644
--- a/graphics/video/video_player.h
+++ b/graphics/video/video_player.h
@@ -117,6 +117,23 @@ public:
virtual void setPalette(byte *pal);
/**
+ * Gets the value of the pixel at the specified x and y coordinates
+ * Note: This method assumes that the video's pitch equals its width, and that
+ * the video has an 8bpp palette
+ * @param x the x coordinate of the pixel
+ * @param y the y coordinate of the pixel
+ */
+ byte getPixel(int x, int y) {
+ return *(_videoFrameBuffer + y * _videoInfo.width + x * 1);
+ }
+
+ /**
+ * Gets the value of the pixel at the specified offset
+ * @param offset the offset of the pixel in the video buffer
+ */
+ byte getPixel(int offset) { return getPixel(offset, 0); }
+
+ /**
* Return the black palette color for the current frame
*/
byte getBlack() { return _curFrameBlack; }
@@ -153,7 +170,7 @@ protected:
uint32 height;
uint32 frameCount;
int32 frameRate;
- int32 frameDelay;
+ int32 frameDelay; // 1/100 ms
uint32 frameOffs;
uint32 currentFrame;
uint32 startTime;