diff options
Diffstat (limited to 'image/codecs/indeo')
-rw-r--r-- | image/codecs/indeo/get_bits.cpp | 60 | ||||
-rw-r--r-- | image/codecs/indeo/get_bits.h | 37 | ||||
-rw-r--r-- | image/codecs/indeo/indeo.cpp | 9 |
3 files changed, 37 insertions, 69 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 { |