libtiff: tif_dirinfo.c: disable DNG 1.2->1.6 tags

From 738e04099b13192bb1f654e74e9b5829313f3161 Mon Sep 17 00:00:00 2001
From: Even Rouault <[EMAIL REDACTED]>
Date: Wed, 7 Jun 2023 21:48:23 +0200
Subject: [PATCH] tif_dirinfo.c: disable DNG 1.2->1.6 tags

They were added per b90b20d36d7833f54a1f3014c324f6c21b988006 but it has
been found in https://gitlab.com/libtiff/libtiff/-/issues/575 that it
could cause compatibity issues with libtiff users, so this addition
should be defered for a feature release (likely 4.6.0) and not a patch one.

Fixes #575
---
 doc/specification/coverage.rst | 493 +--------------------------------
 libtiff/tif_dirinfo.c          |   4 +
 2 files changed, 5 insertions(+), 492 deletions(-)

diff --git a/doc/specification/coverage.rst b/doc/specification/coverage.rst
index 9f4bf7db..fa5c06d8 100644
--- a/doc/specification/coverage.rst
+++ b/doc/specification/coverage.rst
@@ -183,8 +183,7 @@ For the meaning of the tags look in https://www.awaresystems.be/imaging/tiff/tif
 
 :file:`libtiff` supports also many private tags allocated for organizations that wish to
 store additional information in a TIFF file.
-Tags for TIFF/EP and for Digital Negative (DNG) Specification 1.6.0
-(see https://helpx.adobe.com/content/dam/help/en/photoshop/pdf/dng_spec_1_6_0_0.pdf)
+Tags for TIFF/EP and for Digital Negative (DNG) Specification 1.1.0
 are included.
 
 Note that some tags are meaningful only when a particular
@@ -906,496 +905,6 @@ Tags Recognized by LibTIFF
       - R/W
       -  (only internal pseudo tag)
 
-    * - ``ColorimetricReference``
-      - 50879
-      - R/W
-      - DNG 1.2 tags
-
-    * - ``CameraCalibrationSignature``
-      - 50931
-      - R/W
-      -
-
-    * - ``ProfileCalibrationSignature``
-      - 50932
-      - R/W
-      -
-
-    * - ``ExtraCameraProfiles``
-      - 50933
-      - R/W
-      -
-
-    * - ``AsShotProfileName``
-      - 50934
-      - R/W
-      -
-
-    * - ``NoiseReductionApplied``
-      - 50935
-      - R/W
-      -
-
-    * - ``ProfileName``
-      - 50936
-      - R/W
-      -
-
-    * - ``ProfileHueSatMapDims``
-      - 50937
-      - R/W
-      -
-
-    * - ``ProfileHueSatMapData1``
-      - 50938
-      - R/W
-      -
-
-    * - ``ProfileHueSatMapData2``
-      - 50939
-      - R/W
-      -
-
-    * - ``ProfileToneCurve``
-      - 50940
-      - R/W
-      -
-
-    * - ``ProfileEmbedPolicy``
-      - 50941
-      - R/W
-      -
-
-    * - ``ProfileCopyright``
-      - 50942
-      - R/W
-      -
-
-    * - ``ForwardMatrix1``
-      - 50964
-      - R/W
-      -
-
-    * - ``ForwardMatrix2``
-      - 50965
-      - R/W
-      -
-
-    * - ``PreviewApplicationName``
-      - 50966
-      - R/W
-      -
-
-    * - ``PreviewApplicationVersion``
-      - 50967
-      - R/W
-      -
-
-    * - ``PreviewSettingsName``
-      - 50968
-      - R/W
-      -
-
-    * - ``PreviewSettingsDigest``
-      - 50969
-      - R/W
-      -
-
-    * - ``PreviewColorSpace``
-      - 50970
-      - R/W
-      -
-
-    * - ``PreviewDateTime``
-      - 50971
-      - R/W
-      -
-
-    * - ``RawImageDigest``
-      - 50972
-      - R/W
-      -
-
-    * - ``OriginalRawFileDigest``
-      - 50973
-      - R/W
-      -
-
-    * - ``SubTileBlockSize``
-      - 50974
-      - R/W
-      -
-
-    * - ``RowInterleaveFactor``
-      - 50975
-      - R/W
-      -
-
-    * - ``ProfileLookTableDims``
-      - 50981
-      - R/W
-      -
-
-    * - ``ProfileLookTableData``
-      - 50982
-      - R/W
-      -
-
-    * - ``OpcodeList1``
-      - 51008
-      - R/W
-      - DNG 1.3 tags
-
-    * - ``OpcodeList2``
-      - 51009
-      - R/W
-      -
-
-    * - ``OpcodeList3``
-      - 51022
-      - R/W
-      -
-
-    * - ``NoiseProfile``
-      - 51041
-      - R/W
-      -
-
-    * - ``DefaultUserCrop``
-      - 51125
-      - R/W
-      - DNG 1.4 tags
-
-    * - ``DefaultBlackRender``
-      - 51110
-      - R/W
-      -
-
-    * - ``BaselineExposureOffset``
-      - 51109
-      - R/W
-      -
-
-    * - ``ProfileLookTableEncoding``
-      - 51108
-      - R/W
-      -
-
-    * - ``ProfileHueSatMapEncoding``
-      - 51107
-      - R/W
-      -
-
-    * - ``OriginalDefaultFinalSize``
-      - 51089
-      - R/W
-      -
-
-    * - ``OriginalBestQualityFinalSize``
-      - 51090
-      - R/W
-      -
-
-    * - ``OriginalDefaultCropSize``
-      - 51091
-      - R/W
-      -
-
-    * - ``NewRawImageDigest``
-      - 51111
-      - R/W
-      -
-
-    * - ``RawToPreviewGain``
-      - 51112
-      - R/W
-      -
-
-    * - ``DepthFormat``
-      - 51177
-      - R/W
-      - DNG 1.5 tags
-
-    * - ``DepthNear``
-      - 51178
-      - R/W
-      -
-
-    * - ``DepthFar``
-      - 51179
-      - R/W
-      -
-
-    * - ``DepthUnits``
-      - 51180
-      - R/W
-      -
-
-    * - ``DepthMeasureType``
-      - 51181
-      - R/W
-      -
-
-    * - ``EnhanceParams``
-      - 51182
-      - R/W
-      -
-
-    * - ``ProfileGainTableMap``
-      - 52525
-      - R/W
-      - DNG 1.6 tags
-
-    * - ``SemanticName``
-      - 52526
-      - R/W
-      -
-
-    * - ``SemanticInstanceID``
-      - 52528
-      - R/W
-      -
-
-    * - ``MaskSubArea``
-      - 52536
-      - R/W
-      -
-
-    * - ``RGBTables``
-      - 52543
-      - R/W
-      -
-
-    * - ``CalibrationIlluminant3``
-      - 52529
-      - R/W
-      -
-
-    * - ``ColorMatrix3``
-      - 52531
-      - R/W
-      -
-
-    * - ``CameraCalibration3``
-      - 52530
-      - R/W
-      -
-
-    * - ``ReductionMatrix3``
-      - 52538
-      - R/W
-      -
-
-    * - ``ProfileHueSatMapData3``
-      - 52537
-      - R/W
-      -
-
-    * - ``ForwardMatrix3``
-      - 52532
-      - R/W
-      -
-
-    * - ``IlluminantData1``
-      - 52533
-      - R/W
-      -
-
-    * - ``IlluminantData2``
-      - 52534
-      - R/W
-      -
-
-    * - ``IlluminantData3``
-      - 53535
-      - R/W
-      -
-
-    * - ``EP CFARepeatPatternDim``
-      - 33421
-      - R/W
-      - TIFF/EP tags
-
-    * - ``EP CFAPattern``
-      - 33422
-      - R/W
-      -
-
-    * - ``EP BatteryLevel``
-      - 33423
-      - R/W
-      -
-
-    * - ``EP Interlace``
-      - 34857
-      - R/W
-      -
-
-    * - ``EP TimeZoneOffset``
-      - 34858
-      - R/W
-      -
-
-    * - ``EP SelfTimerMode``
-      - 34859
-      - R/W
-      -
-
-    * - ``EP FlashEnergy``
-      - 37387
-      - R/W
-      -
-
-    * - ``EP SpatialFrequencyResponse``
-      - 37388
-      - R/W
-      -
-
-    * - ``EP Noise``
-      - 37389
-      - R/W
-      -
-
-    * - ``EP FocalPlaneXResolution``
-      - 37390
-      - R/W
-      -
-
-    * - ``EP FocalPlaneYResolution``
-      - 37391
-      - R/W
-      -
-
-    * - ``EP FocalPlaneResolutionUnit``
-      - 37392
-      - R/W
-      -
-
-    * - ``EP ImageNumber``
-      - 37393
-      - R/W
-      -
-
-    * - ``EP SecurityClassification``
-      - 37394
-      - R/W
-      -
-
-    * - ``EP ImageHistory``
-      - 37395
-      - R/W
-      -
-
-    * - ``EP ExposureIndex``
-      - 37397
-      - R/W
-      -
-
-    * - ``EP StandardId``
-      - 37398
-      - R/W
-      -
-
-    * - ``EP SensingMethod``
-      - 37399
-      - R/W
-      -
-
-    * - ``EP ExposureTime``
-      - 33434
-      - R/W
-      - TIFF/EP tags equivalent to EXIF tags
-
-    * - ``EP FNumber``
-      - 33437
-      - R/W
-      -
-
-    * - ``EP ExposureProgram``
-      - 34850
-      - R/W
-      -
-
-    * - ``EP SpectralSensitivity``
-      - 34852
-      - R/W
-      -
-
-    * - ``EP ISOSpeedRatings``
-      - 34855
-      - R/W
-      -
-
-    * - ``EP OptoelectricConversionFactor``
-      - 34856
-      - R/W
-      -
-
-    * - ``EP DateTimeOriginal``
-      - 36867
-      - R/W
-      -
-
-    * - ``EP CompressedBitsPerPixel``
-      - 37122
-      - R/W
-      -
-
-    * - ``EP ShutterSpeedValue``
-      - 37377
-      - R/W
-      -
-
-    * - ``EP ApertureValue``
-      - 37378
-      - R/W
-      -
-
-    * - ``EP BrightnessValue``
-      - 37379
-      - R/W
-      -
-
-    * - ``EP ExposureBiasValue``
-      - 37380
-      - R/W
-      -
-
-    * - ``EP MaxApertureValue``
-      - 37381
-      - R/W
-      -
-
-    * - ``EP SubjectDistance``
-      - 37382
-      - R/W
-      -
-
-    * - ``EP MeteringMode``
-      - 37383
-      - R/W
-      -
-
-    * - ``EP LightSource``
-      - 37384
-      - R/W
-      -
-
-    * - ``EP Flash``
-      - 37385
-      - R/W
-      -
-
-    * - ``EP FocalLength``
-      - 37386
-      - R/W
-      -
-
-    * - ``EP SubjectLocation``
-      - 37396
-      - R/W
-      -
-
     * - ``Indexed``
       - 346
       - R/W
diff --git a/libtiff/tif_dirinfo.c b/libtiff/tif_dirinfo.c
index d7bf2cff..0e705e81 100644
--- a/libtiff/tif_dirinfo.c
+++ b/libtiff/tif_dirinfo.c
@@ -212,6 +212,9 @@ static const TIFFField tiffFields[] = {
     {TIFFTAG_CURRENTICCPROFILE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CurrentICCProfile", NULL},
     {TIFFTAG_CURRENTPREPROFILEMATRIX, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CurrentPreProfileMatrix", NULL},
     {TIFFTAG_PERSAMPLE, 0, 0, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "PerSample", NULL},
+#if 0
+    /* TODO: revert above #if 0 for TIFF 4.6.0 */
+
     /* begin DNG 1.2.0.0 tags */
     {TIFFTAG_COLORIMETRICREFERENCE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ColorimetricReference", NULL},
     {TIFFTAG_CAMERACALIBRATIONSIGNATURE, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CameraCalibrationSignature", NULL},
@@ -323,6 +326,7 @@ static const TIFFField tiffFields[] = {
     {TIFFTAG_EP_FOCALLENGTH, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP FocalLength", NULL},
     {TIFFTAG_EP_SUBJECTLOCATION, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP SubjectLocation", NULL},
     /* end TIFF/EP tags */
+#endif
     /* begin TIFF/FX tags */
     {TIFFTAG_INDEXED, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Indexed", NULL},
     {TIFFTAG_GLOBALPARAMETERSIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "GlobalParametersIFD", NULL},