16 height_real = (h / 2) + 1;
18 pathmap = (
unsigned char **)
CALLOC((
unsigned int) (height_real * w),
sizeof(
unsigned char));
20 optimized = (
unsigned char **)
CALLOC((
unsigned int) ((w / 8) + 1),
sizeof(
unsigned char));
27 for (
unsigned long l = 0; l < width; l++)
28 if ((*up_pointers)[l])
29 free((*up_pointers)[l]);
38 if (x >= width || y >= height)
42 if (!(*up_pointers)[x]) {
44 CALLOC((
unsigned int) height,
47 (*optimized)[x / 8] &= (
unsigned char) ~(0x01 << (7 - (x % 8)));
49 if ((*optimized)[x / 8] & (0x01 << (7 - (x % 8))))
52 (*up_pointers)[x][
y] = up_pointer;
58 (*pathmap)[x * height_real + (y >> 1)] |= val;
65 if (x >= width || y >= height) {
69 *val = (*pathmap)[x * height_real + (y >> 1)] & 0x0f;
71 *val = (*pathmap)[x * height_real + (y >> 1)] >> 4;
74 if ((*optimized)[x / 8] & (0x01 << (7 - (x % 8)))) {
77 for (l = 0, counter = 0; l < y / 2; l++) {
78 if ((*pathmap)[x * height_real + l] &
ALI_LUP)
80 if (((*pathmap)[x * height_real + l] >> 4) & ALI_LUP)
83 if (y & 0x01 && ((*pathmap)[x * height_real + l] >> 4) & ALI_LUP)
85 *up_pointer = (*up_pointers)[x][counter];
87 *up_pointer = (*up_pointers)[x][
y];
97 if (!(*up_pointers)[x] || (*optimized)[x / 8] & (0x01 << (7 - (x % 8))))
100 for (l = 0, counter = 0; l < height; l++)
101 if ((*up_pointers)[x][l])
105 free((*up_pointers)[x]);
106 (*up_pointers)[x] =
NULp;
109 (*optimized)[x / 8] |= (
unsigned char) (0x01 << (7 - (x % 8)));
115 for (l = 0, counter = 0; l < height; l++)
116 if ((*up_pointers)[x][l])
117 (*buffer)[counter++] = (*up_pointers)[x][l];
118 (*buffer)[counter] =
NULp;
120 free((*up_pointers)[x]);
127 unsigned long x,
y, i;
130 printf(
"PATH_MATRIX:\n");
131 for (y = 0; y < height; y++) {
132 for (x = 0; x < width; x++) {
134 val = (*pathmap)[x * height_real + y / 2] & 0x0f;
136 val = (*pathmap)[x * height_real + y / 2] >> 4;
142 printf(
"UP_POINTERS:\n");
143 for (x = 0; x < width; x++) {
144 if ((*up_pointers)[x]) {
145 printf(
"%3ld : ", x);
146 if ((*optimized)[x / 8] & 0x01 << (7 - (x % 8))) {
147 for (y = 0; (*up_pointers)[x][
y]; y++) {
149 for (i = 0; i < (*up_pointers)[x][
y]->size(); i++) {
150 up = (*up_pointers)[x][
y]->get(i);
157 for (y = 0; y < height; y++) {
159 if ((*up_pointers)[x][y]) {
160 for (i = 0; i < (*up_pointers)[x][
y]->size(); i++) {
161 up = (*up_pointers)[x][
y]->get(i);
void ali_out_of_memory_if(bool cond)
void get(unsigned long x, unsigned long y, unsigned char *val, ALI_TARRAY< ali_pathmap_up_pointer > **up_pointer)
void set(unsigned long x, unsigned long y, unsigned char val, ALI_TARRAY< ali_pathmap_up_pointer > *up_pointer=NULp)
ALI_PATHMAP(unsigned long width, unsigned long height)
void * CALLOC(long i, long j)
void optimize(unsigned long x)
void ali_fatal_error(const char *message, const char *func)