shortpack(3SP)

NAME
WriteShortpackedData, ReadShortpackedData, WriteShortpackReadingFromFile, ReadShortpackWritingToFile,

SYNOPSIS

#include <speech.h>

int WriteShortpackedData (short *array, int num, FILE *fp)

int ReadShortpackedData (short *array, int num, FILE *fp)

int WriteShortpackReadingFromFile (FILE *ifp, FILE *ofp, int ieee)

ReadShortpackWritingToFile (FILE *ifp, FILE *ofp, int ieee)

DESCRIPTION
These functions read shortpacked data from files into short arrays, write short data into shortpacked files, or translate from one file to another.

The idea is to pack short integers into as few bits as required for sequences of speech samples. For each sequence, a 16 bit header is written that says "here comes n words using m bits per word". The compression code needs to decide where to break up the sequences to optimize the tradeoff between transmitting fewer bits for the sequence versus the cost of transmitting another header for another sequence break. The present algorithm does an OK job, but with a better compression algorithm, a percent or two of the file size could probably be saved.

ReadShortpackedData reads shortpacked data from the open file pointer fp, which should already be positioned at the beginning of the data (i.e. any header information should already have been read). Up to num_element shorts are placed in array, which must already be allocated. The number of shorts read is returned.

WriteShortpackedData writes num shorts from array into the open file pointer fp. Then number of shorts written is returned.

ReadShortpackWritingToFile reads packed shorts from ifp and writes them to ofp. If ieee is 1, the output will be in network byte order; if ieee is 0, the output will not be in network byte order, but rather in host byte order.

WriteShortpackReadingFromFile reads shorts from the open file pointer ifp and writes them packed to opf. If the input is in network byte order, ieee should be 1; otherwise it should be 0. The number of shorts processed is returned.

The last two routines use a circular buffer to hold data between input and output of the shortpacked data.

All of these routines should work with machines with either byte order. Shortpacked data is always in ieee network byte order (which should not matter to the user anyway).

DIAGNOSTICS
On error, the functions returns a negative number and sets the char * variable ErrorString to an appropriate error message

AUTHORS
The shortpack compression algorithm is from Mike Phillips; the code is by Peter Daly. Both from Spoken Language Systems Group at MIT Laboratory for Computer Science.