home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: Alpha / Whiteline Alpha.iso / progtool / c / tiff_lib / source / mk2dtab.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-22  |  2.3 KB  |  70 lines

  1. #pragma warn -use
  2. static char     *sccsid = "@(#)TIFF/mk2dtab.c 1.02, Copyright (c) Sam Leffler, Dieter Linde, "__DATE__;
  3. #pragma warn .use
  4. /*
  5.  * Copyright (c) 1988, 1990 by Sam Leffler, Oct 8 1990
  6.  * All rights reserved.
  7.  *
  8.  * This file is provided for unrestricted use provided that this legend is included on all tape media and as a part of the
  9.  * software program in whole or part.  Users may copy, modify or distribute this file at will.
  10.  *
  11.  * Program to construct packed state tables used by 2d decompression algorithms (G3 + G4).
  12.  * The tables are indexed by PACK(code, len) and the result, if nonzero, indicates a code match
  13.  * and the new decoding state.
  14.  */
  15. #include <stdlib.h>
  16. #include "tiffio.h"
  17.  
  18. #define PACK(code, len)    (((len) << 2) + (code))
  19.  
  20. #define PASS               1
  21. #define HORIZONTAL      2
  22. #define VERTICAL        3
  23. #define EXTENSION       4
  24. #define    UNCOMPRESSED    1
  25.  
  26. #define PACKINFO(mode, v)    (((v) << 4) + mode)
  27. #define UNPACKMODE(v)           ((v) & 0xf)
  28. #define UNPACKINFO(v)           ((v) >> 4)
  29.  
  30. /****************************************************************************
  31.  *
  32.  */
  33. void
  34. main(
  35.     void
  36.     )
  37. {
  38. #define NTABENTS    (PACK(0xf, 10) + 1)
  39.         short     tab[NTABENTS];
  40.         char    *sep;
  41.         int     i;
  42.  
  43.         bzero(tab, sizeof(tab));
  44.         tab[PACK(0x1, 4)] = PACKINFO(PASS, 0);
  45.         tab[PACK(0x1, 3)] = PACKINFO(HORIZONTAL, 0);
  46.         tab[PACK(0x1, 1)] = PACKINFO(VERTICAL, 0);
  47.         tab[PACK(0x3, 3)] = PACKINFO(VERTICAL, 1);
  48.         tab[PACK(0x3, 6)] = PACKINFO(VERTICAL, 2);
  49.         tab[PACK(0x3, 7)] = PACKINFO(VERTICAL, 3);
  50.         tab[PACK(0x2, 3)] = PACKINFO(VERTICAL, -1);
  51.         tab[PACK(0x2, 6)] = PACKINFO(VERTICAL, -2);
  52.         tab[PACK(0x2, 7)] = PACKINFO(VERTICAL, -3);
  53.         tab[PACK(0xf, 10)] = PACKINFO(EXTENSION, UNCOMPRESSED);
  54.         printf("static short g32dtab[%d] = {\n", NTABENTS);
  55.         sep = "    ";
  56.         for (i = 0; i < NTABENTS; i++) {
  57.                 printf("%s%4d", sep, tab[i]);
  58.                 if (((i + 1) % 8) == 0) {
  59.                         printf(",       /* 0x%02x - 0x%02x */\n", i - 7, i);
  60.                         sep = "    ";
  61.                 } 
  62.                 else
  63.                         sep = ", ";
  64.         }
  65.         if (i % NTABENTS)
  66.                 putchar('\n');
  67.         printf("};\n");
  68.     exit(0);
  69. }
  70.