bhyve-fw: drop CSM
[oi-userland.git] / components / library / FreeImage / patches / XTIFF.cpp.patch
blob101ce378ec4799dd5fc546456d875ab2bf5eec15
1 --- FreeImage/Source/Metadata/XTIFF.cpp Wed Mar 4 00:07:10 2015
2 +++ FreeImage/Source/Metadata/XTIFF_.cpp Tue May 24 01:39:44 2022
3 @@ -29,7 +29,7 @@
4 #pragma warning (disable : 4786) // identifier was truncated to 'number' characters
5 #endif
7 -#include "../LibTIFF4/tiffiop.h"
8 +#include <tiffio.h>
10 #include "FreeImage.h"
11 #include "Utilities.h"
12 @@ -224,6 +224,33 @@ tiff_write_geotiff_profile(TIFF *tif, FI
13 // TIFF EXIF tag reading & writing
14 // ----------------------------------------------------------
16 +static uint32 exif_tag_ids[] = {
17 + EXIFTAG_EXPOSURETIME, EXIFTAG_FNUMBER, EXIFTAG_EXPOSUREPROGRAM,
18 + EXIFTAG_SPECTRALSENSITIVITY, EXIFTAG_ISOSPEEDRATINGS, EXIFTAG_OECF,
19 + EXIFTAG_EXIFVERSION, EXIFTAG_DATETIMEORIGINAL, EXIFTAG_DATETIMEDIGITIZED,
20 + EXIFTAG_COMPONENTSCONFIGURATION, EXIFTAG_COMPRESSEDBITSPERPIXEL,
21 + EXIFTAG_SHUTTERSPEEDVALUE, EXIFTAG_APERTUREVALUE,
22 + EXIFTAG_BRIGHTNESSVALUE, EXIFTAG_EXPOSUREBIASVALUE,
23 + EXIFTAG_MAXAPERTUREVALUE, EXIFTAG_SUBJECTDISTANCE, EXIFTAG_METERINGMODE,
24 + EXIFTAG_LIGHTSOURCE, EXIFTAG_FLASH, EXIFTAG_FOCALLENGTH,
25 + EXIFTAG_SUBJECTAREA, EXIFTAG_MAKERNOTE, EXIFTAG_USERCOMMENT,
26 + EXIFTAG_SUBSECTIME, EXIFTAG_SUBSECTIMEORIGINAL,
27 + EXIFTAG_SUBSECTIMEDIGITIZED, EXIFTAG_FLASHPIXVERSION, EXIFTAG_COLORSPACE,
28 + EXIFTAG_PIXELXDIMENSION, EXIFTAG_PIXELYDIMENSION,
29 + EXIFTAG_RELATEDSOUNDFILE, EXIFTAG_FLASHENERGY,
30 + EXIFTAG_SPATIALFREQUENCYRESPONSE, EXIFTAG_FOCALPLANEXRESOLUTION,
31 + EXIFTAG_FOCALPLANEYRESOLUTION, EXIFTAG_FOCALPLANERESOLUTIONUNIT,
32 + EXIFTAG_SUBJECTLOCATION, EXIFTAG_EXPOSUREINDEX, EXIFTAG_SENSINGMETHOD,
33 + EXIFTAG_FILESOURCE, EXIFTAG_SCENETYPE, EXIFTAG_CFAPATTERN,
34 + EXIFTAG_CUSTOMRENDERED, EXIFTAG_EXPOSUREMODE, EXIFTAG_WHITEBALANCE,
35 + EXIFTAG_DIGITALZOOMRATIO, EXIFTAG_FOCALLENGTHIN35MMFILM,
36 + EXIFTAG_SCENECAPTURETYPE, EXIFTAG_GAINCONTROL, EXIFTAG_CONTRAST,
37 + EXIFTAG_SATURATION, EXIFTAG_SHARPNESS, EXIFTAG_DEVICESETTINGDESCRIPTION,
38 + EXIFTAG_SUBJECTDISTANCERANGE, EXIFTAG_GAINCONTROL, EXIFTAG_GAINCONTROL,
39 + EXIFTAG_IMAGEUNIQUEID
40 +};
41 +static int nExifTags = sizeof(exif_tag_ids) / sizeof(exif_tag_ids[0]);
43 /**
44 Read a single Exif tag
46 @@ -575,45 +607,11 @@ tiff_read_exif_tags(TIFF *tif, TagLib::M
48 // loop over all Core Directory Tags
49 // ### uses private data, but there is no other way
50 + // -> Fedora: Best we can do without private headers is to hard-code a list of known EXIF tags and read those
51 if(md_model == TagLib::EXIF_MAIN) {
52 - const TIFFDirectory *td = &tif->tif_dir;
54 - uint32 lastTag = 0; //<- used to prevent reading some tags twice (as stored in tif_fieldinfo)
56 - for (int fi = 0, nfi = (int)tif->tif_nfields; nfi > 0; nfi--, fi++) {
57 - const TIFFField *fld = tif->tif_fields[fi];
59 - const uint32 tag_id = TIFFFieldTag(fld);
61 - if(tag_id == lastTag) {
62 - continue;
63 - }
65 - // test if tag value is set
66 - // (lifted directly from LibTiff _TIFFWriteDirectory)
68 - if( fld->field_bit == FIELD_CUSTOM ) {
69 - int is_set = FALSE;
71 - for(int ci = 0; ci < td->td_customValueCount; ci++ ) {
72 - is_set |= (td->td_customValues[ci].info == fld);
73 - }
75 - if( !is_set ) {
76 - continue;
77 - }
79 - } else if(!TIFFFieldSet(tif, fld->field_bit)) {
80 - continue;
81 - }
83 - // process *all* other tags (some will be ignored)
85 - tiff_read_exif_tag(tif, tag_id, dib, md_model);
87 - lastTag = tag_id;
88 + for (int i = 0; i < nExifTags; ++i) {
89 + tiff_read_exif_tag(tif, exif_tag_ids[i], dib, md_model);
94 return TRUE;
95 @@ -723,10 +721,9 @@ tiff_write_exif_tags(TIFF *tif, TagLib::
97 TagLib& tag_lib = TagLib::instance();
99 - for (int fi = 0, nfi = (int)tif->tif_nfields; nfi > 0; nfi--, fi++) {
100 - const TIFFField *fld = tif->tif_fields[fi];
102 - const uint32 tag_id = TIFFFieldTag(fld);
103 + for (int fi = 0; fi < nExifTags; fi++) {
104 + const uint32 tag_id = exif_tag_ids[fi];
105 + const TIFFField *fld = TIFFFieldWithTag(tif, tag_id);
107 if(skip_write_field(tif, tag_id)) {
108 // skip tags that are already handled by the LibTIFF writing process
109 @@ -749,7 +741,7 @@ tiff_write_exif_tags(TIFF *tif, TagLib::
110 continue;
112 // type of storage may differ (e.g. rationnal array vs float array type)
113 - if((unsigned)_TIFFDataSize(tif_tag_type) != FreeImage_TagDataWidth(tag_type)) {
114 + if((unsigned)TIFFFieldSetGetSize(fld) != FreeImage_TagDataWidth(tag_type)) {
115 // skip tag or _TIFFmemcpy will fail
116 continue;