huffdecode.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
89876b75747f59feeadde56f2c4950817fdca4ccChristian Maeder/***********************************************************************
b58a5478c73bcb2408dfd5f4d35e14b15c72fd46Christian Maeder* This software is part of the ast package *
89876b75747f59feeadde56f2c4950817fdca4ccChristian Maeder* Copyright (c) 1993-2011 AT&T Intellectual Property *
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu Prodescu* and is licensed under the *
89876b75747f59feeadde56f2c4950817fdca4ccChristian Maeder* Eclipse Public License, Version 1.0 *
3f69b6948966979163bdfe8331c38833d5d90ecdChristian Maeder* by AT&T Intellectual Property *
89876b75747f59feeadde56f2c4950817fdca4ccChristian Maeder* A copy of the License is available at *
89876b75747f59feeadde56f2c4950817fdca4ccChristian Maeder* http://www.eclipse.org/org/documents/epl-v10.html *
b58a5478c73bcb2408dfd5f4d35e14b15c72fd46Christian Maeder* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
89876b75747f59feeadde56f2c4950817fdca4ccChristian Maeder* Information and Software Systems Research *
f07bb197c32ccda6af72da82aa8029e4d6bfc99aChristian Maeder* AT&T Research *
f07bb197c32ccda6af72da82aa8029e4d6bfc99aChristian Maeder* Florham Park NJ *
f07bb197c32ccda6af72da82aa8029e4d6bfc99aChristian Maeder* David Korn <dgk@research.att.com> *
8f1f53a2595bb239389fb5119ef590fa48166595Christian Maeder***********************************************************************/
9029484754c7b2037321e7cbd077580866845265Christian Maeder * huffman coding decoding
f07bb197c32ccda6af72da82aa8029e4d6bfc99aChristian Maeder * AT&T Laboratories
9029484754c7b2037321e7cbd077580866845265Christian Maeder#define fillbuff(b,left,bit,inp) while(left<(bit))\
9029484754c7b2037321e7cbd077580866845265Christian Maeder return(-1); \
9029484754c7b2037321e7cbd077580866845265Christian Maeder/* read <n> bits from buffer <b> */
9029484754c7b2037321e7cbd077580866845265Christian Maeder#define getbits(b,left,n) (((b)>>(left-=(n)))&((1L<<(n))-1))
9029484754c7b2037321e7cbd077580866845265Christian Maeder/* return <n> bits */
static char *eof;
static unsigned char *getbuff(void);
register long buffer;
register int left, i, n;
register int lev = 0;
register unsigned char *outp;
register unsigned char *inp;
unsigned char *outend;
unsigned char *outbuff;
if(size>=0)
if(n > size)
n = size;
size -= n;
if(lev==0)
goto pout;
if (p == eof)
size = 0;
*outp++ = *p;
pout:
if(size==0)
if(size>0)
if(n > size)
n = size;
size -= n;
lev = 0;
lev++;
*eof++ = c;
c = intnodes[i];
numbits[c--] = 0;
static unsigned char *getbuff(void)
register unsigned char *cp;
if(!cp && n<0)
return(cp);
return(inbuff);