ReactOS 0.4.16-dev-2613-g9533ad7
tif_dir.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 * Directory Tag Get & Set Routines.
29 * (and also some miscellaneous stuff)
30 */
31#include "tiffiop.h"
32#include <float.h> /*--: for Rational2Double */
33#include <limits.h>
34
35/*
36 * These are used in the backwards compatibility code...
37 */
38#define DATATYPE_VOID 0 /* !untyped data */
39#define DATATYPE_INT 1 /* !signed integer data */
40#define DATATYPE_UINT 2 /* !unsigned integer data */
41#define DATATYPE_IEEEFP 3 /* !IEEE floating point data */
42
43static void setByteArray(TIFF *tif, void **vpp, const void *vp, size_t nmemb,
44 size_t elem_size)
45{
46 if (*vpp)
47 {
48 _TIFFfreeExt(tif, *vpp);
49 *vpp = 0;
50 }
51 if (vp)
52 {
53 tmsize_t bytes = _TIFFMultiplySSize(NULL, nmemb, elem_size, NULL);
54 if (bytes)
55 *vpp = (void *)_TIFFmallocExt(tif, bytes);
56 if (*vpp)
57 _TIFFmemcpy(*vpp, vp, bytes);
58 }
59}
60void _TIFFsetByteArray(void **vpp, const void *vp, uint32_t n)
61{
62 setByteArray(NULL, vpp, vp, n, 1);
63}
64void _TIFFsetByteArrayExt(TIFF *tif, void **vpp, const void *vp, uint32_t n)
65{
66 setByteArray(tif, vpp, vp, n, 1);
67}
68
69static void _TIFFsetNString(TIFF *tif, char **cpp, const char *cp, uint32_t n)
70{
71 setByteArray(tif, (void **)cpp, cp, n, 1);
72}
73
75{
76 setByteArray(NULL, (void **)wpp, wp, n, sizeof(uint16_t));
77}
78void _TIFFsetShortArrayExt(TIFF *tif, uint16_t **wpp, const uint16_t *wp,
79 uint32_t n)
80{
81 setByteArray(tif, (void **)wpp, wp, n, sizeof(uint16_t));
82}
83
85{
86 setByteArray(NULL, (void **)lpp, lp, n, sizeof(uint32_t));
87}
88void _TIFFsetLongArrayExt(TIFF *tif, uint32_t **lpp, const uint32_t *lp,
89 uint32_t n)
90{
91 setByteArray(tif, (void **)lpp, lp, n, sizeof(uint32_t));
92}
93
94static void _TIFFsetLong8Array(TIFF *tif, uint64_t **lpp, const uint64_t *lp,
95 uint32_t n)
96{
97 setByteArray(tif, (void **)lpp, lp, n, sizeof(uint64_t));
98}
99
100void _TIFFsetFloatArray(float **fpp, const float *fp, uint32_t n)
101{
102 setByteArray(NULL, (void **)fpp, fp, n, sizeof(float));
103}
104void _TIFFsetFloatArrayExt(TIFF *tif, float **fpp, const float *fp, uint32_t n)
105{
106 setByteArray(tif, (void **)fpp, fp, n, sizeof(float));
107}
108
109void _TIFFsetDoubleArray(double **dpp, const double *dp, uint32_t n)
110{
111 setByteArray(NULL, (void **)dpp, dp, n, sizeof(double));
112}
113void _TIFFsetDoubleArrayExt(TIFF *tif, double **dpp, const double *dp,
114 uint32_t n)
115{
116 setByteArray(tif, (void **)dpp, dp, n, sizeof(double));
117}
118
119static void setDoubleArrayOneValue(TIFF *tif, double **vpp, double value,
120 size_t nmemb)
121{
122 if (*vpp)
123 _TIFFfreeExt(tif, *vpp);
124 *vpp = _TIFFmallocExt(tif, nmemb * sizeof(double));
125 if (*vpp)
126 {
127 while (nmemb--)
128 ((double *)*vpp)[nmemb] = value;
129 }
130}
131
132/*
133 * Install extra samples information.
134 */
136{
137/* XXX: Unassociated alpha data == 999 is a known Corel Draw bug, see below */
138#define EXTRASAMPLE_COREL_UNASSALPHA 999
139
140 uint16_t *va;
141 uint32_t i;
142 TIFFDirectory *td = &tif->tif_dir;
143 static const char module[] = "setExtraSamples";
144
146 if ((uint16_t)*v > td->td_samplesperpixel)
147 return 0;
148 va = va_arg(ap, uint16_t *);
149 if (*v > 0 && va == NULL) /* typically missing param */
150 return 0;
151 for (i = 0; i < *v; i++)
152 {
153 if (va[i] > EXTRASAMPLE_UNASSALPHA)
154 {
155 /*
156 * XXX: Corel Draw is known to produce incorrect
157 * ExtraSamples tags which must be patched here if we
158 * want to be able to open some of the damaged TIFF
159 * files:
160 */
163 else
164 return 0;
165 }
166 }
167
168 if (td->td_transferfunction[0] != NULL &&
169 (td->td_samplesperpixel - *v > 1) &&
170 !(td->td_samplesperpixel - td->td_extrasamples > 1))
171 {
173 "ExtraSamples tag value is changing, "
174 "but TransferFunction was read with a different value. "
175 "Canceling it");
178 td->td_transferfunction[0] = NULL;
179 }
180
181 td->td_extrasamples = (uint16_t)*v;
183 return 1;
184
185#undef EXTRASAMPLE_COREL_UNASSALPHA
186}
187
188/*
189 * Count ink names separated by \0. Returns
190 * zero if the ink names are not as expected.
191 */
192static uint16_t countInkNamesString(TIFF *tif, uint32_t slen, const char *s)
193{
194 uint16_t i = 0;
195
196 if (slen > 0)
197 {
198 const char *ep = s + slen;
199 const char *cp = s;
200 do
201 {
202 for (; cp < ep && *cp != '\0'; cp++)
203 {
204 }
205 if (cp >= ep)
206 goto bad;
207 cp++; /* skip \0 */
208 i++;
209 } while (cp < ep);
210 return (i);
211 }
212bad:
213 TIFFErrorExtR(tif, "TIFFSetField",
214 "%s: Invalid InkNames value; no null at given buffer end "
215 "location %" PRIu32 ", after %" PRIu16 " ink",
216 tif->tif_name, slen, i);
217 return (0);
218}
219
221{
222 static const char module[] = "_TIFFVSetField";
223
224 TIFFDirectory *td = &tif->tif_dir;
225 int status = 1;
226 uint32_t v32, v;
227 double dblval;
228 char *s;
229 const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
230 uint32_t standard_tag = tag;
231 if (fip == NULL) /* cannot happen since OkToChangeTag() already checks it */
232 return 0;
233 /*
234 * We want to force the custom code to be used for custom
235 * fields even if the tag happens to match a well known
236 * one - important for reinterpreted handling of standard
237 * tag values in custom directories (i.e. EXIF)
238 */
239 if (fip->field_bit == FIELD_CUSTOM)
240 {
241 standard_tag = 0;
242 }
243
244 switch (standard_tag)
245 {
248 break;
251 break;
254 break;
257 /*
258 * If the data require post-decoding processing to byte-swap
259 * samples, set it up here. Note that since tags are required
260 * to be ordered, compression code can override this behavior
261 * in the setup method if it wants to roll the post decoding
262 * work in with its normal work.
263 */
264 if (tif->tif_flags & TIFF_SWAB)
265 {
266 if (td->td_bitspersample == 8)
268 else if (td->td_bitspersample == 16)
270 else if (td->td_bitspersample == 24)
272 else if (td->td_bitspersample == 32)
274 else if (td->td_bitspersample == 64)
276 else if (td->td_bitspersample == 128) /* two 64's */
278 }
279 break;
282 /*
283 * If we're changing the compression scheme, notify the
284 * previous module so that it can cleanup any state it's
285 * setup.
286 */
288 {
289 if ((uint32_t)td->td_compression == v)
290 break;
291 (*tif->tif_cleanup)(tif);
292 tif->tif_flags &= ~TIFF_CODERSETUP;
293 }
294 /*
295 * Setup new compression routine state.
296 */
297 if ((status = TIFFSetCompressionScheme(tif, v)) != 0)
299 else
300 status = 0;
301 break;
304 break;
307 break;
311 goto badvalue;
312 td->td_fillorder = (uint16_t)v;
313 break;
317 goto badvalue;
318 else
320 break;
323 if (v == 0)
324 goto badvalue;
325 if (v != td->td_samplesperpixel)
326 {
327 /* See http://bugzilla.maptools.org/show_bug.cgi?id=2500 */
328 if (td->td_sminsamplevalue != NULL)
329 {
331 "SamplesPerPixel tag value is changing, "
332 "but SMinSampleValue tag was read with a "
333 "different value. Canceling it");
337 }
338 if (td->td_smaxsamplevalue != NULL)
339 {
341 "SamplesPerPixel tag value is changing, "
342 "but SMaxSampleValue tag was read with a "
343 "different value. Canceling it");
347 }
348 /* Test if 3 transfer functions instead of just one are now
349 needed See http://bugzilla.maptools.org/show_bug.cgi?id=2820
350 */
351 if (td->td_transferfunction[0] != NULL &&
352 (v - td->td_extrasamples > 1) &&
353 !(td->td_samplesperpixel - td->td_extrasamples > 1))
354 {
356 "SamplesPerPixel tag value is changing, "
357 "but TransferFunction was read with a "
358 "different value. Canceling it");
361 td->td_transferfunction[0] = NULL;
362 }
363 }
365 break;
367 v32 = (uint32_t)va_arg(ap, uint32_t);
368 if (v32 == 0)
369 goto badvalue32;
370 td->td_rowsperstrip = v32;
372 {
373 td->td_tilelength = v32;
374 td->td_tilewidth = td->td_imagewidth;
375 }
376 break;
379 break;
382 break;
384 if (tif->tif_flags & TIFF_PERSAMPLE)
386 va_arg(ap, double *),
388 else
390 va_arg(ap, double),
392 break;
394 if (tif->tif_flags & TIFF_PERSAMPLE)
396 va_arg(ap, double *),
398 else
400 va_arg(ap, double),
402 break;
404 dblval = va_arg(ap, double);
405 if (dblval != dblval || dblval < 0)
406 goto badvaluedouble;
408 break;
410 dblval = va_arg(ap, double);
411 if (dblval != dblval || dblval < 0)
412 goto badvaluedouble;
414 break;
418 goto badvalue;
420 break;
423 break;
426 break;
430 goto badvalue;
432 break;
436 break;
440 break;
441 case TIFFTAG_COLORMAP:
442 v32 = (uint32_t)(1L << td->td_bitspersample);
444 va_arg(ap, uint16_t *), v32);
446 va_arg(ap, uint16_t *), v32);
448 va_arg(ap, uint16_t *), v32);
449 break;
451 if (!setExtraSamples(tif, ap, &v))
452 goto badvalue;
453 break;
454 case TIFFTAG_MATTEING:
455 td->td_extrasamples = (((uint16_t)va_arg(ap, uint16_vap)) != 0);
456 if (td->td_extrasamples)
457 {
459 _TIFFsetShortArrayExt(tif, &td->td_sampleinfo, &sv, 1);
460 }
461 break;
463 v32 = (uint32_t)va_arg(ap, uint32_t);
464 if (v32 % 16)
465 {
466 if (tif->tif_mode != O_RDONLY)
467 goto badvalue32;
469 tif, tif->tif_name,
470 "Nonstandard tile width %" PRIu32 ", convert file", v32);
471 }
472 td->td_tilewidth = v32;
473 tif->tif_flags |= TIFF_ISTILED;
474 break;
476 v32 = (uint32_t)va_arg(ap, uint32_t);
477 if (v32 % 16)
478 {
479 if (tif->tif_mode != O_RDONLY)
480 goto badvalue32;
482 tif, tif->tif_name,
483 "Nonstandard tile length %" PRIu32 ", convert file", v32);
484 }
485 td->td_tilelength = v32;
486 tif->tif_flags |= TIFF_ISTILED;
487 break;
489 v32 = (uint32_t)va_arg(ap, uint32_t);
490 if (v32 == 0)
491 goto badvalue32;
492 td->td_tiledepth = v32;
493 break;
494 case TIFFTAG_DATATYPE:
496 switch (v)
497 {
498 case DATATYPE_VOID:
500 break;
501 case DATATYPE_INT:
503 break;
504 case DATATYPE_UINT:
506 break;
507 case DATATYPE_IEEEFP:
509 break;
510 default:
511 goto badvalue;
512 }
514 break;
518 goto badvalue;
520
521 /* Try to fix up the SWAB function for complex data. */
523 td->td_bitspersample == 32 &&
526 else if ((td->td_sampleformat == SAMPLEFORMAT_COMPLEXINT ||
528 td->td_bitspersample == 64 &&
531 break;
534 break;
535 case TIFFTAG_SUBIFD:
536 if ((tif->tif_flags & TIFF_INSUBIFD) == 0)
537 {
540 (uint64_t *)va_arg(ap, uint64_t *),
541 (uint32_t)td->td_nsubifd);
542 }
543 else
544 {
545 TIFFErrorExtR(tif, module, "%s: Sorry, cannot nest SubIFDs",
546 tif->tif_name);
547 status = 0;
548 }
549 break;
552 break;
556 break;
558 {
559 uint32_t i;
560 v = (td->td_samplesperpixel - td->td_extrasamples) > 1 ? 3 : 1;
561 for (i = 0; i < v; i++)
563 va_arg(ap, uint16_t *),
564 1U << td->td_bitspersample);
565 break;
566 }
568 /* XXX should check for null range */
570 va_arg(ap, float *), 6);
571 break;
572 case TIFFTAG_INKNAMES:
573 {
575 s = va_arg(ap, char *);
576 uint16_t ninksinstring;
577 ninksinstring = countInkNamesString(tif, v, s);
578 status = ninksinstring > 0;
579 if (ninksinstring > 0)
580 {
581 _TIFFsetNString(tif, &td->td_inknames, s, v);
582 td->td_inknameslen = v;
583 /* Set NumberOfInks to the value ninksinstring */
585 {
586 if (td->td_numberofinks != ninksinstring)
587 {
589 tif, module,
590 "Warning %s; Tag %s:\n Value %" PRIu16
591 " of NumberOfInks is different from the number of "
592 "inks %" PRIu16
593 ".\n -> NumberOfInks value adapted to %" PRIu16 "",
594 tif->tif_name, fip->field_name, td->td_numberofinks,
595 ninksinstring, ninksinstring);
596 td->td_numberofinks = ninksinstring;
597 }
598 }
599 else
600 {
601 td->td_numberofinks = ninksinstring;
603 }
605 {
606 if (td->td_numberofinks != td->td_samplesperpixel)
607 {
609 "Warning %s; Tag %s:\n Value %" PRIu16
610 " of NumberOfInks is different from the "
611 "SamplesPerPixel value %" PRIu16 "",
612 tif->tif_name, fip->field_name,
613 td->td_numberofinks,
615 }
616 }
617 }
618 }
619 break;
622 /* If InkNames already set also NumberOfInks is set accordingly and
623 * should be equal */
625 {
626 if (v != td->td_numberofinks)
627 {
629 tif, module,
630 "Error %s; Tag %s:\n It is not possible to set the "
631 "value %" PRIu32
632 " for NumberOfInks\n which is different from the "
633 "number of inks in the InkNames tag (%" PRIu16 ")",
634 tif->tif_name, fip->field_name, v, td->td_numberofinks);
635 /* Do not set / overwrite number of inks already set by
636 * InkNames case accordingly. */
637 status = 0;
638 }
639 }
640 else
641 {
644 {
645 if (td->td_numberofinks != td->td_samplesperpixel)
646 {
648 "Warning %s; Tag %s:\n Value %" PRIu32
649 " of NumberOfInks is different from the "
650 "SamplesPerPixel value %" PRIu16 "",
651 tif->tif_name, fip->field_name, v,
653 }
654 }
655 }
656 break;
659 if (v == PERSAMPLE_MULTI)
661 else
662 tif->tif_flags &= ~TIFF_PERSAMPLE;
663 break;
664 default:
665 {
666 TIFFTagValue *tv;
667 int tv_size, iCustom;
668
669 /*
670 * This can happen if multiple images are open with different
671 * codecs which have private tags. The global tag information
672 * table may then have tags that are valid for one file but not
673 * the other. If the client tries to set a tag that is not valid
674 * for the image's codec then we'll arrive here. This
675 * happens, for example, when tiffcp is used to convert between
676 * compression schemes and codec-specific tags are blindly copied.
677 *
678 * This also happens when a FIELD_IGNORE tag is written.
679 */
680 if (fip->field_bit == FIELD_IGNORE)
681 {
683 tif, module,
684 "%s: Ignored %stag \"%s\" (not supported by libtiff)",
685 tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "",
686 fip->field_name);
687 status = 0;
688 break;
689 }
690 if (fip->field_bit != FIELD_CUSTOM)
691 {
693 tif, module,
694 "%s: Invalid %stag \"%s\" (not supported by codec)",
695 tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "",
696 fip->field_name);
697 status = 0;
698 break;
699 }
700
701 /*
702 * Find the existing entry for this custom value.
703 */
704 tv = NULL;
705 for (iCustom = 0; iCustom < td->td_customValueCount; iCustom++)
706 {
707 if (td->td_customValues[iCustom].info->field_tag == tag)
708 {
709 tv = td->td_customValues + iCustom;
710 if (tv->value != NULL)
711 {
712 _TIFFfreeExt(tif, tv->value);
713 tv->value = NULL;
714 }
715 break;
716 }
717 }
718
719 /*
720 * Grow the custom list if the entry was not found.
721 */
722 if (tv == NULL)
723 {
724 TIFFTagValue *new_customValues;
725
726 new_customValues = (TIFFTagValue *)_TIFFreallocExt(
727 tif, td->td_customValues,
728 sizeof(TIFFTagValue) * (td->td_customValueCount + 1));
729 if (!new_customValues)
730 {
732 "%s: Failed to allocate space for list of "
733 "custom values",
734 tif->tif_name);
735 status = 0;
736 goto end;
737 }
738
740 td->td_customValues = new_customValues;
741
742 tv = td->td_customValues + (td->td_customValueCount - 1);
743 tv->info = fip;
744 tv->value = NULL;
745 tv->count = 0;
746 }
747
748 /*
749 * Set custom value ... save a copy of the custom tag value.
750 */
751 /*--: Rational2Double: For Rationals evaluate "set_get_field_type"
752 * to determine internal storage size. */
753 tv_size = TIFFFieldSetGetSize(fip);
754 if (tv_size == 0)
755 {
756 status = 0;
757 TIFFErrorExtR(tif, module, "%s: Bad field type %d for \"%s\"",
758 tif->tif_name, fip->field_type, fip->field_name);
759 goto end;
760 }
761
762 if (fip->field_type == TIFF_ASCII)
763 {
764 uint32_t ma;
765 const char *mb;
766 if (fip->field_passcount)
767 {
769 ma = (uint32_t)va_arg(ap, uint32_t);
770 mb = (const char *)va_arg(ap, const char *);
771 }
772 else
773 {
774 mb = (const char *)va_arg(ap, const char *);
775 size_t len = strlen(mb) + 1;
776 if (len >= 0x80000000U)
777 {
778 status = 0;
780 "%s: Too long string value for \"%s\". "
781 "Maximum supported is 2147483647 bytes",
782 tif->tif_name, fip->field_name);
783 goto end;
784 }
785 ma = (uint32_t)len;
786 }
787 tv->count = ma;
788 setByteArray(tif, &tv->value, mb, ma, 1);
789 }
790 else
791 {
792 if (fip->field_passcount)
793 {
796 else
797 tv->count = (int)va_arg(ap, int);
798 }
799 else if (fip->field_writecount == TIFF_VARIABLE ||
801 tv->count = 1;
802 else if (fip->field_writecount == TIFF_SPP)
803 tv->count = td->td_samplesperpixel;
804 else
805 tv->count = fip->field_writecount;
806
807 if (tv->count == 0)
808 {
810 "%s: Null count for \"%s\" (type "
811 "%d, writecount %d, passcount %d)",
812 tif->tif_name, fip->field_name,
813 fip->field_type, fip->field_writecount,
814 fip->field_passcount);
815 break;
816 }
817
818 tv->value = _TIFFCheckMalloc(tif, tv->count, tv_size,
819 "custom tag binary object");
820 if (!tv->value)
821 {
822 status = 0;
823 goto end;
824 }
825
826 if (fip->field_tag == TIFFTAG_DOTRANGE &&
827 strcmp(fip->field_name, "DotRange") == 0)
828 {
829 /* TODO: This is an evil exception and should not have been
830 handled this way ... likely best if we move it into
831 the directory structure with an explicit field in
832 libtiff 4.1 and assign it a FIELD_ value */
833 uint16_t v2[2];
834 v2[0] = (uint16_t)va_arg(ap, int);
835 v2[1] = (uint16_t)va_arg(ap, int);
836 _TIFFmemcpy(tv->value, &v2, 4);
837 }
838
839 else if (fip->field_passcount ||
842 fip->field_writecount == TIFF_SPP || tv->count > 1)
843 {
844 /*--: Rational2Double: For Rationals tv_size is set above to
845 * 4 or 8 according to fip->set_get_field_type! */
846 _TIFFmemcpy(tv->value, va_arg(ap, void *),
847 tv->count * tv_size);
848 /* Test here for too big values for LONG8, SLONG8 in
849 * ClassicTIFF and delete custom field from custom list */
850 if (!(tif->tif_flags & TIFF_BIGTIFF))
851 {
852 if (tv->info->field_type == TIFF_LONG8)
853 {
854 uint64_t *pui64 = (uint64_t *)tv->value;
855 for (int i = 0; i < tv->count; i++)
856 {
857 if (pui64[i] > 0xffffffffu)
858 {
860 tif, module,
861 "%s: Bad LONG8 value %" PRIu64
862 " at %d. array position for \"%s\" tag "
863 "%d in ClassicTIFF. Tag won't be "
864 "written to file",
865 tif->tif_name, pui64[i], i,
866 fip->field_name, tag);
867 goto badvalueifd8long8;
868 }
869 }
870 }
871 else if (tv->info->field_type == TIFF_SLONG8)
872 {
873 int64_t *pi64 = (int64_t *)tv->value;
874 for (int i = 0; i < tv->count; i++)
875 {
876 if (pi64[i] > 2147483647 ||
877 pi64[i] < (-2147483647 - 1))
878 {
880 tif, module,
881 "%s: Bad SLONG8 value %" PRIi64
882 " at %d. array position for \"%s\" tag "
883 "%d in ClassicTIFF. Tag won't be "
884 "written to file",
885 tif->tif_name, pi64[i], i,
886 fip->field_name, tag);
887 goto badvalueifd8long8;
888 }
889 }
890 }
891 }
892 }
893 else
894 {
895 char *val = (char *)tv->value;
896 assert(tv->count == 1);
897
898 switch (fip->field_type)
899 {
900 case TIFF_BYTE:
901 case TIFF_UNDEFINED:
902 {
903 uint8_t v2 = (uint8_t)va_arg(ap, int);
904 _TIFFmemcpy(val, &v2, tv_size);
905 }
906 break;
907 case TIFF_SBYTE:
908 {
909 int8_t v2 = (int8_t)va_arg(ap, int);
910 _TIFFmemcpy(val, &v2, tv_size);
911 }
912 break;
913 case TIFF_SHORT:
914 {
915 uint16_t v2 = (uint16_t)va_arg(ap, int);
916 _TIFFmemcpy(val, &v2, tv_size);
917 }
918 break;
919 case TIFF_SSHORT:
920 {
921 int16_t v2 = (int16_t)va_arg(ap, int);
922 _TIFFmemcpy(val, &v2, tv_size);
923 }
924 break;
925 case TIFF_LONG:
926 case TIFF_IFD:
927 {
929 _TIFFmemcpy(val, &v2, tv_size);
930 }
931 break;
932 case TIFF_SLONG:
933 {
935 _TIFFmemcpy(val, &v2, tv_size);
936 }
937 break;
938 case TIFF_LONG8:
939 case TIFF_IFD8:
940 {
942 _TIFFmemcpy(val, &v2, tv_size);
943 /* Test here for too big values for ClassicTIFF and
944 * delete custom field from custom list */
945 if (!(tif->tif_flags & TIFF_BIGTIFF) &&
946 (v2 > 0xffffffffu))
947 {
949 tif, module,
950 "%s: Bad LONG8 or IFD8 value %" PRIu64
951 " for \"%s\" tag %d in ClassicTIFF. Tag "
952 "won't be written to file",
953 tif->tif_name, v2, fip->field_name, tag);
954 goto badvalueifd8long8;
955 }
956 }
957 break;
958 case TIFF_SLONG8:
959 {
961 _TIFFmemcpy(val, &v2, tv_size);
962 /* Test here for too big values for ClassicTIFF and
963 * delete custom field from custom list */
964 if (!(tif->tif_flags & TIFF_BIGTIFF) &&
965 ((v2 > 2147483647) || (v2 < (-2147483647 - 1))))
966 {
968 tif, module,
969 "%s: Bad SLONG8 value %" PRIi64
970 " for \"%s\" tag %d in ClassicTIFF. Tag "
971 "won't be written to file",
972 tif->tif_name, v2, fip->field_name, tag);
973 goto badvalueifd8long8;
974 }
975 }
976 break;
977 case TIFF_RATIONAL:
978 case TIFF_SRATIONAL:
979 /*-- Rational2Double: For Rationals tv_size is set
980 * above to 4 or 8 according to
981 * fip->set_get_field_type!
982 */
983 {
984 if (tv_size == 8)
985 {
986 double v2 = va_arg(ap, double);
987 _TIFFmemcpy(val, &v2, tv_size);
988 }
989 else
990 {
991 /*-- default should be tv_size == 4 */
992 float v3 = (float)va_arg(ap, double);
993 _TIFFmemcpy(val, &v3, tv_size);
994 /*-- ToDo: After Testing, this should be
995 * removed and tv_size==4 should be set as
996 * default. */
997 if (tv_size != 4)
998 {
1000 "Rational2Double: "
1001 ".set_get_field_type "
1002 "in not 4 but %d",
1003 tv_size);
1004 }
1005 }
1006 }
1007 break;
1008 case TIFF_FLOAT:
1009 {
1010 float v2 =
1012 _TIFFmemcpy(val, &v2, tv_size);
1013 }
1014 break;
1015 case TIFF_DOUBLE:
1016 {
1017 double v2 = va_arg(ap, double);
1018 _TIFFmemcpy(val, &v2, tv_size);
1019 }
1020 break;
1021 default:
1022 _TIFFmemset(val, 0, tv_size);
1023 status = 0;
1024 break;
1025 }
1026 }
1027 }
1028 }
1029 }
1030 if (status)
1031 {
1032 const TIFFField *fip2 = TIFFFieldWithTag(tif, tag);
1033 if (fip2)
1034 TIFFSetFieldBit(tif, fip2->field_bit);
1036 }
1037
1038end:
1039 va_end(ap);
1040 return (status);
1041badvalue:
1042{
1043 const TIFFField *fip2 = TIFFFieldWithTag(tif, tag);
1044 TIFFErrorExtR(tif, module, "%s: Bad value %" PRIu32 " for \"%s\" tag",
1045 tif->tif_name, v, fip2 ? fip2->field_name : "Unknown");
1046 va_end(ap);
1047}
1048 return (0);
1049badvalue32:
1050{
1051 const TIFFField *fip2 = TIFFFieldWithTag(tif, tag);
1052 TIFFErrorExtR(tif, module, "%s: Bad value %" PRIu32 " for \"%s\" tag",
1053 tif->tif_name, v32, fip2 ? fip2->field_name : "Unknown");
1054 va_end(ap);
1055}
1056 return (0);
1057badvaluedouble:
1058{
1059 const TIFFField *fip2 = TIFFFieldWithTag(tif, tag);
1060 TIFFErrorExtR(tif, module, "%s: Bad value %f for \"%s\" tag", tif->tif_name,
1061 dblval, fip2 ? fip2->field_name : "Unknown");
1062 va_end(ap);
1063}
1064 return (0);
1065badvalueifd8long8:
1066{
1067 /* Error message issued already above. */
1068 TIFFTagValue *tv2 = NULL;
1069 int iCustom2, iC2;
1070 /* Find the existing entry for this custom value. */
1071 for (iCustom2 = 0; iCustom2 < td->td_customValueCount; iCustom2++)
1072 {
1073 if (td->td_customValues[iCustom2].info->field_tag == tag)
1074 {
1075 tv2 = td->td_customValues + (iCustom2);
1076 break;
1077 }
1078 }
1079 if (tv2 != NULL)
1080 {
1081 /* Remove custom field from custom list */
1082 if (tv2->value != NULL)
1083 {
1084 _TIFFfreeExt(tif, tv2->value);
1085 tv2->value = NULL;
1086 }
1087 /* Shorten list and close gap in customValues list.
1088 * Re-allocation of td_customValues not necessary here. */
1089 td->td_customValueCount--;
1090 for (iC2 = iCustom2; iC2 < td->td_customValueCount; iC2++)
1091 {
1092 td->td_customValues[iC2] = td->td_customValues[iC2 + 1];
1093 }
1094 }
1095 else
1096 {
1097 assert(0);
1098 }
1099 va_end(ap);
1100}
1101 return (0);
1102} /*-- _TIFFVSetField() --*/
1103
1104/*
1105 * Return 1/0 according to whether or not
1106 * it is permissible to set the tag's value.
1107 * Note that we allow ImageLength to be changed
1108 * so that we can append and extend to images.
1109 * Any other tag may not be altered once writing
1110 * has commenced, unless its value has no effect
1111 * on the format of the data that is written.
1112 */
1114{
1115 const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
1116 if (!fip)
1117 { /* unknown tag */
1118 TIFFErrorExtR(tif, "TIFFSetField", "%s: Unknown %stag %" PRIu32,
1119 tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", tag);
1120 return (0);
1121 }
1123 !fip->field_oktochange)
1124 {
1125 /*
1126 * Consult info table to see if tag can be changed
1127 * after we've started writing. We only allow changes
1128 * to those tags that don't/shouldn't affect the
1129 * compression and/or format of the data.
1130 */
1131 TIFFErrorExtR(tif, "TIFFSetField",
1132 "%s: Cannot modify tag \"%s\" while writing",
1133 tif->tif_name, fip->field_name);
1134 return (0);
1135 }
1136 return (1);
1137}
1138
1139/*
1140 * Record the value of a field in the
1141 * internal directory structure. The
1142 * field will be written to the file
1143 * when/if the directory structure is
1144 * updated.
1145 */
1147{
1148 va_list ap;
1149 int status;
1150
1151 va_start(ap, tag);
1152 status = TIFFVSetField(tif, tag, ap);
1153 va_end(ap);
1154 return (status);
1155}
1156
1157/*
1158 * Clear the contents of the field in the internal structure.
1159 */
1161{
1162 const TIFFField *fip = TIFFFieldWithTag(tif, tag);
1163 TIFFDirectory *td = &tif->tif_dir;
1164
1165 if (!fip)
1166 return 0;
1167
1168 if (fip->field_bit != FIELD_CUSTOM)
1169 TIFFClrFieldBit(tif, fip->field_bit);
1170 else
1171 {
1172 TIFFTagValue *tv = NULL;
1173 int i;
1174
1175 for (i = 0; i < td->td_customValueCount; i++)
1176 {
1177
1178 tv = td->td_customValues + i;
1179 if (tv->info->field_tag == tag)
1180 break;
1181 }
1182
1183 if (i < td->td_customValueCount)
1184 {
1185 _TIFFfreeExt(tif, tv->value);
1186 for (; i < td->td_customValueCount - 1; i++)
1187 {
1188 td->td_customValues[i] = td->td_customValues[i + 1];
1189 }
1190 td->td_customValueCount--;
1191 }
1192 }
1193
1195
1196 return (1);
1197}
1198
1199/*
1200 * Like TIFFSetField, but taking a varargs
1201 * parameter list. This routine is useful
1202 * for building higher-level interfaces on
1203 * top of the library.
1204 */
1206{
1207 return OkToChangeTag(tif, tag)
1208 ? (*tif->tif_tagmethods.vsetfield)(tif, tag, ap)
1209 : 0;
1210}
1211
1213{
1214 TIFFDirectory *td = &tif->tif_dir;
1215 int ret_val = 1;
1216 uint32_t standard_tag = tag;
1217 const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
1218 if (fip == NULL) /* cannot happen since TIFFGetField() already checks it */
1219 return 0;
1220
1221 /*
1222 * We want to force the custom code to be used for custom
1223 * fields even if the tag happens to match a well known
1224 * one - important for reinterpreted handling of standard
1225 * tag values in custom directories (i.e. EXIF)
1226 */
1227 if (fip->field_bit == FIELD_CUSTOM)
1228 {
1229 standard_tag = 0;
1230 }
1231
1232 switch (standard_tag)
1233 {
1235 *va_arg(ap, uint32_t *) = td->td_subfiletype;
1236 break;
1237 case TIFFTAG_IMAGEWIDTH:
1238 *va_arg(ap, uint32_t *) = td->td_imagewidth;
1239 break;
1241 *va_arg(ap, uint32_t *) = td->td_imagelength;
1242 break;
1245 break;
1247 *va_arg(ap, uint16_t *) = td->td_compression;
1248 break;
1250 *va_arg(ap, uint16_t *) = td->td_photometric;
1251 break;
1254 break;
1255 case TIFFTAG_FILLORDER:
1256 *va_arg(ap, uint16_t *) = td->td_fillorder;
1257 break;
1259 *va_arg(ap, uint16_t *) = td->td_orientation;
1260 break;
1263 break;
1265 *va_arg(ap, uint32_t *) = td->td_rowsperstrip;
1266 break;
1269 break;
1272 break;
1274 if (tif->tif_flags & TIFF_PERSAMPLE)
1275 *va_arg(ap, double **) = td->td_sminsamplevalue;
1276 else
1277 {
1278 /* libtiff historically treats this as a single value. */
1279 uint16_t i;
1280 double v = td->td_sminsamplevalue[0];
1281 for (i = 1; i < td->td_samplesperpixel; ++i)
1282 if (td->td_sminsamplevalue[i] < v)
1283 v = td->td_sminsamplevalue[i];
1284 *va_arg(ap, double *) = v;
1285 }
1286 break;
1288 if (tif->tif_flags & TIFF_PERSAMPLE)
1289 *va_arg(ap, double **) = td->td_smaxsamplevalue;
1290 else
1291 {
1292 /* libtiff historically treats this as a single value. */
1293 uint16_t i;
1294 double v = td->td_smaxsamplevalue[0];
1295 for (i = 1; i < td->td_samplesperpixel; ++i)
1296 if (td->td_smaxsamplevalue[i] > v)
1297 v = td->td_smaxsamplevalue[i];
1298 *va_arg(ap, double *) = v;
1299 }
1300 break;
1302 *va_arg(ap, float *) = td->td_xresolution;
1303 break;
1305 *va_arg(ap, float *) = td->td_yresolution;
1306 break;
1308 *va_arg(ap, uint16_t *) = td->td_planarconfig;
1309 break;
1310 case TIFFTAG_XPOSITION:
1311 *va_arg(ap, float *) = td->td_xposition;
1312 break;
1313 case TIFFTAG_YPOSITION:
1314 *va_arg(ap, float *) = td->td_yposition;
1315 break;
1318 break;
1319 case TIFFTAG_PAGENUMBER:
1320 *va_arg(ap, uint16_t *) = td->td_pagenumber[0];
1321 *va_arg(ap, uint16_t *) = td->td_pagenumber[1];
1322 break;
1324 *va_arg(ap, uint16_t *) = td->td_halftonehints[0];
1325 *va_arg(ap, uint16_t *) = td->td_halftonehints[1];
1326 break;
1327 case TIFFTAG_COLORMAP:
1328 *va_arg(ap, const uint16_t **) = td->td_colormap[0];
1329 *va_arg(ap, const uint16_t **) = td->td_colormap[1];
1330 *va_arg(ap, const uint16_t **) = td->td_colormap[2];
1331 break;
1334 _TIFFFillStriles(tif);
1335 *va_arg(ap, const uint64_t **) = td->td_stripoffset_p;
1336 if (td->td_stripoffset_p == NULL)
1337 ret_val = 0;
1338 break;
1341 _TIFFFillStriles(tif);
1342 *va_arg(ap, const uint64_t **) = td->td_stripbytecount_p;
1343 if (td->td_stripbytecount_p == NULL)
1344 ret_val = 0;
1345 break;
1346 case TIFFTAG_MATTEING:
1347 *va_arg(ap, uint16_t *) =
1348 (td->td_extrasamples == 1 &&
1350 break;
1352 *va_arg(ap, uint16_t *) = td->td_extrasamples;
1353 *va_arg(ap, const uint16_t **) = td->td_sampleinfo;
1354 break;
1355 case TIFFTAG_TILEWIDTH:
1356 *va_arg(ap, uint32_t *) = td->td_tilewidth;
1357 break;
1358 case TIFFTAG_TILELENGTH:
1359 *va_arg(ap, uint32_t *) = td->td_tilelength;
1360 break;
1361 case TIFFTAG_TILEDEPTH:
1362 *va_arg(ap, uint32_t *) = td->td_tiledepth;
1363 break;
1364 case TIFFTAG_DATATYPE:
1365 switch (td->td_sampleformat)
1366 {
1367 case SAMPLEFORMAT_UINT:
1369 break;
1370 case SAMPLEFORMAT_INT:
1372 break;
1375 break;
1376 case SAMPLEFORMAT_VOID:
1378 break;
1379 }
1380 break;
1382 *va_arg(ap, uint16_t *) = td->td_sampleformat;
1383 break;
1384 case TIFFTAG_IMAGEDEPTH:
1385 *va_arg(ap, uint32_t *) = td->td_imagedepth;
1386 break;
1387 case TIFFTAG_SUBIFD:
1388 *va_arg(ap, uint16_t *) = td->td_nsubifd;
1389 *va_arg(ap, const uint64_t **) = td->td_subifd;
1390 break;
1393 break;
1395 *va_arg(ap, uint16_t *) = td->td_ycbcrsubsampling[0];
1396 *va_arg(ap, uint16_t *) = td->td_ycbcrsubsampling[1];
1397 break;
1399 *va_arg(ap, const uint16_t **) = td->td_transferfunction[0];
1400 if (td->td_samplesperpixel - td->td_extrasamples > 1)
1401 {
1402 *va_arg(ap, const uint16_t **) = td->td_transferfunction[1];
1403 *va_arg(ap, const uint16_t **) = td->td_transferfunction[2];
1404 }
1405 else
1406 {
1407 *va_arg(ap, const uint16_t **) = NULL;
1408 *va_arg(ap, const uint16_t **) = NULL;
1409 }
1410 break;
1412 *va_arg(ap, const float **) = td->td_refblackwhite;
1413 break;
1414 case TIFFTAG_INKNAMES:
1415 *va_arg(ap, const char **) = td->td_inknames;
1416 break;
1418 *va_arg(ap, uint16_t *) = td->td_numberofinks;
1419 break;
1420 default:
1421 {
1422 int i;
1423
1424 /*
1425 * This can happen if multiple images are open
1426 * with different codecs which have private
1427 * tags. The global tag information table may
1428 * then have tags that are valid for one file
1429 * but not the other. If the client tries to
1430 * get a tag that is not valid for the image's
1431 * codec then we'll arrive here.
1432 */
1433 if (fip->field_bit != FIELD_CUSTOM)
1434 {
1435 TIFFErrorExtR(tif, "_TIFFVGetField",
1436 "%s: Invalid %stag \"%s\" "
1437 "(not supported by codec)",
1438 tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "",
1439 fip->field_name);
1440 ret_val = 0;
1441 break;
1442 }
1443
1444 /*
1445 * Do we have a custom value?
1446 */
1447 ret_val = 0;
1448 for (i = 0; i < td->td_customValueCount; i++)
1449 {
1450 TIFFTagValue *tv = td->td_customValues + i;
1451
1452 if (tv->info->field_tag != tag)
1453 continue;
1454
1455 if (fip->field_passcount)
1456 {
1457 if (fip->field_readcount == TIFF_VARIABLE2)
1458 *va_arg(ap, uint32_t *) = (uint32_t)tv->count;
1459 else /* Assume TIFF_VARIABLE */
1460 *va_arg(ap, uint16_t *) = (uint16_t)tv->count;
1461 *va_arg(ap, const void **) = tv->value;
1462 ret_val = 1;
1463 }
1464 else if (fip->field_tag == TIFFTAG_DOTRANGE &&
1465 strcmp(fip->field_name, "DotRange") == 0)
1466 {
1467 /* TODO: This is an evil exception and should not have been
1468 handled this way ... likely best if we move it into
1469 the directory structure with an explicit field in
1470 libtiff 4.1 and assign it a FIELD_ value */
1471 *va_arg(ap, uint16_t *) = ((uint16_t *)tv->value)[0];
1472 *va_arg(ap, uint16_t *) = ((uint16_t *)tv->value)[1];
1473 ret_val = 1;
1474 }
1475 else
1476 {
1477 if (fip->field_type == TIFF_ASCII ||
1480 fip->field_readcount == TIFF_SPP || tv->count > 1)
1481 {
1482 *va_arg(ap, void **) = tv->value;
1483 ret_val = 1;
1484 }
1485 else
1486 {
1487 char *val = (char *)tv->value;
1488 assert(tv->count == 1);
1489 switch (fip->field_type)
1490 {
1491 case TIFF_BYTE:
1492 case TIFF_UNDEFINED:
1493 *va_arg(ap, uint8_t *) = *(uint8_t *)val;
1494 ret_val = 1;
1495 break;
1496 case TIFF_SBYTE:
1497 *va_arg(ap, int8_t *) = *(int8_t *)val;
1498 ret_val = 1;
1499 break;
1500 case TIFF_SHORT:
1501 *va_arg(ap, uint16_t *) = *(uint16_t *)val;
1502 ret_val = 1;
1503 break;
1504 case TIFF_SSHORT:
1505 *va_arg(ap, int16_t *) = *(int16_t *)val;
1506 ret_val = 1;
1507 break;
1508 case TIFF_LONG:
1509 case TIFF_IFD:
1510 *va_arg(ap, uint32_t *) = *(uint32_t *)val;
1511 ret_val = 1;
1512 break;
1513 case TIFF_SLONG:
1514 *va_arg(ap, int32_t *) = *(int32_t *)val;
1515 ret_val = 1;
1516 break;
1517 case TIFF_LONG8:
1518 case TIFF_IFD8:
1519 *va_arg(ap, uint64_t *) = *(uint64_t *)val;
1520 ret_val = 1;
1521 break;
1522 case TIFF_SLONG8:
1523 *va_arg(ap, int64_t *) = *(int64_t *)val;
1524 ret_val = 1;
1525 break;
1526 case TIFF_RATIONAL:
1527 case TIFF_SRATIONAL:
1528 {
1529 /*-- Rational2Double: For Rationals evaluate
1530 * "set_get_field_type" to determine internal
1531 * storage size and return value size. */
1532 int tv_size = TIFFFieldSetGetSize(fip);
1533 if (tv_size == 8)
1534 {
1535 *va_arg(ap, double *) = *(double *)val;
1536 ret_val = 1;
1537 }
1538 else
1539 {
1540 /*-- default should be tv_size == 4 */
1541 *va_arg(ap, float *) = *(float *)val;
1542 ret_val = 1;
1543 /*-- ToDo: After Testing, this should be
1544 * removed and tv_size==4 should be set as
1545 * default. */
1546 if (tv_size != 4)
1547 {
1548 TIFFErrorExtR(tif, "_TIFFVGetField",
1549 "Rational2Double: "
1550 ".set_get_field_type "
1551 "in not 4 but %d",
1552 tv_size);
1553 }
1554 }
1555 }
1556 break;
1557 case TIFF_FLOAT:
1558 *va_arg(ap, float *) = *(float *)val;
1559 ret_val = 1;
1560 break;
1561 case TIFF_DOUBLE:
1562 *va_arg(ap, double *) = *(double *)val;
1563 ret_val = 1;
1564 break;
1565 default:
1566 ret_val = 0;
1567 break;
1568 }
1569 }
1570 }
1571 break;
1572 }
1573 }
1574 }
1575 return (ret_val);
1576}
1577
1578/*
1579 * Return the value of a field in the
1580 * internal directory structure.
1581 */
1583{
1584 int status;
1585 va_list ap;
1586
1587 va_start(ap, tag);
1588 status = TIFFVGetField(tif, tag, ap);
1589 va_end(ap);
1590 return (status);
1591}
1592
1593/*
1594 * Like TIFFGetField, but taking a varargs
1595 * parameter list. This routine is useful
1596 * for building higher-level interfaces on
1597 * top of the library.
1598 */
1600{
1601 const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
1602 return (fip && (isPseudoTag(tag) || TIFFFieldSet(tif, fip->field_bit))
1603 ? (*tif->tif_tagmethods.vgetfield)(tif, tag, ap)
1604 : 0);
1605}
1606
1607#define CleanupField(member) \
1608 { \
1609 if (td->member) \
1610 { \
1611 _TIFFfreeExt(tif, td->member); \
1612 td->member = 0; \
1613 } \
1614 }
1615
1616/*
1617 * Release storage associated with a directory.
1618 */
1620{
1621 TIFFDirectory *td = &tif->tif_dir;
1622 int i;
1623
1624 (*tif->tif_cleanup)(tif);
1625 _TIFFmemset(td->td_fieldsset, 0, sizeof(td->td_fieldsset));
1626 CleanupField(td_sminsamplevalue);
1627 CleanupField(td_smaxsamplevalue);
1628 CleanupField(td_colormap[0]);
1629 CleanupField(td_colormap[1]);
1630 CleanupField(td_colormap[2]);
1631 CleanupField(td_sampleinfo);
1632 CleanupField(td_subifd);
1633 CleanupField(td_inknames);
1634 CleanupField(td_refblackwhite);
1635 CleanupField(td_transferfunction[0]);
1636 CleanupField(td_transferfunction[1]);
1637 CleanupField(td_transferfunction[2]);
1638 CleanupField(td_stripoffset_p);
1639 CleanupField(td_stripbytecount_p);
1643
1644 /* Cleanup custom tag values */
1645 for (i = 0; i < td->td_customValueCount; i++)
1646 {
1647 if (td->td_customValues[i].value)
1649 }
1650
1651 td->td_customValueCount = 0;
1652 CleanupField(td_customValues);
1653
1654 _TIFFmemset(&(td->td_stripoffset_entry), 0, sizeof(TIFFDirEntry));
1656
1657 /* Reset some internal parameters for IFD data size checking. */
1661 {
1665 }
1667}
1668#undef CleanupField
1669
1670/*
1671 * Client Tag extension support (from Niles Ritter).
1672 */
1674
1676{
1678 _TIFFextender = extender;
1679 return (prev);
1680}
1681
1682/*
1683 * Setup for a new directory. Should we automatically call
1684 * TIFFWriteDirectory() if the current one is dirty?
1685 *
1686 * The newly created directory will not exist on the file till
1687 * TIFFWriteDirectory(), TIFFFlush() or TIFFClose() is called.
1688 */
1690{
1691 /* Free previously allocated memory and setup default values. */
1692 TIFFFreeDirectory(tif);
1694 tif->tif_diroff = 0;
1695 tif->tif_nextdiroff = 0;
1696 tif->tif_curoff = 0;
1697 tif->tif_row = (uint32_t)-1;
1698 tif->tif_curstrip = (uint32_t)-1;
1700
1701 return 0;
1702}
1703
1705{
1706 /* Free previously allocated memory and setup default values. */
1707 TIFFFreeDirectory(tif);
1709
1710 /*
1711 * Reset the field definitions to match the application provided list.
1712 * Hopefully TIFFDefaultDirectory() won't have done anything irreversible
1713 * based on it's assumption this is an image directory.
1714 */
1715 _TIFFSetupFields(tif, infoarray);
1716
1717 tif->tif_diroff = 0;
1718 tif->tif_nextdiroff = 0;
1719 tif->tif_curoff = 0;
1720 tif->tif_row = (uint32_t)-1;
1721 tif->tif_curstrip = (uint32_t)-1;
1722 /* invalidate directory index */
1724 /* invalidate IFD loop lists */
1726 /* To be able to return from SubIFD or custom-IFD to main-IFD */
1728
1729 return 0;
1730}
1731
1733{
1737}
1738
1739/*
1740 * Creates the EXIF GPS custom directory
1741 */
1743{
1747}
1748
1749/*
1750 * Setup a default directory structure.
1751 */
1753{
1754 register TIFFDirectory *td = &tif->tif_dir;
1756
1759
1760 _TIFFmemset(td, 0, sizeof(*td));
1762 td->td_bitspersample = 1;
1765 td->td_samplesperpixel = 1;
1766 td->td_rowsperstrip = (uint32_t)-1;
1767 td->td_tilewidth = 0;
1768 td->td_tilelength = 0;
1769 td->td_tiledepth = 1;
1770#ifdef STRIPBYTECOUNTSORTED_UNUSED
1771 td->td_stripbytecountsorted = 1; /* Our own arrays always sorted. */
1772#endif
1775 td->td_imagedepth = 1;
1776 td->td_ycbcrsubsampling[0] = 2;
1777 td->td_ycbcrsubsampling[1] = 2;
1780 tif->tif_foundfield = NULL;
1784 /* additional default values */
1787 td->td_subfiletype = 0;
1788 td->td_minsamplevalue = 0;
1789 /* td_bitspersample=1 is always set in TIFFDefaultDirectory().
1790 * Therefore, td_maxsamplevalue has to be re-calculated in
1791 * TIFFGetFieldDefaulted(). */
1792 td->td_maxsamplevalue = 1; /* Default for td_bitspersample=1 */
1793 td->td_extrasamples = 0;
1794 td->td_sampleinfo = NULL;
1795
1796 /*
1797 * Give client code a chance to install their own
1798 * tag extensions & methods, prior to compression overloads,
1799 * but do some prior cleanup first.
1800 * (http://trac.osgeo.org/gdal/ticket/5054)
1801 */
1802 if (tif->tif_nfieldscompat > 0)
1803 {
1804 uint32_t i;
1805
1806 for (i = 0; i < tif->tif_nfieldscompat; i++)
1807 {
1810 }
1811 _TIFFfreeExt(tif, tif->tif_fieldscompat);
1812 tif->tif_nfieldscompat = 0;
1813 tif->tif_fieldscompat = NULL;
1814 }
1815 if (_TIFFextender)
1816 (*_TIFFextender)(tif);
1818 /*
1819 * NB: The directory is marked dirty as a result of setting
1820 * up the default compression scheme. However, this really
1821 * isn't correct -- we want TIFF_DIRTYDIRECT to be set only
1822 * if the user does something. We could just do the setup
1823 * by hand, but it seems better to use the normal mechanism
1824 * (i.e. TIFFSetField).
1825 */
1826 tif->tif_flags &= ~TIFF_DIRTYDIRECT;
1827
1828 /*
1829 * As per http://bugzilla.remotesensing.org/show_bug.cgi?id=19
1830 * we clear the ISTILED flag when setting up a new directory.
1831 * Should we also be clearing stuff like INSUBIFD?
1832 */
1833 tif->tif_flags &= ~TIFF_ISTILED;
1834
1835 return (1);
1836}
1837
1838static int TIFFAdvanceDirectory(TIFF *tif, uint64_t *nextdiroff, uint64_t *off,
1839 tdir_t *nextdirnum)
1840{
1841 static const char module[] = "TIFFAdvanceDirectory";
1842
1843 /* Add this directory to the directory list, if not already in. */
1844 if (!_TIFFCheckDirNumberAndOffset(tif, *nextdirnum, *nextdiroff))
1845 {
1846 TIFFErrorExtR(tif, module,
1847 "Starting directory %u at offset 0x%" PRIx64 " (%" PRIu64
1848 ") might cause an IFD loop",
1849 *nextdirnum, *nextdiroff, *nextdiroff);
1850 *nextdiroff = 0;
1851 *nextdirnum = 0;
1852 return (0);
1853 }
1854
1855 if (isMapped(tif))
1856 {
1857 uint64_t poff = *nextdiroff;
1858 if (!(tif->tif_flags & TIFF_BIGTIFF))
1859 {
1860 tmsize_t poffa, poffb, poffc, poffd;
1861 uint16_t dircount;
1862 uint32_t nextdir32;
1863 poffa = (tmsize_t)poff;
1864 poffb = poffa + sizeof(uint16_t);
1865 if (((uint64_t)poffa != poff) || (poffb < poffa) ||
1866 (poffb < (tmsize_t)sizeof(uint16_t)) || (poffb > tif->tif_size))
1867 {
1868 TIFFErrorExtR(tif, module,
1869 "%s:%d: %s: Error fetching directory count",
1870 __FILE__, __LINE__, tif->tif_name);
1871 *nextdiroff = 0;
1872 return (0);
1873 }
1874 _TIFFmemcpy(&dircount, tif->tif_base + poffa, sizeof(uint16_t));
1875 if (tif->tif_flags & TIFF_SWAB)
1876 TIFFSwabShort(&dircount);
1877 poffc = poffb + dircount * 12;
1878 poffd = poffc + sizeof(uint32_t);
1879 if ((poffc < poffb) || (poffc < dircount * 12) || (poffd < poffc) ||
1880 (poffd < (tmsize_t)sizeof(uint32_t)) || (poffd > tif->tif_size))
1881 {
1882 TIFFErrorExtR(tif, module, "Error fetching directory link");
1883 return (0);
1884 }
1885 if (off != NULL)
1886 *off = (uint64_t)poffc;
1887 _TIFFmemcpy(&nextdir32, tif->tif_base + poffc, sizeof(uint32_t));
1888 if (tif->tif_flags & TIFF_SWAB)
1889 TIFFSwabLong(&nextdir32);
1890 *nextdiroff = nextdir32;
1891 }
1892 else
1893 {
1894 tmsize_t poffa, poffb, poffc, poffd;
1895 uint64_t dircount64;
1896 uint16_t dircount16;
1897 if (poff > (uint64_t)TIFF_TMSIZE_T_MAX - sizeof(uint64_t))
1898 {
1899 TIFFErrorExtR(tif, module,
1900 "%s:%d: %s: Error fetching directory count",
1901 __FILE__, __LINE__, tif->tif_name);
1902 return (0);
1903 }
1904 poffa = (tmsize_t)poff;
1905 poffb = poffa + sizeof(uint64_t);
1906 if (poffb > tif->tif_size)
1907 {
1908 TIFFErrorExtR(tif, module,
1909 "%s:%d: %s: Error fetching directory count",
1910 __FILE__, __LINE__, tif->tif_name);
1911 return (0);
1912 }
1913 _TIFFmemcpy(&dircount64, tif->tif_base + poffa, sizeof(uint64_t));
1914 if (tif->tif_flags & TIFF_SWAB)
1915 TIFFSwabLong8(&dircount64);
1916 if (dircount64 > 0xFFFF)
1917 {
1918 TIFFErrorExtR(tif, module,
1919 "Sanity check on directory count failed");
1920 return (0);
1921 }
1922 dircount16 = (uint16_t)dircount64;
1923 if (poffb > TIFF_TMSIZE_T_MAX - (tmsize_t)(dircount16 * 20) -
1924 (tmsize_t)sizeof(uint64_t))
1925 {
1926 TIFFErrorExtR(tif, module, "Error fetching directory link");
1927 return (0);
1928 }
1929 poffc = poffb + dircount16 * 20;
1930 poffd = poffc + sizeof(uint64_t);
1931 if (poffd > tif->tif_size)
1932 {
1933 TIFFErrorExtR(tif, module, "Error fetching directory link");
1934 return (0);
1935 }
1936 if (off != NULL)
1937 *off = (uint64_t)poffc;
1938 _TIFFmemcpy(nextdiroff, tif->tif_base + poffc, sizeof(uint64_t));
1939 if (tif->tif_flags & TIFF_SWAB)
1940 TIFFSwabLong8(nextdiroff);
1941 }
1942 }
1943 else
1944 {
1945 if (!(tif->tif_flags & TIFF_BIGTIFF))
1946 {
1947 uint16_t dircount;
1948 uint32_t nextdir32;
1949 if (!SeekOK(tif, *nextdiroff) ||
1950 !ReadOK(tif, &dircount, sizeof(uint16_t)))
1951 {
1952 TIFFErrorExtR(tif, module,
1953 "%s:%d: %s: Error fetching directory count",
1954 __FILE__, __LINE__, tif->tif_name);
1955 return (0);
1956 }
1957 if (tif->tif_flags & TIFF_SWAB)
1958 TIFFSwabShort(&dircount);
1959 if (off != NULL)
1960 *off = TIFFSeekFile(tif, dircount * 12, SEEK_CUR);
1961 else
1962 (void)TIFFSeekFile(tif, dircount * 12, SEEK_CUR);
1963 if (!ReadOK(tif, &nextdir32, sizeof(uint32_t)))
1964 {
1965 TIFFErrorExtR(tif, module, "%s: Error fetching directory link",
1966 tif->tif_name);
1967 return (0);
1968 }
1969 if (tif->tif_flags & TIFF_SWAB)
1970 TIFFSwabLong(&nextdir32);
1971 *nextdiroff = nextdir32;
1972 }
1973 else
1974 {
1975 uint64_t dircount64;
1976 uint16_t dircount16;
1977 if (!SeekOK(tif, *nextdiroff) ||
1978 !ReadOK(tif, &dircount64, sizeof(uint64_t)))
1979 {
1980 TIFFErrorExtR(tif, module,
1981 "%s:%d: %s: Error fetching directory count",
1982 __FILE__, __LINE__, tif->tif_name);
1983 return (0);
1984 }
1985 if (tif->tif_flags & TIFF_SWAB)
1986 TIFFSwabLong8(&dircount64);
1987 if (dircount64 > 0xFFFF)
1988 {
1989 TIFFErrorExtR(tif, module,
1990 "%s:%d: %s: Error fetching directory count",
1991 __FILE__, __LINE__, tif->tif_name);
1992 return (0);
1993 }
1994 dircount16 = (uint16_t)dircount64;
1995 if (off != NULL)
1996 *off = TIFFSeekFile(tif, dircount16 * 20, SEEK_CUR);
1997 else
1998 (void)TIFFSeekFile(tif, dircount16 * 20, SEEK_CUR);
1999 if (!ReadOK(tif, nextdiroff, sizeof(uint64_t)))
2000 {
2001 TIFFErrorExtR(tif, module, "%s: Error fetching directory link",
2002 tif->tif_name);
2003 return (0);
2004 }
2005 if (tif->tif_flags & TIFF_SWAB)
2006 TIFFSwabLong8(nextdiroff);
2007 }
2008 }
2009 if (*nextdiroff != 0)
2010 {
2011 (*nextdirnum)++;
2012 /* Check next directory for IFD looping and if so, set it as last
2013 * directory. */
2014 if (!_TIFFCheckDirNumberAndOffset(tif, *nextdirnum, *nextdiroff))
2015 {
2017 tif, module,
2018 "the next directory %u at offset 0x%" PRIx64 " (%" PRIu64
2019 ") might be an IFD loop. Treating directory %d as "
2020 "last directory",
2021 *nextdirnum, *nextdiroff, *nextdiroff, (int)(*nextdirnum) - 1);
2022 *nextdiroff = 0;
2023 (*nextdirnum)--;
2024 }
2025 }
2026 return (1);
2027}
2028
2029/*
2030 * Count the number of directories in a file.
2031 */
2033{
2034 uint64_t nextdiroff;
2035 tdir_t nextdirnum;
2036 tdir_t n;
2037 if (!(tif->tif_flags & TIFF_BIGTIFF))
2038 nextdiroff = tif->tif_header.classic.tiff_diroff;
2039 else
2040 nextdiroff = tif->tif_header.big.tiff_diroff;
2041 nextdirnum = 0;
2042 n = 0;
2043 while (nextdiroff != 0 &&
2044 TIFFAdvanceDirectory(tif, &nextdiroff, NULL, &nextdirnum))
2045 {
2046 ++n;
2047 }
2048 /* Update number of main-IFDs in file. */
2049 tif->tif_curdircount = n;
2050 return (n);
2051}
2052
2053/*
2054 * Set the n-th directory as the current directory.
2055 * NB: Directories are numbered starting at 0.
2056 */
2058{
2059 uint64_t nextdiroff;
2060 tdir_t nextdirnum = 0;
2061 tdir_t n;
2062
2064 {
2065 /* tif_setdirectory_force_absolute=1 will force parsing the main IFD
2066 * chain from the beginning, thus IFD directory list needs to be cleared
2067 * from possible SubIFD offsets.
2068 */
2069 _TIFFCleanupIFDOffsetAndNumberMaps(tif); /* invalidate IFD loop lists */
2070 }
2071
2072 /* Even faster path, if offset is available within IFD loop hash list. */
2074 _TIFFGetOffsetFromDirNumber(tif, dirn, &nextdiroff))
2075 {
2076 /* Set parameters for following TIFFReadDirectory() below. */
2077 tif->tif_nextdiroff = nextdiroff;
2078 tif->tif_curdir = dirn;
2079 /* Reset to relative stepping */
2081 }
2082 else
2083 {
2084
2085 /* Fast path when we just advance relative to the current directory:
2086 * start at the current dir offset and continue to seek from there.
2087 * Check special cases when relative is not allowed:
2088 * - jump back from SubIFD or custom directory
2089 * - right after TIFFWriteDirectory() jump back to that directory
2090 * using TIFFSetDirectory() */
2091 const int relative = (dirn >= tif->tif_curdir) &&
2092 (tif->tif_diroff != 0) &&
2094
2095 if (relative)
2096 {
2097 nextdiroff = tif->tif_diroff;
2098 dirn -= tif->tif_curdir;
2099 nextdirnum = tif->tif_curdir;
2100 }
2101 else if (!(tif->tif_flags & TIFF_BIGTIFF))
2102 nextdiroff = tif->tif_header.classic.tiff_diroff;
2103 else
2104 nextdiroff = tif->tif_header.big.tiff_diroff;
2105
2106 /* Reset to relative stepping */
2108
2109 for (n = dirn; n > 0 && nextdiroff != 0; n--)
2110 if (!TIFFAdvanceDirectory(tif, &nextdiroff, NULL, &nextdirnum))
2111 return (0);
2112 /* If the n-th directory could not be reached (does not exist),
2113 * return here without touching anything further. */
2114 if (nextdiroff == 0 || n > 0)
2115 return (0);
2116
2117 tif->tif_nextdiroff = nextdiroff;
2118
2119 /* Set curdir to the actual directory index. */
2120 if (relative)
2121 tif->tif_curdir += dirn - n;
2122 else
2123 tif->tif_curdir = dirn - n;
2124 }
2125
2126 /* The -1 decrement is because TIFFReadDirectory will increment
2127 * tif_curdir after successfully reading the directory. */
2128 if (tif->tif_curdir == 0)
2130 else
2131 tif->tif_curdir--;
2132
2133 tdir_t curdir = tif->tif_curdir;
2134
2135 int retval = TIFFReadDirectory(tif);
2136
2137 if (!retval && tif->tif_curdir == curdir)
2138 {
2139 /* If tif_curdir has not be incremented, TIFFFetchDirectory() in
2140 * TIFFReadDirectory() has failed and tif_curdir shall be set
2141 * specifically. */
2143 }
2144 return (retval);
2145}
2146
2147/*
2148 * Set the current directory to be the directory
2149 * located at the specified file offset. This interface
2150 * is used mainly to access directories linked with
2151 * the SubIFD tag (e.g. thumbnail images).
2152 */
2154{
2155 /* Match nextdiroff and curdir for consistent IFD-loop checking.
2156 * Only with TIFFSetSubDirectory() the IFD list can be corrupted with
2157 * invalid offsets within the main IFD tree. In the case of several subIFDs
2158 * of a main image, there are two possibilities that are not even mutually
2159 * exclusive. a.) The subIFD tag contains an array with all offsets of the
2160 * subIFDs. b.) The SubIFDs are concatenated with their NextIFD parameters.
2161 * (refer to
2162 * https://www.awaresystems.be/imaging/tiff/specification/TIFFPM6.pdf.)
2163 */
2164 int retval;
2165 uint32_t curdir = 0;
2166 int8_t probablySubIFD = 0;
2167 if (diroff == 0)
2168 {
2169 /* Special case to set tif_diroff=0, which is done in
2170 * TIFFReadDirectory() below to indicate that the currently read IFD is
2171 * treated as a new, fresh IFD. */
2174 }
2175 else
2176 {
2177 if (!_TIFFGetDirNumberFromOffset(tif, diroff, &curdir))
2178 {
2179 /* Non-existing offsets might point to a SubIFD or invalid IFD.*/
2180 probablySubIFD = 1;
2181 }
2182 /* -1 because TIFFReadDirectory() will increment tif_curdir. */
2183 if (curdir >= 1)
2184 tif->tif_curdir = curdir - 1;
2185 else
2187 }
2188 curdir = tif->tif_curdir;
2189
2190 tif->tif_nextdiroff = diroff;
2192
2193 /* tif_curdir is incremented in TIFFReadDirectory(), but if it has not been
2194 * incremented, TIFFFetchDirectory() has failed there and tif_curdir shall
2195 * be set specifically. */
2196 if (!retval && diroff != 0 && tif->tif_curdir == curdir)
2197 {
2199 }
2200
2201 if (probablySubIFD)
2202 {
2203 if (retval)
2204 {
2205 /* Reset IFD list to start new one for SubIFD chain and also start
2206 * SubIFD chain with tif_curdir=0 for IFD loop checking. */
2207 /* invalidate IFD loop lists */
2209 tif->tif_curdir = 0; /* first directory of new chain */
2210 /* add this offset to new IFD list */
2211 retval = _TIFFCheckDirNumberAndOffset(tif, tif->tif_curdir, diroff);
2212 }
2213 /* To be able to return from SubIFD or custom-IFD to main-IFD */
2215 }
2216
2217 return (retval);
2218}
2219
2220/*
2221 * Return file offset of the current directory.
2222 */
2224
2225/*
2226 * Return an indication of whether or not we are
2227 * at the last directory in the file.
2228 */
2229int TIFFLastDirectory(TIFF *tif) { return (tif->tif_nextdiroff == 0); }
2230
2231/*
2232 * Unlink the specified directory from the directory chain.
2233 * Note: First directory starts with number dirn=1.
2234 * This is different to TIFFSetDirectory() where the first directory starts with
2235 * zero.
2236 */
2238{
2239 static const char module[] = "TIFFUnlinkDirectory";
2240 uint64_t nextdir;
2241 tdir_t nextdirnum;
2242 uint64_t off;
2243 tdir_t n;
2244
2245 if (tif->tif_mode == O_RDONLY)
2246 {
2247 TIFFErrorExtR(tif, module,
2248 "Can not unlink directory in read-only file");
2249 return (0);
2250 }
2251 if (dirn == 0)
2252 {
2253 TIFFErrorExtR(tif, module,
2254 "For TIFFUnlinkDirectory() first directory starts with "
2255 "number 1 and not 0");
2256 return (0);
2257 }
2258 /*
2259 * Go to the directory before the one we want
2260 * to unlink and nab the offset of the link
2261 * field we'll need to patch.
2262 */
2263 if (!(tif->tif_flags & TIFF_BIGTIFF))
2264 {
2265 nextdir = tif->tif_header.classic.tiff_diroff;
2266 off = 4;
2267 }
2268 else
2269 {
2270 nextdir = tif->tif_header.big.tiff_diroff;
2271 off = 8;
2272 }
2273 nextdirnum = 0; /* First directory is dirn=0 */
2274
2275 for (n = dirn - 1; n > 0; n--)
2276 {
2277 if (nextdir == 0)
2278 {
2279 TIFFErrorExtR(tif, module, "Directory %u does not exist", dirn);
2280 return (0);
2281 }
2282 if (!TIFFAdvanceDirectory(tif, &nextdir, &off, &nextdirnum))
2283 return (0);
2284 }
2285 /*
2286 * Advance to the directory to be unlinked and fetch
2287 * the offset of the directory that follows.
2288 */
2289 if (!TIFFAdvanceDirectory(tif, &nextdir, NULL, &nextdirnum))
2290 return (0);
2291 /*
2292 * Go back and patch the link field of the preceding
2293 * directory to point to the offset of the directory
2294 * that follows.
2295 */
2296 (void)TIFFSeekFile(tif, off, SEEK_SET);
2297 if (!(tif->tif_flags & TIFF_BIGTIFF))
2298 {
2299 uint32_t nextdir32;
2300 nextdir32 = (uint32_t)nextdir;
2301 assert((uint64_t)nextdir32 == nextdir);
2302 if (tif->tif_flags & TIFF_SWAB)
2303 TIFFSwabLong(&nextdir32);
2304 if (!WriteOK(tif, &nextdir32, sizeof(uint32_t)))
2305 {
2306 TIFFErrorExtR(tif, module, "Error writing directory link");
2307 return (0);
2308 }
2309 }
2310 else
2311 {
2312 /* Need local swap because nextdir has to be used unswapped below. */
2313 uint64_t nextdir64 = nextdir;
2314 if (tif->tif_flags & TIFF_SWAB)
2315 TIFFSwabLong8(&nextdir64);
2316 if (!WriteOK(tif, &nextdir64, sizeof(uint64_t)))
2317 {
2318 TIFFErrorExtR(tif, module, "Error writing directory link");
2319 return (0);
2320 }
2321 }
2322
2323 /* For dirn=1 (first directory) also update the libtiff internal
2324 * base offset variables. */
2325 if (dirn == 1)
2326 {
2327 if (!(tif->tif_flags & TIFF_BIGTIFF))
2328 tif->tif_header.classic.tiff_diroff = (uint32_t)nextdir;
2329 else
2330 tif->tif_header.big.tiff_diroff = nextdir;
2331 }
2332
2333 /*
2334 * Leave directory state setup safely. We don't have
2335 * facilities for doing inserting and removing directories,
2336 * so it's safest to just invalidate everything. This
2337 * means that the caller can only append to the directory
2338 * chain.
2339 */
2340 if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata)
2341 {
2342 _TIFFfreeExt(tif, tif->tif_rawdata);
2343 tif->tif_rawdata = NULL;
2344 tif->tif_rawcc = 0;
2345 tif->tif_rawcp = NULL;
2346 tif->tif_rawdataoff = 0;
2347 tif->tif_rawdataloaded = 0;
2348 }
2351 TIFFFreeDirectory(tif);
2353 tif->tif_diroff = 0; /* force link on next write */
2354 tif->tif_nextdiroff = 0; /* next write must be at end */
2355 tif->tif_lastdiroff = 0; /* will be updated on next link */
2356 tif->tif_curoff = 0;
2357 tif->tif_row = (uint32_t)-1;
2358 tif->tif_curstrip = (uint32_t)-1;
2360 if (tif->tif_curdircount > 0)
2361 tif->tif_curdircount--;
2362 else
2364 _TIFFCleanupIFDOffsetAndNumberMaps(tif); /* invalidate IFD loop lists */
2365 return (1);
2366}
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
INT32 int32_t
Definition: types.h:71
UINT32 uint32_t
Definition: types.h:75
INT16 int16_t
Definition: types.h:70
UINT64 uint64_t
Definition: types.h:77
INT64 int64_t
Definition: types.h:72
#define assert(_expr)
Definition: assert.h:32
#define O_RDONLY
Definition: fcntl.h:34
#define PRIu16
Definition: inttypes.h:83
#define PRIu32
Definition: inttypes.h:84
#define PRIi64
Definition: inttypes.h:26
#define PRIx64
Definition: inttypes.h:29
#define PRIu64
Definition: inttypes.h:28
#define va_end(v)
Definition: stdarg.h:28
#define va_arg(v, l)
Definition: stdarg.h:27
#define va_start(v, l)
Definition: stdarg.h:26
unsigned short uint16_t
Definition: stdint.h:35
unsigned char uint8_t
Definition: stdint.h:33
signed char int8_t
Definition: stdint.h:32
#define SEEK_CUR
Definition: stdio.h:44
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1592
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3319
char * va_list
Definition: vadefs.h:50
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
for(i=0;i< ARRAY_SIZE(offsets);i++)
const GLdouble * v
Definition: gl.h:2040
GLdouble s
Definition: gl.h:2039
GLuint GLuint end
Definition: gl.h:1545
GLdouble n
Definition: glext.h:7729
GLuint GLfloat * val
Definition: glext.h:7180
GLfloat GLfloat GLfloat GLfloat v3
Definition: glext.h:6064
GLenum GLsizei len
Definition: glext.h:6722
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define SEEK_SET
Definition: jmemansi.c:26
POINT cp
Definition: magnifier.c:59
static float(__cdecl *square_half_float)(float x
#define uint32_t
Definition: nsiface.idl:61
#define uint64_t
Definition: nsiface.idl:62
#define uint16_t
Definition: nsiface.idl:60
#define uint8_t
Definition: nsiface.idl:59
#define int16_t
Definition: nsiface.idl:55
int td_customValueCount
Definition: tif_dir.h:142
uint16_t td_pagenumber[2]
Definition: tif_dir.h:102
float td_xposition
Definition: tif_dir.h:101
uint32_t td_tiledepth
Definition: tif_dir.h:84
uint16_t td_fillorder
Definition: tif_dir.h:91
uint32_t td_dirdatasize_Noffsets
Definition: tif_dir.h:159
float td_xresolution
Definition: tif_dir.h:98
uint64_t td_dirdatasize_read
Definition: tif_dir.h:157
int td_inknameslen
Definition: tif_dir.h:138
uint16_t * td_sampleinfo
Definition: tif_dir.h:106
float * td_refblackwhite
Definition: tif_dir.h:136
uint32_t td_rowsperstrip
Definition: tif_dir.h:94
uint32_t td_imagewidth
Definition: tif_dir.h:83
uint16_t td_compression
Definition: tif_dir.h:88
uint16_t td_photometric
Definition: tif_dir.h:89
uint32_t td_tilewidth
Definition: tif_dir.h:84
float td_yresolution
Definition: tif_dir.h:98
uint16_t td_extrasamples
Definition: tif_dir.h:105
uint16_t td_threshholding
Definition: tif_dir.h:90
uint16_t td_minsamplevalue
Definition: tif_dir.h:95
double * td_sminsamplevalue
Definition: tif_dir.h:96
uint16_t td_bitspersample
Definition: tif_dir.h:86
char * td_inknames
Definition: tif_dir.h:139
TIFFDirEntry td_stripoffset_entry
Definition: tif_dir.h:127
uint16_t * td_transferfunction[3]
Definition: tif_dir.h:135
uint16_t td_maxsamplevalue
Definition: tif_dir.h:95
uint32_t td_imagedepth
Definition: tif_dir.h:83
uint16_t td_orientation
Definition: tif_dir.h:92
uint32_t td_fieldsset[FIELDSET_ITEMS]
Definition: tif_dir.h:81
uint16_t td_resolutionunit
Definition: tif_dir.h:99
uint16_t td_planarconfig
Definition: tif_dir.h:100
TIFFTagValue * td_customValues
Definition: tif_dir.h:143
double * td_smaxsamplevalue
Definition: tif_dir.h:97
uint64_t * td_stripbytecount_p
Definition: tif_dir.h:114
unsigned char td_iswrittentofile
Definition: tif_dir.h:149
uint64_t * td_stripoffset_p
Definition: tif_dir.h:113
uint16_t * td_colormap[3]
Definition: tif_dir.h:103
uint16_t td_sampleformat
Definition: tif_dir.h:87
uint16_t td_ycbcrsubsampling[2]
Definition: tif_dir.h:132
uint64_t td_dirdatasize_write
Definition: tif_dir.h:155
uint16_t td_samplesperpixel
Definition: tif_dir.h:93
uint32_t td_subfiletype
Definition: tif_dir.h:85
uint16_t td_numberofinks
Definition: tif_dir.h:140
TIFFDirEntry td_stripbytecount_entry
Definition: tif_dir.h:128
uint32_t td_imagelength
Definition: tif_dir.h:83
uint32_t td_stripoffsetbyteallocsize
Definition: tif_dir.h:117
TIFFEntryOffsetAndLength * td_dirdatasize_offsets
Definition: tif_dir.h:162
uint32_t td_tilelength
Definition: tif_dir.h:84
uint16_t td_nsubifd
Definition: tif_dir.h:129
uint64_t * td_subifd
Definition: tif_dir.h:130
float td_yposition
Definition: tif_dir.h:101
uint16_t td_ycbcrpositioning
Definition: tif_dir.h:133
uint16_t td_halftonehints[2]
Definition: tif_dir.h:104
uint64_t tiff_diroff
Definition: tiff.h:122
uint32_t tiff_diroff
Definition: tiff.h:114
TIFFVGetMethod vgetfield
Definition: tiffio.h:376
TIFFVSetMethod vsetfield
Definition: tiffio.h:375
TIFFPrintMethod printdir
Definition: tiffio.h:377
void * value
Definition: tif_dir.h:39
int count
Definition: tif_dir.h:38
const TIFFField * info
Definition: tif_dir.h:37
uint32_t allocated_size
Definition: tif_dir.h:324
TIFFField * fields
Definition: tif_dir.h:327
unsigned char field_oktochange
Definition: tif_dir.h:341
TIFFDataType field_type
Definition: tif_dir.h:335
unsigned char field_passcount
Definition: tif_dir.h:342
char * field_name
Definition: tif_dir.h:343
unsigned short field_bit
Definition: tif_dir.h:340
uint32_t field_tag
Definition: tif_dir.h:332
short field_readcount
Definition: tif_dir.h:333
short field_writecount
Definition: tif_dir.h:334
Definition: ps.c:97
Definition: ecma_167.h:138
Definition: tiffiop.h:113
const TIFFField * tif_foundfield
Definition: tiffiop.h:243
tdir_t tif_curdircount
Definition: tiffiop.h:183
TIFFTagMethods tif_tagmethods
Definition: tiffiop.h:244
int tif_setdirectory_force_absolute
Definition: tiffiop.h:155
tmsize_t tif_rawdataloaded
Definition: tiffiop.h:223
tmsize_t tif_rawcc
Definition: tiffiop.h:225
uint64_t tif_curoff
Definition: tiffiop.h:185
uint64_t tif_nextdiroff
Definition: tiffiop.h:151
TIFFPostMethod tif_postdecode
Definition: tiffiop.h:239
uint64_t tif_diroff
Definition: tiffiop.h:150
char * tif_name
Definition: tiffiop.h:114
TIFFDirectory tif_dir
Definition: tiffiop.h:157
tmsize_t tif_size
Definition: tiffiop.h:228
tdir_t tif_curdir
Definition: tiffiop.h:179
TIFFVoidMethod tif_cleanup
Definition: tiffiop.h:213
uint8_t * tif_rawcp
Definition: tiffiop.h:224
uint8_t * tif_rawdata
Definition: tiffiop.h:220
TIFFHeaderUnion tif_header
Definition: tiffiop.h:160
tmsize_t tif_rawdataoff
Definition: tiffiop.h:222
uint32_t tif_flags
Definition: tiffiop.h:117
uint32_t tif_row
Definition: tiffiop.h:162
size_t tif_nfieldscompat
Definition: tiffiop.h:249
uint64_t tif_lastdiroff
Definition: tiffiop.h:152
uint32_t tif_curstrip
Definition: tiffiop.h:184
int tif_mode
Definition: tiffiop.h:116
TIFFFieldArray * tif_fieldscompat
Definition: tiffiop.h:248
uint8_t * tif_base
Definition: tiffiop.h:227
void * _TIFFCheckMalloc(TIFF *tif, tmsize_t nmemb, tmsize_t elem_size, const char *what)
Definition: tif_aux.c:122
float _TIFFClampDoubleToFloat(double val)
Definition: tif_aux.c:391
tmsize_t _TIFFMultiplySSize(TIFF *tif, tmsize_t first, tmsize_t second, const char *where)
Definition: tif_aux.c:59
void _TIFFCleanupIFDOffsetAndNumberMaps(TIFF *tif)
Definition: tif_close.c:127
int TIFFSetCompressionScheme(TIFF *tif, int scheme)
Definition: tif_compress.c:166
void _TIFFsetLongArray(uint32_t **lpp, const uint32_t *lp, uint32_t n)
Definition: tif_dir.c:84
tdir_t TIFFNumberOfDirectories(TIFF *tif)
Definition: tif_dir.c:2032
static void setByteArray(TIFF *tif, void **vpp, const void *vp, size_t nmemb, size_t elem_size)
Definition: tif_dir.c:43
int TIFFUnsetField(TIFF *tif, uint32_t tag)
Definition: tif_dir.c:1160
int TIFFVGetField(TIFF *tif, uint32_t tag, va_list ap)
Definition: tif_dir.c:1599
void _TIFFsetLongArrayExt(TIFF *tif, uint32_t **lpp, const uint32_t *lp, uint32_t n)
Definition: tif_dir.c:88
#define DATATYPE_INT
Definition: tif_dir.c:39
int TIFFSetSubDirectory(TIFF *tif, uint64_t diroff)
Definition: tif_dir.c:2153
void _TIFFsetByteArray(void **vpp, const void *vp, uint32_t n)
Definition: tif_dir.c:60
void TIFFFreeDirectory(TIFF *tif)
Definition: tif_dir.c:1619
void _TIFFsetFloatArrayExt(TIFF *tif, float **fpp, const float *fp, uint32_t n)
Definition: tif_dir.c:104
int TIFFLastDirectory(TIFF *tif)
Definition: tif_dir.c:2229
int TIFFCreateGPSDirectory(TIFF *tif)
Definition: tif_dir.c:1742
static void _TIFFsetNString(TIFF *tif, char **cpp, const char *cp, uint32_t n)
Definition: tif_dir.c:69
int TIFFSetField(TIFF *tif, uint32_t tag,...)
Definition: tif_dir.c:1146
static void _TIFFsetLong8Array(TIFF *tif, uint64_t **lpp, const uint64_t *lp, uint32_t n)
Definition: tif_dir.c:94
void _TIFFsetByteArrayExt(TIFF *tif, void **vpp, const void *vp, uint32_t n)
Definition: tif_dir.c:64
#define CleanupField(member)
Definition: tif_dir.c:1607
int TIFFDefaultDirectory(TIFF *tif)
Definition: tif_dir.c:1752
#define DATATYPE_UINT
Definition: tif_dir.c:40
int TIFFSetDirectory(TIFF *tif, tdir_t dirn)
Definition: tif_dir.c:2057
static void setDoubleArrayOneValue(TIFF *tif, double **vpp, double value, size_t nmemb)
Definition: tif_dir.c:119
void _TIFFsetDoubleArray(double **dpp, const double *dp, uint32_t n)
Definition: tif_dir.c:109
#define DATATYPE_IEEEFP
Definition: tif_dir.c:41
int TIFFUnlinkDirectory(TIFF *tif, tdir_t dirn)
Definition: tif_dir.c:2237
static int _TIFFVGetField(TIFF *tif, uint32_t tag, va_list ap)
Definition: tif_dir.c:1212
int TIFFCreateDirectory(TIFF *tif)
Definition: tif_dir.c:1689
void _TIFFsetDoubleArrayExt(TIFF *tif, double **dpp, const double *dp, uint32_t n)
Definition: tif_dir.c:113
int TIFFCreateCustomDirectory(TIFF *tif, const TIFFFieldArray *infoarray)
Definition: tif_dir.c:1704
int TIFFCreateEXIFDirectory(TIFF *tif)
Definition: tif_dir.c:1732
static int OkToChangeTag(TIFF *tif, uint32_t tag)
Definition: tif_dir.c:1113
void _TIFFsetShortArray(uint16_t **wpp, const uint16_t *wp, uint32_t n)
Definition: tif_dir.c:74
#define DATATYPE_VOID
Definition: tif_dir.c:38
static int _TIFFVSetField(TIFF *tif, uint32_t tag, va_list ap)
Definition: tif_dir.c:220
static int TIFFAdvanceDirectory(TIFF *tif, uint64_t *nextdiroff, uint64_t *off, tdir_t *nextdirnum)
Definition: tif_dir.c:1838
#define EXTRASAMPLE_COREL_UNASSALPHA
TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc extender)
Definition: tif_dir.c:1675
static uint16_t countInkNamesString(TIFF *tif, uint32_t slen, const char *s)
Definition: tif_dir.c:192
static int setExtraSamples(TIFF *tif, va_list ap, uint32_t *v)
Definition: tif_dir.c:135
int TIFFGetField(TIFF *tif, uint32_t tag,...)
Definition: tif_dir.c:1582
void _TIFFsetShortArrayExt(TIFF *tif, uint16_t **wpp, const uint16_t *wp, uint32_t n)
Definition: tif_dir.c:78
static TIFFExtendProc _TIFFextender
Definition: tif_dir.c:1673
int TIFFVSetField(TIFF *tif, uint32_t tag, va_list ap)
Definition: tif_dir.c:1205
uint64_t TIFFCurrentDirOffset(TIFF *tif)
Definition: tif_dir.c:2223
void _TIFFsetFloatArray(float **fpp, const float *fp, uint32_t n)
Definition: tif_dir.c:100
#define FIELD_TRANSFERFUNCTION
Definition: tif_dir.h:214
#define FIELD_SMAXSAMPLEVALUE
Definition: tif_dir.h:207
#define FIELD_YCBCRSUBSAMPLING
Definition: tif_dir.h:211
#define FIELD_IGNORE
Definition: tif_dir.h:178
#define FIELD_SMINSAMPLEVALUE
Definition: tif_dir.h:206
#define TIFFFieldSet(tif, field)
Definition: tif_dir.h:236
#define FIELD_NUMBEROFINKS
Definition: tif_dir.h:217
#define FIELD_TILEDIMENSIONS
Definition: tif_dir.h:182
#define FIELD_COMPRESSION
Definition: tif_dir.h:189
#define FIELD_YCBCRPOSITIONING
Definition: tif_dir.h:212
#define TIFFClrFieldBit(tif, field)
Definition: tif_dir.h:238
#define FIELD_INKNAMES
Definition: tif_dir.h:215
#define TIFFSetFieldBit(tif, field)
Definition: tif_dir.h:237
#define FIELD_SAMPLESPERPIXEL
Definition: tif_dir.h:194
const TIFFField * TIFFFieldWithTag(TIFF *tif, uint32_t tag)
Definition: tif_dirinfo.c:845
static const TIFFFieldArray exifFieldArray
Definition: tif_dirinfo.c:49
const TIFFField * TIFFFindField(TIFF *tif, uint32_t tag, TIFFDataType dt)
Definition: tif_dirinfo.c:795
const TIFFFieldArray * _TIFFGetFields(void)
Definition: tif_dirinfo.c:507
static const TIFFFieldArray tiffFieldArray
Definition: tif_dirinfo.c:48
static const TIFFFieldArray gpsFieldArray
Definition: tif_dirinfo.c:50
void _TIFFSetupFields(TIFF *tif, const TIFFFieldArray *fieldarray)
Definition: tif_dirinfo.c:513
const TIFFFieldArray * _TIFFGetGpsFields(void)
Definition: tif_dirinfo.c:511
int TIFFFieldSetGetSize(const TIFFField *fip)
Definition: tif_dirinfo.c:673
const TIFFFieldArray * _TIFFGetExifFields(void)
Definition: tif_dirinfo.c:509
int _TIFFCheckDirNumberAndOffset(TIFF *tif, tdir_t dirn, uint64_t diroff)
Definition: tif_dirread.c:5665
int _TIFFGetOffsetFromDirNumber(TIFF *tif, tdir_t dirn, uint64_t *diroff)
Definition: tif_dirread.c:5873
int _TIFFGetDirNumberFromOffset(TIFF *tif, uint64_t diroff, tdir_t *dirn)
Definition: tif_dirread.c:5828
int _TIFFFillStriles(TIFF *tif)
Definition: tif_dirread.c:8381
int TIFFReadDirectory(TIFF *tif)
Definition: tif_dirread.c:4236
void TIFFErrorExtR(TIFF *tif, const char *module, const char *fmt,...)
Definition: tif_error.c:107
void _TIFFfreeExt(TIFF *tif, void *p)
Definition: tif_open.c:275
void * _TIFFreallocExt(TIFF *tif, void *p, tmsize_t s)
Definition: tif_open.c:235
void * _TIFFmallocExt(TIFF *tif, tmsize_t s)
Definition: tif_open.c:173
void _TIFFNoPostDecode(TIFF *tif, uint8_t *buf, tmsize_t cc)
Definition: tif_read.c:1648
void _TIFFSwab24BitData(TIFF *tif, uint8_t *buf, tmsize_t cc)
Definition: tif_read.c:1662
void _TIFFSwab16BitData(TIFF *tif, uint8_t *buf, tmsize_t cc)
Definition: tif_read.c:1655
void _TIFFSwab32BitData(TIFF *tif, uint8_t *buf, tmsize_t cc)
Definition: tif_read.c:1669
void _TIFFSwab64BitData(TIFF *tif, uint8_t *buf, tmsize_t cc)
Definition: tif_read.c:1676
void TIFFSwabLong8(uint64_t *lp)
Definition: tif_swab.c:60
void TIFFSwabShort(uint16_t *wp)
Definition: tif_swab.c:33
void TIFFSwabLong(uint32_t *lp)
Definition: tif_swab.c:45
void _TIFFmemset(void *p, int v, tmsize_t c)
Definition: tif_unix.c:353
void _TIFFmemcpy(void *d, const void *s, tmsize_t c)
Definition: tif_unix.c:355
void TIFFWarningExtR(TIFF *tif, const char *module, const char *fmt,...)
Definition: tif_warning.c:80
#define COMPRESSION_NONE
Definition: tiff.h:182
#define TIFFTAG_BITSPERSAMPLE
Definition: tiff.h:180
#define PLANARCONFIG_SEPARATE
Definition: tiff.h:266
#define TIFFTAG_RESOLUTIONUNIT
Definition: tiff.h:287
int uint16_vap
Definition: tiff.h:100
#define TIFFTAG_DOTRANGE
Definition: tiff.h:327
#define TIFFTAG_SUBIFD
Definition: tiff.h:321
#define EXTRASAMPLE_UNASSALPHA
Definition: tiff.h:332
#define YCBCRPOSITION_CENTERED
Definition: tiff.h:390
#define RESUNIT_CENTIMETER
Definition: tiff.h:290
#define EXTRASAMPLE_ASSOCALPHA
Definition: tiff.h:331
#define ORIENTATION_TOPLEFT
Definition: tiff.h:249
#define TIFFTAG_FILLORDER
Definition: tiff.h:240
#define TIFFTAG_SAMPLESPERPIXEL
Definition: tiff.h:257
#define TIFFTAG_DATATYPE
Definition: tiff.h:406
#define TIFFTAG_YPOSITION
Definition: tiff.h:269
#define FILLORDER_LSB2MSB
Definition: tiff.h:242
#define SAMPLEFORMAT_COMPLEXINT
Definition: tiff.h:338
#define SAMPLEFORMAT_UINT
Definition: tiff.h:334
#define TIFFTAG_COLORMAP
Definition: tiff.h:309
@ TIFF_SSHORT
Definition: tiff.h:155
@ TIFF_SLONG
Definition: tiff.h:156
@ TIFF_BYTE
Definition: tiff.h:148
@ TIFF_SBYTE
Definition: tiff.h:153
@ TIFF_IFD
Definition: tiff.h:160
@ TIFF_SHORT
Definition: tiff.h:150
@ TIFF_UNDEFINED
Definition: tiff.h:154
@ TIFF_LONG
Definition: tiff.h:151
@ TIFF_SLONG8
Definition: tiff.h:162
@ TIFF_LONG8
Definition: tiff.h:161
@ TIFF_ASCII
Definition: tiff.h:149
@ TIFF_FLOAT
Definition: tiff.h:158
@ TIFF_DOUBLE
Definition: tiff.h:159
@ TIFF_IFD8
Definition: tiff.h:163
@ TIFF_SRATIONAL
Definition: tiff.h:157
@ TIFF_RATIONAL
Definition: tiff.h:152
#define TIFFTAG_IMAGEDEPTH
Definition: tiff.h:407
#define TIFFTAG_PHOTOMETRIC
Definition: tiff.h:220
#define TIFFTAG_TILELENGTH
Definition: tiff.h:312
#define TIFFTAG_MAXSAMPLEVALUE
Definition: tiff.h:261
#define TIFFTAG_TILEDEPTH
Definition: tiff.h:408
#define TIFFTAG_EXTRASAMPLES
Definition: tiff.h:329
#define TIFFTAG_IMAGEWIDTH
Definition: tiff.h:178
#define RESUNIT_NONE
Definition: tiff.h:288
#define TIFFTAG_XRESOLUTION
Definition: tiff.h:262
#define TIFFTAG_ORIENTATION
Definition: tiff.h:248
#define TIFFTAG_HALFTONEHINTS
Definition: tiff.h:310
#define TIFFTAG_MATTEING
Definition: tiff.h:405
#define TIFFTAG_MINSAMPLEVALUE
Definition: tiff.h:260
#define TIFFTAG_NUMBEROFINKS
Definition: tiff.h:326
#define SAMPLEFORMAT_IEEEFP
Definition: tiff.h:336
#define TIFFTAG_TRANSFERFUNCTION
Definition: tiff.h:298
#define TIFFTAG_YRESOLUTION
Definition: tiff.h:263
#define PERSAMPLE_MULTI
Definition: tiff.h:754
#define TIFFTAG_TILEBYTECOUNTS
Definition: tiff.h:314
#define TIFFTAG_STRIPBYTECOUNTS
Definition: tiff.h:259
#define TIFFTAG_SMINSAMPLEVALUE
Definition: tiff.h:340
#define TIFFTAG_YCBCRSUBSAMPLING
Definition: tiff.h:388
#define FILLORDER_MSB2LSB
Definition: tiff.h:241
#define TIFFTAG_TILEOFFSETS
Definition: tiff.h:313
#define TIFFTAG_ROWSPERSTRIP
Definition: tiff.h:258
#define ORIENTATION_LEFTBOT
Definition: tiff.h:256
#define TIFFTAG_SMAXSAMPLEVALUE
Definition: tiff.h:341
#define TIFFTAG_SAMPLEFORMAT
Definition: tiff.h:333
#define TIFFTAG_PERSAMPLE
Definition: tiff.h:752
#define SAMPLEFORMAT_COMPLEXIEEEFP
Definition: tiff.h:339
#define TIFFTAG_REFERENCEBLACKWHITE
Definition: tiff.h:392
#define RESUNIT_INCH
Definition: tiff.h:289
#define TIFFTAG_TILEWIDTH
Definition: tiff.h:311
#define TIFFTAG_IMAGELENGTH
Definition: tiff.h:179
#define TIFFTAG_PAGENUMBER
Definition: tiff.h:291
#define THRESHHOLD_BILEVEL
Definition: tiff.h:235
#define TIFFTAG_COMPRESSION
Definition: tiff.h:181
#define TIFFTAG_PLANARCONFIG
Definition: tiff.h:264
#define TIFFTAG_STRIPOFFSETS
Definition: tiff.h:247
#define TIFFTAG_SUBFILETYPE
Definition: tiff.h:170
#define TIFFTAG_XPOSITION
Definition: tiff.h:268
#define SAMPLEFORMAT_VOID
Definition: tiff.h:337
#define TIFFTAG_YCBCRPOSITIONING
Definition: tiff.h:389
#define TIFFTAG_INKNAMES
Definition: tiff.h:325
#define TIFFTAG_THRESHHOLDING
Definition: tiff.h:234
#define SAMPLEFORMAT_INT
Definition: tiff.h:335
#define PLANARCONFIG_CONTIG
Definition: tiff.h:265
#define FIELD_CUSTOM
Definition: tiffio.h:346
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:67
#define TIFF_TMSIZE_T_MAX
Definition: tiffio.h:68
#define TIFF_SPP
Definition: tiffio.h:343
#define TIFF_VARIABLE
Definition: tiffio.h:342
void(* TIFFExtendProc)(TIFF *)
Definition: tiffio.h:312
uint32_t tdir_t
Definition: tiffio.h:71
#define TIFF_ANY
Definition: tiffio.h:341
#define TIFF_VARIABLE2
Definition: tiffio.h:344
#define TIFF_NON_EXISTENT_DIR_NUMBER
Definition: tiffiop.h:64
#define WriteOK(tif, buf, size)
Definition: tiffiop.h:301
#define TIFF_MYBUFFER
Definition: tiffiop.h:126
#define TIFF_BUFFERSETUP
Definition: tiffiop.h:121
#define ReadOK(tif, buf, size)
Definition: tiffiop.h:295
#define TIFF_POSTENCODE
Definition: tiffiop.h:129
#define TIFF_PERSAMPLE
Definition: tiffiop.h:141
#define TIFF_BUF4WRITE
Definition: tiffiop.h:139
#define SeekOK(tif, off)
Definition: tiffiop.h:298
#define isPseudoTag(t)
Definition: tiffiop.h:272
#define TIFF_INSUBIFD
Definition: tiffiop.h:130
#define isMapped(tif)
Definition: tiffiop.h:275
#define TIFF_BEENWRITING
Definition: tiffiop.h:123
#define TIFFSeekFile(tif, off, whence)
Definition: tiffiop.h:282
#define TIFF_DIRTYDIRECT
Definition: tiffiop.h:120
#define TIFF_BIGTIFF
Definition: tiffiop.h:138
#define TIFF_SWAB
Definition: tiffiop.h:124
#define TIFF_ISTILED
Definition: tiffiop.h:127
TIFFHeaderClassic classic
Definition: tiffiop.h:108
TIFFHeaderBig big
Definition: tiffiop.h:109
Definition: pdh_main.c:96
int retval
Definition: wcstombs.cpp:91
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36