Lines Matching refs:sp
92 #define is2DEncoding(sp) (sp->b.groupoptions & GROUP3OPT_2DENCODING) argument
103 #define DECLARE_STATE(tif, sp, mod) \ argument
105 Fax3CodecState* sp = DecoderState(tif); \
107 int lastx = sp->b.rowpixels; /* last element in row */ \
116 const unsigned char* bitmap = sp->bitmap; /* input data bit reverser */ \
118 #define DECLARE_STATE_2D(tif, sp, mod) \ argument
119 DECLARE_STATE(tif, sp, mod); \
125 #define CACHE_STATE(tif, sp) do { \ argument
126 BitAcc = sp->data; \
127 BitsAvail = sp->bit; \
128 EOLcnt = sp->EOLcnt; \
135 #define UNCACHE_STATE(tif, sp) do { \ argument
136 sp->bit = BitsAvail; \
137 sp->data = BitAcc; \
138 sp->EOLcnt = EOLcnt; \
149 Fax3CodecState* sp = DecoderState(tif); in Fax3PreDecode() local
152 assert(sp != NULL); in Fax3PreDecode()
153 sp->bit = 0; /* force initial read */ in Fax3PreDecode()
154 sp->data = 0; in Fax3PreDecode()
155 sp->EOLcnt = 0; /* force initial scan for EOL */ in Fax3PreDecode()
163 sp->bitmap = in Fax3PreDecode()
165 if (sp->refruns) { /* init reference line to white */ in Fax3PreDecode()
166 sp->refruns[0] = (uint32) sp->b.rowpixels; in Fax3PreDecode()
167 sp->refruns[1] = 0; in Fax3PreDecode()
169 sp->line = 0; in Fax3PreDecode()
187 #define unexpected(table, a0) Fax3Unexpected(module, tif, sp->line, a0)
198 #define extension(a0) Fax3Extension(module, tif, sp->line, a0)
209 #define badlength(a0,lastx) Fax3BadLength(module, tif, sp->line, a0, lastx)
219 #define prematureEOF(a0) Fax3PrematureEOF(module, tif, sp->line, a0)
229 DECLARE_STATE(tif, sp, "Fax3Decode1D"); in Fax3Decode1D()
231 if (occ % sp->b.rowbytes) in Fax3Decode1D()
236 CACHE_STATE(tif, sp); in Fax3Decode1D()
237 thisrun = sp->curruns; in Fax3Decode1D()
249 (*sp->fill)(buf, thisrun, pa, lastx); in Fax3Decode1D()
250 buf += sp->b.rowbytes; in Fax3Decode1D()
251 occ -= sp->b.rowbytes; in Fax3Decode1D()
252 sp->line++; in Fax3Decode1D()
257 (*sp->fill)(buf, thisrun, pa, lastx); in Fax3Decode1D()
258 UNCACHE_STATE(tif, sp); in Fax3Decode1D()
261 UNCACHE_STATE(tif, sp); in Fax3Decode1D()
272 DECLARE_STATE_2D(tif, sp, "Fax3Decode2D"); in Fax3Decode2D()
275 if (occ % sp->b.rowbytes) in Fax3Decode2D()
280 CACHE_STATE(tif, sp); in Fax3Decode2D()
284 pa = thisrun = sp->curruns; in Fax3Decode2D()
298 pb = sp->refruns; in Fax3Decode2D()
304 (*sp->fill)(buf, thisrun, pa, lastx); in Fax3Decode2D()
306 SWAP(uint32*, sp->curruns, sp->refruns); in Fax3Decode2D()
307 buf += sp->b.rowbytes; in Fax3Decode2D()
308 occ -= sp->b.rowbytes; in Fax3Decode2D()
309 sp->line++; in Fax3Decode2D()
314 (*sp->fill)(buf, thisrun, pa, lastx); in Fax3Decode2D()
315 UNCACHE_STATE(tif, sp); in Fax3Decode2D()
318 UNCACHE_STATE(tif, sp); in Fax3Decode2D()
507 Fax3BaseState* sp = Fax3State(tif); in Fax3SetupState() local
528 sp->rowbytes = rowbytes; in Fax3SetupState()
529 sp->rowpixels = rowpixels; in Fax3SetupState()
534 (sp->groupoptions & GROUP3OPT_2DENCODING) || in Fax3SetupState()
598 #define Fax3FlushBits(tif, sp) { \ argument
601 *(tif)->tif_rawcp++ = (uint8) (sp)->data; \
603 (sp)->data = 0, (sp)->bit = 8; \
635 Fax3CodecState* sp = EncoderState(tif); in Fax3PutBits() local
636 unsigned int bit = sp->bit; in Fax3PutBits()
637 int data = sp->data; in Fax3PutBits()
641 sp->data = data; in Fax3PutBits()
642 sp->bit = bit; in Fax3PutBits()
670 Fax3CodecState* sp = EncoderState(tif); in putspan() local
671 unsigned int bit = sp->bit; in putspan()
672 int data = sp->data; in putspan()
703 sp->data = data; in putspan()
704 sp->bit = bit; in putspan()
716 Fax3CodecState* sp = EncoderState(tif); in Fax3PutEOL() local
717 unsigned int bit = sp->bit; in Fax3PutEOL()
718 int data = sp->data; in Fax3PutEOL()
721 if (sp->b.groupoptions & GROUP3OPT_FILLBITS) { in Fax3PutEOL()
728 if (align != sp->bit) { in Fax3PutEOL()
729 if (align > sp->bit) in Fax3PutEOL()
730 align = sp->bit + (8 - align); in Fax3PutEOL()
732 align = sp->bit - align; in Fax3PutEOL()
739 if (is2DEncoding(sp)) { in Fax3PutEOL()
740 code = (code<<1) | (sp->tag == G3_1D); in Fax3PutEOL()
745 sp->data = data; in Fax3PutEOL()
746 sp->bit = bit; in Fax3PutEOL()
755 Fax3CodecState* sp = EncoderState(tif); in Fax3PreEncode() local
758 assert(sp != NULL); in Fax3PreEncode()
759 sp->bit = 8; in Fax3PreEncode()
760 sp->data = 0; in Fax3PreEncode()
761 sp->tag = G3_1D; in Fax3PreEncode()
767 if (sp->refline) in Fax3PreEncode()
768 _TIFFmemset(sp->refline, 0x00, sp->b.rowbytes); in Fax3PreEncode()
769 if (is2DEncoding(sp)) { in Fax3PreEncode()
783 sp->maxk = (res > 150 ? 4 : 2); in Fax3PreEncode()
784 sp->k = sp->maxk-1; in Fax3PreEncode()
786 sp->k = sp->maxk = 0; in Fax3PreEncode()
787 sp->line = 0; in Fax3PreEncode()
990 Fax3CodecState* sp = EncoderState(tif); in Fax3Encode1DRow() local
1006 if (sp->b.mode & (FAXMODE_BYTEALIGN|FAXMODE_WORDALIGN)) { in Fax3Encode1DRow()
1007 if (sp->bit != 8) /* byte-align */ in Fax3Encode1DRow()
1008 Fax3FlushBits(tif, sp); in Fax3Encode1DRow()
1009 if ((sp->b.mode&FAXMODE_WORDALIGN) && in Fax3Encode1DRow()
1011 Fax3FlushBits(tif, sp); in Fax3Encode1DRow()
1083 Fax3CodecState* sp = EncoderState(tif); in Fax3Encode() local
1085 if (cc % sp->b.rowbytes) in Fax3Encode()
1091 if ((sp->b.mode & FAXMODE_NOEOL) == 0) in Fax3Encode()
1093 if (is2DEncoding(sp)) { in Fax3Encode()
1094 if (sp->tag == G3_1D) { in Fax3Encode()
1095 if (!Fax3Encode1DRow(tif, bp, sp->b.rowpixels)) in Fax3Encode()
1097 sp->tag = G3_2D; in Fax3Encode()
1099 if (!Fax3Encode2DRow(tif, bp, sp->refline, in Fax3Encode()
1100 sp->b.rowpixels)) in Fax3Encode()
1102 sp->k--; in Fax3Encode()
1104 if (sp->k == 0) { in Fax3Encode()
1105 sp->tag = G3_1D; in Fax3Encode()
1106 sp->k = sp->maxk-1; in Fax3Encode()
1108 _TIFFmemcpy(sp->refline, bp, sp->b.rowbytes); in Fax3Encode()
1110 if (!Fax3Encode1DRow(tif, bp, sp->b.rowpixels)) in Fax3Encode()
1113 bp += sp->b.rowbytes; in Fax3Encode()
1114 cc -= sp->b.rowbytes; in Fax3Encode()
1122 Fax3CodecState* sp = EncoderState(tif); in Fax3PostEncode() local
1124 if (sp->bit != 8) in Fax3PostEncode()
1125 Fax3FlushBits(tif, sp); in Fax3PostEncode()
1133 Fax3CodecState* sp = EncoderState(tif); in Fax3Close() local
1138 if (is2DEncoding(sp)) { in Fax3Close()
1139 code = (code<<1) | (sp->tag == G3_1D); in Fax3Close()
1144 Fax3FlushBits(tif, sp); in Fax3Close()
1151 Fax3CodecState* sp = DecoderState(tif); in Fax3Cleanup() local
1153 assert(sp != 0); in Fax3Cleanup()
1155 tif->tif_tagmethods.vgetfield = sp->b.vgetparent; in Fax3Cleanup()
1156 tif->tif_tagmethods.vsetfield = sp->b.vsetparent; in Fax3Cleanup()
1157 tif->tif_tagmethods.printdir = sp->b.printdir; in Fax3Cleanup()
1159 if (sp->runs) in Fax3Cleanup()
1160 _TIFFfree(sp->runs); in Fax3Cleanup()
1161 if (sp->refline) in Fax3Cleanup()
1162 _TIFFfree(sp->refline); in Fax3Cleanup()
1192 Fax3BaseState* sp = Fax3State(tif); in Fax3VSetField() local
1195 assert(sp != 0); in Fax3VSetField()
1196 assert(sp->vsetparent != 0); in Fax3VSetField()
1200 sp->mode = (int) va_arg(ap, int); in Fax3VSetField()
1208 sp->groupoptions = (uint32) va_arg(ap, uint32); in Fax3VSetField()
1213 sp->groupoptions = (uint32) va_arg(ap, uint32); in Fax3VSetField()
1216 sp->badfaxlines = (uint32) va_arg(ap, uint32); in Fax3VSetField()
1219 sp->cleanfaxdata = (uint16) va_arg(ap, uint16_vap); in Fax3VSetField()
1222 sp->badfaxrun = (uint32) va_arg(ap, uint32); in Fax3VSetField()
1225 return (*sp->vsetparent)(tif, tag, ap); in Fax3VSetField()
1240 Fax3BaseState* sp = Fax3State(tif); in Fax3VGetField() local
1242 assert(sp != 0); in Fax3VGetField()
1246 *va_arg(ap, int*) = sp->mode; in Fax3VGetField()
1253 *va_arg(ap, uint32*) = sp->groupoptions; in Fax3VGetField()
1256 *va_arg(ap, uint32*) = sp->badfaxlines; in Fax3VGetField()
1259 *va_arg(ap, uint16*) = sp->cleanfaxdata; in Fax3VGetField()
1262 *va_arg(ap, uint32*) = sp->badfaxrun; in Fax3VGetField()
1265 return (*sp->vgetparent)(tif, tag, ap); in Fax3VGetField()
1273 Fax3BaseState* sp = Fax3State(tif); in Fax3PrintDir() local
1275 assert(sp != 0); in Fax3PrintDir()
1282 if (sp->groupoptions & GROUP4OPT_UNCOMPRESSED) in Fax3PrintDir()
1287 if (sp->groupoptions & GROUP3OPT_2DENCODING) { in Fax3PrintDir()
1291 if (sp->groupoptions & GROUP3OPT_FILLBITS) { in Fax3PrintDir()
1295 if (sp->groupoptions & GROUP3OPT_UNCOMPRESSED) in Fax3PrintDir()
1299 (unsigned long) sp->groupoptions, in Fax3PrintDir()
1300 (unsigned long) sp->groupoptions); in Fax3PrintDir()
1304 switch (sp->cleanfaxdata) { in Fax3PrintDir()
1316 sp->cleanfaxdata, sp->cleanfaxdata); in Fax3PrintDir()
1320 (unsigned long) sp->badfaxlines); in Fax3PrintDir()
1323 (unsigned long) sp->badfaxrun); in Fax3PrintDir()
1324 if (sp->printdir) in Fax3PrintDir()
1325 (*sp->printdir)(tif, fd, flags); in Fax3PrintDir()
1332 Fax3BaseState* sp; in InitCCITTFax3() local
1356 sp = Fax3State(tif); in InitCCITTFax3()
1357 sp->rw_mode = tif->tif_mode; in InitCCITTFax3()
1362 sp->vgetparent = tif->tif_tagmethods.vgetfield; in InitCCITTFax3()
1364 sp->vsetparent = tif->tif_tagmethods.vsetfield; in InitCCITTFax3()
1366 sp->printdir = tif->tif_tagmethods.printdir; in InitCCITTFax3()
1368 sp->groupoptions = 0; in InitCCITTFax3()
1370 if (sp->rw_mode == O_RDONLY) /* FIXME: improve for in place update */ in InitCCITTFax3()
1432 DECLARE_STATE_2D(tif, sp, "Fax4Decode"); in Fax4Decode()
1434 if (occ % sp->b.rowbytes) in Fax4Decode()
1439 CACHE_STATE(tif, sp); in Fax4Decode()
1443 pa = thisrun = sp->curruns; in Fax4Decode()
1444 pb = sp->refruns; in Fax4Decode()
1454 (*sp->fill)(buf, thisrun, pa, lastx); in Fax4Decode()
1456 SWAP(uint32*, sp->curruns, sp->refruns); in Fax4Decode()
1457 buf += sp->b.rowbytes; in Fax4Decode()
1458 occ -= sp->b.rowbytes; in Fax4Decode()
1459 sp->line++; in Fax4Decode()
1469 (*sp->fill)(buf, thisrun, pa, lastx); in Fax4Decode()
1470 UNCACHE_STATE(tif, sp); in Fax4Decode()
1471 return ( sp->line ? 1 : -1); /* don't error on badly-terminated strips */ in Fax4Decode()
1473 UNCACHE_STATE(tif, sp); in Fax4Decode()
1485 Fax3CodecState *sp = EncoderState(tif); in Fax4Encode() local
1487 if (cc % sp->b.rowbytes) in Fax4Encode()
1493 if (!Fax3Encode2DRow(tif, bp, sp->refline, sp->b.rowpixels)) in Fax4Encode()
1495 _TIFFmemcpy(sp->refline, bp, sp->b.rowbytes); in Fax4Encode()
1496 bp += sp->b.rowbytes; in Fax4Encode()
1497 cc -= sp->b.rowbytes; in Fax4Encode()
1505 Fax3CodecState *sp = EncoderState(tif); in Fax4PostEncode() local
1510 if (sp->bit != 8) in Fax4PostEncode()
1511 Fax3FlushBits(tif, sp); in Fax4PostEncode()
1556 DECLARE_STATE(tif, sp, "Fax3DecodeRLE"); in Fax3DecodeRLE()
1557 int mode = sp->b.mode; in Fax3DecodeRLE()
1559 if (occ % sp->b.rowbytes) in Fax3DecodeRLE()
1564 CACHE_STATE(tif, sp); in Fax3DecodeRLE()
1565 thisrun = sp->curruns; in Fax3DecodeRLE()
1576 (*sp->fill)(buf, thisrun, pa, lastx); in Fax3DecodeRLE()
1589 buf += sp->b.rowbytes; in Fax3DecodeRLE()
1590 occ -= sp->b.rowbytes; in Fax3DecodeRLE()
1591 sp->line++; in Fax3DecodeRLE()
1594 (*sp->fill)(buf, thisrun, pa, lastx); in Fax3DecodeRLE()
1595 UNCACHE_STATE(tif, sp); in Fax3DecodeRLE()
1598 UNCACHE_STATE(tif, sp); in Fax3DecodeRLE()