| 1 | /* |
| 2 | * |
| 3 | * Print plug-in driver utility functions for the GIMP. |
| 4 | * |
| 5 | * Copyright 2001 Robert Krawitz ([email protected]) |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License as published by the Free |
| 9 | * Software Foundation; either version 2 of the License, or (at your option) |
| 10 | * any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 15 | * for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 19 | * |
| 20 | * Revision History: |
| 21 | * |
| 22 | * See ChangeLog |
| 23 | */ |
| 24 | |
| 25 | #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:411:9`! |
| 26 | #include <config.h>cxx . . $ `<file>/config.h`/ |
| 27 | #endif |
| 28 | #include <gutenprint/gutenprint.h>cxx . . $ `<file>/include/gutenprint/gutenprint.h`/ |
| 29 | #include "gutenprint-internal.h"cxx . . $ `<file>/src/main/gutenprint-internal.h`/ |
| 30 | #include <math.h> |
| 31 | #include <string.h> |
| 32 | #include <stdlib.h> |
| 33 | #include <stdio.h> |
| 34 | #include "dither-impl.h"cxx . . $ `<file>/src/main/dither-impl.h`/ |
| 35 | #include <sys/param.h> |
| 36 | |
| 37 | #ifdef __GNUC__cxx . . $ `<built-in>:8:9`! |
| 38 | #define inlinecxx . . $ `src/main/print-dither-matrices.c:38:9`! __inline__ |
| 39 | #endif |
| 40 | |
| 41 | |
| 42 | static unsigned |
| 43 | gcdcxx . . $ gcd(83f10ac8959d5577).(unsigned a, unsigned b) |
| 44 | { |
| 45 | unsigned tmp; |
| 46 | if (b > a) |
| 47 | { |
| 48 | tmp = a; |
| 49 | a = b; |
| 50 | b = tmp; |
| 51 | } |
| 52 | while (1) |
| 53 | { |
| 54 | tmp = a % b; |
| 55 | if (tmp == 0) |
| 56 | return b; |
| 57 | a = b; |
| 58 | b = tmp; |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | static inlinecxx . . $ `src/main/print-dither-matrices.c:38:9`! int |
| 63 | calc_ordered_pointcxx . . $ calc_ordered_point(2bbd4c30a4e514ca).(unsigned x, unsigned y, int steps, int multiplier, |
| 64 | int size, const unsigned *map) |
| 65 | { |
| 66 | int i, j; |
| 67 | unsigned retval = 0; |
| 68 | int divisor = 1; |
| 69 | int div1; |
| 70 | for (i = 0; i < steps; i++) |
| 71 | { |
| 72 | int xa = (x / divisor) % size; |
| 73 | int ya = (y / divisor) % size; |
| 74 | unsigned base; |
| 75 | base = map[ya + (xa * size)]; |
| 76 | div1 = 1; |
| 77 | for (j = i; j < steps - 1; j++) |
| 78 | div1 *= size * size; |
| 79 | retval += base * div1; |
| 80 | divisor *= size; |
| 81 | } |
| 82 | return retval * multiplier; |
| 83 | } |
| 84 | |
| 85 | static int |
| 86 | is_po2cxx . . $ is_po2(15f694ef3c96d230).(size_t i) |
| 87 | { |
| 88 | if (i == 0) |
| 89 | return 0; |
| 90 | return (((i & (i - 1)) == 0) ? 1 : 0); |
| 91 | } |
| 92 | |
| 93 | void |
| 94 | stp_dither_matrix_iterated_initcxx . . $ stp_dither_matrix_iterated_init(323b2fb4b36142ef).(stp_dither_matrix_impl_tcxx . . $ stp_dither_matrix_impl_t# *mat, size_t size, |
| 95 | size_t expt, const unsigned *array) |
| 96 | { |
| 97 | int i; |
| 98 | int x, y; |
| 99 | mat->basecxx . . $ dither_matrix_impl#base. = size; |
| 100 | mat->expcxx . . $ dither_matrix_impl#exp. = expt; |
| 101 | mat->x_sizecxx . . $ dither_matrix_impl#x_size. = 1; |
| 102 | for (i = 0; i < expt; i++) |
| 103 | mat->x_sizecxx . . $ dither_matrix_impl#x_size. *= mat->basecxx . . $ dither_matrix_impl#base.; |
| 104 | mat->y_sizecxx . . $ dither_matrix_impl#y_size. = mat->x_sizecxx . . $ dither_matrix_impl#x_size.; |
| 105 | mat->total_sizecxx . . $ dither_matrix_impl#total_size. = mat->x_sizecxx . . $ dither_matrix_impl#x_size. * mat->y_sizecxx . . $ dither_matrix_impl#y_size.; |
| 106 | mat->matrixcxx . . $ dither_matrix_impl#matrix. = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(sizeof(unsigned) * mat->x_sizecxx . . $ dither_matrix_impl#x_size. * mat->y_sizecxx . . $ dither_matrix_impl#y_size.); |
| 107 | for (x = 0; x < mat->x_sizecxx . . $ dither_matrix_impl#x_size.; x++) |
| 108 | for (y = 0; y < mat->y_sizecxx . . $ dither_matrix_impl#y_size.; y++) |
| 109 | { |
| 110 | mat->matrixcxx . . $ dither_matrix_impl#matrix.[x + y * mat->x_sizecxx . . $ dither_matrix_impl#x_size.] = |
| 111 | calc_ordered_pointcxx . . $ calc_ordered_point(2bbd4c30a4e514ca).(x, y, mat->expcxx . . $ dither_matrix_impl#exp., 1, mat->basecxx . . $ dither_matrix_impl#base., array); |
| 112 | mat->matrixcxx . . $ dither_matrix_impl#matrix.[x + y * mat->x_sizecxx . . $ dither_matrix_impl#x_size.] = |
| 113 | (double) mat->matrixcxx . . $ dither_matrix_impl#matrix.[x + y * mat->x_sizecxx . . $ dither_matrix_impl#x_size.] * 65536.0 / |
| 114 | (double) (mat->x_sizecxx . . $ dither_matrix_impl#x_size. * mat->y_sizecxx . . $ dither_matrix_impl#y_size.); |
| 115 | } |
| 116 | mat->last_xcxx . . $ dither_matrix_impl#last_x. = mat->last_x_modcxx . . $ dither_matrix_impl#last_x_mod. = 0; |
| 117 | mat->last_ycxx . . $ dither_matrix_impl#last_y. = mat->last_y_modcxx . . $ dither_matrix_impl#last_y_mod. = 0; |
| 118 | mat->indexcxx . . $ dither_matrix_impl#index. = 0; |
| 119 | mat->i_owncxx . . $ dither_matrix_impl#i_own. = 1; |
| 120 | if (is_po2cxx . . $ is_po2(15f694ef3c96d230).(mat->x_sizecxx . . $ dither_matrix_impl#x_size.)) |
| 121 | mat->fast_maskcxx . . $ dither_matrix_impl#fast_mask. = mat->x_sizecxx . . $ dither_matrix_impl#x_size. - 1; |
| 122 | else |
| 123 | mat->fast_maskcxx . . $ dither_matrix_impl#fast_mask. = 0; |
| 124 | } |
| 125 | |
| 126 | #define MATRIX_POINTcxx . . $ `src/main/print-dither-matrices.c:126:9`!(m, x, y, x_size, y_size) \ |
| 127 | ((m)[(((x) + (x_size)) % (x_size)) + ((x_size) * (((y) + (y_size)) % (y_size)))]) |
| 128 | |
| 129 | void |
| 130 | stp_dither_matrix_shearcxx . . $ stp_dither_matrix_shear(413ff86ce0465582).(stp_dither_matrix_impl_tcxx . . $ stp_dither_matrix_impl_t# *mat, int x_shear, int y_shear) |
| 131 | { |
| 132 | int i; |
| 133 | int j; |
| 134 | int *tmp = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(mat->x_sizecxx . . $ dither_matrix_impl#x_size. * mat->y_sizecxx . . $ dither_matrix_impl#y_size. * sizeof(int)); |
| 135 | for (i = 0; i < mat->x_sizecxx . . $ dither_matrix_impl#x_size.; i++) |
| 136 | for (j = 0; j < mat->y_sizecxx . . $ dither_matrix_impl#y_size.; j++) |
| 137 | MATRIX_POINTcxx . . $ `src/main/print-dither-matrices.c:126:9`!(tmp, i, j, mat->x_size, mat->y_size) = |
| 138 | MATRIX_POINTcxx . . $ `src/main/print-dither-matrices.c:126:9`!(mat->matrix, i, j * (x_shear + 1), mat->x_size, |
| 139 | mat->y_size); |
| 140 | for (i = 0; i < mat->x_sizecxx . . $ dither_matrix_impl#x_size.; i++) |
| 141 | for (j = 0; j < mat->y_sizecxx . . $ dither_matrix_impl#y_size.; j++) |
| 142 | MATRIX_POINTcxx . . $ `src/main/print-dither-matrices.c:126:9`!(mat->matrix, i, j, mat->x_size, mat->y_size) = |
| 143 | MATRIX_POINTcxx . . $ `src/main/print-dither-matrices.c:126:9`!(tmp, i * (y_shear + 1), j, mat->x_size, mat->y_size); |
| 144 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(tmp); |
| 145 | } |
| 146 | |
| 147 | int |
| 148 | stp_dither_matrix_validate_arraycxx . . $ stp_dither_matrix_validate_array(3326b8bc3e0c6ce2).(const stp_array_tcxx . . $ stp_array_t# *array) |
| 149 | { |
| 150 | double low, high; |
| 151 | const stp_sequence_tcxx . . $ stp_sequence_t# *seq = stp_array_get_sequencecxx . . $ stp_array_get_sequence(38ecccb1b7a939c6).(array); |
| 152 | stp_sequence_get_boundscxx . . $ stp_sequence_get_bounds(f1c777fa1c0d001).(seq, &low, &high); |
| 153 | if (low < 0 || high > 65535) |
| 154 | return 0; |
| 155 | return 1; |
| 156 | } |
| 157 | |
| 158 | |
| 159 | void |
| 160 | stp_dither_matrix_init_from_dither_arraycxx . . $ stp_dither_matrix_init_from_dither_array(e5ac2e4dc17109fa).(stp_dither_matrix_impl_tcxx . . $ stp_dither_matrix_impl_t# *mat, |
| 161 | const stp_array_tcxx . . $ stp_array_t# *array, |
| 162 | int transpose) |
| 163 | { |
| 164 | int x, y; |
| 165 | size_t count; |
| 166 | const unsigned short *vec; |
| 167 | int x_size, y_size; |
| 168 | const stp_sequence_tcxx . . $ stp_sequence_t# *seq = stp_array_get_sequencecxx . . $ stp_array_get_sequence(38ecccb1b7a939c6).(array); |
| 169 | stp_array_get_sizecxx . . $ stp_array_get_size(87544005943869ab).(array, &x_size, &y_size); |
| 170 | |
| 171 | vec = stp_sequence_get_ushort_datacxx . . $ stp_sequence_get_ushort_data(4ed516f6aafd5bf3).(seq, &count); |
| 172 | mat->basecxx . . $ dither_matrix_impl#base. = x_size; |
| 173 | mat->expcxx . . $ dither_matrix_impl#exp. = 1; |
| 174 | if (transpose) |
| 175 | { |
| 176 | mat->x_sizecxx . . $ dither_matrix_impl#x_size. = y_size; |
| 177 | mat->y_sizecxx . . $ dither_matrix_impl#y_size. = x_size; |
| 178 | } |
| 179 | else |
| 180 | { |
| 181 | mat->x_sizecxx . . $ dither_matrix_impl#x_size. = x_size; |
| 182 | mat->y_sizecxx . . $ dither_matrix_impl#y_size. = y_size; |
| 183 | } |
| 184 | mat->total_sizecxx . . $ dither_matrix_impl#total_size. = mat->x_sizecxx . . $ dither_matrix_impl#x_size. * mat->y_sizecxx . . $ dither_matrix_impl#y_size.; |
| 185 | mat->matrixcxx . . $ dither_matrix_impl#matrix. = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(sizeof(unsigned) * mat->x_sizecxx . . $ dither_matrix_impl#x_size. * mat->y_sizecxx . . $ dither_matrix_impl#y_size.); |
| 186 | for (x = 0; x < x_size; x++) |
| 187 | for (y = 0; y < y_size; y++) |
| 188 | { |
| 189 | if (transpose) |
| 190 | mat->matrixcxx . . $ dither_matrix_impl#matrix.[y + x * y_size] = vec[x + y * x_size]; |
| 191 | else |
| 192 | mat->matrixcxx . . $ dither_matrix_impl#matrix.[x + y * x_size] = vec[x + y * x_size]; |
| 193 | } |
| 194 | mat->last_xcxx . . $ dither_matrix_impl#last_x. = mat->last_x_modcxx . . $ dither_matrix_impl#last_x_mod. = 0; |
| 195 | mat->last_ycxx . . $ dither_matrix_impl#last_y. = mat->last_y_modcxx . . $ dither_matrix_impl#last_y_mod. = 0; |
| 196 | mat->indexcxx . . $ dither_matrix_impl#index. = 0; |
| 197 | mat->i_owncxx . . $ dither_matrix_impl#i_own. = 1; |
| 198 | if (is_po2cxx . . $ is_po2(15f694ef3c96d230).(mat->x_sizecxx . . $ dither_matrix_impl#x_size.)) |
| 199 | mat->fast_maskcxx . . $ dither_matrix_impl#fast_mask. = mat->x_sizecxx . . $ dither_matrix_impl#x_size. - 1; |
| 200 | else |
| 201 | mat->fast_maskcxx . . $ dither_matrix_impl#fast_mask. = 0; |
| 202 | } |
| 203 | |
| 204 | |
| 205 | void |
| 206 | stp_dither_matrix_initcxx . . $ stp_dither_matrix_init(d0375a92cd78bd51).(stp_dither_matrix_impl_tcxx . . $ stp_dither_matrix_impl_t# *mat, int x_size, int y_size, |
| 207 | const unsigned int *array, int transpose, int prescaled) |
| 208 | { |
| 209 | int x, y; |
| 210 | mat->basecxx . . $ dither_matrix_impl#base. = x_size; |
| 211 | mat->expcxx . . $ dither_matrix_impl#exp. = 1; |
| 212 | mat->x_sizecxx . . $ dither_matrix_impl#x_size. = x_size; |
| 213 | mat->y_sizecxx . . $ dither_matrix_impl#y_size. = y_size; |
| 214 | mat->total_sizecxx . . $ dither_matrix_impl#total_size. = mat->x_sizecxx . . $ dither_matrix_impl#x_size. * mat->y_sizecxx . . $ dither_matrix_impl#y_size.; |
| 215 | mat->matrixcxx . . $ dither_matrix_impl#matrix. = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(sizeof(unsigned) * mat->x_sizecxx . . $ dither_matrix_impl#x_size. * mat->y_sizecxx . . $ dither_matrix_impl#y_size.); |
| 216 | for (x = 0; x < mat->x_sizecxx . . $ dither_matrix_impl#x_size.; x++) |
| 217 | for (y = 0; y < mat->y_sizecxx . . $ dither_matrix_impl#y_size.; y++) |
| 218 | { |
| 219 | if (transpose) |
| 220 | mat->matrixcxx . . $ dither_matrix_impl#matrix.[x + y * mat->x_sizecxx . . $ dither_matrix_impl#x_size.] = array[y + x * mat->y_sizecxx . . $ dither_matrix_impl#y_size.]; |
| 221 | else |
| 222 | mat->matrixcxx . . $ dither_matrix_impl#matrix.[x + y * mat->x_sizecxx . . $ dither_matrix_impl#x_size.] = array[x + y * mat->x_sizecxx . . $ dither_matrix_impl#x_size.]; |
| 223 | if (!prescaled) |
| 224 | mat->matrixcxx . . $ dither_matrix_impl#matrix.[x + y * mat->x_sizecxx . . $ dither_matrix_impl#x_size.] = |
| 225 | (double) mat->matrixcxx . . $ dither_matrix_impl#matrix.[x + y * mat->x_sizecxx . . $ dither_matrix_impl#x_size.] * 65536.0 / |
| 226 | (double) (mat->x_sizecxx . . $ dither_matrix_impl#x_size. * mat->y_sizecxx . . $ dither_matrix_impl#y_size.); |
| 227 | } |
| 228 | mat->last_xcxx . . $ dither_matrix_impl#last_x. = mat->last_x_modcxx . . $ dither_matrix_impl#last_x_mod. = 0; |
| 229 | mat->last_ycxx . . $ dither_matrix_impl#last_y. = mat->last_y_modcxx . . $ dither_matrix_impl#last_y_mod. = 0; |
| 230 | mat->indexcxx . . $ dither_matrix_impl#index. = 0; |
| 231 | mat->i_owncxx . . $ dither_matrix_impl#i_own. = 1; |
| 232 | if (is_po2cxx . . $ is_po2(15f694ef3c96d230).(mat->x_sizecxx . . $ dither_matrix_impl#x_size.)) |
| 233 | mat->fast_maskcxx . . $ dither_matrix_impl#fast_mask. = mat->x_sizecxx . . $ dither_matrix_impl#x_size. - 1; |
| 234 | else |
| 235 | mat->fast_maskcxx . . $ dither_matrix_impl#fast_mask. = 0; |
| 236 | } |
| 237 | |
| 238 | void |
| 239 | stp_dither_matrix_init_shortcxx . . $ stp_dither_matrix_init_short(433a35797cf0afec).(stp_dither_matrix_impl_tcxx . . $ stp_dither_matrix_impl_t# *mat, int x_size, int y_size, |
| 240 | const unsigned short *array, int transpose, |
| 241 | int prescaled) |
| 242 | { |
| 243 | int x, y; |
| 244 | mat->basecxx . . $ dither_matrix_impl#base. = x_size; |
| 245 | mat->expcxx . . $ dither_matrix_impl#exp. = 1; |
| 246 | mat->x_sizecxx . . $ dither_matrix_impl#x_size. = x_size; |
| 247 | mat->y_sizecxx . . $ dither_matrix_impl#y_size. = y_size; |
| 248 | mat->total_sizecxx . . $ dither_matrix_impl#total_size. = mat->x_sizecxx . . $ dither_matrix_impl#x_size. * mat->y_sizecxx . . $ dither_matrix_impl#y_size.; |
| 249 | mat->matrixcxx . . $ dither_matrix_impl#matrix. = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(sizeof(unsigned) * mat->x_sizecxx . . $ dither_matrix_impl#x_size. * mat->y_sizecxx . . $ dither_matrix_impl#y_size.); |
| 250 | for (x = 0; x < mat->x_sizecxx . . $ dither_matrix_impl#x_size.; x++) |
| 251 | for (y = 0; y < mat->y_sizecxx . . $ dither_matrix_impl#y_size.; y++) |
| 252 | { |
| 253 | if (transpose) |
| 254 | mat->matrixcxx . . $ dither_matrix_impl#matrix.[x + y * mat->x_sizecxx . . $ dither_matrix_impl#x_size.] = array[y + x * mat->y_sizecxx . . $ dither_matrix_impl#y_size.]; |
| 255 | else |
| 256 | mat->matrixcxx . . $ dither_matrix_impl#matrix.[x + y * mat->x_sizecxx . . $ dither_matrix_impl#x_size.] = array[x + y * mat->x_sizecxx . . $ dither_matrix_impl#x_size.]; |
| 257 | if (!prescaled) |
| 258 | mat->matrixcxx . . $ dither_matrix_impl#matrix.[x + y * mat->x_sizecxx . . $ dither_matrix_impl#x_size.] = |
| 259 | (double) mat->matrixcxx . . $ dither_matrix_impl#matrix.[x + y * mat->x_sizecxx . . $ dither_matrix_impl#x_size.] * 65536.0 / |
| 260 | (double) (mat->x_sizecxx . . $ dither_matrix_impl#x_size. * mat->y_sizecxx . . $ dither_matrix_impl#y_size.); |
| 261 | } |
| 262 | mat->last_xcxx . . $ dither_matrix_impl#last_x. = mat->last_x_modcxx . . $ dither_matrix_impl#last_x_mod. = 0; |
| 263 | mat->last_ycxx . . $ dither_matrix_impl#last_y. = mat->last_y_modcxx . . $ dither_matrix_impl#last_y_mod. = 0; |
| 264 | mat->indexcxx . . $ dither_matrix_impl#index. = 0; |
| 265 | mat->i_owncxx . . $ dither_matrix_impl#i_own. = 1; |
| 266 | if (is_po2cxx . . $ is_po2(15f694ef3c96d230).(mat->x_sizecxx . . $ dither_matrix_impl#x_size.)) |
| 267 | mat->fast_maskcxx . . $ dither_matrix_impl#fast_mask. = mat->x_sizecxx . . $ dither_matrix_impl#x_size. - 1; |
| 268 | else |
| 269 | mat->fast_maskcxx . . $ dither_matrix_impl#fast_mask. = 0; |
| 270 | } |
| 271 | |
| 272 | void |
| 273 | stp_dither_matrix_destroycxx . . $ stp_dither_matrix_destroy(68c7be79061d109b).(stp_dither_matrix_impl_tcxx . . $ stp_dither_matrix_impl_t# *mat) |
| 274 | { |
| 275 | if (mat->i_owncxx . . $ dither_matrix_impl#i_own. && mat->matrixcxx . . $ dither_matrix_impl#matrix.) |
| 276 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(mat->matrixcxx . . $ dither_matrix_impl#matrix.); |
| 277 | mat->matrixcxx . . $ dither_matrix_impl#matrix. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 278 | mat->basecxx . . $ dither_matrix_impl#base. = 0; |
| 279 | mat->expcxx . . $ dither_matrix_impl#exp. = 0; |
| 280 | mat->x_sizecxx . . $ dither_matrix_impl#x_size. = 0; |
| 281 | mat->y_sizecxx . . $ dither_matrix_impl#y_size. = 0; |
| 282 | mat->total_sizecxx . . $ dither_matrix_impl#total_size. = 0; |
| 283 | mat->i_owncxx . . $ dither_matrix_impl#i_own. = 0; |
| 284 | } |
| 285 | |
| 286 | void |
| 287 | stp_dither_matrix_clonecxx . . $ stp_dither_matrix_clone(1b0edb5d3301f384).(const stp_dither_matrix_impl_tcxx . . $ stp_dither_matrix_impl_t# *src, stp_dither_matrix_impl_tcxx . . $ stp_dither_matrix_impl_t# *dest, |
| 288 | int x_offset, int y_offset) |
| 289 | { |
| 290 | dest->basecxx . . $ dither_matrix_impl#base. = src->basecxx . . $ dither_matrix_impl#base.; |
| 291 | dest->expcxx . . $ dither_matrix_impl#exp. = src->expcxx . . $ dither_matrix_impl#exp.; |
| 292 | dest->x_sizecxx . . $ dither_matrix_impl#x_size. = src->x_sizecxx . . $ dither_matrix_impl#x_size.; |
| 293 | dest->y_sizecxx . . $ dither_matrix_impl#y_size. = src->y_sizecxx . . $ dither_matrix_impl#y_size.; |
| 294 | dest->total_sizecxx . . $ dither_matrix_impl#total_size. = src->total_sizecxx . . $ dither_matrix_impl#total_size.; |
| 295 | dest->matrixcxx . . $ dither_matrix_impl#matrix. = src->matrixcxx . . $ dither_matrix_impl#matrix.; |
| 296 | dest->x_offsetcxx . . $ dither_matrix_impl#x_offset. = x_offset; |
| 297 | dest->y_offsetcxx . . $ dither_matrix_impl#y_offset. = y_offset; |
| 298 | dest->last_xcxx . . $ dither_matrix_impl#last_x. = 0; |
| 299 | dest->last_x_modcxx . . $ dither_matrix_impl#last_x_mod. = dest->x_offsetcxx . . $ dither_matrix_impl#x_offset. % dest->x_sizecxx . . $ dither_matrix_impl#x_size.; |
| 300 | dest->last_ycxx . . $ dither_matrix_impl#last_y. = 0; |
| 301 | dest->last_y_modcxx . . $ dither_matrix_impl#last_y_mod. = dest->x_sizecxx . . $ dither_matrix_impl#x_size. * (dest->y_offsetcxx . . $ dither_matrix_impl#y_offset. % dest->y_sizecxx . . $ dither_matrix_impl#y_size.); |
| 302 | dest->indexcxx . . $ dither_matrix_impl#index. = dest->last_x_modcxx . . $ dither_matrix_impl#last_x_mod. + dest->last_y_modcxx . . $ dither_matrix_impl#last_y_mod.; |
| 303 | dest->fast_maskcxx . . $ dither_matrix_impl#fast_mask. = src->fast_maskcxx . . $ dither_matrix_impl#fast_mask.; |
| 304 | dest->i_owncxx . . $ dither_matrix_impl#i_own. = 0; |
| 305 | } |
| 306 | |
| 307 | void |
| 308 | stp_dither_matrix_copycxx . . $ stp_dither_matrix_copy(c86f8c2fec3b92f5).(const stp_dither_matrix_impl_tcxx . . $ stp_dither_matrix_impl_t# *src, stp_dither_matrix_impl_tcxx . . $ stp_dither_matrix_impl_t# *dest) |
| 309 | { |
| 310 | int x; |
| 311 | dest->basecxx . . $ dither_matrix_impl#base. = src->basecxx . . $ dither_matrix_impl#base.; |
| 312 | dest->expcxx . . $ dither_matrix_impl#exp. = src->expcxx . . $ dither_matrix_impl#exp.; |
| 313 | dest->x_sizecxx . . $ dither_matrix_impl#x_size. = src->x_sizecxx . . $ dither_matrix_impl#x_size.; |
| 314 | dest->y_sizecxx . . $ dither_matrix_impl#y_size. = src->y_sizecxx . . $ dither_matrix_impl#y_size.; |
| 315 | dest->total_sizecxx . . $ dither_matrix_impl#total_size. = src->total_sizecxx . . $ dither_matrix_impl#total_size.; |
| 316 | dest->matrixcxx . . $ dither_matrix_impl#matrix. = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(sizeof(unsigned) * dest->x_sizecxx . . $ dither_matrix_impl#x_size. * dest->y_sizecxx . . $ dither_matrix_impl#y_size.); |
| 317 | for (x = 0; x < dest->x_sizecxx . . $ dither_matrix_impl#x_size. * dest->y_sizecxx . . $ dither_matrix_impl#y_size.; x++) |
| 318 | dest->matrixcxx . . $ dither_matrix_impl#matrix.[x] = src->matrixcxx . . $ dither_matrix_impl#matrix.[x]; |
| 319 | dest->x_offsetcxx . . $ dither_matrix_impl#x_offset. = 0; |
| 320 | dest->y_offsetcxx . . $ dither_matrix_impl#y_offset. = 0; |
| 321 | dest->last_xcxx . . $ dither_matrix_impl#last_x. = 0; |
| 322 | dest->last_x_modcxx . . $ dither_matrix_impl#last_x_mod. = 0; |
| 323 | dest->last_ycxx . . $ dither_matrix_impl#last_y. = 0; |
| 324 | dest->last_y_modcxx . . $ dither_matrix_impl#last_y_mod. = 0; |
| 325 | dest->indexcxx . . $ dither_matrix_impl#index. = 0; |
| 326 | dest->fast_maskcxx . . $ dither_matrix_impl#fast_mask. = src->fast_maskcxx . . $ dither_matrix_impl#fast_mask.; |
| 327 | dest->i_owncxx . . $ dither_matrix_impl#i_own. = 1; |
| 328 | } |
| 329 | |
| 330 | void |
| 331 | stp_dither_matrix_scale_exponentiallycxx . . $ stp_dither_matrix_scale_exponentially(6c2f9d30bd1a050e).(stp_dither_matrix_impl_tcxx . . $ stp_dither_matrix_impl_t# *mat, double exponent) |
| 332 | { |
| 333 | int i; |
| 334 | int mat_size = mat->x_sizecxx . . $ dither_matrix_impl#x_size. * mat->y_sizecxx . . $ dither_matrix_impl#y_size.; |
| 335 | for (i = 0; i < mat_size; i++) |
| 336 | { |
| 337 | double dd = mat->matrixcxx . . $ dither_matrix_impl#matrix.[i] / 65535.0; |
| 338 | dd = powcxx . . $ pow(d8e7e0733fa41c87).(dd, exponent); |
| 339 | mat->matrixcxx . . $ dither_matrix_impl#matrix.[i] = 65535 * dd; |
| 340 | } |
| 341 | } |
| 342 | |
| 343 | void |
| 344 | stp_dither_matrix_set_rowcxx . . $ stp_dither_matrix_set_row(befc66d6fe93ad5c).(stp_dither_matrix_impl_tcxx . . $ stp_dither_matrix_impl_t# *mat, int y) |
| 345 | { |
| 346 | mat->last_ycxx . . $ dither_matrix_impl#last_y. = y; |
| 347 | mat->last_y_modcxx . . $ dither_matrix_impl#last_y_mod. = mat->x_sizecxx . . $ dither_matrix_impl#x_size. * ((y + mat->y_offsetcxx . . $ dither_matrix_impl#y_offset.) % mat->y_sizecxx . . $ dither_matrix_impl#y_size.); |
| 348 | mat->indexcxx . . $ dither_matrix_impl#index. = mat->last_x_modcxx . . $ dither_matrix_impl#last_x_mod. + mat->last_y_modcxx . . $ dither_matrix_impl#last_y_mod.; |
| 349 | } |
| 350 | |
| 351 | static void |
| 352 | preinit_matrixcxx . . $ preinit_matrix(1a97b8462f9f913c).(stp_vars_tcxx . . $ stp_vars_t# *v) |
| 353 | { |
| 354 | stpi_dither_tcxx . . $ stpi_dither_t# *d = (stpi_dither_tcxx . . $ stpi_dither_t# *) stp_get_component_datacxx . . $ stp_get_component_data(2bc0070dfdce2f04).(v, "Dither"); |
| 355 | int i; |
| 356 | for (i = 0; i < CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d); i++) |
| 357 | stp_dither_matrix_destroycxx . . $ stp_dither_matrix_destroy(68c7be79061d109b).(&(CHANNELcxx . . $ `src/main/dither-impl.h:178:9`!(d, i).dithermatcxx . . $ dither_channel#dithermat.)); |
| 358 | stp_dither_matrix_destroycxx . . $ stp_dither_matrix_destroy(68c7be79061d109b).(&(d->dither_matrixcxx . . $ dither#dither_matrix.)); |
| 359 | } |
| 360 | |
| 361 | static void |
| 362 | postinit_matrixcxx . . $ postinit_matrix(9e1f5dddaee1574e).(stp_vars_tcxx . . $ stp_vars_t# *v, int x_shear, int y_shear) |
| 363 | { |
| 364 | stpi_dither_tcxx . . $ stpi_dither_t# *d = (stpi_dither_tcxx . . $ stpi_dither_t# *) stp_get_component_datacxx . . $ stp_get_component_data(2bc0070dfdce2f04).(v, "Dither"); |
| 365 | unsigned rc = 1 + (unsigned) ceilcxx . . $ ceil(447c67c6676f75c3).(sqrtcxx . . $ sqrt(447c67c6676f75c3).(CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d))); |
| 366 | int i, j; |
| 367 | int color = 0; |
| 368 | unsigned x_n = d->dither_matrixcxx . . $ dither#dither_matrix..x_sizecxx . . $ dither_matrix_impl#x_size. / rc; |
| 369 | unsigned y_n = d->dither_matrixcxx . . $ dither#dither_matrix..y_sizecxx . . $ dither_matrix_impl#y_size. / rc; |
| 370 | if (x_shear || y_shear) |
| 371 | stp_dither_matrix_shearcxx . . $ stp_dither_matrix_shear(413ff86ce0465582).(&(d->dither_matrixcxx . . $ dither#dither_matrix.), x_shear, y_shear); |
| 372 | for (i = 0; i < rc; i++) |
| 373 | for (j = 0; j < rc; j++) |
| 374 | if (color < CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d)) |
| 375 | { |
| 376 | stp_dither_matrix_clonecxx . . $ stp_dither_matrix_clone(1b0edb5d3301f384).(&(d->dither_matrixcxx . . $ dither#dither_matrix.), |
| 377 | &(CHANNELcxx . . $ `src/main/dither-impl.h:178:9`!(d, color).dithermatcxx . . $ dither_channel#dithermat.), |
| 378 | x_n * i, y_n * j); |
| 379 | color++; |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | void |
| 384 | stp_dither_set_iterated_matrixcxx . . $ stp_dither_set_iterated_matrix(6b6d260d194e2c9).(stp_vars_tcxx . . $ stp_vars_t# *v, size_t edge, size_t iterations, |
| 385 | const unsigned *data, int prescaled, |
| 386 | int x_shear, int y_shear) |
| 387 | { |
| 388 | stpi_dither_tcxx . . $ stpi_dither_t# *d = (stpi_dither_tcxx . . $ stpi_dither_t# *) stp_get_component_datacxx . . $ stp_get_component_data(2bc0070dfdce2f04).(v, "Dither"); |
| 389 | (void)prescaled; |
| 390 | |
| 391 | preinit_matrixcxx . . $ preinit_matrix(1a97b8462f9f913c).(v); |
| 392 | stp_dither_matrix_iterated_initcxx . . $ stp_dither_matrix_iterated_init(323b2fb4b36142ef).(&(d->dither_matrixcxx . . $ dither#dither_matrix.), edge, iterations, data); |
| 393 | postinit_matrixcxx . . $ postinit_matrix(9e1f5dddaee1574e).(v, x_shear, y_shear); |
| 394 | } |
| 395 | |
| 396 | void |
| 397 | stp_dither_set_matrixcxx . . $ stp_dither_set_matrix(faa1ae264cb63792).(stp_vars_tcxx . . $ stp_vars_t# *v, const stp_dither_matrix_generic_tcxx . . $ stp_dither_matrix_generic_t# *matrix, |
| 398 | int transposed, int x_shear, int y_shear) |
| 399 | { |
| 400 | stpi_dither_tcxx . . $ stpi_dither_t# *d = (stpi_dither_tcxx . . $ stpi_dither_t# *) stp_get_component_datacxx . . $ stp_get_component_data(2bc0070dfdce2f04).(v, "Dither"); |
| 401 | int x = transposed ? matrix->ycxx . . $ stp_dither_matrix_generic#y. : matrix->xcxx . . $ stp_dither_matrix_generic#x.; |
| 402 | int y = transposed ? matrix->xcxx . . $ stp_dither_matrix_generic#x. : matrix->ycxx . . $ stp_dither_matrix_generic#y.; |
| 403 | preinit_matrixcxx . . $ preinit_matrix(1a97b8462f9f913c).(v); |
| 404 | if (matrix->bytescxx . . $ stp_dither_matrix_generic#bytes. == 2) |
| 405 | stp_dither_matrix_init_shortcxx . . $ stp_dither_matrix_init_short(433a35797cf0afec).(&(d->dither_matrixcxx . . $ dither#dither_matrix.), x, y, |
| 406 | (const unsigned short *) matrix->datacxx . . $ stp_dither_matrix_generic#data., |
| 407 | transposed, matrix->prescaledcxx . . $ stp_dither_matrix_generic#prescaled.); |
| 408 | else if (matrix->bytescxx . . $ stp_dither_matrix_generic#bytes. == 4) |
| 409 | stp_dither_matrix_initcxx . . $ stp_dither_matrix_init(d0375a92cd78bd51).(&(d->dither_matrixcxx . . $ dither#dither_matrix.), x, y, |
| 410 | (const unsigned *)matrix->datacxx . . $ stp_dither_matrix_generic#data., |
| 411 | transposed, matrix->prescaledcxx . . $ stp_dither_matrix_generic#prescaled.); |
| 412 | postinit_matrixcxx . . $ postinit_matrix(9e1f5dddaee1574e).(v, x_shear, y_shear); |
| 413 | } |
| 414 | |
| 415 | void |
| 416 | stp_dither_set_matrix_from_dither_arraycxx . . $ stp_dither_set_matrix_from_dither_array(6587d31ec6306ce9).(stp_vars_tcxx . . $ stp_vars_t# *v, |
| 417 | const stp_array_tcxx . . $ stp_array_t# *array, |
| 418 | int transpose) |
| 419 | { |
| 420 | stpi_dither_tcxx . . $ stpi_dither_t# *d = (stpi_dither_tcxx . . $ stpi_dither_t# *) stp_get_component_datacxx . . $ stp_get_component_data(2bc0070dfdce2f04).(v, "Dither"); |
| 421 | preinit_matrixcxx . . $ preinit_matrix(1a97b8462f9f913c).(v); |
| 422 | stp_dither_matrix_init_from_dither_arraycxx . . $ stp_dither_matrix_init_from_dither_array(e5ac2e4dc17109fa).(&(d->dither_matrixcxx . . $ dither#dither_matrix.), array, transpose); |
| 423 | postinit_matrixcxx . . $ postinit_matrix(9e1f5dddaee1574e).(v, 0, 0); |
| 424 | } |
| 425 | |
| 426 | void |
| 427 | stp_dither_set_transitioncxx . . $ stp_dither_set_transition(8ce3003bda9b93be).(stp_vars_tcxx . . $ stp_vars_t# *v, double exponent) |
| 428 | { |
| 429 | stpi_dither_tcxx . . $ stpi_dither_t# *d = (stpi_dither_tcxx . . $ stpi_dither_t# *) stp_get_component_datacxx . . $ stp_get_component_data(2bc0070dfdce2f04).(v, "Dither"); |
| 430 | unsigned rc = 1 + (unsigned) ceilcxx . . $ ceil(447c67c6676f75c3).(sqrtcxx . . $ sqrt(447c67c6676f75c3).(CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d))); |
| 431 | int i, j; |
| 432 | int color = 0; |
| 433 | unsigned x_n = d->dither_matrixcxx . . $ dither#dither_matrix..x_sizecxx . . $ dither_matrix_impl#x_size. / rc; |
| 434 | unsigned y_n = d->dither_matrixcxx . . $ dither#dither_matrix..y_sizecxx . . $ dither_matrix_impl#y_size. / rc; |
| 435 | for (i = 0; i < CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d); i++) |
| 436 | stp_dither_matrix_destroycxx . . $ stp_dither_matrix_destroy(68c7be79061d109b).(&(CHANNELcxx . . $ `src/main/dither-impl.h:178:9`!(d, i).pickcxx . . $ dither_channel#pick.)); |
| 437 | if (exponent < .999 || exponent > 1.001) |
| 438 | for (i = 0; i < rc; i++) |
| 439 | for (j = 0; j < rc; j++) |
| 440 | if (color < CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d)) |
| 441 | { |
| 442 | stp_dither_matrix_clonecxx . . $ stp_dither_matrix_clone(1b0edb5d3301f384).(&(d->dither_matrixcxx . . $ dither#dither_matrix.), |
| 443 | &(CHANNELcxx . . $ `src/main/dither-impl.h:178:9`!(d, color).pickcxx . . $ dither_channel#pick.), |
| 444 | x_n * i, y_n * j); |
| 445 | color++; |
| 446 | } |
| 447 | } |
| 448 | |
| 449 | static stp_list_tcxx . . $ stp_list_t# *dither_matrix_cachecxx . . $ dither_matrix_cache. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 450 | |
| 451 | typedef structcxx . . $ $anonymous_type_d9d57ee7fc772b66_0# |
| 452 | { |
| 453 | int xcxx . . $ $anonymous_type_d9d57ee7fc772b66_0#x.; |
| 454 | int ycxx . . $ $anonymous_type_d9d57ee7fc772b66_0#y.; |
| 455 | const char *filenamecxx . . $ $anonymous_type_d9d57ee7fc772b66_0#filename.; |
| 456 | const stp_array_tcxx . . $ stp_array_t# *dither_arraycxx . . $ $anonymous_type_d9d57ee7fc772b66_0#dither_array.; |
| 457 | } stp_xml_dither_cache_tcxx . . $ stp_xml_dither_cache_t#; |
| 458 | |
| 459 | static stp_xml_dither_cache_tcxx . . $ stp_xml_dither_cache_t# * |
| 460 | stp_xml_dither_cache_getcxx . . $ stp_xml_dither_cache_get(11a8f52590821a71).(int x, int y) |
| 461 | { |
| 462 | stp_list_item_tcxx . . $ stp_list_item_t# *ln; |
| 463 | |
| 464 | stp_deprintfcxx . . $ stp_deprintf(3d303ebd7ab3b1e3).(STP_DBG_XMLcxx . . $ `include/gutenprint/util.h:182:9`!, |
| 465 | "stp_xml_dither_cache_get: lookup %dx%d... ", x, y); |
| 466 | if (!dither_matrix_cachecxx . . $ dither_matrix_cache.) |
| 467 | { |
| 468 | stp_deprintfcxx . . $ stp_deprintf(3d303ebd7ab3b1e3).(STP_DBG_XMLcxx . . $ `include/gutenprint/util.h:182:9`!, "cache does not exist\n"); |
| 469 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 470 | } |
| 471 | |
| 472 | ln = stp_list_get_startcxx . . $ stp_list_get_start(44f6202a74729935).(dither_matrix_cachecxx . . $ dither_matrix_cache.); |
| 473 | |
| 474 | while (ln) |
| 475 | { |
| 476 | if (((stp_xml_dither_cache_tcxx . . $ stp_xml_dither_cache_t# *) stp_list_item_get_datacxx . . $ stp_list_item_get_data(9a5daa75441a53b5).(ln))->xcxx . . $ $anonymous_type_d9d57ee7fc772b66_0#x. == x && |
| 477 | ((stp_xml_dither_cache_tcxx . . $ stp_xml_dither_cache_t# *) stp_list_item_get_datacxx . . $ stp_list_item_get_data(9a5daa75441a53b5).(ln))->ycxx . . $ $anonymous_type_d9d57ee7fc772b66_0#y. == y) |
| 478 | { |
| 479 | |
| 480 | stp_deprintfcxx . . $ stp_deprintf(3d303ebd7ab3b1e3).(STP_DBG_XMLcxx . . $ `include/gutenprint/util.h:182:9`!, "found\n"); |
| 481 | |
| 482 | return ((stp_xml_dither_cache_tcxx . . $ stp_xml_dither_cache_t# *) stp_list_item_get_datacxx . . $ stp_list_item_get_data(9a5daa75441a53b5).(ln)); |
| 483 | } |
| 484 | ln = stp_list_item_nextcxx . . $ stp_list_item_next(83833ec172b48f23).(ln); |
| 485 | } |
| 486 | stp_deprintfcxx . . $ stp_deprintf(3d303ebd7ab3b1e3).(STP_DBG_XMLcxx . . $ `include/gutenprint/util.h:182:9`!, "missing\n"); |
| 487 | |
| 488 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 489 | } |
| 490 | |
| 491 | static void |
| 492 | stp_xml_dither_cache_setcxx . . $ stp_xml_dither_cache_set(3139f19a0dbb8edf).(int x, int y, const char *filename) |
| 493 | { |
| 494 | stp_xml_dither_cache_tcxx . . $ stp_xml_dither_cache_t# *cacheval; |
| 495 | |
| 496 | STPI_ASSERTcxx . . $ `src/main/gutenprint-internal.h:58:9`!(x && y && filename, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 497 | |
| 498 | stp_xml_initcxx . . $ stp_xml_init(49f6e7a06ebc5aa8).(); |
| 499 | |
| 500 | if (dither_matrix_cachecxx . . $ dither_matrix_cache. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 501 | dither_matrix_cachecxx . . $ dither_matrix_cache. = stp_list_createcxx . . $ stp_list_create(728167c67729d082).(); |
| 502 | |
| 503 | if (stp_xml_dither_cache_getcxx . . $ stp_xml_dither_cache_get(11a8f52590821a71).(x, y)) |
| 504 | /* Already cached for this x and y aspect */ |
| 505 | return; |
| 506 | |
| 507 | cacheval = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(sizeof(stp_xml_dither_cache_tcxx . . $ stp_xml_dither_cache_t#)); |
| 508 | cacheval->xcxx . . $ $anonymous_type_d9d57ee7fc772b66_0#x. = x; |
| 509 | cacheval->ycxx . . $ $anonymous_type_d9d57ee7fc772b66_0#y. = y; |
| 510 | cacheval->filenamecxx . . $ $anonymous_type_d9d57ee7fc772b66_0#filename. = stp_strdupcxx . . $ stp_strdup(a8b8e32347182212).(filename); |
| 511 | cacheval->dither_arraycxx . . $ $anonymous_type_d9d57ee7fc772b66_0#dither_array. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 512 | |
| 513 | stp_list_item_createcxx . . $ stp_list_item_create(54f08bf465e39eec).(dither_matrix_cachecxx . . $ dither_matrix_cache., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, (void *) cacheval); |
| 514 | |
| 515 | stp_deprintfcxx . . $ stp_deprintf(3d303ebd7ab3b1e3).(STP_DBG_XMLcxx . . $ `include/gutenprint/util.h:182:9`!, "stp_xml_dither_cache_set: added %dx%d\n", x, y); |
| 516 | |
| 517 | stp_xml_exitcxx . . $ stp_xml_exit(49f6e7a06ebc5aa8).(); |
| 518 | |
| 519 | return; |
| 520 | } |
| 521 | |
| 522 | /* |
| 523 | * Parse the <dither-matrix> node. |
| 524 | */ |
| 525 | static int |
| 526 | stp_xml_process_dither_matrixcxx . . $ stp_xml_process_dither_matrix(add120f6a4c14e60).(stp_mxml_node_tcxx . . $ stp_mxml_node_t# *dm, /* The dither matrix node */ |
| 527 | const char *file) /* Source file */ |
| 528 | |
| 529 | { |
| 530 | const char *value; |
| 531 | int x = -1; |
| 532 | int y = -1; |
| 533 | |
| 534 | value = stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(dm, "x-aspect"); |
| 535 | x = stp_xmlstrtolcxx . . $ stp_xmlstrtol(3c95bd14d5d5d286).(value); |
| 536 | |
| 537 | value = stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(dm, "y-aspect"); |
| 538 | y = stp_xmlstrtolcxx . . $ stp_xmlstrtol(3c95bd14d5d5d286).(value); |
| 539 | |
| 540 | stp_deprintfcxx . . $ stp_deprintf(3d303ebd7ab3b1e3).(STP_DBG_XMLcxx . . $ `include/gutenprint/util.h:182:9`!, |
| 541 | "stp_xml_process_dither_matrix: x=%d, y=%d\n", x, y); |
| 542 | |
| 543 | stp_xml_dither_cache_setcxx . . $ stp_xml_dither_cache_set(3139f19a0dbb8edf).(x, y, file); |
| 544 | return 1; |
| 545 | } |
| 546 | |
| 547 | static stp_array_tcxx . . $ stp_array_t# * |
| 548 | stpi_dither_array_create_from_xmltreecxx . . $ stpi_dither_array_create_from_xmltree(da0ec9d220311c1d).(stp_mxml_node_tcxx . . $ stp_mxml_node_t# *dm, int x, int y) /* Dither matrix node */ |
| 549 | { |
| 550 | const char *stmp; |
| 551 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *child; |
| 552 | int x_aspect, y_aspect; /* Dither matrix size */ |
| 553 | |
| 554 | /* Get x-size */ |
| 555 | stmp = stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(dm, "x-aspect"); |
| 556 | if (stmp) |
| 557 | { |
| 558 | x_aspect = (int) stp_xmlstrtoulcxx . . $ stp_xmlstrtoul(751346f8406fd082).(stmp); |
| 559 | } |
| 560 | else |
| 561 | { |
| 562 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("stpi_dither_array_create_from_xmltree: \"x-aspect\" missing\n"); |
| 563 | goto error; |
| 564 | } |
| 565 | /* Get y-size */ |
| 566 | stmp = stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(dm, "y-aspect"); |
| 567 | if (stmp) |
| 568 | { |
| 569 | y_aspect = (int) stp_xmlstrtoulcxx . . $ stp_xmlstrtoul(751346f8406fd082).(stmp); |
| 570 | } |
| 571 | else |
| 572 | { |
| 573 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("stpi_dither_array_create_from_xmltree: \"y-aspect\" missing\n"); |
| 574 | goto error; |
| 575 | } |
| 576 | |
| 577 | if (x * y_aspect != y * x_aspect) |
| 578 | { |
| 579 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("stpi_dither_array_create_from_xmltree: requested aspect of (%d, %d), found (%d, %d)\n", |
| 580 | x, y, x_aspect, y_aspect); |
| 581 | goto error; |
| 582 | } |
| 583 | |
| 584 | /* Now read in the array */ |
| 585 | child = stp_xml_get_nodecxx . . $ stp_xml_get_node(a1d8ee452fb78e99).(dm, "array", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 586 | if (child) |
| 587 | return stp_array_create_from_xmltreecxx . . $ stp_array_create_from_xmltree(ca9ac7ca662c1ab8).(child); |
| 588 | else |
| 589 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("stpi_dither_array_create_from_xmltree: cannot find root\n"); |
| 590 | error: |
| 591 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 592 | } |
| 593 | |
| 594 | static stp_array_tcxx . . $ stp_array_t# * |
| 595 | xml_doc_get_dither_arraycxx . . $ xml_doc_get_dither_array(da0ec9d220311c1d).(stp_mxml_node_tcxx . . $ stp_mxml_node_t# *doc, int x, int y) |
| 596 | { |
| 597 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *cur; |
| 598 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *xmlseq; |
| 599 | |
| 600 | if (doc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 601 | { |
| 602 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("xml_doc_get_dither_array: XML file not parsed successfully.\n"); |
| 603 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 604 | } |
| 605 | |
| 606 | cur = doc->childcxx . . $ stp_mxml_node_s#child.; |
| 607 | |
| 608 | if (cur == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 609 | { |
| 610 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("xml_doc_get_dither_array: empty document\n"); |
| 611 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 612 | } |
| 613 | |
| 614 | xmlseq = stp_xml_get_nodecxx . . $ stp_xml_get_node(a1d8ee452fb78e99).(cur, "gutenprint", "dither-matrix", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 615 | if (xmlseq == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 616 | { |
| 617 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("xml-doc-get-dither-array: XML file is not a dither matrix.\n"); |
| 618 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 619 | } |
| 620 | |
| 621 | return stpi_dither_array_create_from_xmltreecxx . . $ stpi_dither_array_create_from_xmltree(da0ec9d220311c1d).(xmlseq, x, y); |
| 622 | } |
| 623 | |
| 624 | static stp_array_tcxx . . $ stp_array_t# * |
| 625 | stpi_dither_array_create_from_filecxx . . $ stpi_dither_array_create_from_file(9c076f4ef7cebe79).(const char* file, int x, int y) |
| 626 | { |
| 627 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *doc; |
| 628 | stp_array_tcxx . . $ stp_array_t# *ret = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 629 | |
| 630 | stp_xml_initcxx . . $ stp_xml_init(49f6e7a06ebc5aa8).(); |
| 631 | |
| 632 | stp_deprintfcxx . . $ stp_deprintf(3d303ebd7ab3b1e3).(STP_DBG_XMLcxx . . $ `include/gutenprint/util.h:182:9`!, |
| 633 | "stpi_dither_array_create_from_file: reading `%s'...\n", file); |
| 634 | |
| 635 | doc = stp_mxmlLoadFromFilecxx . . $ stp_mxmlLoadFromFile(40d1ca7ef3f17308).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, file, STP_MXML_NO_CALLBACKcxx . . $ `include/gutenprint/mxml.h:48:11`!); |
| 636 | |
| 637 | if (doc) |
| 638 | { |
| 639 | ret = xml_doc_get_dither_arraycxx . . $ xml_doc_get_dither_array(da0ec9d220311c1d).(doc, x, y); |
| 640 | stp_mxmlDeletecxx . . $ stp_mxmlDelete(6927777f14b5e2a1).(doc); |
| 641 | } |
| 642 | else |
| 643 | { |
| 644 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("stp_curve_create_from_file: unable to read from %s\n", file); |
| 645 | } |
| 646 | |
| 647 | stp_xml_exitcxx . . $ stp_xml_exit(49f6e7a06ebc5aa8).(); |
| 648 | |
| 649 | return ret; |
| 650 | } |
| 651 | |
| 652 | static stp_array_tcxx . . $ stp_array_t# * |
| 653 | stp_xml_get_dither_arraycxx . . $ stp_xml_get_dither_array(3312a96e2cd8fef).(int x, int y) |
| 654 | { |
| 655 | stp_xml_dither_cache_tcxx . . $ stp_xml_dither_cache_t# *cachedval; |
| 656 | stp_array_tcxx . . $ stp_array_t# *ret; |
| 657 | |
| 658 | cachedval = stp_xml_dither_cache_getcxx . . $ stp_xml_dither_cache_get(11a8f52590821a71).(x, y); |
| 659 | |
| 660 | if (cachedval && cachedval->dither_arraycxx . . $ $anonymous_type_d9d57ee7fc772b66_0#dither_array.) |
| 661 | return stp_array_create_copycxx . . $ stp_array_create_copy(37186108ffa989df).(cachedval->dither_arraycxx . . $ $anonymous_type_d9d57ee7fc772b66_0#dither_array.); |
| 662 | |
| 663 | if (!cachedval) |
| 664 | { |
| 665 | char buf[MAXPATHLENcxx . . $ `<external>/1231830743887005719/param.h:48:10`!+1]; |
| 666 | (void) snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, MAXPATHLENcxx . . $ `<external>/1231830743887005719/param.h:48:10`!, "dither/matrix-%dx%d.xml", x, y); |
| 667 | stp_xml_parse_file_namedcxx . . $ stp_xml_parse_file_named(85c52e162fed56f9).(buf); |
| 668 | cachedval = stp_xml_dither_cache_getcxx . . $ stp_xml_dither_cache_get(11a8f52590821a71).(x, y); |
| 669 | if (cachedval == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || cachedval->filenamecxx . . $ $anonymous_type_d9d57ee7fc772b66_0#filename. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 670 | { |
| 671 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 672 | } |
| 673 | } |
| 674 | |
| 675 | ret = stpi_dither_array_create_from_filecxx . . $ stpi_dither_array_create_from_file(9c076f4ef7cebe79).(cachedval->filenamecxx . . $ $anonymous_type_d9d57ee7fc772b66_0#filename., x, y); |
| 676 | |
| 677 | cachedval->dither_arraycxx . . $ $anonymous_type_d9d57ee7fc772b66_0#dither_array. = ret; |
| 678 | return stp_array_create_copycxx . . $ stp_array_create_copy(37186108ffa989df).(ret); |
| 679 | } |
| 680 | |
| 681 | void |
| 682 | stpi_init_dithercxx . . $ stpi_init_dither(49f6e7a06ebc5aa8).(void) |
| 683 | { |
| 684 | stp_register_xml_parsercxx . . $ stp_register_xml_parser(91857625fba69e1d).("dither-matrix", stp_xml_process_dither_matrixcxx . . $ stp_xml_process_dither_matrix(add120f6a4c14e60).); |
| 685 | } |
| 686 | |
| 687 | stp_array_tcxx . . $ stp_array_t# * |
| 688 | stp_find_standard_dither_arraycxx . . $ stp_find_standard_dither_array(3312a96e2cd8fef).(int x_aspect, int y_aspect) |
| 689 | { |
| 690 | stp_array_tcxx . . $ stp_array_t# *answer; |
| 691 | int divisor = gcdcxx . . $ gcd(83f10ac8959d5577).(x_aspect, y_aspect); |
| 692 | |
| 693 | x_aspect /= divisor; |
| 694 | y_aspect /= divisor; |
| 695 | |
| 696 | if (x_aspect == 3) /* We don't have x3 matrices */ |
| 697 | x_aspect += 1; /* so cheat */ |
| 698 | if (y_aspect == 3) |
| 699 | y_aspect += 1; |
| 700 | |
| 701 | divisor = gcdcxx . . $ gcd(83f10ac8959d5577).(x_aspect, y_aspect); |
| 702 | x_aspect /= divisor; |
| 703 | y_aspect /= divisor; |
| 704 | |
| 705 | answer = stp_xml_get_dither_arraycxx . . $ stp_xml_get_dither_array(3312a96e2cd8fef).(x_aspect, y_aspect); |
| 706 | if (answer) |
| 707 | return answer; |
| 708 | answer = stp_xml_get_dither_arraycxx . . $ stp_xml_get_dither_array(3312a96e2cd8fef).(y_aspect, x_aspect); |
| 709 | if (answer) |
| 710 | return answer; |
| 711 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 712 | } |