## NAME

         zvl_compress - performs Ziv-Lempel compression

## SYNOPSIS

          #include <stdio.h>
          #include <stdlib.h>
          #include <time.h>
          #include <string.h>
          #include <sys/types.h>
          #include <sys/stat.h>
          #include "CVIPdef.h"
          #include "CVIPimage.h"
          #include "CVIPcompress.h"

         int zvl_compress(Image *inputImage, char *filename)

          <inputImage> - pointer to the image
          <filename> - pointer to a character array

         Image *zvl_decompress(char *filename)

          <filename> - pointer to a character array

## PATH

         $CVIPHOME/COMPRESSION/zvl.c

## DESCRIPTION

         This function encodes an image using  the  Ziv-Lempel  algo-
         rithm. The first two 9-bit codes have been reserved for com-
         munication between the encoder and decoder.

## TYPES AND CONSTANTS

         #define INIT_BITS 9
         #define MAX_BITS 14
         #define HASHING_SHIFT MAX_BITS - 8

         #if MAX_BITS == 14     /* Set the table size. Must be a prime number */
         #define TABLE_SIZE 18041
         #elif MAX_BITS == 13
         #define TABLE_SIZE 9029
         #else
         #define TABLE_SIZE 5021
         #endif

         #define CLEAR_TABLE 256 /* Code to clear the string table */
         #define TERMINATOR  257 /* Marks EOF condition, instead of MAX_VALUE */
         #define FIRST_CODE  258 /* First available code for code_vaule table */
         #define CHECK_TIME  100 /* Check comp ratio every CHECK_TIME chars input */
         #define MAXVAL(n) (( 1 <<(n)) -1)  /* max_value formual macro */

## RETURN VALUES

         zvl_compress: 0 on success, -1 on failure

         zvl_decompression: an uncompressed image pointer on success,
         a NULL pointer on failure

## HISTORY

         History information recorded: None

## EXAMPLE

          #include <CVIPtoolkit.h>
          #include <CVIPimage.h>
          #include <CVIPdef.h>
          #include <CVIPconvert.h>
          #include <CVIPview.h>
          #include <sys/types.h>
          #include <sys/stat.h>
          #define VIEWER "picture"
          #define VIDEO_APP "SunVideo &"

          void main()
          {
          Image *cvipImage;
          IMAGE_FORMAT format;
          char *inputfile,*outputfile;

          setDisplay_Image(VIEWER, "Default");

          print_CVIP("\n\t\tEnter the  Input File Name:  ");
          inputfile =(char *) getString_CVIP();
          format = getFormat_CVIP(inputfile);
          cvipImage = read_Image(inputfile,1);
          view_Image(cvipImage, inputfile);
          free(inputfile);
          /* the following call performs the lempel ziv
          coding of the input image */
          zvl_compress(cvipImage,"file1");
          /* the following call performs the lempel ziv
          decoding of the "file1" */
          cvipImage=zvl_decompress("file1");
          print_CVIP("\n\t\tEnter the Output File Name:  ");
          outputfile = getString_CVIP();
          view_Image(cvipImage,outputfile);
          write_Image(cvipImage,outputfile,CVIP_NO,CVIP_NO,format,1);
          free(outputfile);
          }

## SEE ALSO

         libcompress

## AUTHOR

         Copyright (C) 1996 SIUE - by Scott E. Umbaugh.