vchuffman.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 2003-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#include "vchhdr.h"
/* Static Huffman encoding.
**
** Written by Kiem-Phong Vo (kpv@research.att.com)
*/
/* internal handle for Huffman coder and decoder */
typedef struct _vchuff_s
int type;
} Vchuff_t;
/* sentinels to tell that application has set these tables */
/* Copy frequencies, code sizes and code bits into a Vcodex handle. */
#if __STD_C
#else
#endif
{
if(freq)
}
}
return 0;
}
#if __STD_C
#else
#endif
{
ssize_t s;
if(dtsz == 0) /* no data to compress */
return 0;
/* compute code frequencies and lengths */
}
return -1;
/* estimate compressed size */
s = (s+7)/8; /* round up to byte count */
}
else s = 1;
/* set up buffer for output */
s += VCH_SIZE;
return -1;
else
{ /* output the code tree */
return -1;
}
return -1;
if(out)
return s;
}
#if __STD_C
#else
#endif
{
if(dtsz == 0)
return 0;
return -1;
return -1;
while(o < endo)
*o++ = n;
}
else
return -1;
return -1;
return -1;
if(size[p] > 0) /* byte is found */
if((o += 1) >= endo)
break;
}
else if(size[p] == 0) /* corrupted data */
return -1;
else
}
}
}
if(out)
return o-output;
}
#if __STD_C
#else
int type;
#endif
{
if(type == VC_OPENING)
return -1;
return 0;
}
else if(type == VC_CLOSING)
}
return 0;
}
else return 0;
}
{ vchuff,
"huffman", "Huffman encoding.",
"[-version?huffman (AT&T Research) 2003-01-01]" USAGE_LICENSE,
1024*1024,
0
};