mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-15 06:08:35 +00:00
changed decoder API to take a memory block as source, not a Chunk
svn-id: r6807
This commit is contained in:
parent
b6113a2568
commit
4c6e8dc695
@ -21,31 +21,31 @@
|
||||
|
||||
#include <stdafx.h>
|
||||
#include "codec1.h"
|
||||
#include "chunk.h"
|
||||
|
||||
Codec1Decoder::~Codec1Decoder() {
|
||||
}
|
||||
|
||||
bool Codec1Decoder::decode(byte *dst, Chunk &src) {
|
||||
bool Codec1Decoder::decode(byte *dst, const byte *src, int) {
|
||||
byte val;
|
||||
int32 size_line;
|
||||
int32 code, length;
|
||||
int32 h, height = getRect().height();
|
||||
|
||||
for(h = 0; h < height; h++) {
|
||||
size_line = src.getWord(); // size of compressed line !
|
||||
size_line = READ_LE_UINT16(src); // size of compressed line !
|
||||
src += 2;
|
||||
#ifdef DEBUG_CODEC1
|
||||
debug(7, "codec1 : h == %d, size_line == %d", h, size_line);
|
||||
#endif
|
||||
while(size_line > 0) {
|
||||
code = src.getByte();
|
||||
code = *src++;
|
||||
size_line--;
|
||||
length = (code >> 1) + 1;
|
||||
#ifdef DEBUG_CODEC1
|
||||
debug(7, "codec1 : length == %d", length);
|
||||
#endif
|
||||
if(code & 1) {
|
||||
val = src.getByte();
|
||||
val = *src++;
|
||||
size_line--;
|
||||
if (val)
|
||||
memset(dst, val, length);
|
||||
@ -59,7 +59,7 @@ bool Codec1Decoder::decode(byte *dst, Chunk &src) {
|
||||
debug(7, "codec1 : blitting %d entries", length);
|
||||
#endif
|
||||
while(length--) {
|
||||
val = src.getByte();
|
||||
val = *src++;
|
||||
if (val)
|
||||
*dst = val;
|
||||
dst++;
|
||||
@ -67,11 +67,5 @@ bool Codec1Decoder::decode(byte *dst, Chunk &src) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG_CODEC1
|
||||
if(!src.eof()) {
|
||||
int32 len = src.getSize() - src.tell();
|
||||
debug(7, "codec1: remaining length after decode == %d", len);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@
|
||||
class Codec1Decoder : public Decoder {
|
||||
public:
|
||||
virtual ~Codec1Decoder();
|
||||
bool decode(byte *dst, Chunk &);
|
||||
bool decode(byte *dst, const byte *src, int length);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
#include <stdafx.h>
|
||||
#include "codec37.h"
|
||||
#include "chunk.h"
|
||||
|
||||
#include "common/engine.h"
|
||||
|
||||
@ -258,7 +257,7 @@ void Codec37Decoder::maketable(int32 pitch, int32 index) {
|
||||
}
|
||||
}
|
||||
|
||||
void Codec37Decoder::bompDecode(byte *dst, byte *src, int32 len) {
|
||||
void Codec37Decoder::bompDecode(byte *dst, const byte *src, int len) {
|
||||
byte code;
|
||||
byte color;
|
||||
int32 num;
|
||||
@ -369,7 +368,7 @@ void Codec37Decoder::bompDecode(byte *dst, byte *src, int32 len) {
|
||||
dst += 4; \
|
||||
} while(0)
|
||||
|
||||
void Codec37Decoder::proc3WithFDFE(byte *dst, byte *src, int32 next_offs, int32 bw, int32 bh, int32 pitch, int16 *offset_table) {
|
||||
void Codec37Decoder::proc3WithFDFE(byte *dst, const byte *src, int32 next_offs, int32 bw, int32 bh, int32 pitch, int16 *offset_table) {
|
||||
do {
|
||||
int32 i = bw;
|
||||
do {
|
||||
@ -389,7 +388,7 @@ void Codec37Decoder::proc3WithFDFE(byte *dst, byte *src, int32 next_offs, int32
|
||||
} while (--bh);
|
||||
}
|
||||
|
||||
void Codec37Decoder::proc3WithoutFDFE(byte *dst, byte *src, int32 next_offs, int32 bw, int32 bh, int32 pitch, int16 *offset_table) {
|
||||
void Codec37Decoder::proc3WithoutFDFE(byte *dst, const byte *src, int32 next_offs, int32 bw, int32 bh, int32 pitch, int16 *offset_table) {
|
||||
do {
|
||||
int32 i = bw;
|
||||
do {
|
||||
@ -405,7 +404,7 @@ void Codec37Decoder::proc3WithoutFDFE(byte *dst, byte *src, int32 next_offs, int
|
||||
} while (--bh);
|
||||
}
|
||||
|
||||
void Codec37Decoder::proc4WithFDFE(byte *dst, byte *src, int32 next_offs, int32 bw, int32 bh, int32 pitch, int16 *offset_table) {
|
||||
void Codec37Decoder::proc4WithFDFE(byte *dst, const byte *src, int32 next_offs, int32 bw, int32 bh, int32 pitch, int16 *offset_table) {
|
||||
do {
|
||||
int32 i = bw;
|
||||
do {
|
||||
@ -441,7 +440,7 @@ void Codec37Decoder::proc4WithFDFE(byte *dst, byte *src, int32 next_offs, int32
|
||||
} while (--bh);
|
||||
}
|
||||
|
||||
void Codec37Decoder::proc4WithoutFDFE(byte *dst, byte *src, int32 next_offs, int32 bw, int32 bh, int32 pitch, int16 *offset_table) {
|
||||
void Codec37Decoder::proc4WithoutFDFE(byte *dst, const byte *src, int32 next_offs, int32 bw, int32 bh, int32 pitch, int16 *offset_table) {
|
||||
do {
|
||||
int32 i = bw;
|
||||
do {
|
||||
@ -473,23 +472,19 @@ void Codec37Decoder::proc4WithoutFDFE(byte *dst, byte *src, int32 next_offs, int
|
||||
} while (--bh);
|
||||
}
|
||||
|
||||
bool Codec37Decoder::decode(byte *dst, Chunk & src) {
|
||||
bool Codec37Decoder::decode(byte *dst, const byte *src, int length) {
|
||||
int32 width = getRect().width();
|
||||
int32 height = getRect().height();
|
||||
int32 bw = (width + 3) >> 2, bh = (height + 3) >> 2;
|
||||
int32 pitch = bw << 2;
|
||||
|
||||
int32 chunk_size = src.getSize() - 14;
|
||||
byte *chunk_buffer = (byte *)malloc(chunk_size);
|
||||
src.read(chunk_buffer, chunk_size);
|
||||
|
||||
int16 seq_nb = READ_LE_UINT16(chunk_buffer + 2);
|
||||
int32 decoded_size = READ_LE_UINT32(chunk_buffer + 4);
|
||||
byte mask_flags = chunk_buffer[12];
|
||||
maketable(pitch, chunk_buffer[1]);
|
||||
int16 seq_nb = READ_LE_UINT16(src + 2);
|
||||
int32 decoded_size = READ_LE_UINT32(src + 4);
|
||||
byte mask_flags = src[12];
|
||||
maketable(pitch, src[1]);
|
||||
int32 tmp;
|
||||
|
||||
switch(chunk_buffer[0]) {
|
||||
switch(src[0]) {
|
||||
case 0:
|
||||
if ((_deltaBufs[_curtable] - _deltaBuf) > 0) {
|
||||
memset(_deltaBuf, 0, _deltaBufs[_curtable] - _deltaBuf);
|
||||
@ -498,13 +493,13 @@ bool Codec37Decoder::decode(byte *dst, Chunk & src) {
|
||||
if (tmp > 0) {
|
||||
memset(_deltaBufs[_curtable] + decoded_size, 0, tmp);
|
||||
}
|
||||
memcpy(_deltaBufs[_curtable], chunk_buffer + 16, decoded_size);
|
||||
memcpy(_deltaBufs[_curtable], src + 16, decoded_size);
|
||||
break;
|
||||
case 1:
|
||||
error("codec37: missing opcode 1");
|
||||
break;
|
||||
case 2:
|
||||
bompDecode(_deltaBufs[_curtable], chunk_buffer + 16, decoded_size);
|
||||
bompDecode(_deltaBufs[_curtable], src + 16, decoded_size);
|
||||
if ((_deltaBufs[_curtable] - _deltaBuf) > 0) {
|
||||
memset(_deltaBuf, 0, _deltaBufs[_curtable] - _deltaBuf);
|
||||
}
|
||||
@ -519,11 +514,11 @@ bool Codec37Decoder::decode(byte *dst, Chunk & src) {
|
||||
}
|
||||
|
||||
if((mask_flags & 4) != 0) {
|
||||
proc3WithFDFE(_deltaBufs[_curtable], chunk_buffer + 16,
|
||||
proc3WithFDFE(_deltaBufs[_curtable], src + 16,
|
||||
_deltaBufs[_curtable ^ 1] - _deltaBufs[_curtable], bw, bh,
|
||||
pitch, _offsetTable);
|
||||
} else {
|
||||
proc3WithoutFDFE(_deltaBufs[_curtable], chunk_buffer + 16,
|
||||
proc3WithoutFDFE(_deltaBufs[_curtable], src + 16,
|
||||
_deltaBufs[_curtable ^ 1] - _deltaBufs[_curtable], bw, bh,
|
||||
pitch, _offsetTable);
|
||||
}
|
||||
@ -534,11 +529,11 @@ bool Codec37Decoder::decode(byte *dst, Chunk & src) {
|
||||
}
|
||||
|
||||
if((mask_flags & 4) != 0) {
|
||||
proc4WithFDFE(_deltaBufs[_curtable], chunk_buffer + 16,
|
||||
proc4WithFDFE(_deltaBufs[_curtable], src + 16,
|
||||
_deltaBufs[_curtable ^ 1] - _deltaBufs[_curtable], bw, bh,
|
||||
pitch, _offsetTable);
|
||||
} else {
|
||||
proc4WithoutFDFE(_deltaBufs[_curtable], chunk_buffer + 16,
|
||||
proc4WithoutFDFE(_deltaBufs[_curtable], src + 16,
|
||||
_deltaBufs[_curtable ^ 1] - _deltaBufs[_curtable], bw, bh,
|
||||
pitch, _offsetTable);
|
||||
}
|
||||
@ -550,7 +545,6 @@ bool Codec37Decoder::decode(byte *dst, Chunk & src) {
|
||||
|
||||
memcpy(dst, _deltaBufs[_curtable], width * height);
|
||||
|
||||
free(chunk_buffer);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -42,13 +42,13 @@ public:
|
||||
virtual ~Codec37Decoder();
|
||||
protected:
|
||||
void maketable(int32, int32);
|
||||
void bompDecode(byte *dst, byte *src, int32 len);
|
||||
void proc3WithFDFE(byte *, byte *, int32, int32, int32, int32, int16 *);
|
||||
void proc3WithoutFDFE(byte *, byte *, int32, int32, int32, int32, int16 *);
|
||||
void proc4WithFDFE(byte *, byte *, int32, int32, int32, int32, int16 *);
|
||||
void proc4WithoutFDFE(byte *, byte *, int32, int32, int32, int32, int16 *);
|
||||
void bompDecode(byte *dst, const byte *src, int len);
|
||||
void proc3WithFDFE(byte *dst, const byte *src, int32, int32, int32, int32, int16 *);
|
||||
void proc3WithoutFDFE(byte *dst, const byte *src, int32, int32, int32, int32, int16 *);
|
||||
void proc4WithFDFE(byte *dst, const byte *src, int32, int32, int32, int32, int16 *);
|
||||
void proc4WithoutFDFE(byte *dst, const byte *src, int32, int32, int32, int32, int16 *);
|
||||
public:
|
||||
bool decode(byte *dst, Chunk &);
|
||||
bool decode(byte *dst, const byte *src, int length);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -21,16 +21,12 @@
|
||||
|
||||
#include <stdafx.h>
|
||||
#include "codec44.h"
|
||||
#include "chunk.h"
|
||||
|
||||
bool Codec44Decoder::decode(byte *dst, Chunk & src) {
|
||||
bool Codec44Decoder::decode(byte *dst, const byte *src, int length) {
|
||||
int32 size_line, num;
|
||||
int32 length = src.getSize() - 14;
|
||||
int32 width = getRect().width();
|
||||
int32 height = getRect().height();
|
||||
byte *src2 = (byte *)malloc(length);
|
||||
byte *org_src2 = src2;
|
||||
src.read(src2, length);
|
||||
const byte *src2 = src;
|
||||
byte *dst2 = _buffer;
|
||||
byte val;
|
||||
|
||||
@ -62,7 +58,5 @@ bool Codec44Decoder::decode(byte *dst, Chunk & src) {
|
||||
|
||||
memcpy(dst, _buffer, width * height);
|
||||
|
||||
free(org_src2);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class Codec44Decoder : public Decoder {
|
||||
byte _buffer[1000];
|
||||
|
||||
public:
|
||||
bool decode(byte *dst, Chunk &src);
|
||||
bool decode(byte *dst, const byte *src, int length);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -20,10 +20,9 @@
|
||||
*/
|
||||
|
||||
#include <stdafx.h>
|
||||
#include "scumm/scumm.h"
|
||||
#include "engine.h"
|
||||
#include "codec47.h"
|
||||
#include "chunk.h"
|
||||
|
||||
#include "common/engine.h"
|
||||
|
||||
static int32 codec37_table[] = {
|
||||
0, 1, 2, 3, 3, 3,
|
||||
@ -427,7 +426,7 @@ void Codec47Decoder::makeTables47(int32 width) {
|
||||
} while (c < 32768);
|
||||
}
|
||||
|
||||
void Codec47Decoder::bompDecode(byte *dst, byte *src, int32 len) {
|
||||
void Codec47Decoder::bompDecode(byte *dst, const byte *src, int len) {
|
||||
byte code;
|
||||
byte color;
|
||||
int32 num;
|
||||
@ -602,7 +601,7 @@ void Codec47Decoder::level1(byte *d_dst) {
|
||||
}
|
||||
}
|
||||
|
||||
void Codec47Decoder::decode2(byte *dst, byte *src, int32 width, int32 height, byte *param_ptr) {
|
||||
void Codec47Decoder::decode2(byte *dst, const byte *src, int32 width, int32 height, const byte *param_ptr) {
|
||||
_d_src = src;
|
||||
_paramPtr = param_ptr - 0xf8;
|
||||
int32 bw = (width + 7) >> 3;
|
||||
@ -663,33 +662,29 @@ Codec47Decoder::~Codec47Decoder() {
|
||||
clean();
|
||||
}
|
||||
|
||||
bool Codec47Decoder::decode(byte *dst, Chunk &src) {
|
||||
bool Codec47Decoder::decode(byte *dst, const byte *src, int length) {
|
||||
int32 width = getRect().width();
|
||||
int32 height = getRect().height();
|
||||
_offset1 = _deltaBufs[1] - _curBuf;
|
||||
_offset2 = _deltaBufs[0] - _curBuf;
|
||||
|
||||
int32 chunk_size = src.getSize() - 14;
|
||||
byte *chunk_buffer = (byte *)malloc(chunk_size);
|
||||
src.read(chunk_buffer, chunk_size);
|
||||
int32 seq_nb = READ_LE_UINT16(src + 0);
|
||||
|
||||
int32 seq_nb = READ_LE_UINT16(chunk_buffer + 0);
|
||||
|
||||
byte *gfx_data = chunk_buffer + 26;
|
||||
const byte *gfx_data = src + 26;
|
||||
byte *tmp_ptr;
|
||||
|
||||
if (seq_nb == 0) {
|
||||
makeTables47(width);
|
||||
memset(_deltaBufs[0], chunk_buffer[12], width * height);
|
||||
memset(_deltaBufs[1], chunk_buffer[13], width * height);
|
||||
memset(_deltaBufs[0], src[12], width * height);
|
||||
memset(_deltaBufs[1], src[13], width * height);
|
||||
_prevSeqNb = -1;
|
||||
}
|
||||
|
||||
if ((chunk_buffer[4] & 1) != 0) {
|
||||
if ((src[4] & 1) != 0) {
|
||||
gfx_data += 32896;
|
||||
}
|
||||
|
||||
switch(chunk_buffer[2]) {
|
||||
switch(src[2]) {
|
||||
case 0:
|
||||
memcpy(_curBuf, gfx_data, width * height);
|
||||
break;
|
||||
@ -698,7 +693,7 @@ bool Codec47Decoder::decode(byte *dst, Chunk &src) {
|
||||
break;
|
||||
case 2:
|
||||
if (seq_nb == _prevSeqNb + 1) {
|
||||
decode2(_curBuf, gfx_data, width, height, chunk_buffer + 8);
|
||||
decode2(_curBuf, gfx_data, width, height, src + 8);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
@ -708,18 +703,18 @@ bool Codec47Decoder::decode(byte *dst, Chunk &src) {
|
||||
memcpy(_curBuf, _deltaBufs[0], width * height);
|
||||
break;
|
||||
case 5:
|
||||
bompDecode(_curBuf, gfx_data, READ_LE_UINT32(chunk_buffer + 14));
|
||||
bompDecode(_curBuf, gfx_data, READ_LE_UINT32(src + 14));
|
||||
break;
|
||||
}
|
||||
|
||||
memcpy(dst, _curBuf, width * height);
|
||||
|
||||
if (seq_nb == _prevSeqNb + 1) {
|
||||
if (chunk_buffer[3] == 1) {
|
||||
if (src[3] == 1) {
|
||||
tmp_ptr = _curBuf;
|
||||
_curBuf = _deltaBufs[1];
|
||||
_deltaBufs[1] = tmp_ptr;
|
||||
} else if (chunk_buffer[3] == 2) {
|
||||
} else if (src[3] == 2) {
|
||||
tmp_ptr = _deltaBufs[0];
|
||||
_deltaBufs[0] = _deltaBufs[1];
|
||||
_deltaBufs[1] = _curBuf;
|
||||
@ -728,7 +723,5 @@ bool Codec47Decoder::decode(byte *dst, Chunk &src) {
|
||||
}
|
||||
_prevSeqNb = seq_nb;
|
||||
|
||||
free(chunk_buffer);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ private:
|
||||
byte *_curBuf;
|
||||
int32 _prevSeqNb;
|
||||
int32 _lastTableWidth;
|
||||
byte *_d_src, *_paramPtr;
|
||||
const byte *_d_src, *_paramPtr;
|
||||
int32 _d_pitch;
|
||||
int32 _offset1, _offset2;
|
||||
byte _tableBig[99328];
|
||||
@ -43,18 +43,18 @@ private:
|
||||
|
||||
void makeTables47(int32 width);
|
||||
void makeTables37(int32 param);
|
||||
void bompDecode(byte *dst, byte *src, int32 len);
|
||||
void bompDecode(byte *dst, const byte *src, int len);
|
||||
void level1(byte *d_dst);
|
||||
void level2(byte *d_dst);
|
||||
void level3(byte *d_dst);
|
||||
void decode2(byte *dst, byte *src, int32 width, int32 height, byte *param_ptr);
|
||||
void decode2(byte *dst, const byte *src, int32 width, int32 height, const byte *param_ptr);
|
||||
|
||||
public:
|
||||
Codec47Decoder();
|
||||
virtual ~Codec47Decoder();
|
||||
bool initSize(const Point &, const Rect &);
|
||||
void clean();
|
||||
bool decode(byte *dst, Chunk &);
|
||||
bool decode(byte *dst, const byte *src, int length);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -28,8 +28,6 @@
|
||||
|
||||
using ScummVM::Point;
|
||||
using ScummVM::Rect;
|
||||
class Blitter;
|
||||
class Chunk;
|
||||
|
||||
/*! @brief base class for codec decompression.
|
||||
|
||||
@ -47,7 +45,7 @@ public:
|
||||
Decoder() {};
|
||||
virtual ~Decoder() {};
|
||||
virtual bool initSize(const Point &p, const Rect &r) { _p = p; _r = r; return true; };
|
||||
virtual bool decode(byte *dst, Chunk &src) = 0;
|
||||
virtual bool decode(byte *dst, const byte *src, int length) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -605,9 +605,16 @@ void SmushPlayer::handleNewPalette(Chunk &b) {
|
||||
updatePalette();
|
||||
}
|
||||
|
||||
void SmushPlayer::decodeCodec(Chunk &b, const Rect &r, Decoder &codec) {
|
||||
void SmushPlayer::decodeCodec(Chunk &src, const Rect &r, Decoder &codec) {
|
||||
assert(_curBuffer);
|
||||
codec.decode((byte *)_curBuffer, b);
|
||||
|
||||
int32 chunk_size = src.getSize() - 14;
|
||||
byte *chunk_buffer = (byte *)malloc(chunk_size);
|
||||
assert(chunk_buffer);
|
||||
src.read(chunk_buffer, chunk_size);
|
||||
codec.decode((byte *)_curBuffer, chunk_buffer, chunk_size);
|
||||
free(chunk_buffer);
|
||||
|
||||
if (_storeFrame == true) {
|
||||
if (_frameBuffer == NULL) {
|
||||
_frameBuffer = (byte *)malloc(_frameSize.getX() * _frameSize.getY());
|
||||
|
Loading…
Reference in New Issue
Block a user