diff options
author | Paul Gilbert | 2016-09-10 11:16:07 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-09-10 11:16:07 -0400 |
commit | bd010bc79f6a56b51c1414a8cafc64bc248496fe (patch) | |
tree | a1b2d0642709e4d79dce8774ba218d107c13e0c9 | |
parent | 9c7b9e166746a903dc0b7e87967ec257967e1359 (diff) | |
download | scummvm-rg350-bd010bc79f6a56b51c1414a8cafc64bc248496fe.tar.gz scummvm-rg350-bd010bc79f6a56b51c1414a8cafc64bc248496fe.tar.bz2 scummvm-rg350-bd010bc79f6a56b51c1414a8cafc64bc248496fe.zip |
COMMON: Converted Common::BitStream to use DisposeAfterUse
-rw-r--r-- | common/bitstream.h | 11 | ||||
-rw-r--r-- | engines/macventure/text.cpp | 4 | ||||
-rw-r--r-- | video/bink_decoder.cpp | 4 | ||||
-rw-r--r-- | video/smk_decoder.cpp | 6 |
4 files changed, 13 insertions, 12 deletions
diff --git a/common/bitstream.h b/common/bitstream.h index b789f2ac8d..325118bbee 100644 --- a/common/bitstream.h +++ b/common/bitstream.h @@ -28,6 +28,7 @@ #include "common/scummsys.h" #include "common/textconsole.h" #include "common/stream.h" +#include "common/types.h" namespace Common { @@ -88,8 +89,8 @@ protected: template<int valueBits, bool isLE, bool isMSB2LSB> class BitStreamImpl : public BitStream { private: - SeekableReadStream *_stream; ///< The input stream. - bool _disposeAfterUse; ///< Should we delete the stream on destruction? + SeekableReadStream *_stream; ///< The input stream. + DisposeAfterUse::Flag _disposeAfterUse; ///< Should we delete the stream on destruction? uint32 _value; ///< Current value. uint8 _inValue; ///< Position within the current value. @@ -132,7 +133,7 @@ private: public: /** Create a bit stream using this input data stream and optionally delete it on destruction. */ - BitStreamImpl(SeekableReadStream *stream, bool disposeAfterUse = false) : + BitStreamImpl(SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::NO) : _stream(stream), _disposeAfterUse(disposeAfterUse), _value(0), _inValue(0) { if ((valueBits != 8) && (valueBits != 16) && (valueBits != 32)) @@ -141,14 +142,14 @@ public: /** Create a bit stream using this input data stream. */ BitStreamImpl(SeekableReadStream &stream) : - _stream(&stream), _disposeAfterUse(false), _value(0), _inValue(0) { + _stream(&stream), _disposeAfterUse(DisposeAfterUse::NO), _value(0), _inValue(0) { if ((valueBits != 8) && (valueBits != 16) && (valueBits != 32)) error("BitStreamImpl: Invalid memory layout %d, %d, %d", valueBits, isLE, isMSB2LSB); } ~BitStreamImpl() { - if (_disposeAfterUse) + if (_disposeAfterUse == DisposeAfterUse::YES) delete _stream; } diff --git a/engines/macventure/text.cpp b/engines/macventure/text.cpp index b4d67a1306..d8e18fffdf 100644 --- a/engines/macventure/text.cpp +++ b/engines/macventure/text.cpp @@ -50,7 +50,7 @@ TextAsset::TextAsset(MacVentureEngine *engine, ObjID objid, ObjID source, ObjID void TextAsset::decodeOld() { Common::SeekableReadStream *res = _container->getItem(_id); uint16 strLen = res->readUint16BE(); - Common::BitStream32BELSB stream(res, true); + Common::BitStream32BELSB stream(res, DisposeAfterUse::YES); char *str = new char[strLen + 1]; bool lowercase = false; char c; @@ -114,7 +114,7 @@ void TextAsset::decodeOld() { void TextAsset::decodeHuffman() { _decoded = Common::String(""); Common::SeekableReadStream *res = _container->getItem(_id); - Common::BitStream8MSB stream(res, true); + Common::BitStream8MSB stream(res, DisposeAfterUse::YES); uint16 strLen = 0; if (stream.getBit()) { strLen = stream.getBits(15); diff --git a/video/bink_decoder.cpp b/video/bink_decoder.cpp index a228377a27..cf37e0f06b 100644 --- a/video/bink_decoder.cpp +++ b/video/bink_decoder.cpp @@ -187,7 +187,7 @@ void BinkDecoder::readNextPacket() { audio.sampleCount = _bink->readUint32LE() / (2 * audio.channels); audio.bits = new Common::BitStream32LELSB(new Common::SeekableSubReadStream(_bink, - audioPacketStart + 4, audioPacketEnd), true); + audioPacketStart + 4, audioPacketEnd), DisposeAfterUse::YES); audioTrack->decodePacket(); @@ -204,7 +204,7 @@ void BinkDecoder::readNextPacket() { uint32 videoPacketEnd = _bink->pos() + frameSize; frame.bits = new Common::BitStream32LELSB(new Common::SeekableSubReadStream(_bink, - videoPacketStart, videoPacketEnd), true); + videoPacketStart, videoPacketEnd), DisposeAfterUse::YES); videoTrack->decodePacket(frame); diff --git a/video/smk_decoder.cpp b/video/smk_decoder.cpp index ee7a4ce689..4a2ada0e3a 100644 --- a/video/smk_decoder.cpp +++ b/video/smk_decoder.cpp @@ -386,7 +386,7 @@ bool SmackerDecoder::loadStream(Common::SeekableReadStream *stream) { byte *huffmanTrees = (byte *) malloc(_header.treesSize); _fileStream->read(huffmanTrees, _header.treesSize); - Common::BitStream8LSB bs(new Common::MemoryReadStream(huffmanTrees, _header.treesSize, DisposeAfterUse::YES), true); + Common::BitStream8LSB bs(new Common::MemoryReadStream(huffmanTrees, _header.treesSize, DisposeAfterUse::YES), DisposeAfterUse::YES); videoTrack->readTrees(bs, _header.mMapSize, _header.mClrSize, _header.fullSize, _header.typeSize); _firstFrameStart = _fileStream->pos(); @@ -469,7 +469,7 @@ void SmackerDecoder::readNextPacket() { _fileStream->read(frameData, frameDataSize); - Common::BitStream8LSB bs(new Common::MemoryReadStream(frameData, frameDataSize + 1, DisposeAfterUse::YES), true); + Common::BitStream8LSB bs(new Common::MemoryReadStream(frameData, frameDataSize + 1, DisposeAfterUse::YES), DisposeAfterUse::YES); videoTrack->decodeFrame(bs); _fileStream->seek(startPos + frameSize); @@ -773,7 +773,7 @@ Audio::AudioStream *SmackerDecoder::SmackerAudioTrack::getAudioStream() const { } void SmackerDecoder::SmackerAudioTrack::queueCompressedBuffer(byte *buffer, uint32 bufferSize, uint32 unpackedSize) { - Common::BitStream8LSB audioBS(new Common::MemoryReadStream(buffer, bufferSize), true); + Common::BitStream8LSB audioBS(new Common::MemoryReadStream(buffer, bufferSize), DisposeAfterUse::YES); bool dataPresent = audioBS.getBit(); if (!dataPresent) |