[comp.sources.misc] v13i076: Faces v1.4.5: a visual list monitor for mail etc..

rburridge@Sun.COM (Rich Burridge) (07/03/90)

Posting-number: Volume 13, Issue 76
Submitted-by: rburridge@Sun.COM (Rich Burridge)
Archive-name: faces-1.4.5/part07

------CUT HERE------faces.part7-----CUT HERE------
#! /bin/sh
# this is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh to create the files:
#	compface (directory)
# This archive created: Fri Jun 29 10:45:27 EST 1990
#
#
export PATH; PATH=/bin:$PATH
#
if [ -f compface ]
then
echo shar: can not write a directory over file compface
else
if [ ! -d compface ]
then
echo shar: creating directory compface
mkdir compface
fi
echo shar: entering directory compface
cd compface
if [ -f Makefile ]
then
echo shar: will not over-write existing file Makefile
else
echo shar: extracting 'Makefile',     2054 characters
cat > Makefile <<'Funky_Stuff'
#
#  Compface - 48x48x1 image compression and decompression
#
#  Copyright (c) James Ashton - Sydney University - June 1990.
#
#  Written 11th November 1989.
#
#  Permission is given to distribute these sources, as long as the
#  copyright messages are not removed, and no monies are exchanged. 
#
#  No responsibility is taken for any errors on inaccuracies inherent
#  either to the comments or the code of this program, but if reported
#  to me, then an attempt will be made to fix them.

# BINDIR, LIBDIR, and MANDIR are expected to be overridden by the
# calling Makefile

BINDIR		= /usr/local/bin
LIBDIR		= /usr/local/lib
MANDIR		= /usr/manl

NAME		= compface
UNNAME		= uncompface
EXECUTABLE	= $(BINDIR)/$(NAME)
UNEXECUTABLE	= $(BINDIR)/$(UNNAME)
LIBNAME		= lib$(NAME).a
LIBRARY		= $(LIBDIR)/$(LIBNAME)
MAN1DIR		= $(MANDIR)/man1
MAN3DIR		= $(MANDIR)/man3
OBJECTS		= compface.o arith.o file.o compress.o gen.o
SOURCES		= compface.c arith.c file.c compress.c gen.c main.c
HDRS		= compface.h data.h
OTHERS		= README $(NAME).1 $(NAME).3 Makefile

CFLAGS		= -g

$(NAME) :	main.o $(LIBNAME)
		cc $(CFLAGS) -o $(NAME) main.o $(LIBNAME)
		rm -f $(UNNAME)
		ln $(NAME) $(UNNAME)

$(LIBNAME) :	$(OBJECTS)
		ar rc $(LIBNAME) $(OBJECTS)
		ranlib $(LIBNAME)

lint :
		lint -abchx $(SOURCES)

clean :
		rm -f *.o

clobber :
		rm -f *.o *.a *.sh core a.out $(NAME) $(UNNAME)

install :	$(NAME) $(LIBNAME)
		-cp $(NAME) $(EXECUTABLE)
		strip $(EXECUTABLE)
		rm -f $(UNEXECUTABLE)
		ln $(EXECUTABLE) $(UNEXECUTABLE)
		-cp $(NAME).1 $(MAN1DIR)
		rm -f $(MAN1DIR)1/$(UNNAME).1
		-ln $(MAN1DIR)/$(NAME).1 $(MAN1DIR)/$(UNNAME).1
		-cp $(LIBNAME) $(LIBRARY)
		-cp $(NAME).3 $(MAN3DIR)
		rm -f $(MAN3DIR)/$(UNNAME).3
		-ln $(MAN3DIR)/$(NAME).3 $(MAN3DIR)/$(UNNAME).3

shar :
		shar.script $(OTHERS) $(HDRS) $(SOURCES) > $(NAME).sh
		compress $(NAME).sh

arith.o:	arith.c compface.h data.h
compface.o:	compface.c compface.h data.h
compress.o:	compress.c compface.h data.h
file.o:		file.c compface.h data.h
gen.o:		gen.c compface.h data.h
main.o:		main.c compface.h data.h
Funky_Stuff
len=`wc -c < Makefile`
if [ $len !=     2054 ] ; then
echo error: Makefile was $len bytes long, should have been     2054
fi
fi # end of overwriting check
if [ -f README ]
then
echo shar: will not over-write existing file README
else
echo shar: extracting 'README',     1212 characters
cat > README <<'Funky_Stuff'
Compface - 48x48x1 image compression and decompression
Copyright (c) James Ashton 1990.
Written 89/11/11

Feel free to distribute this source at will so long as the above
message and this message are included in full.

The programme (two programmes really - but they're just links to each
other) converts 48x48x1 images to and from a compressed format.  The
uncompressed images are expected to contain 48x48/4 (576) hex digits.
All other characters and any `0's followed by `X' or `x' are ignored.
Usually the files are 48 lines of "0x%04X,0x%04X,0x%04X,".  The
compressed images contain some number of printable characters.  Non
printable characters, including ` ' are ignored.  The purpose of the
programme is to allow the inclusion of face images within mail headers
using the field name `X-face: '.

The programmes make use of a library which can be used to allow the
compression and decompression algorithms to be used in other
programmes such as mail despatchers and mail notification daemons.

A small amount of editing in the Makefile may be required to get it
going - mainly setting EXECUTABLE to what you want and putting the
manual entry in the right place.

						James Ashton.
						jaa@cs.su.oz.au
Funky_Stuff
len=`wc -c < README`
if [ $len !=     1212 ] ; then
echo error: README was $len bytes long, should have been     1212
fi
fi # end of overwriting check
if [ -f arith.c ]
then
echo shar: will not over-write existing file arith.c
else
echo shar: extracting 'arith.c',     3764 characters
cat > arith.c <<'Funky_Stuff'
/*
 *  Compface - 48x48x1 image compression and decompression
 *
 *  Copyright (c) James Ashton - Sydney University - June 1990.
 *
 *  Written 11th November 1989.
 *
 *  Permission is given to distribute these sources, as long as the
 *  copyright messages are not removed, and no monies are exchanged. 
 *
 *  No responsibility is taken for any errors on inaccuracies inherent
 *  either to the comments or the code of this program, but if reported
 *  to me, then an attempt will be made to fix them.
 */

#include "compface.h"

void RevPush(p)
Prob *p;
{
	if (NumProbs >= PIXELS * 2 - 1)
		longjmp(comp_env, ERR_INTERNAL);
	ProbBuf[NumProbs++] = p;
}
 
void BigPush(p)
Prob *p;
{
	static WORD tmp;

	BigDiv(p->p_range, &tmp);
	BigMul(0);
	BigAdd(tmp + p->p_offset);
}

BigPop(p)
register Prob *p; 
{
	static WORD tmp;
	register int i;

	BigDiv(0, &tmp);
	i = 0;
	while ((tmp < p->p_offset) || (tmp >= p->p_range + p->p_offset))
	{
		p++;
		i++;
	}
	BigMul(p->p_range);
	BigAdd(tmp - p->p_offset);
	return i;
}

#ifdef DEBUG
/* Print a BigInt in HexaDecimal
 */
void BigPrint()
{
	register int i, c, count;
	register WORD *w;

	count = 0;
	w = B.b_word + (i = B.b_words);
	while (i--)
	{
		w--;
		c = *((*w >> 4) + HexDigits);
		putc(c, stderr);
		c = *((*w & 0xf) + HexDigits);
		putc(c, stderr);
		if (++count >= 36)
		{
			putc('\\', stderr);
			putc('\n', stderr);
			count = 0;
		}
	}
	putc('\n', stderr);
}
#endif

/* Divide B by a storing the result in B and the remainder in the word
 * pointer to by r
 */
void BigDiv(a, r)
register WORD a, *r;
{
	register int i;
	register WORD *w;
	register COMP c, d;

	a &= WORDMASK;
	if ((a == 1) || (B.b_words == 0))
	{
		*r = 0;
		return;
	}
	if (a == 0)	/* treat this as a == WORDCARRY */
	{			/* and just shift everything right a WORD */
		i = --B.b_words;
		w = B.b_word;
		*r = *w;
		while (i--)
		{
			*w = *(w + 1);
			w++;
		}
		*w = 0;
		return;
	}
	w = B.b_word + (i = B.b_words);
	c = 0;
	while (i--)
	{
		c <<= BITSPERWORD;
		c += (COMP)*--w;
		d = c / (COMP)a;
		c = c % (COMP)a;
		*w = (WORD)(d & WORDMASK);
	}
	*r = c;
	if (B.b_word[B.b_words - 1] == 0)
		B.b_words--;
}

/* Multiply a by B storing the result in B
 */
void BigMul(a)
register WORD a;
{
	register int i;
	register WORD *w;
	register COMP c;

	a &= WORDMASK;
	if ((a == 1) || (B.b_words == 0))
		return;
	if (a == 0)	/* treat this as a == WORDCARRY */
	{			/* and just shift everything left a WORD */
		if ((i = B.b_words++) >= MAXWORDS - 1)
			longjmp(comp_env, ERR_INTERNAL);
		w = B.b_word + i;
		while (i--)
		{
			*w = *(w - 1);
			w--;
		}
		*w = 0;
		return;
	}
	i = B.b_words;
	w = B.b_word;
	c = 0;
	while (i--)
	{
		c += (COMP)*w * (COMP)a;
		*(w++) = (WORD)(c & WORDMASK);
		c >>= BITSPERWORD;
	}
	if (c)
	{
		if (B.b_words++ >= MAXWORDS)
			longjmp(comp_env, ERR_INTERNAL);
		*w = (COMP)(c & WORDMASK);
	}
}

#if 0
/* Subtract a from B storing the result in B
 */
void BigSub(a)
WORD a;
{
	register int i;
	register WORD *w;
	register COMP c;

	a &= WORDMASK;
	if (a == 0)
		return;
	i = 1;
	w = B.b_word;
	c = (COMP)*w - (COMP)a;
	*w = (WORD)(c & WORDMASK);
	while (c & WORDCARRY)
	{
		if (i >= B.b_words)
			longjmp(comp_env, ERR_INTERNAL);
		c = (COMP)*++w - 1;
		*w = (WORD)(c & WORDMASK);
		i++;
	}
	if ((i == B.b_words) && (*w == 0) && (i > 0))
		B.b_words--;
}
#endif

/* Add to a to B storing the result in B
 */
void BigAdd(a)
WORD a;
{
	register int i;
	register WORD *w;
	register COMP c;

	a &= WORDMASK;
	if (a == 0)
		return;
	i = 1;
	w = B.b_word;
	c = (COMP)*w + (COMP)a;
	*w = (WORD)(c & WORDMASK);
	while (c & WORDCARRY)
	{
		c = (COMP)*++w + 1;
		*w = (WORD)(c & WORDMASK);
		i++;
	}
	if (i > B.b_words)
		if (B.b_words++ >= MAXWORDS)
			longjmp(comp_env, ERR_INTERNAL);
		*w = (COMP)(c & WORDMASK);
}
Funky_Stuff
len=`wc -c < arith.c`
if [ $len !=     3764 ] ; then
echo error: arith.c was $len bytes long, should have been     3764
fi
fi # end of overwriting check
if [ -f compface.1 ]
then
echo shar: will not over-write existing file compface.1
else
echo shar: extracting 'compface.1',     2006 characters
cat > compface.1 <<'Funky_Stuff'
.TH COMPFACE 1 "25 January 1990"
.SH NAME
compface, uncompface \- compress and expand 48x48x1 face image files
.SH SYNOPSIS
.B compface
[
.I infile
[
.I outfile
]
]
.LP
.B uncompface
[
.I infile
[
.I outfile
]
]
.SH DESCRIPTION
.IX  compface  ""  "\fLcompface\fP \(em compress face image files"
.IX  uncompface  ""  "\fLuncompface\fP \(em uncompress face image files"
.I compface
is a filter for generating highly compressed representations of 48x48x1
face image files.
.I uncompface
is an inverse filter which performs an inverse transformation with no
loss of data.
The algorithm used is highly tuned for its purpose and achieves better
than a five to one compression ratio on average.
Arguments operate identically for both programmes.
The first argument, if present, causes input to be taken from the named
file instead of from standard input unless it is the string ``-''.
A second argument, if present, causes output to go to the named file
instead of to standard output.
.LP
The input format for
.I compface
(and the output format for
.IR uncompface )
is 48 lines each of 3 sixteen bit hexadecimal integers, comma terminated in C
initialiser style.
The output format of
.I compface
(and the input format for
.IR uncompface )
is some number of lines made up of a space followed by printable
characters (in the range ``!'' to ``~'' inclusive).
The first line contains 72 characters and following lines contain
79 characters except that the last line may be short.
.LP
The amount of compression obtained varies between face image files but
the output of
.I compface
averages less than 200 characters.
The average number of output lines is three.
.SH DIAGNOSTICS
Exit status is normally 0.
Possible errors include IO errors when opening, reading or writing
files, format errors in
.I compface
input files and invalid arguments.
Each results in an explanatory message on standard error and an exit status
of 1.
A warning will be produced if
.I compface
detects extra input data.
.SH SEE ALSO
Compface(3)
Funky_Stuff
len=`wc -c < compface.1`
if [ $len !=     2006 ] ; then
echo error: compface.1 was $len bytes long, should have been     2006
fi
fi # end of overwriting check
if [ -f compface.3 ]
then
echo shar: will not over-write existing file compface.3
else
echo shar: extracting 'compface.3',     1834 characters
cat > compface.3 <<'Funky_Stuff'
.TH COMPFACE 3 "25 January 1990"
.SH NAME
compface, uncompface \- compress and expand 48x48x1 face image files
.SH SYNOPSIS
.B compface (buf)
.LP
.B uncompface (buf)
.LP
.B char *buf
.SH DESCRIPTION
.IX  compface  ""  "\fLcompface\fP \(em compress face image files"
.IX  uncompface  ""  "\fLuncompface\fP \(em uncompress face image files"
.I compface
is a function for generating highly compressed representations of 48x48x1
face image files.
.I uncompface
is an inverse function which performs an inverse transformation with no
loss of data.
The algorithm used is highly tuned for its purpose and achieves better
than a five to one compression ratio on average.
In both functions, input is via a NULL terminated string and a NULL terminated
output string is written over the input string.
.I Buf
should therefore point to a block of 2K size or more to avoid buffer
overruns during output generation.
.LP
The input format for
.I compface
(and the output format for
.IR uncompface )
is 48 lines each of 3 sixteen bit hexadecimal integers, comma terminated in C
initialiser style.
The output format of
.I compface
(and the input format for
.IR uncompface )
is some number of lines made up of a space followed by printable
characters (in the range ``!'' to ``~'' inclusive).
The first line contains 72 characters and following lines contain
79 characters except that the last line may be short.
.LP
The amount of compression obtained varies between face image files but
the output of
.I compface
averages less than 200 characters.
The average number of output lines is three.
.SH DIAGNOSTICS
The return value is normally 0.
1 will be returned if extra input has been ignored during a compress operation.
-1 is returned in the case of an invalid input format.
-2 is returned if an internal buffer overrun occurs.
.SH SEE ALSO
Compface(1)
Funky_Stuff
len=`wc -c < compface.3`
if [ $len !=     1834 ] ; then
echo error: compface.3 was $len bytes long, should have been     1834
fi
fi # end of overwriting check
if [ -f compface.c ]
then
echo shar: will not over-write existing file compface.c
else
echo shar: extracting 'compface.c',      850 characters
cat > compface.c <<'Funky_Stuff'
/*
 *  Compface - 48x48x1 image compression and decompression
 *
 *  Copyright (c) James Ashton - Sydney University - June 1990.
 *
 *  Written 11th November 1989.
 *
 *  Permission is given to distribute these sources, as long as the
 *  copyright messages are not removed, and no monies are exchanged. 
 *
 *  No responsibility is taken for any errors on inaccuracies inherent
 *  either to the comments or the code of this program, but if reported
 *  to me, then an attempt will be made to fix them.
 */

#define MAIN

#include "compface.h"

uncompface(fbuf)
char *fbuf;
{
	if (!(status = setjmp(comp_env)))
	{
		UnCompAll(fbuf);/* compress otherwise */
		UnGenFace();
		WriteFace(fbuf);
	}
	return status;
}

compface(fbuf)
char *fbuf;
{
	if (!(status = setjmp(comp_env)))
	{
		ReadFace(fbuf);
		GenFace();
		CompAll(fbuf);
	}
	return status;
}
Funky_Stuff
len=`wc -c < compface.c`
if [ $len !=      850 ] ; then
echo error: compface.c was $len bytes long, should have been      850
fi
fi # end of overwriting check
if [ -f compface.h ]
then
echo shar: will not over-write existing file compface.h
else
echo shar: extracting 'compface.h',     4663 characters
cat > compface.h <<'Funky_Stuff'
/*
 *  Compface - 48x48x1 image compression and decompression
 *
 *  Copyright (c) James Ashton - Sydney University - June 1990.
 *
 *  Written 11th November 1989.
 *
 *  Permission is given to distribute these sources, as long as the
 *  copyright messages are not removed, and no monies are exchanged. 
 *
 *  No responsibility is taken for any errors on inaccuracies inherent
 *  either to the comments or the code of this program, but if reported
 *  to me, then an attempt will be made to fix them.
 */

#include <strings.h>
#include <fcntl.h>
#include <setjmp.h>

#ifdef MAIN
#define EXTERN
#define INIT(x) = x
#else
#define EXTERN extern
#define INIT(x)
#endif

/* need to know how many bits per hexadecimal digit for io */
#define BITSPERDIG 4
EXTERN char HexDigits[] INIT("0123456789ABCDEF");

/* define the face size - 48x48x1 */
#define WIDTH 48
#define HEIGHT WIDTH

/* total number of pixels and digits */
#define PIXELS (WIDTH * HEIGHT)
#define DIGITS (PIXELS / BITSPERDIG)

/* internal face representation - 1 char per pixel is faster */
EXTERN char F[PIXELS];

/* output formatting word lengths and line lengths */
#define DIGSPERWORD 4
#define WORDSPERLINE (WIDTH / DIGSPERWORD / BITSPERDIG)

/* compressed output uses the full range of printable characters.
 * in ascii these are in a contiguous block so we just need to know
 * the first and last.  The total number of printables is needed too */
#define FIRSTPRINT '!'
#define LASTPRINT '~'
#define NUMPRINTS (LASTPRINT - FIRSTPRINT + 1)

/* output line length for compressed data */
#define MAXLINELEN 78

/* Portable, very large unsigned integer arithmetic is needed.
 * Implementation uses arrays of WORDs.  COMPs must have at least
 * twice as many bits as WORDs to handle intermediate results */
#define WORD unsigned char
#define COMP unsigned long
#define BITSPERWORD 8
#define WORDCARRY (1 << BITSPERWORD)
#define WORDMASK (WORDCARRY - 1)
#define MAXWORDS ((PIXELS * 2 + BITSPERWORD - 1) / BITSPERWORD)

typedef struct bigint
{
	int b_words;
	WORD b_word[MAXWORDS];
} BigInt;

EXTERN BigInt B;

/* This is the guess the next pixel table.  Normally there are 12 neighbour
 * pixels used to give 1<<12 cases but in the upper left corner lesser
 * numbers of neighbours are available, leading to 6231 different guesses */
typedef struct guesses
{
	char g_00[1<<12];
	char g_01[1<<7];
	char g_02[1<<2];
	char g_10[1<<9];
	char g_20[1<<6];
	char g_30[1<<8];
	char g_40[1<<10];
	char g_11[1<<5];
	char g_21[1<<3];
	char g_31[1<<5];
	char g_41[1<<6];
	char g_12[1<<1];
	char g_22[1<<0];
	char g_32[1<<2];
	char g_42[1<<2];
} Guesses;

/* data.h was established by sampling over 1000 faces and icons */
EXTERN Guesses G
#ifdef MAIN
=
#include "data.h"
#endif
;

/* Data of varying probabilities are encoded by a value in the range 0 - 255.
 * The probability of the data determines the range of possible encodings.
 * Offset gives the first possible encoding of the range */
typedef struct prob
{
	WORD p_range;
	WORD p_offset;
} Prob;

/* A stack of probability values */
EXTERN Prob *ProbBuf[PIXELS * 2];
EXTERN int NumProbs INIT(0);

/* Each face is encoded using 9 octrees of 16x16 each.  Each level of the
 * trees has varying probabilities of being white, grey or black.
 * The table below is based on sampling many faces */

#define BLACK 0
#define GREY 1
#define WHITE 2

EXTERN Prob levels[4][3]
#ifdef MAIN
=
{
	{{1, 255},	{251, 0},	{4, 251}},	/* Top of tree almost always grey */
	{{1, 255},	{200, 0},	{55, 200}},
	{{33, 223},	{159, 0},	{64, 159}},
	{{131, 0},	{0, 0}, 	{125, 131}}	/* Grey disallowed at bottom */
}
#endif
;

/* At the bottom of the octree 2x2 elements are considered black if any
 * pixel is black.  The probabilities below give the distribution of the
 * 16 possible 2x2 patterns.  All white is not really a possibility and
 * has a probability range of zero.  Again, experimentally derived data */
EXTERN Prob freqs[16]
#ifdef MAIN
=
{
	{0, 0}, 	{38, 0},	{38, 38},	{13, 152},
	{38, 76},	{13, 165},	{13, 178},	{6, 230},
	{38, 114},	{13, 191},	{13, 204},	{6, 236},
	{13, 217},	{6, 242},	{5, 248},	{3, 253}
}
#endif
;

#define ERR_OK		0	/* successful completion */
#define ERR_EXCESS	1	/* completed OK but some input was ignored */
#define ERR_INSUFF	-1	/* insufficient input.  Bad face format? */
#define ERR_INTERNAL	-2	/* Arithmetic overflow or buffer overflow */

EXTERN int status;

EXTERN jmp_buf comp_env;

void ReadFace(), WriteFace();
void CompAll(), Compress(), PushGreys();
void UnCompAll(), UnCompress(), PopGreys();
void BigAdd(), BigSub(), BigMul(), BigDiv(), BigPrint(), BigPush(), RevPush();
void BigWrite(), BigRead();
void GenFace(), UnGenFace();
Funky_Stuff
len=`wc -c < compface.h`
if [ $len !=     4663 ] ; then
echo error: compface.h was $len bytes long, should have been     4663
fi
fi # end of overwriting check
if [ -f compress.c ]
then
echo shar: will not over-write existing file compress.c
else
echo shar: extracting 'compress.c',     3763 characters
cat > compress.c <<'Funky_Stuff'
/*
 *  Compface - 48x48x1 image compression and decompression
 *
 *  Copyright (c) James Ashton - Sydney University - June 1990.
 *
 *  Written 11th November 1989.
 *
 *  Permission is given to distribute these sources, as long as the
 *  copyright messages are not removed, and no monies are exchanged. 
 *
 *  No responsibility is taken for any errors on inaccuracies inherent
 *  either to the comments or the code of this program, but if reported
 *  to me, then an attempt will be made to fix them.
 */

#include "compface.h"

Same(f, wid, hei)
register char *f;
register int wid, hei;
{
	register char val, *row;
	register int x;

	val = *f;
	while (hei--)
	{
		row = f;
		x = wid;
		while (x--)
			if (*(row++) != val)
				return(0);
		f += WIDTH;
	}
	return 1;
}

AllBlack(f, wid, hei)
char *f;
int wid, hei;
{
	if (wid > 3)
	{
		wid /= 2;
		hei /= 2;
		return (AllBlack(f, wid, hei) && AllBlack(f + wid, wid, hei) &&
		  AllBlack(f + WIDTH * hei, wid, hei) &&
		  AllBlack(f + WIDTH * hei + wid, wid, hei));
	}
	else
		return (*f || *(f + 1) || *(f + WIDTH) || *(f + WIDTH + 1));
}

AllWhite(f, wid, hei)
char *f;
int wid, hei;
{
	return ((*f == 0) && Same(f, wid, hei));
}

void PopGreys(f, wid, hei)
char *f;
int wid, hei;
{
	if (wid > 3)
	{
		wid /= 2;
		hei /= 2;
		PopGreys(f, wid, hei);
		PopGreys(f + wid, wid, hei);
		PopGreys(f + WIDTH * hei, wid, hei);
		PopGreys(f + WIDTH * hei + wid, wid, hei);
	}
	else
	{
		wid = BigPop(freqs);
		if (wid & 1)
			*f = 1;
		if (wid & 2)
			*(f + 1) = 1;
		if (wid & 4)
			*(f + WIDTH) = 1;
		if (wid & 8)
			*(f + WIDTH + 1) = 1;
	}
}

void PushGreys(f, wid, hei)
char *f;
int wid, hei;
{
	if (wid > 3)
	{
		wid /= 2;
		hei /= 2;
		PushGreys(f, wid, hei);
		PushGreys(f + wid, wid, hei);
		PushGreys(f + WIDTH * hei, wid, hei);
		PushGreys(f + WIDTH * hei + wid, wid, hei);
	}
	else
		RevPush(freqs + *f + 2 * *(f + 1) + 4 * *(f + WIDTH) +
		  8 * *(f + WIDTH + 1));
}

void UnCompress(f, wid, hei, lev)
register char *f;
register int wid, hei, lev;
{
	switch (BigPop(&levels[lev][0]))
	{
		case WHITE :
			return;
		case BLACK :
			PopGreys(f, wid, hei);
			return;
		default :
			wid /= 2;
			hei /= 2;
			lev++;
			UnCompress(f, wid, hei, lev);
			UnCompress(f + wid, wid, hei, lev);
			UnCompress(f + hei * WIDTH, wid, hei, lev);
			UnCompress(f + wid + hei * WIDTH, wid, hei, lev);
			return;
	}
}

void Compress(f, wid, hei, lev)
register char *f;
register int wid, hei, lev;
{
	if (AllWhite(f, wid, hei))
	{
		RevPush(&levels[lev][WHITE]);
		return;
	}
	if (AllBlack(f, wid, hei))
	{
		RevPush(&levels[lev][BLACK]);
		PushGreys(f, wid, hei);
		return;
	}
	RevPush(&levels[lev][GREY]);
	wid /= 2;
	hei /= 2;
	lev++;
	Compress(f, wid, hei, lev);
	Compress(f + wid, wid, hei, lev);
	Compress(f + hei * WIDTH, wid, hei, lev);
	Compress(f + wid + hei * WIDTH, wid, hei, lev);
}

void UnCompAll(fbuf)
char *fbuf;
{
	register char *p;

	BigRead(fbuf);
	p = F;
	while (p < F + PIXELS)
		*(p++) = 0;
	UnCompress(F, 16, 16, 0);
	UnCompress(F + 16, 16, 16, 0);
	UnCompress(F + 32, 16, 16, 0);
	UnCompress(F + WIDTH * 16, 16, 16, 0);
	UnCompress(F + WIDTH * 16 + 16, 16, 16, 0);
	UnCompress(F + WIDTH * 16 + 32, 16, 16, 0);
	UnCompress(F + WIDTH * 32, 16, 16, 0);
	UnCompress(F + WIDTH * 32 + 16, 16, 16, 0);
	UnCompress(F + WIDTH * 32 + 32, 16, 16, 0);
}

void CompAll(fbuf)
char *fbuf;
{
	Compress(F, 16, 16, 0);
	Compress(F + 16, 16, 16, 0);
	Compress(F + 32, 16, 16, 0);
	Compress(F + WIDTH * 16, 16, 16, 0);
	Compress(F + WIDTH * 16 + 16, 16, 16, 0);
	Compress(F + WIDTH * 16 + 32, 16, 16, 0);
	Compress(F + WIDTH * 32, 16, 16, 0);
	Compress(F + WIDTH * 32 + 16, 16, 16, 0);
	Compress(F + WIDTH * 32 + 32, 16, 16, 0);
	B.b_words = 0;
	while (NumProbs > 0)
		BigPush(ProbBuf[--NumProbs]);
	BigWrite(fbuf);
}
Funky_Stuff
len=`wc -c < compress.c`
if [ $len !=     3763 ] ; then
echo error: compress.c was $len bytes long, should have been     3763
fi
fi # end of overwriting check
if [ -f data.h ]
then
echo shar: will not over-write existing file data.h
else
echo shar: extracting 'data.h',    20229 characters
cat > data.h <<'Funky_Stuff'

/*
 *  Compface - 48x48x1 image compression and decompression
 *
 *  Copyright (c) James Ashton - Sydney University - June 1990.
 *
 *  Written 11th November 1989.
 *
 *  Permission is given to distribute these sources, as long as the
 *  copyright messages are not removed, and no monies are exchanged. 
 *
 *  No responsibility is taken for any errors on inaccuracies inherent
 *  either to the comments or the code of this program, but if reported
 *  to me, then an attempt will be made to fix them.
 */

{
	{
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1,
		0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1,
		0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1,
		0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 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, 0, 0, 1, 0, 0, 1, 1, 
		0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 
	},
	{
		0, 0, 0, 1, 0, 1, 1, 1, 
	},
	{
		0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 
		0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 
	},
	{
		0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 
		0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 
		0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 
		0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
	},
	{
		0, 1, 
	},
	{
		0, 
	},
	{
		0, 0, 0, 1, 
	},
	{
		0, 0, 0, 1, 
	}
}
Funky_Stuff
len=`wc -c < data.h`
if [ $len !=    20229 ] ; then
echo error: data.h was $len bytes long, should have been    20229
fi
fi # end of overwriting check
if [ -f file.c ]
then
echo shar: will not over-write existing file file.c
else
echo shar: extracting 'file.c',     2734 characters
cat > file.c <<'Funky_Stuff'
/*
 *  Compface - 48x48x1 image compression and decompression
 *
 *  Copyright (c) James Ashton - Sydney University - June 1990.
 *
 *  Written 11th November 1989.
 *
 *  Permission is given to distribute these sources, as long as the
 *  copyright messages are not removed, and no monies are exchanged. 
 *
 *  No responsibility is taken for any errors on inaccuracies inherent
 *  either to the comments or the code of this program, but if reported
 *  to me, then an attempt will be made to fix them.
 */

#include "compface.h"

void BigRead(fbuf)
register char *fbuf;
{
	register int c;
	register char *s;

	s = fbuf + strlen(fbuf);
	while (fbuf < s)
	{
		c = *(fbuf++);
		if ((c < FIRSTPRINT) || (c > LASTPRINT))
			continue;
		BigMul(NUMPRINTS);
		BigAdd((WORD)(c - FIRSTPRINT));
	}
}

void BigWrite(fbuf)
register char *fbuf;
{
	static WORD tmp;
	static char buf[DIGITS];
	register char *s;
	register int i;

	s = buf;
	while (B.b_words > 0)
	{
		BigDiv(NUMPRINTS, &tmp);
		*(s++) = tmp + FIRSTPRINT;
	}
	i = 7;	/* leave room for the field name on the first line */
	*(fbuf++) = ' ';
	while (s-- > buf)
	{
		if (i == 0)
			*(fbuf++) = ' ';
		*(fbuf++) = *s;
		if (++i >= MAXLINELEN)
		{
			*(fbuf++) = '\n';
			i = 0;
		}
	}
	if (i > 0)
		*(fbuf++) = '\n';
	*(fbuf++) = '\0';
}

void ReadFace(fbuf)
char *fbuf;
{
	register int c, i;
	register char *s, *t;

	t = s = fbuf;
	for(i = strlen(s); i > 0; i--)
	{
		c = (int)*(s++);
		if ((c >= '0') && (c <= '9'))
		{
			if (t >= fbuf + DIGITS)
			{
				status = ERR_EXCESS;
				break;
			}
			*(t++) = c - '0';
		}
		else if ((c >= 'A') && (c <= 'F'))
		{
			if (t >= fbuf + DIGITS)
			{
				status = ERR_EXCESS;
				break;
			}
			*(t++) = c - 'A' + 10;
		}
		else if ((c >= 'a') && (c <= 'f'))
		{
			if (t >= fbuf + DIGITS)
			{
				status = ERR_EXCESS;
				break;
			}
			*(t++) = c - 'a' + 10;
		}
		else if (((c == 'x') || (c == 'X')) && (t > fbuf) && (*(t-1) == 0))
			t--;
	}
	if (t < fbuf + DIGITS)
		longjmp(comp_env, ERR_INSUFF);
	s = fbuf;
	t = F;
	c = 1 << (BITSPERDIG - 1);
	while (t < F + PIXELS)
	{
		*(t++) = (*s & c) ? 1 : 0;
		if ((c >>= 1) == 0)
		{
			s++;
			c = 1 << (BITSPERDIG - 1);
		}
	}
}

void WriteFace(fbuf)
char *fbuf;
{
	register char *s, *t;
	register int i, bits, digits, words;

	s = F;
	t = fbuf;
	bits = digits = words = i = 0;
	while (s < F + PIXELS)
	{
		if ((bits == 0) && (digits == 0))
		{
			*(t++) = '0';
			*(t++) = 'x';
		}
		if (*(s++))
			i = i * 2 + 1;
		else
			i *= 2;
		if (++bits == BITSPERDIG)
		{
			*(t++) = *(i + HexDigits);
			bits = i = 0;
			if (++digits == DIGSPERWORD)
			{
				*(t++) = ',';
				digits = 0;
				if (++words == WORDSPERLINE)
				{
					*(t++) = '\n';
					words = 0;
				}
			}
		}
	}
	*(t++) = '\0';
}
Funky_Stuff
len=`wc -c < file.c`
if [ $len !=     2734 ] ; then
echo error: file.c was $len bytes long, should have been     2734
fi
fi # end of overwriting check
if [ -f gen.c ]
then
echo shar: will not over-write existing file gen.c
else
echo shar: extracting 'gen.c',     1900 characters
cat > gen.c <<'Funky_Stuff'
/*
 *  Compface - 48x48x1 image compression and decompression
 *
 *  Copyright (c) James Ashton - Sydney University - June 1990.
 *
 *  Written 11th November 1989.
 *
 *  Permission is given to distribute these sources, as long as the
 *  copyright messages are not removed, and no monies are exchanged. 
 *
 *  No responsibility is taken for any errors on inaccuracies inherent
 *  either to the comments or the code of this program, but if reported
 *  to me, then an attempt will be made to fix them.
 */

#include "compface.h"

#define GEN(g) F[h] ^= G.g[k]; break

static void Gen(f)
register char *f;
{
	register int m, l, k, j, i, h;

	j = 0;
	while (j++ < HEIGHT)
	{
		i = 0;
		while (i++ < WIDTH)
		{
			h = i + j * WIDTH;
			k = 0;
			for (l = i - 2; l <= i + 2; l++)
				for (m = j - 2; m <= j; m++)
				{
					if ((l >= i) && (m == j))
						continue;
					if ((l > 0) && (l <= WIDTH) && (m > 0))
						k = *(f + l + m * WIDTH) ? k * 2 + 1 : k * 2;
				}
			switch (i)
			{
				case 1 :
					switch (j)
					{
						case 1 : GEN(g_22);
						case 2 : GEN(g_21);
						default : GEN(g_20);
					}
					break;
				case 2 :
					switch (j)
					{
						case 1 : GEN(g_12);
						case 2 : GEN(g_11);
						default : GEN(g_10);
					}
					break;
				case WIDTH - 1 :
					switch (j)
					{
						case 1 : GEN(g_42);
						case 2 : GEN(g_41);
						default : GEN(g_40);
					}
					break;
				case WIDTH :
					switch (j)
					{
						case 1 : GEN(g_32);
						case 2 : GEN(g_31);
						default : GEN(g_30);
					}
					break;
				default :
					switch (j)
					{
						case 1 : GEN(g_02);
						case 2 : GEN(g_01);
						default : GEN(g_00);
					}
					break;
			}
		}
	}
}

void GenFace()
{
	static char new[PIXELS];
	register char *f1;
	register char *f2;
	register int i;

	f1 = new;
	f2 = F;
	i = PIXELS;
	while (i-- > 0)
		*(f1++) = *(f2++);
	Gen(new);
}

void UnGenFace()
{
	Gen(F);
}
Funky_Stuff
len=`wc -c < gen.c`
if [ $len !=     1900 ] ; then
echo error: gen.c was $len bytes long, should have been     1900
fi
fi # end of overwriting check
if [ -f main.c ]
then
echo shar: will not over-write existing file main.c
else
echo shar: extracting 'main.c',     3065 characters
cat > main.c <<'Funky_Stuff'
/*
 *  Compface - 48x48x1 image compression and decompression
 *
 *  Copyright (c) James Ashton - Sydney University - June 1990.
 *
 *  Written 11th November 1889.
 *
 *  Permission is given to distribute these sources, as long as the
 *  copyright messages are not removed, and no monies are exchanged. 
 *
 *  No responsibility is taken for any errors on inaccuracies inherent
 *  either to the comments or the code of this program, but if reported
 *  to me, then an attempt will be made to fix them.
 */

#include <fcntl.h>

/* the buffer is longer than needed to handle sparse input formats */
#define FACEBUFLEN 2048
char fbuf[FACEBUFLEN];

/* IO file descriptors and their names */
int infile = 0;
char *inname = "<stdin>";
int outfile = 1;
char *outname = "<stdout>";

/* basename of executable */
char *cmdname;

/* error handling definitions follow */

extern int errno, sys_nerr;
extern char *sys_errlist[];

#define ERR ((errno < sys_nerr) ? sys_errlist[errno] : "")
#define INITERR(s) {(void)strcpy(fbuf, cmdname); (void)strcat(fbuf, ": ");\
					(void)strcat(fbuf, (s));}
#define ADDERR(s) (void)strcat(fbuf, (s));
#define ERROR {(void)strcat(fbuf, "\n");\
				(void)write(2, fbuf, strlen(fbuf)); exit(1);}
#define INITWARN(s) {(void)strcpy(fbuf, cmdname);\
					(void)strcat(fbuf, ": (warning) ");\
					(void)strcat(fbuf, (s));}
#define ADDWARN(s) (void)strcat(fbuf, (s));
#define WARN {(void)strcat(fbuf, "\n"); (void)write(2, fbuf, strlen(fbuf));}

main(argc, argv)
int argc;
char *argv[];
{
	cmdname = *argv;
	while (**argv)
		if (*((*argv)++) == '/')
			cmdname = *argv;	/* find the command's basename */
	if (argc > 3)
	{
		INITERR("usage: ")
		ADDERR(cmdname)
		ADDERR(" [infile [outfile]]")
		ERROR
	}
	if ((argc > 1) && strcmp(*++argv, "-"))
	{
		inname = *argv;
		if ((infile = open(inname, O_RDONLY)) == -1)
		{
			INITERR(inname)
			ADDERR(": ")
			ADDERR(ERR)
			ERROR
		}
	}
	if (argc > 2)
	{
		outname = *++argv;
		if ((outfile = open(outname, O_WRONLY | O_CREAT | O_TRUNC, 0644)) == -1)
		{
			INITERR(outname)
			ADDERR(": ")
			ADDERR(ERR)
			ERROR
		}
	}
	ReadBuf();
	switch ((*cmdname != 'u') ? compface(fbuf) : uncompface(fbuf))
	{
		case -2 :
			INITERR("internal error")
			ERROR
		case -1 :
			INITERR(inname)
			ADDERR(": insufficient or invalid data")
			ERROR
		case 1 :
			INITWARN(inname)
			ADDWARN(": excess data ignored")
			WARN
		default : ;
	}
	WriteBuf();
	return 0;
}

WriteBuf()
{
	register char *s, *t;
	register int len;

	s = fbuf;
	t = s + strlen(s);
	while (s < t)
	{
		if ((len = write(outfile, s, t - s)) == -1)
		{
			INITERR(outname)
			ADDERR(": ")
			ADDERR(ERR)
			ERROR
		}
		s += len;
	}
	return 0;
}

ReadBuf()
{
	register int count, len;
	register char *t;

	count = 0;
	t = fbuf;
	while (len = read(infile, t, FACEBUFLEN - count))
	{
		if (len == -1)
		{
			INITERR(inname)
			ADDERR(": ")
			ADDERR(ERR)
			ERROR
		}
		t += len;
		if ((count += len) >= FACEBUFLEN)
		{
			INITWARN(inname)
			ADDWARN(" exceeds internal buffer size.  Data may be lost")
			WARN
			break;
		}
	}
	return count;
}
Funky_Stuff
len=`wc -c < main.c`
if [ $len !=     3065 ] ; then
echo error: main.c was $len bytes long, should have been     3065
fi
fi # end of overwriting check
cd ..
echo shar: done with directory compface
fi