1 /*============================================================================= 2 pammap.h 3 =============================================================================== 4 5 Interface header file for hash table and lookup table pam functions 6 in libpnm. 7 8 =============================================================================*/ 9 10 #ifndef PAMMAP_H 11 #define PAMMAP_H 12 #include <netpbm/colorname.h> 13 #include <netpbm/pam.h> 14 15 #ifdef __cplusplus 16 extern "C" { 17 #endif 18 #if 0 19 } /* to fake out automatic code indenters */ 20 #endif 21 22 struct tupleint { 23 /* An ordered pair of a tuple value and an integer, such as you 24 would find in a tuple table or tuple hash. 25 26 Note that this is a variable length structure. 27 */ 28 int value; 29 sample tuple[1]; 30 /* This is actually a variable size array -- its size is the 31 depth of the tuple in question. Some compilers do not let us 32 declare a variable length array. 33 */ 34 }; 35 typedef struct tupleint ** tupletable; 36 37 typedef struct { 38 unsigned int size; 39 tupletable table; 40 } tupletable2; 41 42 struct tupleint_list_item { 43 struct tupleint_list_item * next; 44 struct tupleint tupleint; 45 }; 46 typedef struct tupleint_list_item * tupleint_list; 47 48 typedef tupleint_list * tuplehash; 49 50 unsigned int 51 pnm_hashtuple(struct pam * const pamP, tuple const tuple); 52 53 void 54 pnm_addtotuplehash(struct pam * const pamP, 55 tuplehash const tuplehash, 56 tuple const tuple, 57 int const value, 58 int * const fitsP); 59 60 void 61 pnm_addtuplefreqoccurrence(struct pam * const pamP, 62 tuple const value, 63 tuplehash const tuplefreqhash, 64 int * const firstOccurrenceP); 65 66 void 67 pnm_lookuptuple(struct pam * const pamP, const tuplehash tuplehash, 68 const tuple searchval, 69 int * const foundP, int * const retvalP); 70 71 tupletable 72 pnm_alloctupletable(const struct pam * const pamP, unsigned int const size); 73 74 void 75 pnm_freetupletable(const struct pam * const pamP, 76 tupletable const tupletable); 77 78 void 79 pnm_freetupletable2(const struct pam * const pamP, 80 tupletable2 const tupletable); 81 82 tuplehash 83 pnm_createtuplehash(void); 84 85 void 86 pnm_destroytuplehash(tuplehash const tuplehash); 87 88 tupletable 89 pnm_computetuplefreqtable(struct pam * const pamP, 90 tuple ** const tupleArray, 91 unsigned int const maxsize, 92 unsigned int * const sizeP); 93 94 tupletable 95 pnm_computetuplefreqtable2(struct pam * const pamP, 96 tuple ** const tupleArray, 97 unsigned int const maxsize, 98 sample const newMaxval, 99 unsigned int * const sizeP); 100 101 tupletable 102 pnm_computetuplefreqtable3(struct pam * const pamP, 103 tuple ** const tupleArray, 104 unsigned int const maxsize, 105 unsigned int const newDepth, 106 sample const newMaxval, 107 unsigned int * const countP); 108 109 tuplehash 110 pnm_computetuplefreqhash(struct pam * const pamP, 111 tuple ** const tupleArray, 112 unsigned int const maxsize, 113 unsigned int * const sizeP); 114 115 tuplehash 116 pnm_computetupletablehash(struct pam * const pamP, 117 tupletable const tupletable, 118 unsigned int const tupletableSize); 119 120 tupletable 121 pnm_tuplehashtotable(const struct pam * const pamP, 122 tuplehash const tuplehash, 123 unsigned int const maxsize); 124 125 char* 126 pam_colorname(struct pam * const pamP, 127 tuple const color, 128 enum colornameFormat const format); 129 130 #ifdef __cplusplus 131 } 132 #endif 133 134 #endif 135