Lines Matching +full:- +full:wc

2  * Copyright (c) 1988-1997 Sam Leffler
3 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
13 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
33 #define PredictorState(tif) ((TIFFPredictorState*) (tif)->tif_data)
58 TIFFDirectory* td = &tif->tif_dir; in PredictorSetup()
60 switch (sp->predictor) /* no differencing */ in PredictorSetup()
65 if (td->td_bitspersample != 8 in PredictorSetup()
66 && td->td_bitspersample != 16 in PredictorSetup()
67 && td->td_bitspersample != 32) { in PredictorSetup()
68 TIFFErrorExt(tif->tif_clientdata, module, in PredictorSetup()
69 "Horizontal differencing \"Predictor\" not supported with %d-bit samples", in PredictorSetup()
70 td->td_bitspersample); in PredictorSetup()
75 if (td->td_sampleformat != SAMPLEFORMAT_IEEEFP) { in PredictorSetup()
76 TIFFErrorExt(tif->tif_clientdata, module, in PredictorSetup()
78 td->td_sampleformat); in PredictorSetup()
81 if (td->td_bitspersample != 16 in PredictorSetup()
82 && td->td_bitspersample != 24 in PredictorSetup()
83 && td->td_bitspersample != 32 in PredictorSetup()
84 && td->td_bitspersample != 64) { /* Should 64 be allowed? */ in PredictorSetup()
85 TIFFErrorExt(tif->tif_clientdata, module, in PredictorSetup()
86 … "Floating point \"Predictor\" not supported with %d-bit samples", in PredictorSetup()
87 td->td_bitspersample); in PredictorSetup()
92 TIFFErrorExt(tif->tif_clientdata, module, in PredictorSetup()
94 sp->predictor); in PredictorSetup()
97 sp->stride = (td->td_planarconfig == PLANARCONFIG_CONTIG ? in PredictorSetup()
98 td->td_samplesperpixel : 1); in PredictorSetup()
100 * Calculate the scanline/tile-width size in bytes. in PredictorSetup()
103 sp->rowsize = TIFFTileRowSize(tif); in PredictorSetup()
105 sp->rowsize = TIFFScanlineSize(tif); in PredictorSetup()
106 if (sp->rowsize == 0) in PredictorSetup()
116 TIFFDirectory* td = &tif->tif_dir; in PredictorSetupDecode()
121 if (!(*sp->setupdecode)(tif) || !PredictorSetup(tif)) in PredictorSetupDecode()
124 if (sp->predictor == 2) { in PredictorSetupDecode()
125 switch (td->td_bitspersample) { in PredictorSetupDecode()
126 case 8: sp->decodepfunc = horAcc8; break; in PredictorSetupDecode()
127 case 16: sp->decodepfunc = horAcc16; break; in PredictorSetupDecode()
128 case 32: sp->decodepfunc = horAcc32; break; in PredictorSetupDecode()
134 if( tif->tif_decoderow != PredictorDecodeRow ) in PredictorSetupDecode()
136 sp->decoderow = tif->tif_decoderow; in PredictorSetupDecode()
137 tif->tif_decoderow = PredictorDecodeRow; in PredictorSetupDecode()
138 sp->decodestrip = tif->tif_decodestrip; in PredictorSetupDecode()
139 tif->tif_decodestrip = PredictorDecodeTile; in PredictorSetupDecode()
140 sp->decodetile = tif->tif_decodetile; in PredictorSetupDecode()
141 tif->tif_decodetile = PredictorDecodeTile; in PredictorSetupDecode()
145 * If the data is horizontally differenced 16-bit data that in PredictorSetupDecode()
146 * requires byte-swapping, then it must be byte swapped before in PredictorSetupDecode()
147 * the accumulation step. We do this with a special-purpose in PredictorSetupDecode()
151 if (tif->tif_flags & TIFF_SWAB) { in PredictorSetupDecode()
152 if (sp->decodepfunc == horAcc16) { in PredictorSetupDecode()
153 sp->decodepfunc = swabHorAcc16; in PredictorSetupDecode()
154 tif->tif_postdecode = _TIFFNoPostDecode; in PredictorSetupDecode()
155 } else if (sp->decodepfunc == horAcc32) { in PredictorSetupDecode()
156 sp->decodepfunc = swabHorAcc32; in PredictorSetupDecode()
157 tif->tif_postdecode = _TIFFNoPostDecode; in PredictorSetupDecode()
162 else if (sp->predictor == 3) { in PredictorSetupDecode()
163 sp->decodepfunc = fpAcc; in PredictorSetupDecode()
168 if( tif->tif_decoderow != PredictorDecodeRow ) in PredictorSetupDecode()
170 sp->decoderow = tif->tif_decoderow; in PredictorSetupDecode()
171 tif->tif_decoderow = PredictorDecodeRow; in PredictorSetupDecode()
172 sp->decodestrip = tif->tif_decodestrip; in PredictorSetupDecode()
173 tif->tif_decodestrip = PredictorDecodeTile; in PredictorSetupDecode()
174 sp->decodetile = tif->tif_decodetile; in PredictorSetupDecode()
175 tif->tif_decodetile = PredictorDecodeTile; in PredictorSetupDecode()
182 if (tif->tif_flags & TIFF_SWAB) { in PredictorSetupDecode()
183 tif->tif_postdecode = _TIFFNoPostDecode; in PredictorSetupDecode()
198 TIFFDirectory* td = &tif->tif_dir; in PredictorSetupEncode()
200 if (!(*sp->setupencode)(tif) || !PredictorSetup(tif)) in PredictorSetupEncode()
203 if (sp->predictor == 2) { in PredictorSetupEncode()
204 switch (td->td_bitspersample) { in PredictorSetupEncode()
205 case 8: sp->encodepfunc = horDiff8; break; in PredictorSetupEncode()
206 case 16: sp->encodepfunc = horDiff16; break; in PredictorSetupEncode()
207 case 32: sp->encodepfunc = horDiff32; break; in PredictorSetupEncode()
213 if( tif->tif_encoderow != PredictorEncodeRow ) in PredictorSetupEncode()
215 sp->encoderow = tif->tif_encoderow; in PredictorSetupEncode()
216 tif->tif_encoderow = PredictorEncodeRow; in PredictorSetupEncode()
217 sp->encodestrip = tif->tif_encodestrip; in PredictorSetupEncode()
218 tif->tif_encodestrip = PredictorEncodeTile; in PredictorSetupEncode()
219 sp->encodetile = tif->tif_encodetile; in PredictorSetupEncode()
220 tif->tif_encodetile = PredictorEncodeTile; in PredictorSetupEncode()
224 * If the data is horizontally differenced 16-bit data that in PredictorSetupEncode()
225 * requires byte-swapping, then it must be byte swapped after in PredictorSetupEncode()
226 * the differentiation step. We do this with a special-purpose in PredictorSetupEncode()
230 if (tif->tif_flags & TIFF_SWAB) { in PredictorSetupEncode()
231 if (sp->encodepfunc == horDiff16) { in PredictorSetupEncode()
232 sp->encodepfunc = swabHorDiff16; in PredictorSetupEncode()
233 tif->tif_postdecode = _TIFFNoPostDecode; in PredictorSetupEncode()
234 } else if (sp->encodepfunc == horDiff32) { in PredictorSetupEncode()
235 sp->encodepfunc = swabHorDiff32; in PredictorSetupEncode()
236 tif->tif_postdecode = _TIFFNoPostDecode; in PredictorSetupEncode()
241 else if (sp->predictor == 3) { in PredictorSetupEncode()
242 sp->encodepfunc = fpDiff; in PredictorSetupEncode()
247 if( tif->tif_encoderow != PredictorEncodeRow ) in PredictorSetupEncode()
249 sp->encoderow = tif->tif_encoderow; in PredictorSetupEncode()
250 tif->tif_encoderow = PredictorEncodeRow; in PredictorSetupEncode()
251 sp->encodestrip = tif->tif_encodestrip; in PredictorSetupEncode()
252 tif->tif_encodestrip = PredictorEncodeTile; in PredictorSetupEncode()
253 sp->encodetile = tif->tif_encodetile; in PredictorSetupEncode()
254 tif->tif_encodetile = PredictorEncodeTile; in PredictorSetupEncode()
264 tmsize_t i; for (i = n-4; i > 0; i--) { op; } } /*-fallthrough*/ \
265 case 4: op; /*-fallthrough*/ \
266 case 3: op; /*-fallthrough*/ \
267 case 2: op; /*-fallthrough*/ \
268 case 1: op; /*-fallthrough*/ \
273 /* - to avoid any undefined behaviour, we only operate on unsigned types */
275 /* - when storing into the byte stream, we explicitly mask with 0xff so */
276 /* as to make icc -check=conversions happy (not necessary by the standard) */
282 tmsize_t stride = PredictorState(tif)->stride; in horAcc8()
287 TIFFErrorExt(tif->tif_clientdata, "horAcc8", in horAcc8()
300 cc -= 3; in horAcc8()
306 cc -= 3; in horAcc8()
314 cc -= 4; in horAcc8()
321 cc -= 4; in horAcc8()
325 cc -= stride; in horAcc8()
329 cc -= stride; in horAcc8()
340 tmsize_t wc = cc / 2; in swabHorAcc16() local
342 TIFFSwabArrayOfShort(wp, wc); in swabHorAcc16()
350 tmsize_t stride = PredictorState(tif)->stride; in horAcc16()
352 tmsize_t wc = cc / 2; in horAcc16() local
356 TIFFErrorExt(tif->tif_clientdata, "horAcc16", in horAcc16()
361 if (wc > stride) { in horAcc16()
362 wc -= stride; in horAcc16()
365 wc -= stride; in horAcc16()
366 } while (wc > 0); in horAcc16()
375 tmsize_t wc = cc / 4; in swabHorAcc32() local
377 TIFFSwabArrayOfLong(wp, wc); in swabHorAcc32()
385 tmsize_t stride = PredictorState(tif)->stride; in horAcc32()
387 tmsize_t wc = cc / 4; in horAcc32() local
391 TIFFErrorExt(tif->tif_clientdata, "horAcc32", in horAcc32()
396 if (wc > stride) { in horAcc32()
397 wc -= stride; in horAcc32()
400 wc -= stride; in horAcc32()
401 } while (wc > 0); in horAcc32()
412 tmsize_t stride = PredictorState(tif)->stride; in fpAcc()
413 uint32 bps = tif->tif_dir.td_bitspersample / 8; in fpAcc()
414 tmsize_t wc = cc / bps; in fpAcc() local
421 TIFFErrorExt(tif->tif_clientdata, "fpAcc", in fpAcc()
433 count -= stride; in fpAcc()
438 for (count = 0; count < wc; count++) { in fpAcc()
442 cp[bps * count + byte] = tmp[byte * wc + count]; in fpAcc()
445 tmp[(bps - byte - 1) * wc + count]; in fpAcc()
462 assert(sp->decoderow != NULL); in PredictorDecodeRow()
463 assert(sp->decodepfunc != NULL); in PredictorDecodeRow()
465 if ((*sp->decoderow)(tif, op0, occ0, s)) { in PredictorDecodeRow()
466 return (*sp->decodepfunc)(tif, op0, occ0); in PredictorDecodeRow()
474 * row-by-row basis. The width of a "row" has already
475 * been calculated at pre-decode time according to the
484 assert(sp->decodetile != NULL); in PredictorDecodeTile()
486 if ((*sp->decodetile)(tif, op0, occ0, s)) { in PredictorDecodeTile()
487 tmsize_t rowsize = sp->rowsize; in PredictorDecodeTile()
491 TIFFErrorExt(tif->tif_clientdata, "PredictorDecodeTile", in PredictorDecodeTile()
495 assert(sp->decodepfunc != NULL); in PredictorDecodeTile()
497 if( !(*sp->decodepfunc)(tif, op0, rowsize) ) in PredictorDecodeTile()
499 occ0 -= rowsize; in PredictorDecodeTile()
512 tmsize_t stride = sp->stride; in horDiff8()
517 TIFFErrorExt(tif->tif_clientdata, "horDiff8", in horDiff8()
523 cc -= stride; in horDiff8()
533 r1 = cp[3]; cp[3] = (unsigned char)((r1-r2)&0xff); r2 = r1; in horDiff8()
534 g1 = cp[4]; cp[4] = (unsigned char)((g1-g2)&0xff); g2 = g1; in horDiff8()
535 b1 = cp[5]; cp[5] = (unsigned char)((b1-b2)&0xff); b2 = b1; in horDiff8()
537 } while ((cc -= 3) > 0); in horDiff8()
545 r1 = cp[4]; cp[4] = (unsigned char)((r1-r2)&0xff); r2 = r1; in horDiff8()
546 g1 = cp[5]; cp[5] = (unsigned char)((g1-g2)&0xff); g2 = g1; in horDiff8()
547 b1 = cp[6]; cp[6] = (unsigned char)((b1-b2)&0xff); b2 = b1; in horDiff8()
548 a1 = cp[7]; cp[7] = (unsigned char)((a1-a2)&0xff); a2 = a1; in horDiff8()
550 } while ((cc -= 4) > 0); in horDiff8()
552 cp += cc - 1; in horDiff8()
554 REPEAT4(stride, cp[stride] = (unsigned char)((cp[stride] - cp[0])&0xff); cp--) in horDiff8()
555 } while ((cc -= stride) > 0); in horDiff8()
566 tmsize_t stride = sp->stride; in horDiff16()
568 tmsize_t wc = cc/2; in horDiff16() local
572 TIFFErrorExt(tif->tif_clientdata, "horDiff8", in horDiff16()
577 if (wc > stride) { in horDiff16()
578 wc -= stride; in horDiff16()
579 wp += wc - 1; in horDiff16()
581 …AT4(stride, wp[stride] = (uint16)(((unsigned int)wp[stride] - (unsigned int)wp[0]) & 0xffff); wp--) in horDiff16()
582 wc -= stride; in horDiff16()
583 } while (wc > 0); in horDiff16()
592 tmsize_t wc = cc / 2; in swabHorDiff16() local
597 TIFFSwabArrayOfShort(wp, wc); in swabHorDiff16()
606 tmsize_t stride = sp->stride; in horDiff32()
608 tmsize_t wc = cc/4; in horDiff32() local
612 TIFFErrorExt(tif->tif_clientdata, "horDiff32", in horDiff32()
617 if (wc > stride) { in horDiff32()
618 wc -= stride; in horDiff32()
619 wp += wc - 1; in horDiff32()
621 REPEAT4(stride, wp[stride] -= wp[0]; wp--) in horDiff32()
622 wc -= stride; in horDiff32()
623 } while (wc > 0); in horDiff32()
632 tmsize_t wc = cc / 4; in swabHorDiff32() local
637 TIFFSwabArrayOfLong(wp, wc); in swabHorDiff32()
648 tmsize_t stride = PredictorState(tif)->stride; in fpDiff()
649 uint32 bps = tif->tif_dir.td_bitspersample / 8; in fpDiff()
650 tmsize_t wc = cc / bps; in fpDiff() local
657 TIFFErrorExt(tif->tif_clientdata, "fpDiff", in fpDiff()
667 for (count = 0; count < wc; count++) { in fpDiff()
671 cp[byte * wc + count] = tmp[bps * count + byte]; in fpDiff()
673 cp[(bps - byte - 1) * wc + count] = in fpDiff()
681 cp += cc - stride - 1; in fpDiff()
682 for (count = cc; count > stride; count -= stride) in fpDiff()
683 REPEAT4(stride, cp[stride] = (unsigned char)((cp[stride] - cp[0])&0xff); cp--) in fpDiff()
693 assert(sp->encodepfunc != NULL); in PredictorEncodeRow()
694 assert(sp->encoderow != NULL); in PredictorEncodeRow()
697 if( !(*sp->encodepfunc)(tif, bp, cc) ) in PredictorEncodeRow()
699 return (*sp->encoderow)(tif, bp, cc, s); in PredictorEncodeRow()
713 assert(sp->encodepfunc != NULL); in PredictorEncodeTile()
714 assert(sp->encodetile != NULL); in PredictorEncodeTile()
723 TIFFErrorExt(tif->tif_clientdata, module, in PredictorEncodeTile()
731 rowsize = sp->rowsize; in PredictorEncodeTile()
735 TIFFErrorExt(tif->tif_clientdata, "PredictorEncodeTile", in PredictorEncodeTile()
741 (*sp->encodepfunc)(tif, bp, rowsize); in PredictorEncodeTile()
742 cc -= rowsize; in PredictorEncodeTile()
745 result_code = (*sp->encodetile)(tif, working_copy, cc0, s); in PredictorEncodeTile()
764 assert(sp->vsetparent != NULL); in PredictorVSetField()
768 sp->predictor = (uint16) va_arg(ap, uint16_vap); in PredictorVSetField()
772 return (*sp->vsetparent)(tif, tag, ap); in PredictorVSetField()
774 tif->tif_flags |= TIFF_DIRTYDIRECT; in PredictorVSetField()
784 assert(sp->vgetparent != NULL); in PredictorVGetField()
788 *va_arg(ap, uint16*) = (uint16)sp->predictor; in PredictorVGetField()
791 return (*sp->vgetparent)(tif, tag, ap); in PredictorVGetField()
804 switch (sp->predictor) { in PredictorPrintDir()
809 fprintf(fd, "%d (0x%x)\n", sp->predictor, sp->predictor); in PredictorPrintDir()
811 if (sp->printdir) in PredictorPrintDir()
812 (*sp->printdir)(tif, fd, flags); in PredictorPrintDir()
823 * Merge codec-specific tag information. in TIFFPredictorInit()
827 TIFFErrorExt(tif->tif_clientdata, "TIFFPredictorInit", in TIFFPredictorInit()
828 "Merging Predictor codec-specific tags failed"); in TIFFPredictorInit()
835 sp->vgetparent = tif->tif_tagmethods.vgetfield; in TIFFPredictorInit()
836 tif->tif_tagmethods.vgetfield = in TIFFPredictorInit()
838 sp->vsetparent = tif->tif_tagmethods.vsetfield; in TIFFPredictorInit()
839 tif->tif_tagmethods.vsetfield = in TIFFPredictorInit()
841 sp->printdir = tif->tif_tagmethods.printdir; in TIFFPredictorInit()
842 tif->tif_tagmethods.printdir = in TIFFPredictorInit()
845 sp->setupdecode = tif->tif_setupdecode; in TIFFPredictorInit()
846 tif->tif_setupdecode = PredictorSetupDecode; in TIFFPredictorInit()
847 sp->setupencode = tif->tif_setupencode; in TIFFPredictorInit()
848 tif->tif_setupencode = PredictorSetupEncode; in TIFFPredictorInit()
850 sp->predictor = 1; /* default value */ in TIFFPredictorInit()
851 sp->encodepfunc = NULL; /* no predictor routine */ in TIFFPredictorInit()
852 sp->decodepfunc = NULL; /* no predictor routine */ in TIFFPredictorInit()
863 tif->tif_tagmethods.vgetfield = sp->vgetparent; in TIFFPredictorCleanup()
864 tif->tif_tagmethods.vsetfield = sp->vsetparent; in TIFFPredictorCleanup()
865 tif->tif_tagmethods.printdir = sp->printdir; in TIFFPredictorCleanup()
866 tif->tif_setupdecode = sp->setupdecode; in TIFFPredictorCleanup()
867 tif->tif_setupencode = sp->setupencode; in TIFFPredictorCleanup()
876 * c-basic-offset: 8
877 * fill-column: 78