diff options
-rw-r--r-- | audio/decoders/qdm2.cpp | 24 | ||||
-rw-r--r-- | common/bitstream.h | 74 | ||||
-rw-r--r-- | common/huffman.cpp | 15 | ||||
-rw-r--r-- | common/huffman.h | 18 | ||||
-rw-r--r-- | engines/groovie/stuffit.cpp | 6 | ||||
-rw-r--r-- | engines/macventure/container.h | 1 | ||||
-rw-r--r-- | engines/macventure/image.cpp | 12 | ||||
-rw-r--r-- | engines/macventure/image.h | 13 | ||||
-rw-r--r-- | image/codecs/svq1.cpp | 12 | ||||
-rw-r--r-- | image/codecs/svq1.h | 14 | ||||
-rw-r--r-- | video/bink_decoder.h | 6 | ||||
-rw-r--r-- | video/psx_decoder.cpp | 10 | ||||
-rw-r--r-- | video/psx_decoder.h | 12 | ||||
-rw-r--r-- | video/smk_decoder.cpp | 24 | ||||
-rw-r--r-- | video/smk_decoder.h | 6 |
15 files changed, 100 insertions, 147 deletions
diff --git a/audio/decoders/qdm2.cpp b/audio/decoders/qdm2.cpp index a2f4326152..b8d007da51 100644 --- a/audio/decoders/qdm2.cpp +++ b/audio/decoders/qdm2.cpp @@ -213,9 +213,9 @@ private: void fill_coding_method_array(sb_int8_array tone_level_idx, sb_int8_array tone_level_idx_temp, sb_int8_array coding_method, int nb_channels, int c, int superblocktype_2_3, int cm_table_select); - void synthfilt_build_sb_samples(Common::BitStream *gb, int length, int sb_min, int sb_max); - void init_quantized_coeffs_elem0(int8 *quantized_coeffs, Common::BitStream *gb, int length); - void init_tone_level_dequantization(Common::BitStream *gb, int length); + void synthfilt_build_sb_samples(Common::BitStream32LELSB *gb, int length, int sb_min, int sb_max); + void init_quantized_coeffs_elem0(int8 *quantized_coeffs, Common::BitStream32LELSB *gb, int length); + void init_tone_level_dequantization(Common::BitStream32LELSB *gb, int length); void process_subpacket_9(QDM2SubPNode *node); void process_subpacket_10(QDM2SubPNode *node, int length); void process_subpacket_11(QDM2SubPNode *node, int length); @@ -224,7 +224,7 @@ private: void qdm2_decode_super_block(void); void qdm2_fft_init_coefficient(int sub_packet, int offset, int duration, int channel, int exp, int phase); - void qdm2_fft_decode_tones(int duration, Common::BitStream *gb, int b); + void qdm2_fft_decode_tones(int duration, Common::BitStream32LELSB *gb, int b); void qdm2_decode_fft_packets(void); void qdm2_fft_generate_tone(FFTTone *tone); void qdm2_fft_tone_synthesizer(uint8 sub_packet); @@ -677,7 +677,7 @@ void ff_mpa_synth_filter(int16 *synth_buf_ptr, int *synth_buf_offset, * read the longest vlc code * = (max_vlc_length + bits - 1) / bits */ -static int getVlc2(Common::BitStream *s, int16 (*table)[2], int bits, int maxDepth) { +static int getVlc2(Common::BitStream32LELSB *s, int16 (*table)[2], int bits, int maxDepth) { int index = s->peekBits(bits); int code = table[index][0]; int n = table[index][1]; @@ -1227,7 +1227,7 @@ QDM2Stream::~QDM2Stream() { delete[] _compressedData; } -static int qdm2_get_vlc(Common::BitStream *gb, VLC *vlc, int flag, int depth) { +static int qdm2_get_vlc(Common::BitStream32LELSB *gb, VLC *vlc, int flag, int depth) { int value = getVlc2(gb, vlc->table, vlc->bits, depth); // stage-2, 3 bits exponent escape sequence @@ -1246,7 +1246,7 @@ static int qdm2_get_vlc(Common::BitStream *gb, VLC *vlc, int flag, int depth) { return value; } -static int qdm2_get_se_vlc(VLC *vlc, Common::BitStream *gb, int depth) +static int qdm2_get_se_vlc(VLC *vlc, Common::BitStream32LELSB *gb, int depth) { int value = qdm2_get_vlc(gb, vlc, 0, depth); @@ -1612,7 +1612,7 @@ void QDM2Stream::fill_coding_method_array(sb_int8_array tone_level_idx, sb_int8_ * @param sb_min lower subband processed (sb_min included) * @param sb_max higher subband processed (sb_max excluded) */ -void QDM2Stream::synthfilt_build_sb_samples(Common::BitStream *gb, int length, int sb_min, int sb_max) { +void QDM2Stream::synthfilt_build_sb_samples(Common::BitStream32LELSB *gb, int length, int sb_min, int sb_max) { int sb, j, k, n, ch, run, channels; int joined_stereo, zero_encoding, chs; int type34_first; @@ -1792,7 +1792,7 @@ void QDM2Stream::synthfilt_build_sb_samples(Common::BitStream *gb, int length, i * @param gb bitreader context * @param length packet length in bits */ -void QDM2Stream::init_quantized_coeffs_elem0(int8 *quantized_coeffs, Common::BitStream *gb, int length) { +void QDM2Stream::init_quantized_coeffs_elem0(int8 *quantized_coeffs, Common::BitStream32LELSB *gb, int length) { int i, k, run, level, diff; if ((length - gb->pos()) < 16) @@ -1826,7 +1826,7 @@ void QDM2Stream::init_quantized_coeffs_elem0(int8 *quantized_coeffs, Common::Bit * @param gb bitreader context * @param length packet length in bits */ -void QDM2Stream::init_tone_level_dequantization(Common::BitStream *gb, int length) { +void QDM2Stream::init_tone_level_dequantization(Common::BitStream32LELSB *gb, int length) { int sb, j, k, n, ch; for (ch = 0; ch < _channels; ch++) { @@ -2021,7 +2021,7 @@ void QDM2Stream::qdm2_decode_super_block(void) { average_quantized_coeffs(); // average elements in quantized_coeffs[max_ch][10][8] Common::MemoryReadStream *d = new Common::MemoryReadStream(_compressedData, _packetSize*8); - Common::BitStream *gb = new Common::BitStream32LELSB(d); + Common::BitStream32LELSB *gb = new Common::BitStream32LELSB(d); //qdm2_decode_sub_packet_header header.type = gb->getBits(8); @@ -2188,7 +2188,7 @@ void QDM2Stream::qdm2_fft_init_coefficient(int sub_packet, int offset, int durat _fftCoefsIndex++; } -void QDM2Stream::qdm2_fft_decode_tones(int duration, Common::BitStream *gb, int b) { +void QDM2Stream::qdm2_fft_decode_tones(int duration, Common::BitStream32LELSB *gb, int b) { int channel, stereo, phase, exp; int local_int_4, local_int_8, stereo_phase, local_int_10; int local_int_14, stereo_exp, local_int_20, local_int_28; diff --git a/common/bitstream.h b/common/bitstream.h index 325118bbee..ae5677da1a 100644 --- a/common/bitstream.h +++ b/common/bitstream.h @@ -32,50 +32,6 @@ namespace Common { -/** A bit stream. */ -class BitStream { -public: - virtual ~BitStream() { - } - - /** Return the stream position in bits. */ - virtual uint32 pos() const = 0; - - /** Return the stream size in bits. */ - virtual uint32 size() const = 0; - - /** Has the end of the stream been reached? */ - virtual bool eos() const = 0; - - /** Rewind the bit stream back to the start. */ - virtual void rewind() = 0; - - /** Skip the specified amount of bits. */ - virtual void skip(uint32 n) = 0; - - /** Skip the bits to closest data value border. */ - virtual void align() = 0; - - /** Read a bit from the bit stream. */ - virtual uint32 getBit() = 0; - - /** Read a multi-bit value from the bit stream. */ - virtual uint32 getBits(uint8 n) = 0; - - /** Read a bit from the bit stream, without changing the stream's position. */ - virtual uint32 peekBit() = 0; - - /** Read a multi-bit value from the bit stream, without changing the stream's position. */ - virtual uint32 peekBits(uint8 n) = 0; - - /** Add a bit to the value x, making it an n+1-bit value. */ - virtual void addBit(uint32 &x, uint32 n) = 0; - -protected: - BitStream() { - } -}; - /** * A template implementing a bit stream for different data memory layouts. * @@ -86,10 +42,10 @@ protected: * for valueBits, isLE and isMSB2LSB, reads 32bit little-endian values * from the data stream and hands out the bits in the order of LSB to MSB. */ -template<int valueBits, bool isLE, bool isMSB2LSB> -class BitStreamImpl : public BitStream { +template<class STREAM, int valueBits, bool isLE, bool isMSB2LSB> +class BitStreamImpl { private: - SeekableReadStream *_stream; ///< The input stream. + STREAM *_stream; ///< The input stream. DisposeAfterUse::Flag _disposeAfterUse; ///< Should we delete the stream on destruction? uint32 _value; ///< Current value. @@ -133,7 +89,7 @@ private: public: /** Create a bit stream using this input data stream and optionally delete it on destruction. */ - BitStreamImpl(SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::NO) : + BitStreamImpl(STREAM *stream, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::NO) : _stream(stream), _disposeAfterUse(disposeAfterUse), _value(0), _inValue(0) { if ((valueBits != 8) && (valueBits != 16) && (valueBits != 32)) @@ -141,7 +97,7 @@ public: } /** Create a bit stream using this input data stream. */ - BitStreamImpl(SeekableReadStream &stream) : + BitStreamImpl(STREAM &stream) : _stream(&stream), _disposeAfterUse(DisposeAfterUse::NO), _value(0), _inValue(0) { if ((valueBits != 8) && (valueBits != 16) && (valueBits != 32)) @@ -308,27 +264,27 @@ public: // typedefs for various memory layouts. /** 8-bit data, MSB to LSB. */ -typedef BitStreamImpl<8, false, true > BitStream8MSB; +typedef BitStreamImpl<SeekableReadStream, 8, false, true > BitStream8MSB; /** 8-bit data, LSB to MSB. */ -typedef BitStreamImpl<8, false, false> BitStream8LSB; +typedef BitStreamImpl<SeekableReadStream, 8, false, false> BitStream8LSB; /** 16-bit little-endian data, MSB to LSB. */ -typedef BitStreamImpl<16, true , true > BitStream16LEMSB; +typedef BitStreamImpl<SeekableReadStream, 16, true , true > BitStream16LEMSB; /** 16-bit little-endian data, LSB to MSB. */ -typedef BitStreamImpl<16, true , false> BitStream16LELSB; +typedef BitStreamImpl<SeekableReadStream, 16, true , false> BitStream16LELSB; /** 16-bit big-endian data, MSB to LSB. */ -typedef BitStreamImpl<16, false, true > BitStream16BEMSB; +typedef BitStreamImpl<SeekableReadStream, 16, false, true > BitStream16BEMSB; /** 16-bit big-endian data, LSB to MSB. */ -typedef BitStreamImpl<16, false, false> BitStream16BELSB; +typedef BitStreamImpl<SeekableReadStream, 16, false, false> BitStream16BELSB; /** 32-bit little-endian data, MSB to LSB. */ -typedef BitStreamImpl<32, true , true > BitStream32LEMSB; +typedef BitStreamImpl<SeekableReadStream, 32, true , true > BitStream32LEMSB; /** 32-bit little-endian data, LSB to MSB. */ -typedef BitStreamImpl<32, true , false> BitStream32LELSB; +typedef BitStreamImpl<SeekableReadStream, 32, true , false> BitStream32LELSB; /** 32-bit big-endian data, MSB to LSB. */ -typedef BitStreamImpl<32, false, true > BitStream32BEMSB; +typedef BitStreamImpl<SeekableReadStream, 32, false, true > BitStream32BEMSB; /** 32-bit big-endian data, LSB to MSB. */ -typedef BitStreamImpl<32, false, false> BitStream32BELSB; +typedef BitStreamImpl<SeekableReadStream, 32, false, false> BitStream32BELSB; } // End of namespace Common diff --git a/common/huffman.cpp b/common/huffman.cpp index afb4fa00b6..3268ddf251 100644 --- a/common/huffman.cpp +++ b/common/huffman.cpp @@ -68,19 +68,4 @@ void Huffman::setSymbols(const uint32 *symbols) { _symbols[i]->symbol = symbols ? *symbols++ : i; } -uint32 Huffman::getSymbol(BitStream &bits) const { - uint32 code = 0; - - for (uint32 i = 0; i < _codes.size(); i++) { - bits.addBit(code, i); - - for (CodeList::const_iterator cCode = _codes[i].begin(); cCode != _codes[i].end(); ++cCode) - if (code == cCode->code) - return cCode->symbol; - } - - error("Unknown Huffman code"); - return 0; -} - } // End of namespace Common diff --git a/common/huffman.h b/common/huffman.h index 5ba7deca87..f703d078dc 100644 --- a/common/huffman.h +++ b/common/huffman.h @@ -31,8 +31,6 @@ namespace Common { -class BitStream; - /** * Huffman bitstream decoding * @@ -56,7 +54,21 @@ public: void setSymbols(const uint32 *symbols = 0); /** Return the next symbol in the bitstream. */ - uint32 getSymbol(BitStream &bits) const; + template<class BITSTREAM> + uint32 getSymbol(BITSTREAM &bits) const { + uint32 code = 0; + + for (uint32 i = 0; i < _codes.size(); i++) { + bits.addBit(code, i); + + for (CodeList::const_iterator cCode = _codes[i].begin(); cCode != _codes[i].end(); ++cCode) + if (code == cCode->code) + return cCode->symbol; + } + + error("Unknown Huffman code"); + return 0; + } private: struct Symbol { diff --git a/engines/groovie/stuffit.cpp b/engines/groovie/stuffit.cpp index bbfcd3da82..4543e37a27 100644 --- a/engines/groovie/stuffit.cpp +++ b/engines/groovie/stuffit.cpp @@ -71,7 +71,7 @@ private: // Decompression Helpers void update14(uint16 first, uint16 last, byte *code, uint16 *freq) const; - void readTree14(Common::BitStream *bits, SIT14Data *dat, uint16 codesize, uint16 *result) const; + void readTree14(Common::BitStream8LSB *bits, SIT14Data *dat, uint16 codesize, uint16 *result) const; }; StuffItArchive::StuffItArchive() : Common::Archive() { @@ -302,7 +302,7 @@ struct SIT14Data { if (b->pos() & 7) \ b->skip(8 - (b->pos() & 7)) -void StuffItArchive::readTree14(Common::BitStream *bits, SIT14Data *dat, uint16 codesize, uint16 *result) const { +void StuffItArchive::readTree14(Common::BitStream8LSB *bits, SIT14Data *dat, uint16 codesize, uint16 *result) const { uint32 i, l, n; uint32 k = bits->getBit(); uint32 j = bits->getBits(2) + 2; @@ -429,7 +429,7 @@ Common::SeekableReadStream *StuffItArchive::decompress14(Common::SeekableReadStr byte *dst = (byte *)malloc(uncompressedSize); Common::MemoryWriteStream out(dst, uncompressedSize); - Common::BitStream *bits = new Common::BitStream8LSB(src); + Common::BitStream8LSB *bits = new Common::BitStream8LSB(src); uint32 i, j, k, l, m, n; diff --git a/engines/macventure/container.h b/engines/macventure/container.h index ba1370d108..bd8cd0995a 100644 --- a/engines/macventure/container.h +++ b/engines/macventure/container.h @@ -35,7 +35,6 @@ #include "common/file.h" #include "common/fs.h" -#include "common/bitstream.h" namespace MacVenture { diff --git a/engines/macventure/image.cpp b/engines/macventure/image.cpp index 7fccaa81b4..a899341eb9 100644 --- a/engines/macventure/image.cpp +++ b/engines/macventure/image.cpp @@ -155,7 +155,7 @@ void ImageAsset::decodePPIC(ObjID id, Common::Array<byte> &data, uint &bitHeight delete baseStream; } -void ImageAsset::decodePPIC0(Common::BitStream &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes) { +void ImageAsset::decodePPIC0(Common::BitStream32BEMSB &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes) { uint words = bitWidth >> 4; uint bytes = bitWidth & 0xF; uint v = 0; @@ -178,15 +178,15 @@ void ImageAsset::decodePPIC0(Common::BitStream &stream, Common::Array<byte> &dat } -void ImageAsset::decodePPIC1(Common::BitStream &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes) { +void ImageAsset::decodePPIC1(Common::BitStream32BEMSB &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes) { decodeHuffGraphic(PPIC1Huff, stream, data, bitHeight, bitWidth, rowBytes); } -void ImageAsset::decodePPIC2(Common::BitStream &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes) { +void ImageAsset::decodePPIC2(Common::BitStream32BEMSB &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes) { decodeHuffGraphic(PPIC2Huff, stream, data, bitHeight, bitWidth, rowBytes); } -void ImageAsset::decodePPIC3(Common::BitStream &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes) { +void ImageAsset::decodePPIC3(Common::BitStream32BEMSB &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes) { // We need to load the huffman from the PPIC itself PPICHuff huff; uint16 v, bits; @@ -238,7 +238,7 @@ void ImageAsset::decodePPIC3(Common::BitStream &stream, Common::Array<byte> &dat decodeHuffGraphic(huff, stream, data, bitHeight, bitWidth, rowBytes); } -void ImageAsset::decodeHuffGraphic(const PPICHuff &huff, Common::BitStream &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes) { +void ImageAsset::decodeHuffGraphic(const PPICHuff &huff, Common::BitStream32BEMSB &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes) { byte flags = 0; _walkRepeat = 0; _walkLast = 0; @@ -333,7 +333,7 @@ void ImageAsset::decodeHuffGraphic(const PPICHuff &huff, Common::BitStream &stre } } -byte ImageAsset::walkHuff(const PPICHuff &huff, Common::BitStream &stream) { +byte ImageAsset::walkHuff(const PPICHuff &huff, Common::BitStream32BEMSB &stream) { if (_walkRepeat) { _walkRepeat--; _walkLast = ((_walkLast << 8) & 0xFF00) | (_walkLast >> 8); diff --git a/engines/macventure/image.h b/engines/macventure/image.h index 87c5cec2db..9a3a2a10e5 100644 --- a/engines/macventure/image.h +++ b/engines/macventure/image.h @@ -33,6 +33,7 @@ #include "macventure/macventure.h" #include "macventure/container.h" +#include "common/bitstream.h" namespace MacVenture { @@ -76,13 +77,13 @@ public: private: void decodePPIC(ObjID id, Common::Array<byte> &data, uint &bitHeight, uint &bitWidth, uint &rowBytes); - void decodePPIC0(Common::BitStream &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes); - void decodePPIC1(Common::BitStream &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes); - void decodePPIC2(Common::BitStream &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes); - void decodePPIC3(Common::BitStream &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes); + void decodePPIC0(Common::BitStream32BEMSB &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes); + void decodePPIC1(Common::BitStream32BEMSB &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes); + void decodePPIC2(Common::BitStream32BEMSB &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes); + void decodePPIC3(Common::BitStream32BEMSB &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes); - void decodeHuffGraphic(const PPICHuff &huff, Common::BitStream &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes); - byte walkHuff(const PPICHuff &huff, Common::BitStream &stream); + void decodeHuffGraphic(const PPICHuff &huff, Common::BitStream32BEMSB &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes); + byte walkHuff(const PPICHuff &huff, Common::BitStream32BEMSB &stream); void blitDirect(Graphics::ManagedSurface *target, int ox, int oy, const Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes); void blitBIC(Graphics::ManagedSurface *target, int ox, int oy, const Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes); diff --git a/image/codecs/svq1.cpp b/image/codecs/svq1.cpp index 765d512797..2d86070801 100644 --- a/image/codecs/svq1.cpp +++ b/image/codecs/svq1.cpp @@ -282,7 +282,7 @@ const Graphics::Surface *SVQ1Decoder::decodeFrame(Common::SeekableReadStream &st return _surface; } -bool SVQ1Decoder::svq1DecodeBlockIntra(Common::BitStream *s, byte *pixels, int pitch) { +bool SVQ1Decoder::svq1DecodeBlockIntra(Common::BitStream32BEMSB *s, byte *pixels, int pitch) { // initialize list for breadth first processing of vectors byte *list[63]; list[0] = pixels; @@ -383,7 +383,7 @@ bool SVQ1Decoder::svq1DecodeBlockIntra(Common::BitStream *s, byte *pixels, int p return true; } -bool SVQ1Decoder::svq1DecodeBlockNonIntra(Common::BitStream *s, byte *pixels, int pitch) { +bool SVQ1Decoder::svq1DecodeBlockNonIntra(Common::BitStream32BEMSB *s, byte *pixels, int pitch) { // initialize list for breadth first processing of vectors byte *list[63]; list[0] = pixels; @@ -497,7 +497,7 @@ static inline int midPred(int a, int b, int c) { return b; } -bool SVQ1Decoder::svq1DecodeMotionVector(Common::BitStream *s, Common::Point *mv, Common::Point **pmv) { +bool SVQ1Decoder::svq1DecodeMotionVector(Common::BitStream32BEMSB *s, Common::Point *mv, Common::Point **pmv) { for (int i = 0; i < 2; i++) { // get motion code int diff = _motionComponent->getSymbol(*s); @@ -611,7 +611,7 @@ void SVQ1Decoder::putPixels16XY2C(byte *block, const byte *pixels, int lineSize, putPixels8XY2C(block + 8, pixels + 8, lineSize, h); } -bool SVQ1Decoder::svq1MotionInterBlock(Common::BitStream *ss, byte *current, byte *previous, int pitch, +bool SVQ1Decoder::svq1MotionInterBlock(Common::BitStream32BEMSB *ss, byte *current, byte *previous, int pitch, Common::Point *motion, int x, int y) { // predict and decode motion vector @@ -662,7 +662,7 @@ bool SVQ1Decoder::svq1MotionInterBlock(Common::BitStream *ss, byte *current, byt return true; } -bool SVQ1Decoder::svq1MotionInter4vBlock(Common::BitStream *ss, byte *current, byte *previous, int pitch, +bool SVQ1Decoder::svq1MotionInter4vBlock(Common::BitStream32BEMSB *ss, byte *current, byte *previous, int pitch, Common::Point *motion, int x, int y) { // predict and decode motion vector (0) Common::Point *pmv[4]; @@ -749,7 +749,7 @@ bool SVQ1Decoder::svq1MotionInter4vBlock(Common::BitStream *ss, byte *current, b return true; } -bool SVQ1Decoder::svq1DecodeDeltaBlock(Common::BitStream *ss, byte *current, byte *previous, int pitch, +bool SVQ1Decoder::svq1DecodeDeltaBlock(Common::BitStream32BEMSB *ss, byte *current, byte *previous, int pitch, Common::Point *motion, int x, int y) { // get block type uint32 blockType = _blockType->getSymbol(*ss); diff --git a/image/codecs/svq1.h b/image/codecs/svq1.h index 236b810294..148501d17f 100644 --- a/image/codecs/svq1.h +++ b/image/codecs/svq1.h @@ -23,10 +23,10 @@ #ifndef IMAGE_CODECS_SVQ1_H #define IMAGE_CODECS_SVQ1_H +#include "common/bitstream.h" #include "image/codecs/codec.h" namespace Common { -class BitStream; class Huffman; struct Point; } @@ -60,15 +60,15 @@ private: Common::Huffman *_interMean; Common::Huffman *_motionComponent; - bool svq1DecodeBlockIntra(Common::BitStream *s, byte *pixels, int pitch); - bool svq1DecodeBlockNonIntra(Common::BitStream *s, byte *pixels, int pitch); - bool svq1DecodeMotionVector(Common::BitStream *s, Common::Point *mv, Common::Point **pmv); + bool svq1DecodeBlockIntra(Common::BitStream32BEMSB *s, byte *pixels, int pitch); + bool svq1DecodeBlockNonIntra(Common::BitStream32BEMSB *s, byte *pixels, int pitch); + bool svq1DecodeMotionVector(Common::BitStream32BEMSB *s, Common::Point *mv, Common::Point **pmv); void svq1SkipBlock(byte *current, byte *previous, int pitch, int x, int y); - bool svq1MotionInterBlock(Common::BitStream *ss, byte *current, byte *previous, int pitch, + bool svq1MotionInterBlock(Common::BitStream32BEMSB *ss, byte *current, byte *previous, int pitch, Common::Point *motion, int x, int y); - bool svq1MotionInter4vBlock(Common::BitStream *ss, byte *current, byte *previous, int pitch, + bool svq1MotionInter4vBlock(Common::BitStream32BEMSB *ss, byte *current, byte *previous, int pitch, Common::Point *motion, int x, int y); - bool svq1DecodeDeltaBlock(Common::BitStream *ss, byte *current, byte *previous, int pitch, + bool svq1DecodeDeltaBlock(Common::BitStream32BEMSB *ss, byte *current, byte *previous, int pitch, Common::Point *motion, int x, int y); void putPixels8C(byte *block, const byte *pixels, int lineSize, int h); diff --git a/video/bink_decoder.h b/video/bink_decoder.h index 6f18dd539c..8a67913a03 100644 --- a/video/bink_decoder.h +++ b/video/bink_decoder.h @@ -32,6 +32,7 @@ #define VIDEO_BINK_DECODER_H #include "common/array.h" +#include "common/bitstream.h" #include "common/rational.h" #include "video/video_decoder.h" @@ -45,7 +46,6 @@ class QueuingAudioStream; namespace Common { class SeekableReadStream; -class BitStream; class Huffman; class RDFT; @@ -100,7 +100,7 @@ private: uint32 sampleCount; - Common::BitStream *bits; + Common::BitStream32LELSB *bits; bool first; @@ -133,7 +133,7 @@ private: uint32 offset; uint32 size; - Common::BitStream *bits; + Common::BitStream32LELSB *bits; VideoFrame(); ~VideoFrame(); diff --git a/video/psx_decoder.cpp b/video/psx_decoder.cpp index 426f5eb608..973803e69f 100644 --- a/video/psx_decoder.cpp +++ b/video/psx_decoder.cpp @@ -499,7 +499,7 @@ void PSXStreamDecoder::PSXVideoTrack::decodeFrame(Common::SeekableReadStream *fr _nextFrameStartTime = _nextFrameStartTime.addFrames(sectorCount); } -void PSXStreamDecoder::PSXVideoTrack::decodeMacroBlock(Common::BitStream *bits, int mbX, int mbY, uint16 scale, uint16 version) { +void PSXStreamDecoder::PSXVideoTrack::decodeMacroBlock(Common::BitStream16LEMSB *bits, int mbX, int mbY, uint16 scale, uint16 version) { int pitchY = _macroBlocksW * 16; int pitchC = _macroBlocksW * 8; @@ -546,7 +546,7 @@ void PSXStreamDecoder::PSXVideoTrack::dequantizeBlock(int *coefficients, float * } } -int PSXStreamDecoder::PSXVideoTrack::readDC(Common::BitStream *bits, uint16 version, PlaneType plane) { +int PSXStreamDecoder::PSXVideoTrack::readDC(Common::BitStream16LEMSB *bits, uint16 version, PlaneType plane) { // Version 2 just has its coefficient as 10-bits if (version == 2) return readSignedCoefficient(bits); @@ -576,7 +576,7 @@ int PSXStreamDecoder::PSXVideoTrack::readDC(Common::BitStream *bits, uint16 vers if (count > 63) \ error("PSXStreamDecoder::readAC(): Too many coefficients") -void PSXStreamDecoder::PSXVideoTrack::readAC(Common::BitStream *bits, int *block) { +void PSXStreamDecoder::PSXVideoTrack::readAC(Common::BitStream16LEMSB *bits, int *block) { // Clear the block first for (int i = 0; i < 63; i++) block[i] = 0; @@ -611,7 +611,7 @@ void PSXStreamDecoder::PSXVideoTrack::readAC(Common::BitStream *bits, int *block } } -int PSXStreamDecoder::PSXVideoTrack::readSignedCoefficient(Common::BitStream *bits) { +int PSXStreamDecoder::PSXVideoTrack::readSignedCoefficient(Common::BitStream16LEMSB *bits) { uint val = bits->getBits(10); // extend the sign @@ -672,7 +672,7 @@ void PSXStreamDecoder::PSXVideoTrack::idct(float *dequantData, float *result) { } } -void PSXStreamDecoder::PSXVideoTrack::decodeBlock(Common::BitStream *bits, byte *block, int pitch, uint16 scale, uint16 version, PlaneType plane) { +void PSXStreamDecoder::PSXVideoTrack::decodeBlock(Common::BitStream16LEMSB *bits, byte *block, int pitch, uint16 scale, uint16 version, PlaneType plane) { // Version 2 just has signed 10 bits for DC // Version 3 has them huffman coded int coefficients[8 * 8]; diff --git a/video/psx_decoder.h b/video/psx_decoder.h index b19bd72fa0..fa36af1bb3 100644 --- a/video/psx_decoder.h +++ b/video/psx_decoder.h @@ -23,6 +23,7 @@ #ifndef VIDEO_PSX_DECODER_H #define VIDEO_PSX_DECODER_H +#include "common/bitstream.h" #include "common/endian.h" #include "common/rational.h" #include "common/rect.h" @@ -35,7 +36,6 @@ class QueuingAudioStream; } namespace Common { -class BitStream; class Huffman; class SeekableReadStream; } @@ -108,19 +108,19 @@ private: uint16 _macroBlocksW, _macroBlocksH; byte *_yBuffer, *_cbBuffer, *_crBuffer; - void decodeMacroBlock(Common::BitStream *bits, int mbX, int mbY, uint16 scale, uint16 version); - void decodeBlock(Common::BitStream *bits, byte *block, int pitch, uint16 scale, uint16 version, PlaneType plane); + void decodeMacroBlock(Common::BitStream16LEMSB *bits, int mbX, int mbY, uint16 scale, uint16 version); + void decodeBlock(Common::BitStream16LEMSB *bits, byte *block, int pitch, uint16 scale, uint16 version, PlaneType plane); - void readAC(Common::BitStream *bits, int *block); + void readAC(Common::BitStream16LEMSB *bits, int *block); Common::Huffman *_acHuffman; - int readDC(Common::BitStream *bits, uint16 version, PlaneType plane); + int readDC(Common::BitStream16LEMSB *bits, uint16 version, PlaneType plane); Common::Huffman *_dcHuffmanLuma, *_dcHuffmanChroma; int _lastDC[3]; void dequantizeBlock(int *coefficients, float *block, uint16 scale); void idct(float *dequantData, float *result); - int readSignedCoefficient(Common::BitStream *bits); + int readSignedCoefficient(Common::BitStream16LEMSB *bits); }; class PSXAudioTrack : public AudioTrack { diff --git a/video/smk_decoder.cpp b/video/smk_decoder.cpp index d913707119..d8057ac068 100644 --- a/video/smk_decoder.cpp +++ b/video/smk_decoder.cpp @@ -54,9 +54,9 @@ enum SmkBlockTypes { class SmallHuffmanTree { public: - SmallHuffmanTree(Common::BitStream &bs); + SmallHuffmanTree(Common::BitStream8LSB &bs); - uint16 getCode(Common::BitStream &bs); + uint16 getCode(Common::BitStream8LSB &bs); private: enum { SMK_NODE = 0x8000 @@ -70,10 +70,10 @@ private: uint16 _prefixtree[256]; byte _prefixlength[256]; - Common::BitStream &_bs; + Common::BitStream8LSB &_bs; }; -SmallHuffmanTree::SmallHuffmanTree(Common::BitStream &bs) +SmallHuffmanTree::SmallHuffmanTree(Common::BitStream8LSB &bs) : _treeSize(0), _bs(bs) { uint32 bit = _bs.getBit(); assert(bit); @@ -118,7 +118,7 @@ uint16 SmallHuffmanTree::decodeTree(uint32 prefix, int length) { return r1+r2+1; } -uint16 SmallHuffmanTree::getCode(Common::BitStream &bs) { +uint16 SmallHuffmanTree::getCode(Common::BitStream8LSB &bs) { byte peek = bs.peekBits(MIN<uint32>(bs.size() - bs.pos(), 8)); uint16 *p = &_tree[_prefixtree[peek]]; bs.skip(_prefixlength[peek]); @@ -139,11 +139,11 @@ uint16 SmallHuffmanTree::getCode(Common::BitStream &bs) { class BigHuffmanTree { public: - BigHuffmanTree(Common::BitStream &bs, int allocSize); + BigHuffmanTree(Common::BitStream8LSB &bs, int allocSize); ~BigHuffmanTree(); void reset(); - uint32 getCode(Common::BitStream &bs); + uint32 getCode(Common::BitStream8LSB &bs); private: enum { SMK_NODE = 0x80000000 @@ -159,13 +159,13 @@ private: byte _prefixlength[256]; /* Used during construction */ - Common::BitStream &_bs; + Common::BitStream8LSB &_bs; uint32 _markers[3]; SmallHuffmanTree *_loBytes; SmallHuffmanTree *_hiBytes; }; -BigHuffmanTree::BigHuffmanTree(Common::BitStream &bs, int allocSize) +BigHuffmanTree::BigHuffmanTree(Common::BitStream8LSB &bs, int allocSize) : _bs(bs) { uint32 bit = _bs.getBit(); if (!bit) { @@ -256,7 +256,7 @@ uint32 BigHuffmanTree::decodeTree(uint32 prefix, int length) { return r1+r2+1; } -uint32 BigHuffmanTree::getCode(Common::BitStream &bs) { +uint32 BigHuffmanTree::getCode(Common::BitStream8LSB &bs) { byte peek = bs.peekBits(MIN<uint32>(bs.size() - bs.pos(), 8)); uint32 *p = &_tree[_prefixtree[peek]]; bs.skip(_prefixlength[peek]); @@ -553,14 +553,14 @@ Graphics::PixelFormat SmackerDecoder::SmackerVideoTrack::getPixelFormat() const return _surface->format; } -void SmackerDecoder::SmackerVideoTrack::readTrees(Common::BitStream &bs, uint32 mMapSize, uint32 mClrSize, uint32 fullSize, uint32 typeSize) { +void SmackerDecoder::SmackerVideoTrack::readTrees(Common::BitStream8LSB &bs, uint32 mMapSize, uint32 mClrSize, uint32 fullSize, uint32 typeSize) { _MMapTree = new BigHuffmanTree(bs, mMapSize); _MClrTree = new BigHuffmanTree(bs, mClrSize); _FullTree = new BigHuffmanTree(bs, fullSize); _TypeTree = new BigHuffmanTree(bs, typeSize); } -void SmackerDecoder::SmackerVideoTrack::decodeFrame(Common::BitStream &bs) { +void SmackerDecoder::SmackerVideoTrack::decodeFrame(Common::BitStream8LSB &bs) { _MMapTree->reset(); _MClrTree->reset(); _FullTree->reset(); diff --git a/video/smk_decoder.h b/video/smk_decoder.h index bc04a683d2..e0ea600f6d 100644 --- a/video/smk_decoder.h +++ b/video/smk_decoder.h @@ -23,6 +23,7 @@ #ifndef VIDEO_SMK_PLAYER_H #define VIDEO_SMK_PLAYER_H +#include "common/bitstream.h" #include "common/rational.h" #include "graphics/pixelformat.h" #include "graphics/surface.h" @@ -34,7 +35,6 @@ class QueuingAudioStream; } namespace Common { -class BitStream; class SeekableReadStream; } @@ -91,9 +91,9 @@ protected: const byte *getPalette() const { _dirtyPalette = false; return _palette; } bool hasDirtyPalette() const { return _dirtyPalette; } - void readTrees(Common::BitStream &bs, uint32 mMapSize, uint32 mClrSize, uint32 fullSize, uint32 typeSize); + void readTrees(Common::BitStream8LSB &bs, uint32 mMapSize, uint32 mClrSize, uint32 fullSize, uint32 typeSize); void increaseCurFrame() { _curFrame++; } - void decodeFrame(Common::BitStream &bs); + void decodeFrame(Common::BitStream8LSB &bs); void unpackPalette(Common::SeekableReadStream *stream); protected: |