diff options
Diffstat (limited to 'engines/bladerunner/vqa_decoder.cpp')
-rw-r--r-- | engines/bladerunner/vqa_decoder.cpp | 79 |
1 files changed, 8 insertions, 71 deletions
diff --git a/engines/bladerunner/vqa_decoder.cpp b/engines/bladerunner/vqa_decoder.cpp index 15bf49306a..1e22257843 100644 --- a/engines/bladerunner/vqa_decoder.cpp +++ b/engines/bladerunner/vqa_decoder.cpp @@ -27,6 +27,7 @@ #include "bladerunner/decompress_lzo.h" #include "bladerunner/lights.h" #include "bladerunner/view.h" +#include "bladerunner/zbuffer.h" #include "audio/decoders/raw.h" @@ -191,8 +192,8 @@ const Graphics::Surface *VQADecoder::decodeVideoFrame() { return _videoTrack->decodeVideoFrame(); } -const uint16 *VQADecoder::decodeZBuffer() { - return _videoTrack->decodeZBuffer(); +void VQADecoder::decodeZBuffer(ZBuffer *zbuffer) { + _videoTrack->decodeZBuffer(zbuffer); } Audio::SeekableAudioStream *VQADecoder::decodeAudioFrame() { @@ -552,7 +553,6 @@ VQADecoder::VQAVideoTrack::VQAVideoTrack(VQADecoder *vqaDecoder) { _maxVPTRSize = header->maxVPTRSize; _maxCBFZSize = header->maxCBFZSize; _maxZBUFChunkSize = vqaDecoder->_maxZBUFChunkSize; - _zbuffer = nullptr; _codebookSize = 0; _codebook = nullptr; @@ -564,7 +564,6 @@ VQADecoder::VQAVideoTrack::VQAVideoTrack(VQADecoder *vqaDecoder) { _curFrame = -1; - _zbufChunk = new uint8[roundup(_maxZBUFChunkSize)]; _surface = new Graphics::Surface(); @@ -583,7 +582,6 @@ VQADecoder::VQAVideoTrack::~VQAVideoTrack() { if (_surface) _surface->free(); delete _surface; - delete[] _zbuffer; if (_viewData) delete[] _viewData; @@ -668,42 +666,6 @@ bool VQADecoder::VQAVideoTrack::readCBFZ(Common::SeekableReadStream *s, uint32 s return true; } -static int decodeZBUF_partial(uint8 *src, uint16 *curZBUF, uint32 srcLen) { - uint32 dstSize = 640 * 480; // This is taken from global variables? - uint32 dstRemain = dstSize; - - uint16 *curzp = curZBUF; - uint16 *inp = (uint16*)src; - - while (dstRemain && (inp - (uint16*)src) < (std::ptrdiff_t)srcLen) { - uint32 count = FROM_LE_16(*inp++); - - if (count & 0x8000) { - count = MIN(count & 0x7fff, dstRemain); - dstRemain -= count; - - while (count--) { - uint16 value = FROM_LE_16(*inp++); - if (value) - *curzp = value; - ++curzp; - } - } else { - count = MIN(count, dstRemain); - dstRemain -= count; - uint16 value = FROM_LE_16(*inp++); - - if (!value) { - curzp += count; - } else { - while (count--) - *curzp++ = value; - } - } - } - return dstSize - dstRemain; -} - bool VQADecoder::VQAVideoTrack::readZBUF(Common::SeekableReadStream *s, uint32 size) { if (size > _maxZBUFChunkSize) { debug("VQA ERROR: ZBUF chunk size: %08x > %08x", size, _maxZBUFChunkSize); @@ -711,42 +673,17 @@ bool VQADecoder::VQAVideoTrack::readZBUF(Common::SeekableReadStream *s, uint32 s return false; } - uint32 width, height, complete, unk0; - width = s->readUint32LE(); - height = s->readUint32LE(); - complete = s->readUint32LE(); - unk0 = s->readUint32LE(); - - uint32 remain = size - 16; - - if (_width != width || _height != height) { - debug("%d, %d, %d, %d", width, height, complete, unk0); - s->skip(roundup(remain)); - return false; - } - - _zbufChunkComplete = complete; - _zbufChunkSize = remain; - s->read(_zbufChunk, roundup(remain)); + _zbufChunkSize = size; + s->read(_zbufChunk, roundup(size)); return true; } -const uint16 *VQADecoder::VQAVideoTrack::decodeZBuffer() { +void VQADecoder::VQAVideoTrack::decodeZBuffer(ZBuffer *zbuffer) { if (_maxZBUFChunkSize == 0) - return nullptr; - - if (!_zbuffer) - _zbuffer = new uint16[_width * _height]; - - if (_zbufChunkComplete) { - size_t zbufOutSize; - decompress_lzo1x(_zbufChunk, _zbufChunkSize, (uint8*)_zbuffer, &zbufOutSize); - } else { - decodeZBUF_partial(_zbufChunk, _zbuffer, _zbufChunkSize); - } + return; - return _zbuffer; + zbuffer->decodeData(_zbufChunk, _zbufChunkSize); } bool VQADecoder::VQAVideoTrack::readVIEW(Common::SeekableReadStream *s, uint32 size) { |