aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm/smush
diff options
context:
space:
mode:
authorGregory Montoir2007-01-30 22:44:14 +0000
committerGregory Montoir2007-01-30 22:44:14 +0000
commit9abaa064a07bfb44ea3663e026cce874c77d449e (patch)
tree510a29a939ba31bbdab07993f72a3516e7dac39e /engines/scumm/smush
parent3766e0a77df3839c1622b254390e665c009d4b74 (diff)
downloadscummvm-rg350-9abaa064a07bfb44ea3663e026cce874c77d449e.tar.gz
scummvm-rg350-9abaa064a07bfb44ea3663e026cce874c77d449e.tar.bz2
scummvm-rg350-9abaa064a07bfb44ea3663e026cce874c77d449e.zip
got rid of codec37/codec47 init/deinit methods, cleanup
svn-id: r25295
Diffstat (limited to 'engines/scumm/smush')
-rw-r--r--engines/scumm/smush/codec37.cpp22
-rw-r--r--engines/scumm/smush/codec37.h4
-rw-r--r--engines/scumm/smush/codec47.cpp15
-rw-r--r--engines/scumm/smush/codec47.h4
-rw-r--r--engines/scumm/smush/smush_player.cpp36
-rw-r--r--engines/scumm/smush/smush_player.h10
6 files changed, 27 insertions, 64 deletions
diff --git a/engines/scumm/smush/codec37.cpp b/engines/scumm/smush/codec37.cpp
index 0078237c30..fadb7d115a 100644
--- a/engines/scumm/smush/codec37.cpp
+++ b/engines/scumm/smush/codec37.cpp
@@ -28,8 +28,7 @@
namespace Scumm {
-void Codec37Decoder::init(int width, int height) {
- deinit();
+Codec37Decoder::Codec37Decoder(int width, int height) {
_width = width;
_height = height;
_frameSize = _width * _height;
@@ -40,26 +39,15 @@ void Codec37Decoder::init(int width, int height) {
_deltaBufs[0] = _deltaBuf + 0x4D80;
_deltaBufs[1] = _deltaBuf + 0xE880 + _frameSize;
_offsetTable = new int16[255];
- _curtable = 0;
if (_offsetTable == 0)
error("unable to allocate decoder offset table");
- _tableLastPitch = -1;
- _tableLastIndex = -1;
-}
-
-Codec37Decoder::Codec37Decoder() {
- _deltaSize = 0;
- _deltaBuf = 0;
- _deltaBufs[0] = 0;
- _deltaBufs[1] = 0;
_curtable = 0;
- _offsetTable = 0;
+ _prevSeqNb = 0;
_tableLastPitch = -1;
_tableLastIndex = -1;
- _prevSeqNb = 0;
}
-void Codec37Decoder::deinit() {
+Codec37Decoder::~Codec37Decoder() {
if (_offsetTable) {
delete []_offsetTable;
_offsetTable = 0;
@@ -75,10 +63,6 @@ void Codec37Decoder::deinit() {
}
}
-Codec37Decoder::~Codec37Decoder() {
- deinit();
-}
-
void Codec37Decoder::maketable(int pitch, int index) {
static const int8 maketable_bytes[] = {
0, 0, 1, 0, 2, 0, 3, 0, 5, 0,
diff --git a/engines/scumm/smush/codec37.h b/engines/scumm/smush/codec37.h
index 534316c1e5..10b371143d 100644
--- a/engines/scumm/smush/codec37.h
+++ b/engines/scumm/smush/codec37.h
@@ -42,10 +42,8 @@ private:
int _width, _height;
public:
- Codec37Decoder();
+ Codec37Decoder(int width, int height);
~Codec37Decoder();
- void init(int width, int height);
- void deinit();
protected:
void maketable(int, int);
void proc1(byte *dst, const byte *src, int32, int, int, int, int16 *);
diff --git a/engines/scumm/smush/codec47.cpp b/engines/scumm/smush/codec47.cpp
index 443d17becb..c9b5ffa329 100644
--- a/engines/scumm/smush/codec47.cpp
+++ b/engines/scumm/smush/codec47.cpp
@@ -501,8 +501,7 @@ void Codec47Decoder::decode2(byte *dst, const byte *src, int width, int height,
} while (--bh);
}
-void Codec47Decoder::init(int width, int height) {
- deinit();
+Codec47Decoder::Codec47Decoder(int width, int height) {
_width = width;
_height = height;
_tableBig = (byte *)malloc(256 * 388);
@@ -518,13 +517,7 @@ void Codec47Decoder::init(int width, int height) {
_curBuf = _deltaBuf + _frameSize * 2;
}
-Codec47Decoder::Codec47Decoder() {
- _tableBig = NULL;
- _tableSmall = NULL;
- _deltaBuf = NULL;
-}
-
-void Codec47Decoder::deinit() {
+Codec47Decoder::~Codec47Decoder() {
if (_tableBig) {
free(_tableBig);
_tableBig = NULL;
@@ -543,10 +536,6 @@ void Codec47Decoder::deinit() {
}
}
-Codec47Decoder::~Codec47Decoder() {
- deinit();
-}
-
bool Codec47Decoder::decode(byte *dst, const byte *src) {
_offset1 = _deltaBufs[1] - _curBuf;
_offset2 = _deltaBufs[0] - _curBuf;
diff --git a/engines/scumm/smush/codec47.h b/engines/scumm/smush/codec47.h
index ea71c22963..017f518e7e 100644
--- a/engines/scumm/smush/codec47.h
+++ b/engines/scumm/smush/codec47.h
@@ -53,10 +53,8 @@ private:
void decode2(byte *dst, const byte *src, int width, int height, const byte *param_ptr);
public:
- Codec47Decoder();
+ Codec47Decoder(int width, int height);
~Codec47Decoder();
- void init(int width, int height);
- void deinit();
bool decode(byte *dst, const byte *src);
};
diff --git a/engines/scumm/smush/smush_player.cpp b/engines/scumm/smush/smush_player.cpp
index ce2f32d29b..5c89e758cc 100644
--- a/engines/scumm/smush/smush_player.cpp
+++ b/engines/scumm/smush/smush_player.cpp
@@ -40,6 +40,8 @@
#include "scumm/util.h"
#include "scumm/smush/channel.h"
#include "scumm/smush/chunk.h"
+#include "scumm/smush/codec37.h"
+#include "scumm/smush/codec47.h"
#include "scumm/smush/smush_font.h"
#include "scumm/smush/smush_mixer.h"
#include "scumm/smush/smush_player.h"
@@ -238,6 +240,8 @@ SmushPlayer::SmushPlayer(ScummEngine_v7 *scumm) {
_vm = scumm;
_version = -1;
_nbframes = 0;
+ _codec37 = 0;
+ _codec47 = 0;
_smixer = NULL;
_strings = NULL;
_sf[0] = NULL;
@@ -284,8 +288,6 @@ SmushPlayer::~SmushPlayer() {
void SmushPlayer::init(int32 speed) {
_frame = 0;
_speed = speed;
- _codec37AlreadyInit = false;
- _codec47AlreadyInit = false;
_endOfFile = false;
_vm->_smushVideoShouldFinish = false;
@@ -354,14 +356,10 @@ void SmushPlayer::release() {
_initDone = false;
- if (_codec37AlreadyInit) {
- _codec37.deinit();
- _codec37AlreadyInit = false;
- }
- if (_codec47AlreadyInit) {
- _codec47.deinit();
- _codec47AlreadyInit = false;
- }
+ delete _codec37;
+ _codec37 = 0;
+ delete _codec47;
+ _codec47 = 0;
}
void SmushPlayer::checkBlock(const Chunk &b, Chunk::type type_expected, uint32 min_size) {
@@ -798,18 +796,16 @@ void SmushPlayer::decodeFrameObject(int codec, const uint8 *src, int left, int t
smush_decode_codec1(_dst, src, left, top, width, height, _vm->_screenWidth);
break;
case 37:
- if (!_codec37AlreadyInit) {
- _codec37.init(width, height);
- _codec37AlreadyInit = true;
- }
- _codec37.decode(_dst, src);
+ if (!_codec37)
+ _codec37 = new Codec37Decoder(width, height);
+ if (_codec37)
+ _codec37->decode(_dst, src);
break;
case 47:
- if (!_codec47AlreadyInit) {
- _codec47.init(width, height);
- _codec47AlreadyInit = true;
- }
- _codec47.decode(_dst, src);
+ if (!_codec47)
+ _codec47 = new Codec47Decoder(width, height);
+ if (_codec47)
+ _codec47->decode(_dst, src);
break;
default:
error("Invalid codec for frame object : %d", codec);
diff --git a/engines/scumm/smush/smush_player.h b/engines/scumm/smush/smush_player.h
index 5d87714360..db7697a196 100644
--- a/engines/scumm/smush/smush_player.h
+++ b/engines/scumm/smush/smush_player.h
@@ -25,8 +25,6 @@
#include "common/util.h"
#include "scumm/smush/chunk.h"
-#include "scumm/smush/codec37.h"
-#include "scumm/smush/codec47.h"
#include "scumm/sound.h"
namespace Scumm {
@@ -35,6 +33,8 @@ class ScummEngine_v7;
class SmushFont;
class SmushMixer;
class StringResource;
+class Codec37Decoder;
+class Codec47Decoder;
class SmushPlayer {
friend class Insane;
@@ -46,10 +46,8 @@ private:
int16 _deltaPal[0x300];
byte _pal[0x300];
StringResource *_strings;
- Codec37Decoder _codec37;
- bool _codec37AlreadyInit;
- Codec47Decoder _codec47;
- bool _codec47AlreadyInit;
+ Codec37Decoder *_codec37;
+ Codec47Decoder *_codec47;
FileChunk *_base;
byte *_frameBuffer;
byte *_specialBuffer;