| 1 | /* |
| 2 | * |
| 3 | * Softweave calculator for Gutenprint. |
| 4 | * |
| 5 | * Copyright 2000 Charles Briscoe-Smith <[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 | |
| 21 | /* |
| 22 | * This file must include only standard C header files. The core code must |
| 23 | * compile on generic platforms that don't support glib, gimp, gtk, etc. |
| 24 | */ |
| 25 | |
| 26 | #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`! |
| 27 | #include <config.h>cxx . . $ `<file>/config.h`/ |
| 28 | #endif |
| 29 | #include <string.h> |
| 30 | #include <gutenprint/gutenprint.h>cxx . . $ `<file>/include/gutenprint/gutenprint.h`/ |
| 31 | #include "gutenprint-internal.h"cxx . . $ `<file>/src/main/gutenprint-internal.h`/ |
| 32 | #include <gutenprint/gutenprint-intl-internal.h>cxx . . $ `<file>/include/gutenprint/gutenprint-intl-internal.h`/ |
| 33 | #ifdef HAVE_LIMITS_Hcxx . . $ `../../config.h:94:9`! |
| 34 | #include <limits.h> |
| 35 | #endif |
| 36 | |
| 37 | static int |
| 38 | gcdcxx . . $ gcd(9b79fb6aee4c0440).(int x, int y) |
| 39 | { |
| 40 | if (y == 0) |
| 41 | return x; |
| 42 | while (x != 0) { |
| 43 | if (y > x) { |
| 44 | int t = x; |
| 45 | x = y; |
| 46 | y = t; |
| 47 | } |
| 48 | x %= y; |
| 49 | } |
| 50 | return y; |
| 51 | } |
| 52 | |
| 53 | typedef struct stpi_softweavecxx . . $ stpi_softweave# |
| 54 | { |
| 55 | stp_linebufs_tcxx . . $ stp_linebufs_t# *linebasescxx . . $ stpi_softweave#linebases.; /* Base address of each row buffer */ |
| 56 | stp_lineoff_tcxx . . $ stp_lineoff_t# *lineoffsetscxx . . $ stpi_softweave#lineoffsets.; /* Offsets within each row buffer */ |
| 57 | stp_lineactive_tcxx . . $ stp_lineactive_t# *lineactivecxx . . $ stpi_softweave#lineactive.; /* Does this line have anything printed? */ |
| 58 | stp_linecount_tcxx . . $ stp_linecount_t# *linecountscxx . . $ stpi_softweave#linecounts.; /* How many rows we've printed this pass */ |
| 59 | stp_linebounds_tcxx . . $ stp_linebounds_t# *lineboundscxx . . $ stpi_softweave#linebounds.; /* Starting and ending print column */ |
| 60 | stp_pass_tcxx . . $ stp_pass_t# *passescxx . . $ stpi_softweave#passes.; /* Circular list of pass numbers */ |
| 61 | int last_pass_offsetcxx . . $ stpi_softweave#last_pass_offset.; /* Starting row (offset from the start of */ |
| 62 | /* the page) of the most recently printed */ |
| 63 | /* pass (so we can determine how far to */ |
| 64 | /* advance the paper) */ |
| 65 | int last_passcxx . . $ stpi_softweave#last_pass.; /* Number of the most recently printed pass */ |
| 66 | |
| 67 | int jetscxx . . $ stpi_softweave#jets.; /* Number of jets per color */ |
| 68 | int virtual_jetscxx . . $ stpi_softweave#virtual_jets.; /* Number of jets per color, taking into */ |
| 69 | /* account the head offset */ |
| 70 | int separationcxx . . $ stpi_softweave#separation.; /* Offset from one jet to the next in rows */ |
| 71 | void *weaveparmcxx . . $ stpi_softweave#weaveparm.; /* Weave calculation parameter block */ |
| 72 | |
| 73 | int horizontal_weavecxx . . $ stpi_softweave#horizontal_weave.; /* Number of horizontal passes required */ |
| 74 | /* This is > 1 for some of the ultra-high */ |
| 75 | /* resolution modes */ |
| 76 | int vertical_subpassescxx . . $ stpi_softweave#vertical_subpasses.; /* Number of passes per line (for better */ |
| 77 | /* quality) */ |
| 78 | int vmodcxx . . $ stpi_softweave#vmod.; /* Number of banks of passes */ |
| 79 | int oversamplecxx . . $ stpi_softweave#oversample.; /* Excess precision per row */ |
| 80 | int repeat_countcxx . . $ stpi_softweave#repeat_count.; /* How many times a pass is repeated */ |
| 81 | int ncolorscxx . . $ stpi_softweave#ncolors.; /* How many colors */ |
| 82 | int linewidthcxx . . $ stpi_softweave#linewidth.; /* Line width in input pixels */ |
| 83 | int vertical_heightcxx . . $ stpi_softweave#vertical_height.; /* Image height in output pixels */ |
| 84 | int firstlinecxx . . $ stpi_softweave#firstline.; /* Actual first line (referenced to paper) */ |
| 85 | |
| 86 | int bitwidthcxx . . $ stpi_softweave#bitwidth.; /* Bits per pixel */ |
| 87 | int linenocxx . . $ stpi_softweave#lineno.; |
| 88 | int vertical_oversamplecxx . . $ stpi_softweave#vertical_oversample.; /* Vertical oversampling */ |
| 89 | int current_vertical_subpasscxx . . $ stpi_softweave#current_vertical_subpass.; |
| 90 | int horizontal_widthcxx . . $ stpi_softweave#horizontal_width.; /* Horizontal width, in bits */ |
| 91 | int *head_offsetcxx . . $ stpi_softweave#head_offset.; /* offset of printheads */ |
| 92 | unsigned char *scxx . . $ stpi_softweave#s.[STP_MAX_WEAVEcxx . . $ `include/gutenprint/weave.h:46:9`!]; |
| 93 | unsigned char *fold_bufcxx . . $ stpi_softweave#fold_buf.; |
| 94 | unsigned char *comp_bufcxx . . $ stpi_softweave#comp_buf.; |
| 95 | stp_weave_tcxx . . $ stp_weave_t# wcachecxx . . $ stpi_softweave#wcache.; |
| 96 | int rcachecxx . . $ stpi_softweave#rcache.; |
| 97 | int vcachecxx . . $ stpi_softweave#vcache.; |
| 98 | stp_flushfunccxx . . $ stp_flushfunc# *flushfunccxx . . $ stpi_softweave#flushfunc.; |
| 99 | stp_fillfunccxx . . $ stp_fillfunc# *fillfunccxx . . $ stpi_softweave#fillfunc.; |
| 100 | stp_packfunccxx . . $ stp_packfunc# *packcxx . . $ stpi_softweave#pack.; |
| 101 | stp_compute_linewidth_funccxx . . $ stp_compute_linewidth_func# *compute_linewidthcxx . . $ stpi_softweave#compute_linewidth.; |
| 102 | } stpi_softweave_tcxx . . $ stpi_softweave_t#; |
| 103 | |
| 104 | /* RAW WEAVE */ |
| 105 | |
| 106 | typedef struct rawcxx . . $ raw# { |
| 107 | int separationcxx . . $ raw#separation.; |
| 108 | int jetscxx . . $ raw#jets.; |
| 109 | int oversamplingcxx . . $ raw#oversampling.; |
| 110 | int advancebasiscxx . . $ raw#advancebasis.; |
| 111 | int subblocksperpassblockcxx . . $ raw#subblocksperpassblock.; |
| 112 | int passespersubblockcxx . . $ raw#passespersubblock.; |
| 113 | stp_weave_strategy_tcxx . . $ stp_weave_strategy_t# strategycxx . . $ raw#strategy.; |
| 114 | stp_vars_tcxx . . $ stp_vars_t# *vcxx . . $ raw#v.; |
| 115 | } raw_tcxx . . $ raw_t#; |
| 116 | |
| 117 | /* |
| 118 | * Strategy types currently defined: |
| 119 | * |
| 120 | * 0: zig-zag type pass block filling |
| 121 | * 1: ascending pass block filling |
| 122 | * 2: descending pass block filling |
| 123 | * 3: ascending fill with 2x expansion |
| 124 | * 4: staggered zig-zag neighbour-avoidance fill |
| 125 | * 5: ascending fill with 3x expansion |
| 126 | * |
| 127 | * In theory, strategy 0 should be optimal; in practice, it can lead |
| 128 | * to visible areas of banding. If it's necessary to avoid filling |
| 129 | * neighbouring rows in neighbouring passes, strategy 4 should be optimal, |
| 130 | * at least for some weaves. |
| 131 | */ |
| 132 | |
| 133 | static void |
| 134 | initialize_raw_weavecxx . . $ initialize_raw_weave(2ef59c0a6f110945).(raw_tcxx . . $ raw_t# *w, /* I - weave struct to be filled in */ |
| 135 | int separation, /* I - jet separation */ |
| 136 | int jets, /* I - number of jets */ |
| 137 | int oversample, /* I - oversampling factor */ |
| 138 | stp_weave_strategy_tcxx . . $ stp_weave_strategy_t# strat, /* I - weave pattern variation to use */ |
| 139 | stp_vars_tcxx . . $ stp_vars_t# *v) |
| 140 | { |
| 141 | w->separationcxx . . $ raw#separation. = separation; |
| 142 | w->jetscxx . . $ raw#jets. = jets; |
| 143 | w->oversamplingcxx . . $ raw#oversampling. = oversample; |
| 144 | w->advancebasiscxx . . $ raw#advancebasis. = jets / oversample; |
| 145 | if (w->advancebasiscxx . . $ raw#advancebasis. == 0) |
| 146 | w->advancebasiscxx . . $ raw#advancebasis.++; |
| 147 | w->subblocksperpassblockcxx . . $ raw#subblocksperpassblock. = gcdcxx . . $ gcd(9b79fb6aee4c0440).(separation, w->advancebasiscxx . . $ raw#advancebasis.); |
| 148 | w->passespersubblockcxx . . $ raw#passespersubblock. = separation / w->subblocksperpassblockcxx . . $ raw#subblocksperpassblock.; |
| 149 | w->strategycxx . . $ raw#strategy. = strat; |
| 150 | w->vcxx . . $ raw#v. = v; |
| 151 | } |
| 152 | |
| 153 | static void |
| 154 | calculate_raw_pass_parameterscxx . . $ calculate_raw_pass_parameters(fcd0e22862c5ffae).(raw_tcxx . . $ raw_t# *w, /* I - weave parameters */ |
| 155 | int pass, /* I - pass number ( >= 0) */ |
| 156 | int *startrow, /* O - print head position */ |
| 157 | int *subpass) /* O - subpass number */ |
| 158 | { |
| 159 | int band, passinband, subpassblock, subpassoffset; |
| 160 | |
| 161 | band = pass / (w->separationcxx . . $ raw#separation. * w->oversamplingcxx . . $ raw#oversampling.); |
| 162 | passinband = pass % (w->separationcxx . . $ raw#separation. * w->oversamplingcxx . . $ raw#oversampling.); |
| 163 | subpassblock = pass % w->separationcxx . . $ raw#separation. |
| 164 | * w->subblocksperpassblockcxx . . $ raw#subblocksperpassblock. / w->separationcxx . . $ raw#separation.; |
| 165 | |
| 166 | switch (w->strategycxx . . $ raw#strategy.) { |
| 167 | case STP_WEAVE_ZIGZAGcxx . . $ STP_WEAVE_ZIGZAG.: |
| 168 | if (subpassblock * 2 < w->subblocksperpassblockcxx . . $ raw#subblocksperpassblock.) |
| 169 | subpassoffset = 2 * subpassblock; |
| 170 | else |
| 171 | subpassoffset = 2 * (w->subblocksperpassblockcxx . . $ raw#subblocksperpassblock. |
| 172 | - subpassblock) - 1; |
| 173 | break; |
| 174 | case STP_WEAVE_ASCENDINGcxx . . $ STP_WEAVE_ASCENDING.: |
| 175 | subpassoffset = subpassblock; |
| 176 | break; |
| 177 | case STP_WEAVE_DESCENDINGcxx . . $ STP_WEAVE_DESCENDING.: |
| 178 | subpassoffset = w->subblocksperpassblockcxx . . $ raw#subblocksperpassblock. - 1 - subpassblock; |
| 179 | break; |
| 180 | case STP_WEAVE_ASCENDING_2Xcxx . . $ STP_WEAVE_ASCENDING_2X.: |
| 181 | if (subpassblock * 2 < w->subblocksperpassblockcxx . . $ raw#subblocksperpassblock.) |
| 182 | subpassoffset = 2 * subpassblock; |
| 183 | else |
| 184 | subpassoffset = 1 + 2 * (subpassblock |
| 185 | - (w->subblocksperpassblockcxx . . $ raw#subblocksperpassblock. |
| 186 | + 1) / 2); |
| 187 | break; |
| 188 | case STP_WEAVE_ASCENDING_3Xcxx . . $ STP_WEAVE_ASCENDING_3X.: |
| 189 | if (subpassblock * 3 < w->subblocksperpassblockcxx . . $ raw#subblocksperpassblock.) |
| 190 | subpassoffset = 3 * subpassblock; |
| 191 | else if (3 * (subpassblock - (w->subblocksperpassblockcxx . . $ raw#subblocksperpassblock. + 2) / 3) |
| 192 | < w->subblocksperpassblockcxx . . $ raw#subblocksperpassblock. - 2) |
| 193 | subpassoffset = 2 + 3 * (subpassblock |
| 194 | - (w->subblocksperpassblockcxx . . $ raw#subblocksperpassblock. |
| 195 | + 2) / 3); |
| 196 | else |
| 197 | subpassoffset = 1 + 3 * (subpassblock |
| 198 | - (w->subblocksperpassblockcxx . . $ raw#subblocksperpassblock. |
| 199 | + 2) / 3 |
| 200 | - w->subblocksperpassblockcxx . . $ raw#subblocksperpassblock. |
| 201 | / 3); |
| 202 | break; |
| 203 | case STP_WEAVE_STAGGEREDcxx . . $ STP_WEAVE_STAGGERED.: |
| 204 | if (subpassblock * 2 < w->subblocksperpassblockcxx . . $ raw#subblocksperpassblock.) |
| 205 | subpassoffset = 2 * subpassblock; |
| 206 | else if (subpassblock * 2 < w->subblocksperpassblockcxx . . $ raw#subblocksperpassblock. + 2) |
| 207 | subpassoffset = 1; |
| 208 | else |
| 209 | subpassoffset = 2 * (w->subblocksperpassblockcxx . . $ raw#subblocksperpassblock. |
| 210 | - subpassblock) + 1; |
| 211 | break; |
| 212 | default: |
| 213 | subpassoffset = subpassblock; |
| 214 | break; |
| 215 | } |
| 216 | |
| 217 | *startrow = w->separationcxx . . $ raw#separation. * w->jetscxx . . $ raw#jets. * band |
| 218 | + w->advancebasiscxx . . $ raw#advancebasis. * passinband + subpassoffset; |
| 219 | *subpass = passinband / w->separationcxx . . $ raw#separation.; |
| 220 | } |
| 221 | |
| 222 | static void |
| 223 | calculate_raw_row_parameterscxx . . $ calculate_raw_row_parameters(f76d13ec94067dce).(raw_tcxx . . $ raw_t# *w, /* I - weave parameters */ |
| 224 | int row, /* I - row number */ |
| 225 | int subpass, /* I - subpass number */ |
| 226 | int *pass, /* O - pass number */ |
| 227 | int *jet, /* O - jet number in pass */ |
| 228 | int *startrow) /* O - starting row of pass */ |
| 229 | { |
| 230 | int subblockoffset, subpassblock, band, baserow, passinband, offset; |
| 231 | int pass_div_separation; |
| 232 | int pass_mod_separation; |
| 233 | int off_mod_separation; |
| 234 | |
| 235 | subblockoffset = row % w->subblocksperpassblockcxx . . $ raw#subblocksperpassblock.; |
| 236 | switch (w->strategycxx . . $ raw#strategy.) { |
| 237 | case STP_WEAVE_ZIGZAGcxx . . $ STP_WEAVE_ZIGZAG.: |
| 238 | if (subblockoffset % 2 == 0) |
| 239 | subpassblock = subblockoffset / 2; |
| 240 | else |
| 241 | subpassblock = w->subblocksperpassblockcxx . . $ raw#subblocksperpassblock. |
| 242 | - (subblockoffset + 1) / 2; |
| 243 | break; |
| 244 | case STP_WEAVE_ASCENDINGcxx . . $ STP_WEAVE_ASCENDING.: |
| 245 | subpassblock = subblockoffset; |
| 246 | break; |
| 247 | case STP_WEAVE_DESCENDINGcxx . . $ STP_WEAVE_DESCENDING.: |
| 248 | subpassblock = w->subblocksperpassblockcxx . . $ raw#subblocksperpassblock. - 1 - subblockoffset; |
| 249 | break; |
| 250 | case STP_WEAVE_ASCENDING_2Xcxx . . $ STP_WEAVE_ASCENDING_2X.: |
| 251 | if (subblockoffset % 2 == 0) |
| 252 | subpassblock = subblockoffset / 2; |
| 253 | else |
| 254 | subpassblock = (subblockoffset - 1) / 2 |
| 255 | + (w->subblocksperpassblockcxx . . $ raw#subblocksperpassblock. + 1) / 2; |
| 256 | break; |
| 257 | case STP_WEAVE_ASCENDING_3Xcxx . . $ STP_WEAVE_ASCENDING_3X.: |
| 258 | if (subblockoffset % 3 == 0) |
| 259 | subpassblock = subblockoffset / 3; |
| 260 | else if (subblockoffset % 3 == 1) |
| 261 | subpassblock = (subblockoffset - 1) / 3 |
| 262 | + (w->subblocksperpassblockcxx . . $ raw#subblocksperpassblock. + 2) / 3; |
| 263 | else |
| 264 | subpassblock = (subblockoffset - 2) / 3 |
| 265 | + (w->subblocksperpassblockcxx . . $ raw#subblocksperpassblock. + 2) / 3 |
| 266 | + (w->subblocksperpassblockcxx . . $ raw#subblocksperpassblock. + 1) / 3; |
| 267 | break; |
| 268 | case STP_WEAVE_STAGGEREDcxx . . $ STP_WEAVE_STAGGERED.: |
| 269 | if (subblockoffset % 2 == 0) |
| 270 | subpassblock = subblockoffset / 2; |
| 271 | else if (subblockoffset == 1) |
| 272 | subpassblock = (w->subblocksperpassblockcxx . . $ raw#subblocksperpassblock. + 1) / 2; |
| 273 | else |
| 274 | subpassblock = w->subblocksperpassblockcxx . . $ raw#subblocksperpassblock. |
| 275 | - (subblockoffset - 1) / 2; |
| 276 | break; |
| 277 | default: |
| 278 | subpassblock = subblockoffset; |
| 279 | break; |
| 280 | } |
| 281 | |
| 282 | band = row / (w->separationcxx . . $ raw#separation. * w->jetscxx . . $ raw#jets.); |
| 283 | baserow = row - subblockoffset - band * w->separationcxx . . $ raw#separation. * w->jetscxx . . $ raw#jets.; |
| 284 | passinband = baserow / w->advancebasiscxx . . $ raw#advancebasis.; |
| 285 | offset = baserow % w->advancebasiscxx . . $ raw#advancebasis.; |
| 286 | pass_div_separation = passinband / w->separationcxx . . $ raw#separation.; |
| 287 | pass_mod_separation = passinband % w->separationcxx . . $ raw#separation.; |
| 288 | off_mod_separation = offset % w->separationcxx . . $ raw#separation.; |
| 289 | |
| 290 | while (off_mod_separation != 0 |
| 291 | || pass_div_separation != subpass |
| 292 | || pass_mod_separation / w->passespersubblockcxx . . $ raw#passespersubblock. |
| 293 | != subpassblock) |
| 294 | { |
| 295 | offset += w->advancebasiscxx . . $ raw#advancebasis.; |
| 296 | passinband--; |
| 297 | if (passinband >= 0) |
| 298 | { |
| 299 | pass_mod_separation--; |
| 300 | if (pass_mod_separation < 0) |
| 301 | { |
| 302 | pass_mod_separation += w->separationcxx . . $ raw#separation.; |
| 303 | pass_div_separation--; |
| 304 | } |
| 305 | if (w->advancebasiscxx . . $ raw#advancebasis. < w->separationcxx . . $ raw#separation.) |
| 306 | { |
| 307 | off_mod_separation += w->advancebasiscxx . . $ raw#advancebasis.; |
| 308 | if (off_mod_separation >= w->separationcxx . . $ raw#separation.) |
| 309 | off_mod_separation -= w->separationcxx . . $ raw#separation.; |
| 310 | } |
| 311 | else if (w->advancebasiscxx . . $ raw#advancebasis. > w->separationcxx . . $ raw#separation.) |
| 312 | off_mod_separation = offset % w->separationcxx . . $ raw#separation.; |
| 313 | } |
| 314 | else |
| 315 | { |
| 316 | const int roundedjets = |
| 317 | (w->advancebasiscxx . . $ raw#advancebasis. * w->oversamplingcxx . . $ raw#oversampling.) % w->jetscxx . . $ raw#jets.; |
| 318 | band--; |
| 319 | passinband += w->separationcxx . . $ raw#separation. * w->oversamplingcxx . . $ raw#oversampling.; |
| 320 | offset += w->separationcxx . . $ raw#separation. * (w->jetscxx . . $ raw#jets. - roundedjets); |
| 321 | pass_div_separation = passinband / w->separationcxx . . $ raw#separation.; |
| 322 | pass_mod_separation = passinband % w->separationcxx . . $ raw#separation.; |
| 323 | off_mod_separation = offset % w->separationcxx . . $ raw#separation.; |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | *pass = band * w->oversamplingcxx . . $ raw#oversampling. * w->separationcxx . . $ raw#separation. + passinband; |
| 328 | *jet = (offset / w->separationcxx . . $ raw#separation.) % w->jetscxx . . $ raw#jets.; |
| 329 | *startrow = row - (*jet * w->separationcxx . . $ raw#separation.); |
| 330 | } |
| 331 | |
| 332 | /* COOKED WEAVE */ |
| 333 | |
| 334 | typedef struct cookedcxx . . $ cooked# { |
| 335 | raw_tcxx . . $ raw_t# rwcxx . . $ cooked#rw.; |
| 336 | int first_row_printedcxx . . $ cooked#first_row_printed.; |
| 337 | int last_row_printedcxx . . $ cooked#last_row_printed.; |
| 338 | |
| 339 | int first_premapped_passcxx . . $ cooked#first_premapped_pass.; /* First raw pass used by this page */ |
| 340 | int first_normal_passcxx . . $ cooked#first_normal_pass.; |
| 341 | int first_postmapped_passcxx . . $ cooked#first_postmapped_pass.; |
| 342 | int first_unused_passcxx . . $ cooked#first_unused_pass.; |
| 343 | |
| 344 | int *pass_premapcxx . . $ cooked#pass_premap.; |
| 345 | int *stagger_premapcxx . . $ cooked#stagger_premap.; |
| 346 | int *pass_postmapcxx . . $ cooked#pass_postmap.; |
| 347 | int *stagger_postmapcxx . . $ cooked#stagger_postmap.; |
| 348 | } cooked_tcxx . . $ cooked_t#; |
| 349 | |
| 350 | typedef struct startmapcxx . . $ startmap# { |
| 351 | int startrowcxx . . $ startmap#startrow.; |
| 352 | int mapcxx . . $ startmap#map.; |
| 353 | int poscxx . . $ startmap#pos.; /* Secondary key for stable sort */ |
| 354 | } startmap_tcxx . . $ startmap_t#; |
| 355 | |
| 356 | static int |
| 357 | smap_comparecxx . . $ smap_compare(9148c8c3ff42c9d8).(const void *p1, const void *p2) |
| 358 | { |
| 359 | const startmap_tcxx . . $ startmap_t# *s1 = (const startmap_tcxx . . $ startmap_t# *)p1; |
| 360 | const startmap_tcxx . . $ startmap_t# *s2 = (const startmap_tcxx . . $ startmap_t# *)p2; |
| 361 | if (s1->startrowcxx . . $ startmap#startrow. < s2->startrowcxx . . $ startmap#startrow.) |
| 362 | return -1; |
| 363 | else if (s1->startrowcxx . . $ startmap#startrow. > s2->startrowcxx . . $ startmap#startrow.) |
| 364 | return 1; |
| 365 | else if (s1->poscxx . . $ startmap#pos. < s2->poscxx . . $ startmap#pos.) |
| 366 | return -1; |
| 367 | else |
| 368 | return 1; |
| 369 | } |
| 370 | |
| 371 | static void |
| 372 | sort_by_start_rowcxx . . $ sort_by_start_row(be3b0d48baed922d).(int *map, int *startrows, int count) |
| 373 | { |
| 374 | startmap_tcxx . . $ startmap_t# *smap = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(sizeof(startmap_tcxx . . $ startmap_t#) * count); |
| 375 | int i; |
| 376 | for (i = 0; i < count; i++) |
| 377 | { |
| 378 | smap[i].startrowcxx . . $ startmap#startrow. = startrows[i]; |
| 379 | smap[i].mapcxx . . $ startmap#map. = map[i]; |
| 380 | smap[i].poscxx . . $ startmap#pos. = i; |
| 381 | } |
| 382 | qsortcxx . . $ qsort(ebb60b13a65e77d7).(smap, count, sizeof(startmap_tcxx . . $ startmap_t#), smap_comparecxx . . $ smap_compare(9148c8c3ff42c9d8).); |
| 383 | for (i = 0; i < count; i++) |
| 384 | { |
| 385 | startrows[i] = smap[i].startrowcxx . . $ startmap#startrow.; |
| 386 | map[i] = smap[i].mapcxx . . $ startmap#map.; |
| 387 | } |
| 388 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(smap); |
| 389 | } |
| 390 | |
| 391 | static void |
| 392 | calculate_staggercxx . . $ calculate_stagger(139d589895306880).(raw_tcxx . . $ raw_t# *w, int *map, int *startrows_stagger, int count) |
| 393 | { |
| 394 | int i; |
| 395 | |
| 396 | for (i = 0; i < count; i++) { |
| 397 | int startrow, subpass; |
| 398 | calculate_raw_pass_parameterscxx . . $ calculate_raw_pass_parameters(fcd0e22862c5ffae).(w, map[i], &startrow, &subpass); |
| 399 | startrow -= w->separationcxx . . $ raw#separation. * w->jetscxx . . $ raw#jets.; |
| 400 | startrows_stagger[i] = (startrows_stagger[i] - startrow) |
| 401 | / w->separationcxx . . $ raw#separation.; |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | static void |
| 406 | invert_mapcxx . . $ invert_map(6863c225efd7735c).(int *map, int *stagger, int count, int oldfirstpass, |
| 407 | int newfirstpass) |
| 408 | { |
| 409 | int i; |
| 410 | int *newmap, *newstagger; |
| 411 | newmap = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(count * sizeof(int)); |
| 412 | newstagger = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(count * sizeof(int)); |
| 413 | |
| 414 | for (i = 0; i < count; i++) { |
| 415 | newmap[map[i] - oldfirstpass] = i + newfirstpass; |
| 416 | newstagger[map[i] - oldfirstpass] = stagger[i]; |
| 417 | } |
| 418 | |
| 419 | memcpycxx . . $ memcpy(cc817cb175f282d).(map, newmap, count * sizeof(int)); |
| 420 | memcpycxx . . $ memcpy(cc817cb175f282d).(stagger, newstagger, count * sizeof(int)); |
| 421 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(newstagger); |
| 422 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(newmap); |
| 423 | } |
| 424 | |
| 425 | static void |
| 426 | make_passmapcxx . . $ make_passmap(d49ec1cf36f50a7d).(raw_tcxx . . $ raw_t# *w, int **map, int **starts, int first_pass_number, |
| 427 | int first_pass_to_map, int first_pass_after_map, |
| 428 | int first_pass_to_stagger, int first_pass_after_stagger, |
| 429 | int first_row_of_maximal_pass, int separations_to_distribute) |
| 430 | { |
| 431 | int *passmap, *startrows; |
| 432 | int passes_to_map = first_pass_after_map - first_pass_to_map; |
| 433 | int i; |
| 434 | |
| 435 | STPI_ASSERTcxx . . $ `src/main/gutenprint-internal.h:58:9`!(first_pass_to_map <= first_pass_after_map, w->v); |
| 436 | STPI_ASSERTcxx . . $ `src/main/gutenprint-internal.h:58:9`!(first_pass_to_stagger <= first_pass_after_stagger, w->v); |
| 437 | |
| 438 | *map = passmap = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(passes_to_map * sizeof(int)); |
| 439 | *starts = startrows = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(passes_to_map * sizeof(int)); |
| 440 | |
| 441 | for (i = 0; i < passes_to_map; i++) { |
| 442 | int startrow, subpass; |
| 443 | int pass = i + first_pass_to_map; |
| 444 | calculate_raw_pass_parameterscxx . . $ calculate_raw_pass_parameters(fcd0e22862c5ffae).(w, pass, &startrow, &subpass); |
| 445 | passmap[i] = pass; |
| 446 | if (first_row_of_maximal_pass >= 0) |
| 447 | startrow = first_row_of_maximal_pass - startrow |
| 448 | + w->separationcxx . . $ raw#separation. * w->jetscxx . . $ raw#jets.; |
| 449 | else |
| 450 | startrow -= w->separationcxx . . $ raw#separation. * w->jetscxx . . $ raw#jets.; |
| 451 | while (startrow < 0) |
| 452 | startrow += w->separationcxx . . $ raw#separation.; |
| 453 | startrows[i] = startrow; |
| 454 | } |
| 455 | |
| 456 | sort_by_start_rowcxx . . $ sort_by_start_row(be3b0d48baed922d).(passmap, startrows, passes_to_map); |
| 457 | |
| 458 | separations_to_distribute++; |
| 459 | |
| 460 | for (i = 0; i < first_pass_after_stagger - first_pass_to_stagger; i++) { |
| 461 | int offset = first_pass_to_stagger - first_pass_to_map; |
| 462 | if (startrows[i + offset] / w->separationcxx . . $ raw#separation. |
| 463 | < i % separations_to_distribute) |
| 464 | { |
| 465 | startrows[i + offset] |
| 466 | = startrows[i + offset] % w->separationcxx . . $ raw#separation. |
| 467 | + w->separationcxx . . $ raw#separation. * (i % separations_to_distribute); |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | if (first_row_of_maximal_pass >= 0) { |
| 472 | for (i = 0; i < passes_to_map; i++) { |
| 473 | startrows[i] = first_row_of_maximal_pass - startrows[i]; |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | sort_by_start_rowcxx . . $ sort_by_start_row(be3b0d48baed922d).(passmap, startrows, passes_to_map); |
| 478 | calculate_staggercxx . . $ calculate_stagger(139d589895306880).(w, passmap, startrows, passes_to_map); |
| 479 | |
| 480 | invert_mapcxx . . $ invert_map(6863c225efd7735c).(passmap, startrows, passes_to_map, first_pass_to_map, |
| 481 | first_pass_to_map - first_pass_number); |
| 482 | } |
| 483 | |
| 484 | static void |
| 485 | calculate_pass_mapcxx . . $ calculate_pass_map(d4ef3cfd66df5034).(stp_vars_tcxx . . $ stp_vars_t# *v, |
| 486 | cooked_tcxx . . $ cooked_t# *w, /* I - weave parameters */ |
| 487 | int pageheight, /* I - number of rows on page */ |
| 488 | int firstrow, /* I - first printed row */ |
| 489 | int lastrow) /* I - last printed row */ |
| 490 | { |
| 491 | int startrow, subpass; |
| 492 | int pass = -1; |
| 493 | |
| 494 | w->first_row_printedcxx . . $ cooked#first_row_printed. = firstrow; |
| 495 | w->last_row_printedcxx . . $ cooked#last_row_printed. = lastrow; |
| 496 | |
| 497 | if (pageheight <= lastrow) |
| 498 | pageheight = lastrow + 1; |
| 499 | |
| 500 | do { |
| 501 | calculate_raw_pass_parameterscxx . . $ calculate_raw_pass_parameters(fcd0e22862c5ffae).(&w->rwcxx . . $ cooked#rw., ++pass, |
| 502 | &startrow, &subpass); |
| 503 | } while (startrow - w->rwcxx . . $ cooked#rw..separationcxx . . $ raw#separation. < firstrow); |
| 504 | |
| 505 | w->first_premapped_passcxx . . $ cooked#first_premapped_pass. = pass; |
| 506 | |
| 507 | while (startrow < w->rwcxx . . $ cooked#rw..separationcxx . . $ raw#separation. * w->rwcxx . . $ cooked#rw..jetscxx . . $ raw#jets. |
| 508 | && startrow - w->rwcxx . . $ cooked#rw..separationcxx . . $ raw#separation. < pageheight |
| 509 | && startrow <= lastrow + w->rwcxx . . $ cooked#rw..separationcxx . . $ raw#separation. * w->rwcxx . . $ cooked#rw..jetscxx . . $ raw#jets.) |
| 510 | { |
| 511 | calculate_raw_pass_parameterscxx . . $ calculate_raw_pass_parameters(fcd0e22862c5ffae).(&w->rwcxx . . $ cooked#rw., ++pass, |
| 512 | &startrow, &subpass); |
| 513 | } |
| 514 | w->first_normal_passcxx . . $ cooked#first_normal_pass. = pass; |
| 515 | |
| 516 | while (startrow - w->rwcxx . . $ cooked#rw..separationcxx . . $ raw#separation. < pageheight |
| 517 | && startrow <= lastrow + w->rwcxx . . $ cooked#rw..separationcxx . . $ raw#separation. * w->rwcxx . . $ cooked#rw..jetscxx . . $ raw#jets.) |
| 518 | { |
| 519 | calculate_raw_pass_parameterscxx . . $ calculate_raw_pass_parameters(fcd0e22862c5ffae).(&w->rwcxx . . $ cooked#rw., ++pass, |
| 520 | &startrow, &subpass); |
| 521 | } |
| 522 | w->first_postmapped_passcxx . . $ cooked#first_postmapped_pass. = pass; |
| 523 | |
| 524 | while (startrow <= lastrow + w->rwcxx . . $ cooked#rw..separationcxx . . $ raw#separation. * w->rwcxx . . $ cooked#rw..jetscxx . . $ raw#jets.) { |
| 525 | calculate_raw_pass_parameterscxx . . $ calculate_raw_pass_parameters(fcd0e22862c5ffae).(&w->rwcxx . . $ cooked#rw., ++pass, |
| 526 | &startrow, &subpass); |
| 527 | } |
| 528 | w->first_unused_passcxx . . $ cooked#first_unused_pass. = pass; |
| 529 | |
| 530 | stp_dprintfcxx . . $ stp_dprintf(13526ca24396f6ac).(STP_DBG_WEAVE_PARAMScxx . . $ `include/gutenprint/util.h:174:9`!, v, |
| 531 | "first premapped %d first normal %d first postmapped %d " |
| 532 | "first unused %d\n", |
| 533 | w->first_premapped_passcxx . . $ cooked#first_premapped_pass., w->first_normal_passcxx . . $ cooked#first_normal_pass., |
| 534 | w->first_postmapped_passcxx . . $ cooked#first_postmapped_pass., w->first_unused_passcxx . . $ cooked#first_unused_pass.); |
| 535 | /* |
| 536 | * FIXME: make sure first_normal_pass doesn't advance beyond |
| 537 | * first_postmapped_pass, or first_postmapped_pass doesn't |
| 538 | * retreat before first_normal_pass. |
| 539 | */ |
| 540 | |
| 541 | if (w->first_normal_passcxx . . $ cooked#first_normal_pass. > w->first_premapped_passcxx . . $ cooked#first_premapped_pass.) { |
| 542 | int spread, separations_to_distribute, normal_passes_mapped; |
| 543 | separations_to_distribute = firstrow / w->rwcxx . . $ cooked#rw..separationcxx . . $ raw#separation.; |
| 544 | spread = (separations_to_distribute + 1) * w->rwcxx . . $ cooked#rw..separationcxx . . $ raw#separation.; |
| 545 | normal_passes_mapped = (spread + w->rwcxx . . $ cooked#rw..advancebasiscxx . . $ raw#advancebasis. - 1) |
| 546 | / w->rwcxx . . $ cooked#rw..advancebasiscxx . . $ raw#advancebasis.; |
| 547 | w->first_normal_passcxx . . $ cooked#first_normal_pass. += normal_passes_mapped; |
| 548 | make_passmapcxx . . $ make_passmap(d49ec1cf36f50a7d).(&w->rwcxx . . $ cooked#rw., &w->pass_premapcxx . . $ cooked#pass_premap., &w->stagger_premapcxx . . $ cooked#stagger_premap., |
| 549 | w->first_premapped_passcxx . . $ cooked#first_premapped_pass., |
| 550 | w->first_premapped_passcxx . . $ cooked#first_premapped_pass., w->first_normal_passcxx . . $ cooked#first_normal_pass., |
| 551 | w->first_premapped_passcxx . . $ cooked#first_premapped_pass., |
| 552 | w->first_normal_passcxx . . $ cooked#first_normal_pass. - normal_passes_mapped, |
| 553 | -1, separations_to_distribute); |
| 554 | } else { |
| 555 | w->pass_premapcxx . . $ cooked#pass_premap. = 0; |
| 556 | w->stagger_premapcxx . . $ cooked#stagger_premap. = 0; |
| 557 | } |
| 558 | |
| 559 | if (w->first_unused_passcxx . . $ cooked#first_unused_pass. >= w->first_postmapped_passcxx . . $ cooked#first_postmapped_pass.) { |
| 560 | int spread, separations_to_distribute, normal_passes_mapped; |
| 561 | separations_to_distribute = (pageheight - lastrow - 1) |
| 562 | / w->rwcxx . . $ cooked#rw..separationcxx . . $ raw#separation.; |
| 563 | spread = (separations_to_distribute + 1) * w->rwcxx . . $ cooked#rw..separationcxx . . $ raw#separation.; |
| 564 | normal_passes_mapped = (spread + w->rwcxx . . $ cooked#rw..advancebasiscxx . . $ raw#advancebasis.) |
| 565 | / w->rwcxx . . $ cooked#rw..advancebasiscxx . . $ raw#advancebasis.; |
| 566 | w->first_postmapped_passcxx . . $ cooked#first_postmapped_pass. -= normal_passes_mapped; |
| 567 | make_passmapcxx . . $ make_passmap(d49ec1cf36f50a7d).(&w->rwcxx . . $ cooked#rw., &w->pass_postmapcxx . . $ cooked#pass_postmap., &w->stagger_postmapcxx . . $ cooked#stagger_postmap., |
| 568 | w->first_premapped_passcxx . . $ cooked#first_premapped_pass., |
| 569 | w->first_postmapped_passcxx . . $ cooked#first_postmapped_pass., w->first_unused_passcxx . . $ cooked#first_unused_pass., |
| 570 | w->first_postmapped_passcxx . . $ cooked#first_postmapped_pass. + normal_passes_mapped, |
| 571 | w->first_unused_passcxx . . $ cooked#first_unused_pass., |
| 572 | pageheight - 1 |
| 573 | - w->rwcxx . . $ cooked#rw..separationcxx . . $ raw#separation. * (w->rwcxx . . $ cooked#rw..jetscxx . . $ raw#jets. - 1), |
| 574 | separations_to_distribute); |
| 575 | } else { |
| 576 | w->pass_postmapcxx . . $ cooked#pass_postmap. = 0; |
| 577 | w->stagger_postmapcxx . . $ cooked#stagger_postmap. = 0; |
| 578 | } |
| 579 | } |
| 580 | |
| 581 | static void * /* O - weave parameter block */ |
| 582 | initialize_weave_paramscxx . . $ initialize_weave_params(ecf22cda90d5d2ef).(int separation, /* I - jet separation */ |
| 583 | int jets, /* I - number of jets */ |
| 584 | int oversample, /* I - oversampling factor */ |
| 585 | int firstrow, /* I - first row number to print */ |
| 586 | int lastrow, /* I - last row number to print */ |
| 587 | int pageheight, /* I - number of rows on the whole |
| 588 | page, without using any |
| 589 | expanded margin facilities */ |
| 590 | stp_weave_strategy_tcxx . . $ stp_weave_strategy_t# strategy, /* I - weave pattern variant to use */ |
| 591 | stp_vars_tcxx . . $ stp_vars_t# *v) |
| 592 | { |
| 593 | cooked_tcxx . . $ cooked_t# *w = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(sizeof(cooked_tcxx . . $ cooked_t#)); |
| 594 | if (w) { |
| 595 | initialize_raw_weavecxx . . $ initialize_raw_weave(2ef59c0a6f110945).(&w->rwcxx . . $ cooked#rw., separation, jets, oversample, strategy, v); |
| 596 | calculate_pass_mapcxx . . $ calculate_pass_map(d4ef3cfd66df5034).(v, w, pageheight, firstrow, lastrow); |
| 597 | } |
| 598 | return w; |
| 599 | } |
| 600 | |
| 601 | static void |
| 602 | stpi_destroy_weave_paramscxx . . $ stpi_destroy_weave_params(5d22bdacc48458e8).(void *vw) |
| 603 | { |
| 604 | cooked_tcxx . . $ cooked_t# *w = (cooked_tcxx . . $ cooked_t# *) vw; |
| 605 | |
| 606 | if (w->pass_premapcxx . . $ cooked#pass_premap.) stp_freecxx . . $ stp_free(5d22bdacc48458e8).(w->pass_premapcxx . . $ cooked#pass_premap.); |
| 607 | if (w->stagger_premapcxx . . $ cooked#stagger_premap.) stp_freecxx . . $ stp_free(5d22bdacc48458e8).(w->stagger_premapcxx . . $ cooked#stagger_premap.); |
| 608 | if (w->pass_postmapcxx . . $ cooked#pass_postmap.) stp_freecxx . . $ stp_free(5d22bdacc48458e8).(w->pass_postmapcxx . . $ cooked#pass_postmap.); |
| 609 | if (w->stagger_postmapcxx . . $ cooked#stagger_postmap.) stp_freecxx . . $ stp_free(5d22bdacc48458e8).(w->stagger_postmapcxx . . $ cooked#stagger_postmap.); |
| 610 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(w); |
| 611 | } |
| 612 | |
| 613 | static void |
| 614 | stpi_calculate_row_parameterscxx . . $ stpi_calculate_row_parameters(ca1493586ba34b5b).(void *vw, /* I - weave parameters */ |
| 615 | int row, /* I - row number */ |
| 616 | int subpass, /* I - subpass */ |
| 617 | int *pass, /* O - pass containing row */ |
| 618 | int *jetnum, /* O - jet number of row */ |
| 619 | int *startingrow, /* O - phys start of pass */ |
| 620 | int *ophantomrows, /* O - missing rows @ start */ |
| 621 | int *ojetsused) /* O - jets used by pass */ |
| 622 | { |
| 623 | cooked_tcxx . . $ cooked_t# *w = (cooked_tcxx . . $ cooked_t# *) vw; |
| 624 | int raw_pass, jet, startrow, phantomrows, jetsused; |
| 625 | int stagger = 0; |
| 626 | int extra; |
| 627 | |
| 628 | STPI_ASSERTcxx . . $ `src/main/gutenprint-internal.h:58:9`!(row >= w->first_row_printed, w->rw.v); |
| 629 | STPI_ASSERTcxx . . $ `src/main/gutenprint-internal.h:58:9`!(row <= w->last_row_printed, w->rw.v); |
| 630 | calculate_raw_row_parameterscxx . . $ calculate_raw_row_parameters(f76d13ec94067dce).(&w->rwcxx . . $ cooked#rw., |
| 631 | row + w->rwcxx . . $ cooked#rw..separationcxx . . $ raw#separation. * w->rwcxx . . $ cooked#rw..jetscxx . . $ raw#jets., |
| 632 | subpass, &raw_pass, &jet, &startrow); |
| 633 | startrow -= w->rwcxx . . $ cooked#rw..separationcxx . . $ raw#separation. * w->rwcxx . . $ cooked#rw..jetscxx . . $ raw#jets.; |
| 634 | jetsused = w->rwcxx . . $ cooked#rw..jetscxx . . $ raw#jets.; |
| 635 | phantomrows = 0; |
| 636 | |
| 637 | if (raw_pass < w->first_normal_passcxx . . $ cooked#first_normal_pass.) { |
| 638 | STPI_ASSERTcxx . . $ `src/main/gutenprint-internal.h:58:9`!(raw_pass >= w->first_premapped_pass, w->rw.v); |
| 639 | *pass = w->pass_premapcxx . . $ cooked#pass_premap.[raw_pass - w->first_premapped_passcxx . . $ cooked#first_premapped_pass.]; |
| 640 | stagger = w->stagger_premapcxx . . $ cooked#stagger_premap.[raw_pass - w->first_premapped_passcxx . . $ cooked#first_premapped_pass.]; |
| 641 | } else if (raw_pass >= w->first_postmapped_passcxx . . $ cooked#first_postmapped_pass.) { |
| 642 | STPI_ASSERTcxx . . $ `src/main/gutenprint-internal.h:58:9`!(raw_pass >= w->first_postmapped_pass, w->rw.v); |
| 643 | *pass = w->pass_postmapcxx . . $ cooked#pass_postmap.[raw_pass - w->first_postmapped_passcxx . . $ cooked#first_postmapped_pass.]; |
| 644 | stagger = w->stagger_postmapcxx . . $ cooked#stagger_postmap.[raw_pass |
| 645 | - w->first_postmapped_passcxx . . $ cooked#first_postmapped_pass.]; |
| 646 | } else { |
| 647 | *pass = raw_pass - w->first_premapped_passcxx . . $ cooked#first_premapped_pass.; |
| 648 | } |
| 649 | |
| 650 | startrow += stagger * w->rwcxx . . $ cooked#rw..separationcxx . . $ raw#separation.; |
| 651 | *jetnum = jet - stagger; |
| 652 | if (stagger < 0) { |
| 653 | stagger = -stagger; |
| 654 | phantomrows += stagger; |
| 655 | } |
| 656 | jetsused -= stagger; |
| 657 | |
| 658 | extra = w->first_row_printedcxx . . $ cooked#first_row_printed. |
| 659 | - (startrow + w->rwcxx . . $ cooked#rw..separationcxx . . $ raw#separation. * phantomrows); |
| 660 | if (extra > 0) { |
| 661 | extra = (extra + w->rwcxx . . $ cooked#rw..separationcxx . . $ raw#separation. - 1) / w->rwcxx . . $ cooked#rw..separationcxx . . $ raw#separation.; |
| 662 | jetsused -= extra; |
| 663 | phantomrows += extra; |
| 664 | } |
| 665 | |
| 666 | extra = startrow + w->rwcxx . . $ cooked#rw..separationcxx . . $ raw#separation. * (phantomrows + jetsused - 1) |
| 667 | - w->last_row_printedcxx . . $ cooked#last_row_printed.; |
| 668 | if (extra > 0) { |
| 669 | extra = (extra + w->rwcxx . . $ cooked#rw..separationcxx . . $ raw#separation. - 1) / w->rwcxx . . $ cooked#rw..separationcxx . . $ raw#separation.; |
| 670 | jetsused -= extra; |
| 671 | } |
| 672 | |
| 673 | *startingrow = startrow; |
| 674 | *ophantomrows = phantomrows; |
| 675 | *ojetsused = jetsused; |
| 676 | } |
| 677 | |
| 678 | /* |
| 679 | * "Soft" weave |
| 680 | * |
| 681 | * The Epson Stylus Color/Photo printers don't have memory to print |
| 682 | * using all of the nozzles in the print head. For example, the Stylus Photo |
| 683 | * 700/EX has 32 nozzles. At 720 dpi, with an 8" wide image, a single line |
| 684 | * requires (8 * 720 * 6 / 8) bytes, or 4320 bytes (because the Stylus Photo |
| 685 | * printers have 6 ink colors). To use 32 nozzles would require 138240 bytes. |
| 686 | * It's actually worse than that, though, because the nozzles are spaced 8 |
| 687 | * rows apart. Therefore, in order to store enough data to permit sending the |
| 688 | * page as a simple raster, the printer would require enough memory to store |
| 689 | * 256 rows, or 1105920 bytes. Considering that the Photo EX can print |
| 690 | * 11" wide, we're looking at more like 1.5 MB. In fact, these printers are |
| 691 | * capable of 1440 dpi horizontal resolution. This would require 3 MB. The |
| 692 | * printers actually have 64K-256K. |
| 693 | * |
| 694 | * With the newer (740/750 and later) printers it's even worse, since these |
| 695 | * printers support multiple dot sizes. But that's neither here nor there. |
| 696 | * |
| 697 | * Older Epson printers had a mode called MicroWeave (tm). In this mode, the |
| 698 | * host fed the printer individual rows of dots, and the printer bundled them |
| 699 | * up and sent them to the print head in the correct order to achieve high |
| 700 | * quality. This MicroWeave mode still works in new printers, but the |
| 701 | * implementation is very minimal: the printer uses exactly one nozzle of |
| 702 | * each color (the first one). This makes printing extremely slow (more than |
| 703 | * 30 minutes for one 8.5x11" page), although the quality is extremely high |
| 704 | * with no visible banding whatsoever. It's not good for the print head, |
| 705 | * though, since no ink is flowing through the other nozzles. This leads to |
| 706 | * drying of ink and possible permanent damage to the print head. |
| 707 | * |
| 708 | * By the way, although the Epson manual says that microweave mode should be |
| 709 | * used at 720 dpi, 360 dpi continues to work in much the same way. At 360 |
| 710 | * dpi, data is fed to the printer one row at a time on all Epson printers. |
| 711 | * The pattern that the printer uses to print is very prone to banding. |
| 712 | * However, 360 dpi is inherently a low quality mode; if you're using it, |
| 713 | * presumably you don't much care about quality. |
| 714 | * |
| 715 | * Printers from roughly the Stylus Color 600 and later do not have the |
| 716 | * capability to do MicroWeave correctly. Instead, the host must arrange |
| 717 | * the output in the order that it will be sent to the print head. This |
| 718 | * is a very complex process; the jets in the print head are spaced more |
| 719 | * than one row (1/720") apart, so we can't simply send consecutive rows |
| 720 | * of dots to the printer. Instead, we have to pass e. g. the first, ninth, |
| 721 | * 17th, 25th... rows in order for them to print in the correct position on |
| 722 | * the paper. This interleaving process is called "soft" weaving. |
| 723 | * |
| 724 | * This decision was probably made to save money on memory in the printer. |
| 725 | * It certainly makes the driver code far more complicated than it would |
| 726 | * be if the printer could arrange the output. Is that a bad thing? |
| 727 | * Usually this takes far less CPU time than the dithering process, and it |
| 728 | * does allow us more control over the printing process, e. g. to reduce |
| 729 | * banding. Conceivably, we could even use this ability to map out bad |
| 730 | * jets. |
| 731 | * |
| 732 | * Interestingly, apparently the Windows (and presumably Macintosh) drivers |
| 733 | * for most or all Epson printers still list a "microweave" mode. |
| 734 | * Experiments have demonstrated that this does not in fact use the |
| 735 | * "microweave" mode of the printer. Possibly it does nothing, or it uses |
| 736 | * a different weave pattern from what the non-"microweave" mode does. |
| 737 | * This is unnecessarily confusing. |
| 738 | * |
| 739 | * What makes this interesting is that there are many different ways of |
| 740 | * of accomplishing this goal. The naive way would be to divide the image |
| 741 | * up into groups of 256 rows, and print all the mod8=0 rows in the first pass, |
| 742 | * mod8=1 rows in the second, and so forth. The problem with this approach |
| 743 | * is that the individual ink jets are not perfectly uniform; some emit |
| 744 | * slightly bigger or smaller drops than others. Since each group of 8 |
| 745 | * adjacent rows is printed with the same nozzle, that means that there will |
| 746 | * be distinct streaks of lighter and darker bands within the image (8 rows |
| 747 | * is 1/90", which is visible; 1/720" is not). Possibly worse is that these |
| 748 | * patterns will repeat every 256 rows. This creates banding patterns that |
| 749 | * are about 1/3" wide. |
| 750 | * |
| 751 | * So we have to do something to break up this patterning. |
| 752 | * |
| 753 | * Epson does not publish the weaving algorithms that they use in their |
| 754 | * bundled drivers. Indeed, their developer web site |
| 755 | * (http://www.ercipd.com/isv/edr_docs.htm) does not even describe how to |
| 756 | * do this weaving at all; it says that the only way to achieve 720 dpi |
| 757 | * is to use MicroWeave. It does note (correctly) that 1440 dpi horizontal |
| 758 | * can only be achieved by the driver (i. e. in software). The manual |
| 759 | * actually makes it fairly clear how to do this (it requires two passes |
| 760 | * with horizontal head movement between passes), and it is presumably |
| 761 | * possible to do this with MicroWeave. |
| 762 | * |
| 763 | * The information about how to do this is apparently available under NDA. |
| 764 | * It's actually easy enough to reverse engineer what's inside a print file |
| 765 | * with a simple Perl script. There are presumably other printer commands |
| 766 | * that are not documented and may not be as easy to reverse engineer. |
| 767 | * |
| 768 | * I considered a few algorithms to perform the weave. The first one I |
| 769 | * devised let me use only (jets - distance_between_jets + 1) nozzles, or |
| 770 | * 25. This is OK in principle, but it's slower than using all nozzles. |
| 771 | * By playing around with it some more, I came up with an algorithm that |
| 772 | * lets me use all of the nozzles, except near the top and bottom of the |
| 773 | * page. |
| 774 | * |
| 775 | * This still produces some banding, though. Even better quality can be |
| 776 | * achieved by using multiple nozzles on the same line. How do we do this? |
| 777 | * In 1440x720 mode, we're printing two output lines at the same vertical |
| 778 | * position. However, if we want four passes, we have to effectively print |
| 779 | * each line twice. Actually doing this would increase the density, so |
| 780 | * what we do is print half the dots on each pass. This produces near-perfect |
| 781 | * output, and it's far faster than using (pseudo) "MicroWeave". |
| 782 | * |
| 783 | * The current algorithm is not completely general. The number of passes |
| 784 | * is limited to (nozzles / gap). On the Photo EX class printers, that limits |
| 785 | * it to 4 -- 32 nozzles, an inter-nozzle gap of 8 lines. Furthermore, there |
| 786 | * are a number of routines that are only coded up to 8 passes. Fortunately, |
| 787 | * this is enough passes to get rid of most banding. What's left is a very |
| 788 | * fine pattern that is sometimes described as "corduroy", since the pattern |
| 789 | * looks like that kind of fabric. |
| 790 | * |
| 791 | * Newer printers (those that support variable dot sizes, such as the 740, |
| 792 | * 1200, etc.) have an additional complication: when used in softweave mode, |
| 793 | * they operate at 360 dpi horizontal resolution. This requires FOUR passes |
| 794 | * to achieve 1440x720 dpi. Thus, to enable us to break up each row |
| 795 | * into separate sub-rows, we have to actually print each row eight times. |
| 796 | * Fortunately, all such printers have 48 nozzles and a gap of 6 rows, |
| 797 | * except for the high-speed 900, which uses 96 nozzles and a gap of 2 rows. |
| 798 | * |
| 799 | * I cannot let this entirely pass without commenting on the Stylus Color 440. |
| 800 | * This is a very low-end printer with 21 (!) nozzles and a separation of 8. |
| 801 | * The weave routine works correctly with single-pass printing, which is enough |
| 802 | * to minimally achieve 720 dpi output (it's physically a 720 dpi printer). |
| 803 | * However, the routine does not work correctly at more than one pass per row. |
| 804 | * Therefore, this printer bands badly. |
| 805 | * |
| 806 | * Yet another complication is how to get near the top and bottom of the page. |
| 807 | * This algorithm lets us print to within one head width of the top of the |
| 808 | * page, and a bit more than one head width from the bottom. That leaves a |
| 809 | * lot of blank space. Doing the weave properly outside of this region is |
| 810 | * increasingly difficult as we get closer to the edge of the paper; in the |
| 811 | * interior region, any nozzle can print any line, but near the top and |
| 812 | * bottom edges, only some nozzles can print. We've handled this for now by |
| 813 | * using the naive way mentioned above near the borders, and switching over |
| 814 | * to the high quality method in the interior. Unfortunately, this means |
| 815 | * that the quality is quite visibly degraded near the top and bottom of the |
| 816 | * page. Algorithms that degrade more gracefully are more complicated. |
| 817 | * Epson does not advertise that the printers can print at the very top of the |
| 818 | * page, although in practice most or all of them can. I suspect that the |
| 819 | * quality that can be achieved very close to the top is poor enough that |
| 820 | * Epson does not want to allow printing there. That is a valid decision, |
| 821 | * although we have taken another approach. |
| 822 | * |
| 823 | * To compute the weave information, we need to start with the following |
| 824 | * information: |
| 825 | * |
| 826 | * 1) The number of jets the print head has for each color; |
| 827 | * |
| 828 | * 2) The separation in rows between the jets; |
| 829 | * |
| 830 | * 3) The horizontal resolution of the printer; |
| 831 | * |
| 832 | * 4) The desired horizontal resolution of the output; |
| 833 | * |
| 834 | * 5) The desired extra passes to reduce banding. |
| 835 | * |
| 836 | * As discussed above, each row is actually printed in one or more passes |
| 837 | * of the print head; we refer to these as subpasses. For example, if we're |
| 838 | * printing at 1440(h)x720(v) on a printer with true horizontal resolution of |
| 839 | * 360 dpi, and we wish to print each line twice with different nozzles |
| 840 | * to reduce banding, we need to use 8 subpasses. The dither routine |
| 841 | * will feed us a complete row of bits for each color; we have to split that |
| 842 | * up, first by round robining the bits to ensure that they get printed at |
| 843 | * the right micro-position, and then to split up the bits that are actually |
| 844 | * turned on into two equal chunks to reduce banding. |
| 845 | * |
| 846 | * Given the above information, and the desired row index and subpass (which |
| 847 | * together form a line number), we can compute: |
| 848 | * |
| 849 | * 1) Which pass this line belongs to. Passes are numbered consecutively, |
| 850 | * and each pass must logically (see #3 below) start at no smaller a row |
| 851 | * number than the previous pass, as the printer cannot advance by a |
| 852 | * negative amount. |
| 853 | * |
| 854 | * 2) Which jet will print this line. |
| 855 | * |
| 856 | * 3) The "logical" first line of this pass. That is, what line would be |
| 857 | * printed by jet 0 in this pass. This number may be less than zero. |
| 858 | * If it is, there are ghost lines that don't actually contain any data. |
| 859 | * The difference between the logical first line of this pass and the |
| 860 | * logical first line of the preceding pass tells us how many lines must |
| 861 | * be advanced. |
| 862 | * |
| 863 | * 4) The "physical" first line of this pass. That is, the first line index |
| 864 | * that is actually printed in this pass. This information lets us know |
| 865 | * when we must prepare this pass. |
| 866 | * |
| 867 | * 5) The last line of this pass. This lets us know when we must actually |
| 868 | * send this pass to the printer. |
| 869 | * |
| 870 | * 6) The number of ghost rows this pass contains. We must still send the |
| 871 | * ghost data to the printer, so this lets us know how much data we must |
| 872 | * fill in prior to the start of the pass. |
| 873 | * |
| 874 | * The bookkeeping to keep track of all this stuff is quite hairy, and needs |
| 875 | * to be documented separately. |
| 876 | * |
| 877 | * The routine initialize_weave calculates the basic parameters, given |
| 878 | * the number of jets and separation between jets, in rows. |
| 879 | * |
| 880 | * -- Robert Krawitz <[email protected]) November 3, 1999 |
| 881 | */ |
| 882 | |
| 883 | static stp_lineoff_tcxx . . $ stp_lineoff_t# * |
| 884 | allocate_lineoffcxx . . $ allocate_lineoff(f9cc67cbefa1e6ee).(int count, int ncolors) |
| 885 | { |
| 886 | int i; |
| 887 | stp_lineoff_tcxx . . $ stp_lineoff_t# *retval = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(count * sizeof(stp_lineoff_tcxx . . $ stp_lineoff_t#)); |
| 888 | for (i = 0; i < count; i++) |
| 889 | { |
| 890 | retval[i].ncolorscxx . . $ $anonymous_type_bcaa485bbb542c91_2#ncolors. = ncolors; |
| 891 | retval[i].vcxx . . $ $anonymous_type_bcaa485bbb542c91_2#v. = stp_zalloccxx . . $ stp_zalloc(bfcfa4d6b7f7ef64).(ncolors * sizeof(unsigned long)); |
| 892 | } |
| 893 | return (retval); |
| 894 | } |
| 895 | |
| 896 | static stp_lineactive_tcxx . . $ stp_lineactive_t# * |
| 897 | allocate_lineactivecxx . . $ allocate_lineactive(8a7d6838fdee0fcd).(int count, int ncolors) |
| 898 | { |
| 899 | int i; |
| 900 | stp_lineactive_tcxx . . $ stp_lineactive_t# *retval = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(count * sizeof(stp_lineactive_tcxx . . $ stp_lineactive_t#)); |
| 901 | for (i = 0; i < count; i++) |
| 902 | { |
| 903 | retval[i].ncolorscxx . . $ $anonymous_type_bcaa485bbb542c91_3#ncolors. = ncolors; |
| 904 | retval[i].vcxx . . $ $anonymous_type_bcaa485bbb542c91_3#v. = stp_zalloccxx . . $ stp_zalloc(bfcfa4d6b7f7ef64).(ncolors * sizeof(char)); |
| 905 | } |
| 906 | return (retval); |
| 907 | } |
| 908 | |
| 909 | static stp_linecount_tcxx . . $ stp_linecount_t# * |
| 910 | allocate_linecountcxx . . $ allocate_linecount(99317dc61261ead).(int count, int ncolors) |
| 911 | { |
| 912 | int i; |
| 913 | stp_linecount_tcxx . . $ stp_linecount_t# *retval = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(count * sizeof(stp_linecount_tcxx . . $ stp_linecount_t#)); |
| 914 | for (i = 0; i < count; i++) |
| 915 | { |
| 916 | retval[i].ncolorscxx . . $ $anonymous_type_bcaa485bbb542c91_4#ncolors. = ncolors; |
| 917 | retval[i].vcxx . . $ $anonymous_type_bcaa485bbb542c91_4#v. = stp_zalloccxx . . $ stp_zalloc(bfcfa4d6b7f7ef64).(ncolors * sizeof(int)); |
| 918 | } |
| 919 | return (retval); |
| 920 | } |
| 921 | |
| 922 | static stp_linebounds_tcxx . . $ stp_linebounds_t# * |
| 923 | allocate_lineboundscxx . . $ allocate_linebounds(92ca5e3e387da280).(int count, int ncolors) |
| 924 | { |
| 925 | int i; |
| 926 | stp_linebounds_tcxx . . $ stp_linebounds_t# *retval = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(count * sizeof(stp_linebounds_tcxx . . $ stp_linebounds_t#)); |
| 927 | for (i = 0; i < count; i++) |
| 928 | { |
| 929 | retval[i].ncolorscxx . . $ $anonymous_type_bcaa485bbb542c91_6#ncolors. = ncolors; |
| 930 | retval[i].start_poscxx . . $ $anonymous_type_bcaa485bbb542c91_6#start_pos. = stp_zalloccxx . . $ stp_zalloc(bfcfa4d6b7f7ef64).(ncolors * sizeof(int)); |
| 931 | retval[i].end_poscxx . . $ $anonymous_type_bcaa485bbb542c91_6#end_pos. = stp_zalloccxx . . $ stp_zalloc(bfcfa4d6b7f7ef64).(ncolors * sizeof(int)); |
| 932 | } |
| 933 | return (retval); |
| 934 | } |
| 935 | |
| 936 | static stp_linebufs_tcxx . . $ stp_linebufs_t# * |
| 937 | allocate_linebufcxx . . $ allocate_linebuf(9554748dee2a43a6).(int count, int ncolors) |
| 938 | { |
| 939 | int i; |
| 940 | stp_linebufs_tcxx . . $ stp_linebufs_t# *retval = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(count * sizeof(stp_linebufs_tcxx . . $ stp_linebufs_t#)); |
| 941 | for (i = 0; i < count; i++) |
| 942 | { |
| 943 | retval[i].ncolorscxx . . $ $anonymous_type_bcaa485bbb542c91_5#ncolors. = ncolors; |
| 944 | retval[i].vcxx . . $ $anonymous_type_bcaa485bbb542c91_5#v. = stp_zalloccxx . . $ stp_zalloc(bfcfa4d6b7f7ef64).(ncolors * sizeof(unsigned char *)); |
| 945 | } |
| 946 | return (retval); |
| 947 | } |
| 948 | |
| 949 | /* |
| 950 | * Initialize the weave parameters |
| 951 | * |
| 952 | * Rules: |
| 953 | * |
| 954 | * 1) Currently, osample * v_subpasses * v_subsample <= 8, and no one |
| 955 | * of these variables may exceed 4. |
| 956 | * |
| 957 | * 2) first_line >= 0 |
| 958 | * |
| 959 | * 3) line_height < physlines |
| 960 | * |
| 961 | * 4) page_height >= 2 * jets * sep |
| 962 | */ |
| 963 | |
| 964 | static void |
| 965 | stpi_destroy_weavecxx . . $ stpi_destroy_weave(5d22bdacc48458e8).(void *vsw) |
| 966 | { |
| 967 | int i, j; |
| 968 | stpi_softweave_tcxx . . $ stpi_softweave_t# *sw = (stpi_softweave_tcxx . . $ stpi_softweave_t# *) vsw; |
| 969 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(sw->passescxx . . $ stpi_softweave#passes.); |
| 970 | if (sw->fold_bufcxx . . $ stpi_softweave#fold_buf.) |
| 971 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(sw->fold_bufcxx . . $ stpi_softweave#fold_buf.); |
| 972 | if (sw->comp_bufcxx . . $ stpi_softweave#comp_buf.) |
| 973 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(sw->comp_bufcxx . . $ stpi_softweave#comp_buf.); |
| 974 | for (i = 0; i < STP_MAX_WEAVEcxx . . $ `include/gutenprint/weave.h:46:9`!; i++) |
| 975 | if (sw->scxx . . $ stpi_softweave#s.[i]) |
| 976 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(sw->scxx . . $ stpi_softweave#s.[i]); |
| 977 | for (i = 0; i < sw->vmodcxx . . $ stpi_softweave#vmod.; i++) |
| 978 | { |
| 979 | for (j = 0; j < sw->ncolorscxx . . $ stpi_softweave#ncolors.; j++) |
| 980 | { |
| 981 | if (sw->linebasescxx . . $ stpi_softweave#linebases.[i].vcxx . . $ $anonymous_type_bcaa485bbb542c91_5#v.[j]) |
| 982 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(sw->linebasescxx . . $ stpi_softweave#linebases.[i].vcxx . . $ $anonymous_type_bcaa485bbb542c91_5#v.[j]); |
| 983 | } |
| 984 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(sw->linecountscxx . . $ stpi_softweave#linecounts.[i].vcxx . . $ $anonymous_type_bcaa485bbb542c91_4#v.); |
| 985 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(sw->linebasescxx . . $ stpi_softweave#linebases.[i].vcxx . . $ $anonymous_type_bcaa485bbb542c91_5#v.); |
| 986 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(sw->lineactivecxx . . $ stpi_softweave#lineactive.[i].vcxx . . $ $anonymous_type_bcaa485bbb542c91_3#v.); |
| 987 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(sw->lineoffsetscxx . . $ stpi_softweave#lineoffsets.[i].vcxx . . $ $anonymous_type_bcaa485bbb542c91_2#v.); |
| 988 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(sw->lineboundscxx . . $ stpi_softweave#linebounds.[i].start_poscxx . . $ $anonymous_type_bcaa485bbb542c91_6#start_pos.); |
| 989 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(sw->lineboundscxx . . $ stpi_softweave#linebounds.[i].end_poscxx . . $ $anonymous_type_bcaa485bbb542c91_6#end_pos.); |
| 990 | } |
| 991 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(sw->linecountscxx . . $ stpi_softweave#linecounts.); |
| 992 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(sw->lineactivecxx . . $ stpi_softweave#lineactive.); |
| 993 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(sw->lineoffsetscxx . . $ stpi_softweave#lineoffsets.); |
| 994 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(sw->linebasescxx . . $ stpi_softweave#linebases.); |
| 995 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(sw->lineboundscxx . . $ stpi_softweave#linebounds.); |
| 996 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(sw->head_offsetcxx . . $ stpi_softweave#head_offset.); |
| 997 | stpi_destroy_weave_paramscxx . . $ stpi_destroy_weave_params(5d22bdacc48458e8).(sw->weaveparmcxx . . $ stpi_softweave#weaveparm.); |
| 998 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(vsw); |
| 999 | } |
| 1000 | |
| 1001 | void |
| 1002 | stp_initialize_weavecxx . . $ stp_initialize_weave(21970b5590b16727).(stp_vars_tcxx . . $ stp_vars_t# *v, |
| 1003 | int jets, /* Width of print head */ |
| 1004 | int sep, /* Separation in rows between jets */ |
| 1005 | int osample, /* Horizontal oversample */ |
| 1006 | int v_subpasses, /* Vertical passes */ |
| 1007 | int v_subsample, /* Vertical oversampling */ |
| 1008 | int ncolors, |
| 1009 | int bitwidth, /* bits/pixel */ |
| 1010 | int linewidth, /* Width of a line, in pixels */ |
| 1011 | int line_count, /* Lines that will be printed */ |
| 1012 | int first_line, /* First line that will be printed */ |
| 1013 | int page_height, /* Total height of the page in rows */ |
| 1014 | const int *head_offset, |
| 1015 | stp_weave_strategy_tcxx . . $ stp_weave_strategy_t# weave_strategy, |
| 1016 | stp_flushfunccxx . . $ stp_flushfunc# flushfunc, |
| 1017 | stp_fillfunccxx . . $ stp_fillfunc# fillfunc, |
| 1018 | stp_packfunccxx . . $ stp_packfunc# pack, |
| 1019 | stp_compute_linewidth_funccxx . . $ stp_compute_linewidth_func# compute_linewidth) |
| 1020 | { |
| 1021 | int i; |
| 1022 | int last_line, maxHeadOffset; |
| 1023 | stpi_softweave_tcxx . . $ stpi_softweave_t# *sw = stp_zalloccxx . . $ stp_zalloc(bfcfa4d6b7f7ef64).(sizeof (stpi_softweave_tcxx . . $ stpi_softweave_t#)); |
| 1024 | |
| 1025 | if (jets < 1) |
| 1026 | jets = 1; |
| 1027 | if (jets == 1 || sep < 1) |
| 1028 | sep = 1; |
| 1029 | if (v_subpasses < 1) |
| 1030 | v_subpasses = 1; |
| 1031 | if (v_subsample < 1) |
| 1032 | v_subsample = 1; |
| 1033 | |
| 1034 | sw->separationcxx . . $ stpi_softweave#separation. = sep; |
| 1035 | sw->jetscxx . . $ stpi_softweave#jets. = jets; |
| 1036 | sw->horizontal_weavecxx . . $ stpi_softweave#horizontal_weave. = osample; |
| 1037 | sw->oversamplecxx . . $ stpi_softweave#oversample. = osample * v_subpasses * v_subsample; |
| 1038 | if (sw->oversamplecxx . . $ stpi_softweave#oversample. > jets) |
| 1039 | { |
| 1040 | int found = 0; |
| 1041 | for (i = 2; i <= osample; i++) |
| 1042 | { |
| 1043 | if ((osample % i == 0) && (sw->oversamplecxx . . $ stpi_softweave#oversample. / i <= jets)) |
| 1044 | { |
| 1045 | sw->repeat_countcxx . . $ stpi_softweave#repeat_count. = i; |
| 1046 | osample /= i; |
| 1047 | found = 1; |
| 1048 | break; |
| 1049 | } |
| 1050 | } |
| 1051 | if (!found) |
| 1052 | { |
| 1053 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "Weave error: oversample (%d) > jets (%d)\n", |
| 1054 | sw->oversamplecxx . . $ stpi_softweave#oversample., jets); |
| 1055 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(sw); |
| 1056 | return; |
| 1057 | } |
| 1058 | } |
| 1059 | else |
| 1060 | sw->repeat_countcxx . . $ stpi_softweave#repeat_count. = 1; |
| 1061 | |
| 1062 | sw->vertical_oversamplecxx . . $ stpi_softweave#vertical_oversample. = v_subsample; |
| 1063 | sw->vertical_subpassescxx . . $ stpi_softweave#vertical_subpasses. = v_subpasses; |
| 1064 | sw->oversamplecxx . . $ stpi_softweave#oversample. = osample * v_subpasses * v_subsample; |
| 1065 | sw->firstlinecxx . . $ stpi_softweave#firstline. = first_line; |
| 1066 | sw->linenocxx . . $ stpi_softweave#lineno. = first_line; |
| 1067 | sw->flushfunccxx . . $ stpi_softweave#flushfunc. = flushfunc; |
| 1068 | |
| 1069 | if (sw->oversamplecxx . . $ stpi_softweave#oversample. > jets) |
| 1070 | { |
| 1071 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "Weave error: oversample (%d) > jets (%d)\n", |
| 1072 | sw->oversamplecxx . . $ stpi_softweave#oversample., jets); |
| 1073 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(sw); |
| 1074 | return; |
| 1075 | } |
| 1076 | |
| 1077 | /* |
| 1078 | * setup printhead offsets. |
| 1079 | * for monochrome (bw) printing, the offsets are 0. |
| 1080 | */ |
| 1081 | sw->head_offsetcxx . . $ stpi_softweave#head_offset. = stp_zalloccxx . . $ stp_zalloc(bfcfa4d6b7f7ef64).(ncolors * sizeof(int)); |
| 1082 | if (ncolors > 1) |
| 1083 | for(i = 0; i < ncolors; i++) |
| 1084 | sw->head_offsetcxx . . $ stpi_softweave#head_offset.[i] = head_offset[i]; |
| 1085 | |
| 1086 | maxHeadOffset = 0; |
| 1087 | for (i = 0; i < ncolors; i++) |
| 1088 | if (sw->head_offsetcxx . . $ stpi_softweave#head_offset.[i] > maxHeadOffset) |
| 1089 | maxHeadOffset = sw->head_offsetcxx . . $ stpi_softweave#head_offset.[i]; |
| 1090 | |
| 1091 | sw->virtual_jetscxx . . $ stpi_softweave#virtual_jets. = sw->jetscxx . . $ stpi_softweave#jets.; |
| 1092 | if (maxHeadOffset > 0) |
| 1093 | sw->virtual_jetscxx . . $ stpi_softweave#virtual_jets. += (maxHeadOffset + sw->separationcxx . . $ stpi_softweave#separation. - 1) / sw->separationcxx . . $ stpi_softweave#separation.; |
| 1094 | last_line = first_line + line_count - 1 + maxHeadOffset; |
| 1095 | |
| 1096 | sw->weaveparmcxx . . $ stpi_softweave#weaveparm. = initialize_weave_paramscxx . . $ initialize_weave_params(ecf22cda90d5d2ef).(sw->separationcxx . . $ stpi_softweave#separation., sw->jetscxx . . $ stpi_softweave#jets., |
| 1097 | sw->oversamplecxx . . $ stpi_softweave#oversample., first_line, last_line, |
| 1098 | page_height, weave_strategy, v); |
| 1099 | /* |
| 1100 | * The value of vmod limits how many passes may be unfinished at a time. |
| 1101 | * If pass x is not yet printed, pass x+vmod cannot be started. |
| 1102 | * |
| 1103 | * The multiplier of 2: 1 for the normal passes, 1 for the special passes |
| 1104 | * at the start or end. |
| 1105 | */ |
| 1106 | sw->vmodcxx . . $ stpi_softweave#vmod. = 2 * sw->separationcxx . . $ stpi_softweave#separation. * sw->oversamplecxx . . $ stpi_softweave#oversample. * sw->repeat_countcxx . . $ stpi_softweave#repeat_count.; |
| 1107 | if (sw->virtual_jetscxx . . $ stpi_softweave#virtual_jets. > sw->jetscxx . . $ stpi_softweave#jets.) |
| 1108 | sw->vmodcxx . . $ stpi_softweave#vmod. *= (sw->virtual_jetscxx . . $ stpi_softweave#virtual_jets. + sw->jetscxx . . $ stpi_softweave#jets. - 1) / sw->jetscxx . . $ stpi_softweave#jets.; |
| 1109 | |
| 1110 | sw->bitwidthcxx . . $ stpi_softweave#bitwidth. = bitwidth; |
| 1111 | sw->last_pass_offsetcxx . . $ stpi_softweave#last_pass_offset. = 0; |
| 1112 | sw->last_passcxx . . $ stpi_softweave#last_pass. = -1; |
| 1113 | sw->current_vertical_subpasscxx . . $ stpi_softweave#current_vertical_subpass. = 0; |
| 1114 | sw->ncolorscxx . . $ stpi_softweave#ncolors. = ncolors; |
| 1115 | sw->linewidthcxx . . $ stpi_softweave#linewidth. = linewidth; |
| 1116 | sw->vertical_heightcxx . . $ stpi_softweave#vertical_height. = line_count; |
| 1117 | sw->lineoffsetscxx . . $ stpi_softweave#lineoffsets. = allocate_lineoffcxx . . $ allocate_lineoff(f9cc67cbefa1e6ee).(sw->vmodcxx . . $ stpi_softweave#vmod., ncolors); |
| 1118 | sw->lineactivecxx . . $ stpi_softweave#lineactive. = allocate_lineactivecxx . . $ allocate_lineactive(8a7d6838fdee0fcd).(sw->vmodcxx . . $ stpi_softweave#vmod., ncolors); |
| 1119 | sw->linebasescxx . . $ stpi_softweave#linebases. = allocate_linebufcxx . . $ allocate_linebuf(9554748dee2a43a6).(sw->vmodcxx . . $ stpi_softweave#vmod., ncolors); |
| 1120 | sw->lineboundscxx . . $ stpi_softweave#linebounds. = allocate_lineboundscxx . . $ allocate_linebounds(92ca5e3e387da280).(sw->vmodcxx . . $ stpi_softweave#vmod., ncolors); |
| 1121 | sw->passescxx . . $ stpi_softweave#passes. = stp_zalloccxx . . $ stp_zalloc(bfcfa4d6b7f7ef64).(sw->vmodcxx . . $ stpi_softweave#vmod. * sizeof(stp_pass_tcxx . . $ stp_pass_t#)); |
| 1122 | sw->linecountscxx . . $ stpi_softweave#linecounts. = allocate_linecountcxx . . $ allocate_linecount(99317dc61261ead).(sw->vmodcxx . . $ stpi_softweave#vmod., ncolors); |
| 1123 | sw->rcachecxx . . $ stpi_softweave#rcache. = -2; |
| 1124 | sw->vcachecxx . . $ stpi_softweave#vcache. = -2; |
| 1125 | sw->fillfunccxx . . $ stpi_softweave#fillfunc. = fillfunc; |
| 1126 | sw->compute_linewidthcxx . . $ stpi_softweave#compute_linewidth. = compute_linewidth; |
| 1127 | sw->packcxx . . $ stpi_softweave#pack. = pack; |
| 1128 | sw->horizontal_widthcxx . . $ stpi_softweave#horizontal_width. = |
| 1129 | (sw->compute_linewidthcxx . . $ stpi_softweave#compute_linewidth.)(v, ((sw->linewidthcxx . . $ stpi_softweave#linewidth. + sw->horizontal_weavecxx . . $ stpi_softweave#horizontal_weave. - 1) / |
| 1130 | sw->horizontal_weavecxx . . $ stpi_softweave#horizontal_weave.)); |
| 1131 | stp_dprintfcxx . . $ stp_dprintf(13526ca24396f6ac).(STP_DBG_WEAVE_PARAMScxx . . $ `include/gutenprint/util.h:174:9`!, v, |
| 1132 | "Computing linewidth for linewidth %d weave %d => %d (%d)\n", |
| 1133 | sw->linewidthcxx . . $ stpi_softweave#linewidth., sw->horizontal_weavecxx . . $ stpi_softweave#horizontal_weave., sw->horizontal_widthcxx . . $ stpi_softweave#horizontal_width., |
| 1134 | ((sw->horizontal_widthcxx . . $ stpi_softweave#horizontal_width. + 7) / 8)); |
| 1135 | sw->horizontal_widthcxx . . $ stpi_softweave#horizontal_width. = ((sw->horizontal_widthcxx . . $ stpi_softweave#horizontal_width. + 7) / 8); |
| 1136 | |
| 1137 | for (i = 0; i < sw->vmodcxx . . $ stpi_softweave#vmod.; i++) |
| 1138 | { |
| 1139 | int j; |
| 1140 | sw->passescxx . . $ stpi_softweave#passes.[i].passcxx . . $ $anonymous_type_bcaa485bbb542c91_1#pass. = -1; |
| 1141 | for (j = 0; j < sw->ncolorscxx . . $ stpi_softweave#ncolors.; j++) |
| 1142 | { |
| 1143 | sw->linebasescxx . . $ stpi_softweave#linebases.[i].vcxx . . $ $anonymous_type_bcaa485bbb542c91_5#v.[j] = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1144 | } |
| 1145 | } |
| 1146 | stp_dprintfcxx . . $ stp_dprintf(13526ca24396f6ac).(STP_DBG_WEAVE_PARAMScxx . . $ `include/gutenprint/util.h:174:9`!, v, |
| 1147 | "Weave parameters: separation %d jets %d (%d) h %d v %d v_sub %d\n", |
| 1148 | sw->separationcxx . . $ stpi_softweave#separation., sw->jetscxx . . $ stpi_softweave#jets., sw->virtual_jetscxx . . $ stpi_softweave#virtual_jets., osample, |
| 1149 | v_subpasses, v_subsample); |
| 1150 | stp_dprintfcxx . . $ stp_dprintf(13526ca24396f6ac).(STP_DBG_WEAVE_PARAMScxx . . $ `include/gutenprint/util.h:174:9`!, v, |
| 1151 | " ncolors %d bpp %d width %d (%d) line_count %d first %d last %d max_offset %d\n", |
| 1152 | sw->ncolorscxx . . $ stpi_softweave#ncolors., sw->bitwidthcxx . . $ stpi_softweave#bitwidth., linewidth, sw->horizontal_widthcxx . . $ stpi_softweave#horizontal_width., |
| 1153 | sw->vertical_heightcxx . . $ stpi_softweave#vertical_height., first_line, last_line, maxHeadOffset); |
| 1154 | stp_dprintfcxx . . $ stp_dprintf(13526ca24396f6ac).(STP_DBG_WEAVE_PARAMScxx . . $ `include/gutenprint/util.h:174:9`!, v, |
| 1155 | " oversample %d line buffer count %d total buffer %d, page_height %d\n", |
| 1156 | sw->oversamplecxx . . $ stpi_softweave#oversample., sw->vmodcxx . . $ stpi_softweave#vmod., |
| 1157 | sw->vmodcxx . . $ stpi_softweave#vmod. * sw->virtual_jetscxx . . $ stpi_softweave#virtual_jets. * sw->bitwidthcxx . . $ stpi_softweave#bitwidth. * |
| 1158 | sw->ncolorscxx . . $ stpi_softweave#ncolors. * sw->horizontal_widthcxx . . $ stpi_softweave#horizontal_width., page_height); |
| 1159 | stp_dprintfcxx . . $ stp_dprintf(13526ca24396f6ac).(STP_DBG_WEAVE_PARAMScxx . . $ `include/gutenprint/util.h:174:9`!, v, |
| 1160 | " ***Buffer limit %d (vj %d bw %d hw %d)\n", |
| 1161 | sw->virtual_jetscxx . . $ stpi_softweave#virtual_jets. * sw->bitwidthcxx . . $ stpi_softweave#bitwidth. * sw->horizontal_widthcxx . . $ stpi_softweave#horizontal_width., |
| 1162 | sw->virtual_jetscxx . . $ stpi_softweave#virtual_jets., sw->bitwidthcxx . . $ stpi_softweave#bitwidth., sw->horizontal_widthcxx . . $ stpi_softweave#horizontal_width.); |
| 1163 | stp_allocate_component_datacxx . . $ stp_allocate_component_data(c746010122f90098).(v, "Weave", NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, stpi_destroy_weavecxx . . $ stpi_destroy_weave(5d22bdacc48458e8)., sw); |
| 1164 | return; |
| 1165 | } |
| 1166 | |
| 1167 | static void |
| 1168 | weave_parameters_by_rowcxx . . $ weave_parameters_by_row(6948d9d8b6898345).(const stp_vars_tcxx . . $ stp_vars_t# *v, stpi_softweave_tcxx . . $ stpi_softweave_t# *sw, |
| 1169 | int row, int vertical_subpass, stp_weave_tcxx . . $ stp_weave_t# *w) |
| 1170 | { |
| 1171 | int jetsused; |
| 1172 | int sub_repeat_count = vertical_subpass % sw->repeat_countcxx . . $ stpi_softweave#repeat_count.; |
| 1173 | /* |
| 1174 | * Conceptually, this does not modify the softweave state. We cache |
| 1175 | * the results, but this cache is considered hidden. |
| 1176 | */ |
| 1177 | vertical_subpass /= sw->repeat_countcxx . . $ stpi_softweave#repeat_count.; |
| 1178 | |
| 1179 | if (sw->rcachecxx . . $ stpi_softweave#rcache. == row && sw->vcachecxx . . $ stpi_softweave#vcache. == vertical_subpass) |
| 1180 | { |
| 1181 | memcpycxx . . $ memcpy(cc817cb175f282d).(w, &sw->wcachecxx . . $ stpi_softweave#wcache., sizeof(stp_weave_tcxx . . $ stp_weave_t#)); |
| 1182 | w->passcxx . . $ $anonymous_type_bcaa485bbb542c91_0#pass. = (w->passcxx . . $ $anonymous_type_bcaa485bbb542c91_0#pass. * sw->repeat_countcxx . . $ stpi_softweave#repeat_count.) + sub_repeat_count; |
| 1183 | return; |
| 1184 | } |
| 1185 | sw->rcachecxx . . $ stpi_softweave#rcache. = row; |
| 1186 | sw->vcachecxx . . $ stpi_softweave#vcache. = vertical_subpass; |
| 1187 | |
| 1188 | w->rowcxx . . $ $anonymous_type_bcaa485bbb542c91_0#row. = row; |
| 1189 | stpi_calculate_row_parameterscxx . . $ stpi_calculate_row_parameters(ca1493586ba34b5b).(sw->weaveparmcxx . . $ stpi_softweave#weaveparm., row, vertical_subpass, |
| 1190 | &w->passcxx . . $ $anonymous_type_bcaa485bbb542c91_0#pass., &w->jetcxx . . $ $anonymous_type_bcaa485bbb542c91_0#jet., &w->logicalpassstartcxx . . $ $anonymous_type_bcaa485bbb542c91_0#logicalpassstart., |
| 1191 | &w->missingstartrowscxx . . $ $anonymous_type_bcaa485bbb542c91_0#missingstartrows., &jetsused); |
| 1192 | |
| 1193 | w->physpassstartcxx . . $ $anonymous_type_bcaa485bbb542c91_0#physpassstart. = w->logicalpassstartcxx . . $ $anonymous_type_bcaa485bbb542c91_0#logicalpassstart. + sw->separationcxx . . $ stpi_softweave#separation. * w->missingstartrowscxx . . $ $anonymous_type_bcaa485bbb542c91_0#missingstartrows.; |
| 1194 | w->physpassendcxx . . $ $anonymous_type_bcaa485bbb542c91_0#physpassend. = w->physpassstartcxx . . $ $anonymous_type_bcaa485bbb542c91_0#physpassstart. + sw->separationcxx . . $ stpi_softweave#separation. * (jetsused - 1); |
| 1195 | |
| 1196 | memcpycxx . . $ memcpy(cc817cb175f282d).(&(sw->wcachecxx . . $ stpi_softweave#wcache.), w, sizeof(stp_weave_tcxx . . $ stp_weave_t#)); |
| 1197 | w->passcxx . . $ $anonymous_type_bcaa485bbb542c91_0#pass. = (w->passcxx . . $ $anonymous_type_bcaa485bbb542c91_0#pass. * sw->repeat_countcxx . . $ stpi_softweave#repeat_count.) + sub_repeat_count; |
| 1198 | stp_dprintfcxx . . $ stp_dprintf(13526ca24396f6ac).(STP_DBG_ROWScxx . . $ `include/gutenprint/util.h:175:9`!, v, "row %d, jet %d of pass %d " |
| 1199 | "(pos %d, start %d, end %d, missing rows %d)\n", |
| 1200 | w->rowcxx . . $ $anonymous_type_bcaa485bbb542c91_0#row., w->jetcxx . . $ $anonymous_type_bcaa485bbb542c91_0#jet., w->passcxx . . $ $anonymous_type_bcaa485bbb542c91_0#pass., w->logicalpassstartcxx . . $ $anonymous_type_bcaa485bbb542c91_0#logicalpassstart., w->physpassstartcxx . . $ $anonymous_type_bcaa485bbb542c91_0#physpassstart., |
| 1201 | w->physpassendcxx . . $ $anonymous_type_bcaa485bbb542c91_0#physpassend., w->missingstartrowscxx . . $ $anonymous_type_bcaa485bbb542c91_0#missingstartrows.); |
| 1202 | } |
| 1203 | |
| 1204 | static stpi_softweave_tcxx . . $ stpi_softweave_t# * |
| 1205 | get_swcxx . . $ get_sw(821cfaf20b80b407).(const stp_vars_tcxx . . $ stp_vars_t# *v) |
| 1206 | { |
| 1207 | return (stpi_softweave_tcxx . . $ stpi_softweave_t# *) stp_get_component_datacxx . . $ stp_get_component_data(2bc0070dfdce2f04).(v, "Weave"); |
| 1208 | } |
| 1209 | |
| 1210 | void |
| 1211 | stp_weave_parameters_by_rowcxx . . $ stp_weave_parameters_by_row(f905154d6ace42ae).(const stp_vars_tcxx . . $ stp_vars_t# *v, int row, |
| 1212 | int vertical_subpass, stp_weave_tcxx . . $ stp_weave_t# *w) |
| 1213 | { |
| 1214 | stpi_softweave_tcxx . . $ stpi_softweave_t# *sw = get_swcxx . . $ get_sw(821cfaf20b80b407).(v); |
| 1215 | weave_parameters_by_rowcxx . . $ weave_parameters_by_row(6948d9d8b6898345).(v, sw, row, vertical_subpass, w); |
| 1216 | } |
| 1217 | |
| 1218 | |
| 1219 | static stp_lineoff_tcxx . . $ stp_lineoff_t# * |
| 1220 | stpi_get_lineoffsetscxx . . $ stpi_get_lineoffsets(bda34ccbee190ce3).(const stp_vars_tcxx . . $ stp_vars_t# *v, stpi_softweave_tcxx . . $ stpi_softweave_t# *sw, |
| 1221 | int row, int subpass, int offset) |
| 1222 | { |
| 1223 | stp_weave_tcxx . . $ stp_weave_t# w; |
| 1224 | weave_parameters_by_rowcxx . . $ weave_parameters_by_row(6948d9d8b6898345).(v, sw, row + offset, subpass, &w); |
| 1225 | return &(sw->lineoffsetscxx . . $ stpi_softweave#lineoffsets.[w.passcxx . . $ $anonymous_type_bcaa485bbb542c91_0#pass. % sw->vmodcxx . . $ stpi_softweave#vmod.]); |
| 1226 | } |
| 1227 | |
| 1228 | static stp_lineactive_tcxx . . $ stp_lineactive_t# * |
| 1229 | stpi_get_lineactivecxx . . $ stpi_get_lineactive(78e4cbbfa629d95e).(const stp_vars_tcxx . . $ stp_vars_t# *v, stpi_softweave_tcxx . . $ stpi_softweave_t# *sw, |
| 1230 | int row, int subpass, int offset) |
| 1231 | { |
| 1232 | stp_weave_tcxx . . $ stp_weave_t# w; |
| 1233 | weave_parameters_by_rowcxx . . $ weave_parameters_by_row(6948d9d8b6898345).(v, sw, row + offset, subpass, &w); |
| 1234 | return &(sw->lineactivecxx . . $ stpi_softweave#lineactive.[w.passcxx . . $ $anonymous_type_bcaa485bbb542c91_0#pass. % sw->vmodcxx . . $ stpi_softweave#vmod.]); |
| 1235 | } |
| 1236 | |
| 1237 | static stp_linecount_tcxx . . $ stp_linecount_t# * |
| 1238 | stpi_get_linecountcxx . . $ stpi_get_linecount(d7e8f0406324f842).(const stp_vars_tcxx . . $ stp_vars_t# *v, stpi_softweave_tcxx . . $ stpi_softweave_t# *sw, |
| 1239 | int row, int subpass, int offset) |
| 1240 | { |
| 1241 | stp_weave_tcxx . . $ stp_weave_t# w; |
| 1242 | weave_parameters_by_rowcxx . . $ weave_parameters_by_row(6948d9d8b6898345).(v, sw, row + offset, subpass, &w); |
| 1243 | return &(sw->linecountscxx . . $ stpi_softweave#linecounts.[w.passcxx . . $ $anonymous_type_bcaa485bbb542c91_0#pass. % sw->vmodcxx . . $ stpi_softweave#vmod.]); |
| 1244 | } |
| 1245 | |
| 1246 | static stp_linebufs_tcxx . . $ stp_linebufs_t# * |
| 1247 | stpi_get_linebasescxx . . $ stpi_get_linebases(7875a90f91ede3b5).(const stp_vars_tcxx . . $ stp_vars_t# *v, stpi_softweave_tcxx . . $ stpi_softweave_t# *sw, |
| 1248 | int row, int subpass, int offset) |
| 1249 | { |
| 1250 | stp_weave_tcxx . . $ stp_weave_t# w; |
| 1251 | weave_parameters_by_rowcxx . . $ weave_parameters_by_row(6948d9d8b6898345).(v, sw, row + offset, subpass, &w); |
| 1252 | return &(sw->linebasescxx . . $ stpi_softweave#linebases.[w.passcxx . . $ $anonymous_type_bcaa485bbb542c91_0#pass. % sw->vmodcxx . . $ stpi_softweave#vmod.]); |
| 1253 | } |
| 1254 | |
| 1255 | static stp_linebounds_tcxx . . $ stp_linebounds_t# * |
| 1256 | stpi_get_lineboundscxx . . $ stpi_get_linebounds(d251c61b600a1ca1).(const stp_vars_tcxx . . $ stp_vars_t# *v, stpi_softweave_tcxx . . $ stpi_softweave_t# *sw, |
| 1257 | int row, int subpass, int offset) |
| 1258 | { |
| 1259 | stp_weave_tcxx . . $ stp_weave_t# w; |
| 1260 | weave_parameters_by_rowcxx . . $ weave_parameters_by_row(6948d9d8b6898345).(v, sw, row + offset, subpass, &w); |
| 1261 | return &(sw->lineboundscxx . . $ stpi_softweave#linebounds.[w.passcxx . . $ $anonymous_type_bcaa485bbb542c91_0#pass. % sw->vmodcxx . . $ stpi_softweave#vmod.]); |
| 1262 | } |
| 1263 | |
| 1264 | static stp_pass_tcxx . . $ stp_pass_t# * |
| 1265 | stpi_get_pass_by_rowcxx . . $ stpi_get_pass_by_row(c47193c54bea5c00).(stp_vars_tcxx . . $ stp_vars_t# *v, stpi_softweave_tcxx . . $ stpi_softweave_t# *sw, |
| 1266 | int row, int subpass,int offset) |
| 1267 | { |
| 1268 | stp_weave_tcxx . . $ stp_weave_t# w; |
| 1269 | weave_parameters_by_rowcxx . . $ weave_parameters_by_row(6948d9d8b6898345).(v, sw, row + offset, subpass, &w); |
| 1270 | return &(sw->passescxx . . $ stpi_softweave#passes.[w.passcxx . . $ $anonymous_type_bcaa485bbb542c91_0#pass. % sw->vmodcxx . . $ stpi_softweave#vmod.]); |
| 1271 | } |
| 1272 | |
| 1273 | stp_lineoff_tcxx . . $ stp_lineoff_t# * |
| 1274 | stp_get_lineoffsets_by_passcxx . . $ stp_get_lineoffsets_by_pass(76405e8e39d7c090).(const stp_vars_tcxx . . $ stp_vars_t# *v, int pass) |
| 1275 | { |
| 1276 | const stpi_softweave_tcxx . . $ stpi_softweave_t# *sw = get_swcxx . . $ get_sw(821cfaf20b80b407).(v); |
| 1277 | return &(sw->lineoffsetscxx . . $ stpi_softweave#lineoffsets.[pass % sw->vmodcxx . . $ stpi_softweave#vmod.]); |
| 1278 | } |
| 1279 | |
| 1280 | stp_lineactive_tcxx . . $ stp_lineactive_t# * |
| 1281 | stp_get_lineactive_by_passcxx . . $ stp_get_lineactive_by_pass(9c74d4d92755b24).(const stp_vars_tcxx . . $ stp_vars_t# *v, int pass) |
| 1282 | { |
| 1283 | const stpi_softweave_tcxx . . $ stpi_softweave_t# *sw = get_swcxx . . $ get_sw(821cfaf20b80b407).(v); |
| 1284 | return &(sw->lineactivecxx . . $ stpi_softweave#lineactive.[pass % sw->vmodcxx . . $ stpi_softweave#vmod.]); |
| 1285 | } |
| 1286 | |
| 1287 | stp_linecount_tcxx . . $ stp_linecount_t# * |
| 1288 | stp_get_linecount_by_passcxx . . $ stp_get_linecount_by_pass(609db6c57e04d78).(const stp_vars_tcxx . . $ stp_vars_t# *v, int pass) |
| 1289 | { |
| 1290 | const stpi_softweave_tcxx . . $ stpi_softweave_t# *sw = get_swcxx . . $ get_sw(821cfaf20b80b407).(v); |
| 1291 | return &(sw->linecountscxx . . $ stpi_softweave#linecounts.[pass % sw->vmodcxx . . $ stpi_softweave#vmod.]); |
| 1292 | } |
| 1293 | |
| 1294 | const stp_linebufs_tcxx . . $ stp_linebufs_t# * |
| 1295 | stp_get_linebases_by_passcxx . . $ stp_get_linebases_by_pass(bb0e838850c47750).(const stp_vars_tcxx . . $ stp_vars_t# *v, int pass) |
| 1296 | { |
| 1297 | const stpi_softweave_tcxx . . $ stpi_softweave_t# *sw = get_swcxx . . $ get_sw(821cfaf20b80b407).(v); |
| 1298 | return &(sw->linebasescxx . . $ stpi_softweave#linebases.[pass % sw->vmodcxx . . $ stpi_softweave#vmod.]); |
| 1299 | } |
| 1300 | |
| 1301 | stp_pass_tcxx . . $ stp_pass_t# * |
| 1302 | stp_get_pass_by_passcxx . . $ stp_get_pass_by_pass(497f042961eb7c51).(const stp_vars_tcxx . . $ stp_vars_t# *v, int pass) |
| 1303 | { |
| 1304 | const stpi_softweave_tcxx . . $ stpi_softweave_t# *sw = get_swcxx . . $ get_sw(821cfaf20b80b407).(v); |
| 1305 | return &(sw->passescxx . . $ stpi_softweave#passes.[pass % sw->vmodcxx . . $ stpi_softweave#vmod.]); |
| 1306 | } |
| 1307 | |
| 1308 | static void |
| 1309 | check_linebasescxx . . $ check_linebases(cfe8b1ad425e2ec4).(stp_vars_tcxx . . $ stp_vars_t# *v, stpi_softweave_tcxx . . $ stpi_softweave_t# *sw, |
| 1310 | int row, int cpass, int head_offset, int color) |
| 1311 | { |
| 1312 | stp_linebufs_tcxx . . $ stp_linebufs_t# *bufs = |
| 1313 | (stp_linebufs_tcxx . . $ stp_linebufs_t# *) stpi_get_linebasescxx . . $ stpi_get_linebases(7875a90f91ede3b5).(v, sw, row, cpass, head_offset); |
| 1314 | if (!(bufs->vcxx . . $ $anonymous_type_bcaa485bbb542c91_5#v.[color])) |
| 1315 | bufs->vcxx . . $ $anonymous_type_bcaa485bbb542c91_5#v.[color] = |
| 1316 | stp_zalloccxx . . $ stp_zalloc(bfcfa4d6b7f7ef64). (sw->virtual_jetscxx . . $ stpi_softweave#virtual_jets. * sw->bitwidthcxx . . $ stpi_softweave#bitwidth. * sw->horizontal_widthcxx . . $ stpi_softweave#horizontal_width.); |
| 1317 | } |
| 1318 | |
| 1319 | /* |
| 1320 | * If there are phantom rows at the beginning of a pass, fill them in so |
| 1321 | * that the printer knows exactly what it doesn't have to print. We're |
| 1322 | * using RLE compression here. Each line must be specified independently, |
| 1323 | * so we have to compute how many full blocks (groups of 128 bytes, or 1024 |
| 1324 | * "off" pixels) and how much leftover is needed. Note that we can only |
| 1325 | * RLE-encode groups of 2 or more bytes; single bytes must be specified |
| 1326 | * with a count of 1. |
| 1327 | */ |
| 1328 | |
| 1329 | void |
| 1330 | stp_fill_tiffcxx . . $ stp_fill_tiff(7a0514de46275760).(stp_vars_tcxx . . $ stp_vars_t# *v, int row, int subpass, |
| 1331 | int width, int missingstartrows, int color) |
| 1332 | { |
| 1333 | stpi_softweave_tcxx . . $ stpi_softweave_t# *sw = get_swcxx . . $ get_sw(821cfaf20b80b407).(v); |
| 1334 | stp_lineoff_tcxx . . $ stp_lineoff_t# *lineoffs; |
| 1335 | stp_linecount_tcxx . . $ stp_linecount_t# *linecount; |
| 1336 | const stp_linebufs_tcxx . . $ stp_linebufs_t# *bufs; |
| 1337 | int i = 0; |
| 1338 | int k = 0; |
| 1339 | |
| 1340 | width = sw->bitwidthcxx . . $ stpi_softweave#bitwidth. * width * 8; |
| 1341 | for (k = 0; k < missingstartrows; k++) |
| 1342 | { |
| 1343 | int bytes_to_fill = width; |
| 1344 | int full_blocks = bytes_to_fill / (128 * 8); |
| 1345 | int leftover = (7 + (bytes_to_fill % (128 * 8))) / 8; |
| 1346 | int l = 0; |
| 1347 | bufs = stpi_get_linebasescxx . . $ stpi_get_linebases(7875a90f91ede3b5).(v, sw, row, subpass, sw->head_offsetcxx . . $ stpi_softweave#head_offset.[color]); |
| 1348 | |
| 1349 | while (l < full_blocks) |
| 1350 | { |
| 1351 | (bufs->vcxx . . $ $anonymous_type_bcaa485bbb542c91_5#v.[color][2 * i]) = 129; |
| 1352 | (bufs->vcxx . . $ $anonymous_type_bcaa485bbb542c91_5#v.[color][2 * i + 1]) = 0; |
| 1353 | i++; |
| 1354 | l++; |
| 1355 | } |
| 1356 | if (leftover == 1) |
| 1357 | { |
| 1358 | (bufs->vcxx . . $ $anonymous_type_bcaa485bbb542c91_5#v.[color][2 * i]) = 1; |
| 1359 | (bufs->vcxx . . $ $anonymous_type_bcaa485bbb542c91_5#v.[color][2 * i + 1]) = 0; |
| 1360 | i++; |
| 1361 | } |
| 1362 | else if (leftover > 0) |
| 1363 | { |
| 1364 | (bufs->vcxx . . $ $anonymous_type_bcaa485bbb542c91_5#v.[color][2 * i]) = 257 - leftover; |
| 1365 | (bufs->vcxx . . $ $anonymous_type_bcaa485bbb542c91_5#v.[color][2 * i + 1]) = 0; |
| 1366 | i++; |
| 1367 | } |
| 1368 | } |
| 1369 | |
| 1370 | lineoffs = stpi_get_lineoffsetscxx . . $ stpi_get_lineoffsets(bda34ccbee190ce3).(v, sw, row, subpass, sw->head_offsetcxx . . $ stpi_softweave#head_offset.[color]); |
| 1371 | linecount = stpi_get_linecountcxx . . $ stpi_get_linecount(d7e8f0406324f842).(v, sw, row, subpass, sw->head_offsetcxx . . $ stpi_softweave#head_offset.[color]); |
| 1372 | lineoffs->vcxx . . $ $anonymous_type_bcaa485bbb542c91_2#v.[color] = 2 * i; |
| 1373 | linecount->vcxx . . $ $anonymous_type_bcaa485bbb542c91_4#v.[color] = missingstartrows; |
| 1374 | } |
| 1375 | |
| 1376 | void |
| 1377 | stp_fill_uncompressedcxx . . $ stp_fill_uncompressed(7a0514de46275760).(stp_vars_tcxx . . $ stp_vars_t# *v, int row, int subpass, |
| 1378 | int width, int missingstartrows, int color) |
| 1379 | { |
| 1380 | stpi_softweave_tcxx . . $ stpi_softweave_t# *sw = get_swcxx . . $ get_sw(821cfaf20b80b407).(v); |
| 1381 | stp_lineoff_tcxx . . $ stp_lineoff_t# *lineoffs; |
| 1382 | stp_linecount_tcxx . . $ stp_linecount_t# *linecount; |
| 1383 | const stp_linebufs_tcxx . . $ stp_linebufs_t# *bufs; |
| 1384 | |
| 1385 | bufs = stpi_get_linebasescxx . . $ stpi_get_linebases(7875a90f91ede3b5).(v, sw, row, subpass, sw->head_offsetcxx . . $ stpi_softweave#head_offset.[color]); |
| 1386 | lineoffs = stpi_get_lineoffsetscxx . . $ stpi_get_lineoffsets(bda34ccbee190ce3).(v, sw, row, subpass, sw->head_offsetcxx . . $ stpi_softweave#head_offset.[color]); |
| 1387 | linecount = stpi_get_linecountcxx . . $ stpi_get_linecount(d7e8f0406324f842).(v, sw, row, subpass, sw->head_offsetcxx . . $ stpi_softweave#head_offset.[color]); |
| 1388 | width *= sw->bitwidthcxx . . $ stpi_softweave#bitwidth. * missingstartrows; |
| 1389 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(bufs->vcxx . . $ $anonymous_type_bcaa485bbb542c91_5#v.[color], 0, width); |
| 1390 | lineoffs->vcxx . . $ $anonymous_type_bcaa485bbb542c91_2#v.[color] = width; |
| 1391 | linecount->vcxx . . $ $anonymous_type_bcaa485bbb542c91_4#v.[color] = missingstartrows; |
| 1392 | } |
| 1393 | |
| 1394 | int |
| 1395 | stp_compute_tiff_linewidthcxx . . $ stp_compute_tiff_linewidth(91704a15f9368999).(stp_vars_tcxx . . $ stp_vars_t# *v, int n) |
| 1396 | { |
| 1397 | (void)v; |
| 1398 | /* |
| 1399 | * It's possible for the "compression" to actually expand the line by |
| 1400 | * roughly one part in 128. |
| 1401 | */ |
| 1402 | return ((n + 128 + 7) * 129 / 128); |
| 1403 | } |
| 1404 | |
| 1405 | int |
| 1406 | stp_compute_uncompressed_linewidthcxx . . $ stp_compute_uncompressed_linewidth(91704a15f9368999).(stp_vars_tcxx . . $ stp_vars_t# *v, int n) |
| 1407 | { |
| 1408 | (void)v; |
| 1409 | return (8 * ((n + 7) / 8)); |
| 1410 | } |
| 1411 | |
| 1412 | static void |
| 1413 | initialize_rowcxx . . $ initialize_row(5d3bd2a8f01ef399).(stp_vars_tcxx . . $ stp_vars_t# *v, stpi_softweave_tcxx . . $ stpi_softweave_t# *sw, |
| 1414 | int row, int width, unsigned char *const cols[]) |
| 1415 | { |
| 1416 | stp_weave_tcxx . . $ stp_weave_t# w; |
| 1417 | int i, j, jj; |
| 1418 | stp_pass_tcxx . . $ stp_pass_t# *pass; |
| 1419 | |
| 1420 | for (i = 0; i < sw->oversamplecxx . . $ stpi_softweave#oversample.; i++) |
| 1421 | { |
| 1422 | for (j = 0; j < sw->ncolorscxx . . $ stpi_softweave#ncolors.; j++) |
| 1423 | { |
| 1424 | if (cols[j]) |
| 1425 | { |
| 1426 | stp_lineoff_tcxx . . $ stp_lineoff_t# *lineoffs = |
| 1427 | stpi_get_lineoffsetscxx . . $ stpi_get_lineoffsets(bda34ccbee190ce3).(v, sw, row, i, sw->head_offsetcxx . . $ stpi_softweave#head_offset.[j]); |
| 1428 | stp_lineactive_tcxx . . $ stp_lineactive_t# *lineactive = |
| 1429 | stpi_get_lineactivecxx . . $ stpi_get_lineactive(78e4cbbfa629d95e).(v, sw, row, i, sw->head_offsetcxx . . $ stpi_softweave#head_offset.[j]); |
| 1430 | stp_linecount_tcxx . . $ stp_linecount_t# *linecount = |
| 1431 | stpi_get_linecountcxx . . $ stpi_get_linecount(d7e8f0406324f842).(v, sw, row, i, sw->head_offsetcxx . . $ stpi_softweave#head_offset.[j]); |
| 1432 | stp_linebounds_tcxx . . $ stp_linebounds_t# *linebounds = |
| 1433 | stpi_get_lineboundscxx . . $ stpi_get_linebounds(d251c61b600a1ca1).(v, sw, row, i, sw->head_offsetcxx . . $ stpi_softweave#head_offset.[j]); |
| 1434 | check_linebasescxx . . $ check_linebases(cfe8b1ad425e2ec4).(v, sw, row, i, sw->head_offsetcxx . . $ stpi_softweave#head_offset.[j], j); |
| 1435 | weave_parameters_by_rowcxx . . $ weave_parameters_by_row(6948d9d8b6898345).(v, sw, row+sw->head_offsetcxx . . $ stpi_softweave#head_offset.[j], i, &w); |
| 1436 | pass = stpi_get_pass_by_rowcxx . . $ stpi_get_pass_by_row(c47193c54bea5c00).(v, sw, row, i, sw->head_offsetcxx . . $ stpi_softweave#head_offset.[j]); |
| 1437 | |
| 1438 | /* initialize pass if not initialized yet */ |
| 1439 | if (pass->passcxx . . $ $anonymous_type_bcaa485bbb542c91_1#pass. < 0) |
| 1440 | { |
| 1441 | pass->passcxx . . $ $anonymous_type_bcaa485bbb542c91_1#pass. = w.passcxx . . $ $anonymous_type_bcaa485bbb542c91_0#pass.; |
| 1442 | pass->missingstartrowscxx . . $ $anonymous_type_bcaa485bbb542c91_1#missingstartrows. = w.missingstartrowscxx . . $ $anonymous_type_bcaa485bbb542c91_0#missingstartrows.; |
| 1443 | pass->logicalpassstartcxx . . $ $anonymous_type_bcaa485bbb542c91_1#logicalpassstart. = w.logicalpassstartcxx . . $ $anonymous_type_bcaa485bbb542c91_0#logicalpassstart.; |
| 1444 | pass->physpassstartcxx . . $ $anonymous_type_bcaa485bbb542c91_1#physpassstart. = w.physpassstartcxx . . $ $anonymous_type_bcaa485bbb542c91_0#physpassstart.; |
| 1445 | pass->physpassendcxx . . $ $anonymous_type_bcaa485bbb542c91_1#physpassend. = w.physpassendcxx . . $ $anonymous_type_bcaa485bbb542c91_0#physpassend.; |
| 1446 | pass->subpasscxx . . $ $anonymous_type_bcaa485bbb542c91_1#subpass. = i; |
| 1447 | |
| 1448 | for(jj=0; jj<sw->ncolorscxx . . $ stpi_softweave#ncolors.; jj++) |
| 1449 | { |
| 1450 | if (lineoffs->vcxx . . $ $anonymous_type_bcaa485bbb542c91_2#v.[jj] != 0) |
| 1451 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "WARNING: pass %d subpass %d row %d: " |
| 1452 | "lineoffs %ld should be zero!\n", |
| 1453 | w.passcxx . . $ $anonymous_type_bcaa485bbb542c91_0#pass., i, row, lineoffs->vcxx . . $ $anonymous_type_bcaa485bbb542c91_2#v.[jj]); |
| 1454 | lineoffs->vcxx . . $ $anonymous_type_bcaa485bbb542c91_2#v.[jj] = 0; |
| 1455 | lineactive->vcxx . . $ $anonymous_type_bcaa485bbb542c91_3#v.[jj] = 0; |
| 1456 | if (linecount->vcxx . . $ $anonymous_type_bcaa485bbb542c91_4#v.[jj] != 0) |
| 1457 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "WARNING: pass %d subpass %d row %d: " |
| 1458 | "linecount %d should be zero!\n", |
| 1459 | w.passcxx . . $ $anonymous_type_bcaa485bbb542c91_0#pass., i, row, linecount->vcxx . . $ $anonymous_type_bcaa485bbb542c91_4#v.[jj]); |
| 1460 | linecount->vcxx . . $ $anonymous_type_bcaa485bbb542c91_4#v.[jj] = 0; |
| 1461 | linebounds->start_poscxx . . $ $anonymous_type_bcaa485bbb542c91_6#start_pos.[jj] = INT_MAXcxx . . $ `<external>/67164224788392828/limits.h:120:9`!; |
| 1462 | linebounds->end_poscxx . . $ $anonymous_type_bcaa485bbb542c91_6#end_pos.[jj] = -1; |
| 1463 | } |
| 1464 | } |
| 1465 | |
| 1466 | if((linecount->vcxx . . $ $anonymous_type_bcaa485bbb542c91_4#v.[j] == 0) && (w.jetcxx . . $ $anonymous_type_bcaa485bbb542c91_0#jet. > 0)) |
| 1467 | { |
| 1468 | (sw->fillfunccxx . . $ stpi_softweave#fillfunc.)(v, row, i, width, w.jetcxx . . $ $anonymous_type_bcaa485bbb542c91_0#jet., j); |
| 1469 | } |
| 1470 | } |
| 1471 | } |
| 1472 | } |
| 1473 | } |
| 1474 | |
| 1475 | static void |
| 1476 | add_to_row_1cxx . . $ add_to_row_1(32228e2430e8a82f).(stp_vars_tcxx . . $ stp_vars_t# *v, stpi_softweave_tcxx . . $ stpi_softweave_t# *sw, int row, unsigned char *buf, |
| 1477 | size_t nbytes, int color, int setactive, int h_pass) |
| 1478 | { |
| 1479 | const stp_linebufs_tcxx . . $ stp_linebufs_t# *bufs = |
| 1480 | stpi_get_linebasescxx . . $ stpi_get_linebases(7875a90f91ede3b5).(v, sw, sw->linenocxx . . $ stpi_softweave#lineno., h_pass, sw->head_offsetcxx . . $ stpi_softweave#head_offset.[color]); |
| 1481 | stp_lineoff_tcxx . . $ stp_lineoff_t# *lineoffs = |
| 1482 | stpi_get_lineoffsetscxx . . $ stpi_get_lineoffsets(bda34ccbee190ce3).(v, sw, sw->linenocxx . . $ stpi_softweave#lineno., h_pass, sw->head_offsetcxx . . $ stpi_softweave#head_offset.[color]); |
| 1483 | stp_lineactive_tcxx . . $ stp_lineactive_t# *lineactive = |
| 1484 | stpi_get_lineactivecxx . . $ stpi_get_lineactive(78e4cbbfa629d95e).(v, sw, sw->linenocxx . . $ stpi_softweave#lineno., h_pass, sw->head_offsetcxx . . $ stpi_softweave#head_offset.[color]); |
| 1485 | stp_linecount_tcxx . . $ stp_linecount_t# *linecount = |
| 1486 | stpi_get_linecountcxx . . $ stpi_get_linecount(d7e8f0406324f842).(v, sw, sw->linenocxx . . $ stpi_softweave#lineno., h_pass, sw->head_offsetcxx . . $ stpi_softweave#head_offset.[color]); |
| 1487 | size_t place = lineoffs->vcxx . . $ $anonymous_type_bcaa485bbb542c91_2#v.[color]; |
| 1488 | size_t count = linecount->vcxx . . $ $anonymous_type_bcaa485bbb542c91_4#v.[color]; |
| 1489 | if (place + nbytes > sw->virtual_jetscxx . . $ stpi_softweave#virtual_jets. * sw->bitwidthcxx . . $ stpi_softweave#bitwidth. * sw->horizontal_widthcxx . . $ stpi_softweave#horizontal_width.) |
| 1490 | { |
| 1491 | int i; |
| 1492 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: %s\n", _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Fatal error!")); |
| 1493 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: Static weave data follows:\n"); |
| 1494 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: jets: %d\n", sw->jetscxx . . $ stpi_softweave#jets.); |
| 1495 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: virtual_jets: %d\n", sw->virtual_jetscxx . . $ stpi_softweave#virtual_jets.); |
| 1496 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: separation: %d\n", sw->separationcxx . . $ stpi_softweave#separation.); |
| 1497 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: horizontal_weave: %d\n", sw->horizontal_weavecxx . . $ stpi_softweave#horizontal_weave.); |
| 1498 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: vertical_subpasses: %d\n", sw->vertical_subpassescxx . . $ stpi_softweave#vertical_subpasses.); |
| 1499 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: vmod: %d\n", sw->vmodcxx . . $ stpi_softweave#vmod.); |
| 1500 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: oversample: %d\n", sw->oversamplecxx . . $ stpi_softweave#oversample.); |
| 1501 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: repeat_count: %d\n", sw->repeat_countcxx . . $ stpi_softweave#repeat_count.); |
| 1502 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: ncolors: %d\n", sw->ncolorscxx . . $ stpi_softweave#ncolors.); |
| 1503 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: linewidth: %d\n", sw->linewidthcxx . . $ stpi_softweave#linewidth.); |
| 1504 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: vertical_height: %d\n", sw->vertical_heightcxx . . $ stpi_softweave#vertical_height.); |
| 1505 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: firstline: %d\n", sw->firstlinecxx . . $ stpi_softweave#firstline.); |
| 1506 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: bitwidth: %d\n", sw->bitwidthcxx . . $ stpi_softweave#bitwidth.); |
| 1507 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: vertical_oversample: %d\n", sw->vertical_oversamplecxx . . $ stpi_softweave#vertical_oversample.); |
| 1508 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: horizontal_width: %d\n", sw->horizontal_widthcxx . . $ stpi_softweave#horizontal_width.); |
| 1509 | if (sw->head_offsetcxx . . $ stpi_softweave#head_offset.) |
| 1510 | { |
| 1511 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: head_offset:\n"); |
| 1512 | for (i = 0; i < sw->ncolorscxx . . $ stpi_softweave#ncolors.; i++) |
| 1513 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: head %d: %d\n", i, sw->head_offsetcxx . . $ stpi_softweave#head_offset.[i]); |
| 1514 | } |
| 1515 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: Dynamic weave data follows:\n"); |
| 1516 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: last_pass_offset: %d\n", sw->last_pass_offsetcxx . . $ stpi_softweave#last_pass_offset.); |
| 1517 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: last_pass: %d\n", sw->last_passcxx . . $ stpi_softweave#last_pass.); |
| 1518 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: lineno: %d\n", sw->linenocxx . . $ stpi_softweave#lineno.); |
| 1519 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: current_vertical_subpass: %d\n", sw->current_vertical_subpasscxx . . $ stpi_softweave#current_vertical_subpass.); |
| 1520 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: rcache: %d\n", sw->rcachecxx . . $ stpi_softweave#rcache.); |
| 1521 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: vcache: %d\n", sw->vcachecxx . . $ stpi_softweave#vcache.); |
| 1522 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: Other parameters: row %d color %d setactive %d hpass %d\n", |
| 1523 | row, color, setactive, h_pass); |
| 1524 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: Buffer overflow: limit %d (jets %d bits %d horizontal %d), actual %ld (current %d added %d), count %ld\n", |
| 1525 | sw->virtual_jetscxx . . $ stpi_softweave#virtual_jets. * sw->bitwidthcxx . . $ stpi_softweave#bitwidth. * sw->horizontal_widthcxx . . $ stpi_softweave#horizontal_width., |
| 1526 | sw->virtual_jetscxx . . $ stpi_softweave#virtual_jets., sw->bitwidthcxx . . $ stpi_softweave#bitwidth., sw->horizontal_widthcxx . . $ stpi_softweave#horizontal_width., |
| 1527 | (long) (place + nbytes), (int) place, (int) nbytes, (long) count); |
| 1528 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: %s\n", _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Please report the above information to [email protected]")); |
| 1529 | stp_abortcxx . . $ stp_abort(49f6e7a06ebc5aa8).(); |
| 1530 | } |
| 1531 | memcpycxx . . $ memcpy(cc817cb175f282d).(bufs->vcxx . . $ $anonymous_type_bcaa485bbb542c91_5#v.[color] + lineoffs->vcxx . . $ $anonymous_type_bcaa485bbb542c91_2#v.[color], buf, nbytes); |
| 1532 | lineoffs->vcxx . . $ $anonymous_type_bcaa485bbb542c91_2#v.[color] += nbytes; |
| 1533 | if (setactive) |
| 1534 | lineactive->vcxx . . $ $anonymous_type_bcaa485bbb542c91_3#v.[color] = 1; |
| 1535 | } |
| 1536 | |
| 1537 | static void |
| 1538 | add_to_rowcxx . . $ add_to_row(32228e2430e8a82f).(stp_vars_tcxx . . $ stp_vars_t# *v, stpi_softweave_tcxx . . $ stpi_softweave_t# *sw, int row, unsigned char *buf, |
| 1539 | size_t nbytes, int color, int setactive, int h_pass) |
| 1540 | { |
| 1541 | if (!sw->head_offsetcxx . . $ stpi_softweave#head_offset.) |
| 1542 | { |
| 1543 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: %s\n", _cxx . . $ `include/gutenprint/gutenprint-intl-internal.h:58:11`!("Fatal error!")); |
| 1544 | stp_eprintfcxx . . $ stp_eprintf(7aef7aa9b820d38).(v, "ERROR: add_to_row: sw->head_offset == NULL\n"); |
| 1545 | return; |
| 1546 | } |
| 1547 | add_to_row_1cxx . . $ add_to_row_1(32228e2430e8a82f).(v, sw, row, buf, nbytes, color, setactive, h_pass); |
| 1548 | } |
| 1549 | |
| 1550 | static void |
| 1551 | stpi_flush_passescxx . . $ stpi_flush_passes(c8b26ae77f1a10bd).(stp_vars_tcxx . . $ stp_vars_t# *v, int flushall) |
| 1552 | { |
| 1553 | stpi_softweave_tcxx . . $ stpi_softweave_t# *sw = get_swcxx . . $ get_sw(821cfaf20b80b407).(v); |
| 1554 | while (1) |
| 1555 | { |
| 1556 | stp_pass_tcxx . . $ stp_pass_t# *pass = stp_get_pass_by_passcxx . . $ stp_get_pass_by_pass(497f042961eb7c51).(v, sw->last_passcxx . . $ stpi_softweave#last_pass. + 1); |
| 1557 | /* |
| 1558 | * This ought to be pass->physpassend > sw->lineno |
| 1559 | * but that causes rubbish to be output for some reason. |
| 1560 | */ |
| 1561 | if (pass->passcxx . . $ $anonymous_type_bcaa485bbb542c91_1#pass. < 0 || (!flushall && pass->physpassendcxx . . $ $anonymous_type_bcaa485bbb542c91_1#physpassend. >= sw->linenocxx . . $ stpi_softweave#lineno.)) |
| 1562 | return; |
| 1563 | (sw->flushfunccxx . . $ stpi_softweave#flushfunc.)(v, pass->passcxx . . $ $anonymous_type_bcaa485bbb542c91_1#pass., pass->subpasscxx . . $ $anonymous_type_bcaa485bbb542c91_1#subpass.); |
| 1564 | sw->last_passcxx . . $ stpi_softweave#last_pass. = pass->passcxx . . $ $anonymous_type_bcaa485bbb542c91_1#pass.; |
| 1565 | pass->passcxx . . $ $anonymous_type_bcaa485bbb542c91_1#pass. = -1; |
| 1566 | } |
| 1567 | } |
| 1568 | |
| 1569 | void |
| 1570 | stp_flush_allcxx . . $ stp_flush_all(1a97b8462f9f913c).(stp_vars_tcxx . . $ stp_vars_t# *v) |
| 1571 | { |
| 1572 | stpi_flush_passescxx . . $ stpi_flush_passes(c8b26ae77f1a10bd).(v, 1); |
| 1573 | } |
| 1574 | |
| 1575 | static void |
| 1576 | finalize_rowcxx . . $ finalize_row(6be2d0fde82f98a8).(stp_vars_tcxx . . $ stp_vars_t# *v, stpi_softweave_tcxx . . $ stpi_softweave_t# *sw) |
| 1577 | { |
| 1578 | int row = sw->linenocxx . . $ stpi_softweave#lineno.; |
| 1579 | int i,j; |
| 1580 | stp_dprintfcxx . . $ stp_dprintf(13526ca24396f6ac).(STP_DBG_ROWScxx . . $ `include/gutenprint/util.h:175:9`!, v, "Finalizing row %d...\n", row); |
| 1581 | for (i = 0; i < sw->oversamplecxx . . $ stpi_softweave#oversample.; i++) |
| 1582 | { |
| 1583 | stp_weave_tcxx . . $ stp_weave_t# w; |
| 1584 | stp_linecount_tcxx . . $ stp_linecount_t# *lines; |
| 1585 | |
| 1586 | for(j=0; j<sw->ncolorscxx . . $ stpi_softweave#ncolors.; j++) |
| 1587 | { |
| 1588 | lines = stpi_get_linecountcxx . . $ stpi_get_linecount(d7e8f0406324f842).(v, sw, row, i, sw->head_offsetcxx . . $ stpi_softweave#head_offset.[j]); |
| 1589 | lines->vcxx . . $ $anonymous_type_bcaa485bbb542c91_4#v.[j]++; |
| 1590 | } |
| 1591 | |
| 1592 | weave_parameters_by_rowcxx . . $ weave_parameters_by_row(6948d9d8b6898345).(v, sw, row, i, &w); |
| 1593 | if (w.physpassendcxx . . $ $anonymous_type_bcaa485bbb542c91_0#physpassend. == row) |
| 1594 | { |
| 1595 | stp_dprintfcxx . . $ stp_dprintf(13526ca24396f6ac).(STP_DBG_ROWScxx . . $ `include/gutenprint/util.h:175:9`!, v, |
| 1596 | "Pass=%d, physpassend=%d, row=%d, lineno=%d, flush..\n", |
| 1597 | w.passcxx . . $ $anonymous_type_bcaa485bbb542c91_0#pass., w.physpassendcxx . . $ $anonymous_type_bcaa485bbb542c91_0#physpassend., row, sw->linenocxx . . $ stpi_softweave#lineno.); |
| 1598 | stpi_flush_passescxx . . $ stpi_flush_passes(c8b26ae77f1a10bd).(v, 0); |
| 1599 | } |
| 1600 | } |
| 1601 | } |
| 1602 | |
| 1603 | void |
| 1604 | stp_write_weavecxx . . $ stp_write_weave(6cdd413d772848ad).(stp_vars_tcxx . . $ stp_vars_t# *v, unsigned char *const cols[]) |
| 1605 | { |
| 1606 | stpi_softweave_tcxx . . $ stpi_softweave_t# *sw = get_swcxx . . $ get_sw(821cfaf20b80b407).(v); |
| 1607 | int length = (sw->linewidthcxx . . $ stpi_softweave#linewidth. + 7) / 8; |
| 1608 | stp_linebounds_tcxx . . $ stp_linebounds_t# *linebounds[STP_MAX_WEAVEcxx . . $ `include/gutenprint/weave.h:46:9`!]; |
| 1609 | int xlength = (length + sw->horizontal_weavecxx . . $ stpi_softweave#horizontal_weave. - 1) / sw->horizontal_weavecxx . . $ stpi_softweave#horizontal_weave.; |
| 1610 | int ylength = xlength * sw->horizontal_weavecxx . . $ stpi_softweave#horizontal_weave.; |
| 1611 | unsigned char *comp_ptr; |
| 1612 | int i, j; |
| 1613 | int setactive; |
| 1614 | int h_passes = sw->horizontal_weavecxx . . $ stpi_softweave#horizontal_weave. * sw->vertical_subpassescxx . . $ stpi_softweave#vertical_subpasses.; |
| 1615 | int cpass = sw->current_vertical_subpasscxx . . $ stpi_softweave#current_vertical_subpass. * h_passes; |
| 1616 | |
| 1617 | if (!sw->fold_bufcxx . . $ stpi_softweave#fold_buf.) |
| 1618 | { |
| 1619 | stp_dprintfcxx . . $ stp_dprintf(13526ca24396f6ac).(STP_DBG_WEAVE_PARAMScxx . . $ `include/gutenprint/util.h:174:9`!, v, |
| 1620 | "fold buffer allocation: length %d lw %d weave %d xlength %d ylength %d\n", |
| 1621 | length, sw->linewidthcxx . . $ stpi_softweave#linewidth., sw->horizontal_weavecxx . . $ stpi_softweave#horizontal_weave., xlength, ylength); |
| 1622 | stp_dprintfcxx . . $ stp_dprintf(13526ca24396f6ac).(STP_DBG_WEAVE_PARAMScxx . . $ `include/gutenprint/util.h:174:9`!, v, |
| 1623 | "Allocating fold buf %d * %d (%d)\n", ylength, sw->bitwidthcxx . . $ stpi_softweave#bitwidth., |
| 1624 | sw->bitwidthcxx . . $ stpi_softweave#bitwidth. * ylength); |
| 1625 | sw->fold_bufcxx . . $ stpi_softweave#fold_buf. = stp_zalloccxx . . $ stp_zalloc(bfcfa4d6b7f7ef64).(sw->bitwidthcxx . . $ stpi_softweave#bitwidth. * ylength); |
| 1626 | } |
| 1627 | if (!sw->comp_bufcxx . . $ stpi_softweave#comp_buf.) |
| 1628 | { |
| 1629 | stp_dprintfcxx . . $ stp_dprintf(13526ca24396f6ac).(STP_DBG_WEAVE_PARAMScxx . . $ `include/gutenprint/util.h:174:9`!, v, |
| 1630 | "Allocating compression buffer based on %d, %d\n", |
| 1631 | sw->bitwidthcxx . . $ stpi_softweave#bitwidth., ylength); |
| 1632 | sw->comp_bufcxx . . $ stpi_softweave#comp_buf. = stp_zalloccxx . . $ stp_zalloc(bfcfa4d6b7f7ef64).(sw->bitwidthcxx . . $ stpi_softweave#bitwidth. * |
| 1633 | (sw->compute_linewidthcxx . . $ stpi_softweave#compute_linewidth.)(v,ylength)); |
| 1634 | } |
| 1635 | if (sw->current_vertical_subpasscxx . . $ stpi_softweave#current_vertical_subpass. == 0) |
| 1636 | initialize_rowcxx . . $ initialize_row(5d3bd2a8f01ef399).(v, sw, sw->linenocxx . . $ stpi_softweave#lineno., xlength, cols); |
| 1637 | |
| 1638 | for (j = 0; j < sw->ncolorscxx . . $ stpi_softweave#ncolors.; j++) |
| 1639 | { |
| 1640 | if (cols[j]) |
| 1641 | { |
| 1642 | const unsigned char *in; |
| 1643 | int idx; |
| 1644 | |
| 1645 | for (i = 0; i < h_passes; i++) |
| 1646 | { |
| 1647 | int offset = sw->head_offsetcxx . . $ stpi_softweave#head_offset.[j]; |
| 1648 | int pass = cpass + i; |
| 1649 | if (!sw->scxx . . $ stpi_softweave#s.[i]) |
| 1650 | sw->scxx . . $ stpi_softweave#s.[i] = stp_zalloccxx . . $ stp_zalloc(bfcfa4d6b7f7ef64).(sw->bitwidthcxx . . $ stpi_softweave#bitwidth. * |
| 1651 | (sw->compute_linewidthcxx . . $ stpi_softweave#compute_linewidth.)(v, ylength)); |
| 1652 | linebounds[i] = |
| 1653 | stpi_get_lineboundscxx . . $ stpi_get_linebounds(d251c61b600a1ca1).(v, sw, sw->linenocxx . . $ stpi_softweave#lineno., pass, offset); |
| 1654 | } |
| 1655 | |
| 1656 | if (sw->bitwidthcxx . . $ stpi_softweave#bitwidth. == 2) |
| 1657 | { |
| 1658 | stp_foldcxx . . $ stp_fold(7127c6a555fcd89a).(cols[j], length, sw->fold_bufcxx . . $ stpi_softweave#fold_buf.); |
| 1659 | in = sw->fold_bufcxx . . $ stpi_softweave#fold_buf.; |
| 1660 | } |
| 1661 | else |
| 1662 | in = cols[j]; |
| 1663 | if (sw->horizontal_weavecxx . . $ stpi_softweave#horizontal_weave. == 1) |
| 1664 | memcpycxx . . $ memcpy(cc817cb175f282d).(sw->scxx . . $ stpi_softweave#s.[0], in, length * sw->bitwidthcxx . . $ stpi_softweave#bitwidth.); |
| 1665 | else |
| 1666 | stp_unpackcxx . . $ stp_unpack(79c8feae71b0e62d).(length, sw->bitwidthcxx . . $ stpi_softweave#bitwidth., sw->horizontal_weavecxx . . $ stpi_softweave#horizontal_weave., in, sw->scxx . . $ stpi_softweave#s.); |
| 1667 | if (sw->vertical_subpassescxx . . $ stpi_softweave#vertical_subpasses. > 1) |
| 1668 | { |
| 1669 | for (idx = 0; idx < sw->horizontal_weavecxx . . $ stpi_softweave#horizontal_weave.; idx++) |
| 1670 | stp_splitcxx . . $ stp_split(d3b79da7ecc484f7).(length, sw->bitwidthcxx . . $ stpi_softweave#bitwidth., sw->vertical_subpassescxx . . $ stpi_softweave#vertical_subpasses., |
| 1671 | sw->scxx . . $ stpi_softweave#s.[idx], sw->horizontal_weavecxx . . $ stpi_softweave#horizontal_weave., &(sw->scxx . . $ stpi_softweave#s.[idx])); |
| 1672 | } |
| 1673 | for (i = 0; i < h_passes; i++) |
| 1674 | { |
| 1675 | int first, last; |
| 1676 | setactive = (sw->packcxx . . $ stpi_softweave#pack.)(v, sw->scxx . . $ stpi_softweave#s.[i], sw->bitwidthcxx . . $ stpi_softweave#bitwidth. * xlength, |
| 1677 | sw->comp_bufcxx . . $ stpi_softweave#comp_buf., &comp_ptr, &first, &last); |
| 1678 | if (first < linebounds[i]->start_poscxx . . $ $anonymous_type_bcaa485bbb542c91_6#start_pos.[j]) |
| 1679 | linebounds[i]->start_poscxx . . $ $anonymous_type_bcaa485bbb542c91_6#start_pos.[j] = first; |
| 1680 | if (last > linebounds[i]->end_poscxx . . $ $anonymous_type_bcaa485bbb542c91_6#end_pos.[j]) |
| 1681 | linebounds[i]->end_poscxx . . $ $anonymous_type_bcaa485bbb542c91_6#end_pos.[j] = last; |
| 1682 | add_to_rowcxx . . $ add_to_row(32228e2430e8a82f).(v, sw, sw->linenocxx . . $ stpi_softweave#lineno., sw->comp_bufcxx . . $ stpi_softweave#comp_buf., |
| 1683 | comp_ptr - sw->comp_bufcxx . . $ stpi_softweave#comp_buf., j, setactive, cpass + i); |
| 1684 | } |
| 1685 | } |
| 1686 | } |
| 1687 | sw->current_vertical_subpasscxx . . $ stpi_softweave#current_vertical_subpass.++; |
| 1688 | if (sw->current_vertical_subpasscxx . . $ stpi_softweave#current_vertical_subpass. >= sw->vertical_oversamplecxx . . $ stpi_softweave#vertical_oversample.) |
| 1689 | { |
| 1690 | finalize_rowcxx . . $ finalize_row(6be2d0fde82f98a8).(v, sw); |
| 1691 | sw->linenocxx . . $ stpi_softweave#lineno.++; |
| 1692 | sw->current_vertical_subpasscxx . . $ stpi_softweave#current_vertical_subpass. = 0; |
| 1693 | } |
| 1694 | } |
| 1695 | |
| 1696 | #if 0 |
| 1697 | #define TEST_RAW |
| 1698 | #endif |
| 1699 | #if 0 |
| 1700 | #define TEST_COOKED |
| 1701 | #endif |
| 1702 | #if 0 |
| 1703 | #define ACCUMULATE |
| 1704 | #endif |
| 1705 | |
| 1706 | #if defined(TEST_RAW) || defined(TEST_COOKED) |
| 1707 | #define TEST |
| 1708 | #endif |
| 1709 | |
| 1710 | #ifdef TEST |
| 1711 | #define MAXCOLLECT (1000) |
| 1712 | #endif |
| 1713 | |
| 1714 | #ifdef TEST_COOKED |
| 1715 | static void |
| 1716 | calculate_pass_parameters(cooked_t *w, /* I - weave parameters */ |
| 1717 | int pass, /* I - pass number ( >= 0) */ |
| 1718 | int *startrow, /* O - print head position */ |
| 1719 | int *subpass, /* O - subpass number */ |
| 1720 | int *phantomrows, /* O - missing rows */ |
| 1721 | int *jetsused) /* O - jets used to print */ |
| 1722 | { |
| 1723 | int raw_pass = pass + w->first_premapped_pass; |
| 1724 | int stagger = 0; |
| 1725 | int extra; |
| 1726 | |
| 1727 | if (raw_pass < w->first_normal_pass) { |
| 1728 | int i = 0; |
| 1729 | while (i + w->first_premapped_pass < w->first_normal_pass) { |
| 1730 | if (w->pass_premap[i] == pass) { |
| 1731 | raw_pass = i + w->first_premapped_pass; |
| 1732 | stagger = w->stagger_premap[i]; |
| 1733 | break; |
| 1734 | } |
| 1735 | i++; |
| 1736 | } |
| 1737 | } else if (raw_pass >= w->first_postmapped_pass) { |
| 1738 | int i = 0; |
| 1739 | while (i + w->first_postmapped_pass < w->first_unused_pass) { |
| 1740 | if (w->pass_postmap[i] == pass) { |
| 1741 | raw_pass = i + w->first_postmapped_pass; |
| 1742 | stagger = w->stagger_postmap[i]; |
| 1743 | break; |
| 1744 | } |
| 1745 | i++; |
| 1746 | } |
| 1747 | } |
| 1748 | |
| 1749 | calculate_raw_pass_parameters(&w->rw, raw_pass, startrow, subpass); |
| 1750 | *startrow -= w->rw.separation * w->rw.jets; |
| 1751 | *jetsused = w->rw.jets; |
| 1752 | *phantomrows = 0; |
| 1753 | |
| 1754 | *startrow += stagger * w->rw.separation; |
| 1755 | if (stagger < 0) { |
| 1756 | stagger = -stagger; |
| 1757 | *phantomrows += stagger; |
| 1758 | } |
| 1759 | *jetsused -= stagger; |
| 1760 | |
| 1761 | extra = w->first_row_printed - (*startrow + w->rw.separation * *phantomrows); |
| 1762 | extra = (extra + w->rw.separation - 1) / w->rw.separation; |
| 1763 | if (extra > 0) { |
| 1764 | *jetsused -= extra; |
| 1765 | *phantomrows += extra; |
| 1766 | } |
| 1767 | |
| 1768 | extra = *startrow + w->rw.separation * (*phantomrows + *jetsused - 1) |
| 1769 | - w->last_row_printed; |
| 1770 | extra = (extra + w->rw.separation - 1) / w->rw.separation; |
| 1771 | if (extra > 0) { |
| 1772 | *jetsused -= extra; |
| 1773 | } |
| 1774 | } |
| 1775 | #endif /* TEST_COOKED */ |
| 1776 | |
| 1777 | #ifdef TEST |
| 1778 | |
| 1779 | #ifdef ACCUMULATE |
| 1780 | #define PUTCHAR(x) /* nothing */ |
| 1781 | #else |
| 1782 | #define PUTCHAR(x) putchar(x) |
| 1783 | #endif |
| 1784 | |
| 1785 | static void |
| 1786 | plotpass(int startrow, int phantomjets, int jetsused, int totaljets, |
| 1787 | int separation, int subpass, int *collect, int *prints) |
| 1788 | { |
| 1789 | int hpos, i; |
| 1790 | |
| 1791 | for (hpos = 0; hpos < startrow; hpos++) |
| 1792 | PUTCHAR(' '); |
| 1793 | |
| 1794 | for (i = 0; i < phantomjets; i++) { |
| 1795 | int j; |
| 1796 | PUTCHAR('X'); |
| 1797 | hpos++; |
| 1798 | for (j = 1; j < separation; j++) { |
| 1799 | PUTCHAR(' '); |
| 1800 | hpos++; |
| 1801 | } |
| 1802 | } |
| 1803 | |
| 1804 | for (; i < phantomjets + jetsused; i++) { |
| 1805 | if (i > phantomjets) { |
| 1806 | int j; |
| 1807 | for (j = 1; j < separation; j++) { |
| 1808 | PUTCHAR('-'); |
| 1809 | hpos++; |
| 1810 | } |
| 1811 | } |
| 1812 | if (hpos < MAXCOLLECT) { |
| 1813 | if (collect[hpos] & 1 << subpass) |
| 1814 | PUTCHAR('^'); |
| 1815 | else if (subpass < 10) |
| 1816 | PUTCHAR('0' + subpass); |
| 1817 | else |
| 1818 | PUTCHAR('A' + subpass - 10); |
| 1819 | collect[hpos] |= 1 << subpass; |
| 1820 | prints[hpos]++; |
| 1821 | } else { |
| 1822 | PUTCHAR('0' + subpass); |
| 1823 | } |
| 1824 | hpos++; |
| 1825 | } |
| 1826 | |
| 1827 | while (i++ < totaljets) { |
| 1828 | int j; |
| 1829 | for (j = 1; j < separation; j++) { |
| 1830 | PUTCHAR(' '); |
| 1831 | hpos++; |
| 1832 | } |
| 1833 | PUTCHAR('X'); |
| 1834 | } |
| 1835 | #ifdef ACCUMULATE |
| 1836 | for (i=0; i<=MAXCOLLECT; i++) { |
| 1837 | if (collect[i] == 0) |
| 1838 | putchar(' '); |
| 1839 | else if (collect[i] < 10) |
| 1840 | putchar('0'+collect[i]); |
| 1841 | else |
| 1842 | putchar('A'+collect[i]-10); |
| 1843 | } |
| 1844 | #endif |
| 1845 | putchar('\n'); |
| 1846 | } |
| 1847 | #endif /* TEST */ |
| 1848 | |
| 1849 | #ifdef TEST_COOKED |
| 1850 | int |
| 1851 | main(int ac, char *av[]) |
| 1852 | { |
| 1853 | int S =ac>1 ? atoi(av[1]) : 4; |
| 1854 | int J =ac>2 ? atoi(av[2]) : 12; |
| 1855 | int H =ac>3 ? atoi(av[3]) : 1; |
| 1856 | int firstrow =ac>4 ? atoi(av[4]) : 1; |
| 1857 | int lastrow =ac>5 ? atoi(av[5]) : 100; |
| 1858 | int pageheight=ac>6 ? atoi(av[6]) : 1000; |
| 1859 | stp_weave_strategy_t strategy =ac>7 ? atoi(av[7]) : 1; |
| 1860 | cooked_t *weave; |
| 1861 | int passes; |
| 1862 | |
| 1863 | int pass, x; |
| 1864 | int collect[MAXCOLLECT]; |
| 1865 | int prints[MAXCOLLECT]; |
| 1866 | |
| 1867 | memset(collect, 0, MAXCOLLECT*sizeof(int)); |
| 1868 | memset(prints, 0, MAXCOLLECT*sizeof(int)); |
| 1869 | printf("S=%d J=%d H=%d firstrow=%d lastrow=%d " |
| 1870 | "pageheight=%d strategy=%d\n", |
| 1871 | S, J, H, firstrow, lastrow, pageheight, strategy); |
| 1872 | |
| 1873 | weave = initialize_weave_params(S, J, H, firstrow, lastrow, |
| 1874 | pageheight, strategy); |
| 1875 | passes = weave->first_unused_pass - weave->first_premapped_pass; |
| 1876 | |
| 1877 | for (pass = 0; pass < passes; pass++) { |
| 1878 | int startrow, subpass, phantomjets, jetsused; |
| 1879 | |
| 1880 | calculate_pass_parameters(weave, pass, &startrow, &subpass, |
| 1881 | &phantomjets, &jetsused); |
| 1882 | |
| 1883 | plotpass(startrow, phantomjets, jetsused, J, S, subpass, |
| 1884 | collect, prints); |
| 1885 | } |
| 1886 | |
| 1887 | for (pass=MAXCOLLECT - 1; prints[pass] == 0; pass--) |
| 1888 | ; |
| 1889 | |
| 1890 | for (x=0; x<=pass; x++) { |
| 1891 | if (collect[x] < 10) |
| 1892 | putchar('0'+collect[x]); |
| 1893 | else |
| 1894 | putchar('A'+collect[x]-10); |
| 1895 | } |
| 1896 | putchar('\n'); |
| 1897 | |
| 1898 | for (x=0; x<=pass; x++) { |
| 1899 | if (prints[x] < 10) |
| 1900 | putchar('0'+prints[x]); |
| 1901 | else |
| 1902 | putchar('A'+prints[x]-10); |
| 1903 | } |
| 1904 | putchar('\n'); |
| 1905 | |
| 1906 | return 0; |
| 1907 | } |
| 1908 | #endif /* TEST_COOKED */ |
| 1909 | |
| 1910 | #ifdef TEST_RAW |
| 1911 | int |
| 1912 | main(int ac, char *av[]) |
| 1913 | { |
| 1914 | int S =ac>1 ? atoi(av[1]) : 4; |
| 1915 | int J =ac>2 ? atoi(av[2]) : 12; |
| 1916 | int h_pos =ac>3 ? atoi(av[3]) : 1; |
| 1917 | int h_over=ac>4 ? atoi(av[4]) : 1; |
| 1918 | int v_over=ac>5 ? atoi(av[5]) : 1; |
| 1919 | int H = h_pos * h_over * v_over; |
| 1920 | |
| 1921 | int pass, passes, x; |
| 1922 | int collect[MAXCOLLECT]; |
| 1923 | int prints[MAXCOLLECT]; |
| 1924 | raw_t raw; |
| 1925 | |
| 1926 | memset(collect, 0, MAXCOLLECT*sizeof(int)); |
| 1927 | memset(prints, 0, MAXCOLLECT*sizeof(int)); |
| 1928 | printf("S=%d J=%d H=%d\n", S, J, H); |
| 1929 | |
| 1930 | if (H > J) { |
| 1931 | printf("H > J, so this weave will not work!\n"); |
| 1932 | } |
| 1933 | passes = S * H * 3; |
| 1934 | |
| 1935 | initialize_raw_weave(&raw, S, J, H); |
| 1936 | |
| 1937 | for (pass=0; pass<passes + S * H; pass++) { |
| 1938 | int startrow, subpass, phantomjets, jetsused; |
| 1939 | |
| 1940 | calculate_raw_pass_parameters(&raw, pass, &startrow, &subpass); |
| 1941 | phantomjets = 0; |
| 1942 | jetsused = J; |
| 1943 | |
| 1944 | plotpass(startrow, phantomjets, jetsused, J, S, subpass, |
| 1945 | collect, prints); |
| 1946 | } |
| 1947 | for (pass=MAXCOLLECT - 1; prints[pass] == 0; pass--) |
| 1948 | ; |
| 1949 | |
| 1950 | for (x=0; x<=pass; x++) { |
| 1951 | if (collect[x] < 10) |
| 1952 | putchar('0'+collect[x]); |
| 1953 | else |
| 1954 | putchar('A'+collect[x]-10); |
| 1955 | } |
| 1956 | putchar('\n'); |
| 1957 | |
| 1958 | for (x=0; x<=pass; x++) { |
| 1959 | if (prints[x] < 10) |
| 1960 | putchar('0'+prints[x]); |
| 1961 | else |
| 1962 | putchar('A'+prints[x]-10); |
| 1963 | } |
| 1964 | putchar('\n'); |
| 1965 | |
| 1966 | printf(" A first row given by pass lookup doesn't match row lookup\n" |
| 1967 | " B jet out of range\n" |
| 1968 | " C given jet number of pass doesn't print this row\n" |
| 1969 | " D subpass given by reverse lookup doesn't match requested subpass\n"); |
| 1970 | |
| 1971 | for (x = S * J; x < S * J * 20; x++) { |
| 1972 | int h; |
| 1973 | for (h = 0; h < H; h++) { |
| 1974 | int pass, jet, start, first, subpass, z; |
| 1975 | int a=0, b=0, c=0, d=0; |
| 1976 | calculate_raw_row_parameters(&raw, x, h, &pass, &jet, &start); |
| 1977 | for (z=0; z < pass; z++) { |
| 1978 | putchar(' '); |
| 1979 | } |
| 1980 | printf("%d", jet); |
| 1981 | calculate_raw_pass_parameters(&raw, pass, &first, &subpass); |
| 1982 | if (first != start) |
| 1983 | a=1; |
| 1984 | if (jet < 0 || jet >= J) |
| 1985 | b=1; |
| 1986 | if (x != first + jet * S) |
| 1987 | c=1; |
| 1988 | if (subpass != h) |
| 1989 | d=1; |
| 1990 | if (a || b || c || d) { |
| 1991 | printf(" ("); |
| 1992 | if (a) putchar('A'); |
| 1993 | if (b) putchar('B'); |
| 1994 | if (c) putchar('C'); |
| 1995 | if (d) putchar('D'); |
| 1996 | putchar(')'); |
| 1997 | printf("\npass=%d first=%d start=%d jet=%d subpass=%d", pass, first, start, jet, subpass); |
| 1998 | } |
| 1999 | putchar('\n'); |
| 2000 | } |
| 2001 | /* putchar('\n'); */ |
| 2002 | } |
| 2003 | |
| 2004 | return 0; |
| 2005 | } |
| 2006 | |
| 2007 | #endif /* TEST_RAW */ |