35 #define PredictorState(tif) ((TIFFPredictorState*) (tif)->tif_data) 53 PredictorSetup(
TIFF* tif)
55 static const char module[] =
"PredictorSetup";
69 "Horizontal differencing \"Predictor\" not supported with %d-bit samples",
77 "Floating point \"Predictor\" not supported with %d data format",
84 "\"Predictor\" value %d not supported",
102 PredictorSetupDecode(
TIFF* tif)
107 if (!(*sp->
setupdecode)(tif) || !PredictorSetup(tif))
180 PredictorSetupEncode(
TIFF* tif)
185 if (!(*sp->
setupencode)(tif) || !PredictorSetup(tif))
229 #define REPEAT4(n, op) \ 231 default: { int i; for (i = n-4; i > 0; i--) { op; } } \ 244 char* cp = (
char*) cp0;
251 unsigned int cr = cp[0];
252 unsigned int cg = cp[1];
253 unsigned int cb = cp[2];
256 cp[0] = (char) (cr += cp[0]);
257 cp[1] = (char) (cg += cp[1]);
258 cp[2] = (char) (cb += cp[2]);
259 }
while ((int32) cc > 0);
260 }
else if (stride == 4) {
261 unsigned int cr = cp[0];
262 unsigned int cg = cp[1];
263 unsigned int cb = cp[2];
264 unsigned int ca = cp[3];
267 cp[0] = (char) (cr += cp[0]);
268 cp[1] = (char) (cg += cp[1]);
269 cp[2] = (char) (cb += cp[2]);
270 cp[3] = (char) (ca += cp[3]);
271 }
while ((int32) cc > 0);
275 (
char) (cp[stride] + *cp); cp++)
277 }
while ((int32) cc > 0);
293 REPEAT4(stride, wp[stride] += wp[0]; wp++)
295 }
while ((int32) wc > 0);
309 REPEAT4(stride, wp[stride] += wp[0]; wp++)
311 }
while ((int32) wc > 0);
319 uint32* wp = (uint32*) cp0;
326 REPEAT4(stride, wp[stride] += wp[0]; wp++)
328 }
while ((int32) wc > 0);
336 uint32* wp = (uint32*) cp0;
342 REPEAT4(stride, wp[stride] += wp[0]; wp++)
344 }
while ((int32) wc > 0);
364 while (count > stride) {
365 REPEAT4(stride, cp[stride] += cp[0]; cp++)
371 for (count = 0; count < wc; count++) {
373 for (byte = 0; byte < bps; byte++) {
375 cp[bps * count +
byte] = tmp[byte * wc + count];
377 cp[bps * count +
byte] =
378 tmp[(bps - byte - 1) * wc + count];
397 if ((*sp->
decoderow)(tif, op0, occ0, s)) {
423 while ((
long)occ0 > 0) {
438 char* cp = (
char*) cp0;
451 r1 = cp[3]; cp[3] = r1-r2; r2 = r1;
452 g1 = cp[4]; cp[4] = g1-g2; g2 = g1;
453 b1 = cp[5]; cp[5] = b1-b2; b2 = b1;
455 }
while ((int32)(cc -= 3) > 0);
456 }
else if (stride == 4) {
463 r1 = cp[4]; cp[4] = r1-r2; r2 = r1;
464 g1 = cp[5]; cp[5] = g1-g2; g2 = g1;
465 b1 = cp[6]; cp[6] = b1-b2; b2 = b1;
466 a1 = cp[7]; cp[7] = a1-a2; a2 = a1;
468 }
while ((int32)(cc -= 4) > 0);
472 REPEAT4(stride, cp[stride] -= cp[0]; cp--)
473 }
while ((int32)(cc -= stride) > 0);
490 REPEAT4(stride, wp[stride] -= wp[0]; wp--)
492 }
while ((int32) wc > 0);
501 int32 *wp = (int32*) cp0;
508 REPEAT4(stride, wp[stride] -= wp[0]; wp--)
510 }
while ((int32) wc > 0);
531 for (count = 0; count < wc; count++) {
533 for (byte = 0; byte < bps; byte++) {
535 cp[byte * wc + count] = tmp[bps * count +
byte];
537 cp[(bps - byte - 1) * wc + count] =
538 tmp[bps * count + byte];
545 cp += cc - stride - 1;
546 for (count = cc; count > stride; count -= stride)
547 REPEAT4(stride, cp[stride] -= cp[0]; cp--)
567 static const char module[] =
"PredictorEncodeTile";
583 if( working_copy == NULL )
586 "Out of memory allocating %d byte temp buffer.",
590 memcpy( working_copy, bp0, cc0 );
595 assert((cc0%rowsize)==0);
601 result_code = (*sp->
encodetile)(tif, working_copy, cc0, s);
608 #define FIELD_PREDICTOR (FIELD_CODEC+0) 616 PredictorVSetField(
TIFF* tif,
ttag_t tag, va_list ap)
636 PredictorVGetField(
TIFF* tif,
ttag_t tag, va_list ap)
654 PredictorPrintDir(
TIFF* tif, FILE* fd,
long flags)
660 fprintf(fd,
" Predictor: ");
662 case 1: fprintf(fd,
"none ");
break;
663 case 2: fprintf(fd,
"horizontal differencing ");
break;
664 case 3: fprintf(fd,
"floating point predictor ");
break;
685 "Merging Predictor codec-specific tags failed");
TIFFCodeMethod decodestrip
TIFFPostMethod encodepfunc
#define PredictorState(tif)
TIFFCodeMethod tif_decoderow
TIFFTagMethods tif_tagmethods
tsize_t TIFFTileRowSize(TIFF *tif)
TIFFVGetMethod vgetparent
TIFFCodeMethod tif_encodestrip
TIFFCodeMethod tif_encoderow
tsize_t TIFFScanlineSize(TIFF *tif)
#define PREDICTOR_HORIZONTAL
void TIFFSwabArrayOfShort(uint16 *wp, register unsigned long n)
TIFFVSetMethod vsetparent
int TIFFPredictorCleanup(TIFF *tif)
TIFFPostMethod decodepfunc
void _TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c)
#define TIFFSetFieldBit(tif, field)
TIFFCodeMethod encodetile
TIFFCodeMethod tif_decodestrip
TIFFCodeMethod tif_encodetile
TIFFBoolMethod setupdecode
#define SAMPLEFORMAT_IEEEFP
TIFFPostMethod tif_postdecode
int _TIFFMergeFieldInfo(TIFF *, const TIFFFieldInfo[], int)
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
void TIFFSwabArrayOfLong(register uint32 *lp, register unsigned long n)
#define TIFFFieldSet(tif, field)
TIFFCodeMethod tif_decodetile
TIFFBoolMethod setupencode
#define TIFFArrayCount(a)
void _TIFFNoPostDecode(TIFF *tif, tidata_t buf, tsize_t cc)
uint16 td_samplesperpixel
TIFFCodeMethod decodetile
int TIFFPredictorInit(TIFF *tif)
#define TIFFTAG_PREDICTOR
void * _TIFFmalloc(tsize_t s)
TIFFCodeMethod encodestrip
void _TIFFfree(tdata_t p)
#define PREDICTOR_FLOATINGPOINT
TIFFBoolMethod tif_setupencode
#define PLANARCONFIG_CONTIG
TIFFBoolMethod tif_setupdecode