diff options
author | Matthew Hoops | 2014-02-27 21:27:24 -0500 |
---|---|---|
committer | Matthew Hoops | 2014-02-28 00:27:37 -0500 |
commit | 08ea14a8d0e1a1478d1f486edeecea3e619e0cd0 (patch) | |
tree | 54e46574c82d1aa95c4cca2a16e31faae2e34aea | |
parent | e6717aaf43c7a25d426502a6d5d7028d50aab255 (diff) | |
download | scummvm-rg350-08ea14a8d0e1a1478d1f486edeecea3e619e0cd0.tar.gz scummvm-rg350-08ea14a8d0e1a1478d1f486edeecea3e619e0cd0.tar.bz2 scummvm-rg350-08ea14a8d0e1a1478d1f486edeecea3e619e0cd0.zip |
IMAGE: Make Codec take a stream reference; change function name to decodeFrame
30 files changed, 290 insertions, 291 deletions
diff --git a/image/codecs/cdtoons.cpp b/image/codecs/cdtoons.cpp index e1246a034f..6a2dc51b86 100644 --- a/image/codecs/cdtoons.cpp +++ b/image/codecs/cdtoons.cpp @@ -39,12 +39,12 @@ struct CDToonsDiff { Common::Rect rect; }; -static Common::Rect readRect(Common::SeekableReadStream *stream) { +static Common::Rect readRect(Common::SeekableReadStream &stream) { Common::Rect rect; - rect.top = stream->readUint16BE(); - rect.left = stream->readUint16BE(); - rect.bottom = stream->readUint16BE(); - rect.right = stream->readUint16BE(); + rect.top = stream.readUint16BE(); + rect.left = stream.readUint16BE(); + rect.bottom = stream.readUint16BE(); + rect.right = stream.readUint16BE(); return rect; } @@ -67,14 +67,14 @@ CDToonsDecoder::~CDToonsDecoder() { delete[] i->_value.data; } -Graphics::Surface *CDToonsDecoder::decodeImage(Common::SeekableReadStream *stream) { - uint16 u0 = stream->readUint16BE(); // always 9? - uint16 frameId = stream->readUint16BE(); - uint16 blocksValidUntil = stream->readUint16BE(); - byte u6 = stream->readByte(); - byte backgroundColor = stream->readByte(); +Graphics::Surface *CDToonsDecoder::decodeFrame(Common::SeekableReadStream &stream) { + uint16 u0 = stream.readUint16BE(); // always 9? + uint16 frameId = stream.readUint16BE(); + uint16 blocksValidUntil = stream.readUint16BE(); + byte u6 = stream.readByte(); + byte backgroundColor = stream.readByte(); debugN(5, "CDToons frame %d, size %d, unknown %04x (at 0), blocks valid until %d, unknown 6 is %02x, bkg color is %02x\n", - frameId, stream->size(), u0, blocksValidUntil, u6, backgroundColor); + frameId, stream.size(), u0, blocksValidUntil, u6, backgroundColor); Common::Rect clipRect = readRect(stream); debugN(9, "CDToons clipRect: (%d, %d) to (%d, %d)\n", @@ -84,31 +84,31 @@ Graphics::Surface *CDToonsDecoder::decodeImage(Common::SeekableReadStream *strea debugN(9, "CDToons dirtyRect: (%d, %d) to (%d, %d)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); - uint32 flags = stream->readUint32BE(); + uint32 flags = stream.readUint32BE(); if (flags & 0x80) error("CDToons: frame already processed?"); debugN(5, "CDToons flags: %08x\n", flags); - uint16 blockCount = stream->readUint16BE(); - uint16 blockOffset = stream->readUint16BE(); + uint16 blockCount = stream.readUint16BE(); + uint16 blockOffset = stream.readUint16BE(); debugN(9, "CDToons: %d blocks at 0x%04x\n", blockCount, blockOffset); // max block id? - uint16 u32 = stream->readUint16BE(); + uint16 u32 = stream.readUint16BE(); debugN(5, "CDToons unknown at 32: %04x\n", u32); - byte actionCount = stream->readByte(); - byte u35 = stream->readByte(); + byte actionCount = stream.readByte(); + byte u35 = stream.readByte(); - uint16 paletteId = stream->readUint16BE(); - byte paletteSet = stream->readByte(); + uint16 paletteId = stream.readUint16BE(); + byte paletteSet = stream.readByte(); debugN(9, "CDToons palette id %04x, palette byte %02x\n", paletteId, paletteSet); - byte u39 = stream->readByte(); - uint16 u40 = stream->readUint16BE(); - uint16 u42 = stream->readUint16BE(); + byte u39 = stream.readByte(); + uint16 u40 = stream.readUint16BE(); + uint16 u42 = stream.readUint16BE(); debugN(5, "CDToons: unknown at 35 is %02x, unknowns at 39: %02x, %04x, %04x\n", u35, u39, u40, u42); @@ -116,41 +116,41 @@ Graphics::Surface *CDToonsDecoder::decodeImage(Common::SeekableReadStream *strea for (uint i = 0; i < actionCount; i++) { CDToonsAction action; - action.blockId = stream->readUint16BE(); + action.blockId = stream.readUint16BE(); action.rect = readRect(stream); debugN(9, "CDToons action: render block %d at (%d, %d) to (%d, %d)\n", action.blockId, action.rect.left, action.rect.top, action.rect.right, action.rect.bottom); actions.push_back(action); } - if (stream->pos() > blockOffset) + if (stream.pos() > blockOffset) error("CDToons header ended at 0x%08x, but blocks should have started at 0x%08x", - stream->pos(), blockOffset); + stream.pos(), blockOffset); - if (stream->pos() != blockOffset) - error("CDToons had %d unknown bytes after header", blockOffset - stream->pos()); + if (stream.pos() != blockOffset) + error("CDToons had %d unknown bytes after header", blockOffset - stream.pos()); for (uint i = 0; i < blockCount; i++) { - uint16 blockId = stream->readUint16BE(); + uint16 blockId = stream.readUint16BE(); if (blockId >= 1200) error("CDToons: block id %d was too high", blockId); if (_blocks.contains(blockId)) error("CDToons: new block %d was already seen", blockId); CDToonsBlock block; - block.flags = stream->readUint16BE(); + block.flags = stream.readUint16BE(); // flag 1 = palette, flag 2 = data? if (block.flags & 0x8000) error("CDToons: block already processed?"); - block.size = stream->readUint32BE(); + block.size = stream.readUint32BE(); if (block.size < 14) error("CDToons: block size was %d, too small", block.size); block.size -= 14; - block.startFrame = stream->readUint16BE(); - block.endFrame = stream->readUint16BE(); - block.unknown12 = stream->readUint16BE(); + block.startFrame = stream.readUint16BE(); + block.endFrame = stream.readUint16BE(); + block.unknown12 = stream.readUint16BE(); block.data = new byte[block.size]; - stream->read(block.data, block.size); + stream.read(block.data, block.size); debugN(9, "CDToons block id 0x%04x of size 0x%08x, flags %04x, from frame %d to %d, unknown at 12 is %04x\n", blockId, block.size, block.flags, block.startFrame, block.endFrame, block.unknown12); @@ -162,16 +162,16 @@ Graphics::Surface *CDToonsDecoder::decodeImage(Common::SeekableReadStream *strea Common::Array<CDToonsDiff> diffs; while (true) { - int32 nextPos = stream->pos(); - uint32 tag = stream->readUint32BE(); - uint32 size = stream->readUint32BE(); + int32 nextPos = stream.pos(); + uint32 tag = stream.readUint32BE(); + uint32 size = stream.readUint32BE(); nextPos += size; switch (tag) { case MKTAG('D','i','f','f'): { debugN(5, "CDToons: Diff\n"); - uint16 count = stream->readUint16BE(); + uint16 count = stream.readUint16BE(); Common::Rect diffClipRect = readRect(stream); debugN(9, "CDToons diffClipRect: (%d, %d) to (%d, %d)\n", @@ -182,14 +182,14 @@ Graphics::Surface *CDToonsDecoder::decodeImage(Common::SeekableReadStream *strea CDToonsDiff diff; diff.rect = readRect(stream); - diff.size = stream->readUint32BE(); + diff.size = stream.readUint32BE(); if (diff.size < 20) error("CDToons: Diff block size was %d, too small", diff.size); - uint16 diffWidth = stream->readUint16BE(); - uint16 diffHeight = stream->readUint16BE(); - uint16 unknown16 = stream->readUint16BE(); - uint16 unknown18 = stream->readUint16BE(); + uint16 diffWidth = stream.readUint16BE(); + uint16 diffHeight = stream.readUint16BE(); + uint16 unknown16 = stream.readUint16BE(); + uint16 unknown18 = stream.readUint16BE(); diff.size -= 8; if (diffWidth != diff.rect.width() || diffHeight != diff.rect.height()) @@ -199,7 +199,7 @@ Graphics::Surface *CDToonsDecoder::decodeImage(Common::SeekableReadStream *strea unknown16, unknown18); diff.data = new byte[diff.size]; - stream->read(diff.data, diff.size); + stream.read(diff.data, diff.size); diffs.push_back(diff); } } @@ -212,8 +212,8 @@ Graphics::Surface *CDToonsDecoder::decodeImage(Common::SeekableReadStream *strea if (xFrmBegin) error("CDToons: duplicate XFrm"); - xFrmBegin = stream->readByte(); - xFrmCount = stream->readByte(); + xFrmBegin = stream.readByte(); + xFrmCount = stream.readByte(); debugN(9, "CDToons XFrm: run %d actions from %d\n", xFrmCount, xFrmBegin - 1); // TODO: don't ignore (if xFrmCount is non-zero) @@ -248,7 +248,7 @@ Graphics::Surface *CDToonsDecoder::decodeImage(Common::SeekableReadStream *strea if (!(flags & 0x40)) error("CDToons: useless FrtR?"); - uint16 count = stream->readUint16BE(); + uint16 count = stream.readUint16BE(); debugN(9, "CDToons FrtR: %d dirty rectangles\n", count); for (uint i = 0; i < count; i++) { Common::Rect dirtyRectFrtR = readRect(stream); @@ -263,7 +263,7 @@ Graphics::Surface *CDToonsDecoder::decodeImage(Common::SeekableReadStream *strea if (!(flags & 0x20)) error("CDToons: useless BckR?"); - uint16 count = stream->readUint16BE(); + uint16 count = stream.readUint16BE(); debugN(9, "CDToons BckR: %d subentries\n", count); for (uint i = 0; i < count; i++) { Common::Rect dirtyRectBckR = readRect(stream); @@ -276,15 +276,15 @@ Graphics::Surface *CDToonsDecoder::decodeImage(Common::SeekableReadStream *strea warning("Unknown CDToons tag '%s'", tag2str(tag)); } - if (stream->pos() > nextPos) + if (stream.pos() > nextPos) error("CDToons ran off the end of a block while reading it (at %d, next block at %d)", - stream->pos(), nextPos); - if (stream->pos() != nextPos) { - warning("CDToons had %d unknown bytes after block", nextPos - stream->pos()); - stream->seek(nextPos); + stream.pos(), nextPos); + if (stream.pos() != nextPos) { + warning("CDToons had %d unknown bytes after block", nextPos - stream.pos()); + stream.seek(nextPos); } - if (stream->pos() == stream->size()) + if (stream.pos() == stream.size()) break; } diff --git a/image/codecs/cdtoons.h b/image/codecs/cdtoons.h index ac569b5307..a75ce551c2 100644 --- a/image/codecs/cdtoons.h +++ b/image/codecs/cdtoons.h @@ -49,7 +49,7 @@ public: CDToonsDecoder(uint16 width, uint16 height); ~CDToonsDecoder(); - Graphics::Surface *decodeImage(Common::SeekableReadStream *stream); + Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream); Graphics::PixelFormat getPixelFormat() const { return Graphics::PixelFormat::createFormatCLUT8(); } bool containsPalette() const { return true; } const byte *getPalette() { _dirtyPalette = false; return _palette; } diff --git a/image/codecs/cinepak.cpp b/image/codecs/cinepak.cpp index 6af7ab08ff..8d5dbceb4a 100644 --- a/image/codecs/cinepak.cpp +++ b/image/codecs/cinepak.cpp @@ -83,13 +83,13 @@ CinepakDecoder::~CinepakDecoder() { delete[] _clipTableBuf; } -const Graphics::Surface *CinepakDecoder::decodeImage(Common::SeekableReadStream *stream) { - _curFrame.flags = stream->readByte(); - _curFrame.length = (stream->readByte() << 16); - _curFrame.length |= stream->readUint16BE(); - _curFrame.width = stream->readUint16BE(); - _curFrame.height = stream->readUint16BE(); - _curFrame.stripCount = stream->readUint16BE(); +const Graphics::Surface *CinepakDecoder::decodeFrame(Common::SeekableReadStream &stream) { + _curFrame.flags = stream.readByte(); + _curFrame.length = (stream.readByte() << 16); + _curFrame.length |= stream.readUint16BE(); + _curFrame.width = stream.readUint16BE(); + _curFrame.height = stream.readUint16BE(); + _curFrame.stripCount = stream.readUint16BE(); if (_curFrame.strips == NULL) _curFrame.strips = new CinepakStrip[_curFrame.stripCount]; @@ -98,11 +98,11 @@ const Graphics::Surface *CinepakDecoder::decodeImage(Common::SeekableReadStream // Borrowed from FFMPEG. This should cut out the extra data Cinepak for Sega has (which is useless). // The theory behind this is that this is here to confuse standard Cinepak decoders. But, we won't let that happen! ;) - if (_curFrame.length != (uint32)stream->size()) { - if (stream->readUint16BE() == 0xFE00) - stream->readUint32BE(); - else if ((stream->size() % _curFrame.length) == 0) - stream->seek(-2, SEEK_CUR); + if (_curFrame.length != (uint32)stream.size()) { + if (stream.readUint16BE() == 0xFE00) + stream.readUint32BE(); + else if ((stream.size() % _curFrame.length) == 0) + stream.seek(-2, SEEK_CUR); } if (!_curFrame.surface) { @@ -121,29 +121,29 @@ const Graphics::Surface *CinepakDecoder::decodeImage(Common::SeekableReadStream } } - _curFrame.strips[i].id = stream->readUint16BE(); - _curFrame.strips[i].length = stream->readUint16BE() - 12; // Subtract the 12 byte header - _curFrame.strips[i].rect.top = _y; stream->readUint16BE(); // Ignore, substitute with our own. - _curFrame.strips[i].rect.left = 0; stream->readUint16BE(); // Ignore, substitute with our own - _curFrame.strips[i].rect.bottom = _y + stream->readUint16BE(); - _curFrame.strips[i].rect.right = _curFrame.width; stream->readUint16BE(); // Ignore, substitute with our own + _curFrame.strips[i].id = stream.readUint16BE(); + _curFrame.strips[i].length = stream.readUint16BE() - 12; // Subtract the 12 byte header + _curFrame.strips[i].rect.top = _y; stream.readUint16BE(); // Ignore, substitute with our own. + _curFrame.strips[i].rect.left = 0; stream.readUint16BE(); // Ignore, substitute with our own + _curFrame.strips[i].rect.bottom = _y + stream.readUint16BE(); + _curFrame.strips[i].rect.right = _curFrame.width; stream.readUint16BE(); // Ignore, substitute with our own // Sanity check. Because Cinepak is based on 4x4 blocks, the width and height of each strip needs to be divisible by 4. assert(!(_curFrame.strips[i].rect.width() % 4) && !(_curFrame.strips[i].rect.height() % 4)); - uint32 pos = stream->pos(); + uint32 pos = stream.pos(); - while ((uint32)stream->pos() < (pos + _curFrame.strips[i].length) && !stream->eos()) { - byte chunkID = stream->readByte(); + while ((uint32)stream.pos() < (pos + _curFrame.strips[i].length) && !stream.eos()) { + byte chunkID = stream.readByte(); - if (stream->eos()) + if (stream.eos()) break; // Chunk Size is 24-bit, ignore the first 4 bytes - uint32 chunkSize = stream->readByte() << 16; - chunkSize += stream->readUint16BE() - 4; + uint32 chunkSize = stream.readByte() << 16; + chunkSize += stream.readUint16BE() - 4; - int32 startPos = stream->pos(); + int32 startPos = stream.pos(); switch (chunkID) { case 0x20: @@ -168,8 +168,8 @@ const Graphics::Surface *CinepakDecoder::decodeImage(Common::SeekableReadStream return _curFrame.surface; } - if (stream->pos() != startPos + (int32)chunkSize) - stream->seek(startPos + chunkSize); + if (stream.pos() != startPos + (int32)chunkSize) + stream.seek(startPos + chunkSize); } _y = _curFrame.strips[i].rect.bottom; @@ -178,32 +178,32 @@ const Graphics::Surface *CinepakDecoder::decodeImage(Common::SeekableReadStream return _curFrame.surface; } -void CinepakDecoder::loadCodebook(Common::SeekableReadStream *stream, uint16 strip, byte codebookType, byte chunkID, uint32 chunkSize) { +void CinepakDecoder::loadCodebook(Common::SeekableReadStream &stream, uint16 strip, byte codebookType, byte chunkID, uint32 chunkSize) { CinepakCodebook *codebook = (codebookType == 1) ? _curFrame.strips[strip].v1_codebook : _curFrame.strips[strip].v4_codebook; - int32 startPos = stream->pos(); + int32 startPos = stream.pos(); uint32 flag = 0, mask = 0; for (uint16 i = 0; i < 256; i++) { if ((chunkID & 0x01) && !(mask >>= 1)) { - if ((stream->pos() - startPos + 4) > (int32)chunkSize) + if ((stream.pos() - startPos + 4) > (int32)chunkSize) break; - flag = stream->readUint32BE(); + flag = stream.readUint32BE(); mask = 0x80000000; } if (!(chunkID & 0x01) || (flag & mask)) { byte n = (chunkID & 0x04) ? 4 : 6; - if ((stream->pos() - startPos + n) > (int32)chunkSize) + if ((stream.pos() - startPos + n) > (int32)chunkSize) break; for (byte j = 0; j < 4; j++) - codebook[i].y[j] = stream->readByte(); + codebook[i].y[j] = stream.readByte(); if (n == 6) { - codebook[i].u = stream->readSByte(); - codebook[i].v = stream->readSByte(); + codebook[i].u = stream.readSByte(); + codebook[i].v = stream.readSByte(); } else { // This codebook type indicates either greyscale or // palettized video. For greyscale, default us to @@ -215,10 +215,10 @@ void CinepakDecoder::loadCodebook(Common::SeekableReadStream *stream, uint16 str } } -void CinepakDecoder::decodeVectors(Common::SeekableReadStream *stream, uint16 strip, byte chunkID, uint32 chunkSize) { +void CinepakDecoder::decodeVectors(Common::SeekableReadStream &stream, uint16 strip, byte chunkID, uint32 chunkSize) { uint32 flag = 0, mask = 0; uint32 iy[4]; - int32 startPos = stream->pos(); + int32 startPos = stream.pos(); for (uint16 y = _curFrame.strips[strip].rect.top; y < _curFrame.strips[strip].rect.bottom; y += 4) { iy[0] = _curFrame.strips[strip].rect.left + y * _curFrame.width; @@ -228,28 +228,28 @@ void CinepakDecoder::decodeVectors(Common::SeekableReadStream *stream, uint16 st for (uint16 x = _curFrame.strips[strip].rect.left; x < _curFrame.strips[strip].rect.right; x += 4) { if ((chunkID & 0x01) && !(mask >>= 1)) { - if ((stream->pos() - startPos + 4) > (int32)chunkSize) + if ((stream.pos() - startPos + 4) > (int32)chunkSize) return; - flag = stream->readUint32BE(); + flag = stream.readUint32BE(); mask = 0x80000000; } if (!(chunkID & 0x01) || (flag & mask)) { if (!(chunkID & 0x02) && !(mask >>= 1)) { - if ((stream->pos() - startPos + 4) > (int32)chunkSize) + if ((stream.pos() - startPos + 4) > (int32)chunkSize) return; - flag = stream->readUint32BE(); + flag = stream.readUint32BE(); mask = 0x80000000; } if ((chunkID & 0x02) || (~flag & mask)) { - if ((stream->pos() - startPos + 1) > (int32)chunkSize) + if ((stream.pos() - startPos + 1) > (int32)chunkSize) return; // Get the codebook - CinepakCodebook codebook = _curFrame.strips[strip].v1_codebook[stream->readByte()]; + CinepakCodebook codebook = _curFrame.strips[strip].v1_codebook[stream.readByte()]; PUT_PIXEL(iy[0] + 0, codebook.y[0], codebook.u, codebook.v); PUT_PIXEL(iy[0] + 1, codebook.y[0], codebook.u, codebook.v); @@ -271,28 +271,28 @@ void CinepakDecoder::decodeVectors(Common::SeekableReadStream *stream, uint16 st PUT_PIXEL(iy[3] + 2, codebook.y[3], codebook.u, codebook.v); PUT_PIXEL(iy[3] + 3, codebook.y[3], codebook.u, codebook.v); } else if (flag & mask) { - if ((stream->pos() - startPos + 4) > (int32)chunkSize) + if ((stream.pos() - startPos + 4) > (int32)chunkSize) return; - CinepakCodebook codebook = _curFrame.strips[strip].v4_codebook[stream->readByte()]; + CinepakCodebook codebook = _curFrame.strips[strip].v4_codebook[stream.readByte()]; PUT_PIXEL(iy[0] + 0, codebook.y[0], codebook.u, codebook.v); PUT_PIXEL(iy[0] + 1, codebook.y[1], codebook.u, codebook.v); PUT_PIXEL(iy[1] + 0, codebook.y[2], codebook.u, codebook.v); PUT_PIXEL(iy[1] + 1, codebook.y[3], codebook.u, codebook.v); - codebook = _curFrame.strips[strip].v4_codebook[stream->readByte()]; + codebook = _curFrame.strips[strip].v4_codebook[stream.readByte()]; PUT_PIXEL(iy[0] + 2, codebook.y[0], codebook.u, codebook.v); PUT_PIXEL(iy[0] + 3, codebook.y[1], codebook.u, codebook.v); PUT_PIXEL(iy[1] + 2, codebook.y[2], codebook.u, codebook.v); PUT_PIXEL(iy[1] + 3, codebook.y[3], codebook.u, codebook.v); - codebook = _curFrame.strips[strip].v4_codebook[stream->readByte()]; + codebook = _curFrame.strips[strip].v4_codebook[stream.readByte()]; PUT_PIXEL(iy[2] + 0, codebook.y[0], codebook.u, codebook.v); PUT_PIXEL(iy[2] + 1, codebook.y[1], codebook.u, codebook.v); PUT_PIXEL(iy[3] + 0, codebook.y[2], codebook.u, codebook.v); PUT_PIXEL(iy[3] + 1, codebook.y[3], codebook.u, codebook.v); - codebook = _curFrame.strips[strip].v4_codebook[stream->readByte()]; + codebook = _curFrame.strips[strip].v4_codebook[stream.readByte()]; PUT_PIXEL(iy[2] + 2, codebook.y[0], codebook.u, codebook.v); PUT_PIXEL(iy[2] + 3, codebook.y[1], codebook.u, codebook.v); PUT_PIXEL(iy[3] + 2, codebook.y[2], codebook.u, codebook.v); diff --git a/image/codecs/cinepak.h b/image/codecs/cinepak.h index 99a316e428..985fc91165 100644 --- a/image/codecs/cinepak.h +++ b/image/codecs/cinepak.h @@ -71,7 +71,7 @@ public: CinepakDecoder(int bitsPerPixel = 24); ~CinepakDecoder(); - const Graphics::Surface *decodeImage(Common::SeekableReadStream *stream); + const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream); Graphics::PixelFormat getPixelFormat() const { return _pixelFormat; } private: @@ -80,8 +80,8 @@ private: Graphics::PixelFormat _pixelFormat; byte *_clipTable, *_clipTableBuf; - void loadCodebook(Common::SeekableReadStream *stream, uint16 strip, byte codebookType, byte chunkID, uint32 chunkSize); - void decodeVectors(Common::SeekableReadStream *stream, uint16 strip, byte chunkID, uint32 chunkSize); + void loadCodebook(Common::SeekableReadStream &stream, uint16 strip, byte codebookType, byte chunkID, uint32 chunkSize); + void decodeVectors(Common::SeekableReadStream &stream, uint16 strip, byte chunkID, uint32 chunkSize); }; } // End of namespace Image diff --git a/image/codecs/codec.h b/image/codecs/codec.h index 1b7a295e9d..092f9754f3 100644 --- a/image/codecs/codec.h +++ b/image/codecs/codec.h @@ -59,9 +59,8 @@ public: * containing the decoded frame. * * @return a pointer to the decoded frame - * @note stream is not deleted */ - virtual const Graphics::Surface *decodeImage(Common::SeekableReadStream *stream) = 0; + virtual const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream) = 0; /** * Get the format that the surface returned from decodeImage() will diff --git a/image/codecs/indeo3.cpp b/image/codecs/indeo3.cpp index 77bcec09bb..af9120ca93 100644 --- a/image/codecs/indeo3.cpp +++ b/image/codecs/indeo3.cpp @@ -165,24 +165,24 @@ void Indeo3Decoder::allocFrames() { } } -const Graphics::Surface *Indeo3Decoder::decodeImage(Common::SeekableReadStream *stream) { +const Graphics::Surface *Indeo3Decoder::decodeFrame(Common::SeekableReadStream &stream) { // Not Indeo 3? Fail - if (!isIndeo3(*stream)) + if (!isIndeo3(stream)) return 0; - stream->seek(12); - uint32 frameDataLen = stream->readUint32LE(); + stream.seek(12); + uint32 frameDataLen = stream.readUint32LE(); // Less data than the frame should have? Fail - if (stream->size() < (int)(frameDataLen - 16)) + if (stream.size() < (int)(frameDataLen - 16)) return 0; - stream->seek(16); // Behind header - stream->skip(2); // Unknown + stream.seek(16); // Behind header + stream.skip(2); // Unknown - uint16 flags1 = stream->readUint16LE(); - uint32 flags3 = stream->readUint32LE(); - uint8 flags2 = stream->readByte(); + uint16 flags1 = stream.readUint16LE(); + uint32 flags3 = stream.readUint32LE(); + uint8 flags2 = stream.readByte(); // Finding the reference frame if (flags1 & 0x200) { @@ -196,22 +196,22 @@ const Graphics::Surface *Indeo3Decoder::decodeImage(Common::SeekableReadStream * if (flags3 == 0x80) return _surface; - stream->skip(3); + stream.skip(3); - uint16 fHeight = stream->readUint16LE(); - uint16 fWidth = stream->readUint16LE(); + uint16 fHeight = stream.readUint16LE(); + uint16 fWidth = stream.readUint16LE(); uint32 chromaHeight = ((fHeight >> 2) + 3) & 0x7FFC; uint32 chromaWidth = ((fWidth >> 2) + 3) & 0x7FFC; uint32 offs; - uint32 offsY = stream->readUint32LE() + 16; - uint32 offsU = stream->readUint32LE() + 16; - uint32 offsV = stream->readUint32LE() + 16; + uint32 offsY = stream.readUint32LE() + 16; + uint32 offsU = stream.readUint32LE() + 16; + uint32 offsV = stream.readUint32LE() + 16; - stream->skip(4); + stream.skip(4); - uint32 hPos = stream->pos(); + uint32 hPos = stream.pos(); if (offsY < hPos) { warning("Indeo3Decoder::decodeImage: offsY < hPos"); @@ -226,11 +226,11 @@ const Graphics::Surface *Indeo3Decoder::decodeImage(Common::SeekableReadStream * return 0; } - uint32 dataSize = stream->size() - hPos; + uint32 dataSize = stream.size() - hPos; byte *inData = new byte[dataSize]; - if (stream->read(inData, dataSize) != dataSize) { + if (stream.read(inData, dataSize) != dataSize) { delete[] inData; return 0; } @@ -239,23 +239,23 @@ const Graphics::Surface *Indeo3Decoder::decodeImage(Common::SeekableReadStream * byte *buf_pos; // Luminance Y - stream->seek(offsY); + stream.seek(offsY); buf_pos = inData + offsY + 4 - hPos; - offs = stream->readUint32LE(); + offs = stream.readUint32LE(); decodeChunk(_cur_frame->Ybuf, _ref_frame->Ybuf, fWidth, fHeight, buf_pos + offs * 2, flags2, hdr_pos, buf_pos, MIN<int>(fWidth, 160)); // Chrominance U - stream->seek(offsU); + stream.seek(offsU); buf_pos = inData + offsU + 4 - hPos; - offs = stream->readUint32LE(); + offs = stream.readUint32LE(); decodeChunk(_cur_frame->Vbuf, _ref_frame->Vbuf, chromaWidth, chromaHeight, buf_pos + offs * 2, flags2, hdr_pos, buf_pos, MIN<int>(chromaWidth, 40)); // Chrominance V - stream->seek(offsV); + stream.seek(offsV); buf_pos = inData + offsV + 4 - hPos; - offs = stream->readUint32LE(); + offs = stream.readUint32LE(); decodeChunk(_cur_frame->Ubuf, _ref_frame->Ubuf, chromaWidth, chromaHeight, buf_pos + offs * 2, flags2, hdr_pos, buf_pos, MIN<int>(chromaWidth, 40)); diff --git a/image/codecs/indeo3.h b/image/codecs/indeo3.h index 275cbc1654..f1b406d40d 100644 --- a/image/codecs/indeo3.h +++ b/image/codecs/indeo3.h @@ -48,7 +48,7 @@ public: Indeo3Decoder(uint16 width, uint16 height); ~Indeo3Decoder(); - const Graphics::Surface *decodeImage(Common::SeekableReadStream *stream); + const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream); Graphics::PixelFormat getPixelFormat() const; static bool isIndeo3(Common::SeekableReadStream &stream); diff --git a/image/codecs/mjpeg.cpp b/image/codecs/mjpeg.cpp index aa7e1d0ec4..4ad72f259d 100644 --- a/image/codecs/mjpeg.cpp +++ b/image/codecs/mjpeg.cpp @@ -147,20 +147,20 @@ static const byte s_mjpegValACChrominance[] = { 0xf9, 0xfa }; -const Graphics::Surface *MJPEGDecoder::decodeImage(Common::SeekableReadStream *stream) { +const Graphics::Surface *MJPEGDecoder::decodeFrame(Common::SeekableReadStream &stream) { // We need to reconstruct an actual JPEG stream here, then feed it to the JPEG decoder // Yes, this is a pain. - stream->readUint32BE(); // Skip nonsense JPEG header - uint16 inputSkip = stream->readUint16BE() + 4; - uint32 tag = stream->readUint32BE(); + stream.readUint32BE(); // Skip nonsense JPEG header + uint16 inputSkip = stream.readUint16BE() + 4; + uint32 tag = stream.readUint32BE(); if (tag != MKTAG('A', 'V', 'I', '1')) { warning("Invalid MJPEG tag found"); return 0; } - uint32 outputSize = stream->size() - inputSkip + sizeof(s_jpegHeader) + DHT_SEGMENT_SIZE; + uint32 outputSize = stream.size() - inputSkip + sizeof(s_jpegHeader) + DHT_SEGMENT_SIZE; byte *data = (byte *)malloc(outputSize); if (!data) { @@ -193,8 +193,8 @@ const Graphics::Surface *MJPEGDecoder::decodeImage(Common::SeekableReadStream *s dataOffset += 162; // Write the actual data - stream->seek(inputSkip); - stream->read(data + dataOffset, stream->size() - inputSkip); + stream.seek(inputSkip); + stream.read(data + dataOffset, stream.size() - inputSkip); Common::MemoryReadStream convertedStream(data, outputSize, DisposeAfterUse::YES); JPEGDecoder jpeg; diff --git a/image/codecs/mjpeg.h b/image/codecs/mjpeg.h index b34b84b225..904b89d3ae 100644 --- a/image/codecs/mjpeg.h +++ b/image/codecs/mjpeg.h @@ -47,7 +47,7 @@ public: MJPEGDecoder(); ~MJPEGDecoder(); - const Graphics::Surface *decodeImage(Common::SeekableReadStream *stream); + const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream); Graphics::PixelFormat getPixelFormat() const { return _pixelFormat; } private: diff --git a/image/codecs/mpeg.cpp b/image/codecs/mpeg.cpp index d81123f26d..beb042dbf1 100644 --- a/image/codecs/mpeg.cpp +++ b/image/codecs/mpeg.cpp @@ -52,13 +52,13 @@ MPEGDecoder::~MPEGDecoder() { } } -const Graphics::Surface *MPEGDecoder::decodeImage(Common::SeekableReadStream *stream) { +const Graphics::Surface *MPEGDecoder::decodeFrame(Common::SeekableReadStream &stream) { uint32 framePeriod; decodePacket(stream, framePeriod); return _surface; } -bool MPEGDecoder::decodePacket(Common::SeekableReadStream *packet, uint32 &framePeriod, Graphics::Surface *dst) { +bool MPEGDecoder::decodePacket(Common::SeekableReadStream &packet, uint32 &framePeriod, Graphics::Surface *dst) { // Decode as much as we can out of this packet uint32 size = 0xFFFFFFFF; mpeg2_state_t state; @@ -70,7 +70,7 @@ bool MPEGDecoder::decodePacket(Common::SeekableReadStream *packet, uint32 &frame switch (state) { case STATE_BUFFER: - size = packet->read(_buffer, BUFFER_SIZE); + size = packet.read(_buffer, BUFFER_SIZE); mpeg2_buffer(_mpegDecoder, _buffer, _buffer + size); break; case STATE_SLICE: diff --git a/image/codecs/mpeg.h b/image/codecs/mpeg.h index b9e961cf24..7f231dd8b3 100644 --- a/image/codecs/mpeg.h +++ b/image/codecs/mpeg.h @@ -72,11 +72,11 @@ public: ~MPEGDecoder(); // Codec interface - const Graphics::Surface *decodeImage(Common::SeekableReadStream *stream); + const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream); Graphics::PixelFormat getPixelFormat() const { return _pixelFormat; } // MPEGPSDecoder call - bool decodePacket(Common::SeekableReadStream *packet, uint32 &framePeriod, Graphics::Surface *dst = 0); + bool decodePacket(Common::SeekableReadStream &packet, uint32 &framePeriod, Graphics::Surface *dst = 0); private: Graphics::PixelFormat _pixelFormat; diff --git a/image/codecs/msrle.cpp b/image/codecs/msrle.cpp index 951de83c31..89fe869a9e 100644 --- a/image/codecs/msrle.cpp +++ b/image/codecs/msrle.cpp @@ -39,7 +39,7 @@ MSRLEDecoder::~MSRLEDecoder() { delete _surface; } -const Graphics::Surface *MSRLEDecoder::decodeImage(Common::SeekableReadStream *stream) { +const Graphics::Surface *MSRLEDecoder::decodeFrame(Common::SeekableReadStream &stream) { if (_bitsPerPixel == 8) { decode8(stream); } else @@ -48,7 +48,7 @@ const Graphics::Surface *MSRLEDecoder::decodeImage(Common::SeekableReadStream *s return _surface; } -void MSRLEDecoder::decode8(Common::SeekableReadStream *stream) { +void MSRLEDecoder::decode8(Common::SeekableReadStream &stream) { int x = 0; int y = _surface->h - 1; @@ -60,9 +60,9 @@ void MSRLEDecoder::decode8(Common::SeekableReadStream *stream) { byte *output = data + ((height - 1) * width); byte *output_end = data + ((height) * width); - while (!stream->eos()) { - byte count = stream->readByte(); - byte value = stream->readByte(); + while (!stream.eos()) { + byte count = stream.readByte(); + byte value = stream.readByte(); if (count == 0) { if (value == 0) { @@ -84,8 +84,8 @@ void MSRLEDecoder::decode8(Common::SeekableReadStream *stream) { } else if (value == 2) { // Skip - count = stream->readByte(); - value = stream->readByte(); + count = stream.readByte(); + value = stream.readByte(); y -= value; x += count; @@ -101,15 +101,15 @@ void MSRLEDecoder::decode8(Common::SeekableReadStream *stream) { // Copy data if (output + value > output_end) { - stream->skip(value); + stream.skip(value); continue; } for (int i = 0; i < value; i++) - *output++ = stream->readByte(); + *output++ = stream.readByte(); if (value & 1) - stream->skip(1); + stream.skip(1); x += value; } diff --git a/image/codecs/msrle.h b/image/codecs/msrle.h index 10e3531c07..a65ef1c41d 100644 --- a/image/codecs/msrle.h +++ b/image/codecs/msrle.h @@ -38,7 +38,7 @@ public: MSRLEDecoder(uint16 width, uint16 height, byte bitsPerPixel); ~MSRLEDecoder(); - const Graphics::Surface *decodeImage(Common::SeekableReadStream *stream); + const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream); Graphics::PixelFormat getPixelFormat() const { return Graphics::PixelFormat::createFormatCLUT8(); } private: @@ -46,7 +46,7 @@ private: Graphics::Surface *_surface; - void decode8(Common::SeekableReadStream *stream); + void decode8(Common::SeekableReadStream &stream); }; } // End of namespace Image diff --git a/image/codecs/msvideo1.cpp b/image/codecs/msvideo1.cpp index e94afedb2d..25d7395363 100644 --- a/image/codecs/msvideo1.cpp +++ b/image/codecs/msvideo1.cpp @@ -29,8 +29,8 @@ namespace Image { #define CHECK_STREAM_PTR(n) \ - if ((stream->pos() + n) > stream->size() ) { \ - warning ("MS Video-1: Stream out of bounds (%d >= %d)", stream->pos() + n, stream->size()); \ + if ((stream.pos() + n) > stream.size() ) { \ + warning ("MS Video-1: Stream out of bounds (%d >= %d)", stream.pos() + n, stream.size()); \ return; \ } @@ -46,7 +46,7 @@ MSVideo1Decoder::~MSVideo1Decoder() { delete _surface; } -void MSVideo1Decoder::decode8(Common::SeekableReadStream *stream) { +void MSVideo1Decoder::decode8(Common::SeekableReadStream &stream) { byte colors[8]; byte *pixels = (byte *)_surface->getPixels(); uint16 stride = _surface->w; @@ -73,8 +73,8 @@ void MSVideo1Decoder::decode8(Common::SeekableReadStream *stream) { /* get the next two bytes in the encoded data stream */ CHECK_STREAM_PTR(2); - byte byte_a = stream->readByte(); - byte byte_b = stream->readByte(); + byte byte_a = stream.readByte(); + byte byte_b = stream.readByte(); /* check if the decode is finished */ if (byte_a == 0 && byte_b == 0 && totalBlocks == 0) { @@ -87,8 +87,8 @@ void MSVideo1Decoder::decode8(Common::SeekableReadStream *stream) { uint16 flags = (byte_b << 8) | byte_a; CHECK_STREAM_PTR(2); - colors[0] = stream->readByte(); - colors[1] = stream->readByte(); + colors[0] = stream.readByte(); + colors[1] = stream.readByte(); for (byte pixel_y = 0; pixel_y < 4; pixel_y++) { for (byte pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1) @@ -101,7 +101,7 @@ void MSVideo1Decoder::decode8(Common::SeekableReadStream *stream) { CHECK_STREAM_PTR(8); for (byte i = 0; i < 8; i++) - colors[i] = stream->readByte(); + colors[i] = stream.readByte(); for (byte pixel_y = 0; pixel_y < 4; pixel_y++) { for (byte pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1) @@ -125,7 +125,7 @@ void MSVideo1Decoder::decode8(Common::SeekableReadStream *stream) { } } -const Graphics::Surface *MSVideo1Decoder::decodeImage(Common::SeekableReadStream *stream) { +const Graphics::Surface *MSVideo1Decoder::decodeFrame(Common::SeekableReadStream &stream) { if (_bitsPerPixel == 8) decode8(stream); else { diff --git a/image/codecs/msvideo1.h b/image/codecs/msvideo1.h index 517936d35b..bdee5acbe5 100644 --- a/image/codecs/msvideo1.h +++ b/image/codecs/msvideo1.h @@ -38,7 +38,7 @@ public: MSVideo1Decoder(uint16 width, uint16 height, byte bitsPerPixel); ~MSVideo1Decoder(); - const Graphics::Surface *decodeImage(Common::SeekableReadStream *stream); + const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream); Graphics::PixelFormat getPixelFormat() const { return Graphics::PixelFormat::createFormatCLUT8(); } private: @@ -46,8 +46,8 @@ private: Graphics::Surface *_surface; - void decode8(Common::SeekableReadStream *stream); - //void decode16(Common::SeekableReadStream *stream); + void decode8(Common::SeekableReadStream &stream); + //void decode16(Common::SeekableReadStream &stream); }; } // End of namespace Image diff --git a/image/codecs/qtrle.cpp b/image/codecs/qtrle.cpp index a609e9bba9..94744efa5a 100644 --- a/image/codecs/qtrle.cpp +++ b/image/codecs/qtrle.cpp @@ -48,8 +48,8 @@ QTRLEDecoder::QTRLEDecoder(uint16 width, uint16 height, byte bitsPerPixel) : Cod } #define CHECK_STREAM_PTR(n) \ - if ((stream->pos() + n) > stream->size()) { \ - warning("QTRLE Problem: stream out of bounds (%d > %d)", stream->pos() + n, stream->size()); \ + if ((stream.pos() + n) > stream.size()) { \ + warning("QTRLE Problem: stream out of bounds (%d > %d)", stream.pos() + n, stream.size()); \ return; \ } @@ -59,14 +59,14 @@ QTRLEDecoder::QTRLEDecoder(uint16 width, uint16 height, byte bitsPerPixel) : Cod return; \ } \ -void QTRLEDecoder::decode1(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange) { +void QTRLEDecoder::decode1(Common::SeekableReadStream &stream, uint32 rowPtr, uint32 linesToChange) { uint32 pixelPtr = 0; byte *rgb = (byte *)_surface->getPixels(); while (linesToChange) { CHECK_STREAM_PTR(2); - byte skip = stream->readByte(); - int8 rleCode = stream->readSByte(); + byte skip = stream.readByte(); + int8 rleCode = stream.readSByte(); if (rleCode == 0) break; @@ -83,8 +83,8 @@ void QTRLEDecoder::decode1(Common::SeekableReadStream *stream, uint32 rowPtr, ui rleCode = -rleCode; // get the next 2 bytes from the stream, treat them as groups of 8 pixels, and output them rleCode times */ CHECK_STREAM_PTR(2); - byte pi0 = stream->readByte(); - byte pi1 = stream->readByte(); + byte pi0 = stream.readByte(); + byte pi1 = stream.readByte(); CHECK_PIXEL_PTR(rleCode * 2); while (rleCode--) { @@ -98,25 +98,25 @@ void QTRLEDecoder::decode1(Common::SeekableReadStream *stream, uint32 rowPtr, ui CHECK_PIXEL_PTR(rleCode); while (rleCode--) - rgb[pixelPtr++] = stream->readByte(); + rgb[pixelPtr++] = stream.readByte(); } } } -void QTRLEDecoder::decode2_4(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange, byte bpp) { +void QTRLEDecoder::decode2_4(Common::SeekableReadStream &stream, uint32 rowPtr, uint32 linesToChange, byte bpp) { uint32 pixelPtr = 0; byte *rgb = (byte *)_surface->getPixels(); byte numPixels = (bpp == 4) ? 8 : 16; while (linesToChange--) { CHECK_STREAM_PTR(2); - pixelPtr = rowPtr + (numPixels * (stream->readByte() - 1)); + pixelPtr = rowPtr + (numPixels * (stream.readByte() - 1)); - for (int8 rleCode = stream->readSByte(); rleCode != -1; rleCode = stream->readSByte()) { + for (int8 rleCode = stream.readSByte(); rleCode != -1; rleCode = stream.readSByte()) { if (rleCode == 0) { // there's another skip code in the stream CHECK_STREAM_PTR(1); - pixelPtr += (numPixels * (stream->readByte() - 1)); + pixelPtr += (numPixels * (stream.readByte() - 1)); } else if (rleCode < 0) { // decode the run length code rleCode = -rleCode; @@ -127,10 +127,10 @@ void QTRLEDecoder::decode2_4(Common::SeekableReadStream *stream, uint32 rowPtr, byte pi[16]; // 16 palette indices for (int8 i = numPixels - 1; i >= 0; i--) { - pi[numPixels - 1 - i] = (stream->readByte() >> ((i * bpp) & 0x07)) & ((1 << bpp) - 1); + pi[numPixels - 1 - i] = (stream.readByte() >> ((i * bpp) & 0x07)) & ((1 << bpp) - 1); if ((i & ((numPixels >> 2) - 1)) == 0) - stream->readByte(); + stream.readByte(); } CHECK_PIXEL_PTR(rleCode * numPixels); @@ -145,7 +145,7 @@ void QTRLEDecoder::decode2_4(Common::SeekableReadStream *stream, uint32 rowPtr, CHECK_PIXEL_PTR(rleCode * (numPixels >> 2)); while (rleCode--) { - byte temp = stream->readByte(); + byte temp = stream.readByte(); if (bpp == 4) { rgb[pixelPtr++] = (temp >> 4) & 0x0f; rgb[pixelPtr++] = temp & 0x0f; @@ -163,19 +163,19 @@ void QTRLEDecoder::decode2_4(Common::SeekableReadStream *stream, uint32 rowPtr, } } -void QTRLEDecoder::decode8(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange) { +void QTRLEDecoder::decode8(Common::SeekableReadStream &stream, uint32 rowPtr, uint32 linesToChange) { uint32 pixelPtr = 0; byte *rgb = (byte *)_surface->getPixels(); while (linesToChange--) { CHECK_STREAM_PTR(2); - pixelPtr = rowPtr + 4 * (stream->readByte() - 1); + pixelPtr = rowPtr + 4 * (stream.readByte() - 1); - for (int8 rleCode = stream->readSByte(); rleCode != -1; rleCode = stream->readSByte()) { + for (int8 rleCode = stream.readSByte(); rleCode != -1; rleCode = stream.readSByte()) { if (rleCode == 0) { // there's another skip code in the stream CHECK_STREAM_PTR(1); - pixelPtr += 4 * (stream->readByte() - 1); + pixelPtr += 4 * (stream.readByte() - 1); } else if (rleCode < 0) { // decode the run length code rleCode = -rleCode; @@ -186,7 +186,7 @@ void QTRLEDecoder::decode8(Common::SeekableReadStream *stream, uint32 rowPtr, ui byte pi[4]; // 4 palette indexes for (byte i = 0; i < 4; i++) - pi[i] = stream->readByte(); + pi[i] = stream.readByte(); CHECK_PIXEL_PTR(rleCode * 4); @@ -200,7 +200,7 @@ void QTRLEDecoder::decode8(Common::SeekableReadStream *stream, uint32 rowPtr, ui CHECK_PIXEL_PTR(rleCode); while (rleCode--) - rgb[pixelPtr++] = stream->readByte(); + rgb[pixelPtr++] = stream.readByte(); } } @@ -208,25 +208,25 @@ void QTRLEDecoder::decode8(Common::SeekableReadStream *stream, uint32 rowPtr, ui } } -void QTRLEDecoder::decode16(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange) { +void QTRLEDecoder::decode16(Common::SeekableReadStream &stream, uint32 rowPtr, uint32 linesToChange) { uint32 pixelPtr = 0; uint16 *rgb = (uint16 *)_surface->getPixels(); while (linesToChange--) { CHECK_STREAM_PTR(2); - pixelPtr = rowPtr + stream->readByte() - 1; + pixelPtr = rowPtr + stream.readByte() - 1; - for (int8 rleCode = stream->readSByte(); rleCode != -1; rleCode = stream->readSByte()) { + for (int8 rleCode = stream.readSByte(); rleCode != -1; rleCode = stream.readSByte()) { if (rleCode == 0) { // there's another skip code in the stream CHECK_STREAM_PTR(1); - pixelPtr += stream->readByte() - 1; + pixelPtr += stream.readByte() - 1; } else if (rleCode < 0) { // decode the run length code rleCode = -rleCode; CHECK_STREAM_PTR(2); - uint16 rgb16 = stream->readUint16BE(); + uint16 rgb16 = stream.readUint16BE(); CHECK_PIXEL_PTR(rleCode); @@ -238,7 +238,7 @@ void QTRLEDecoder::decode16(Common::SeekableReadStream *stream, uint32 rowPtr, u // copy pixels directly to output while (rleCode--) - rgb[pixelPtr++] = stream->readUint16BE(); + rgb[pixelPtr++] = stream.readUint16BE(); } } @@ -246,28 +246,28 @@ void QTRLEDecoder::decode16(Common::SeekableReadStream *stream, uint32 rowPtr, u } } -void QTRLEDecoder::decode24(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange) { +void QTRLEDecoder::decode24(Common::SeekableReadStream &stream, uint32 rowPtr, uint32 linesToChange) { uint32 pixelPtr = 0; uint32 *rgb = (uint32 *)_surface->getPixels(); while (linesToChange--) { CHECK_STREAM_PTR(2); - pixelPtr = rowPtr + stream->readByte() - 1; + pixelPtr = rowPtr + stream.readByte() - 1; - for (int8 rleCode = stream->readSByte(); rleCode != -1; rleCode = stream->readSByte()) { + for (int8 rleCode = stream.readSByte(); rleCode != -1; rleCode = stream.readSByte()) { if (rleCode == 0) { // there's another skip code in the stream CHECK_STREAM_PTR(1); - pixelPtr += stream->readByte() - 1; + pixelPtr += stream.readByte() - 1; } else if (rleCode < 0) { // decode the run length code rleCode = -rleCode; CHECK_STREAM_PTR(3); - byte r = stream->readByte(); - byte g = stream->readByte(); - byte b = stream->readByte(); + byte r = stream.readByte(); + byte g = stream.readByte(); + byte b = stream.readByte(); uint32 color = _surface->format.RGBToColor(r, g, b); CHECK_PIXEL_PTR(rleCode); @@ -280,9 +280,9 @@ void QTRLEDecoder::decode24(Common::SeekableReadStream *stream, uint32 rowPtr, u // copy pixels directly to output while (rleCode--) { - byte r = stream->readByte(); - byte g = stream->readByte(); - byte b = stream->readByte(); + byte r = stream.readByte(); + byte g = stream.readByte(); + byte b = stream.readByte(); rgb[pixelPtr++] = _surface->format.RGBToColor(r, g, b); } } @@ -292,29 +292,29 @@ void QTRLEDecoder::decode24(Common::SeekableReadStream *stream, uint32 rowPtr, u } } -void QTRLEDecoder::decode32(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange) { +void QTRLEDecoder::decode32(Common::SeekableReadStream &stream, uint32 rowPtr, uint32 linesToChange) { uint32 pixelPtr = 0; uint32 *rgb = (uint32 *)_surface->getPixels(); while (linesToChange--) { CHECK_STREAM_PTR(2); - pixelPtr = rowPtr + stream->readByte() - 1; + pixelPtr = rowPtr + stream.readByte() - 1; - for (int8 rleCode = stream->readSByte(); rleCode != -1; rleCode = stream->readSByte()) { + for (int8 rleCode = stream.readSByte(); rleCode != -1; rleCode = stream.readSByte()) { if (rleCode == 0) { // there's another skip code in the stream CHECK_STREAM_PTR(1); - pixelPtr += stream->readByte() - 1; + pixelPtr += stream.readByte() - 1; } else if (rleCode < 0) { // decode the run length code rleCode = -rleCode; CHECK_STREAM_PTR(4); - byte a = stream->readByte(); - byte r = stream->readByte(); - byte g = stream->readByte(); - byte b = stream->readByte(); + byte a = stream.readByte(); + byte r = stream.readByte(); + byte g = stream.readByte(); + byte b = stream.readByte(); uint32 color = _surface->format.ARGBToColor(a, r, g, b); CHECK_PIXEL_PTR(rleCode); @@ -327,10 +327,10 @@ void QTRLEDecoder::decode32(Common::SeekableReadStream *stream, uint32 rowPtr, u // copy pixels directly to output while (rleCode--) { - byte a = stream->readByte(); - byte r = stream->readByte(); - byte g = stream->readByte(); - byte b = stream->readByte(); + byte a = stream.readByte(); + byte r = stream.readByte(); + byte g = stream.readByte(); + byte b = stream.readByte(); rgb[pixelPtr++] = _surface->format.ARGBToColor(a, r, g, b); } } @@ -340,29 +340,29 @@ void QTRLEDecoder::decode32(Common::SeekableReadStream *stream, uint32 rowPtr, u } } -const Graphics::Surface *QTRLEDecoder::decodeImage(Common::SeekableReadStream *stream) { +const Graphics::Surface *QTRLEDecoder::decodeFrame(Common::SeekableReadStream &stream) { uint16 startLine = 0; uint16 height = _surface->h; // check if this frame is even supposed to change - if (stream->size() < 8) + if (stream.size() < 8) return _surface; // start after the chunk size - stream->readUint32BE(); + stream.readUint32BE(); // fetch the header - uint16 header = stream->readUint16BE(); + uint16 header = stream.readUint16BE(); // if a header is present, fetch additional decoding parameters if (header & 8) { - if (stream->size() < 14) + if (stream.size() < 14) return _surface; - startLine = stream->readUint16BE(); - stream->readUint16BE(); // Unknown - height = stream->readUint16BE(); - stream->readUint16BE(); // Unknown + startLine = stream.readUint16BE(); + stream.readUint16BE(); // Unknown + height = stream.readUint16BE(); + stream.readUint16BE(); // Unknown } uint32 rowPtr = _surface->w * startLine; diff --git a/image/codecs/qtrle.h b/image/codecs/qtrle.h index c16daa0349..7ef89537cf 100644 --- a/image/codecs/qtrle.h +++ b/image/codecs/qtrle.h @@ -39,7 +39,7 @@ public: QTRLEDecoder(uint16 width, uint16 height, byte bitsPerPixel); ~QTRLEDecoder(); - const Graphics::Surface *decodeImage(Common::SeekableReadStream *stream); + const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream); Graphics::PixelFormat getPixelFormat() const; private: @@ -47,12 +47,12 @@ private: Graphics::Surface *_surface; - void decode1(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange); - void decode2_4(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange, byte bpp); - void decode8(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange); - void decode16(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange); - void decode24(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange); - void decode32(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange); + void decode1(Common::SeekableReadStream &stream, uint32 rowPtr, uint32 linesToChange); + void decode2_4(Common::SeekableReadStream &stream, uint32 rowPtr, uint32 linesToChange, byte bpp); + void decode8(Common::SeekableReadStream &stream, uint32 rowPtr, uint32 linesToChange); + void decode16(Common::SeekableReadStream &stream, uint32 rowPtr, uint32 linesToChange); + void decode24(Common::SeekableReadStream &stream, uint32 rowPtr, uint32 linesToChange); + void decode32(Common::SeekableReadStream &stream, uint32 rowPtr, uint32 linesToChange); }; } // End of namespace Image diff --git a/image/codecs/rpza.cpp b/image/codecs/rpza.cpp index ecd930f785..5aeee7c90b 100644 --- a/image/codecs/rpza.cpp +++ b/image/codecs/rpza.cpp @@ -61,7 +61,7 @@ RPZADecoder::~RPZADecoder() { WRITE_UINT16((uint16 *)_surface->getPixels() + blockPtr, color); \ blockPtr++ -const Graphics::Surface *RPZADecoder::decodeImage(Common::SeekableReadStream *stream) { +const Graphics::Surface *RPZADecoder::decodeFrame(Common::SeekableReadStream &stream) { uint16 colorA = 0, colorB = 0; uint16 color4[4]; @@ -73,40 +73,40 @@ const Graphics::Surface *RPZADecoder::decodeImage(Common::SeekableReadStream *st uint16 tb; // First byte is always 0xe1. Warn if it's different - byte firstByte = stream->readByte(); + byte firstByte = stream.readByte(); if (firstByte != 0xe1) warning("First RPZA chunk byte is 0x%02x instead of 0xe1", firstByte); // Get chunk size, ingnoring first byte - uint32 chunkSize = stream->readUint16BE() << 8; - chunkSize += stream->readByte(); + uint32 chunkSize = stream.readUint16BE() << 8; + chunkSize += stream.readByte(); // If length mismatch use size from MOV file and try to decode anyway - if (chunkSize != (uint32)stream->size()) { + if (chunkSize != (uint32)stream.size()) { warning("MOV chunk size != encoded chunk size; using MOV chunk size"); - chunkSize = stream->size(); + chunkSize = stream.size(); } // Number of 4x4 blocks in frame int32 totalBlocks = ((_surface->w + 3) / 4) * ((_surface->h + 3) / 4); // Process chunk data - while ((uint32)stream->pos() < chunkSize) { - byte opcode = stream->readByte(); // Get opcode + while ((uint32)stream.pos() < chunkSize) { + byte opcode = stream.readByte(); // Get opcode byte numBlocks = (opcode & 0x1f) + 1; // Extract block counter from opcode // If opcode MSbit is 0, we need more data to decide what to do if ((opcode & 0x80) == 0) { - colorA = (opcode << 8) | stream->readByte(); + colorA = (opcode << 8) | stream.readByte(); opcode = 0; - if (stream->readByte() & 0x80) { + if (stream.readByte() & 0x80) { // Must behave as opcode 110xxxxx, using colorA computed // above. Use fake opcode 0x20 to enter switch block at // the right place opcode = 0x20; numBlocks = 1; } - stream->seek(-1, SEEK_CUR); + stream.seek(-1, SEEK_CUR); } switch (opcode & 0xe0) { @@ -116,7 +116,7 @@ const Graphics::Surface *RPZADecoder::decodeImage(Common::SeekableReadStream *st } break; case 0xa0: // Fill blocks with one color - colorA = stream->readUint16BE(); + colorA = stream.readUint16BE(); while (numBlocks--) { blockPtr = rowPtr + pixelPtr; for (byte pixel_y = 0; pixel_y < 4; pixel_y++) { @@ -131,9 +131,9 @@ const Graphics::Surface *RPZADecoder::decodeImage(Common::SeekableReadStream *st // Fill blocks with 4 colors case 0xc0: - colorA = stream->readUint16BE(); + colorA = stream.readUint16BE(); case 0x20: - colorB = stream->readUint16BE(); + colorB = stream.readUint16BE(); // Sort out the colors color4[0] = colorB; @@ -162,7 +162,7 @@ const Graphics::Surface *RPZADecoder::decodeImage(Common::SeekableReadStream *st while (numBlocks--) { blockPtr = rowPtr + pixelPtr; for (byte pixel_y = 0; pixel_y < 4; pixel_y++) { - byte index = stream->readByte(); + byte index = stream.readByte(); for (byte pixel_x = 0; pixel_x < 4; pixel_x++) { byte idx = (index >> (2 * (3 - pixel_x))) & 0x03; PUT_PIXEL(color4[idx]); @@ -180,7 +180,7 @@ const Graphics::Surface *RPZADecoder::decodeImage(Common::SeekableReadStream *st for (byte pixel_x = 0; pixel_x < 4; pixel_x++) { // We already have color of upper left pixel if (pixel_y != 0 || pixel_x != 0) - colorA = stream->readUint16BE(); + colorA = stream.readUint16BE(); PUT_PIXEL(colorA); } diff --git a/image/codecs/rpza.h b/image/codecs/rpza.h index f87ee1113a..62f4c02df5 100644 --- a/image/codecs/rpza.h +++ b/image/codecs/rpza.h @@ -39,7 +39,7 @@ public: RPZADecoder(uint16 width, uint16 height); ~RPZADecoder(); - const Graphics::Surface *decodeImage(Common::SeekableReadStream *stream); + const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream); Graphics::PixelFormat getPixelFormat() const { return Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); } private: diff --git a/image/codecs/smc.cpp b/image/codecs/smc.cpp index 434a1058b7..54493d0c34 100644 --- a/image/codecs/smc.cpp +++ b/image/codecs/smc.cpp @@ -29,7 +29,7 @@ namespace Image { #define GET_BLOCK_COUNT() \ - (opcode & 0x10) ? (1 + stream->readByte()) : 1 + (opcode & 0x0F); + (opcode & 0x10) ? (1 + stream.readByte()) : 1 + (opcode & 0x0F); #define ADVANCE_BLOCK() \ { \ @@ -55,7 +55,7 @@ SMCDecoder::~SMCDecoder() { delete _surface; } -const Graphics::Surface *SMCDecoder::decodeImage(Common::SeekableReadStream *stream) { +const Graphics::Surface *SMCDecoder::decodeFrame(Common::SeekableReadStream &stream) { byte *pixels = (byte *)_surface->getPixels(); uint32 numBlocks = 0; @@ -77,9 +77,9 @@ const Graphics::Surface *SMCDecoder::decodeImage(Common::SeekableReadStream *str uint32 colorOctetIndex = 0; uint32 colorTableIndex = 0; // indices to color pair, quad, or octet tables - int32 chunkSize = stream->readUint32BE() & 0x00FFFFFF; - if (chunkSize != stream->size()) - warning("MOV chunk size != SMC chunk size (%d != %d); ignoring SMC chunk size", chunkSize, stream->size()); + int32 chunkSize = stream.readUint32BE() & 0x00FFFFFF; + if (chunkSize != stream.size()) + warning("MOV chunk size != SMC chunk size (%d != %d); ignoring SMC chunk size", chunkSize, stream.size()); int32 totalBlocks = ((_surface->w + 3) / 4) * ((_surface->h + 3) / 4); @@ -88,8 +88,8 @@ const Graphics::Surface *SMCDecoder::decodeImage(Common::SeekableReadStream *str // sanity checks // make sure stream ptr hasn't gone out of bounds - if (stream->pos() > stream->size()) { - warning("SMC decoder just went out of bounds (stream ptr = %d, chunk size = %d)", stream->pos(), stream->size()); + if (stream.pos() > stream.size()) { + warning("SMC decoder just went out of bounds (stream ptr = %d, chunk size = %d)", stream.pos(), stream.size()); return _surface; } @@ -99,7 +99,7 @@ const Graphics::Surface *SMCDecoder::decodeImage(Common::SeekableReadStream *str return _surface; } - byte opcode = stream->readByte(); + byte opcode = stream.readByte(); switch (opcode & 0xF0) { // skip n blocks @@ -192,7 +192,7 @@ const Graphics::Surface *SMCDecoder::decodeImage(Common::SeekableReadStream *str case 0x60: case 0x70: numBlocks = GET_BLOCK_COUNT(); - pixel = stream->readByte(); + pixel = stream.readByte(); while (numBlocks--) { blockPtr = rowPtr + pixelPtr; @@ -216,7 +216,7 @@ const Graphics::Surface *SMCDecoder::decodeImage(Common::SeekableReadStream *str // fetch the next 2 colors from bytestream and store in next // available entry in the color pair table for (byte i = 0; i < CPAIR; i++) { - pixel = stream->readByte(); + pixel = stream.readByte(); colorTableIndex = CPAIR * colorPairIndex + i; _colorPairs[colorTableIndex] = pixel; } @@ -229,10 +229,10 @@ const Graphics::Surface *SMCDecoder::decodeImage(Common::SeekableReadStream *str if (colorPairIndex == COLORS_PER_TABLE) colorPairIndex = 0; } else - colorTableIndex = CPAIR * stream->readByte(); + colorTableIndex = CPAIR * stream.readByte(); while (numBlocks--) { - colorFlags = stream->readUint16BE(); + colorFlags = stream.readUint16BE(); uint16 flagMask = 0x8000; blockPtr = rowPtr + pixelPtr; for (byte y = 0; y < 4; y++) { @@ -262,7 +262,7 @@ const Graphics::Surface *SMCDecoder::decodeImage(Common::SeekableReadStream *str // fetch the next 4 colors from bytestream and store in next // available entry in the color quad table for (byte i = 0; i < CQUAD; i++) { - pixel = stream->readByte(); + pixel = stream.readByte(); colorTableIndex = CQUAD * colorQuadIndex + i; _colorQuads[colorTableIndex] = pixel; } @@ -275,10 +275,10 @@ const Graphics::Surface *SMCDecoder::decodeImage(Common::SeekableReadStream *str if (colorQuadIndex == COLORS_PER_TABLE) colorQuadIndex = 0; } else - colorTableIndex = CQUAD * stream->readByte(); + colorTableIndex = CQUAD * stream.readByte(); while (numBlocks--) { - colorFlags = stream->readUint32BE(); + colorFlags = stream.readUint32BE(); // flag mask actually acts as a bit shift count here byte flagMask = 30; @@ -306,7 +306,7 @@ const Graphics::Surface *SMCDecoder::decodeImage(Common::SeekableReadStream *str // fetch the next 8 colors from bytestream and store in next // available entry in the color octet table for (byte i = 0; i < COCTET; i++) { - pixel = stream->readByte(); + pixel = stream.readByte(); colorTableIndex = COCTET * colorOctetIndex + i; _colorOctets[colorTableIndex] = pixel; } @@ -319,7 +319,7 @@ const Graphics::Surface *SMCDecoder::decodeImage(Common::SeekableReadStream *str if (colorOctetIndex == COLORS_PER_TABLE) colorOctetIndex = 0; } else - colorTableIndex = COCTET * stream->readByte(); + colorTableIndex = COCTET * stream.readByte(); while (numBlocks--) { /* @@ -331,7 +331,7 @@ const Graphics::Surface *SMCDecoder::decodeImage(Common::SeekableReadStream *str // build the color flags byte flagData[6]; - stream->read(flagData, 6); + stream.read(flagData, 6); colorFlagsA = ((READ_BE_UINT16(flagData) & 0xFFF0) << 8) | (READ_BE_UINT16(flagData + 2) >> 4); colorFlagsB = ((READ_BE_UINT16(flagData + 4) & 0xFFF0) << 8) | ((flagData[1] & 0xF) << 8) | @@ -369,7 +369,7 @@ const Graphics::Surface *SMCDecoder::decodeImage(Common::SeekableReadStream *str blockPtr = rowPtr + pixelPtr; for (byte y = 0; y < 4; y++) { for (byte x = 0; x < 4; x++) - pixels[blockPtr++] = stream->readByte(); + pixels[blockPtr++] = stream.readByte(); blockPtr += rowInc; } diff --git a/image/codecs/smc.h b/image/codecs/smc.h index 2de1f69ce4..579d629a1c 100644 --- a/image/codecs/smc.h +++ b/image/codecs/smc.h @@ -45,7 +45,7 @@ public: SMCDecoder(uint16 width, uint16 height); ~SMCDecoder(); - const Graphics::Surface *decodeImage(Common::SeekableReadStream *stream); + const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream); Graphics::PixelFormat getPixelFormat() const { return Graphics::PixelFormat::createFormatCLUT8(); } private: diff --git a/image/codecs/svq1.cpp b/image/codecs/svq1.cpp index 550445bc64..765d512797 100644 --- a/image/codecs/svq1.cpp +++ b/image/codecs/svq1.cpp @@ -91,10 +91,10 @@ SVQ1Decoder::~SVQ1Decoder() { #define ALIGN(x, a) (((x)+(a)-1)&~((a)-1)) -const Graphics::Surface *SVQ1Decoder::decodeImage(Common::SeekableReadStream *stream) { +const Graphics::Surface *SVQ1Decoder::decodeFrame(Common::SeekableReadStream &stream) { debug(1, "SVQ1Decoder::decodeImage()"); - Common::BitStream32BEMSB frameData(*stream); + Common::BitStream32BEMSB frameData(stream); uint32 frameCode = frameData.getBits(22); debug(1, " frameCode: %d", frameCode); diff --git a/image/codecs/svq1.h b/image/codecs/svq1.h index 56310a1a38..687f7615d4 100644 --- a/image/codecs/svq1.h +++ b/image/codecs/svq1.h @@ -44,7 +44,7 @@ public: SVQ1Decoder(uint16 width, uint16 height); ~SVQ1Decoder(); - const Graphics::Surface *decodeImage(Common::SeekableReadStream *stream); + const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream); Graphics::PixelFormat getPixelFormat() const { return _surface->format; } private: diff --git a/image/codecs/truemotion1.cpp b/image/codecs/truemotion1.cpp index 3b8ad85606..1302d72e2f 100644 --- a/image/codecs/truemotion1.cpp +++ b/image/codecs/truemotion1.cpp @@ -163,9 +163,9 @@ void TrueMotion1Decoder::genVectorTable16(const byte *selVectorTable) { } } -void TrueMotion1Decoder::decodeHeader(Common::SeekableReadStream *stream) { - _buf = new byte[stream->size()]; - stream->read(_buf, stream->size()); +void TrueMotion1Decoder::decodeHeader(Common::SeekableReadStream &stream) { + _buf = new byte[stream.size()]; + stream.read(_buf, stream.size()); byte headerBuffer[128]; // logical maximum size of the header const byte *selVectorTable; @@ -243,7 +243,7 @@ void TrueMotion1Decoder::decodeHeader(Common::SeekableReadStream *stream) { _indexStream = _mbChangeBits + _mbChangeBitsRowSize * (_height >> 2); } - _indexStreamSize = stream->size() - (_indexStream - _buf); + _indexStreamSize = stream.size() - (_indexStream - _buf); _lastDeltaset = _header.deltaset; _lastVectable = _header.vectable; @@ -397,7 +397,7 @@ void TrueMotion1Decoder::decode16() { } } -const Graphics::Surface *TrueMotion1Decoder::decodeImage(Common::SeekableReadStream *stream) { +const Graphics::Surface *TrueMotion1Decoder::decodeFrame(Common::SeekableReadStream &stream) { decodeHeader(stream); if (compressionTypes[_header.compression].algorithm == ALGO_NOP) { diff --git a/image/codecs/truemotion1.h b/image/codecs/truemotion1.h index e836ddb0e4..bb87dbc32c 100644 --- a/image/codecs/truemotion1.h +++ b/image/codecs/truemotion1.h @@ -43,7 +43,7 @@ public: TrueMotion1Decoder(uint16 width, uint16 height); ~TrueMotion1Decoder(); - const Graphics::Surface *decodeImage(Common::SeekableReadStream *stream); + const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream); // Always return RGB565 Graphics::PixelFormat getPixelFormat() const { return Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0); } @@ -96,7 +96,7 @@ private: } _header; void selectDeltaTables(int deltaTableIndex); - void decodeHeader(Common::SeekableReadStream *stream); + void decodeHeader(Common::SeekableReadStream &stream); void decode16(); int makeYdt16Entry(int p1, int p2); int makeCdt16Entry(int p1, int p2); diff --git a/image/jpeg.cpp b/image/jpeg.cpp index 3602d501be..1ce45f2539 100644 --- a/image/jpeg.cpp +++ b/image/jpeg.cpp @@ -59,8 +59,8 @@ void JPEGDecoder::destroy() { _surface.free(); } -const Graphics::Surface *JPEGDecoder::decodeImage(Common::SeekableReadStream *stream) { - if (!loadStream(*stream)) +const Graphics::Surface *JPEGDecoder::decodeFrame(Common::SeekableReadStream &stream) { + if (!loadStream(stream)) return 0; return getSurface(); diff --git a/image/jpeg.h b/image/jpeg.h index 1bf76ecfca..dea799c31f 100644 --- a/image/jpeg.h +++ b/image/jpeg.h @@ -58,7 +58,7 @@ public: virtual const Graphics::Surface *getSurface() const; // Codec API - const Graphics::Surface *decodeImage(Common::SeekableReadStream *stream); + const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream); Graphics::PixelFormat getPixelFormat() const; // Special API for JPEG diff --git a/video/avi_decoder.cpp b/video/avi_decoder.cpp index 5e404ecaac..e9c6ef93b2 100644 --- a/video/avi_decoder.cpp +++ b/video/avi_decoder.cpp @@ -711,7 +711,7 @@ AVIDecoder::AVIVideoTrack::~AVIVideoTrack() { void AVIDecoder::AVIVideoTrack::decodeFrame(Common::SeekableReadStream *stream) { if (stream) { if (_videoCodec) - _lastFrame = _videoCodec->decodeImage(stream); + _lastFrame = _videoCodec->decodeFrame(*stream); } else { // Empty frame _lastFrame = 0; diff --git a/video/coktel_decoder.cpp b/video/coktel_decoder.cpp index e01c5f3827..21dda15cd0 100644 --- a/video/coktel_decoder.cpp +++ b/video/coktel_decoder.cpp @@ -2262,7 +2262,7 @@ bool VMDDecoder::renderFrame(Common::Rect &rect) { return false; Common::MemoryReadStream frameStream(_videoBuffer[0], _videoBufferLen[0]); - const Graphics::Surface *codecSurf = _codec->decodeImage(&frameStream); + const Graphics::Surface *codecSurf = _codec->decodeFrame(frameStream); if (!codecSurf) return false; diff --git a/video/qt_decoder.cpp b/video/qt_decoder.cpp index 20c20d05b1..cd3679615b 100644 --- a/video/qt_decoder.cpp +++ b/video/qt_decoder.cpp @@ -725,7 +725,7 @@ const Graphics::Surface *QuickTimeDecoder::VideoTrackHandler::bufferNextFrame() return 0; } - const Graphics::Surface *frame = entry->_videoCodec->decodeImage(frameData); + const Graphics::Surface *frame = entry->_videoCodec->decodeFrame(*frameData); delete frameData; // Update the palette |