aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Fach-Pedersen2014-05-17 01:16:34 +0200
committerEugene Sandulenko2016-09-29 22:21:00 +0200
commit5c69ed59951c9436c5dd450396fc16dd5ab38f83 (patch)
treedf65761dc9e3e6710e1e6595408e539960da3489
parent2e3fd7cf050e24b9f6363b1a38c6ff45847c6d6f (diff)
downloadscummvm-rg350-5c69ed59951c9436c5dd450396fc16dd5ab38f83.tar.gz
scummvm-rg350-5c69ed59951c9436c5dd450396fc16dd5ab38f83.tar.bz2
scummvm-rg350-5c69ed59951c9436c5dd450396fc16dd5ab38f83.zip
BLADERUNNER: Style
-rw-r--r--engines/bladerunner/bladerunner.cpp6
-rw-r--r--engines/bladerunner/vqa_decoder.cpp673
-rw-r--r--engines/bladerunner/vqa_decoder.h112
3 files changed, 395 insertions, 396 deletions
diff --git a/engines/bladerunner/bladerunner.cpp b/engines/bladerunner/bladerunner.cpp
index 3ae0d47239..7e8466c14a 100644
--- a/engines/bladerunner/bladerunner.cpp
+++ b/engines/bladerunner/bladerunner.cpp
@@ -220,7 +220,7 @@ void BladeRunnerEngine::playOuttake(int id, bool no_localization) {
VQADecoder vqa_decoder(s);
- bool b = vqa_decoder.read_header();
+ bool b = vqa_decoder.readHeader();
if (!b) return;
uint32 frame_count = 0;
@@ -238,13 +238,13 @@ void BladeRunnerEngine::playOuttake(int id, bool no_localization) {
if (next_frame_time <= cur_time)
{
- int frame_number = vqa_decoder.read_frame();
+ int frame_number = vqa_decoder.readFrame();
debug("frame_number: %d", frame_number);
if (frame_number < 0)
break;
- b = vqa_decoder.decode_frame((uint16*)_surface1.getPixels());
+ b = vqa_decoder.decodeFrame((uint16*)_surface1.getPixels());
_system->copyRectToScreen(_surface1.getPixels(), _surface1.pitch, 0, 0, _surface1.w, _surface1.h);
_system->updateScreen();
diff --git a/engines/bladerunner/vqa_decoder.cpp b/engines/bladerunner/vqa_decoder.cpp
index b717964f5f..46e45de1a7 100644
--- a/engines/bladerunner/vqa_decoder.cpp
+++ b/engines/bladerunner/vqa_decoder.cpp
@@ -66,33 +66,32 @@ namespace BladeRunner {
#define kWVQA 0x57565141
#define kZBUF 0x5A425546
-VQADecoder::VQADecoder(Common::SeekableReadStream *r)
- : r(r),
- frame(0),
- zbuf(0),
- codebook(0),
- cbfz(0),
- vptr(0),
- cur_frame(-1),
- cur_loop(-1),
- loop_special(-1),
- loop_default(-1),
- has_view(false),
- audio_frame(0),
- max_view_chunk_size(0),
- max_zbuf_chunk_size(0),
- max_aesc_chunk_size(0)
-{
- // debug("Opening VQA: '%s'\n", r->get_name());
+VQADecoder::VQADecoder(Common::SeekableReadStream *s)
+ : _s(s),
+ _frame(0),
+ _zbuf(0),
+ _codebook(0),
+ _cbfz(0),
+ _vptr(0),
+ _curFrame(-1),
+ _curLoop(-1),
+ _loopSpecial(-1),
+ _loopDefault(-1),
+ _hasView(false),
+ _audioFrame(0),
+ _maxVIEWChunkSize(0),
+ _maxZBUFChunkSize(0),
+ _maxAESCChunkSize(0)
+{
}
VQADecoder::~VQADecoder()
{
}
-struct iff_chunk_header_s
+struct IFFChunkHeader
{
- iff_chunk_header_s()
+ IFFChunkHeader()
: id(0), size(0)
{}
@@ -105,9 +104,9 @@ static inline uint32 roundup(uint32 v)
return (v + 1) & ~1u;
}
-const char *str_tag(uint32 tag);
+const char *strTag(uint32 tag);
-int32 stream_remain(Common::SeekableReadStream *s) {
+int32 remain(Common::SeekableReadStream *s) {
int32 pos = s->pos();
if (pos == -1) return -1;
@@ -118,21 +117,21 @@ int32 stream_remain(Common::SeekableReadStream *s) {
}
static
-bool read_iff_chunk_header(Common::SeekableReadStream *r, iff_chunk_header_s *ts)
+bool readIFFChunkHeader(Common::SeekableReadStream *s, IFFChunkHeader *ts)
{
- if (stream_remain(r) < 8)
+ if (remain(s) < 8)
return false;
- ts->id = r->readUint32BE();
- ts->size = r->readUint32BE();
+ ts->id = s->readUint32BE();
+ ts->size = s->readUint32BE();
// if (ts->size != roundup(ts->size))
- // debug("%s: %d\n", str_tag(ts->id), ts->size);
+ // debug("%s: %d\n", strTag(ts->id), ts->size);
return true;
}
-const char *str_tag(uint32 tag)
+const char *strTag(uint32 tag)
{
static char s[5];
@@ -145,117 +144,117 @@ const char *str_tag(uint32 tag)
return s;
}
-bool VQADecoder::read_header()
+bool VQADecoder::readHeader()
{
- iff_chunk_header_s chd;
+ IFFChunkHeader chd;
uint32 type;
bool rc;
- read_iff_chunk_header(r, &chd);
+ readIFFChunkHeader(_s, &chd);
if (chd.id != kFORM || !chd.size)
return false;
- type = r->readUint32BE();
+ type = _s->readUint32BE();
if (type != kWVQA)
return false;
do {
- if (!read_iff_chunk_header(r, &chd))
+ if (!readIFFChunkHeader(_s, &chd))
return false;
- debug("\t%s : %x\n", str_tag(chd.id), chd.size);
+ debug("\t%s : %x\n", strTag(chd.id), chd.size);
rc = false;
switch (chd.id)
{
- case kCINF: rc = read_cinf(chd.size); break;
- case kCLIP: rc = read_clip(chd.size); break;
- case kFINF: rc = read_finf(chd.size); break;
- case kLINF: rc = read_linf(chd.size); break;
- case kLNIN: rc = read_lnin(chd.size); break;
- case kMFCI: rc = read_mfci(chd.size); break;
- case kMSCI: rc = read_msci(chd.size); break;
- case kVQHD: rc = read_vqhd(chd.size); break;
+ case kCINF: rc = readCINF(chd.size); break;
+ case kCLIP: rc = readCLIP(chd.size); break;
+ case kFINF: rc = readFINF(chd.size); break;
+ case kLINF: rc = readLINF(chd.size); break;
+ case kLNIN: rc = readLNIN(chd.size); break;
+ case kMFCI: rc = readMFCI(chd.size); break;
+ case kMSCI: rc = readMSCI(chd.size); break;
+ case kVQHD: rc = readVQHD(chd.size); break;
default:
- debug("Unhandled chunk '%s'\n", str_tag(chd.id));
- r->skip(roundup(chd.size));
+ debug("Unhandled chunk '%s'\n", strTag(chd.id));
+ _s->skip(roundup(chd.size));
rc = true;
}
if (!rc)
{
- debug("failed to handle chunk %s\n", str_tag(chd.id));
+ debug("failed to handle chunk %s\n", strTag(chd.id));
return false;
}
} while (chd.id != kFINF);
- for (int i = 0; i != loop_info.loop_count; ++i) {
+ for (int i = 0; i != _loopInfo.loopCount; ++i) {
debug("LOOP %2d: %4d %4d %s\n", i,
- loop_info.loops[i].begin,
- loop_info.loops[i].end,
- loop_info.loops[i].name.c_str());
+ _loopInfo.loops[i].begin,
+ _loopInfo.loops[i].end,
+ _loopInfo.loops[i].name.c_str());
}
return true;
}
-bool VQADecoder::read_vqhd(uint32 size)
+bool VQADecoder::readVQHD(uint32 size)
{
if (size != 42)
return false;
- header.version = r->readUint16LE();
- header.flags = r->readUint16LE();
- header.numFrames = r->readUint16LE();
- header.width = r->readUint16LE();
- header.height = r->readUint16LE();
- header.blockW = r->readByte();
- header.blockH = r->readByte();
- header.frameRate = r->readByte();
- header.cbParts = r->readByte();
- header.colors = r->readUint16LE();
- header.maxBlocks = r->readUint16LE();
- header.offset_x = r->readUint16LE();
- header.offset_y = r->readUint16LE();
- header.maxVPTRSize = r->readUint16LE();
- header.freq = r->readUint16LE();
- header.channels = r->readByte();
- header.bits = r->readByte();
- header.unk3 = r->readUint32LE();
- header.unk4 = r->readUint16LE();
- header.maxCBFZSize = r->readUint32LE();
- header.unk5 = r->readUint32LE();
-
- if (header.offset_x || header.offset_y)
+ _header.version = _s->readUint16LE();
+ _header.flags = _s->readUint16LE();
+ _header.numFrames = _s->readUint16LE();
+ _header.width = _s->readUint16LE();
+ _header.height = _s->readUint16LE();
+ _header.blockW = _s->readByte();
+ _header.blockH = _s->readByte();
+ _header.frameRate = _s->readByte();
+ _header.cbParts = _s->readByte();
+ _header.colors = _s->readUint16LE();
+ _header.maxBlocks = _s->readUint16LE();
+ _header.offset_x = _s->readUint16LE();
+ _header.offset_y = _s->readUint16LE();
+ _header.maxVPTRSize = _s->readUint16LE();
+ _header.freq = _s->readUint16LE();
+ _header.channels = _s->readByte();
+ _header.bits = _s->readByte();
+ _header.unk3 = _s->readUint32LE();
+ _header.unk4 = _s->readUint16LE();
+ _header.maxCBFZSize = _s->readUint32LE();
+ _header.unk5 = _s->readUint32LE();
+
+ if (_header.offset_x || _header.offset_y)
{
- debug("header.offset_x, header.offset_y: %d %d\n", header.offset_x, header.offset_y);
+ debug("_header.offset_x, _header.offset_y: %d %d\n", _header.offset_x, _header.offset_y);
}
- // if (header.unk3 || header.unk4 != 4 || header.unk5 || header.flags != 0x0014)
+ // if (_header.unk3 || _header.unk4 != 4 || _header.unk5 || _header.flags != 0x0014)
{
- debug("header.version %d\n", header.version);
- debug("header.flags %04x\n", header.flags);
- debug("header.numFrames %d\n", header.numFrames);
- debug("header.width %d\n", header.width);
- debug("header.height %d\n", header.height);
- debug("header.blockW %d\n", header.blockW);
- debug("header.blockH %d\n", header.blockH);
- debug("header.frameRate %d\n", header.frameRate);
- debug("header.cbParts %d\n", header.cbParts);
- debug("header.colors %d\n", header.colors);
- debug("header.maxBlocks %d\n", header.maxBlocks);
- debug("header.offsetX %d\n", header.offset_x);
- debug("header.offsetY %d\n", header.offset_y);
- debug("header.maxVPTRSize %d\n", header.maxVPTRSize);
- debug("header.freq %d\n", header.freq);
- debug("header.channels %d\n", header.channels);
- debug("header.bits %d\n", header.bits);
- debug("header.unk3 %d\n", header.unk3);
- debug("header.unk4 %d\n", header.unk4);
- debug("header.maxCBFZSize %d\n", header.maxCBFZSize);
- debug("header.unk5 %d\n", header.unk5);
+ debug("_header.version %d\n", _header.version);
+ debug("_header.flags %04x\n", _header.flags);
+ debug("_header.numFrames %d\n", _header.numFrames);
+ debug("_header.width %d\n", _header.width);
+ debug("_header.height %d\n", _header.height);
+ debug("_header.blockW %d\n", _header.blockW);
+ debug("_header.blockH %d\n", _header.blockH);
+ debug("_header.frameRate %d\n", _header.frameRate);
+ debug("_header.cbParts %d\n", _header.cbParts);
+ debug("_header.colors %d\n", _header.colors);
+ debug("_header.maxBlocks %d\n", _header.maxBlocks);
+ debug("_header.offsetX %d\n", _header.offset_x);
+ debug("_header.offsetY %d\n", _header.offset_y);
+ debug("_header.maxVPTRSize %d\n", _header.maxVPTRSize);
+ debug("_header.freq %d\n", _header.freq);
+ debug("_header.channels %d\n", _header.channels);
+ debug("_header.bits %d\n", _header.bits);
+ debug("_header.unk3 %d\n", _header.unk3);
+ debug("_header.unk4 %d\n", _header.unk4);
+ debug("_header.maxCBFZSize %d\n", _header.maxCBFZSize);
+ debug("_header.unk5 %d\n", _header.unk5);
}
// exit(-1);
@@ -263,276 +262,276 @@ bool VQADecoder::read_vqhd(uint32 size)
return true;
}
-bool VQADecoder::read_msci(uint32 size)
+bool VQADecoder::readMSCI(uint32 size)
{
- iff_chunk_header_s chd;
- read_iff_chunk_header(r, &chd);
+ IFFChunkHeader chd;
+ readIFFChunkHeader(_s, &chd);
if (chd.id != kMSCH)
return false;
uint32 count, unk0;
- count = r->readUint32LE();
- unk0 = r->readUint32LE();
+ count = _s->readUint32LE();
+ unk0 = _s->readUint32LE();
assert(unk0 == 0);
- read_iff_chunk_header(r, &chd);
+ readIFFChunkHeader(_s, &chd);
if (chd.id != kMSCT || chd.size != count * 0x10)
return false;
for (uint32 i = 0; i < count; ++i)
{
uint32 tag, size;
- tag = r->readUint32BE();
- size = r->readUint32LE();
+ tag = _s->readUint32BE();
+ size = _s->readUint32LE();
switch (tag)
{
case kVIEW:
- max_view_chunk_size = size;
- debug("max VIEW size: %08x\n", max_view_chunk_size);
+ _maxVIEWChunkSize = size;
+ debug("max VIEW size: %08x\n", _maxVIEWChunkSize);
break;
case kZBUF:
- max_zbuf_chunk_size = size;
- zbuf_chunk = new uint8[roundup(max_zbuf_chunk_size)];
- debug("max ZBUF size: %08x\n", max_zbuf_chunk_size);
+ _maxZBUFChunkSize = size;
+ _zbufChunk = new uint8[roundup(_maxZBUFChunkSize)];
+ debug("max ZBUF size: %08x\n", _maxZBUFChunkSize);
break;
case kAESC:
- max_aesc_chunk_size = size;
- debug("max AESC size: %08x\n", max_aesc_chunk_size);
+ _maxAESCChunkSize = size;
+ debug("max AESC size: %08x\n", _maxAESCChunkSize);
break;
default:
- debug("Unknown tag in MSCT: %s\n", str_tag(tag));
+ debug("Unknown tag in MSCT: %s\n", strTag(tag));
}
uint32 zero;
- zero = r->readUint32LE(); assert(zero == 0);
- zero = r->readUint32LE(); assert(zero == 0);
+ zero = _s->readUint32LE(); assert(zero == 0);
+ zero = _s->readUint32LE(); assert(zero == 0);
}
return true;
}
-bool VQADecoder::read_linf(uint32 size)
+bool VQADecoder::readLINF(uint32 size)
{
- iff_chunk_header_s chd;
- read_iff_chunk_header(r, &chd);
+ IFFChunkHeader chd;
+ readIFFChunkHeader(_s, &chd);
if (chd.id != kLINH || chd.size != 6)
return false;
- loop_info.loop_count = r->readUint16LE();
- loop_info.flags = r->readUint32LE();
+ _loopInfo.loopCount = _s->readUint16LE();
+ _loopInfo.flags = _s->readUint32LE();
- if ((loop_info.flags & 3) == 0)
+ if ((_loopInfo.flags & 3) == 0)
return false;
- read_iff_chunk_header(r, &chd);
- if (chd.id != kLIND || chd.size != 4u * loop_info.loop_count)
+ readIFFChunkHeader(_s, &chd);
+ if (chd.id != kLIND || chd.size != 4u * _loopInfo.loopCount)
return false;
- loop_info.loops = new Loop[loop_info.loop_count];
- for (int i = 0; i != loop_info.loop_count; ++i)
+ _loopInfo.loops = new Loop[_loopInfo.loopCount];
+ for (int i = 0; i != _loopInfo.loopCount; ++i)
{
- loop_info.loops[i].begin = r->readUint16LE();
- loop_info.loops[i].end = r->readUint16LE();
+ _loopInfo.loops[i].begin = _s->readUint16LE();
+ _loopInfo.loops[i].end = _s->readUint16LE();
- // debug("Loop %d: %04x %04x\n", i, loop_info.loops[i].begin, loop_info.loops[i].end);
+ // debug("Loop %d: %04x %04x\n", i, _loopInfo.loops[i].begin, _loopInfo.loops[i].end);
}
return true;
}
-bool VQADecoder::read_cinf(uint32 size)
+bool VQADecoder::readCINF(uint32 size)
{
- iff_chunk_header_s chd;
+ IFFChunkHeader chd;
- read_iff_chunk_header(r, &chd);
+ readIFFChunkHeader(_s, &chd);
if (chd.id != kCINH || chd.size != 8u)
return false;
- clip_info.clip_count = r->readUint16LE();
- r->skip(6);
+ _clipInfo.clipCount = _s->readUint16LE();
+ _s->skip(6);
- read_iff_chunk_header(r, &chd);
- if (chd.id != kCIND || chd.size != 6u * clip_info.clip_count)
+ readIFFChunkHeader(_s, &chd);
+ if (chd.id != kCIND || chd.size != 6u * _clipInfo.clipCount)
return false;
- for (int i = 0; i != clip_info.clip_count; ++i)
+ for (int i = 0; i != _clipInfo.clipCount; ++i)
{
uint16 a;
uint32 b;
- a = r->readUint16LE();
- b = r->readUint32LE();
+ a = _s->readUint16LE();
+ b = _s->readUint32LE();
debug("%4d %08x\n", a, b);
}
return true;
}
-bool VQADecoder::read_finf(uint32 size)
+bool VQADecoder::readFINF(uint32 size)
{
- if (size != 4u * header.numFrames)
+ if (size != 4u * _header.numFrames)
return false;
- frame_info = new uint32[header.numFrames];
+ _frameInfo = new uint32[_header.numFrames];
- for (uint32 i = 0; i != header.numFrames; ++i)
- frame_info[i] = r->readUint32LE();
+ for (uint32 i = 0; i != _header.numFrames; ++i)
+ _frameInfo[i] = _s->readUint32LE();
if (false) {
uint32 last = 0;
- for (uint32 i = 0; i != header.numFrames; ++i)
+ for (uint32 i = 0; i != _header.numFrames; ++i)
{
- uint32 diff = frame_info[i] - last;
- debug("frame_info[%4d] = 0x%08x - %08x\n", i, frame_info[i], diff);
- last = frame_info[i];
+ uint32 diff = _frameInfo[i] - last;
+ debug("_frameInfo[%4d] = 0x%08x - %08x\n", i, _frameInfo[i], diff);
+ last = _frameInfo[i];
}
}
return true;
}
-bool VQADecoder::read_lnin(uint32 size)
+bool VQADecoder::readLNIN(uint32 size)
{
- iff_chunk_header_s chd;
+ IFFChunkHeader chd;
- read_iff_chunk_header(r, &chd);
+ readIFFChunkHeader(_s, &chd);
if (chd.id != kLNIH || chd.size != 10)
return false;
- uint16 loop_names_count, loop_unk_1, loop_unk_2, loop_unk_3, loop_unk_4;
+ uint16 loopNamesCount, loopUnk1, loopUnk2, loopUnk3, loopUnk4;
- loop_names_count = r->readUint16LE();
- loop_unk_1 = r->readUint16LE();
- loop_unk_2 = r->readUint16LE();
- loop_unk_3 = r->readUint16LE();
- loop_unk_4 = r->readUint16LE();
+ loopNamesCount = _s->readUint16LE();
+ loopUnk1 = _s->readUint16LE();
+ loopUnk2 = _s->readUint16LE();
+ loopUnk3 = _s->readUint16LE();
+ loopUnk4 = _s->readUint16LE();
- if (loop_names_count != loop_info.loop_count)
+ if (loopNamesCount != _loopInfo.loopCount)
return false;
- read_iff_chunk_header(r, &chd);
- if (chd.id != kLNIO || chd.size != 4u * loop_names_count)
+ readIFFChunkHeader(_s, &chd);
+ if (chd.id != kLNIO || chd.size != 4u * loopNamesCount)
return false;
- uint32 *loop_name_offsets = (uint32*)alloca(loop_names_count * sizeof(uint32));
- for (int i = 0; i != loop_names_count; ++i) {
- loop_name_offsets[i] = r->readUint32LE();
+ uint32 *loopNameOffsets = (uint32*)alloca(loopNamesCount * sizeof(uint32));
+ for (int i = 0; i != loopNamesCount; ++i) {
+ loopNameOffsets[i] = _s->readUint32LE();
}
- read_iff_chunk_header(r, &chd);
+ readIFFChunkHeader(_s, &chd);
if (chd.id != kLNID)
return false;
char *names = (char*)alloca(roundup(chd.size));
- r->read(names, roundup(chd.size));
+ _s->read(names, roundup(chd.size));
- for (int i = 0; i != loop_names_count; ++i) {
- char *begin = names + loop_name_offsets[i];
- size_t len = ((i == loop_names_count) ? chd.size : loop_name_offsets[i+1]) - loop_name_offsets[i];
+ for (int i = 0; i != loopNamesCount; ++i) {
+ char *begin = names + loopNameOffsets[i];
+ size_t len = ((i == loopNamesCount) ? chd.size : loopNameOffsets[i+1]) - loopNameOffsets[i];
- loop_info.loops[i].name = Common::String(begin, len);
+ _loopInfo.loops[i].name = Common::String(begin, len);
}
return true;
}
-bool VQADecoder::read_clip(uint32 size)
+bool VQADecoder::readCLIP(uint32 size)
{
- r->skip(roundup(size));
+ _s->skip(roundup(size));
return true;
}
-bool VQADecoder::read_mfci(uint32 size)
+bool VQADecoder::readMFCI(uint32 size)
{
- r->skip(roundup(size));
+ _s->skip(roundup(size));
return true;
}
-int VQADecoder::read_frame()
+int VQADecoder::readFrame()
{
- // debug("VQADecoder::read_frame(): %d, %d, %d, %d\n", loop_default, loop_special, cur_loop, cur_frame);
+ // debug("VQADecoder::readFrame(): %d, %d, %d, %d\n", _loopDefault, _loopSpecial, _curLoop, _curFrame);
- if (loop_info.loop_count)
+ if (_loopInfo.loopCount)
{
- if (loop_special >= 0)
+ if (_loopSpecial >= 0)
{
- cur_loop = loop_special;
- loop_special = -1;
+ _curLoop = _loopSpecial;
+ _loopSpecial = -1;
- cur_frame = loop_info.loops[cur_loop].begin;
- seek_to_frame(cur_frame);
+ _curFrame = _loopInfo.loops[_curLoop].begin;
+ seekToFrame(_curFrame);
}
- else if (cur_loop == -1 && loop_default >= 0)
+ else if (_curLoop == -1 && _loopDefault >= 0)
{
- cur_loop = loop_default;
- cur_frame = loop_info.loops[cur_loop].begin;
- seek_to_frame(cur_frame);
+ _curLoop = _loopDefault;
+ _curFrame = _loopInfo.loops[_curLoop].begin;
+ seekToFrame(_curFrame);
}
- else if (cur_loop >= -1 && cur_frame == loop_info.loops[cur_loop].end)
+ else if (_curLoop >= -1 && _curFrame == _loopInfo.loops[_curLoop].end)
{
- if (loop_default == -1)
+ if (_loopDefault == -1)
return -1;
- cur_loop = loop_default;
- cur_frame = loop_info.loops[cur_loop].begin;
- seek_to_frame(cur_frame);
+ _curLoop = _loopDefault;
+ _curFrame = _loopInfo.loops[_curLoop].begin;
+ seekToFrame(_curFrame);
}
else
- ++cur_frame;
+ ++_curFrame;
}
else
- ++cur_frame;
+ ++_curFrame;
- if (cur_frame >= header.numFrames)
+ if (_curFrame >= _header.numFrames)
return -1;
- iff_chunk_header_s chd;
+ IFFChunkHeader chd;
- has_view = false;
+ _hasView = false;
- if (stream_remain(r) < 8) {
- debug("remain: %d\n", stream_remain(r));
+ if (remain(_s) < 8) {
+ debug("remain: %d\n", remain(_s));
return -1;
}
do {
- if (!read_iff_chunk_header(r, &chd)) {
+ if (!readIFFChunkHeader(_s, &chd)) {
debug("Error reading chunk header\n");
return -1;
}
- // debug("%s ", str_tag(chd.id));
+ // debug("%s ", strTag(chd.id));
bool rc = false;
switch (chd.id)
{
- case kAESC: rc = read_aesc(chd.size); break;
- case kLITE: rc = read_lite(chd.size); break;
- case kSN2J: rc = read_sn2j(chd.size); break;
- case kSND2: rc = read_snd2(chd.size); break;
- case kVIEW: rc = read_view(chd.size); break;
- case kVQFL: rc = read_vqfl(chd.size); break;
- case kVQFR: rc = read_vqfr(chd.size); break;
- case kZBUF: rc = read_zbuf(chd.size); break;
+ case kAESC: rc = readAESC(chd.size); break;
+ case kLITE: rc = readLITE(chd.size); break;
+ case kSN2J: rc = readSN2J(chd.size); break;
+ case kSND2: rc = readSND2(chd.size); break;
+ case kVIEW: rc = readVIEW(chd.size); break;
+ case kVQFL: rc = readVQFL(chd.size); break;
+ case kVQFR: rc = readVQFR(chd.size); break;
+ case kZBUF: rc = readZBUF(chd.size); break;
default:
- r->skip(roundup(chd.size));
+ _s->skip(roundup(chd.size));
rc = true;
}
if (!rc)
{
- debug("Error handling chunk %s\n", str_tag(chd.id));
+ debug("Error handling chunk %s\n", strTag(chd.id));
return -1;
}
} while (chd.id != kVQFR);
- return cur_frame;
+ return _curFrame;
}
-bool VQADecoder::read_sn2j(uint32 size)
+bool VQADecoder::readSN2J(uint32 size)
{
if (size != 6)
return false;
@@ -540,15 +539,15 @@ bool VQADecoder::read_sn2j(uint32 size)
uint16 step_index;
uint32 predictor;
- step_index = r->readUint16LE();
- predictor = r->readUint32LE();
+ step_index = _s->readUint16LE();
+ predictor = _s->readUint32LE();
// ima_adpcm_ws_decoder.set_parameters(step_index >> 5, predictor);
return true;
}
-bool VQADecoder::read_snd2(uint32 size)
+bool VQADecoder::readSND2(uint32 size)
{
if (size != 735)
{
@@ -556,44 +555,44 @@ bool VQADecoder::read_snd2(uint32 size)
return false;
}
- if (!audio_frame)
- audio_frame = new int16[2 * size];
- memset(audio_frame, 0, 4 * size);
+ if (!_audioFrame)
+ _audioFrame = new int16[2 * size];
+ memset(_audioFrame, 0, 4 * size);
- uint8 *in_frame = new uint8[roundup(size)];
- r->read(in_frame, roundup(size));
+ uint8 *inFrame = new uint8[roundup(size)];
+ _s->read(inFrame, roundup(size));
- // ima_adpcm_ws_decoder.decode(in_frame, size, audio_frame);
+ // ima_adpcm_ws_decoder.decode(inFrame, size, _audioFrame);
- delete[] in_frame;
+ delete[] inFrame;
return true;
}
-bool VQADecoder::read_vqfr(uint32 size)
+bool VQADecoder::readVQFR(uint32 size)
{
- iff_chunk_header_s chd;
+ IFFChunkHeader chd;
while (size >= 8)
{
- if (!read_iff_chunk_header(r, &chd))
+ if (!readIFFChunkHeader(_s, &chd))
return false;
size -= roundup(chd.size) + 8;
- // debug("(%s) ", str_tag(chd.id)); fflush(0);
+ // debug("(%s) ", strTag(chd.id)); fflush(0);
bool rc = false;
switch (chd.id)
{
- case kCBFZ: rc = read_cbfz(chd.size); break;
- case kVPTR: rc = read_vptr(chd.size); break;
+ case kCBFZ: rc = readCBFZ(chd.size); break;
+ case kVPTR: rc = readVPTR(chd.size); break;
default:
- r->skip(roundup(chd.size));
+ _s->skip(roundup(chd.size));
}
if (!rc)
{
- debug("VQFR: error handling chunk %s\n", str_tag(chd.id));
+ debug("VQFR: error handling chunk %s\n", strTag(chd.id));
return false;
}
}
@@ -601,27 +600,27 @@ bool VQADecoder::read_vqfr(uint32 size)
return true;
}
-bool VQADecoder::read_vqfl(uint32 size)
+bool VQADecoder::readVQFL(uint32 size)
{
- iff_chunk_header_s chd;
+ IFFChunkHeader chd;
while (size >= 8)
{
- if (!read_iff_chunk_header(r, &chd))
+ if (!readIFFChunkHeader(_s, &chd))
return false;
size -= roundup(chd.size) + 8;
bool rc = false;
switch (chd.id)
{
- case kCBFZ: rc = read_cbfz(chd.size); break;
+ case kCBFZ: rc = readCBFZ(chd.size); break;
default:
- r->skip(roundup(chd.size));
+ _s->skip(roundup(chd.size));
}
if (!rc)
{
- debug("VQFL: error handling chunk %s\n", str_tag(chd.id));
+ debug("VQFL: error handling chunk %s\n", strTag(chd.id));
return false;
}
}
@@ -629,179 +628,179 @@ bool VQADecoder::read_vqfl(uint32 size)
return true;
}
-bool VQADecoder::read_cbfz(uint32 size)
+bool VQADecoder::readCBFZ(uint32 size)
{
- if (size > header.maxCBFZSize)
+ if (size > _header.maxCBFZSize)
{
- debug("%d > %d\n", size, header.maxCBFZSize);
+ debug("%d > %d\n", size, _header.maxCBFZSize);
return false;
}
- if (!codebook)
+ if (!_codebook)
{
- codebookSize = 2 * header.maxBlocks * header.blockW * header.blockH;
- codebook = new uint8[codebookSize];
+ _codebookSize = 2 * _header.maxBlocks * _header.blockW * _header.blockH;
+ _codebook = new uint8[_codebookSize];
}
- if (!cbfz)
- cbfz = new uint8[roundup(header.maxCBFZSize)];
+ if (!_cbfz)
+ _cbfz = new uint8[roundup(_header.maxCBFZSize)];
- r->read(cbfz, roundup(size));
+ _s->read(_cbfz, roundup(size));
- decompress_lcw(cbfz, size, codebook, codebookSize);
+ decompress_lcw(_cbfz, size, _codebook, _codebookSize);
return true;
}
static
-int decodeZBUF_partial(uint8 *src, uint16 *cur_zbuf, uint32 src_len)
+int decodeZBUF_partial(uint8 *src, uint16 *curZBUF, uint32 srcLen)
{
- uint32 dst_size = 640 * 480; // This is taken from global variables?
- uint32 dst_remain = dst_size;
+ uint32 dstSize = 640 * 480; // This is taken from global variables?
+ uint32 dstRemain = dstSize;
- uint16 *curz_p = cur_zbuf;
- uint16 *in_p = (uint16*)src;
+ uint16 *curzp = curZBUF;
+ uint16 *inp = (uint16*)src;
- while (dst_remain && (in_p - (uint16*)src) < (ptrdiff_t)src_len)
+ while (dstRemain && (inp - (uint16*)src) < (ptrdiff_t)srcLen)
{
- uint32 count = FROM_LE_16(*in_p++);
+ uint32 count = FROM_LE_16(*inp++);
if (count & 0x8000)
{
- count = MIN(count & 0x7fff, dst_remain);
- dst_remain -= count;
+ count = MIN(count & 0x7fff, dstRemain);
+ dstRemain -= count;
while (count--)
{
- uint16 value = FROM_LE_16(*in_p++);
+ uint16 value = FROM_LE_16(*inp++);
if (value)
- *curz_p = value;
- ++curz_p;
+ *curzp = value;
+ ++curzp;
}
}
else
{
- count = MIN(count, dst_remain);
- dst_remain -= count;
- uint16 value = FROM_LE_16(*in_p++);
+ count = MIN(count, dstRemain);
+ dstRemain -= count;
+ uint16 value = FROM_LE_16(*inp++);
if (!value)
- curz_p += count;
+ curzp += count;
else
{
while (count--)
- *curz_p++ = value;
+ *curzp++ = value;
}
}
}
- return dst_size - dst_remain;
+ return dstSize - dstRemain;
}
-bool VQADecoder::read_zbuf(uint32 size)
+bool VQADecoder::readZBUF(uint32 size)
{
- if (size > max_zbuf_chunk_size) {
- debug("VQA ERROR: ZBUF chunk size: %08x > %08x\n", size, max_zbuf_chunk_size);
- r->skip(roundup(size));
+ if (size > _maxZBUFChunkSize) {
+ debug("VQA ERROR: ZBUF chunk size: %08x > %08x\n", size, _maxZBUFChunkSize);
+ _s->skip(roundup(size));
return false;
}
uint32 width, height, complete, unk0;
- width = r->readUint32LE();
- height = r->readUint32LE();
- complete = r->readUint32LE();
- unk0 = r->readUint32LE();
+ width = _s->readUint32LE();
+ height = _s->readUint32LE();
+ complete = _s->readUint32LE();
+ unk0 = _s->readUint32LE();
uint32 remain = size - 16;
- if (width != header.width || height != header.height)
+ if (width != _header.width || height != _header.height)
{
debug("%d, %d, %d, %d\n", width, height, complete, unk0);
- r->skip(roundup(remain));
+ _s->skip(roundup(remain));
return false;
}
- if (!zbuf)
+ if (!_zbuf)
{
if (!complete) {
- r->skip(roundup(remain));
+ _s->skip(roundup(remain));
return false;
}
- zbuf = new uint16[width * height];
+ _zbuf = new uint16[width * height];
}
- r->read(zbuf_chunk, roundup(remain));
+ _s->read(_zbufChunk, roundup(remain));
if (complete) {
- size_t zbuf_out_size;
- decompress_lzo1x(zbuf_chunk, remain, (uint8*)zbuf, &zbuf_out_size);
+ size_t zbufOutSize;
+ decompress_lzo1x(_zbufChunk, remain, (uint8*)_zbuf, &zbufOutSize);
} else {
- decodeZBUF_partial(zbuf_chunk, zbuf, remain);
+ decodeZBUF_partial(_zbufChunk, _zbuf, remain);
}
return true;
}
-bool VQADecoder::get_zbuf(uint16 *a_zbuf)
+bool VQADecoder::getZBUF(uint16 *zbuf)
{
- if (!zbuf)
+ if (!_zbuf)
return false;
- memcpy(a_zbuf, zbuf, 2 * header.width * header.height);
+ memcpy(zbuf, _zbuf, 2 * _header.width * _header.height);
return true;
}
-bool VQADecoder::read_view(uint32 size)
+bool VQADecoder::readVIEW(uint32 size)
{
if (size != 56)
return false;
- r->skip(size);
- // has_view = true;
+ _s->skip(size);
+ // _hasView = true;
return true;
}
-bool VQADecoder::read_aesc(uint32 size)
+bool VQADecoder::readAESC(uint32 size)
{
- r->skip(roundup(size));
+ _s->skip(roundup(size));
return true;
}
-bool VQADecoder::read_lite(uint32 size)
+bool VQADecoder::readLITE(uint32 size)
{
- r->skip(roundup(size));
+ _s->skip(roundup(size));
return true;
}
-bool VQADecoder::read_vptr(uint32 size)
+bool VQADecoder::readVPTR(uint32 size)
{
- if (size > header.maxVPTRSize)
+ if (size > _header.maxVPTRSize)
return false;
- if (!vptr)
- vptr = new uint8[roundup(header.maxVPTRSize)];
+ if (!_vptr)
+ _vptr = new uint8[roundup(_header.maxVPTRSize)];
- vptrSize = size;
- r->read(vptr, roundup(size));
+ _vptrSize = size;
+ _s->read(_vptr, roundup(size));
return true;
}
-void VQADecoder::vptr_write_block(uint16 *frame, unsigned int dst_block, unsigned int src_block, int count, bool alpha) const
+void VQADecoder::VPTRWriteBlock(uint16 *frame, unsigned int dstBlock, unsigned int srcBlock, int count, bool alpha) const
{
- uint16 frame_width = header.width;
+ uint16 frame_width = _header.width;
uint32 frame_stride = 640;
- uint16 block_width = header.blockW;
- uint16 block_height = header.blockH;
+ uint16 block_width = _header.blockW;
+ uint16 block_height = _header.blockH;
const uint8 *const block_src =
- &codebook[2 * src_block * block_width * block_height];
+ &_codebook[2 * srcBlock * block_width * block_height];
int blocks_per_line = frame_width / block_width;
do
{
- uint32 frame_x = dst_block % blocks_per_line * block_width + header.offset_x / 2;
- uint32 frame_y = dst_block / blocks_per_line * block_height + header.offset_y;
+ uint32 frame_x = dstBlock % blocks_per_line * block_width + _header.offset_x / 2;
+ uint32 frame_y = dstBlock / blocks_per_line * block_height + _header.offset_y;
uint32 dst_offset = frame_x + frame_y * frame_stride;
@@ -824,45 +823,45 @@ void VQADecoder::vptr_write_block(uint16 *frame, unsigned int dst_block, unsigne
dst += frame_stride - block_width;
}
- ++dst_block;
+ ++dstBlock;
}
while (--count);
}
-void VQADecoder::set_loop_special(int loop, bool wait)
+void VQADecoder::setLoopSpecial(int loop, bool wait)
{
- loop_special = loop;
+ _loopSpecial = loop;
if (!wait)
- cur_loop = -1;
+ _curLoop = -1;
}
-void VQADecoder::set_loop_default(int loop)
+void VQADecoder::setLoopDefault(int loop)
{
- loop_default = loop;
+ _loopDefault = loop;
}
-bool VQADecoder::seek_to_frame(int frame)
+bool VQADecoder::seekToFrame(int frame)
{
- if (frame < 0 || frame >= header.numFrames)
+ if (frame < 0 || frame >= _header.numFrames)
return false;
- r->seek(2 * (frame_info[frame] & 0x0fffffff), SEEK_SET);
+ _s->seek(2 * (_frameInfo[frame] & 0x0fffffff), SEEK_SET);
return true;
}
-bool VQADecoder::decode_frame(uint16 *a_frame)
+bool VQADecoder::decodeFrame(uint16 *frame)
{
- if (!codebook || !vptr)
+ if (!_codebook || !_vptr)
return false;
- if (!frame)
- frame = new uint16[header.width * header.height];
+ if (!_frame)
+ _frame = new uint16[_header.width * _header.height];
- uint8 *src = vptr;
- uint8 *end = vptr + vptrSize;
+ uint8 *src = _vptr;
+ uint8 *end = _vptr + _vptrSize;
- uint16 count, src_block, dst_block = 0;
- (void)src_block;
+ uint16 count, srcBlock, dstBlock = 0;
+ (void)srcBlock;
while (end - src >= 2)
{
@@ -874,58 +873,58 @@ bool VQADecoder::decode_frame(uint16 *a_frame)
{
case 0:
count = command & 0x1fff;
- dst_block += count;
+ dstBlock += count;
break;
case 1:
count = 2 * (((command >> 8) & 0x1f) + 1);
- src_block = command & 0x00ff;
+ srcBlock = command & 0x00ff;
- vptr_write_block(frame, dst_block, src_block, count);
- dst_block += count;
+ VPTRWriteBlock(_frame, dstBlock, srcBlock, count);
+ dstBlock += count;
break;
case 2:
count = 2 * (((command >> 8) & 0x1f) + 1);
- src_block = command & 0x00ff;
+ srcBlock = command & 0x00ff;
- vptr_write_block(frame, dst_block, src_block, 1);
- ++dst_block;
+ VPTRWriteBlock(_frame, dstBlock, srcBlock, 1);
+ ++dstBlock;
for (int i = 0; i < count; ++i)
{
- src_block = *src++;
- vptr_write_block(frame, dst_block, src_block, 1);
- ++dst_block;
+ srcBlock = *src++;
+ VPTRWriteBlock(_frame, dstBlock, srcBlock, 1);
+ ++dstBlock;
}
break;
case 3:
case 4:
count = 1;
- src_block = command & 0x1fff;
+ srcBlock = command & 0x1fff;
- vptr_write_block(frame, dst_block, src_block, count, prefix == 4);
- ++dst_block;
+ VPTRWriteBlock(_frame, dstBlock, srcBlock, count, prefix == 4);
+ ++dstBlock;
break;
case 5:
case 6:
count = *src++;
- src_block = command & 0x1fff;
+ srcBlock = command & 0x1fff;
- vptr_write_block(frame, dst_block, src_block, count, prefix == 6);
- dst_block += count;
+ VPTRWriteBlock(_frame, dstBlock, srcBlock, count, prefix == 6);
+ dstBlock += count;
break;
default:
debug("Undefined case %d\n", command >> 13);
}
}
- memcpy(a_frame, frame, 2 * 640 * 480);
+ memcpy(frame, _frame, 2 * 640 * 480);
return true;
}
-int16 *VQADecoder::get_audio_frame()
+int16 *VQADecoder::getAudioFrame()
{
- return audio_frame;
+ return _audioFrame;
}
}; // End of namespace BladeRunner
diff --git a/engines/bladerunner/vqa_decoder.h b/engines/bladerunner/vqa_decoder.h
index c4b5974f2a..cd0123e20a 100644
--- a/engines/bladerunner/vqa_decoder.h
+++ b/engines/bladerunner/vqa_decoder.h
@@ -29,6 +29,7 @@
#include "common/types.h"
namespace BladeRunner {
+
class VQADecoder
{
struct Header
@@ -70,94 +71,93 @@ class VQADecoder
struct LoopInfo
{
- uint16 loop_count;
+ uint16 loopCount;
uint32 flags;
- Loop *loops;
+ Loop *loops;
LoopInfo()
- : loop_count(0)
+ : loopCount(0)
{}
};
struct ClipInfo
{
- uint16 clip_count;
+ uint16 clipCount;
};
- Common::SeekableReadStream *r;
-
- Header header;
- LoopInfo loop_info;
- ClipInfo clip_info;
+ Common::SeekableReadStream *_s;
- uint16 *frame;
- uint16 *zbuf;
+ Header _header;
+ LoopInfo _loopInfo;
+ ClipInfo _clipInfo;
- size_t codebookSize;
- uint8 *codebook;
- uint8 *cbfz;
+ uint16 *_frame;
+ uint16 *_zbuf;
- size_t vptrSize;
- uint8 *vptr;
+ size_t _codebookSize;
+ uint8 *_codebook;
+ uint8 *_cbfz;
- uint32 *frame_info;
+ size_t _vptrSize;
+ uint8 *_vptr;
- int cur_frame;
+ uint32 *_frameInfo;
- int cur_loop;
- int loop_special;
- int loop_default;
+ int _curFrame;
+ int _curLoop;
+ int _loopSpecial;
+ int _loopDefault;
- uint32 max_view_chunk_size;
- uint32 max_zbuf_chunk_size;
- uint32 max_aesc_chunk_size;
- uint8 *zbuf_chunk;
+ uint32 _maxVIEWChunkSize;
+ uint32 _maxZBUFChunkSize;
+ uint32 _maxAESCChunkSize;
+ uint8 *_zbufChunk;
- bool has_view;
+ bool _hasView;
// view_t view;
// ima_adpcm_ws_decoder_t ima_adpcm_ws_decoder;
- int16 *audio_frame;
-
- bool read_vqhd(uint32 size);
- bool read_msci(uint32 size);
- bool read_mfci(uint32 size);
- bool read_linf(uint32 size);
- bool read_cinf(uint32 size);
- bool read_finf(uint32 size);
- bool read_lnin(uint32 size);
- bool read_clip(uint32 size);
-
- bool read_sn2j(uint32 size);
- bool read_snd2(uint32 size);
- bool read_vqfr(uint32 size);
- bool read_vptr(uint32 size);
- bool read_vqfl(uint32 size);
- bool read_cbfz(uint32 size);
- bool read_zbuf(uint32 size);
- bool read_view(uint32 size);
- bool read_aesc(uint32 size);
- bool read_lite(uint32 size);
+ int16 *_audioFrame;
+
+ bool readVQHD(uint32 size);
+ bool readMSCI(uint32 size);
+ bool readMFCI(uint32 size);
+ bool readLINF(uint32 size);
+ bool readCINF(uint32 size);
+ bool readFINF(uint32 size);
+ bool readLNIN(uint32 size);
+ bool readCLIP(uint32 size);
+
+ bool readSN2J(uint32 size);
+ bool readSND2(uint32 size);
+ bool readVQFR(uint32 size);
+ bool readVPTR(uint32 size);
+ bool readVQFL(uint32 size);
+ bool readCBFZ(uint32 size);
+ bool readZBUF(uint32 size);
+ bool readVIEW(uint32 size);
+ bool readAESC(uint32 size);
+ bool readLITE(uint32 size);
public:
VQADecoder(Common::SeekableReadStream *r);
~VQADecoder();
- bool read_header();
- int read_frame();
+ bool readHeader();
+ int readFrame();
- void vptr_write_block(uint16 *frame, unsigned int dst_block, unsigned int src_block, int count, bool alpha = false) const;
+ void VPTRWriteBlock(uint16 *frame, unsigned int dst_block, unsigned int src_block, int count, bool alpha = false) const;
- void set_loop_special(int loop, bool wait);
- void set_loop_default(int loop);
+ void setLoopSpecial(int loop, bool wait);
+ void setLoopDefault(int loop);
- bool seek_to_frame(int frame);
- bool decode_frame(uint16 *frame);
+ bool seekToFrame(int frame);
+ bool decodeFrame(uint16 *frame);
- int16 *get_audio_frame();
+ int16 *getAudioFrame();
// bool get_view(view_t *view);
- bool get_zbuf(uint16 *zbuf);
+ bool getZBUF(uint16 *zbuf);
};
}; // End of namespace BladeRunner