IMAGE: Inline indeo getVLC2
This commit is contained in:
parent
dde259f068
commit
60fae8847e
6 changed files with 51 additions and 83 deletions
|
@ -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
|
|
|
@ -54,7 +54,37 @@ public:
|
||||||
* read the longest vlc code
|
* read the longest vlc code
|
||||||
* = (max_vlc_length + bits - 1) / bits
|
* = (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
|
} // End of namespace Indeo
|
||||||
|
|
|
@ -1258,16 +1258,15 @@ int IndeoDecoderBase::decodeCodedBlocks(GetBits *gb, IVIBandDesc *band,
|
||||||
// zero column flags
|
// zero column flags
|
||||||
memset(colFlags, 0, sizeof(colFlags));
|
memset(colFlags, 0, sizeof(colFlags));
|
||||||
while (scanPos <= numCoeffs) {
|
while (scanPos <= numCoeffs) {
|
||||||
sym = gb->getVLC2(band->_blkVlc._tab->_table,
|
sym = gb->getVLC2<1>(band->_blkVlc._tab->_table, IVI_VLC_BITS);
|
||||||
IVI_VLC_BITS, 1);
|
|
||||||
if (sym == rvmap->_eobSym)
|
if (sym == rvmap->_eobSym)
|
||||||
break; // End of block
|
break; // End of block
|
||||||
|
|
||||||
// Escape - run/val explicitly coded using 3 vlc codes
|
// Escape - run/val explicitly coded using 3 vlc codes
|
||||||
if (sym == rvmap->_escSym) {
|
if (sym == rvmap->_escSym) {
|
||||||
run = gb->getVLC2(band->_blkVlc._tab->_table, IVI_VLC_BITS, 1) + 1;
|
run = gb->getVLC2<1>(band->_blkVlc._tab->_table, IVI_VLC_BITS) + 1;
|
||||||
lo = gb->getVLC2(band->_blkVlc._tab->_table, IVI_VLC_BITS, 1);
|
lo = gb->getVLC2<1>(band->_blkVlc._tab->_table, IVI_VLC_BITS);
|
||||||
hi = gb->getVLC2(band->_blkVlc._tab->_table, IVI_VLC_BITS, 1);
|
hi = gb->getVLC2<1>(band->_blkVlc._tab->_table, IVI_VLC_BITS);
|
||||||
// merge them and convert into signed val
|
// merge them and convert into signed val
|
||||||
val = IVI_TOSIGNED((hi << 6) | lo);
|
val = IVI_TOSIGNED((hi << 6) | lo);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -484,8 +484,8 @@ int Indeo4Decoder::decodeMbInfo(IVIBandDesc *band, IVITile *tile) {
|
||||||
|
|
||||||
mb->_qDelta = 0;
|
mb->_qDelta = 0;
|
||||||
if (!band->_plane && !band->_bandNum && _ctx._inQ) {
|
if (!band->_plane && !band->_bandNum && _ctx._inQ) {
|
||||||
mb->_qDelta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table,
|
mb->_qDelta = _ctx._gb->getVLC2<1>(_ctx._mbVlc._tab->_table,
|
||||||
IVI_VLC_BITS, 1);
|
IVI_VLC_BITS);
|
||||||
mb->_qDelta = IVI_TOSIGNED(mb->_qDelta);
|
mb->_qDelta = IVI_TOSIGNED(mb->_qDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -522,8 +522,8 @@ int Indeo4Decoder::decodeMbInfo(IVIBandDesc *band, IVITile *tile) {
|
||||||
if (refMb) mb->_qDelta = refMb->_qDelta;
|
if (refMb) mb->_qDelta = refMb->_qDelta;
|
||||||
} else if (mb->_cbp || (!band->_plane && !band->_bandNum &&
|
} else if (mb->_cbp || (!band->_plane && !band->_bandNum &&
|
||||||
_ctx._inQ)) {
|
_ctx._inQ)) {
|
||||||
mb->_qDelta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table,
|
mb->_qDelta = _ctx._gb->getVLC2<1>(_ctx._mbVlc._tab->_table,
|
||||||
IVI_VLC_BITS, 1);
|
IVI_VLC_BITS);
|
||||||
mb->_qDelta = IVI_TOSIGNED(mb->_qDelta);
|
mb->_qDelta = IVI_TOSIGNED(mb->_qDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -543,22 +543,22 @@ int Indeo4Decoder::decodeMbInfo(IVIBandDesc *band, IVITile *tile) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// decode motion vector deltas
|
// decode motion vector deltas
|
||||||
mvDelta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table,
|
mvDelta = _ctx._gb->getVLC2<1>(_ctx._mbVlc._tab->_table,
|
||||||
IVI_VLC_BITS, 1);
|
IVI_VLC_BITS);
|
||||||
mvY += IVI_TOSIGNED(mvDelta);
|
mvY += IVI_TOSIGNED(mvDelta);
|
||||||
mvDelta = _ctx._gb->getVLC2(_ctx._mbVlc._tab->_table,
|
mvDelta = _ctx._gb->getVLC2<1>(_ctx._mbVlc._tab->_table,
|
||||||
IVI_VLC_BITS, 1);
|
IVI_VLC_BITS);
|
||||||
mvX += IVI_TOSIGNED(mvDelta);
|
mvX += IVI_TOSIGNED(mvDelta);
|
||||||
mb->_mvX = mvX;
|
mb->_mvX = mvX;
|
||||||
mb->_mvY = mvY;
|
mb->_mvY = mvY;
|
||||||
if (mb->_type == 3) {
|
if (mb->_type == 3) {
|
||||||
mvDelta = _ctx._gb->getVLC2(
|
mvDelta = _ctx._gb->getVLC2<1>(
|
||||||
_ctx._mbVlc._tab->_table,
|
_ctx._mbVlc._tab->_table,
|
||||||
IVI_VLC_BITS, 1);
|
IVI_VLC_BITS);
|
||||||
mvY += IVI_TOSIGNED(mvDelta);
|
mvY += IVI_TOSIGNED(mvDelta);
|
||||||
mvDelta = _ctx._gb->getVLC2(
|
mvDelta = _ctx._gb->getVLC2<1>(
|
||||||
_ctx._mbVlc._tab->_table,
|
_ctx._mbVlc._tab->_table,
|
||||||
IVI_VLC_BITS, 1);
|
IVI_VLC_BITS);
|
||||||
mvX += IVI_TOSIGNED(mvDelta);
|
mvX += IVI_TOSIGNED(mvDelta);
|
||||||
mb->_bMvX = -mvX;
|
mb->_bMvX = -mvX;
|
||||||
mb->_bMvY = -mvY;
|
mb->_bMvY = -mvY;
|
||||||
|
|
|
@ -299,7 +299,7 @@ int Indeo5Decoder::decodeMbInfo(IVIBandDesc *band, IVITile *tile) {
|
||||||
|
|
||||||
mb->_qDelta = 0;
|
mb->_qDelta = 0;
|
||||||
if (!band->_plane && !band->_bandNum && (_ctx._frameFlags & 8)) {
|
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);
|
mb->_qDelta = IVI_TOSIGNED(mb->_qDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,7 +332,7 @@ int Indeo5Decoder::decodeMbInfo(IVIBandDesc *band, IVITile *tile) {
|
||||||
if (refMb) mb->_qDelta = refMb->_qDelta;
|
if (refMb) mb->_qDelta = refMb->_qDelta;
|
||||||
} else if (mb->_cbp || (!band->_plane && !band->_bandNum &&
|
} else if (mb->_cbp || (!band->_plane && !band->_bandNum &&
|
||||||
(_ctx._frameFlags & 8))) {
|
(_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);
|
mb->_qDelta = IVI_TOSIGNED(mb->_qDelta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -351,9 +351,9 @@ int Indeo5Decoder::decodeMbInfo(IVIBandDesc *band, IVITile *tile) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// decode motion vector deltas
|
// 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);
|
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);
|
mvX += IVI_TOSIGNED(mvDelta);
|
||||||
mb->_mvX = mvX;
|
mb->_mvX = mvX;
|
||||||
mb->_mvY = mvY;
|
mb->_mvY = mvY;
|
||||||
|
|
|
@ -24,7 +24,6 @@ MODULE_OBJS := \
|
||||||
codecs/smc.o \
|
codecs/smc.o \
|
||||||
codecs/svq1.o \
|
codecs/svq1.o \
|
||||||
codecs/truemotion1.o \
|
codecs/truemotion1.o \
|
||||||
codecs/indeo/get_bits.o \
|
|
||||||
codecs/indeo/indeo.o \
|
codecs/indeo/indeo.o \
|
||||||
codecs/indeo/indeo_dsp.o \
|
codecs/indeo/indeo_dsp.o \
|
||||||
codecs/indeo/mem.o \
|
codecs/indeo/mem.o \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue