#pragma prototyped
/*-------------------------------------------------------------*/
/*--- Decompression machinery ---*/
/*--- decompress.c ---*/
/*-------------------------------------------------------------*/
/*--
library for lossless, block-sorting data compression.
Copyright (C) 1996-1998 Julian R Seward. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
4. The name of the author may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Julian Seward, Guildford, Surrey, UK.
jseward@acm.org
This program is based on (at least) the work of:
Mike Burrows
David Wheeler
Peter Fenwick
Alistair Moffat
Radford Neal
Ian H. Witten
Robert Sedgewick
Jon L. Bentley
For more information on these sources, see the manual.
--*/
#include "bzhdr.h"
/*---------------------------------------------------*/
static
{
Int32 i;
s->nInUse = 0;
for (i = 0; i < 256; i++)
if (s->inUse[i]) {
s->seqToUnseq[s->nInUse] = i;
s->nInUse++;
}
}
/*---------------------------------------------------*/
while (True) { \
UInt32 v; \
v = (s->bsBuff >> \
vvv = v; \
break; \
} \
s->bsBuff \
= (s->bsBuff << 8) | \
((UInt32) \
s->bsLive += 8; \
}
/*---------------------------------------------------*/
{ \
if (groupPos == 0) { \
groupNo++; \
} \
groupPos--; \
zn++; \
}; \
}
/*---------------------------------------------------*/
{
Int32 i ;
Int32 j;
Int32 t;
Int32 N;
if (s->state == BZ_X_MAGIC_1) {
/*initialise the save area*/
s->save_i = 0;
s->save_j = 0;
s->save_t = 0;
s->save_alphaSize = 0;
s->save_nGroups = 0;
s->save_nSelectors = 0;
s->save_EOB = 0;
s->save_groupNo = 0;
s->save_groupPos = 0;
s->save_nextSym = 0;
s->save_nblockMAX = 0;
s->save_nblock = 0;
s->save_es = 0;
s->save_N = 0;
s->save_curr = 0;
s->save_zt = 0;
s->save_zn = 0;
s->save_zvec = 0;
s->save_zj = 0;
s->save_gSel = 0;
s->save_gMinlen = 0;
s->save_gLimit = NULL;
s->save_gBase = NULL;
s->save_gPerm = NULL;
}
/*restore from the save area*/
i = s->save_i;
j = s->save_j;
t = s->save_t;
alphaSize = s->save_alphaSize;
nGroups = s->save_nGroups;
nSelectors = s->save_nSelectors;
groupNo = s->save_groupNo;
groupPos = s->save_groupPos;
nextSym = s->save_nextSym;
nblockMAX = s->save_nblockMAX;
nblock = s->save_nblock;
N = s->save_N;
gMinlen = s->save_gMinlen;
gLimit = s->save_gLimit;
gBase = s->save_gBase;
gPerm = s->save_gPerm;
switch (s->state) {
if (s->blockSize100k < '1' ||
s->blockSize100k -= '0';
if (s->smallDecompress) {
);
} else {
}
s->currBlockNo++;
if (s->verbosity >= 2)
s->storedBlockCRC = 0;
s->origPtr = 0;
/*--- Receive the mapping table ---*/
for (i = 0; i < 16; i++) {
if (uc == 1)
}
for (i = 0; i < 16; i++)
if (s->inUse16[i])
for (j = 0; j < 16; j++) {
}
makeMaps_d ( s );
/*--- Now the selectors ---*/
for (i = 0; i < nSelectors; i++) {
j = 0;
while (True) {
if (uc == 0) break;
j++;
}
s->selectorMtf[i] = j;
}
/*--- Undo the MTF values for the selectors. ---*/
{
for (i = 0; i < nSelectors; i++) {
v = s->selectorMtf[i];
}
}
/*--- Now the coding tables ---*/
for (t = 0; t < nGroups; t++) {
for (i = 0; i < alphaSize; i++) {
while (True) {
if (uc == 0) break;
}
}
}
/*--- Create the Huffman decoding tables ---*/
for (t = 0; t < nGroups; t++) {
minLen = 32;
maxLen = 0;
for (i = 0; i < alphaSize; i++) {
}
&(s->limit[t][0]),
&(s->base[t][0]),
&(s->perm[t][0]),
&(s->len[t][0]),
);
}
/*--- Now the MTF values ---*/
groupNo = -1;
groupPos = 0;
for (i = 0; i <= 255; i++) s->unzftab[i] = 0;
/*-- MTF init --*/
{
kk--;
}
}
}
/*-- end MTF init --*/
nblock = 0;
while (True) {
es = -1;
N = 1;
do {
N = N * 2;
}
es++;
if (s->smallDecompress)
while (es > 0) {
nblock++;
es--;
}
else
while (es > 0) {
nblock++;
es--;
};
continue;
} else {
/*-- uc = MTF ( nextSym-1 ) --*/
{
/* avoid general-case expense */
while (nn > 3) {
nn -= 4;
}
while (nn > 0) {
};
} else {
/* general case */
};
while (lno > 0) {
lno--;
}
s->mtfbase[0]--;
if (s->mtfbase[0] == 0) {
kk--;
}
}
}
}
}
/*-- end uc = MTF ( nextSym-1 ) --*/
if (s->smallDecompress)
nblock++;
continue;
}
}
s->state_out_len = 0;
s->state_out_ch = 0;
BZ_INITIALISE_CRC ( s->calculatedBlockCRC );
s->state = BZ_X_OUTPUT;
/*-- Set up cftab to facilitate generation of T^(-1) --*/
s->cftab[0] = 0;
if (s->smallDecompress) {
/*-- Make a copy of cftab, used in generation of T --*/
/*-- compute the T vector --*/
for (i = 0; i < nblock; i++) {
}
/*-- Compute T^(-1) by pointer reversal on T --*/
i = s->origPtr;
j = GET_LL(i);
do {
SET_LL(j, i);
i = j;
j = tmp;
}
while (i != s->origPtr);
s->nblock_used = 0;
if (s->blockRandomised) {
} else {
}
} else {
/*-- compute the T^(-1) vector --*/
for (i = 0; i < nblock; i++) {
}
s->nblock_used = 0;
if (s->blockRandomised) {
} else {
}
}
s->storedCombinedCRC = 0;
}
s->save_i = i;
s->save_j = j;
s->save_t = t;
s->save_alphaSize = alphaSize;
s->save_nGroups = nGroups;
s->save_nSelectors = nSelectors;
s->save_groupNo = groupNo;
s->save_groupPos = groupPos;
s->save_nextSym = nextSym;
s->save_nblockMAX = nblockMAX;
s->save_nblock = nblock;
s->save_N = N;
s->save_gMinlen = gMinlen;
s->save_gLimit = gLimit;
s->save_gBase = gBase;
s->save_gPerm = gPerm;
return retVal;
}
/*-------------------------------------------------------------*/
/*--- end decompress.c ---*/
/*-------------------------------------------------------------*/