ReactOS 0.4.15-dev-7998-gdb93cb1
tif_predict.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 1988-1997 Sam Leffler
3 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
4 *
5 * Permission to use, copy, modify, distribute, and sell this software and
6 * its documentation for any purpose is hereby granted without fee, provided
7 * that (i) the above copyright notices and this permission notice appear in
8 * all copies of the software and related documentation, and (ii) the names of
9 * Sam Leffler and Silicon Graphics may not be used in any advertising or
10 * publicity relating to the software without the specific, prior written
11 * permission of Sam Leffler and Silicon Graphics.
12 *
13 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
14 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
15 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
16 *
17 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
18 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
19 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
21 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
22 * OF THIS SOFTWARE.
23 */
24
25/*
26 * TIFF Library.
27 *
28 * Predictor Tag Support (used by multiple codecs).
29 */
30#include <precomp.h>
31#include "tif_predict.h"
32
33#define PredictorState(tif) ((TIFFPredictorState*) (tif)->tif_data)
34
35static int horAcc8(TIFF* tif, uint8* cp0, tmsize_t cc);
36static int horAcc16(TIFF* tif, uint8* cp0, tmsize_t cc);
37static int horAcc32(TIFF* tif, uint8* cp0, tmsize_t cc);
38static int swabHorAcc16(TIFF* tif, uint8* cp0, tmsize_t cc);
39static int swabHorAcc32(TIFF* tif, uint8* cp0, tmsize_t cc);
40static int horDiff8(TIFF* tif, uint8* cp0, tmsize_t cc);
41static int horDiff16(TIFF* tif, uint8* cp0, tmsize_t cc);
42static int horDiff32(TIFF* tif, uint8* cp0, tmsize_t cc);
43static int swabHorDiff16(TIFF* tif, uint8* cp0, tmsize_t cc);
44static int swabHorDiff32(TIFF* tif, uint8* cp0, tmsize_t cc);
45static int fpAcc(TIFF* tif, uint8* cp0, tmsize_t cc);
46static int fpDiff(TIFF* tif, uint8* cp0, tmsize_t cc);
47static int PredictorDecodeRow(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s);
48static int PredictorDecodeTile(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s);
49static int PredictorEncodeRow(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s);
50static int PredictorEncodeTile(TIFF* tif, uint8* bp0, tmsize_t cc0, uint16 s);
51
52static int
54{
55 static const char module[] = "PredictorSetup";
56
58 TIFFDirectory* td = &tif->tif_dir;
59
60 switch (sp->predictor) /* no differencing */
61 {
62 case PREDICTOR_NONE:
63 return 1;
65 if (td->td_bitspersample != 8
66 && td->td_bitspersample != 16
67 && td->td_bitspersample != 32) {
69 "Horizontal differencing \"Predictor\" not supported with %d-bit samples",
71 return 0;
72 }
73 break;
77 "Floating point \"Predictor\" not supported with %d data format",
78 td->td_sampleformat);
79 return 0;
80 }
81 if (td->td_bitspersample != 16
82 && td->td_bitspersample != 24
83 && td->td_bitspersample != 32
84 && td->td_bitspersample != 64) { /* Should 64 be allowed? */
86 "Floating point \"Predictor\" not supported with %d-bit samples",
88 return 0;
89 }
90 break;
91 default:
93 "\"Predictor\" value %d not supported",
94 sp->predictor);
95 return 0;
96 }
97 sp->stride = (td->td_planarconfig == PLANARCONFIG_CONTIG ?
98 td->td_samplesperpixel : 1);
99 /*
100 * Calculate the scanline/tile-width size in bytes.
101 */
102 if (isTiled(tif))
103 sp->rowsize = TIFFTileRowSize(tif);
104 else
105 sp->rowsize = TIFFScanlineSize(tif);
106 if (sp->rowsize == 0)
107 return 0;
108
109 return 1;
110}
111
112static int
114{
116 TIFFDirectory* td = &tif->tif_dir;
117
118 /* Note: when PredictorSetup() fails, the effets of setupdecode() */
119 /* will not be "cancelled" so setupdecode() might be robust to */
120 /* be called several times. */
121 if (!(*sp->setupdecode)(tif) || !PredictorSetup(tif))
122 return 0;
123
124 if (sp->predictor == 2) {
125 switch (td->td_bitspersample) {
126 case 8: sp->decodepfunc = horAcc8; break;
127 case 16: sp->decodepfunc = horAcc16; break;
128 case 32: sp->decodepfunc = horAcc32; break;
129 }
130 /*
131 * Override default decoding method with one that does the
132 * predictor stuff.
133 */
135 {
136 sp->decoderow = tif->tif_decoderow;
138 sp->decodestrip = tif->tif_decodestrip;
140 sp->decodetile = tif->tif_decodetile;
142 }
143
144 /*
145 * If the data is horizontally differenced 16-bit data that
146 * requires byte-swapping, then it must be byte swapped before
147 * the accumulation step. We do this with a special-purpose
148 * routine and override the normal post decoding logic that
149 * the library setup when the directory was read.
150 */
151 if (tif->tif_flags & TIFF_SWAB) {
152 if (sp->decodepfunc == horAcc16) {
153 sp->decodepfunc = swabHorAcc16;
155 } else if (sp->decodepfunc == horAcc32) {
156 sp->decodepfunc = swabHorAcc32;
158 }
159 }
160 }
161
162 else if (sp->predictor == 3) {
163 sp->decodepfunc = fpAcc;
164 /*
165 * Override default decoding method with one that does the
166 * predictor stuff.
167 */
169 {
170 sp->decoderow = tif->tif_decoderow;
172 sp->decodestrip = tif->tif_decodestrip;
174 sp->decodetile = tif->tif_decodetile;
176 }
177 /*
178 * The data should not be swapped outside of the floating
179 * point predictor, the accumulation routine should return
180 * byres in the native order.
181 */
182 if (tif->tif_flags & TIFF_SWAB) {
184 }
185 /*
186 * Allocate buffer to keep the decoded bytes before
187 * rearranging in the right order
188 */
189 }
190
191 return 1;
192}
193
194static int
196{
198 TIFFDirectory* td = &tif->tif_dir;
199
200 if (!(*sp->setupencode)(tif) || !PredictorSetup(tif))
201 return 0;
202
203 if (sp->predictor == 2) {
204 switch (td->td_bitspersample) {
205 case 8: sp->encodepfunc = horDiff8; break;
206 case 16: sp->encodepfunc = horDiff16; break;
207 case 32: sp->encodepfunc = horDiff32; break;
208 }
209 /*
210 * Override default encoding method with one that does the
211 * predictor stuff.
212 */
214 {
215 sp->encoderow = tif->tif_encoderow;
217 sp->encodestrip = tif->tif_encodestrip;
219 sp->encodetile = tif->tif_encodetile;
221 }
222
223 /*
224 * If the data is horizontally differenced 16-bit data that
225 * requires byte-swapping, then it must be byte swapped after
226 * the differentiation step. We do this with a special-purpose
227 * routine and override the normal post decoding logic that
228 * the library setup when the directory was read.
229 */
230 if (tif->tif_flags & TIFF_SWAB) {
231 if (sp->encodepfunc == horDiff16) {
232 sp->encodepfunc = swabHorDiff16;
234 } else if (sp->encodepfunc == horDiff32) {
235 sp->encodepfunc = swabHorDiff32;
237 }
238 }
239 }
240
241 else if (sp->predictor == 3) {
242 sp->encodepfunc = fpDiff;
243 /*
244 * Override default encoding method with one that does the
245 * predictor stuff.
246 */
248 {
249 sp->encoderow = tif->tif_encoderow;
251 sp->encodestrip = tif->tif_encodestrip;
253 sp->encodetile = tif->tif_encodetile;
255 }
256 }
257
258 return 1;
259}
260
261#define REPEAT4(n, op) \
262 switch (n) { \
263 default: { \
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*/ \
269 case 0: ; \
270 }
271
272/* Remarks related to C standard compliance in all below functions : */
273/* - to avoid any undefined behaviour, we only operate on unsigned types */
274/* since the behaviour of "overflows" is defined (wrap over) */
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) */
277
279static int
281{
282 tmsize_t stride = PredictorState(tif)->stride;
283
284 unsigned char* cp = (unsigned char*) cp0;
285 if((cc%stride)!=0)
286 {
287 TIFFErrorExt(tif->tif_clientdata, "horAcc8",
288 "%s", "(cc%stride)!=0");
289 return 0;
290 }
291
292 if (cc > stride) {
293 /*
294 * Pipeline the most common cases.
295 */
296 if (stride == 3) {
297 unsigned int cr = cp[0];
298 unsigned int cg = cp[1];
299 unsigned int cb = cp[2];
300 cc -= 3;
301 cp += 3;
302 while (cc>0) {
303 cp[0] = (unsigned char) ((cr += cp[0]) & 0xff);
304 cp[1] = (unsigned char) ((cg += cp[1]) & 0xff);
305 cp[2] = (unsigned char) ((cb += cp[2]) & 0xff);
306 cc -= 3;
307 cp += 3;
308 }
309 } else if (stride == 4) {
310 unsigned int cr = cp[0];
311 unsigned int cg = cp[1];
312 unsigned int cb = cp[2];
313 unsigned int ca = cp[3];
314 cc -= 4;
315 cp += 4;
316 while (cc>0) {
317 cp[0] = (unsigned char) ((cr += cp[0]) & 0xff);
318 cp[1] = (unsigned char) ((cg += cp[1]) & 0xff);
319 cp[2] = (unsigned char) ((cb += cp[2]) & 0xff);
320 cp[3] = (unsigned char) ((ca += cp[3]) & 0xff);
321 cc -= 4;
322 cp += 4;
323 }
324 } else {
325 cc -= stride;
326 do {
328 (unsigned char) ((cp[stride] + *cp) & 0xff); cp++)
329 cc -= stride;
330 } while (cc>0);
331 }
332 }
333 return 1;
334}
335
336static int
338{
339 uint16* wp = (uint16*) cp0;
340 tmsize_t wc = cc / 2;
341
342 TIFFSwabArrayOfShort(wp, wc);
343 return horAcc16(tif, cp0, cc);
344}
345
347static int
349{
350 tmsize_t stride = PredictorState(tif)->stride;
351 uint16* wp = (uint16*) cp0;
352 tmsize_t wc = cc / 2;
353
354 if((cc%(2*stride))!=0)
355 {
356 TIFFErrorExt(tif->tif_clientdata, "horAcc16",
357 "%s", "cc%(2*stride))!=0");
358 return 0;
359 }
360
361 if (wc > stride) {
362 wc -= stride;
363 do {
364 REPEAT4(stride, wp[stride] = (uint16)(((unsigned int)wp[stride] + (unsigned int)wp[0]) & 0xffff); wp++)
365 wc -= stride;
366 } while (wc > 0);
367 }
368 return 1;
369}
370
371static int
373{
374 uint32* wp = (uint32*) cp0;
375 tmsize_t wc = cc / 4;
376
377 TIFFSwabArrayOfLong(wp, wc);
378 return horAcc32(tif, cp0, cc);
379}
380
382static int
384{
385 tmsize_t stride = PredictorState(tif)->stride;
386 uint32* wp = (uint32*) cp0;
387 tmsize_t wc = cc / 4;
388
389 if((cc%(4*stride))!=0)
390 {
391 TIFFErrorExt(tif->tif_clientdata, "horAcc32",
392 "%s", "cc%(4*stride))!=0");
393 return 0;
394 }
395
396 if (wc > stride) {
397 wc -= stride;
398 do {
399 REPEAT4(stride, wp[stride] += wp[0]; wp++)
400 wc -= stride;
401 } while (wc > 0);
402 }
403 return 1;
404}
405
406/*
407 * Floating point predictor accumulation routine.
408 */
409static int
411{
412 tmsize_t stride = PredictorState(tif)->stride;
413 uint32 bps = tif->tif_dir.td_bitspersample / 8;
414 tmsize_t wc = cc / bps;
415 tmsize_t count = cc;
416 uint8 *cp = (uint8 *) cp0;
417 uint8 *tmp;
418
419 if(cc%(bps*stride)!=0)
420 {
421 TIFFErrorExt(tif->tif_clientdata, "fpAcc",
422 "%s", "cc%(bps*stride))!=0");
423 return 0;
424 }
425
426 tmp = (uint8 *)_TIFFmalloc(cc);
427 if (!tmp)
428 return 0;
429
430 while (count > stride) {
432 (unsigned char) ((cp[stride] + cp[0]) & 0xff); cp++)
433 count -= stride;
434 }
435
436 _TIFFmemcpy(tmp, cp0, cc);
437 cp = (uint8 *) cp0;
438 for (count = 0; count < wc; count++) {
439 uint32 byte;
440 for (byte = 0; byte < bps; byte++) {
441 #if WORDS_BIGENDIAN
442 cp[bps * count + byte] = tmp[byte * wc + count];
443 #else
444 cp[bps * count + byte] =
445 tmp[(bps - byte - 1) * wc + count];
446 #endif
447 }
448 }
449 _TIFFfree(tmp);
450 return 1;
451}
452
453/*
454 * Decode a scanline and apply the predictor routine.
455 */
456static int
458{
460
461 assert(sp != NULL);
462 assert(sp->decoderow != NULL);
463 assert(sp->decodepfunc != NULL);
464
465 if ((*sp->decoderow)(tif, op0, occ0, s)) {
466 return (*sp->decodepfunc)(tif, op0, occ0);
467 } else
468 return 0;
469}
470
471/*
472 * Decode a tile/strip and apply the predictor routine.
473 * Note that horizontal differencing must be done on a
474 * row-by-row basis. The width of a "row" has already
475 * been calculated at pre-decode time according to the
476 * strip/tile dimensions.
477 */
478static int
480{
482
483 assert(sp != NULL);
484 assert(sp->decodetile != NULL);
485
486 if ((*sp->decodetile)(tif, op0, occ0, s)) {
487 tmsize_t rowsize = sp->rowsize;
488 assert(rowsize > 0);
489 if((occ0%rowsize) !=0)
490 {
491 TIFFErrorExt(tif->tif_clientdata, "PredictorDecodeTile",
492 "%s", "occ0%rowsize != 0");
493 return 0;
494 }
495 assert(sp->decodepfunc != NULL);
496 while (occ0 > 0) {
497 if( !(*sp->decodepfunc)(tif, op0, rowsize) )
498 return 0;
499 occ0 -= rowsize;
500 op0 += rowsize;
501 }
502 return 1;
503 } else
504 return 0;
505}
506
508static int
510{
512 tmsize_t stride = sp->stride;
513 unsigned char* cp = (unsigned char*) cp0;
514
515 if((cc%stride)!=0)
516 {
517 TIFFErrorExt(tif->tif_clientdata, "horDiff8",
518 "%s", "(cc%stride)!=0");
519 return 0;
520 }
521
522 if (cc > stride) {
523 cc -= stride;
524 /*
525 * Pipeline the most common cases.
526 */
527 if (stride == 3) {
528 unsigned int r1, g1, b1;
529 unsigned int r2 = cp[0];
530 unsigned int g2 = cp[1];
531 unsigned int b2 = cp[2];
532 do {
533 r1 = cp[3]; cp[3] = (unsigned char)((r1-r2)&0xff); r2 = r1;
534 g1 = cp[4]; cp[4] = (unsigned char)((g1-g2)&0xff); g2 = g1;
535 b1 = cp[5]; cp[5] = (unsigned char)((b1-b2)&0xff); b2 = b1;
536 cp += 3;
537 } while ((cc -= 3) > 0);
538 } else if (stride == 4) {
539 unsigned int r1, g1, b1, a1;
540 unsigned int r2 = cp[0];
541 unsigned int g2 = cp[1];
542 unsigned int b2 = cp[2];
543 unsigned int a2 = cp[3];
544 do {
545 r1 = cp[4]; cp[4] = (unsigned char)((r1-r2)&0xff); r2 = r1;
546 g1 = cp[5]; cp[5] = (unsigned char)((g1-g2)&0xff); g2 = g1;
547 b1 = cp[6]; cp[6] = (unsigned char)((b1-b2)&0xff); b2 = b1;
548 a1 = cp[7]; cp[7] = (unsigned char)((a1-a2)&0xff); a2 = a1;
549 cp += 4;
550 } while ((cc -= 4) > 0);
551 } else {
552 cp += cc - 1;
553 do {
554 REPEAT4(stride, cp[stride] = (unsigned char)((cp[stride] - cp[0])&0xff); cp--)
555 } while ((cc -= stride) > 0);
556 }
557 }
558 return 1;
559}
560
562static int
564{
566 tmsize_t stride = sp->stride;
567 uint16 *wp = (uint16*) cp0;
568 tmsize_t wc = cc/2;
569
570 if((cc%(2*stride))!=0)
571 {
572 TIFFErrorExt(tif->tif_clientdata, "horDiff8",
573 "%s", "(cc%(2*stride))!=0");
574 return 0;
575 }
576
577 if (wc > stride) {
578 wc -= stride;
579 wp += wc - 1;
580 do {
581 REPEAT4(stride, wp[stride] = (uint16)(((unsigned int)wp[stride] - (unsigned int)wp[0]) & 0xffff); wp--)
582 wc -= stride;
583 } while (wc > 0);
584 }
585 return 1;
586}
587
588static int
590{
591 uint16* wp = (uint16*) cp0;
592 tmsize_t wc = cc / 2;
593
594 if( !horDiff16(tif, cp0, cc) )
595 return 0;
596
597 TIFFSwabArrayOfShort(wp, wc);
598 return 1;
599}
600
602static int
604{
606 tmsize_t stride = sp->stride;
607 uint32 *wp = (uint32*) cp0;
608 tmsize_t wc = cc/4;
609
610 if((cc%(4*stride))!=0)
611 {
612 TIFFErrorExt(tif->tif_clientdata, "horDiff32",
613 "%s", "(cc%(4*stride))!=0");
614 return 0;
615 }
616
617 if (wc > stride) {
618 wc -= stride;
619 wp += wc - 1;
620 do {
621 REPEAT4(stride, wp[stride] -= wp[0]; wp--)
622 wc -= stride;
623 } while (wc > 0);
624 }
625 return 1;
626}
627
628static int
630{
631 uint32* wp = (uint32*) cp0;
632 tmsize_t wc = cc / 4;
633
634 if( !horDiff32(tif, cp0, cc) )
635 return 0;
636
637 TIFFSwabArrayOfLong(wp, wc);
638 return 1;
639}
640
641/*
642 * Floating point predictor differencing routine.
643 */
645static int
647{
648 tmsize_t stride = PredictorState(tif)->stride;
649 uint32 bps = tif->tif_dir.td_bitspersample / 8;
650 tmsize_t wc = cc / bps;
652 uint8 *cp = (uint8 *) cp0;
653 uint8 *tmp;
654
655 if((cc%(bps*stride))!=0)
656 {
657 TIFFErrorExt(tif->tif_clientdata, "fpDiff",
658 "%s", "(cc%(bps*stride))!=0");
659 return 0;
660 }
661
662 tmp = (uint8 *)_TIFFmalloc(cc);
663 if (!tmp)
664 return 0;
665
666 _TIFFmemcpy(tmp, cp0, cc);
667 for (count = 0; count < wc; count++) {
668 uint32 byte;
669 for (byte = 0; byte < bps; byte++) {
670 #if WORDS_BIGENDIAN
671 cp[byte * wc + count] = tmp[bps * count + byte];
672 #else
673 cp[(bps - byte - 1) * wc + count] =
674 tmp[bps * count + byte];
675 #endif
676 }
677 }
678 _TIFFfree(tmp);
679
680 cp = (uint8 *) cp0;
681 cp += cc - stride - 1;
682 for (count = cc; count > stride; count -= stride)
683 REPEAT4(stride, cp[stride] = (unsigned char)((cp[stride] - cp[0])&0xff); cp--)
684 return 1;
685}
686
687static int
689{
691
692 assert(sp != NULL);
693 assert(sp->encodepfunc != NULL);
694 assert(sp->encoderow != NULL);
695
696 /* XXX horizontal differencing alters user's data XXX */
697 if( !(*sp->encodepfunc)(tif, bp, cc) )
698 return 0;
699 return (*sp->encoderow)(tif, bp, cc, s);
700}
701
702static int
704{
705 static const char module[] = "PredictorEncodeTile";
707 uint8 *working_copy;
708 tmsize_t cc = cc0, rowsize;
709 unsigned char* bp;
710 int result_code;
711
712 assert(sp != NULL);
713 assert(sp->encodepfunc != NULL);
714 assert(sp->encodetile != NULL);
715
716 /*
717 * Do predictor manipulation in a working buffer to avoid altering
718 * the callers buffer. http://trac.osgeo.org/gdal/ticket/1965
719 */
720 working_copy = (uint8*) _TIFFmalloc(cc0);
721 if( working_copy == NULL )
722 {
724 "Out of memory allocating " TIFF_SSIZE_FORMAT " byte temp buffer.",
725 cc0 );
726 return 0;
727 }
728 memcpy( working_copy, bp0, cc0 );
729 bp = working_copy;
730
731 rowsize = sp->rowsize;
732 assert(rowsize > 0);
733 if((cc0%rowsize)!=0)
734 {
735 TIFFErrorExt(tif->tif_clientdata, "PredictorEncodeTile",
736 "%s", "(cc0%rowsize)!=0");
737 _TIFFfree( working_copy );
738 return 0;
739 }
740 while (cc > 0) {
741 (*sp->encodepfunc)(tif, bp, rowsize);
742 cc -= rowsize;
743 bp += rowsize;
744 }
745 result_code = (*sp->encodetile)(tif, working_copy, cc0, s);
746
747 _TIFFfree( working_copy );
748
749 return result_code;
750}
751
752#define FIELD_PREDICTOR (FIELD_CODEC+0) /* XXX */
753
754static const TIFFField predictFields[] = {
756};
757
758static int
760{
762
763 assert(sp != NULL);
764 assert(sp->vsetparent != NULL);
765
766 switch (tag) {
768 sp->predictor = (uint16) va_arg(ap, uint16_vap);
770 break;
771 default:
772 return (*sp->vsetparent)(tif, tag, ap);
773 }
775 return 1;
776}
777
778static int
780{
782
783 assert(sp != NULL);
784 assert(sp->vgetparent != NULL);
785
786 switch (tag) {
788 *va_arg(ap, uint16*) = (uint16)sp->predictor;
789 break;
790 default:
791 return (*sp->vgetparent)(tif, tag, ap);
792 }
793 return 1;
794}
795
796static void
798{
800
801 (void) flags;
802 if (TIFFFieldSet(tif,FIELD_PREDICTOR)) {
803 fprintf(fd, " Predictor: ");
804 switch (sp->predictor) {
805 case 1: fprintf(fd, "none "); break;
806 case 2: fprintf(fd, "horizontal differencing "); break;
807 case 3: fprintf(fd, "floating point predictor "); break;
808 }
809 fprintf(fd, "%d (0x%x)\n", sp->predictor, sp->predictor);
810 }
811 if (sp->printdir)
812 (*sp->printdir)(tif, fd, flags);
813}
814
815int
817{
819
820 assert(sp != 0);
821
822 /*
823 * Merge codec-specific tag information.
824 */
827 TIFFErrorExt(tif->tif_clientdata, "TIFFPredictorInit",
828 "Merging Predictor codec-specific tags failed");
829 return 0;
830 }
831
832 /*
833 * Override parent get/set field methods.
834 */
835 sp->vgetparent = tif->tif_tagmethods.vgetfield;
837 PredictorVGetField;/* hook for predictor tag */
838 sp->vsetparent = tif->tif_tagmethods.vsetfield;
840 PredictorVSetField;/* hook for predictor tag */
841 sp->printdir = tif->tif_tagmethods.printdir;
843 PredictorPrintDir; /* hook for predictor tag */
844
845 sp->setupdecode = tif->tif_setupdecode;
847 sp->setupencode = tif->tif_setupencode;
849
850 sp->predictor = 1; /* default value */
851 sp->encodepfunc = NULL; /* no predictor routine */
852 sp->decodepfunc = NULL; /* no predictor routine */
853 return 1;
854}
855
856int
858{
860
861 assert(sp != 0);
862
863 tif->tif_tagmethods.vgetfield = sp->vgetparent;
864 tif->tif_tagmethods.vsetfield = sp->vsetparent;
865 tif->tif_tagmethods.printdir = sp->printdir;
866 tif->tif_setupdecode = sp->setupdecode;
867 tif->tif_setupencode = sp->setupencode;
868
869 return 1;
870}
871
872/* vim: set ts=8 sts=8 sw=8 noet: */
873/*
874 * Local Variables:
875 * mode: c
876 * c-basic-offset: 8
877 * fill-column: 78
878 * End:
879 */
char * va_list
Definition: acmsvcex.h:78
#define va_arg(ap, T)
Definition: acmsvcex.h:89
unsigned short uint16
Definition: types.h:30
unsigned int uint32
Definition: types.h:32
unsigned char uint8
Definition: types.h:28
return
Definition: dirsup.c:529
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
static const WCHAR ca[]
Definition: main.c:455
#define byte(x, n)
Definition: tomcrypt.h:118
unsigned char
Definition: typeof.h:29
#define assert(x)
Definition: debug.h:53
GLdouble s
Definition: gl.h:2039
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizei stride
Definition: glext.h:5848
GLbitfield flags
Definition: glext.h:7161
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
uint32_t cc
Definition: isohybrid.c:75
POINT cp
Definition: magnifier.c:59
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static const struct update_accum a1
Definition: msg.c:578
static const struct update_accum a2
Definition: msg.c:586
static CRYPT_DATA_BLOB b2[]
Definition: msg.c:582
static CRYPT_DATA_BLOB b1[]
Definition: msg.c:573
static DNS_RECORDW r1
Definition: record.c:37
static DNS_RECORDW r2
Definition: record.c:38
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
static const WCHAR sp[]
Definition: suminfo.c:287
static int fd
Definition: io.c:51
uint16 td_sampleformat
Definition: tif_dir.h:76
uint16 td_samplesperpixel
Definition: tif_dir.h:82
uint16 td_bitspersample
Definition: tif_dir.h:75
uint16 td_planarconfig
Definition: tif_dir.h:89
TIFFVGetMethod vgetfield
Definition: tiffio.h:334
TIFFVSetMethod vsetfield
Definition: tiffio.h:333
TIFFPrintMethod printdir
Definition: tiffio.h:335
Definition: ecma_167.h:138
Definition: tiffiop.h:115
TIFFCodeMethod tif_encodestrip
Definition: tiffiop.h:183
TIFFCodeMethod tif_encodetile
Definition: tiffiop.h:185
TIFFTagMethods tif_tagmethods
Definition: tiffiop.h:219
TIFFCodeMethod tif_decodestrip
Definition: tiffiop.h:182
TIFFPostMethod tif_postdecode
Definition: tiffiop.h:214
thandle_t tif_clientdata
Definition: tiffiop.h:207
uint32 tif_flags
Definition: tiffiop.h:119
TIFFCodeMethod tif_decoderow
Definition: tiffiop.h:180
TIFFBoolMethod tif_setupencode
Definition: tiffiop.h:176
TIFFDirectory tif_dir
Definition: tiffiop.h:151
TIFFCodeMethod tif_encoderow
Definition: tiffiop.h:181
TIFFBoolMethod tif_setupdecode
Definition: tiffiop.h:174
TIFFCodeMethod tif_decodetile
Definition: tiffiop.h:184
#define TIFF_SSIZE_FORMAT
Definition: tif_config.h:105
#define TIFFFieldSet(tif, field)
Definition: tif_dir.h:196
@ TIFF_SETGET_UINT16
Definition: tif_dir.h:208
#define TIFFSetFieldBit(tif, field)
Definition: tif_dir.h:197
int _TIFFMergeFields(TIFF *tif, const TIFFField info[], uint32 n)
Definition: tif_dirinfo.c:369
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
static int swabHorAcc16(TIFF *tif, uint8 *cp0, tmsize_t cc)
Definition: tif_predict.c:337
static int PredictorDecodeRow(TIFF *tif, uint8 *op0, tmsize_t occ0, uint16 s)
Definition: tif_predict.c:457
#define PredictorState(tif)
Definition: tif_predict.c:33
int TIFFPredictorCleanup(TIFF *tif)
Definition: tif_predict.c:857
static int swabHorDiff16(TIFF *tif, uint8 *cp0, tmsize_t cc)
Definition: tif_predict.c:589
static int PredictorDecodeTile(TIFF *tif, uint8 *op0, tmsize_t occ0, uint16 s)
Definition: tif_predict.c:479
static int fpDiff(TIFF *tif, uint8 *cp0, tmsize_t cc)
Definition: tif_predict.c:646
#define REPEAT4(n, op)
Definition: tif_predict.c:261
static void PredictorPrintDir(TIFF *tif, FILE *fd, long flags)
Definition: tif_predict.c:797
static int PredictorSetupDecode(TIFF *tif)
Definition: tif_predict.c:113
static int PredictorEncodeRow(TIFF *tif, uint8 *bp, tmsize_t cc, uint16 s)
Definition: tif_predict.c:688
static int horAcc16(TIFF *tif, uint8 *cp0, tmsize_t cc)
Definition: tif_predict.c:348
static int swabHorDiff32(TIFF *tif, uint8 *cp0, tmsize_t cc)
Definition: tif_predict.c:629
#define FIELD_PREDICTOR
Definition: tif_predict.c:752
static int horDiff8(TIFF *tif, uint8 *cp0, tmsize_t cc)
Definition: tif_predict.c:509
static int PredictorSetupEncode(TIFF *tif)
Definition: tif_predict.c:195
static int PredictorSetup(TIFF *tif)
Definition: tif_predict.c:53
int TIFFPredictorInit(TIFF *tif)
Definition: tif_predict.c:816
static int PredictorEncodeTile(TIFF *tif, uint8 *bp0, tmsize_t cc0, uint16 s)
Definition: tif_predict.c:703
static const TIFFField predictFields[]
Definition: tif_predict.c:754
static int horAcc32(TIFF *tif, uint8 *cp0, tmsize_t cc)
Definition: tif_predict.c:383
static int fpAcc(TIFF *tif, uint8 *cp0, tmsize_t cc)
Definition: tif_predict.c:410
static int horDiff16(TIFF *tif, uint8 *cp0, tmsize_t cc)
Definition: tif_predict.c:563
static int PredictorVGetField(TIFF *tif, uint32 tag, va_list ap)
Definition: tif_predict.c:779
static int horAcc8(TIFF *tif, uint8 *cp0, tmsize_t cc)
Definition: tif_predict.c:280
static int swabHorAcc32(TIFF *tif, uint8 *cp0, tmsize_t cc)
Definition: tif_predict.c:372
static int PredictorVSetField(TIFF *tif, uint32 tag, va_list ap)
Definition: tif_predict.c:759
static int horDiff32(TIFF *tif, uint8 *cp0, tmsize_t cc)
Definition: tif_predict.c:603
void _TIFFNoPostDecode(TIFF *tif, uint8 *buf, tmsize_t cc)
Definition: tif_read.c:1603
tmsize_t TIFFScanlineSize(TIFF *tif)
Definition: tif_strip.c:314
void TIFFSwabArrayOfShort(register uint16 *wp, tmsize_t n)
Definition: tif_swab.c:71
void TIFFSwabArrayOfLong(register uint32 *lp, tmsize_t n)
Definition: tif_swab.c:103
tmsize_t TIFFTileRowSize(TIFF *tif)
Definition: tif_tile.c:180
void _TIFFfree(void *p)
Definition: tif_unix.c:326
void * _TIFFmalloc(tmsize_t s)
Definition: tif_unix.c:309
void _TIFFmemcpy(void *d, const void *s, tmsize_t c)
Definition: tif_unix.c:344
int uint16_vap
Definition: tiff.h:86
#define PREDICTOR_NONE
Definition: tiff.h:278
@ TIFF_SHORT
Definition: tiff.h:127
#define PREDICTOR_FLOATINGPOINT
Definition: tiff.h:280
#define SAMPLEFORMAT_IEEEFP
Definition: tiff.h:310
#define TIFFTAG_PREDICTOR
Definition: tiff.h:277
#define PREDICTOR_HORIZONTAL
Definition: tiff.h:279
#define PLANARCONFIG_CONTIG
Definition: tiff.h:239
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65
#define isTiled(tif)
Definition: tiffiop.h:229
#define TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW
Definition: tiffiop.h:339
#define TIFF_DIRTYDIRECT
Definition: tiffiop.h:122
#define TIFF_SWAB
Definition: tiffiop.h:126
#define TIFFArrayCount(a)
Definition: tiffiop.h:283
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36