This file is indexed.

/usr/include/libAfterImage/ascmap.h is in libafterimage-dev 2.2.12-11.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#ifndef ASCMAP_H_HEADER_ICLUDED
#define ASCMAP_H_HEADER_ICLUDED

#ifdef __cplusplus
extern "C" {
#endif

/****h* libAfterImage/ascmap.h
 * NAME
 * ascmap - Defines main structures and function for image quantization.
 * DESCRIPTION
 * Image quantization is needed primarily in order to be able to export
 * images into file, with colormap format, such as GIF and XPM.
 * libAfterImage attempts to allocate colorcells to the most used colors,
 * and then approximate remaining colors with the closest colorcell.
 *
 * Since quality of quantization is in reverse proportion to the number
 * of colors in original image, libAfterImage allows one to set arbitrary
 * level of downsampling of the color spectrum in the range of 8 bit per
 * channel to 1 bit per channel. Downsampling is performed by simple
 * dropping of less significant bits off of color values.
 *
 * In order to be able to determine closeness of colors, 3-channel RGB
 * values are converted into flat 24bit (or less if downsampling is used)
 * index. That is done by intermixing bits from different channels, like
 * so : R8G8B8R7G7B7...R1G1B1. That flat index is used to arrange colors
 * in ascending order, and later on to be able to find closest mapped
 * color. Simple hashing technique is used to speed up the
 * sorting/searching, as it allows one to limit linked lists traversals.
 *
 * SEE ALSO
 * Structures :
 *          ASColormapEntry
 *          ASColormap
 *
 * Functions :
 *          colormap_asimage(), destroy_colormap()
 *
 * Other libAfterImage modules :
 *          ascmap.h asfont.h asimage.h asvisual.h blender.h export.h
 *          import.h transform.h ximage.h
 * AUTHOR
 * Sasha Vasko <sasha at aftercode dot net>
 *******/

/***********************************************************************************/
/* reduced colormap building code :                                                */
/***********************************************************************************/
typedef struct ASMappedColor
{
	CARD8  alpha, red, green, blue;
	CARD32 indexed;
	unsigned int count ;
	int cmap_idx ;
	struct ASMappedColor *next ;
}ASMappedColor;

typedef struct ASSortedColorBucket
{
	unsigned int count ;
	ASMappedColor *head, *tail ;			/* pointers to first and last
											 * mapped colors in the stack */
	int good_offset ;                       /* skip to closest stack that
											 * has mapped colors */
}ASSortedColorBucket;

#define MAKE_INDEXED_COLOR3(red,green,blue) \
                   ((((green&0x200)|(blue&0x100)|(red&0x80))<<14))

#define MAKE_INDEXED_COLOR6(red,green,blue) \
				   (MAKE_INDEXED_COLOR3(red,green,blue)| \
		            (((green&0x100)|(blue&0x80) |(red&0x40))<<12))

#define MAKE_INDEXED_COLOR9(red,green,blue) \
                   (MAKE_INDEXED_COLOR6(red,green,blue)| \
		            (((green&0x80) |(blue&0x40) |(red&0x20))<<10))

#define MAKE_INDEXED_COLOR12(red,green,blue) \
                   (MAKE_INDEXED_COLOR9(red,green,blue)| \
					(((green&0x40) |(blue&0x20) |(red&0x10))<<8 ))

#define MAKE_INDEXED_COLOR15(red,green,blue) \
                   (MAKE_INDEXED_COLOR12(red,green,blue)| \
					(((green&0x20) |(blue&0x10) |(red&0x08))<<6 ))

#define MAKE_INDEXED_COLOR18(red,green,blue) \
                   (MAKE_INDEXED_COLOR15(red,green,blue)| \
					(((green&0x10) |(blue&0x08) |(red&0x04))<<4 ))

#define MAKE_INDEXED_COLOR21(red,green,blue) \
                   (MAKE_INDEXED_COLOR18(red,green,blue)| \
					(((green&0x08) |(blue&0x04) |(red&0x02))<<2 ))

#define MAKE_INDEXED_COLOR24(red,green,blue) \
                   (MAKE_INDEXED_COLOR21(red,green,blue)| \
					 ((green&0x04) |(blue&0x02) |(red&0x01)))

#define INDEX_SHIFT_RED(r)    (r)
#define INDEX_SHIFT_GREEN(g) ((g)<<2)
#define INDEX_SHIFT_BLUE(b) ((b)<<1)

#define INDEX_UNSHIFT_RED(r)    (r)
#define INDEX_UNSHIFT_GREEN(g)  ((g)>>2)
#define INDEX_UNSHIFT_BLUE(b)   ((b)>>1)

#define INDEX_UNESHIFT_RED(r,e)   ((r)>>(e))
#define INDEX_UNESHIFT_GREEN(g,e) ((g)>>(2+(e)))
#define INDEX_UNESHIFT_BLUE(b,e)  ((b)>>(1+(e)))


#define SLOTS_OFFSET24 15
#define SLOTS_MASK24   0x1FF
#define SLOTS_OFFSET21 12
#define SLOTS_MASK21   0x1FF

#define MAKE_INDEXED_COLOR MAKE_INDEXED_COLOR21
#define SLOTS_OFFSET	9
#define SLOTS_MASK		0xFFF
#define MAX_COLOR_BUCKETS		  4096


typedef struct ASSortedColorHash
{
	unsigned int count_unique ;
	ASSortedColorBucket *buckets ;
	int buckets_num ;
	CARD32  last_found ;
	int     last_idx ;
}ASSortedColorHash;

/****s* libAfterImage/ASColormapEntry
 * NAME
 * ASColormapEntry - ASColormapEntry represents single colorcell in the colormap.
 * SOURCE
 */

typedef struct ASColormapEntry
{
	CARD8 red, green, blue;
}ASColormapEntry;
/*******/
/****s* libAfterImage/ASColormap
 * NAME
 * ASColormap - ASColormap represents entire colormap generated for the image.
 * SOURCE
 */
typedef struct ASColormap
{
	ASColormapEntry *entries ;  /* array of colorcells */
	unsigned int count ;        /* number of used colorcells */
	ASSortedColorHash *hash ;   /* internal data */
	Bool has_opaque ;           /* If True then Image has opaque pixels */
}ASColormap;
/*******/

void         add_index_color   ( ASSortedColorHash *index,
	                             CARD32 indexed, unsigned int slot,
							     CARD32 red, CARD32 green, CARD32 blue );
void         destroy_colorhash ( ASSortedColorHash *index, Bool reusable );
unsigned int add_colormap_items( ASSortedColorHash *index,
	                             unsigned int start, unsigned int stop,
								 unsigned int quota, unsigned int base,
								 ASColormapEntry *entries );

void        fix_colorindex_shortcuts( ASSortedColorHash *index );
int         get_color_index         ( ASSortedColorHash *index,
	                                  CARD32 indexed, unsigned int slot );
ASColormap *color_hash2colormap     ( ASColormap *cmap,
	                                  unsigned int max_colors );

/****f* libAfterImage/colormap_asimage()
 * NAME
 * colormap_asimage()
 * SYNOPSIS
 * int *colormap_asimage( ASImage *im, ASColormap *cmap,
 *                        unsigned int max_colors, unsigned int dither,
 *                        int opaque_threshold );
 * INPUTS
 * im				- pointer to valid ASImage structure.
 * cmap             - preallocated structure to store colormap in.
 * max_colors       - maximum size of the colormap.
 * dither           - number of bits to strip off the color data ( 0...7 )
 * opaque_threshold - alpha channel threshold at which pixel should be
 *                    treated as opaque
 * RETURN VALUE
 * pointer to the array of indexes representing pixel's colorcells. This
 * array has size of WIDTHxHEIGHT where WIDTH and HEIGHT are size of the
 * source image.
 * DESCRIPTION
 * This function is all that is needed to quantize the ASImage. In order
 * to obtain colorcell of the pixel at (x,y) from result, the following
 * code could be used :
 * cmap->entries[res[y*width+x]]
 * where res is returned pointer.
 * Recommended value for dither parameter is 4 while quantizing photos to
 * 256 colors, and it could be less , if original has limited number of
 * colors.
 *
 *********/
/****f* libAfterImage/destroy_colormap()
 * NAME
 * destroy_colormap()
 * SYNOPSIS
 * void destroy_colormap( ASColormap *cmap, Bool reusable );
 * INPUTS
 * cmap				- pointer to valid ASColormap structure.
 * reusable         - if True, then the memory pointed to by cmap will
 *                    not be deallocated, as if it was allocated on stack
 * DESCRIPTION
 * Destroys ASColormap object created using colormap_asimage.
 *********/
int *colormap_asimage( ASImage *im, ASColormap *cmap,
	                   unsigned int max_colors, unsigned int dither,
					   int opaque_threshold );
void destroy_colormap( ASColormap *cmap, Bool reusable );

#ifdef __cplusplus
}
#endif

#endif