diff options
| author | Willem Jan Palenstijn | 2017-07-12 17:04:39 +0200 |
|---|---|---|
| committer | Willem Jan Palenstijn | 2017-08-24 19:46:59 +0200 |
| commit | 60fae8847eeef85b6cda99cc1d690c59e292ecf7 (patch) | |
| tree | 579c2b136c717f086d321214b12d881fa0929d41 /image/codecs/indeo | |
| parent | dde259f06813534c7179a714403d8fd6fe918d09 (diff) | |
| download | scummvm-rg350-60fae8847eeef85b6cda99cc1d690c59e292ecf7.tar.gz scummvm-rg350-60fae8847eeef85b6cda99cc1d690c59e292ecf7.tar.bz2 scummvm-rg350-60fae8847eeef85b6cda99cc1d690c59e292ecf7.zip | |
IMAGE: Inline indeo getVLC2
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 | 32 | ||||
| -rw-r--r-- | image/codecs/indeo/indeo.cpp | 9 |
3 files changed, 35 insertions, 66 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 { |
