aboutsummaryrefslogtreecommitdiff
path: root/image
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2017-07-12 17:04:39 +0200
committerWillem Jan Palenstijn2017-08-24 19:46:59 +0200
commit60fae8847eeef85b6cda99cc1d690c59e292ecf7 (patch)
tree579c2b136c717f086d321214b12d881fa0929d41 /image
parentdde259f06813534c7179a714403d8fd6fe918d09 (diff)
downloadscummvm-rg350-60fae8847eeef85b6cda99cc1d690c59e292ecf7.tar.gz
scummvm-rg350-60fae8847eeef85b6cda99cc1d690c59e292ecf7.tar.bz2
scummvm-rg350-60fae8847eeef85b6cda99cc1d690c59e292ecf7.zip
IMAGE: Inline indeo getVLC2
Diffstat (limited to 'image')
-rw-r--r--image/codecs/indeo/get_bits.cpp60
-rw-r--r--image/codecs/indeo/get_bits.h32
-rw-r--r--image/codecs/indeo/indeo.cpp9
-rw-r--r--image/codecs/indeo4.cpp24
-rw-r--r--image/codecs/indeo5.cpp8
-rw-r--r--image/module.mk1
6 files changed, 51 insertions, 83 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..c2d593bfb5 100644
--- a/image/codecs/indeo/get_bits.h
+++ b/image/codecs/indeo/get_bits.h
@@ -54,7 +54,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..4658068b27 100644
--- a/image/codecs/indeo4.cpp
+++ b/image/codecs/indeo4.cpp
@@ -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..858c634704 100644
--- a/image/codecs/indeo5.cpp
+++ b/image/codecs/indeo5.cpp
@@ -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/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 \