/***********************************************************************
* *
* 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"
/* Recursively partitioning a data string to improve Huffman coding
**
** Written by Binh Dao Vo and Kiem-Phong Vo
*/
typedef struct _part_s
} Part_t;
/* compute the byte frequencies and encoding cost of a string */
#if __STD_C
#else
#endif
{
double e;
int i;
for(e = 0., i = 0; i < VCH_SIZE; ++i)
return e;
}
#if __STD_C
#else
double e; /* current entropy value */
int add; /* 1/0 for adding/subtracting */
#endif
{
int b;
for(b = 0; b < VCH_SIZE; ++b)
{ if(fr[b] == 0)
continue;
if(add)
}
return e;
}
#if __STD_C
#else
#endif
{
return -1;
return 0;
}
/* recursively partition a dataset into parts with different statistical models */
#if __STD_C
#else
double re; /* entropy of this dataset */
#endif
{
/* cost of coding the entire data set */
/* see if large enough to split */
/* first partition is at minsz */
/* loop adding 1 to left part and subtracting 1 from right part */
{ b = data[p++];
/* update the costs of left&right parts */
{ /* good partition, recurse to do the two parts */
return -1;
return -1;
return 0;
}
}
}
#if __STD_C
#else
#endif
{
double e;
if(size == 0)
return 0;
/* estimate table entropy */
/* estimate the cost of emitting a Huffman table */
for(c = 0, n = 0; n < VCH_SIZE; ++n)
if(freq[n])
c += 1;
/* get buffer space to write data */
return -1;
/* recursively partition into smaller segments and compress */
return -1;
return -1;
if(out)
return n;
}
#if __STD_C
#else
#endif
{
if(size == 0)
return 0;
return -1;
/* get the size of uncompressed data */
return -1;
/* set up buffer */
return -1;
{ /* get the size and compressed data of this segment */
return -1;
/* decompress the data */
return -1;
/* write out data */
return -1;
}
/* free unused buffers */
if(out)
return sz;
}
/* Event handler */
#if __STD_C
#else
int type;
#endif
{
if(type == VC_OPENING)
return -1;
/* open the entropy coder handle */
return -1;
}
return 0;
}
else if(type == VC_CLOSING)
}
return 0;
}
else if(type == VC_FREEBUFFER)
return 0;
}
else return 0;
}
{ pthuff,
"huffpart", "Huffman encoding by partitioning.",
"[-version?huffpart (AT&T Research) 2003-01-01]" USAGE_LICENSE,
1024*1024,
0
};