[Scummvm-cvs-logs] SF.net SVN: scummvm: [25295] scummvm/trunk/engines/scumm/smush

cyx at users.sourceforge.net cyx at users.sourceforge.net
Tue Jan 30 23:44:15 CET 2007


Revision: 25295
          http://scummvm.svn.sourceforge.net/scummvm/?rev=25295&view=rev
Author:   cyx
Date:     2007-01-30 14:44:14 -0800 (Tue, 30 Jan 2007)

Log Message:
-----------
got rid of codec37/codec47 init/deinit methods, cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/scumm/smush/codec37.cpp
    scummvm/trunk/engines/scumm/smush/codec37.h
    scummvm/trunk/engines/scumm/smush/codec47.cpp
    scummvm/trunk/engines/scumm/smush/codec47.h
    scummvm/trunk/engines/scumm/smush/smush_player.cpp
    scummvm/trunk/engines/scumm/smush/smush_player.h

Modified: scummvm/trunk/engines/scumm/smush/codec37.cpp
===================================================================
--- scummvm/trunk/engines/scumm/smush/codec37.cpp	2007-01-30 22:32:51 UTC (rev 25294)
+++ scummvm/trunk/engines/scumm/smush/codec37.cpp	2007-01-30 22:44:14 UTC (rev 25295)
@@ -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 @@
 	_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 @@
 	}
 }
 
-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,

Modified: scummvm/trunk/engines/scumm/smush/codec37.h
===================================================================
--- scummvm/trunk/engines/scumm/smush/codec37.h	2007-01-30 22:32:51 UTC (rev 25294)
+++ scummvm/trunk/engines/scumm/smush/codec37.h	2007-01-30 22:44:14 UTC (rev 25295)
@@ -42,10 +42,8 @@
 	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 *);

Modified: scummvm/trunk/engines/scumm/smush/codec47.cpp
===================================================================
--- scummvm/trunk/engines/scumm/smush/codec47.cpp	2007-01-30 22:32:51 UTC (rev 25294)
+++ scummvm/trunk/engines/scumm/smush/codec47.cpp	2007-01-30 22:44:14 UTC (rev 25295)
@@ -501,8 +501,7 @@
 	} 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 @@
 	_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 @@
 	}
 }
 
-Codec47Decoder::~Codec47Decoder() {
-	deinit();
-}
-
 bool Codec47Decoder::decode(byte *dst, const byte *src) {
 	_offset1 = _deltaBufs[1] - _curBuf;
 	_offset2 = _deltaBufs[0] - _curBuf;

Modified: scummvm/trunk/engines/scumm/smush/codec47.h
===================================================================
--- scummvm/trunk/engines/scumm/smush/codec47.h	2007-01-30 22:32:51 UTC (rev 25294)
+++ scummvm/trunk/engines/scumm/smush/codec47.h	2007-01-30 22:44:14 UTC (rev 25295)
@@ -53,10 +53,8 @@
 	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);
 };
 

Modified: scummvm/trunk/engines/scumm/smush/smush_player.cpp
===================================================================
--- scummvm/trunk/engines/scumm/smush/smush_player.cpp	2007-01-30 22:32:51 UTC (rev 25294)
+++ scummvm/trunk/engines/scumm/smush/smush_player.cpp	2007-01-30 22:44:14 UTC (rev 25295)
@@ -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 @@
 	_vm = scumm;
 	_version = -1;
 	_nbframes = 0;
+	_codec37 = 0;
+	_codec47 = 0;
 	_smixer = NULL;
 	_strings = NULL;
 	_sf[0] = NULL;
@@ -284,8 +288,6 @@
 void SmushPlayer::init(int32 speed) {
 	_frame = 0;
 	_speed = speed;
-	_codec37AlreadyInit = false;
-	_codec47AlreadyInit = false;
 	_endOfFile = false;
 
 	_vm->_smushVideoShouldFinish = false;
@@ -354,14 +356,10 @@
 
 	_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 @@
 		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);

Modified: scummvm/trunk/engines/scumm/smush/smush_player.h
===================================================================
--- scummvm/trunk/engines/scumm/smush/smush_player.h	2007-01-30 22:32:51 UTC (rev 25294)
+++ scummvm/trunk/engines/scumm/smush/smush_player.h	2007-01-30 22:44:14 UTC (rev 25295)
@@ -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 SmushFont;
 class SmushMixer;
 class StringResource;
+class Codec37Decoder;
+class Codec47Decoder;
 
 class SmushPlayer {
 	friend class Insane;
@@ -46,10 +46,8 @@
 	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;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list