home *** CD-ROM | disk | FTP | other *** search
/ Encyclopedia of Graphics File Formats Companion / GFF_CD.ISO / software / unix / libtiff / lbtif3_3.tar / contrib / fax2ps / defs.h next >
C/C++ Source or Header  |  1993-02-11  |  3KB  |  98 lines

  1. #ifndef _DEFS_
  2. #define    _DEFS_
  3.  
  4. /*
  5.  * Copyright (c) 1991, 1992, 1993 by Sam Leffler.
  6.  * All rights reserved.
  7.  *
  8.  * This file is provided for unrestricted use provided that this
  9.  * legend is included on all tape media and as a part of the
  10.  * software program in whole or part.  Users may copy, modify or
  11.  * distribute this file at will.
  12.  */
  13. #include "tiffiop.h"
  14.  
  15. #ifndef TRUE
  16. #define    TRUE    1
  17. #define    FALSE    0
  18. #endif
  19.  
  20. typedef    struct {
  21.     unsigned short count;    /* frequency count (maybe long?) */
  22.     unsigned short code;    /* assigned code */
  23.     unsigned long cost;        /* cost to use w/o encoding */
  24. } Code;
  25.  
  26. typedef struct {
  27.     Code    c;
  28.     unsigned short move;    /* relative move before */
  29.     unsigned short runlen;    /* runlen draw */
  30. } CodeEntry;
  31. #define    CODEHASH    11597
  32. #define    HASHCODE(x,y)    ((((x)<<16)|(y)) % CODEHASH)
  33. extern    CodeEntry* codehash[CODEHASH];
  34. #define    MAXCODES    8600    /* about 75% population */
  35. extern    CodeEntry* codetable;
  36.  
  37. typedef struct {
  38.     Code    c;
  39.     CodeEntry*    a;        /* first part of pair */
  40.     CodeEntry*    b;        /* second part of pair */
  41. } CodePairEntry;
  42. #define    PAIRHASH    16033
  43. #define    HASHPAIR(a,b)    ((((u_int)(a)<<16)|((u_int)(b)&0xffff)) % PAIRHASH)
  44. extern    CodePairEntry* pairhash[PAIRHASH];
  45. extern    CodePairEntry* pairtable;
  46. #define    MAXPAIRS    10000
  47. extern    int maxpairs;
  48. #define    isPair(p) \
  49.     (&pairtable[0] <= (CodePairEntry*)(p) && \
  50.      (CodePairEntry*)(p) < &pairtable[maxpairs])
  51.  
  52. extern    char** codeNames;    /* codeNames[code] => ASCII code name */
  53. extern    char* codeNameSpace;    /* storage space for codeNames and strings */
  54. extern    int ncodes;        /* number of assigned codes */
  55. extern    int includeStatistics;    /* if 1, add comments w/ frequency stats */
  56. extern    int startOfRow;        /* if 1, have yet to emit a code for this row */
  57. extern    int dopairs;        /* if 1, encode pairs of codes */
  58. extern    int debug;        /* debug decoding */
  59.  
  60. #if USE_PROTOTYPES
  61. extern    CodeEntry* enterCode(int dx, int len);
  62. extern    CodePairEntry* findPair(CodeEntry* a, CodeEntry* b);
  63. extern    CodePairEntry* enterPair(CodeEntry* a, CodeEntry* b);
  64. extern    int printPair(TIFF* tif, CodeEntry* a, CodeEntry* b);
  65. #else
  66. extern    CodeEntry* enterCode();
  67. extern    CodePairEntry* findPair();
  68. extern    CodePairEntry* enterPair();
  69. extern    int printPair();
  70. #endif
  71.  
  72. #include "tif_fax3.h"
  73.  
  74. typedef struct {
  75.     long    row;
  76.     int        cc;
  77.     u_char*    buf;
  78.     u_char*    bp;
  79.     u_char*    scanline;
  80.     u_char    pass;
  81.     u_char    is2d;
  82.     u_short    options;
  83.     CodeEntry*    lastCode;
  84.     Fax3BaseState b;
  85. } Fax3DecodeState;
  86. extern    Fax3DecodeState fax;
  87.  
  88. #if USE_PROTOTYPES
  89. extern    int FaxPreDecode(TIFF* tif);
  90. extern    int Fax3DecodeRow(TIFF* tif, int npels);
  91. extern    int Fax4DecodeRow(TIFF* tif, int npels);
  92. #else
  93. extern    int FaxPreDecode();
  94. extern    int Fax3DecodeRow();
  95. extern    int Fax4DecodeRow();
  96. #endif
  97. #endif    /* _DEFS_ */
  98.