aboutsummaryrefslogtreecommitdiff
path: root/image
diff options
context:
space:
mode:
Diffstat (limited to 'image')
-rw-r--r--image/codecs/indeo/get_bits.cpp60
-rw-r--r--image/codecs/indeo/get_bits.h37
-rw-r--r--image/codecs/indeo/indeo.cpp9
-rw-r--r--image/codecs/indeo4.cpp28
-rw-r--r--image/codecs/indeo5.cpp12
-rw-r--r--image/codecs/svq1.cpp12
-rw-r--r--image/codecs/svq1.h14
-rw-r--r--image/module.mk1
8 files changed, 70 insertions, 103 deletions
diff --git a/image/codecs/indeo/get_bits.cpp b/image/codecs/indeo/get_bits.cpp
deleted file mode 100644
index f808a96e76..0000000000
--- a/image/codecs/indeo/get_bits.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "image/codecs/indeo/get_bits.h"
-
-namespace Image {
-namespace Indeo {
-
-int GetBits::getVLC2(int16 (*table)[2], int bits, int maxDepth) {
- int code;
- int n, nbBits;
- unsigned int index;
-
- index = peekBits(bits);
- code = table[index][0];
- n = table[index][1];
-
- if (maxDepth > 1 && n < 0) {
- skip(bits);
- nbBits = -n;
-
- index = peekBits(nbBits) + code;
- code = table[index][0];
- n = table[index][1];
-
- if (maxDepth > 2 && n < 0) {
- skip(nbBits);
- nbBits = -n;
-
- index = peekBits(nbBits) + code;
- code = table[index][0];
- n = table[index][1];
- }
- }
-
- skip(n);
- return code;
-}
-
-} // End of namespace Indeo
-} // End of namespace Image
diff --git a/image/codecs/indeo/get_bits.h b/image/codecs/indeo/get_bits.h
index 359d8fcab0..f972e68ae0 100644
--- a/image/codecs/indeo/get_bits.h
+++ b/image/codecs/indeo/get_bits.h
@@ -31,15 +31,14 @@ namespace Indeo {
/**
* Intel Indeo Bitstream reader
*/
-class GetBits : public Common::BitStream8LSB {
+class GetBits : public Common::BitStreamMemory8LSB {
public:
/**
* Constructor
* @param stream Source stream to reader from
* @param disposeAfterUse Whether to destroy stream in destructor
*/
- GetBits(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse
- = DisposeAfterUse::YES) : Common::BitStream8LSB(stream, disposeAfterUse) {}
+ GetBits(const uint8 *ptr, uint32 size) : Common::BitStreamMemory8LSB(new Common::BitStreamMemoryStream(ptr, size), DisposeAfterUse::YES) {}
/**
* The number of bits left
@@ -54,7 +53,37 @@ public:
* read the longest vlc code
* = (max_vlc_length + bits - 1) / bits
*/
- int getVLC2(int16 (*table)[2], int bits, int maxDepth);
+ template <int maxDepth>
+ int getVLC2(int16 (*table)[2], int bits) {
+ int code;
+ int n, nbBits;
+ unsigned int index;
+
+ index = peekBits(bits);
+ code = table[index][0];
+ n = table[index][1];
+
+ if (maxDepth > 1 && n < 0) {
+ skip(bits);
+ nbBits = -n;
+
+ index = peekBits(nbBits) + code;
+ code = table[index][0];
+ n = table[index][1];
+
+ if (maxDepth > 2 && n < 0) {
+ skip(nbBits);
+ nbBits = -n;
+
+ index = peekBits(nbBits) + code;
+ code = table[index][0];
+ n = table[index][1];
+ }
+ }
+
+ skip(n);
+ return code;
+ }
};
} // End of namespace Indeo
diff --git a/image/codecs/indeo/indeo.cpp b/image/codecs/indeo/indeo.cpp
index 769790b76f..f420069139 100644
--- a/image/codecs/indeo/indeo.cpp
+++ b/image/codecs/indeo/indeo.cpp
@@ -1258,16 +1258,15 @@ int IndeoDecoderBase::decodeCodedBlocks(GetBits *gb, IVIBandDesc *band,
// zero column flags
memset(colFlags, 0, sizeof(colFlags));
while (scanPos <= numCoeffs) {
- sym = gb->getVLC2(band->_blkVlc._tab->_table,
- IVI_VLC_BITS, 1);
+ sym = gb->getVLC2<1>(band->_blkVlc._tab->_table, IVI_VLC_BITS);
if (sym == rvmap->_eobSym)
break; // End of block
// Escape - run/val explicitly coded using 3 vlc codes
if (sym == rvmap->_escSym) {
- run = gb->getVLC2(band->_blkVlc._tab->_table, IVI_VLC_BITS, 1) + 1;
- lo = gb->getVLC2(band->_blkVlc._tab->_table, IVI_VLC_BITS, 1);
- hi = gb->getVLC2(band->_blkVlc._tab->_table, IVI_VLC_BITS, 1);
+ run = gb->getVLC2<1>(band->_blkVlc._tab->_table, IVI_VLC_BITS) + 1;
+ lo = gb->getVLC2<1>(band->_blkVlc._tab->_table, IVI_VLC_BITS);
+ hi = gb->getVLC2<1>(band->_blkVlc._tab->_table, IVI_VLC_BITS);
// merge them and convert into signed val
val = IVI_TOSIGNED((hi << 6) | lo);
} else {
diff --git a/image/codecs/indeo4.cpp b/image/codecs/indeo4.cpp
index b6ac0882e7..ead1d3a814 100644
--- a/image/codecs/indeo4.cpp
+++ b/image/codecs/indeo4.cpp
@@ -56,7 +56,7 @@ bool Indeo4Decoder::isIndeo4(Common::SeekableReadStream &stream) {
stream.seek(-16, SEEK_CUR);
// Validate the first 18-bit word has the correct identifier
- Indeo::GetBits gb(new Common::MemoryReadStream(buffer, 16 * 8), DisposeAfterUse::YES);
+ Indeo::GetBits gb(buffer, 16 * 8);
bool isIndeo4 = gb.getBits(18) == 0x3FFF8;
return isIndeo4;
@@ -74,7 +74,7 @@ const Graphics::Surface *Indeo4Decoder::decodeFrame(Common::SeekableReadStream &
_ctx._frameSize = stream.size();
// Set up the GetBits instance for reading the data
- _ctx._gb = new GetBits(new Common::MemoryReadStream(_ctx._frameData, _ctx._frameSize));
+ _ctx._gb = new GetBits(_ctx._frameData, _ctx._frameSize);
// Decode the frame
int err = decodeIndeoFrame();
@@ -484,8 +484,8 @@ int Indeo4Decoder::decodeMbInfo(IVIBandDesc *band, IVITile *tile) {
mb->_qDelta = 0;
if (!band->_plane && !band->_bandNum && _ctx._inQ) {
- mb->_qDelta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table,
- IVI_VLC_BITS, 1);
+ mb->_qDelta = _ctx._gb->getVLC2<1>(_ctx._mbVlc._tab->_table,
+ IVI_VLC_BITS);
mb->_qDelta = IVI_TOSIGNED(mb->_qDelta);
}
@@ -522,8 +522,8 @@ int Indeo4Decoder::decodeMbInfo(IVIBandDesc *band, IVITile *tile) {
if (refMb) mb->_qDelta = refMb->_qDelta;
} else if (mb->_cbp || (!band->_plane && !band->_bandNum &&
_ctx._inQ)) {
- mb->_qDelta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table,
- IVI_VLC_BITS, 1);
+ mb->_qDelta = _ctx._gb->getVLC2<1>(_ctx._mbVlc._tab->_table,
+ IVI_VLC_BITS);
mb->_qDelta = IVI_TOSIGNED(mb->_qDelta);
}
@@ -543,22 +543,22 @@ int Indeo4Decoder::decodeMbInfo(IVIBandDesc *band, IVITile *tile) {
}
} else {
// decode motion vector deltas
- mvDelta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table,
- IVI_VLC_BITS, 1);
+ mvDelta = _ctx._gb->getVLC2<1>(_ctx._mbVlc._tab->_table,
+ IVI_VLC_BITS);
mvY += IVI_TOSIGNED(mvDelta);
- mvDelta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table,
- IVI_VLC_BITS, 1);
+ mvDelta = _ctx._gb->getVLC2<1>(_ctx._mbVlc._tab->_table,
+ IVI_VLC_BITS);
mvX += IVI_TOSIGNED(mvDelta);
mb->_mvX = mvX;
mb->_mvY = mvY;
if (mb->_type == 3) {
- mvDelta = _ctx._gb->getVLC2(
+ mvDelta = _ctx._gb->getVLC2<1>(
_ctx._mbVlc._tab->_table,
- IVI_VLC_BITS, 1);
+ IVI_VLC_BITS);
mvY += IVI_TOSIGNED(mvDelta);
- mvDelta = _ctx._gb->getVLC2(
+ mvDelta = _ctx._gb->getVLC2<1>(
_ctx._mbVlc._tab->_table,
- IVI_VLC_BITS, 1);
+ IVI_VLC_BITS);
mvX += IVI_TOSIGNED(mvDelta);
mb->_bMvX = -mvX;
mb->_bMvY = -mvY;
diff --git a/image/codecs/indeo5.cpp b/image/codecs/indeo5.cpp
index aca49c3d55..c4e98d4ac7 100644
--- a/image/codecs/indeo5.cpp
+++ b/image/codecs/indeo5.cpp
@@ -67,7 +67,7 @@ bool Indeo5Decoder::isIndeo5(Common::SeekableReadStream &stream) {
stream.seek(-16, SEEK_CUR);
// Validate the first 5-bit word has the correct identifier
- Indeo::GetBits gb(new Common::MemoryReadStream(buffer, 16 * 8));
+ Indeo::GetBits gb(buffer, 16 * 8);
bool isIndeo5 = gb.getBits(5) == 0x1F;
return isIndeo5;
@@ -85,7 +85,7 @@ const Graphics::Surface *Indeo5Decoder::decodeFrame(Common::SeekableReadStream &
_ctx._frameSize = stream.size();
// Set up the GetBits instance for reading the data
- _ctx._gb = new GetBits(new Common::MemoryReadStream(_ctx._frameData, _ctx._frameSize));
+ _ctx._gb = new GetBits(_ctx._frameData, _ctx._frameSize);
// Decode the frame
int err = decodeIndeoFrame();
@@ -299,7 +299,7 @@ int Indeo5Decoder::decodeMbInfo(IVIBandDesc *band, IVITile *tile) {
mb->_qDelta = 0;
if (!band->_plane && !band->_bandNum && (_ctx._frameFlags & 8)) {
- mb->_qDelta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table, IVI_VLC_BITS, 1);
+ mb->_qDelta = _ctx._gb->getVLC2<1>(_ctx._mbVlc._tab->_table, IVI_VLC_BITS);
mb->_qDelta = IVI_TOSIGNED(mb->_qDelta);
}
@@ -332,7 +332,7 @@ int Indeo5Decoder::decodeMbInfo(IVIBandDesc *band, IVITile *tile) {
if (refMb) mb->_qDelta = refMb->_qDelta;
} else if (mb->_cbp || (!band->_plane && !band->_bandNum &&
(_ctx._frameFlags & 8))) {
- mb->_qDelta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table, IVI_VLC_BITS, 1);
+ mb->_qDelta = _ctx._gb->getVLC2<1>(_ctx._mbVlc._tab->_table, IVI_VLC_BITS);
mb->_qDelta = IVI_TOSIGNED(mb->_qDelta);
}
}
@@ -351,9 +351,9 @@ int Indeo5Decoder::decodeMbInfo(IVIBandDesc *band, IVITile *tile) {
}
} else {
// decode motion vector deltas
- mvDelta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table, IVI_VLC_BITS, 1);
+ mvDelta = _ctx._gb->getVLC2<1>(_ctx._mbVlc._tab->_table, IVI_VLC_BITS);
mvY += IVI_TOSIGNED(mvDelta);
- mvDelta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table, IVI_VLC_BITS, 1);
+ mvDelta = _ctx._gb->getVLC2<1>(_ctx._mbVlc._tab->_table, IVI_VLC_BITS);
mvX += IVI_TOSIGNED(mvDelta);
mb->_mvX = mvX;
mb->_mvY = mvY;
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/image/module.mk b/image/module.mk
index 2ede7c3bdb..be049eb818 100644
--- a/image/module.mk
+++ b/image/module.mk
@@ -24,7 +24,6 @@ MODULE_OBJS := \
codecs/smc.o \
codecs/svq1.o \
codecs/truemotion1.o \
- codecs/indeo/get_bits.o \
codecs/indeo/indeo.o \
codecs/indeo/indeo_dsp.o \
codecs/indeo/mem.o \