summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2014-09-01 13:56:46 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2014-09-01 13:56:46 +0200
commit22f703cab05b7cd368f4de9e03991b7664dc5022 (patch)
tree6f4d50beaa42328e24b1c6b56b6ec059e4ef21a5
Initial import of argyll version 1.5.1-8debian/1.5.1-8
-rw-r--r--.pc/.quilt_patches1
-rw-r--r--.pc/.quilt_series1
-rw-r--r--.pc/.version1
-rw-r--r--.pc/01_autotools-support.diff/Makefile.am0
-rw-r--r--.pc/01_autotools-support.diff/Makefile.shared0
-rw-r--r--.pc/01_autotools-support.diff/aclocal.m40
-rw-r--r--.pc/01_autotools-support.diff/cgats/Makefile.am0
-rw-r--r--.pc/01_autotools-support.diff/config.guess0
-rw-r--r--.pc/01_autotools-support.diff/config.h.in0
-rw-r--r--.pc/01_autotools-support.diff/config.sub0
-rw-r--r--.pc/01_autotools-support.diff/configure0
-rw-r--r--.pc/01_autotools-support.diff/configure.ac0
-rw-r--r--.pc/01_autotools-support.diff/depcomp0
-rw-r--r--.pc/01_autotools-support.diff/doc/Makefile.am0
-rw-r--r--.pc/01_autotools-support.diff/gamut/Makefile.am0
-rw-r--r--.pc/01_autotools-support.diff/h/Makefile.am0
-rw-r--r--.pc/01_autotools-support.diff/icc/Makefile.am0
-rw-r--r--.pc/01_autotools-support.diff/imdi/Makefile.am0
-rw-r--r--.pc/01_autotools-support.diff/imdi/imdi_k.h0
-rw-r--r--.pc/01_autotools-support.diff/install-sh0
-rw-r--r--.pc/01_autotools-support.diff/jcnf/Makefile.am0
-rw-r--r--.pc/01_autotools-support.diff/jcnf/yajl/Makefile.am0
-rw-r--r--.pc/01_autotools-support.diff/link/Makefile.am0
-rw-r--r--.pc/01_autotools-support.diff/m4/libtool.m40
-rw-r--r--.pc/01_autotools-support.diff/m4/ltoptions.m40
-rw-r--r--.pc/01_autotools-support.diff/m4/ltsugar.m40
-rw-r--r--.pc/01_autotools-support.diff/m4/ltversion.m40
-rw-r--r--.pc/01_autotools-support.diff/m4/lt~obsolete.m40
-rw-r--r--.pc/01_autotools-support.diff/missing0
-rw-r--r--.pc/01_autotools-support.diff/numlib/Makefile.am0
-rw-r--r--.pc/01_autotools-support.diff/plot/Makefile.am0
-rw-r--r--.pc/01_autotools-support.diff/profile/Makefile.am0
-rw-r--r--.pc/01_autotools-support.diff/ref/Makefile.am0
-rw-r--r--.pc/01_autotools-support.diff/render/Makefile.am0
-rw-r--r--.pc/01_autotools-support.diff/rspl/Makefile.am0
-rw-r--r--.pc/01_autotools-support.diff/scanin/Makefile.am0
-rw-r--r--.pc/01_autotools-support.diff/spectro/Makefile.am0
-rw-r--r--.pc/01_autotools-support.diff/target/Makefile.am0
-rw-r--r--.pc/01_autotools-support.diff/tweak/Makefile.am0
-rw-r--r--.pc/01_autotools-support.diff/ucmm/Makefile.am0
-rw-r--r--.pc/01_autotools-support.diff/xicc/Makefile.am0
-rw-r--r--.pc/02_firmware-package-builder.diff/firmware-package-builder/argyll-firmware-spyder2/debian/changelog0
-rw-r--r--.pc/02_firmware-package-builder.diff/firmware-package-builder/argyll-firmware-spyder2/debian/compat0
-rw-r--r--.pc/02_firmware-package-builder.diff/firmware-package-builder/argyll-firmware-spyder2/debian/control0
-rw-r--r--.pc/02_firmware-package-builder.diff/firmware-package-builder/argyll-firmware-spyder2/debian/copyright0
-rw-r--r--.pc/02_firmware-package-builder.diff/firmware-package-builder/argyll-firmware-spyder2/debian/install0
-rw-r--r--.pc/02_firmware-package-builder.diff/firmware-package-builder/argyll-firmware-spyder2/debian/rules0
-rw-r--r--.pc/03_usb-db.diff/usb/55-Argyll.rules90
-rw-r--r--.pc/04_CVE-2012-4405.diff/icc/icc.c17833
-rw-r--r--.pc/06_fix_udev_rule.patch/usb/55-Argyll.rules90
-rw-r--r--.pc/applied-patches5
-rw-r--r--Jambase4541
-rw-r--r--Jamfile67
-rw-r--r--Jamtop160
-rw-r--r--License.txt662
-rw-r--r--License2.txt282
-rw-r--r--License3.txt674
-rw-r--r--Makefile10
-rw-r--r--Makefile.am23
-rw-r--r--Makefile.shared15
-rw-r--r--Readme.txt43
-rw-r--r--aclocal.m41073
-rw-r--r--adirs26
-rw-r--r--afiles22
-rw-r--r--binfiles3
-rw-r--r--blddirs1
-rw-r--r--cgats/Jamfile37
-rw-r--r--cgats/License.txt22
-rw-r--r--cgats/Makefile68
-rw-r--r--cgats/Makefile.IBMNT41
-rw-r--r--cgats/Makefile.OSX38
-rw-r--r--cgats/Makefile.UNIX38
-rw-r--r--cgats/Makefile.WNT38
-rw-r--r--cgats/Makefile.am9
-rw-r--r--cgats/Readme.txt286
-rw-r--r--cgats/afiles16
-rw-r--r--cgats/cgats.c2166
-rw-r--r--cgats/cgats.h180
-rw-r--r--cgats/cgatsstd.c111
-rw-r--r--cgats/makezip.ksh2
-rw-r--r--cgats/pars.c642
-rw-r--r--cgats/pars.h242
-rw-r--r--cgats/parsstd.c476
-rw-r--r--config.guess1558
-rw-r--r--config.h.in95
-rw-r--r--config.sub1791
-rw-r--r--configure15216
-rw-r--r--configure.ac133
-rw-r--r--debian/README.Debian8
-rw-r--r--debian/README.Spyder236
-rw-r--r--debian/applycal.159
-rw-r--r--debian/argyll.examples1
-rw-r--r--debian/argyll.install50
-rw-r--r--debian/argyll.manpages45
-rw-r--r--debian/argyll.postrm35
-rw-r--r--debian/argyll.preinst57
-rw-r--r--debian/average.152
-rw-r--r--debian/cb2ti3.135
-rw-r--r--debian/cctiff.1145
-rw-r--r--debian/ccttest.119
-rw-r--r--debian/ccxxmake.1171
-rw-r--r--debian/changelog506
-rw-r--r--debian/chartread.1185
-rw-r--r--debian/collink.1355
-rw-r--r--debian/colprof.1369
-rw-r--r--debian/compat1
-rw-r--r--debian/control114
-rw-r--r--debian/copyright823
-rw-r--r--debian/dispcal.1289
-rw-r--r--debian/dispread.1183
-rw-r--r--debian/dispwin.1151
-rw-r--r--debian/extracticc.119
-rw-r--r--debian/extractttag.131
-rw-r--r--debian/fakeCMY.137
-rw-r--r--debian/fakeread.1107
-rw-r--r--debian/greytiff.129
-rw-r--r--debian/icc-utils.install2
-rw-r--r--debian/icc-utils.manpages2
-rw-r--r--debian/iccdump.135
-rw-r--r--debian/iccgamut.1181
-rw-r--r--debian/icclu.161
-rw-r--r--debian/illumread.163
-rw-r--r--debian/invprofcheck.183
-rw-r--r--debian/kodak2ti3.141
-rw-r--r--debian/libicc-dev.install4
-rw-r--r--debian/libicc2.install1
-rw-r--r--debian/libicc2.symbols103
-rw-r--r--debian/libimdi-dev.install8
-rw-r--r--debian/libimdi0.install1
-rw-r--r--debian/libimdi0.symbols16
-rw-r--r--debian/mppcheck.151
-rw-r--r--debian/mpplu.1107
-rw-r--r--debian/mppprof.153
-rw-r--r--debian/oeminst.149
-rw-r--r--debian/patches/01_autotools-support.diff31463
-rw-r--r--debian/patches/02_firmware-package-builder.diff71
-rw-r--r--debian/patches/03_kfreebsd.diff22
-rw-r--r--debian/patches/03_usb-db.diff15
-rw-r--r--debian/patches/04_CVE-2012-4405.diff14
-rw-r--r--debian/patches/05_external-yajl.diff19
-rw-r--r--debian/patches/06_fix_udev_rule.patch23
-rw-r--r--debian/patches/series5
-rw-r--r--debian/pathplot.117
-rw-r--r--debian/printcal.1153
-rw-r--r--debian/printtarg.1243
-rw-r--r--debian/profcheck.1115
-rw-r--r--debian/refine.1109
-rw-r--r--debian/revfix.191
-rwxr-xr-xdebian/rules125
-rw-r--r--debian/scanin.1215
-rw-r--r--debian/simpprof.123
-rw-r--r--debian/source/format1
-rw-r--r--debian/spec2cie.184
-rw-r--r--debian/specplot.149
-rw-r--r--debian/splitti3.159
-rw-r--r--debian/spotread.1235
-rw-r--r--debian/synthcal.187
-rw-r--r--debian/synthread.185
-rw-r--r--debian/targen.1203
-rw-r--r--debian/tiffgamut.1165
-rw-r--r--debian/txt2ti3.161
-rw-r--r--debian/verify.1117
-rw-r--r--debian/viewgam.179
-rw-r--r--debian/watch3
-rw-r--r--debian/xicclu.1257
-rw-r--r--depcomp791
-rw-r--r--doc/ArgyllDoc.html5570
-rw-r--r--doc/ArgyllFlow.jpgbin0 -> 225826 bytes
-rw-r--r--doc/ArgyllFlowThumb.jpgbin0 -> 10629 bytes
-rw-r--r--doc/CMP_DT_003.jpgbin0 -> 23966 bytes
-rw-r--r--doc/CMP_Digital_Target-3.jpgbin0 -> 21111 bytes
-rw-r--r--doc/CRTspectrum.jpgbin0 -> 32231 bytes
-rw-r--r--doc/ChangesSummary.html790
-rw-r--r--doc/Chroma4.jpgbin0 -> 16118 bytes
-rw-r--r--doc/ColorManagement.html271
-rw-r--r--doc/ColorMunki.jpgbin0 -> 43097 bytes
-rw-r--r--doc/ColorMunkiCreate.jpgbin0 -> 29653 bytes
-rw-r--r--doc/Compiling.html170
-rw-r--r--doc/CrushedDisplyBlacks.html85
-rw-r--r--doc/DC.jpgbin0 -> 23570 bytes
-rw-r--r--doc/DTP20.jpgbin0 -> 83527 bytes
-rw-r--r--doc/DTP22.jpgbin0 -> 51054 bytes
-rw-r--r--doc/DTP41.jpgbin0 -> 78517 bytes
-rw-r--r--doc/DTP51.jpgbin0 -> 52356 bytes
-rw-r--r--doc/DTP92.jpgbin0 -> 41789 bytes
-rw-r--r--doc/DTP94.jpgbin0 -> 46245 bytes
-rw-r--r--doc/DocLicense.txt451
-rw-r--r--doc/Environment.html125
-rw-r--r--doc/FWA.html262
-rw-r--r--doc/FWA_measure.jpgbin0 -> 23717 bytes
-rw-r--r--doc/File_Formats.html186
-rw-r--r--doc/Fluorescent.jpgbin0 -> 35863 bytes
-rw-r--r--doc/HCFR.jpgbin0 -> 21765 bytes
-rw-r--r--doc/HCT.jpgbin0 -> 9601 bytes
-rw-r--r--doc/HiResLaser.jpgbin0 -> 28163 bytes
-rw-r--r--doc/Huey.jpgbin0 -> 30022 bytes
-rw-r--r--doc/Installing.html49
-rw-r--r--doc/Installing_Linux.html582
-rw-r--r--doc/Installing_MSWindows.html583
-rw-r--r--doc/Installing_OSX.html283
-rw-r--r--doc/Kgraph1.jpgbin0 -> 14691 bytes
-rw-r--r--doc/Kgraph2.jpgbin0 -> 13544 bytes
-rw-r--r--doc/Kgraph3.jpgbin0 -> 14548 bytes
-rw-r--r--doc/Kgraph4.jpgbin0 -> 14056 bytes
-rw-r--r--doc/Kgraph5.jpgbin0 -> 14084 bytes
-rw-r--r--doc/Kgraph6.jpgbin0 -> 14830 bytes
-rw-r--r--doc/Kgraph7.jpgbin0 -> 15134 bytes
-rw-r--r--doc/Kgraph8.jpgbin0 -> 14218 bytes
-rw-r--r--doc/Kparams.jpgbin0 -> 15850 bytes
-rw-r--r--doc/LSDC.jpgbin0 -> 12237 bytes
-rw-r--r--doc/LabSteps.jpgbin0 -> 13335 bytes
-rw-r--r--doc/License.txt662
-rw-r--r--doc/License2.txt282
-rw-r--r--doc/License3.txt674
-rw-r--r--doc/Limitations.html42
-rw-r--r--doc/Makefile.am6
-rw-r--r--doc/MinorTools.html64
-rw-r--r--doc/Organisation.html230
-rw-r--r--doc/Overview.html57
-rw-r--r--doc/Performance.html106
-rw-r--r--doc/Q60.jpgbin0 -> 14943 bytes
-rw-r--r--doc/QPcard201.jpgbin0 -> 4967 bytes
-rw-r--r--doc/QPcard202.jpgbin0 -> 9016 bytes
-rw-r--r--doc/SG.jpgbin0 -> 11348 bytes
-rw-r--r--doc/SG_footer.txt1
-rw-r--r--doc/SG_header.txt12
-rw-r--r--doc/Scenarios.html2177
-rw-r--r--doc/Smile.jpgbin0 -> 25761 bytes
-rw-r--r--doc/Source.html219
-rw-r--r--doc/Spyd2.jpgbin0 -> 64227 bytes
-rw-r--r--doc/Spyd3.jpgbin0 -> 13975 bytes
-rw-r--r--doc/Spyd3x.jpgbin0 -> 13519 bytes
-rw-r--r--doc/Spyd4.jpgbin0 -> 11284 bytes
-rw-r--r--doc/SpyderChecker.jpgbin0 -> 12497 bytes
-rw-r--r--doc/WideGamutColmters.html120
-rw-r--r--doc/YellowGreen.jpgbin0 -> 18404 bytes
-rw-r--r--doc/afiles179
-rw-r--r--doc/applycal.html135
-rw-r--r--doc/average.html43
-rw-r--r--doc/cal_format.html216
-rw-r--r--doc/calvschar.html62
-rw-r--r--doc/cb2ti3.html56
-rw-r--r--doc/ccmxs.html424
-rw-r--r--doc/ccmxs/DTP-94_1964_10_Dell_2408W.ccmx25
-rw-r--r--doc/ccmxs/DTP-94_1997_Shaw_Dell_2408W.ccmx25
-rw-r--r--doc/ccmxs/DTP-94_Dell_2408W.ccmx25
-rw-r--r--doc/ccmxs/DTP-94_Dell_U2410.ccmx25
-rw-r--r--doc/ccmxs/EyeOne_Display_1_NEC1990SXi.ccmx25
-rw-r--r--doc/ccmxs/EyeOne_Display_2_EIZO_S2233W.ccmx25
-rw-r--r--doc/ccmxs/EyeOne_Display_2_NEC1990SXi.ccmx25
-rw-r--r--doc/ccmxs/EyeOne_Display_LT_U2410_Standard_1931.ccmx25
-rw-r--r--doc/ccmxs/EyeOne_Display_LT_U2410_Standard_1964.ccmx25
-rw-r--r--doc/ccmxs/EyeOne_Display_LT_U2410_sRGB_1931.ccmx25
-rw-r--r--doc/ccmxs/EyeOne_Display_LT_U2410_sRGB_1964.ccmx25
-rw-r--r--doc/ccmxs/Huey_Acer_al2016w.ccmx25
-rw-r--r--doc/ccmxs/Huey_Eizo_CG243.ccmx25
-rw-r--r--doc/ccmxs/Huey_HP_compaq_6730s.ccmx25
-rw-r--r--doc/ccmxs/Huey_HP_lp2475w.ccmx25
-rw-r--r--doc/ccmxs/Huey_NEC1990SXi.ccmx25
-rw-r--r--doc/ccmxs/Huey_NEC_Spectraview_241.ccmx25
-rw-r--r--doc/ccmxs/NEC_EyeOne_Display_2_NEC2690WUXi2.ccmx25
-rw-r--r--doc/ccmxs/Spyder2_EIZO_S2433W_standard_1931.ccmx25
-rw-r--r--doc/ccmxs/Spyder2_EIZO_S2433W_standard_1964.ccmx25
-rw-r--r--doc/ccmxs/Spyder3_EIZO_S2233_standard_1964.ccmx25
-rw-r--r--doc/ccmxs/Spyder3_EIZO_S2243W_standard_1931.ccmx25
-rw-r--r--doc/ccmxs/Spyder3_HP_LP2475w.ccmx25
-rw-r--r--doc/ccmxs/Spyder3_NEC2690WUXi2.ccmx25
-rw-r--r--doc/ccmxs/Spyder3_NEC_PA301W.ccmx25
-rw-r--r--doc/cctiff.html351
-rw-r--r--doc/ccxxmake.html954
-rw-r--r--doc/chartread.html499
-rw-r--r--doc/cht_format.html576
-rw-r--r--doc/collink.html1059
-rw-r--r--doc/colorchecker.jpgbin0 -> 7522 bytes
-rw-r--r--doc/colprof.html1559
-rw-r--r--doc/cube.jpgbin0 -> 11036 bytes
-rw-r--r--doc/dispcal.html2256
-rw-r--r--doc/dispprofloc.html313
-rw-r--r--doc/dispread.html926
-rw-r--r--doc/dispwin.html593
-rw-r--r--doc/evalInputTargets.html61
-rw-r--r--doc/extracticc.html40
-rw-r--r--doc/extractttag.html43
-rw-r--r--doc/fakeCMY.html73
-rw-r--r--doc/fakeread.html248
-rw-r--r--doc/filmread.html55
-rw-r--r--doc/filmtarg.html78
-rw-r--r--doc/gamma.html64
-rw-r--r--doc/gamutmapping1.jpgbin0 -> 19794 bytes
-rw-r--r--doc/greytiff.html96
-rw-r--r--doc/i1d.jpgbin0 -> 36903 bytes
-rw-r--r--doc/i1d3_1.jpgbin0 -> 16744 bytes
-rw-r--r--doc/i1d3_2.jpgbin0 -> 16538 bytes
-rw-r--r--doc/i1m.jpgbin0 -> 29888 bytes
-rw-r--r--doc/i1p.jpgbin0 -> 62804 bytes
-rw-r--r--doc/i1pro2.jpgbin0 -> 73450 bytes
-rw-r--r--doc/i1proDriver.html157
-rw-r--r--doc/i1proDriver.xlsbin0 -> 187392 bytes
-rw-r--r--doc/i1scan14.jpgbin0 -> 15925 bytes
-rw-r--r--doc/iccdump.html52
-rw-r--r--doc/iccgamut.html334
-rw-r--r--doc/iccgamutmapping.html163
-rw-r--r--doc/icclu.html119
-rw-r--r--doc/illumread.html319
-rw-r--r--doc/illumread_1.jpgbin0 -> 14047 bytes
-rw-r--r--doc/illumread_2.jpgbin0 -> 13451 bytes
-rw-r--r--doc/illumread_3.jpgbin0 -> 17753 bytes
-rw-r--r--doc/illumread_4.jpgbin0 -> 21691 bytes
-rw-r--r--doc/illumread_5.jpgbin0 -> 15948 bytes
-rw-r--r--doc/illumread_6.jpgbin0 -> 8066 bytes
-rw-r--r--doc/instruments.html2214
-rw-r--r--doc/invprofcheck.html133
-rw-r--r--doc/kodak2ti3.html59
-rw-r--r--doc/monitorcontrols.html90
-rw-r--r--doc/mox.jpgbin0 -> 8355 bytes
-rw-r--r--doc/moxxr.jpgbin0 -> 6289 bytes
-rw-r--r--doc/mppcheck.html78
-rw-r--r--doc/mpplu.html182
-rw-r--r--doc/mppprof.html99
-rw-r--r--doc/oeminst.html323
-rw-r--r--doc/printcal.html399
-rw-r--r--doc/printtarg.html681
-rw-r--r--doc/profcheck.html251
-rw-r--r--doc/refine.html354
-rw-r--r--doc/revfix.html252
-rw-r--r--doc/scanin.html582
-rw-r--r--doc/sl.jpgbin0 -> 77102 bytes
-rw-r--r--doc/spec2cie.html207
-rw-r--r--doc/specplot.html46
-rw-r--r--doc/splitti3.html75
-rw-r--r--doc/spotread.html1011
-rw-r--r--doc/srgbplot.gifbin0 -> 3468 bytes
-rw-r--r--doc/ss.jpgbin0 -> 65180 bytes
-rw-r--r--doc/surface.jpgbin0 -> 11222 bytes
-rw-r--r--doc/synthcal.html108
-rw-r--r--doc/synthread.html166
-rw-r--r--doc/targen.html1024
-rw-r--r--doc/ti3_format.html311
-rw-r--r--doc/tiffgamut.html357
-rw-r--r--doc/timage.html100
-rw-r--r--doc/txt2ti3.html98
-rw-r--r--doc/ucmm.html122
-rw-r--r--doc/verify.html186
-rw-r--r--doc/viewgam.html125
-rw-r--r--doc/xicclu.html551
-rw-r--r--firmware-package-builder/argyll-firmware-spyder2/debian/changelog12
-rw-r--r--firmware-package-builder/argyll-firmware-spyder2/debian/compat1
-rw-r--r--firmware-package-builder/argyll-firmware-spyder2/debian/control17
-rw-r--r--firmware-package-builder/argyll-firmware-spyder2/debian/copyright8
-rw-r--r--firmware-package-builder/argyll-firmware-spyder2/debian/install1
-rw-r--r--firmware-package-builder/argyll-firmware-spyder2/debian/rules10
-rw-r--r--gamut/GenRMGam.c786
-rw-r--r--gamut/GenVisGam.c189
-rw-r--r--gamut/Jamfile93
-rw-r--r--gamut/License.txt662
-rw-r--r--gamut/Makefile.am27
-rw-r--r--gamut/Readme.txt25
-rw-r--r--gamut/afiles19
-rw-r--r--gamut/fakegam.c325
-rw-r--r--gamut/gammap.c2552
-rw-r--r--gamut/gammap.h68
-rw-r--r--gamut/gammap.txt259
-rw-r--r--gamut/gamut.c7136
-rw-r--r--gamut/gamut.h406
-rw-r--r--gamut/isecvol.c320
-rw-r--r--gamut/maptest.c240
-rw-r--r--gamut/nearsmth.c3570
-rw-r--r--gamut/nearsmth.h274
-rw-r--r--gamut/smthtest.c460
-rw-r--r--gamut/surftest.c255
-rw-r--r--gamut/viewgam.c700
-rw-r--r--h/License.txt662
-rw-r--r--h/Makefile.am3
-rw-r--r--h/Readme.txt1
-rw-r--r--h/aconfig.h29
-rw-r--r--h/afiles9
-rw-r--r--h/copyright.h5
-rw-r--r--h/counters.h246
-rw-r--r--h/llist.h92
-rw-r--r--h/sort.h62
-rw-r--r--h/xlist.h56
-rw-r--r--icc/ClayRGB1998.icmbin0 -> 580 bytes
-rw-r--r--icc/Jamfile58
-rw-r--r--icc/License.txt22
-rw-r--r--icc/Makefile82
-rw-r--r--icc/Makefile.IBMNT41
-rw-r--r--icc/Makefile.OSX38
-rw-r--r--icc/Makefile.UNIX38
-rw-r--r--icc/Makefile.WNT38
-rw-r--r--icc/Makefile.am22
-rw-r--r--icc/Readme.txt150
-rw-r--r--icc/afiles26
-rw-r--r--icc/icc.c17838
-rw-r--r--icc/icc.h1992
-rw-r--r--icc/iccV42.h555
-rw-r--r--icc/iccdump.c269
-rw-r--r--icc/icclu.c424
-rw-r--r--icc/iccrw.c311
-rw-r--r--icc/iccstd.c443
-rw-r--r--icc/icctest.c2393
-rw-r--r--icc/lab2lab.icmbin0 -> 500 bytes
-rw-r--r--icc/log.txt173
-rw-r--r--icc/lutest.c3506
-rw-r--r--icc/makezip.ksh6
-rw-r--r--icc/mcheck.c541
-rw-r--r--icc/sRGB.icmbin0 -> 3212 bytes
-rw-r--r--icc/testDE2K.c226
-rw-r--r--icc/todo.txt197
-rw-r--r--imdi/Jamfile90
-rw-r--r--imdi/License.txt662
-rw-r--r--imdi/Makefile66
-rw-r--r--imdi/Makefile.OSX42
-rw-r--r--imdi/Makefile.UNIX42
-rw-r--r--imdi/Makefile.WNT42
-rw-r--r--imdi/Makefile.am40
-rw-r--r--imdi/Readme.txt114
-rw-r--r--imdi/afiles26
-rw-r--r--imdi/cctiff.c2320
-rw-r--r--imdi/cctiffo.c1097
-rw-r--r--imdi/cgen.c2150
-rw-r--r--imdi/ctest.c156
-rw-r--r--imdi/greytiff.c575
-rw-r--r--imdi/imdi.c605
-rw-r--r--imdi/imdi.h93
-rw-r--r--imdi/imdi_arch.h71
-rw-r--r--imdi/imdi_gen.c319
-rw-r--r--imdi/imdi_gen.h271
-rw-r--r--imdi/imdi_k.h910
-rw-r--r--imdi/imdi_make.c514
-rw-r--r--imdi/imdi_tab.c803
-rw-r--r--imdi/imdi_tab.h170
-rw-r--r--imdi/imdi_utl.h262
-rw-r--r--imdi/itest.c652
-rw-r--r--imdi/refi.c212
-rw-r--r--imdi/refi.h53
-rw-r--r--imdi/ssort.c322
-rw-r--r--install-sh527
-rw-r--r--install.bat5
-rw-r--r--jam.patch74
-rw-r--r--jcnf/Jamfile32
-rw-r--r--jcnf/Makefile.am15
-rw-r--r--jcnf/Readme.txt22
-rw-r--r--jcnf/afiles7
-rw-r--r--jcnf/jcnf.c1248
-rw-r--r--jcnf/jcnf.h199
-rw-r--r--jcnf/test.c161
-rw-r--r--jcnf/test.jcnf33
-rw-r--r--jcnf/yajl/COPYING29
-rw-r--r--jcnf/yajl/ChangeLog88
-rw-r--r--jcnf/yajl/Jamfile30
-rw-r--r--jcnf/yajl/Makefile.am13
-rw-r--r--jcnf/yajl/README68
-rw-r--r--jcnf/yajl/TODO9
-rw-r--r--jcnf/yajl/YAJL.dxy1258
-rw-r--r--jcnf/yajl/YAJLDoc.cmake26
-rw-r--r--jcnf/yajl/afiles84
-rw-r--r--jcnf/yajl/cases/array.json6
-rw-r--r--jcnf/yajl/cases/array.json.gold22
-rw-r--r--jcnf/yajl/cases/bogus_char.json4
-rw-r--r--jcnf/yajl/cases/bogus_char.json.gold9
-rw-r--r--jcnf/yajl/cases/codepoints_from_unicode_org.json1
-rw-r--r--jcnf/yajl/cases/codepoints_from_unicode_org.json.gold1
-rw-r--r--jcnf/yajl/cases/dc_simple_with_comments.json11
-rw-r--r--jcnf/yajl/cases/dc_simple_with_comments.json.gold4
-rw-r--r--jcnf/yajl/cases/deep_arrays.json1
-rw-r--r--jcnf/yajl/cases/deep_arrays.json.gold2048
-rw-r--r--jcnf/yajl/cases/difficult_json_c_test_case.json1
-rw-r--r--jcnf/yajl/cases/difficult_json_c_test_case.json.gold35
-rw-r--r--jcnf/yajl/cases/difficult_json_c_test_case_with_comments.json1
-rw-r--r--jcnf/yajl/cases/difficult_json_c_test_case_with_comments.json.gold35
-rw-r--r--jcnf/yajl/cases/doubles.json1
-rw-r--r--jcnf/yajl/cases/doubles.json.gold6
-rw-r--r--jcnf/yajl/cases/empty_array.json1
-rw-r--r--jcnf/yajl/cases/empty_array.json.gold2
-rw-r--r--jcnf/yajl/cases/escaped_bulgarian.json4
-rw-r--r--jcnf/yajl/cases/escaped_bulgarian.json.gold6
-rw-r--r--jcnf/yajl/cases/escaped_foobar.json1
-rw-r--r--jcnf/yajl/cases/escaped_foobar.json.gold1
-rw-r--r--jcnf/yajl/cases/integers.json3
-rw-r--r--jcnf/yajl/cases/integers.json.gold13
-rw-r--r--jcnf/yajl/cases/invalid_utf8.json1
-rw-r--r--jcnf/yajl/cases/invalid_utf8.json.gold2
-rw-r--r--jcnf/yajl/cases/isolated_surrogate_marker.json1
-rw-r--r--jcnf/yajl/cases/isolated_surrogate_marker.json.gold1
-rw-r--r--jcnf/yajl/cases/leading_zero_in_number.json1
-rw-r--r--jcnf/yajl/cases/leading_zero_in_number.json.gold4
-rw-r--r--jcnf/yajl/cases/lonely_minus_sign.json7
-rw-r--r--jcnf/yajl/cases/lonely_minus_sign.json.gold8
-rw-r--r--jcnf/yajl/cases/missing_integer_after_decimal_point.json1
-rw-r--r--jcnf/yajl/cases/missing_integer_after_decimal_point.json.gold1
-rw-r--r--jcnf/yajl/cases/missing_integer_after_exponent.json1
-rw-r--r--jcnf/yajl/cases/missing_integer_after_exponent.json.gold1
-rw-r--r--jcnf/yajl/cases/non_utf8_char_in_string.json1
-rw-r--r--jcnf/yajl/cases/non_utf8_char_in_string.json.gold7
-rw-r--r--jcnf/yajl/cases/nulls_and_bools.json5
-rw-r--r--jcnf/yajl/cases/nulls_and_bools.json.gold8
-rw-r--r--jcnf/yajl/cases/simple.json5
-rw-r--r--jcnf/yajl/cases/simple.json.gold8
-rw-r--r--jcnf/yajl/cases/simple_with_comments.json11
-rw-r--r--jcnf/yajl/cases/simple_with_comments.json.gold8
-rw-r--r--jcnf/yajl/cases/string_invalid_escape.json1
-rw-r--r--jcnf/yajl/cases/string_invalid_escape.json.gold2
-rw-r--r--jcnf/yajl/cases/string_invalid_hex_char.json1
-rw-r--r--jcnf/yajl/cases/string_invalid_hex_char.json.gold1
-rw-r--r--jcnf/yajl/cases/string_with_escapes.json3
-rw-r--r--jcnf/yajl/cases/string_with_escapes.json.gold6
-rw-r--r--jcnf/yajl/cases/string_with_invalid_newline.json2
-rw-r--r--jcnf/yajl/cases/string_with_invalid_newline.json.gold1
-rw-r--r--jcnf/yajl/cases/unescaped_bulgarian.json1
-rw-r--r--jcnf/yajl/cases/unescaped_bulgarian.json.gold3
-rw-r--r--jcnf/yajl/configure94
-rw-r--r--jcnf/yajl/json_reformat.c204
-rw-r--r--jcnf/yajl/json_verify.c129
-rw-r--r--jcnf/yajl/rfc4627.txt3
-rw-r--r--jcnf/yajl/run_tests.sh61
-rw-r--r--jcnf/yajl/yajl.c152
-rw-r--r--jcnf/yajl/yajl_alloc.c65
-rw-r--r--jcnf/yajl/yajl_alloc.h50
-rw-r--r--jcnf/yajl/yajl_buf.c119
-rw-r--r--jcnf/yajl/yajl_buf.h73
-rw-r--r--jcnf/yajl/yajl_bytestack.h85
-rw-r--r--jcnf/yajl/yajl_common.h85
-rw-r--r--jcnf/yajl/yajl_encode.c179
-rw-r--r--jcnf/yajl/yajl_encode.h44
-rw-r--r--jcnf/yajl/yajl_gen.c381
-rw-r--r--jcnf/yajl/yajl_gen.h129
-rw-r--r--jcnf/yajl/yajl_lex.c753
-rw-r--r--jcnf/yajl/yajl_lex.h135
-rw-r--r--jcnf/yajl/yajl_parse.h184
-rw-r--r--jcnf/yajl/yajl_parser.c505
-rw-r--r--jcnf/yajl/yajl_parser.h79
-rw-r--r--jcnf/yajl/yajl_test.c293
-rw-r--r--jpg/Jamfile26
-rw-r--r--jpg/Makefile.am134
-rw-r--r--jpg/Makefile.in1094
-rw-r--r--jpg/README351
-rw-r--r--jpg/aclocal.m49652
-rw-r--r--jpg/afiles185
-rw-r--r--jpg/ansi2knr.136
-rw-r--r--jpg/ansi2knr.c739
-rw-r--r--jpg/cderror.h134
-rw-r--r--jpg/cdjpeg.c181
-rw-r--r--jpg/cdjpeg.h187
-rw-r--r--jpg/change.log346
-rw-r--r--jpg/cjpeg.1348
-rw-r--r--jpg/cjpeg.c643
-rw-r--r--jpg/ckconfig.c402
-rw-r--r--jpg/coderules.txt118
-rw-r--r--jpg/config.guess1522
-rw-r--r--jpg/config.sub1771
-rw-r--r--jpg/configure15928
-rw-r--r--jpg/configure.ac356
-rw-r--r--jpg/depcomp688
-rw-r--r--jpg/djpeg.1252
-rw-r--r--jpg/djpeg.c617
-rw-r--r--jpg/example.c433
-rw-r--r--jpg/filelist.txt215
-rw-r--r--jpg/install-sh527
-rw-r--r--jpg/install.txt1096
-rw-r--r--jpg/jaricom.c153
-rw-r--r--jpg/jcapimin.c288
-rw-r--r--jpg/jcapistd.c161
-rw-r--r--jpg/jcarith.c937
-rw-r--r--jpg/jccoefct.c454
-rw-r--r--jpg/jccolor.c490
-rw-r--r--jpg/jcdctmgr.c482
-rw-r--r--jpg/jchuff.c1576
-rw-r--r--jpg/jcinit.c65
-rw-r--r--jpg/jcmainct.c293
-rw-r--r--jpg/jcmarker.c682
-rw-r--r--jpg/jcmaster.c858
-rw-r--r--jpg/jcomapi.c106
-rw-r--r--jpg/jconfig.bcc48
-rw-r--r--jpg/jconfig.cfg53
-rw-r--r--jpg/jconfig.dj38
-rw-r--r--jpg/jconfig.mac43
-rw-r--r--jpg/jconfig.manx43
-rw-r--r--jpg/jconfig.mc652
-rw-r--r--jpg/jconfig.sas43
-rw-r--r--jpg/jconfig.st42
-rw-r--r--jpg/jconfig.txt164
-rw-r--r--jpg/jconfig.vc45
-rw-r--r--jpg/jconfig.vms37
-rw-r--r--jpg/jconfig.wat38
-rw-r--r--jpg/jcparam.c632
-rw-r--r--jpg/jcprepct.c358
-rw-r--r--jpg/jcsample.c545
-rw-r--r--jpg/jctrans.c382
-rw-r--r--jpg/jdapimin.c396
-rw-r--r--jpg/jdapistd.c275
-rw-r--r--jpg/jdarith.c776
-rw-r--r--jpg/jdatadst.c267
-rw-r--r--jpg/jdatasrc.c275
-rw-r--r--jpg/jdcoefct.c741
-rw-r--r--jpg/jdcolor.c512
-rw-r--r--jpg/jdct.h393
-rw-r--r--jpg/jddctmgr.c384
-rw-r--r--jpg/jdhuff.c1541
-rw-r--r--jpg/jdinput.c661
-rw-r--r--jpg/jdmainct.c512
-rw-r--r--jpg/jdmarker.c1406
-rw-r--r--jpg/jdmaster.c531
-rw-r--r--jpg/jdmerge.c400
-rw-r--r--jpg/jdosaobj.txt16
-rw-r--r--jpg/jdpostct.c290
-rw-r--r--jpg/jdsample.c361
-rw-r--r--jpg/jdtrans.c140
-rw-r--r--jpg/jerror.c252
-rw-r--r--jpg/jerror.h304
-rw-r--r--jpg/jfdctflt.c174
-rw-r--r--jpg/jfdctfst.c230
-rw-r--r--jpg/jfdctint.c4348
-rw-r--r--jpg/jidctflt.c235
-rw-r--r--jpg/jidctfst.c368
-rw-r--r--jpg/jidctint.c5137
-rw-r--r--jpg/jinclude.h91
-rw-r--r--jpg/jmemansi.c167
-rw-r--r--jpg/jmemdos.c638
-rw-r--r--jpg/jmemdosa.asm379
-rw-r--r--jpg/jmemmac.c289
-rw-r--r--jpg/jmemmgr.c1119
-rw-r--r--jpg/jmemname.c276
-rw-r--r--jpg/jmemnobs.c109
-rw-r--r--jpg/jmemsys.h198
-rw-r--r--jpg/jmorecfg.h369
-rw-r--r--jpg/jpegint.h426
-rw-r--r--jpg/jpeglib.h1160
-rw-r--r--jpg/jpegsr8d.zipbin0 -> 1060974 bytes
-rw-r--r--jpg/jpegtran.1285
-rw-r--r--jpg/jpegtran.c560
-rw-r--r--jpg/jquant1.c857
-rw-r--r--jpg/jquant2.c1311
-rw-r--r--jpg/jutils.c227
-rw-r--r--jpg/jversion.h14
-rw-r--r--jpg/libjpeg.map4
-rw-r--r--jpg/libjpeg.txt3085
-rw-r--r--jpg/ltmain.sh9655
-rw-r--r--jpg/makcjpeg.st36
-rw-r--r--jpg/makdjpeg.st36
-rw-r--r--jpg/makeadsw.vc677
-rw-r--r--jpg/makeasln.v1033
-rw-r--r--jpg/makecdep.vc682
-rw-r--r--jpg/makecdsp.vc6130
-rw-r--r--jpg/makecfil.v1069
-rw-r--r--jpg/makecmak.vc6159
-rw-r--r--jpg/makecvcx.v1076
-rw-r--r--jpg/makeddep.vc682
-rw-r--r--jpg/makeddsp.vc6130
-rw-r--r--jpg/makedfil.v1069
-rw-r--r--jpg/makedmak.vc6159
-rw-r--r--jpg/makedvcx.v1076
-rw-r--r--jpg/makefile.ansi221
-rw-r--r--jpg/makefile.bcc292
-rw-r--r--jpg/makefile.dj227
-rw-r--r--jpg/makefile.manx221
-rw-r--r--jpg/makefile.mc6256
-rw-r--r--jpg/makefile.mms225
-rw-r--r--jpg/makefile.sas259
-rw-r--r--jpg/makefile.unix235
-rw-r--r--jpg/makefile.vc273
-rw-r--r--jpg/makefile.vms142
-rw-r--r--jpg/makefile.wat240
-rw-r--r--jpg/makejdep.vc6423
-rw-r--r--jpg/makejdsp.vc6285
-rw-r--r--jpg/makejdsw.vc629
-rw-r--r--jpg/makejfil.v10186
-rw-r--r--jpg/makejmak.vc6425
-rw-r--r--jpg/makejsln.v1017
-rw-r--r--jpg/makejvcx.v10112
-rw-r--r--jpg/makeproj.mac213
-rw-r--r--jpg/makerdep.vc66
-rw-r--r--jpg/makerdsp.vc678
-rw-r--r--jpg/makerfil.v1030
-rw-r--r--jpg/makermak.vc6110
-rw-r--r--jpg/makervcx.v1062
-rw-r--r--jpg/maketdep.vc643
-rw-r--r--jpg/maketdsp.vc6122
-rw-r--r--jpg/maketfil.v1063
-rw-r--r--jpg/maketmak.vc6131
-rw-r--r--jpg/maketvcx.v1074
-rw-r--r--jpg/makewdep.vc66
-rw-r--r--jpg/makewdsp.vc678
-rw-r--r--jpg/makewfil.v1030
-rw-r--r--jpg/makewmak.vc6110
-rw-r--r--jpg/makewvcx.v1062
-rw-r--r--jpg/makljpeg.st68
-rw-r--r--jpg/maktjpeg.st30
-rw-r--r--jpg/makvms.opt4
-rw-r--r--jpg/missing376
-rw-r--r--jpg/rdbmp.c480
-rw-r--r--jpg/rdcolmap.c253
-rw-r--r--jpg/rdgif.c38
-rw-r--r--jpg/rdjpgcom.163
-rw-r--r--jpg/rdjpgcom.c515
-rw-r--r--jpg/rdppm.c459
-rw-r--r--jpg/rdrle.c387
-rw-r--r--jpg/rdswitch.c365
-rw-r--r--jpg/rdtarga.c500
-rw-r--r--jpg/readme.dos15
-rw-r--r--jpg/structure.txt941
-rw-r--r--jpg/testimg.bmpbin0 -> 35050 bytes
-rw-r--r--jpg/testimg.jpgbin0 -> 5764 bytes
-rw-r--r--jpg/testimg.ppm4
-rw-r--r--jpg/testimgp.jpgbin0 -> 5645 bytes
-rw-r--r--jpg/testorig.jpgbin0 -> 5770 bytes
-rw-r--r--jpg/testprog.jpgbin0 -> 5655 bytes
-rw-r--r--jpg/transupp.c1597
-rw-r--r--jpg/transupp.h213
-rw-r--r--jpg/usage.txt637
-rw-r--r--jpg/wizard.txt211
-rw-r--r--jpg/wrbmp.c442
-rw-r--r--jpg/wrgif.c399
-rw-r--r--jpg/wrjpgcom.1103
-rw-r--r--jpg/wrjpgcom.c583
-rw-r--r--jpg/wrppm.c269
-rw-r--r--jpg/wrrle.c305
-rw-r--r--jpg/wrtarga.c253
-rw-r--r--lib/Readme.txt1
-rw-r--r--lib/afiles2
-rw-r--r--link/Jamfile36
-rw-r--r--link/License.txt662
-rw-r--r--link/Makefile.am11
-rw-r--r--link/Readme.txt6
-rw-r--r--link/afiles7
-rw-r--r--link/collink.c3298
-rw-r--r--link/monoplot.c231
-rw-r--r--link/pathplot.c281
-rw-r--r--log.txt3581
-rw-r--r--m4/libtool.m47991
-rw-r--r--m4/ltoptions.m4384
-rw-r--r--m4/ltsugar.m4123
-rw-r--r--m4/ltversion.m423
-rw-r--r--m4/lt~obsolete.m498
-rw-r--r--makeall.bat5
-rw-r--r--makeall.sh12
-rw-r--r--makeinstall.sh9
-rw-r--r--makepackagebin.sh173
-rw-r--r--missing215
-rw-r--r--notes.txt118
-rw-r--r--numlib/Jamfile28
-rw-r--r--numlib/LUtest.c113
-rw-r--r--numlib/License.txt662
-rw-r--r--numlib/Makefile.am15
-rw-r--r--numlib/Readme.txt14
-rw-r--r--numlib/aatree.c432
-rw-r--r--numlib/aatree.h58
-rw-r--r--numlib/afiles32
-rw-r--r--numlib/dhsx.c302
-rw-r--r--numlib/dhsx.h42
-rw-r--r--numlib/dnsq.c1675
-rw-r--r--numlib/dnsq.h120
-rw-r--r--numlib/dnsqtest.c192
-rw-r--r--numlib/ludecomp.c500
-rw-r--r--numlib/ludecomp.h93
-rw-r--r--numlib/numlib.h18
-rw-r--r--numlib/numsup.c1539
-rw-r--r--numlib/numsup.h380
-rw-r--r--numlib/powell.c691
-rw-r--r--numlib/powell.h74
-rw-r--r--numlib/rand.c108
-rw-r--r--numlib/rand.h36
-rw-r--r--numlib/sobol.c211
-rw-r--r--numlib/sobol.h52
-rw-r--r--numlib/soboltest.c127
-rw-r--r--numlib/svd.c611
-rw-r--r--numlib/svd.h90
-rw-r--r--numlib/svdtest.c214
-rw-r--r--numlib/tdhsx.c117
-rw-r--r--numlib/tpowell.c123
-rw-r--r--numlib/zbrent.c182
-rw-r--r--numlib/zbrent.h44
-rw-r--r--numlib/zbrenttest.c56
-rw-r--r--plot/Imakefile6
-rw-r--r--plot/Jamfile27
-rw-r--r--plot/License.txt662
-rw-r--r--plot/Makefile.am12
-rw-r--r--plot/Readme.txt2
-rw-r--r--plot/afiles14
-rw-r--r--plot/osx/Jamfile21
-rw-r--r--plot/osx/Readme.txt1
-rw-r--r--plot/osx/acoccoa.h402
-rw-r--r--plot/osx/helloc.c313
-rw-r--r--plot/osx/hellom.m181
-rw-r--r--plot/plot.c2511
-rw-r--r--plot/plot.h94
-rw-r--r--plot/vrml.c928
-rw-r--r--plot/vrml.h113
-rw-r--r--profile/3dap5k.sp103
-rw-r--r--profile/CIE_C.sp118
-rw-r--r--profile/D50_0.0.sp132
-rw-r--r--profile/D50_0.1.sp132
-rw-r--r--profile/D50_0.3.sp132
-rw-r--r--profile/D50_0.5.sp132
-rw-r--r--profile/D50_0.7.sp132
-rw-r--r--profile/D50_1.0.sp132
-rw-r--r--profile/D50_1.2.sp132
-rw-r--r--profile/D50_1.5.sp132
-rw-r--r--profile/D50_1.7.sp132
-rw-r--r--profile/D50_2.0.sp132
-rw-r--r--profile/D50_2.5.sp132
-rw-r--r--profile/D50_3.0.sp132
-rw-r--r--profile/GTIPlus.sp64
-rw-r--r--profile/Jamfile104
-rw-r--r--profile/License.txt662
-rw-r--r--profile/Makefile.am27
-rw-r--r--profile/Office.sp103
-rw-r--r--profile/Readme.txt3
-rw-r--r--profile/Trulux.sp103
-rw-r--r--profile/TruluxPlus.sp103
-rw-r--r--profile/afiles40
-rw-r--r--profile/applycal.c693
-rw-r--r--profile/cb2ti3.c244
-rw-r--r--profile/colprof.c1116
-rw-r--r--profile/example.sp132
-rw-r--r--profile/example121.sp147
-rw-r--r--profile/invprofcheck.c733
-rw-r--r--profile/kodak2ti3.c1273
-rw-r--r--profile/mppcheck.c588
-rw-r--r--profile/mppprof.c961
-rw-r--r--profile/printcal.c2320
-rw-r--r--profile/prof.h109
-rw-r--r--profile/profcheck.c1349
-rw-r--r--profile/profin.c1310
-rw-r--r--profile/profout.c2963
-rw-r--r--profile/simpprof.c433
-rw-r--r--profile/splitti3.c400
-rw-r--r--profile/txt2ti3.c830
-rw-r--r--profile/verify.c783
-rw-r--r--ref/3dap5k.sp103
-rw-r--r--ref/CIE_C.sp118
-rw-r--r--ref/CMP_DT_003.cht336
-rw-r--r--ref/CMP_Digital_Target-3.cht1210
-rw-r--r--ref/CMP_Digital_Target-3.cie591
-rw-r--r--ref/CMP_Digital_Target-3.ti2601
-rw-r--r--ref/CRT.ccss42
-rw-r--r--ref/ClayRGB1998.icmbin0 -> 580 bytes
-rw-r--r--ref/ColorChecker.cht59
-rw-r--r--ref/ColorChecker.cie39
-rw-r--r--ref/ColorChecker.ti254
-rw-r--r--ref/ColorCheckerDC.cht318
-rw-r--r--ref/ColorCheckerPassport.cht122
-rw-r--r--ref/ColorCheckerPassport.cie64
-rw-r--r--ref/ColorCheckerSG.cht203
-rw-r--r--ref/D50_0.0.sp132
-rw-r--r--ref/D50_0.1.sp132
-rw-r--r--ref/D50_0.3.sp132
-rw-r--r--ref/D50_0.5.sp132
-rw-r--r--ref/D50_0.7.sp132
-rw-r--r--ref/D50_1.0.sp132
-rw-r--r--ref/D50_1.2.sp132
-rw-r--r--ref/D50_1.5.sp132
-rw-r--r--ref/D50_1.7.sp132
-rw-r--r--ref/D50_2.0.sp132
-rw-r--r--ref/D50_2.5.sp132
-rw-r--r--ref/D50_3.0.sp132
-rw-r--r--ref/ECI2002.ti21578
-rw-r--r--ref/ECI2002R.ti21517
-rw-r--r--ref/FograStrip2.ti1120
-rw-r--r--ref/FograStrip2_2.ti275
-rw-r--r--ref/FograStrip3.ti1146
-rw-r--r--ref/FograStrip3_3.ti2101
-rw-r--r--ref/GTIPlus.sp64
-rw-r--r--ref/Hutchcolor.cht597
-rw-r--r--ref/LaserSoftDCPro.cht202
-rw-r--r--ref/License.txt662
-rw-r--r--ref/Makefile.am7
-rw-r--r--ref/Office.sp103
-rw-r--r--ref/QPcard_201.cht76
-rw-r--r--ref/QPcard_201.cie42
-rw-r--r--ref/QPcard_202.cht80
-rw-r--r--ref/QPcard_202.cie48
-rw-r--r--ref/ReadMe.txt61
-rw-r--r--ref/SOtele.sp23
-rw-r--r--ref/SpyderChecker.cht115
-rw-r--r--ref/SpyderChecker.cie62
-rw-r--r--ref/Trulux.sp103
-rw-r--r--ref/TruluxPlus.sp103
-rw-r--r--ref/afiles59
-rw-r--r--ref/ccxx.ti122
-rw-r--r--ref/example.sp132
-rw-r--r--ref/example121.sp147
-rw-r--r--ref/i1_RGB_Scan_1.4.cht341
-rw-r--r--ref/i1_RGB_Scan_1.4.ti2319
-rw-r--r--ref/it8.cht338
-rw-r--r--ref/lab2lab.icmbin0 -> 500 bytes
-rw-r--r--ref/linear.cal275
-rw-r--r--ref/sRGB.icmbin0 -> 3212 bytes
-rw-r--r--ref/strange.cal275
-rw-r--r--render/Jamfile31
-rw-r--r--render/License.txt662
-rw-r--r--render/Makefile.am13
-rw-r--r--render/Readme.txt10
-rw-r--r--render/afiles11
-rw-r--r--render/makecharts.ksh12
-rw-r--r--render/render.c2425
-rw-r--r--render/render.h239
-rw-r--r--render/screens.h811
-rw-r--r--render/thscreen.c474
-rw-r--r--render/thscreen.h156
-rw-r--r--render/timage.c682
-rw-r--r--rspl/Jamfile83
-rw-r--r--rspl/License.txt662
-rw-r--r--rspl/Makefile.am15
-rw-r--r--rspl/Readme.txt39
-rw-r--r--rspl/afiles34
-rw-r--r--rspl/c1.c396
-rw-r--r--rspl/c1df.c313
-rw-r--r--rspl/gam.c1220
-rw-r--r--rspl/gam.h131
-rw-r--r--rspl/mlbs.c605
-rw-r--r--rspl/mlbs.h77
-rw-r--r--rspl/opt.c725
-rw-r--r--rspl/rev.c6608
-rw-r--r--rspl/rev.h457
-rw-r--r--rspl/revbench.c306
-rw-r--r--rspl/rspl.c1511
-rw-r--r--rspl/rspl.h645
-rw-r--r--rspl/rspl1.c391
-rw-r--r--rspl/rspl1.h115
-rw-r--r--rspl/rspl_imp.h27
-rw-r--r--rspl/scat.c2861
-rw-r--r--rspl/scat2.c233
-rw-r--r--rspl/sm1.c88
-rw-r--r--rspl/sm2.c110
-rw-r--r--rspl/sm3.c110
-rw-r--r--rspl/smtmpp.c1203
-rw-r--r--rspl/smtnd.c1171
-rw-r--r--rspl/spline.c352
-rw-r--r--rspl/stest.c654
-rw-r--r--rspl/t2d.c1016
-rw-r--r--rspl/t2ddf.c517
-rw-r--r--rspl/t3d.c905
-rw-r--r--rspl/t3ddf.c570
-rw-r--r--rspl/tnd.c489
-rw-r--r--rspl/trnd.c275
-rw-r--r--scanin/CMP_DT_003.cht336
-rw-r--r--scanin/CMP_Digital_Target-3.cht1210
-rw-r--r--scanin/CMP_Digital_Target-3.cie591
-rw-r--r--scanin/CMP_Digital_Target-3.ti2601
-rw-r--r--scanin/ColorChecker.cht59
-rw-r--r--scanin/ColorChecker.cie39
-rw-r--r--scanin/ColorCheckerDC.cht318
-rw-r--r--scanin/ColorCheckerPassport.cht122
-rw-r--r--scanin/ColorCheckerPassport.cie64
-rw-r--r--scanin/ColorCheckerSG.cht203
-rw-r--r--scanin/Hutchcolor.cht597
-rw-r--r--scanin/Jamfile33
-rw-r--r--scanin/LaserSoftDCPro.cht202
-rw-r--r--scanin/License.txt662
-rw-r--r--scanin/Makefile.am19
-rw-r--r--scanin/QPcard_201.cht76
-rw-r--r--scanin/QPcard_201.cie42
-rw-r--r--scanin/QPcard_202.cht80
-rw-r--r--scanin/QPcard_202.cie48
-rw-r--r--scanin/Readme.txt8
-rw-r--r--scanin/SpyderChecker.cht115
-rw-r--r--scanin/SpyderChecker.cie62
-rw-r--r--scanin/afiles28
-rw-r--r--scanin/i1_RGB_Scan_1.4.cht341
-rw-r--r--scanin/it8.cht338
-rw-r--r--scanin/scanin.c1436
-rw-r--r--scanin/scanrd.c4659
-rw-r--r--scanin/scanrd.h125
-rw-r--r--scanin/scanrd_.h321
-rw-r--r--spectro/IntsLib_Readme.txt21
-rw-r--r--spectro/Jamfile254
-rw-r--r--spectro/License.txt662
-rw-r--r--spectro/License2.txt282
-rw-r--r--spectro/License3.txt674
-rw-r--r--spectro/LzmaDec.c993
-rw-r--r--spectro/LzmaDec.h231
-rw-r--r--spectro/LzmaTypes.h254
-rw-r--r--spectro/Makefile.OSX44
-rw-r--r--spectro/Makefile.SA183
-rw-r--r--spectro/Makefile.UNIX44
-rw-r--r--spectro/Makefile.WNT47
-rw-r--r--spectro/Makefile.am53
-rw-r--r--spectro/Readme.txt37
-rw-r--r--spectro/SOtele.sp23
-rw-r--r--spectro/afiles110
-rw-r--r--spectro/aglob.c141
-rw-r--r--spectro/aglob.h63
-rw-r--r--spectro/average.c405
-rw-r--r--spectro/ccxx.ti122
-rw-r--r--spectro/ccxxmake.c1446
-rw-r--r--spectro/chartread.c2993
-rw-r--r--spectro/colorhug.c1093
-rw-r--r--spectro/colorhug.h90
-rw-r--r--spectro/conv.c1471
-rw-r--r--spectro/conv.h297
-rw-r--r--spectro/dispcal.c5356
-rw-r--r--spectro/dispread.c969
-rw-r--r--spectro/dispsup.c2343
-rw-r--r--spectro/dispsup.h247
-rw-r--r--spectro/dispwin.c6321
-rw-r--r--spectro/dispwin.h327
-rw-r--r--spectro/dtp20.c1695
-rw-r--r--spectro/dtp20.h139
-rw-r--r--spectro/dtp22.c1110
-rw-r--r--spectro/dtp22.h105
-rw-r--r--spectro/dtp41.c1292
-rw-r--r--spectro/dtp41.h110
-rw-r--r--spectro/dtp51.c898
-rw-r--r--spectro/dtp51.h102
-rw-r--r--spectro/dtp92.c1325
-rw-r--r--spectro/dtp92.h103
-rw-r--r--spectro/fakeread.c1025
-rw-r--r--spectro/hcfr.c878
-rw-r--r--spectro/hcfr.h102
-rw-r--r--spectro/hidio.c866
-rw-r--r--spectro/hidio.h87
-rw-r--r--spectro/huey.c1663
-rw-r--r--spectro/huey.h134
-rw-r--r--spectro/i1d3.c3637
-rw-r--r--spectro/i1d3.h161
-rw-r--r--spectro/i1disp.c2591
-rw-r--r--spectro/i1disp.h172
-rw-r--r--spectro/i1pro.c809
-rw-r--r--spectro/i1pro.h56
-rw-r--r--spectro/i1pro_imp.c12093
-rw-r--r--spectro/i1pro_imp.h1376
-rw-r--r--spectro/icoms.c484
-rw-r--r--spectro/icoms.h484
-rw-r--r--spectro/icoms_nt.c563
-rw-r--r--spectro/icoms_ux.c739
-rw-r--r--spectro/ifiles14
-rw-r--r--spectro/illumread.c1232
-rw-r--r--spectro/inflate.c922
-rw-r--r--spectro/inst.c1359
-rw-r--r--spectro/inst.h999
-rw-r--r--spectro/instappsup.c556
-rw-r--r--spectro/instappsup.h100
-rw-r--r--spectro/instlib.ksh191
-rw-r--r--spectro/instlib.txt11
-rw-r--r--spectro/insttypeinst.h25
-rw-r--r--spectro/insttypes.c384
-rw-r--r--spectro/insttypes.h100
-rw-r--r--spectro/iusb.h131
-rw-r--r--spectro/linear.cal275
-rw-r--r--spectro/linear.sp23
-rw-r--r--spectro/mongoose.c4819
-rw-r--r--spectro/mongoose.h308
-rw-r--r--spectro/munki.c940
-rw-r--r--spectro/munki.h72
-rw-r--r--spectro/munki_imp.c9103
-rw-r--r--spectro/munki_imp.h1029
-rw-r--r--spectro/oemarch.c2610
-rw-r--r--spectro/oemarch.h102
-rw-r--r--spectro/oeminst.c276
-rw-r--r--spectro/pollem.c111
-rw-r--r--spectro/pollem.h50
-rw-r--r--spectro/spec2cie.c831
-rw-r--r--spectro/spotread.c2271
-rw-r--r--spectro/spyd2.c3808
-rw-r--r--spectro/spyd2.h168
-rw-r--r--spectro/spyd2PLD.h10
-rw-r--r--spectro/spyd2setup.h119
-rw-r--r--spectro/ss.c2109
-rw-r--r--spectro/ss.h115
-rw-r--r--spectro/ss_imp.c1943
-rw-r--r--spectro/ss_imp.h1335
-rw-r--r--spectro/strange.cal275
-rw-r--r--spectro/synthcal.c350
-rw-r--r--spectro/synthread.c691
-rw-r--r--spectro/usbio.c585
-rw-r--r--spectro/usbio.h247
-rw-r--r--spectro/usbio_lusb.c897
-rw-r--r--spectro/usbio_lx.c1069
-rw-r--r--spectro/usbio_nt.c898
-rw-r--r--spectro/usbio_ox.c986
-rw-r--r--spectro/vinflate.c972
-rw-r--r--spectro/webwin.c455
-rw-r--r--spectro/webwin.h31
-rw-r--r--spectro/xdg_bds.c1088
-rw-r--r--spectro/xdg_bds.h115
-rw-r--r--target/ColorChecker.ti254
-rw-r--r--target/ECI2002.ti21578
-rw-r--r--target/ECI2002R.ti21517
-rw-r--r--target/FograStrip2.ti1120
-rw-r--r--target/FograStrip2_2.ti275
-rw-r--r--target/FograStrip3.ti1146
-rw-r--r--target/FograStrip3_3.ti2101
-rw-r--r--target/Jamfile74
-rw-r--r--target/License.txt662
-rw-r--r--target/Makefile.am28
-rw-r--r--target/Readme.txt13
-rw-r--r--target/afiles32
-rw-r--r--target/alphix.c468
-rw-r--r--target/alphix.h118
-rw-r--r--target/filmtarg.c458
-rw-r--r--target/i1_RGB_Scan_1.4.ti2319
-rw-r--r--target/ifarp.c946
-rw-r--r--target/ifarp.h67
-rw-r--r--target/ofps.c10222
-rw-r--r--target/ofps.h438
-rw-r--r--target/ppoint.c1056
-rw-r--r--target/ppoint.h134
-rw-r--r--target/prand.c604
-rw-r--r--target/prand.h68
-rw-r--r--target/printtarg.c4300
-rw-r--r--target/randix.c166
-rw-r--r--target/randix.h41
-rw-r--r--target/simdlat.c1063
-rw-r--r--target/simdlat.h94
-rw-r--r--target/simplat.c1095
-rw-r--r--target/simplat.h86
-rw-r--r--target/targen.c2224
-rw-r--r--target/targen.h30
-rw-r--r--tiff/COPYRIGHT21
-rw-r--r--tiff/ChangeLog4590
-rw-r--r--tiff/HOWTO-RELEASE105
-rw-r--r--tiff/Jamfile73
-rw-r--r--tiff/Makefile.am56
-rw-r--r--tiff/Makefile.in842
-rw-r--r--tiff/Makefile.vc65
-rw-r--r--tiff/README59
-rw-r--r--tiff/README.vms12
-rw-r--r--tiff/RELEASE-DATE1
-rw-r--r--tiff/SConstruct171
-rw-r--r--tiff/TODO12
-rw-r--r--tiff/VERSION1
-rw-r--r--tiff/aclocal.m41059
-rw-r--r--tiff/afiles448
-rw-r--r--tiff/autogen.sh8
-rw-r--r--tiff/build/Makefile.am31
-rw-r--r--tiff/build/Makefile.in625
-rw-r--r--tiff/build/README3
-rw-r--r--tiff/config/compile142
-rw-r--r--tiff/config/config.guess1516
-rw-r--r--tiff/config/config.sub1622
-rw-r--r--tiff/config/depcomp530
-rw-r--r--tiff/config/install-sh401
-rw-r--r--tiff/config/ltmain.sh8745
-rw-r--r--tiff/config/missing360
-rw-r--r--tiff/config/mkinstalldirs158
-rw-r--r--tiff/configure21416
-rw-r--r--tiff/configure.ac703
-rw-r--r--tiff/configure.com1345
-rw-r--r--tiff/contrib/Makefile.am29
-rw-r--r--tiff/contrib/Makefile.in623
-rw-r--r--tiff/contrib/README2
-rw-r--r--tiff/contrib/acorn/Makefile.acorn165
-rw-r--r--tiff/contrib/acorn/Makefile.am28
-rw-r--r--tiff/contrib/acorn/Makefile.in421
-rw-r--r--tiff/contrib/acorn/ReadMe79
-rw-r--r--tiff/contrib/acorn/SetVars3
-rw-r--r--tiff/contrib/acorn/cleanlib5
-rw-r--r--tiff/contrib/acorn/convert175
-rw-r--r--tiff/contrib/acorn/install128
-rw-r--r--tiff/contrib/addtiffo/Makefile.am36
-rw-r--r--tiff/contrib/addtiffo/Makefile.in556
-rw-r--r--tiff/contrib/addtiffo/Makefile.vc28
-rw-r--r--tiff/contrib/addtiffo/README142
-rw-r--r--tiff/contrib/addtiffo/addtiffo.c176
-rw-r--r--tiff/contrib/addtiffo/tif_overview.c896
-rw-r--r--tiff/contrib/addtiffo/tif_ovrcache.c341
-rw-r--r--tiff/contrib/addtiffo/tif_ovrcache.h108
-rw-r--r--tiff/contrib/dbs/Makefile.am43
-rw-r--r--tiff/contrib/dbs/Makefile.in737
-rw-r--r--tiff/contrib/dbs/README7
-rw-r--r--tiff/contrib/dbs/tiff-bi.c91
-rw-r--r--tiff/contrib/dbs/tiff-grayscale.c146
-rw-r--r--tiff/contrib/dbs/tiff-palette.c283
-rw-r--r--tiff/contrib/dbs/tiff-rgb.c201
-rw-r--r--tiff/contrib/dbs/xtiff/Makefile.am43
-rw-r--r--tiff/contrib/dbs/xtiff/Makefile.in436
-rw-r--r--tiff/contrib/dbs/xtiff/README6
-rw-r--r--tiff/contrib/dbs/xtiff/patchlevel.h8
-rw-r--r--tiff/contrib/dbs/xtiff/xtiff.c1290
-rw-r--r--tiff/contrib/dbs/xtiff/xtifficon.h21
-rw-r--r--tiff/contrib/iptcutil/Makefile.am36
-rw-r--r--tiff/contrib/iptcutil/Makefile.in553
-rw-r--r--tiff/contrib/iptcutil/README25
-rw-r--r--tiff/contrib/iptcutil/iptcutil.c941
-rw-r--r--tiff/contrib/iptcutil/test.iptcbin0 -> 1107 bytes
-rw-r--r--tiff/contrib/iptcutil/test.txt32
-rw-r--r--tiff/contrib/mac-cw/Makefile.am27
-rw-r--r--tiff/contrib/mac-cw/Makefile.in420
-rw-r--r--tiff/contrib/mac-cw/Makefile.script72
-rw-r--r--tiff/contrib/mac-cw/README18
-rw-r--r--tiff/contrib/mac-cw/mac_main.c27
-rw-r--r--tiff/contrib/mac-cw/mac_main.h19
-rw-r--r--tiff/contrib/mac-cw/metrowerks.note84
-rw-r--r--tiff/contrib/mac-cw/mkg3_main.c21
-rw-r--r--tiff/contrib/mac-cw/version.h11
-rw-r--r--tiff/contrib/mac-mpw/BUILD.mpw47
-rw-r--r--tiff/contrib/mac-mpw/Makefile.am27
-rw-r--r--tiff/contrib/mac-mpw/Makefile.in420
-rw-r--r--tiff/contrib/mac-mpw/README20
-rw-r--r--tiff/contrib/mac-mpw/libtiff.make202
-rw-r--r--tiff/contrib/mac-mpw/mactrans.c63
-rw-r--r--tiff/contrib/mac-mpw/port.make53
-rw-r--r--tiff/contrib/mac-mpw/tools.make138
-rw-r--r--tiff/contrib/mac-mpw/top.make133
-rw-r--r--tiff/contrib/mfs/Makefile.am28
-rw-r--r--tiff/contrib/mfs/Makefile.in421
-rw-r--r--tiff/contrib/mfs/README37
-rw-r--r--tiff/contrib/mfs/mfs_file.c586
-rw-r--r--tiff/contrib/pds/Makefile.am28
-rw-r--r--tiff/contrib/pds/Makefile.in421
-rw-r--r--tiff/contrib/pds/README90
-rw-r--r--tiff/contrib/pds/tif_imageiter.c525
-rw-r--r--tiff/contrib/pds/tif_imageiter.h64
-rw-r--r--tiff/contrib/pds/tif_pdsdirread.c1131
-rw-r--r--tiff/contrib/pds/tif_pdsdirwrite.c971
-rw-r--r--tiff/contrib/ras/Makefile.am28
-rw-r--r--tiff/contrib/ras/Makefile.in421
-rw-r--r--tiff/contrib/ras/README10
-rw-r--r--tiff/contrib/ras/ras2tif.c254
-rw-r--r--tiff/contrib/ras/tif2ras.c344
-rw-r--r--tiff/contrib/stream/Makefile.am28
-rw-r--r--tiff/contrib/stream/Makefile.in421
-rw-r--r--tiff/contrib/stream/README30
-rw-r--r--tiff/contrib/stream/tiffstream.cpp238
-rw-r--r--tiff/contrib/stream/tiffstream.h69
-rw-r--r--tiff/contrib/tags/Makefile.am28
-rw-r--r--tiff/contrib/tags/Makefile.in421
-rw-r--r--tiff/contrib/tags/README132
-rw-r--r--tiff/contrib/tags/listtif.c39
-rw-r--r--tiff/contrib/tags/maketif.c77
-rw-r--r--tiff/contrib/tags/xtif_dir.c350
-rw-r--r--tiff/contrib/tags/xtiffio.h59
-rw-r--r--tiff/contrib/tags/xtiffiop.h72
-rw-r--r--tiff/contrib/win_dib/Makefile.am28
-rw-r--r--tiff/contrib/win_dib/Makefile.in421
-rw-r--r--tiff/contrib/win_dib/Makefile.w95134
-rw-r--r--tiff/contrib/win_dib/README.Tiffile31
-rw-r--r--tiff/contrib/win_dib/README.tiff2dib51
-rw-r--r--tiff/contrib/win_dib/Tiffile.cpp449
-rw-r--r--tiff/contrib/win_dib/tiff2dib.c379
-rw-r--r--tiff/html/Makefile.am84
-rw-r--r--tiff/html/Makefile.in725
-rw-r--r--tiff/html/TIFFTechNote2.html707
-rw-r--r--tiff/html/addingtags.html292
-rw-r--r--tiff/html/bugs.html63
-rw-r--r--tiff/html/build.html880
-rw-r--r--tiff/html/contrib.html209
-rw-r--r--tiff/html/document.html48
-rw-r--r--tiff/html/images.html41
-rw-r--r--tiff/html/images/Makefile.am46
-rw-r--r--tiff/html/images/Makefile.in487
-rw-r--r--tiff/html/images/back.gifbin0 -> 1000 bytes
-rw-r--r--tiff/html/images/bali.jpgbin0 -> 26152 bytes
-rw-r--r--tiff/html/images/cat.gifbin0 -> 12477 bytes
-rw-r--r--tiff/html/images/cover.jpgbin0 -> 20189 bytes
-rw-r--r--tiff/html/images/cramps.gifbin0 -> 13137 bytes
-rw-r--r--tiff/html/images/dave.gifbin0 -> 8220 bytes
-rw-r--r--tiff/html/images/info.gifbin0 -> 131 bytes
-rw-r--r--tiff/html/images/jello.jpgbin0 -> 13744 bytes
-rw-r--r--tiff/html/images/jim.gifbin0 -> 14493 bytes
-rw-r--r--tiff/html/images/note.gifbin0 -> 264 bytes
-rw-r--r--tiff/html/images/oxford.gifbin0 -> 6069 bytes
-rw-r--r--tiff/html/images/quad.jpgbin0 -> 23904 bytes
-rw-r--r--tiff/html/images/ring.gifbin0 -> 4275 bytes
-rw-r--r--tiff/html/images/smallliz.jpgbin0 -> 16463 bytes
-rw-r--r--tiff/html/images/strike.gifbin0 -> 5610 bytes
-rw-r--r--tiff/html/images/warning.gifbin0 -> 287 bytes
-rw-r--r--tiff/html/index.html123
-rw-r--r--tiff/html/internals.html572
-rw-r--r--tiff/html/intro.html68
-rw-r--r--tiff/html/libtiff.html747
-rw-r--r--tiff/html/man/Makefile.am119
-rw-r--r--tiff/html/man/Makefile.in556
-rw-r--r--tiff/html/man/TIFFClose.3tiff.html87
-rw-r--r--tiff/html/man/TIFFDataWidth.3tiff.html98
-rw-r--r--tiff/html/man/TIFFError.3tiff.html106
-rw-r--r--tiff/html/man/TIFFFlush.3tiff.html113
-rw-r--r--tiff/html/man/TIFFGetField.3tiff.html1446
-rw-r--r--tiff/html/man/TIFFOpen.3tiff.html421
-rw-r--r--tiff/html/man/TIFFPrintDirectory.3tiff.html225
-rw-r--r--tiff/html/man/TIFFRGBAImage.3tiff.html319
-rw-r--r--tiff/html/man/TIFFReadDirectory.3tiff.html218
-rw-r--r--tiff/html/man/TIFFReadEncodedStrip.3tiff.html133
-rw-r--r--tiff/html/man/TIFFReadEncodedTile.3tiff.html130
-rw-r--r--tiff/html/man/TIFFReadRGBAImage.3tiff.html301
-rw-r--r--tiff/html/man/TIFFReadRGBAStrip.3tiff.html208
-rw-r--r--tiff/html/man/TIFFReadRGBATile.3tiff.html261
-rw-r--r--tiff/html/man/TIFFReadRawStrip.3tiff.html109
-rw-r--r--tiff/html/man/TIFFReadRawTile.3tiff.html111
-rw-r--r--tiff/html/man/TIFFReadScanline.3tiff.html157
-rw-r--r--tiff/html/man/TIFFReadTile.3tiff.html133
-rw-r--r--tiff/html/man/TIFFSetDirectory.3tiff.html122
-rw-r--r--tiff/html/man/TIFFSetField.3tiff.html1362
-rw-r--r--tiff/html/man/TIFFWarning.3tiff.html108
-rw-r--r--tiff/html/man/TIFFWriteDirectory.3tiff.html176
-rw-r--r--tiff/html/man/TIFFWriteEncodedStrip.3tiff.html153
-rw-r--r--tiff/html/man/TIFFWriteEncodedTile.3tiff.html147
-rw-r--r--tiff/html/man/TIFFWriteRawStrip.3tiff.html144
-rw-r--r--tiff/html/man/TIFFWriteRawTile.3tiff.html128
-rw-r--r--tiff/html/man/TIFFWriteScanline.3tiff.html206
-rw-r--r--tiff/html/man/TIFFWriteTile.3tiff.html115
-rw-r--r--tiff/html/man/TIFFbuffer.3tiff.html116
-rw-r--r--tiff/html/man/TIFFcodec.3tiff.html116
-rw-r--r--tiff/html/man/TIFFcolor.3tiff.html975
-rw-r--r--tiff/html/man/TIFFmemory.3tiff.html110
-rw-r--r--tiff/html/man/TIFFquery.3tiff.html148
-rw-r--r--tiff/html/man/TIFFsize.3tiff.html95
-rw-r--r--tiff/html/man/TIFFstrip.3tiff.html129
-rw-r--r--tiff/html/man/TIFFswab.3tiff.html110
-rw-r--r--tiff/html/man/TIFFtile.3tiff.html141
-rw-r--r--tiff/html/man/fax2ps.1.html252
-rw-r--r--tiff/html/man/fax2tiff.1.html607
-rw-r--r--tiff/html/man/gif2tiff.1.html141
-rw-r--r--tiff/html/man/index.html64
-rw-r--r--tiff/html/man/libtiff.3tiff.html3137
-rw-r--r--tiff/html/man/pal2rgb.1.html189
-rw-r--r--tiff/html/man/ppm2tiff.1.html141
-rw-r--r--tiff/html/man/ras2tiff.1.html139
-rw-r--r--tiff/html/man/raw2tiff.1.html510
-rw-r--r--tiff/html/man/rgb2ycbcr.1.html155
-rw-r--r--tiff/html/man/sgi2tiff.1.html147
-rw-r--r--tiff/html/man/thumbnail.1.html148
-rw-r--r--tiff/html/man/tiff2bw.1.html161
-rw-r--r--tiff/html/man/tiff2pdf.1.html609
-rw-r--r--tiff/html/man/tiff2ps.1.html532
-rw-r--r--tiff/html/man/tiff2rgba.1.html162
-rw-r--r--tiff/html/man/tiffcmp.1.html156
-rw-r--r--tiff/html/man/tiffcp.1.html536
-rw-r--r--tiff/html/man/tiffcrop.1.html851
-rw-r--r--tiff/html/man/tiffdither.1.html183
-rw-r--r--tiff/html/man/tiffdump.1.html145
-rw-r--r--tiff/html/man/tiffgt.1.html551
-rw-r--r--tiff/html/man/tiffinfo.1.html196
-rw-r--r--tiff/html/man/tiffmedian.1.html183
-rw-r--r--tiff/html/man/tiffset.1.html176
-rw-r--r--tiff/html/man/tiffsplit.1.html102
-rw-r--r--tiff/html/man/tiffsv.1.html207
-rw-r--r--tiff/html/misc.html116
-rw-r--r--tiff/html/support.html655
-rw-r--r--tiff/html/tools.html164
-rw-r--r--tiff/html/v3.4beta007.html112
-rw-r--r--tiff/html/v3.4beta016.html122
-rw-r--r--tiff/html/v3.4beta018.html84
-rw-r--r--tiff/html/v3.4beta024.html139
-rw-r--r--tiff/html/v3.4beta028.html146
-rw-r--r--tiff/html/v3.4beta029.html86
-rw-r--r--tiff/html/v3.4beta031.html94
-rw-r--r--tiff/html/v3.4beta032.html90
-rw-r--r--tiff/html/v3.4beta033.html82
-rw-r--r--tiff/html/v3.4beta034.html68
-rw-r--r--tiff/html/v3.4beta035.html63
-rw-r--r--tiff/html/v3.4beta036.html117
-rw-r--r--tiff/html/v3.5.1.html75
-rw-r--r--tiff/html/v3.5.2.html108
-rw-r--r--tiff/html/v3.5.3.html132
-rw-r--r--tiff/html/v3.5.4.html88
-rw-r--r--tiff/html/v3.5.5.html155
-rw-r--r--tiff/html/v3.5.6-beta.html185
-rw-r--r--tiff/html/v3.5.7.html259
-rw-r--r--tiff/html/v3.6.0.html434
-rw-r--r--tiff/html/v3.6.1.html199
-rw-r--r--tiff/html/v3.7.0.html144
-rw-r--r--tiff/html/v3.7.0alpha.html249
-rw-r--r--tiff/html/v3.7.0beta.html162
-rw-r--r--tiff/html/v3.7.0beta2.html131
-rw-r--r--tiff/html/v3.7.1.html233
-rw-r--r--tiff/html/v3.7.2.html222
-rw-r--r--tiff/html/v3.7.3.html230
-rw-r--r--tiff/html/v3.7.4.html133
-rw-r--r--tiff/html/v3.8.0.html199
-rw-r--r--tiff/html/v3.8.1.html217
-rw-r--r--tiff/html/v3.8.2.html137
-rw-r--r--tiff/html/v3.9.0beta.html304
-rw-r--r--tiff/html/v3.9.1.html115
-rw-r--r--tiff/html/v3.9.2.html122
-rw-r--r--tiff/libtiff/Makefile.am143
-rw-r--r--tiff/libtiff/Makefile.in887
-rw-r--r--tiff/libtiff/Makefile.vc102
-rw-r--r--tiff/libtiff/SConstruct73
-rw-r--r--tiff/libtiff/libtiff.def140
-rw-r--r--tiff/libtiff/mkg3states.c451
-rw-r--r--tiff/libtiff/t4.h292
-rw-r--r--tiff/libtiff/tif_acorn.c526
-rw-r--r--tiff/libtiff/tif_apple.c281
-rw-r--r--tiff/libtiff/tif_atari.c250
-rw-r--r--tiff/libtiff/tif_aux.c290
-rw-r--r--tiff/libtiff/tif_close.c126
-rw-r--r--tiff/libtiff/tif_codec.c160
-rw-r--r--tiff/libtiff/tif_color.c282
-rw-r--r--tiff/libtiff/tif_compress.c295
-rw-r--r--tiff/libtiff/tif_config.h-vms46
-rw-r--r--tiff/libtiff/tif_config.h.in309
-rw-r--r--tiff/libtiff/tif_config.vc.h63
-rw-r--r--tiff/libtiff/tif_config.wince.h74
-rw-r--r--tiff/libtiff/tif_dir.c1389
-rw-r--r--tiff/libtiff/tif_dir.h211
-rw-r--r--tiff/libtiff/tif_dirinfo.c888
-rw-r--r--tiff/libtiff/tif_dirread.c2081
-rw-r--r--tiff/libtiff/tif_dirwrite.c1414
-rw-r--r--tiff/libtiff/tif_dumpmode.c126
-rw-r--r--tiff/libtiff/tif_error.c80
-rw-r--r--tiff/libtiff/tif_extension.c118
-rw-r--r--tiff/libtiff/tif_fax3.c1626
-rw-r--r--tiff/libtiff/tif_fax3.h532
-rw-r--r--tiff/libtiff/tif_fax3sm.c1253
-rw-r--r--tiff/libtiff/tif_flush.c74
-rw-r--r--tiff/libtiff/tif_getimage.c2676
-rw-r--r--tiff/libtiff/tif_jbig.c385
-rw-r--r--tiff/libtiff/tif_jpeg.c2065
-rw-r--r--tiff/libtiff/tif_luv.c1629
-rw-r--r--tiff/libtiff/tif_lzw.c1129
-rw-r--r--tiff/libtiff/tif_msdos.c193
-rw-r--r--tiff/libtiff/tif_next.c154
-rw-r--r--tiff/libtiff/tif_ojpeg.c2438
-rw-r--r--tiff/libtiff/tif_open.c695
-rw-r--r--tiff/libtiff/tif_packbits.c300
-rw-r--r--tiff/libtiff/tif_pixarlog.c1371
-rw-r--r--tiff/libtiff/tif_predict.c736
-rw-r--r--tiff/libtiff/tif_predict.h77
-rw-r--r--tiff/libtiff/tif_print.c646
-rw-r--r--tiff/libtiff/tif_read.c750
-rw-r--r--tiff/libtiff/tif_stream.cxx295
-rw-r--r--tiff/libtiff/tif_strip.c370
-rw-r--r--tiff/libtiff/tif_swab.c242
-rw-r--r--tiff/libtiff/tif_thunder.c165
-rw-r--r--tiff/libtiff/tif_tile.c280
-rw-r--r--tiff/libtiff/tif_unix.c300
-rw-r--r--tiff/libtiff/tif_version.c40
-rw-r--r--tiff/libtiff/tif_warning.c81
-rw-r--r--tiff/libtiff/tif_win3.c232
-rw-r--r--tiff/libtiff/tif_win32.c408
-rw-r--r--tiff/libtiff/tif_write.c718
-rw-r--r--tiff/libtiff/tif_zip.c419
-rw-r--r--tiff/libtiff/tiff.h654
-rw-r--r--tiff/libtiff/tiffconf.h.in103
-rw-r--r--tiff/libtiff/tiffconf.vc.h116
-rw-r--r--tiff/libtiff/tiffconf.wince.h136
-rw-r--r--tiff/libtiff/tiffio.h526
-rw-r--r--tiff/libtiff/tiffio.hxx49
-rw-r--r--tiff/libtiff/tiffiop.h350
-rw-r--r--tiff/libtiff/tiffvers.h9
-rw-r--r--tiff/libtiff/uvcode.h180
-rw-r--r--tiff/m4/acinclude.m4669
-rw-r--r--tiff/m4/libtool.m47437
-rw-r--r--tiff/m4/ltoptions.m4369
-rw-r--r--tiff/m4/ltsugar.m4123
-rw-r--r--tiff/m4/ltversion.m423
-rw-r--r--tiff/m4/lt~obsolete.m498
-rw-r--r--tiff/man/Makefile.am92
-rw-r--r--tiff/man/Makefile.in602
-rw-r--r--tiff/man/TIFFClose.3tiff53
-rw-r--r--tiff/man/TIFFDataWidth.3tiff74
-rw-r--r--tiff/man/TIFFError.3tiff69
-rw-r--r--tiff/man/TIFFFlush.3tiff64
-rw-r--r--tiff/man/TIFFGetField.3tiff232
-rw-r--r--tiff/man/TIFFOpen.3tiff279
-rw-r--r--tiff/man/TIFFPrintDirectory.3tiff70
-rw-r--r--tiff/man/TIFFRGBAImage.3tiff286
-rw-r--r--tiff/man/TIFFReadDirectory.3tiff164
-rw-r--r--tiff/man/TIFFReadEncodedStrip.3tiff78
-rw-r--r--tiff/man/TIFFReadEncodedTile.3tiff76
-rw-r--r--tiff/man/TIFFReadRGBAImage.3tiff218
-rw-r--r--tiff/man/TIFFReadRGBAStrip.3tiff170
-rw-r--r--tiff/man/TIFFReadRGBATile.3tiff171
-rw-r--r--tiff/man/TIFFReadRawStrip.3tiff64
-rw-r--r--tiff/man/TIFFReadRawTile.3tiff65
-rw-r--r--tiff/man/TIFFReadScanline.3tiff94
-rw-r--r--tiff/man/TIFFReadTile.3tiff84
-rw-r--r--tiff/man/TIFFSetDirectory.3tiff79
-rw-r--r--tiff/man/TIFFSetField.3tiff217
-rw-r--r--tiff/man/TIFFWarning.3tiff70
-rw-r--r--tiff/man/TIFFWriteDirectory.3tiff138
-rw-r--r--tiff/man/TIFFWriteEncodedStrip.3tiff102
-rw-r--r--tiff/man/TIFFWriteEncodedTile.3tiff96
-rw-r--r--tiff/man/TIFFWriteRawStrip.3tiff96
-rw-r--r--tiff/man/TIFFWriteRawTile.3tiff84
-rw-r--r--tiff/man/TIFFWriteScanline.3tiff154
-rw-r--r--tiff/man/TIFFWriteTile.3tiff77
-rw-r--r--tiff/man/TIFFbuffer.3tiff77
-rw-r--r--tiff/man/TIFFcodec.3tiff82
-rw-r--r--tiff/man/TIFFcolor.3tiff268
-rw-r--r--tiff/man/TIFFmemory.3tiff90
-rw-r--r--tiff/man/TIFFquery.3tiff142
-rw-r--r--tiff/man/TIFFsize.3tiff59
-rw-r--r--tiff/man/TIFFstrip.3tiff99
-rw-r--r--tiff/man/TIFFswab.3tiff80
-rw-r--r--tiff/man/TIFFtile.3tiff131
-rw-r--r--tiff/man/bmp2tiff.185
-rw-r--r--tiff/man/fax2ps.1159
-rw-r--r--tiff/man/fax2tiff.1286
-rw-r--r--tiff/man/gif2tiff.181
-rw-r--r--tiff/man/libtiff.3tiff536
-rw-r--r--tiff/man/pal2rgb.1111
-rw-r--r--tiff/man/ppm2tiff.1105
-rw-r--r--tiff/man/ras2tiff.196
-rw-r--r--tiff/man/raw2tiff.1196
-rw-r--r--tiff/man/rgb2ycbcr.199
-rw-r--r--tiff/man/sgi2tiff.193
-rw-r--r--tiff/man/thumbnail.190
-rw-r--r--tiff/man/tiff2bw.194
-rw-r--r--tiff/man/tiff2pdf.1251
-rw-r--r--tiff/man/tiff2ps.1268
-rw-r--r--tiff/man/tiff2rgba.197
-rw-r--r--tiff/man/tiffcmp.187
-rw-r--r--tiff/man/tiffcp.1291
-rw-r--r--tiff/man/tiffcrop.1571
-rw-r--r--tiff/man/tiffdither.1132
-rw-r--r--tiff/man/tiffdump.181
-rw-r--r--tiff/man/tiffgt.1245
-rw-r--r--tiff/man/tiffinfo.188
-rw-r--r--tiff/man/tiffmedian.1112
-rw-r--r--tiff/man/tiffset.182
-rw-r--r--tiff/man/tiffsplit.169
-rw-r--r--tiff/man/tiffsv.1142
-rw-r--r--tiff/nmake.opt218
-rw-r--r--tiff/port/Makefile.am31
-rw-r--r--tiff/port/Makefile.in555
-rw-r--r--tiff/port/Makefile.vc43
-rw-r--r--tiff/port/dummy.c19
-rw-r--r--tiff/port/getopt.c131
-rw-r--r--tiff/port/lfind.c69
-rw-r--r--tiff/port/libport.h58
-rw-r--r--tiff/port/strcasecmp.c57
-rw-r--r--tiff/port/strtoul.c116
-rw-r--r--tiff/test/Makefile.am46
-rw-r--r--tiff/test/Makefile.in845
-rw-r--r--tiff/test/ascii_tag.c177
-rw-r--r--tiff/test/check_tag.c79
-rw-r--r--tiff/test/long_tag.c161
-rw-r--r--tiff/test/short_tag.c187
-rw-r--r--tiff/test/strip.c298
-rw-r--r--tiff/test/strip_rw.c162
-rw-r--r--tiff/test/test_arrays.c836
-rw-r--r--tiff/test/test_arrays.h70
-rw-r--r--tiff/tools/Jamfile20
-rw-r--r--tiff/tools/Makefile.am145
-rw-r--r--tiff/tools/Makefile.in876
-rw-r--r--tiff/tools/Makefile.vc51
-rw-r--r--tiff/tools/bmp2tiff.c850
-rw-r--r--tiff/tools/fax2ps.c446
-rw-r--r--tiff/tools/fax2tiff.c465
-rw-r--r--tiff/tools/gif2tiff.c522
-rw-r--r--tiff/tools/pal2rgb.c431
-rw-r--r--tiff/tools/ppm2tiff.c362
-rw-r--r--tiff/tools/ras2tiff.c306
-rw-r--r--tiff/tools/rasterfile.h49
-rw-r--r--tiff/tools/raw2tiff.c647
-rw-r--r--tiff/tools/rgb2ycbcr.c382
-rw-r--r--tiff/tools/sgi2tiff.c335
-rw-r--r--tiff/tools/sgisv.c316
-rw-r--r--tiff/tools/thumbnail.c639
-rw-r--r--tiff/tools/tiff2bw.c467
-rw-r--r--tiff/tools/tiff2pdf.c5405
-rw-r--r--tiff/tools/tiff2ps.c2370
-rw-r--r--tiff/tools/tiff2rgba.c548
-rw-r--r--tiff/tools/tiffcmp.c640
-rw-r--r--tiff/tools/tiffcp.c1770
-rw-r--r--tiff/tools/tiffcrop.c9012
-rw-r--r--tiff/tools/tiffdither.c332
-rw-r--r--tiff/tools/tiffdump.c785
-rw-r--r--tiff/tools/tiffgt.c462
-rw-r--r--tiff/tools/tiffinfo.c456
-rw-r--r--tiff/tools/tiffmedian.c902
-rw-r--r--tiff/tools/tiffset.c325
-rw-r--r--tiff/tools/tiffsplit.c297
-rw-r--r--tiff/tools/ycbcr.c168
-rw-r--r--ttbd.txt327
-rw-r--r--tweak/Jamfile26
-rw-r--r--tweak/License.txt662
-rw-r--r--tweak/Makefile.am11
-rw-r--r--tweak/Readme.txt5
-rw-r--r--tweak/afiles5
-rw-r--r--tweak/refine.c1269
-rw-r--r--ucmm/Jamfile26
-rw-r--r--ucmm/Makefile.am9
-rw-r--r--ucmm/afiles4
-rw-r--r--ucmm/ucmm.c1086
-rw-r--r--ucmm/ucmm.h98
-rw-r--r--usb/45-Argyll.rules62
-rw-r--r--usb/55-Argyll.rules90
-rw-r--r--usb/Argyll9
-rw-r--r--usb/Argyll.kext/Info.plist30
-rw-r--r--usb/Argyll.usermap53
-rw-r--r--usb/ArgyllCMS.cat3
-rw-r--r--usb/ArgyllCMS.inf213
-rw-r--r--usb/ArgyllCMS.inf.d34
-rw-r--r--usb/ArgyllCMS.inf.t111
-rw-r--r--usb/ArgyllCMS_x64.cat3
-rw-r--r--usb/Jamfile52
-rw-r--r--usb/Readme.txt8
-rw-r--r--usb/afiles60
-rw-r--r--usb/bin/amd64/libusb0.sysbin0 -> 52832 bytes
-rw-r--r--usb/bin/ia64/libusb0.sysbin0 -> 110176 bytes
-rw-r--r--usb/bin/libusb-win32-bin-README.txt27
-rw-r--r--usb/bin/x86/libusb0.sysbin0 -> 42592 bytes
-rw-r--r--usb/binfiles.lx4
-rw-r--r--usb/binfiles.msw6
-rw-r--r--usb/binfiles.osx2
-rw-r--r--usb/driver/AUTHORS.txt16
-rw-r--r--usb/driver/COPYING_GPL.txt674
-rw-r--r--usb/driver/LICENSE.txt9
-rw-r--r--usb/driver/Makefile261
-rw-r--r--usb/driver/README.txt12
-rw-r--r--usb/driver/abort_endpoint.c56
-rw-r--r--usb/driver/claim_interface.c89
-rw-r--r--usb/driver/clear_feature.c64
-rw-r--r--usb/driver/dispatch.c99
-rw-r--r--usb/driver/driver_api.h400
-rw-r--r--usb/driver/driver_debug.c75
-rw-r--r--usb/driver/driver_debug.h30
-rw-r--r--usb/driver/driver_registry.c376
-rw-r--r--usb/driver/get_configuration.c56
-rw-r--r--usb/driver/get_descriptor.c289
-rw-r--r--usb/driver/get_interface.c109
-rw-r--r--usb/driver/get_status.c74
-rw-r--r--usb/driver/ioctl.c795
-rw-r--r--usb/driver/libusb-win32-README-1.2.6.0.txt239
-rw-r--r--usb/driver/libusb_driver.c971
-rw-r--r--usb/driver/libusb_driver.h429
-rw-r--r--usb/driver/libusb_driver_rc.rc25
-rw-r--r--usb/driver/lusb_defdi_guids.h45
-rw-r--r--usb/driver/pnp.c302
-rw-r--r--usb/driver/power.c269
-rw-r--r--usb/driver/release_interface.c105
-rw-r--r--usb/driver/reset_device.c56
-rw-r--r--usb/driver/reset_endpoint.c56
-rw-r--r--usb/driver/set_configuration.c205
-rw-r--r--usb/driver/set_descriptor.c71
-rw-r--r--usb/driver/set_feature.c67
-rw-r--r--usb/driver/set_interface.c124
-rw-r--r--usb/driver/transfer.c1493
-rw-r--r--usb/driver/usbd.def35
-rw-r--r--usb/driver/usbdlib_gcc.h310
-rw-r--r--usb/driver/vendor_request.c143
-rw-r--r--usb/install_kext.sh6
-rw-r--r--xicc/Jamfile172
-rw-r--r--xicc/License.txt662
-rw-r--r--xicc/Makefile.am28
-rw-r--r--xicc/Readme.txt15
-rw-r--r--xicc/afiles68
-rw-r--r--xicc/cam02.c1279
-rw-r--r--xicc/cam02.h208
-rw-r--r--xicc/cam02plot.c845
-rw-r--r--xicc/cam02ref.h621
-rw-r--r--xicc/cam02test.c1325
-rw-r--r--xicc/cam97s3.c596
-rw-r--r--xicc/cam97s3.h169
-rw-r--r--xicc/cam97test.c456
-rw-r--r--xicc/ccmx.c766
-rw-r--r--xicc/ccmx.h120
-rw-r--r--xicc/ccss.c636
-rw-r--r--xicc/ccss.h112
-rw-r--r--xicc/ccttest.c306
-rw-r--r--xicc/cgatsplot.c248
-rw-r--r--xicc/cv.c136
-rw-r--r--xicc/cvtest.c411
-rw-r--r--xicc/example.sp130
-rw-r--r--xicc/extracticc.c219
-rw-r--r--xicc/extractttag.c203
-rw-r--r--xicc/fakeCMY.c493
-rw-r--r--xicc/fbview.c312
-rw-r--r--xicc/iccgamut.c811
-rw-r--r--xicc/iccjpeg.c271
-rw-r--r--xicc/iccjpeg.h73
-rw-r--r--xicc/icheck.c532
-rw-r--r--xicc/monctest.c278
-rw-r--r--xicc/moncurve.c668
-rw-r--r--xicc/moncurve.h121
-rw-r--r--xicc/mpp.c4446
-rw-r--r--xicc/mpp.h268
-rw-r--r--xicc/mpplu.c1355
-rw-r--r--xicc/revfix.c796
-rw-r--r--xicc/specplot.c370
-rw-r--r--xicc/specsubsamp.c232
-rw-r--r--xicc/spectest.c750
-rw-r--r--xicc/spectest2.c270
-rw-r--r--xicc/tiffgamut.c1300
-rw-r--r--xicc/tiffgmts.c1187
-rw-r--r--xicc/transplot.c279
-rw-r--r--xicc/xcal.c496
-rw-r--r--xicc/xcal.h78
-rw-r--r--xicc/xcam.c214
-rw-r--r--xicc/xcam.h82
-rw-r--r--xicc/xcolorants.c768
-rw-r--r--xicc/xcolorants.h326
-rw-r--r--xicc/xcolorantslu.c228
-rw-r--r--xicc/xdevlin.c299
-rw-r--r--xicc/xdevlin.h96
-rw-r--r--xicc/xdgb.c109
-rw-r--r--xicc/xdgb.h71
-rw-r--r--xicc/xfbview.c703
-rw-r--r--xicc/xfit.c2829
-rw-r--r--xicc/xfit.h239
-rw-r--r--xicc/xicc.c3607
-rw-r--r--xicc/xicc.h945
-rw-r--r--xicc/xicclu.c1149
-rw-r--r--xicc/xlut.c4271
-rw-r--r--xicc/xlutfix.c1306
-rw-r--r--xicc/xmatrix.c2022
-rw-r--r--xicc/xmono.c324
-rw-r--r--xicc/xspect.c4714
-rw-r--r--xicc/xspect.h430
-rw-r--r--xicc/xutils.c294
-rw-r--r--xicc/xutils.h69
-rw-r--r--ziparch.sh96
1695 files changed, 795790 insertions, 0 deletions
diff --git a/.pc/.quilt_patches b/.pc/.quilt_patches
new file mode 100644
index 0000000..6857a8d
--- /dev/null
+++ b/.pc/.quilt_patches
@@ -0,0 +1 @@
+debian/patches
diff --git a/.pc/.quilt_series b/.pc/.quilt_series
new file mode 100644
index 0000000..c206706
--- /dev/null
+++ b/.pc/.quilt_series
@@ -0,0 +1 @@
+series
diff --git a/.pc/.version b/.pc/.version
new file mode 100644
index 0000000..0cfbf08
--- /dev/null
+++ b/.pc/.version
@@ -0,0 +1 @@
+2
diff --git a/.pc/01_autotools-support.diff/Makefile.am b/.pc/01_autotools-support.diff/Makefile.am
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/Makefile.am
diff --git a/.pc/01_autotools-support.diff/Makefile.shared b/.pc/01_autotools-support.diff/Makefile.shared
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/Makefile.shared
diff --git a/.pc/01_autotools-support.diff/aclocal.m4 b/.pc/01_autotools-support.diff/aclocal.m4
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/aclocal.m4
diff --git a/.pc/01_autotools-support.diff/cgats/Makefile.am b/.pc/01_autotools-support.diff/cgats/Makefile.am
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/cgats/Makefile.am
diff --git a/.pc/01_autotools-support.diff/config.guess b/.pc/01_autotools-support.diff/config.guess
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/config.guess
diff --git a/.pc/01_autotools-support.diff/config.h.in b/.pc/01_autotools-support.diff/config.h.in
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/config.h.in
diff --git a/.pc/01_autotools-support.diff/config.sub b/.pc/01_autotools-support.diff/config.sub
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/config.sub
diff --git a/.pc/01_autotools-support.diff/configure b/.pc/01_autotools-support.diff/configure
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/configure
diff --git a/.pc/01_autotools-support.diff/configure.ac b/.pc/01_autotools-support.diff/configure.ac
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/configure.ac
diff --git a/.pc/01_autotools-support.diff/depcomp b/.pc/01_autotools-support.diff/depcomp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/depcomp
diff --git a/.pc/01_autotools-support.diff/doc/Makefile.am b/.pc/01_autotools-support.diff/doc/Makefile.am
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/doc/Makefile.am
diff --git a/.pc/01_autotools-support.diff/gamut/Makefile.am b/.pc/01_autotools-support.diff/gamut/Makefile.am
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/gamut/Makefile.am
diff --git a/.pc/01_autotools-support.diff/h/Makefile.am b/.pc/01_autotools-support.diff/h/Makefile.am
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/h/Makefile.am
diff --git a/.pc/01_autotools-support.diff/icc/Makefile.am b/.pc/01_autotools-support.diff/icc/Makefile.am
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/icc/Makefile.am
diff --git a/.pc/01_autotools-support.diff/imdi/Makefile.am b/.pc/01_autotools-support.diff/imdi/Makefile.am
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/imdi/Makefile.am
diff --git a/.pc/01_autotools-support.diff/imdi/imdi_k.h b/.pc/01_autotools-support.diff/imdi/imdi_k.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/imdi/imdi_k.h
diff --git a/.pc/01_autotools-support.diff/install-sh b/.pc/01_autotools-support.diff/install-sh
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/install-sh
diff --git a/.pc/01_autotools-support.diff/jcnf/Makefile.am b/.pc/01_autotools-support.diff/jcnf/Makefile.am
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/jcnf/Makefile.am
diff --git a/.pc/01_autotools-support.diff/jcnf/yajl/Makefile.am b/.pc/01_autotools-support.diff/jcnf/yajl/Makefile.am
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/jcnf/yajl/Makefile.am
diff --git a/.pc/01_autotools-support.diff/link/Makefile.am b/.pc/01_autotools-support.diff/link/Makefile.am
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/link/Makefile.am
diff --git a/.pc/01_autotools-support.diff/m4/libtool.m4 b/.pc/01_autotools-support.diff/m4/libtool.m4
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/m4/libtool.m4
diff --git a/.pc/01_autotools-support.diff/m4/ltoptions.m4 b/.pc/01_autotools-support.diff/m4/ltoptions.m4
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/m4/ltoptions.m4
diff --git a/.pc/01_autotools-support.diff/m4/ltsugar.m4 b/.pc/01_autotools-support.diff/m4/ltsugar.m4
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/m4/ltsugar.m4
diff --git a/.pc/01_autotools-support.diff/m4/ltversion.m4 b/.pc/01_autotools-support.diff/m4/ltversion.m4
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/m4/ltversion.m4
diff --git a/.pc/01_autotools-support.diff/m4/lt~obsolete.m4 b/.pc/01_autotools-support.diff/m4/lt~obsolete.m4
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/m4/lt~obsolete.m4
diff --git a/.pc/01_autotools-support.diff/missing b/.pc/01_autotools-support.diff/missing
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/missing
diff --git a/.pc/01_autotools-support.diff/numlib/Makefile.am b/.pc/01_autotools-support.diff/numlib/Makefile.am
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/numlib/Makefile.am
diff --git a/.pc/01_autotools-support.diff/plot/Makefile.am b/.pc/01_autotools-support.diff/plot/Makefile.am
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/plot/Makefile.am
diff --git a/.pc/01_autotools-support.diff/profile/Makefile.am b/.pc/01_autotools-support.diff/profile/Makefile.am
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/profile/Makefile.am
diff --git a/.pc/01_autotools-support.diff/ref/Makefile.am b/.pc/01_autotools-support.diff/ref/Makefile.am
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/ref/Makefile.am
diff --git a/.pc/01_autotools-support.diff/render/Makefile.am b/.pc/01_autotools-support.diff/render/Makefile.am
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/render/Makefile.am
diff --git a/.pc/01_autotools-support.diff/rspl/Makefile.am b/.pc/01_autotools-support.diff/rspl/Makefile.am
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/rspl/Makefile.am
diff --git a/.pc/01_autotools-support.diff/scanin/Makefile.am b/.pc/01_autotools-support.diff/scanin/Makefile.am
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/scanin/Makefile.am
diff --git a/.pc/01_autotools-support.diff/spectro/Makefile.am b/.pc/01_autotools-support.diff/spectro/Makefile.am
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/spectro/Makefile.am
diff --git a/.pc/01_autotools-support.diff/target/Makefile.am b/.pc/01_autotools-support.diff/target/Makefile.am
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/target/Makefile.am
diff --git a/.pc/01_autotools-support.diff/tweak/Makefile.am b/.pc/01_autotools-support.diff/tweak/Makefile.am
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/tweak/Makefile.am
diff --git a/.pc/01_autotools-support.diff/ucmm/Makefile.am b/.pc/01_autotools-support.diff/ucmm/Makefile.am
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/ucmm/Makefile.am
diff --git a/.pc/01_autotools-support.diff/xicc/Makefile.am b/.pc/01_autotools-support.diff/xicc/Makefile.am
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/01_autotools-support.diff/xicc/Makefile.am
diff --git a/.pc/02_firmware-package-builder.diff/firmware-package-builder/argyll-firmware-spyder2/debian/changelog b/.pc/02_firmware-package-builder.diff/firmware-package-builder/argyll-firmware-spyder2/debian/changelog
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/02_firmware-package-builder.diff/firmware-package-builder/argyll-firmware-spyder2/debian/changelog
diff --git a/.pc/02_firmware-package-builder.diff/firmware-package-builder/argyll-firmware-spyder2/debian/compat b/.pc/02_firmware-package-builder.diff/firmware-package-builder/argyll-firmware-spyder2/debian/compat
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/02_firmware-package-builder.diff/firmware-package-builder/argyll-firmware-spyder2/debian/compat
diff --git a/.pc/02_firmware-package-builder.diff/firmware-package-builder/argyll-firmware-spyder2/debian/control b/.pc/02_firmware-package-builder.diff/firmware-package-builder/argyll-firmware-spyder2/debian/control
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/02_firmware-package-builder.diff/firmware-package-builder/argyll-firmware-spyder2/debian/control
diff --git a/.pc/02_firmware-package-builder.diff/firmware-package-builder/argyll-firmware-spyder2/debian/copyright b/.pc/02_firmware-package-builder.diff/firmware-package-builder/argyll-firmware-spyder2/debian/copyright
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/02_firmware-package-builder.diff/firmware-package-builder/argyll-firmware-spyder2/debian/copyright
diff --git a/.pc/02_firmware-package-builder.diff/firmware-package-builder/argyll-firmware-spyder2/debian/install b/.pc/02_firmware-package-builder.diff/firmware-package-builder/argyll-firmware-spyder2/debian/install
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/02_firmware-package-builder.diff/firmware-package-builder/argyll-firmware-spyder2/debian/install
diff --git a/.pc/02_firmware-package-builder.diff/firmware-package-builder/argyll-firmware-spyder2/debian/rules b/.pc/02_firmware-package-builder.diff/firmware-package-builder/argyll-firmware-spyder2/debian/rules
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pc/02_firmware-package-builder.diff/firmware-package-builder/argyll-firmware-spyder2/debian/rules
diff --git a/.pc/03_usb-db.diff/usb/55-Argyll.rules b/.pc/03_usb-db.diff/usb/55-Argyll.rules
new file mode 100644
index 0000000..3da9c69
--- /dev/null
+++ b/.pc/03_usb-db.diff/usb/55-Argyll.rules
@@ -0,0 +1,90 @@
+# udev rule to recognize instruments and make them accessible to user applications.
+# Copy this to /etc/udev/rules.d/55-Argyll.rules
+
+# Skip all this to speed things up if it'a not a usb add.
+ACTION!="add", GOTO="argyll_rules_end"
+SUBSYSTEM!="usb", GOTO="argyll_rules_end"
+
+# Recognize the color measurement devices
+
+# Colorimtre HCFR
+ATTRS{idVendor}=="04db", ATTRS{idProduct}=="005b", ENV{COLOR_MEASUREMENT_DEVICE}="1"
+
+
+# MonacoOPTIX (Same as i1 Display 1)
+ATTRS{idVendor}=="0670", ATTRS{idProduct}=="0001", ENV{COLOR_MEASUREMENT_DEVICE}="1"
+
+
+# HueyL (not tested)
+ATTRS{idVendor}=="0765", ATTRS{idProduct}=="5001", ENV{COLOR_MEASUREMENT_DEVICE}="1"
+
+# HueyL (not tested)
+ATTRS{idVendor}=="0765", ATTRS{idProduct}=="5010", ENV{COLOR_MEASUREMENT_DEVICE}="1"
+
+# i1Display 3
+ATTRS{idVendor}=="0765", ATTRS{idProduct}=="5020", ENV{COLOR_MEASUREMENT_DEVICE}="1"
+
+# ColorMunki Smile
+ATTRS{idVendor}=="0765", ATTRS{idProduct}=="6003", ENV{COLOR_MEASUREMENT_DEVICE}="1"
+
+# DTP20
+ATTRS{idVendor}=="0765", ATTRS{idProduct}=="d020", ENV{COLOR_MEASUREMENT_DEVICE}="1"
+
+# DTP92Q (not tested)
+ATTRS{idVendor}=="0765", ATTRS{idProduct}=="d092", ENV{COLOR_MEASUREMENT_DEVICE}="1"
+
+# DTP94
+ATTRS{idVendor}=="0765", ATTRS{idProduct}=="d094", ENV{COLOR_MEASUREMENT_DEVICE}="1"
+
+
+# i1Pro
+ATTRS{idVendor}=="0971", ATTRS{idProduct}=="2000", ENV{COLOR_MEASUREMENT_DEVICE}="1"
+
+# i1Monitor
+ATTRS{idVendor}=="0971", ATTRS{idProduct}=="2001", ENV{COLOR_MEASUREMENT_DEVICE}="1"
+
+# i1Display
+ATTRS{idVendor}=="0971", ATTRS{idProduct}=="2003", ENV{COLOR_MEASUREMENT_DEVICE}="1"
+
+# i1 io table (not tested)
+ATTRS{idVendor}=="0971", ATTRS{idProduct}=="2004", ENV{COLOR_MEASUREMENT_DEVICE}="1"
+
+# Huey
+ATTRS{idVendor}=="0971", ATTRS{idProduct}=="2005", ENV{COLOR_MEASUREMENT_DEVICE}="1"
+
+# i1 iSis (not tested)
+ATTRS{idVendor}=="0971", ATTRS{idProduct}=="2006", ENV{COLOR_MEASUREMENT_DEVICE}="1"
+
+# ColorMunki
+ATTRS{idVendor}=="0971", ATTRS{idProduct}=="2007", ENV{COLOR_MEASUREMENT_DEVICE}="1"
+
+
+# Spyder 1
+ATTRS{idVendor}=="085c", ATTRS{idProduct}=="0100", ENV{COLOR_MEASUREMENT_DEVICE}="1"
+
+# Spyder 2
+ATTRS{idVendor}=="085c", ATTRS{idProduct}=="0200", ENV{COLOR_MEASUREMENT_DEVICE}="1"
+
+# Spyder 3
+ATTRS{idVendor}=="085c", ATTRS{idProduct}=="0300", ENV{COLOR_MEASUREMENT_DEVICE}="1"
+
+# Spyder 4
+ATTRS{idVendor}=="085c", ATTRS{idProduct}=="0400", ENV{COLOR_MEASUREMENT_DEVICE}="1"
+
+
+# ColorHug, old and new
+ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="f8da", ENV{COLOR_MEASUREMENT_DEVICE}="1"
+ATTRS{idVendor}=="273f", ATTRS{idProduct}=="1001", ENV{COLOR_MEASUREMENT_DEVICE}="1"
+
+
+# Let udev-acl manage these devices, if it's available
+TEST=="/var/run/ConsoleKit/database", ENV{COLOR_MEASUREMENT_DEVICE}=="*?", ENV{ACL_MANAGE}="1"
+
+# Otherwise, restrict access to members of the plugdev group,
+# which the user may have to add to the system.
+ENV{COLOR_MEASUREMENT_DEVICE}=="*?", ENV{ACL_MANAGE}!="*?", MODE="660", GROUP="plugdev"
+
+# Set ID_VENDOR and ID_MODEL acording to VID and PID
+IMPORT{program}="usb-db %p"
+
+LABEL="argyll_rules_end"
diff --git a/.pc/04_CVE-2012-4405.diff/icc/icc.c b/.pc/04_CVE-2012-4405.diff/icc/icc.c
new file mode 100644
index 0000000..68668d0
--- /dev/null
+++ b/.pc/04_CVE-2012-4405.diff/icc/icc.c
@@ -0,0 +1,17833 @@
+
+/*
+ * International Color Consortium Format Library (icclib)
+ * For ICC profile version 3.4
+ *
+ * Author: Graeme W. Gill
+ * Date: 2002/04/22
+ * Version: 2.15
+ *
+ * Copyright 1997 - 2012 Graeme W. Gill
+ *
+ * This material is licensed with an "MIT" free use license:-
+ * see the License.txt file in this directory for licensing details.
+ */
+
+/*
+ * TTBD:
+ *
+ * Add a "warning mode" to file reading, in which file format
+ * errors are ignored where possible, rather than generating
+ * a fatal error (see ICM_STRICT #define).
+ *
+ * NameColor Dump doesn't handle device space correctly -
+ * should use appropriate interpretation in case device is Lab etc.
+ *
+ * Should recognise & honour unicode 0xFFFE endian marker.
+ * Should generate it on writing too ?
+ *
+ * Add support for copying tags from one icc to another.
+ *
+ * Should fix all write_number failure errors to indicate failed value.
+ * (Partially implemented - need to check all write_number functions)
+ *
+ * Make write fail error messages be specific on which element failed.
+ *
+ * Should add named color space lookup function support.
+ *
+ * Would be nice to add generic ability to add new tag type handling,
+ * so that the base library doesn't need to be modified (ie. VideoCardGamma) ?
+ *
+ * Need to add DeviceSettings and OutputResponse tags to bring up to
+ * ICC.1:1998-09 [started but not complete]
+ *
+ */
+
+#undef ICM_STRICT /* Not fully implimented - switch off strict checking of file format */
+
+/* Make the default grid points of the Lab clut be symetrical about */
+/* a/b 0.0, and also make L = 100.0 fall on a grid point. */
+#define SYMETRICAL_DEFAULT_LAB_RANGE
+
+#define _ICC_C_ /* Turn on implimentation code */
+
+#undef DEBUG_SETLUT /* Show each value being set in setting lut contents */
+#undef DEBUG_SETLUT_CLIP /* Show clipped values when setting LUT */
+#undef DEBUG_LULUT /* Show each value being looked up from lut contents */
+#undef DEBUG_LLULUT /* Debug individual lookup steps (not fully implemented) */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+#include <ctype.h>
+#include <math.h>
+#include <time.h>
+#ifdef __sun
+#include <unistd.h>
+#endif
+#if defined(__IBMC__) && defined(_M_IX86)
+#include <float.h>
+#endif
+#include "icc.h"
+
+#ifdef _MSC_VER
+#define vsnprintf _vsnprintf
+#define snprintf _snprintf
+#endif
+
+/* ========================================================== */
+/* Default system interface object implementations */
+
+#ifndef SEPARATE_STD
+#define COMBINED_STD
+
+#include "iccstd.c"
+
+#undef COMBINED_STD
+#endif /* SEPARATE_STD */
+
+/* Forced byte alignment for tag table and tags */
+#define ALIGN_SIZE 4
+
+/* =========================================================== */
+
+#ifdef DEBUG_SETLUT
+#undef DBGSL
+#define DBGSL(xxx) printf xxx ;
+#else
+#undef DBGSL
+#define DBGSL(xxx)
+#endif
+
+#if defined(DEBUG_SETLUT) || defined(DEBUG_SETLUT_CLIP)
+#undef DBGSLC
+#define DBGSLC(xxx) printf xxx ;
+#else
+#undef DBGSLC
+#define DBGSLC(xxx)
+#endif
+
+#ifdef DEBUG_LULUT
+#undef DBGLL
+#define DBGLL(xxx) printf xxx ;
+#else
+#undef DBGLL
+#define DBGLL(xxx)
+#endif
+
+#ifdef DEBUG_LLULUT
+#undef DBLLL
+#define DBLLL(xxx) printf xxx ;
+#else
+#undef DBLLL
+#define DBLLL(xxx)
+#endif
+
+/* =========================================================== */
+/* Overflow protected unsigned int arithmatic functions. */
+/* These functions saturate rather than wrapping around. */
+/* (Divide doesn't need protection) */
+/* They return UINT_MAX if there was an overflow */
+
+/* a + b */
+static unsigned int sat_add(unsigned int a, unsigned int b) {
+ if (b > (UINT_MAX - a))
+ return UINT_MAX;
+ return a + b;
+}
+
+/* a - b */
+static unsigned int sat_sub(unsigned int a, unsigned int b) {
+ if (a < b)
+ return UINT_MAX;
+ return a - b;
+}
+
+/* a * b */
+static unsigned int sat_mul(unsigned int a, unsigned int b) {
+ unsigned int c;
+
+ if (a == 0 || b == 0)
+ return 0;
+
+ if (a > (UINT_MAX/b))
+ return UINT_MAX;
+ else
+ return a * b;
+}
+
+/* A + B + C */
+#define sat_addadd(A, B, C) sat_add(A, sat_add(B, C))
+
+/* A + B * C */
+#define sat_addmul(A, B, C) sat_add(A, sat_mul(B, C))
+
+/* A + B + C * D */
+#define sat_addaddmul(A, B, C, D) sat_add(A, sat_add(B, sat_mul(C, D)))
+
+/* A * B * C */
+#define sat_mul3(A, B, C) sat_mul(A, sat_mul(B, C))
+
+/* a ^ b */
+static unsigned int sat_pow(unsigned int a, unsigned int b) {
+ unsigned int c = 1;
+ for (; b > 0; b--) {
+ c = sat_mul(c, a);
+ if (c == UINT_MAX)
+ break;
+ }
+ return c;
+}
+
+/* Alignment */
+static unsigned int sat_align(unsigned int align_size, unsigned int a) {
+ align_size--;
+
+ if (align_size > (UINT_MAX - a))
+ return UINT_MAX;
+
+ return (a + align_size) & ~align_size;
+}
+
+/* These test functions detect whether an overflow would occur */
+
+/* Return nz if add would overflow */
+static int ovr_add(unsigned int a, unsigned int b) {
+
+ if (b > (UINT_MAX - a))
+ return 1;
+ return 0;
+}
+
+/* Return nz if sub would overflow */
+static int ovr_sub(unsigned int a, unsigned int b) {
+ if (a < b)
+ return 1;
+ return 0;
+}
+
+/* Return nz if mult would overflow */
+static int ovr_mul(unsigned int a, unsigned int b) {
+ if (a > (UINT_MAX/b))
+ return 1;
+ return 0;
+}
+
+
+/* size_t versions of saturating arithmatic */
+
+#ifndef SIZE_MAX
+# define SIZE_MAX ((size_t)(-1))
+#endif
+
+/* a + b */
+static size_t ssat_add(size_t a, size_t b) {
+ if (b > (SIZE_MAX - a))
+ return SIZE_MAX;
+ return a + b;
+}
+
+/* a - b */
+static size_t ssat_sub(size_t a, size_t b) {
+ if (a < b)
+ return SIZE_MAX;
+ return a - b;
+}
+
+/* a * b */
+static size_t ssat_mul(size_t a, size_t b) {
+ size_t c;
+
+ if (a == 0 || b == 0)
+ return 0;
+
+ if (a > (SIZE_MAX/b))
+ return SIZE_MAX;
+ else
+ return a * b;
+}
+
+/* ------------------------------------------------- */
+/* Memory image icmFile compatible class */
+/* Buffer is assumed to have been allocated by the given allocator, */
+/* and will be expanded on write. */
+
+/* Get the size of the file */
+static size_t icmFileMem_get_size(icmFile *pp) {
+ icmFileMem *p = (icmFileMem *)pp;
+
+ return p->end - p->start;
+}
+
+/* Set current position to offset. Return 0 on success, nz on failure. */
+static int icmFileMem_seek(
+icmFile *pp,
+unsigned int offset
+) {
+ icmFileMem *p = (icmFileMem *)pp;
+ unsigned char *np;
+
+ np = p->start + offset;
+ if (np < p->start || np >= p->end)
+ return 1;
+ p->cur = np;
+ return 0;
+}
+
+/* Read count items of size length. Return number of items successfully read. */
+static size_t icmFileMem_read(
+icmFile *pp,
+void *buffer,
+size_t size,
+size_t count
+) {
+ icmFileMem *p = (icmFileMem *)pp;
+ size_t len;
+
+ len = ssat_mul(size, count);
+ if (len > (p->end - p->cur)) { /* Too much */
+ if (size > 0)
+ count = (p->end - p->cur)/size;
+ else
+ count = 0;
+ }
+ len = size * count;
+ if (len > 0)
+ memmove(buffer, p->cur, len);
+ p->cur += len;
+ return count;
+}
+
+/* Expand the memory buffer file to hold up to pointer ep */
+/* Don't expand if realloc fails */
+static void icmFileMem_filemem_resize(icmFileMem *p, unsigned char *ep) {
+ size_t na, co, ce;
+ unsigned char *nstart;
+
+ /* No need to realloc */
+ if (ep <= p->aend) {
+ return;
+ }
+
+ co = p->cur - p->start; /* Current offset */
+ ce = p->end - p->start; /* Current end */
+ na = ep - p->start; /* new allocated size */
+
+ /* Round new allocation up */
+ if (na <= 1024)
+ na += 1024;
+ else
+ na += 4096;
+
+ if ((nstart = p->al->realloc(p->al, p->start, na)) != NULL) {
+ p->start = nstart;
+ p->cur = nstart + co;
+ p->end = nstart + ce;
+ p->aend = nstart + na;
+ }
+}
+
+/* write count items of size length. Return number of items successfully written. */
+static size_t icmFileMem_write(
+icmFile *pp,
+void *buffer,
+size_t size,
+size_t count
+) {
+ icmFileMem *p = (icmFileMem *)pp;
+ size_t len;
+
+ len = ssat_mul(size, count);
+ if (len > (size_t)(p->aend - p->cur)) /* Try and expand buffer */
+ icmFileMem_filemem_resize(p, p->start + len);
+
+ if (len > (size_t)(p->aend - p->cur)) {
+ if (size > 0)
+ count = (p->aend - p->cur)/size;
+ else
+ count = 0;
+ }
+ len = size * count;
+ if (len > 0)
+ memmove(p->cur, buffer, len);
+ p->cur += len;
+ if (p->end < p->cur)
+ p->end = p->cur;
+ return count;
+}
+
+/* do a printf */
+static int icmFileMem_printf(
+icmFile *pp,
+const char *format,
+...
+) {
+ int rv;
+ va_list args;
+ icmFileMem *p = (icmFileMem *)pp;
+ int len;
+
+ va_start(args, format);
+
+ rv = 1;
+ len = 100; /* Initial allocation for printf */
+ icmFileMem_filemem_resize(p, p->cur + len);
+
+ /* We have to use the available printf functions to resize the buffer if needed. */
+ for (;rv != 0;) {
+ /* vsnprintf() either returns -1 if it doesn't fit, or */
+ /* returns the size-1 needed in order to fit. */
+ len = vsnprintf((char *)p->cur, (p->aend - p->cur), format, args);
+
+ if (len > -1 && ((p->cur + len +1) <= p->aend)) /* Fitted in current allocation */
+ break;
+
+ if (len > -1) /* vsnprintf returned needed size-1 */
+ len = len+2; /* (In case vsnprintf returned 1 less than it needs) */
+ else
+ len *= 2; /* We just have to guess */
+
+ /* Attempt to resize */
+ icmFileMem_filemem_resize(p, p->cur + len);
+
+ /* If resize failed */
+ if ((p->aend - p->cur) < len) {
+ rv = 0;
+ break;
+ }
+ }
+ if (rv != 0) {
+ /* Figure out where end of printf is */
+ len = strlen((char *)p->cur); /* Length excluding nul */
+ p->cur += len;
+ if (p->cur > p->end)
+ p->end = p->cur;
+ rv = len;
+ }
+ va_end(args);
+ return rv;
+}
+
+/* flush all write data out to secondary storage. Return nz on failure. */
+static int icmFileMem_flush(
+icmFile *pp
+) {
+ return 0;
+}
+
+/* Return the memory buffer. Error if not icmFileMem */
+static int icmFileMem_get_buf(
+icmFile *pp,
+unsigned char **buf,
+size_t *len
+) {
+ icmFileMem *p = (icmFileMem *)pp;
+ if (buf != NULL)
+ *buf = p->start;
+ if (len != NULL)
+ *len = p->end - p->start;
+ return 0;
+}
+
+/* we're done with the file object, return nz on failure */
+static int icmFileMem_delete(
+icmFile *pp
+) {
+ icmFileMem *p = (icmFileMem *)pp;
+ icmAlloc *al = p->al;
+ int del_al = p->del_al;
+
+ if (p->del_buf) /* Free the memory buffer */
+ al->free(al, p->start);
+ al->free(al, p); /* Free object */
+ if (del_al) /* We are responsible for deleting allocator */
+ al->del(al);
+ return 0;
+}
+
+/* Create a memory image file access class with allocator */
+/* Buffer is used as is. */
+icmFile *new_icmFileMem_a(
+void *base, /* Pointer to base of memory buffer */
+size_t length, /* Number of bytes in buffer */
+icmAlloc *al /* heap allocator */
+) {
+ icmFileMem *p;
+
+ if ((p = (icmFileMem *) al->calloc(al, 1, sizeof(icmFileMem))) == NULL) {
+ return NULL;
+ }
+ p->al = al; /* Heap allocator */
+ p->get_size = icmFileMem_get_size;
+ p->seek = icmFileMem_seek;
+ p->read = icmFileMem_read;
+ p->write = icmFileMem_write;
+ p->gprintf = icmFileMem_printf;
+ p->flush = icmFileMem_flush;
+ p->get_buf = icmFileMem_get_buf;
+ p->del = icmFileMem_delete;
+
+ p->start = (unsigned char *)base;
+ p->cur = p->start;
+ p->aend = p->end = p->start + length;
+
+ return (icmFile *)p;
+}
+
+/* Create a memory image file access class with given allocator */
+/* and delete base when icmFile is deleted. */
+icmFile *new_icmFileMem_ad(void *base, size_t length, icmAlloc *al) {
+ icmFile *fp;
+
+ if ((fp = new_icmFileMem_a(base, length, al)) != NULL) {
+ ((icmFileMem *)fp)->del_buf = 1;
+ }
+
+ return fp;
+}
+
+/* ========================================================== */
+/* Conversion support functions */
+/* Convert between ICC storage types and native C types */
+/* Write routine return non-zero if numbers can't be represented */
+
+/* Unsigned */
+static unsigned int read_UInt8Number(char *p) {
+ unsigned int rv;
+ rv = (unsigned int)((ORD8 *)p)[0];
+ return rv;
+}
+
+static int write_UInt8Number(unsigned int d, char *p) {
+ if (d > 255)
+ return 1;
+ ((ORD8 *)p)[0] = (ORD8)d;
+ return 0;
+}
+
+static unsigned int read_UInt16Number(char *p) {
+ unsigned int rv;
+ rv = 256 * (unsigned int)((ORD8 *)p)[0]
+ + (unsigned int)((ORD8 *)p)[1];
+ return rv;
+}
+
+static int write_UInt16Number(unsigned int d, char *p) {
+ if (d > 65535)
+ return 1;
+ ((ORD8 *)p)[0] = (ORD8)(d >> 8);
+ ((ORD8 *)p)[1] = (ORD8)(d);
+ return 0;
+}
+
+static unsigned int read_UInt32Number(char *p) {
+ unsigned int rv;
+ rv = 16777216 * (unsigned int)((ORD8 *)p)[0]
+ + 65536 * (unsigned int)((ORD8 *)p)[1]
+ + 256 * (unsigned int)((ORD8 *)p)[2]
+ + (unsigned int)((ORD8 *)p)[3];
+ return rv;
+}
+
+static int write_UInt32Number(unsigned int d, char *p) {
+ ((ORD8 *)p)[0] = (ORD8)(d >> 24);
+ ((ORD8 *)p)[1] = (ORD8)(d >> 16);
+ ((ORD8 *)p)[2] = (ORD8)(d >> 8);
+ ((ORD8 *)p)[3] = (ORD8)(d);
+ return 0;
+}
+
+static void read_UInt64Number(icmUint64 *d, char *p) {
+ d->h = 16777216 * (unsigned int)((ORD8 *)p)[0]
+ + 65536 * (unsigned int)((ORD8 *)p)[1]
+ + 256 * (unsigned int)((ORD8 *)p)[2]
+ + (unsigned int)((ORD8 *)p)[3];
+ d->l = 16777216 * (unsigned int)((ORD8 *)p)[4]
+ + 65536 * (unsigned int)((ORD8 *)p)[5]
+ + 256 * (unsigned int)((ORD8 *)p)[6]
+ + (unsigned int)((ORD8 *)p)[7];
+}
+
+static int write_UInt64Number(icmUint64 *d, char *p) {
+ ((ORD8 *)p)[0] = (ORD8)(d->h >> 24);
+ ((ORD8 *)p)[1] = (ORD8)(d->h >> 16);
+ ((ORD8 *)p)[2] = (ORD8)(d->h >> 8);
+ ((ORD8 *)p)[3] = (ORD8)(d->h);
+ ((ORD8 *)p)[4] = (ORD8)(d->l >> 24);
+ ((ORD8 *)p)[5] = (ORD8)(d->l >> 16);
+ ((ORD8 *)p)[6] = (ORD8)(d->l >> 8);
+ ((ORD8 *)p)[7] = (ORD8)(d->l);
+ return 0;
+}
+
+static double read_U8Fixed8Number(char *p) {
+ ORD32 o32;
+ o32 = 256 * (ORD32)((ORD8 *)p)[0] /* Read big endian 16 bit unsigned */
+ + (ORD32)((ORD8 *)p)[1];
+ return (double)o32/256.0;
+}
+
+static int write_U8Fixed8Number(double d, char *p) {
+ ORD32 o32;
+ d = d * 256.0 + 0.5;
+ if (d >= 65536.0)
+ return 1;
+ if (d < 0.0)
+ return 1;
+ o32 = (ORD32)d;
+ ((ORD8 *)p)[0] = (ORD8)((o32) >> 8);
+ ((ORD8 *)p)[1] = (ORD8)((o32));
+ return 0;
+}
+
+static double read_U16Fixed16Number(char *p) {
+ ORD32 o32;
+ o32 = 16777216 * (ORD32)((ORD8 *)p)[0] /* Read big endian 32 bit unsigned */
+ + 65536 * (ORD32)((ORD8 *)p)[1]
+ + 256 * (ORD32)((ORD8 *)p)[2]
+ + (ORD32)((ORD8 *)p)[3];
+ return (double)o32/65536.0;
+}
+
+static int write_U16Fixed16Number(double d, char *p) {
+ ORD32 o32;
+ d = d * 65536.0 + 0.5;
+ if (d >= 4294967296.0)
+ return 1;
+ if (d < 0.0)
+ return 1;
+ o32 = (ORD32)d;
+ ((ORD8 *)p)[0] = (ORD8)((o32) >> 24);
+ ((ORD8 *)p)[1] = (ORD8)((o32) >> 16);
+ ((ORD8 *)p)[2] = (ORD8)((o32) >> 8);
+ ((ORD8 *)p)[3] = (ORD8)((o32));
+ return 0;
+}
+
+
+/* Signed numbers */
+static int read_SInt8Number(char *p) {
+ int rv;
+ rv = (int)((INR8 *)p)[0];
+ return rv;
+}
+
+static int write_SInt8Number(int d, char *p) {
+ if (d > 127)
+ return 1;
+ else if (d < -128)
+ return 1;
+ ((INR8 *)p)[0] = (INR8)d;
+ return 0;
+}
+
+static int read_SInt16Number(char *p) {
+ int rv;
+ rv = 256 * (int)((INR8 *)p)[0]
+ + (int)((ORD8 *)p)[1];
+ return rv;
+}
+
+static int write_SInt16Number(int d, char *p) {
+ if (d > 32767)
+ return 1;
+ else if (d < -32768)
+ return 1;
+ ((INR8 *)p)[0] = (INR8)(d >> 8);
+ ((ORD8 *)p)[1] = (ORD8)(d);
+ return 0;
+}
+
+static int read_SInt32Number(char *p) {
+ int rv;
+ rv = 16777216 * (int)((INR8 *)p)[0]
+ + 65536 * (int)((ORD8 *)p)[1]
+ + 256 * (int)((ORD8 *)p)[2]
+ + (int)((ORD8 *)p)[3];
+ return rv;
+}
+
+static int write_SInt32Number(int d, char *p) {
+ ((INR8 *)p)[0] = (INR8)(d >> 24);
+ ((ORD8 *)p)[1] = (ORD8)(d >> 16);
+ ((ORD8 *)p)[2] = (ORD8)(d >> 8);
+ ((ORD8 *)p)[3] = (ORD8)(d);
+ return 0;
+}
+
+static void read_SInt64Number(icmInt64 *d, char *p) {
+ d->h = 16777216 * (int)((INR8 *)p)[0]
+ + 65536 * (int)((ORD8 *)p)[1]
+ + 256 * (int)((ORD8 *)p)[2]
+ + (int)((ORD8 *)p)[3];
+ d->l = 16777216 * (unsigned int)((ORD8 *)p)[4]
+ + 65536 * (unsigned int)((ORD8 *)p)[5]
+ + 256 * (unsigned int)((ORD8 *)p)[6]
+ + (unsigned int)((ORD8 *)p)[7];
+}
+
+static int write_SInt64Number(icmInt64 *d, char *p) {
+ ((INR8 *)p)[0] = (INR8)(d->h >> 24);
+ ((ORD8 *)p)[1] = (ORD8)(d->h >> 16);
+ ((ORD8 *)p)[2] = (ORD8)(d->h >> 8);
+ ((ORD8 *)p)[3] = (ORD8)(d->h);
+ ((ORD8 *)p)[4] = (ORD8)(d->l >> 24);
+ ((ORD8 *)p)[5] = (ORD8)(d->l >> 16);
+ ((ORD8 *)p)[6] = (ORD8)(d->l >> 8);
+ ((ORD8 *)p)[7] = (ORD8)(d->l);
+ return 0;
+}
+
+static double read_S15Fixed16Number(char *p) {
+ INR32 i32;
+ i32 = 16777216 * (INR32)((INR8 *)p)[0] /* Read big endian 32 bit signed */
+ + 65536 * (INR32)((ORD8 *)p)[1]
+ + 256 * (INR32)((ORD8 *)p)[2]
+ + (INR32)((ORD8 *)p)[3];
+ return (double)i32/65536.0;
+}
+
+static int write_S15Fixed16Number(double d, char *p) {
+ INR32 i32;
+ d = floor(d * 65536.0 + 0.5); /* Beware! (int)(d + 0.5) doesn't work! */
+ if (d >= 2147483648.0)
+ return 1;
+ if (d < -2147483648.0)
+ return 1;
+ i32 = (INR32)d;
+ ((INR8 *)p)[0] = (INR8)((i32) >> 24); /* Write big endian 32 bit signed */
+ ((ORD8 *)p)[1] = (ORD8)((i32) >> 16);
+ ((ORD8 *)p)[2] = (ORD8)((i32) >> 8);
+ ((ORD8 *)p)[3] = (ORD8)((i32));
+ return 0;
+}
+
+/* Device coordinate as 8 bit value range 0.0 - 1.0 */
+static double read_DCS8Number(char *p) {
+ unsigned int rv;
+ rv = (unsigned int)((ORD8 *)p)[0];
+ return (double)rv/255.0;
+}
+
+static int write_DCS8Number(double d, char *p) {
+ ORD32 o32;
+ d = d * 255.0 + 0.5;
+ if (d >= 256.0)
+ return 1;
+ if (d < 0.0)
+ return 1;
+ o32 = (ORD32)d;
+ ((ORD8 *)p)[0] = (ORD8)(o32);
+ return 0;
+}
+
+/* Device coordinate as 16 bit value range 0.0 - 1.0 */
+static double read_DCS16Number(char *p) {
+ unsigned int rv;
+ rv = 256 * (unsigned int)((ORD8 *)p)[0]
+ + (unsigned int)((ORD8 *)p)[1];
+ return (double)rv/65535.0;
+}
+
+static int write_DCS16Number(double d, char *p) {
+ ORD32 o32;
+ d = d * 65535.0 + 0.5;
+ if (d >= 65536.0)
+ return 1;
+ if (d < 0.0)
+ return 1;
+ o32 = (ORD32)d;
+ ((ORD8 *)p)[0] = (ORD8)(o32 >> 8);
+ ((ORD8 *)p)[1] = (ORD8)(o32);
+ return 0;
+}
+
+static void Lut_Lut2XYZ(double *out, double *in);
+static void Lut_XYZ2Lut(double *out, double *in);
+static void Lut_Lut2Lab_8(double *out, double *in);
+static void Lut_Lab2Lut_8(double *out, double *in);
+static void Lut_Lut2LabV2_16(double *out, double *in);
+static void Lut_Lab2LutV2_16(double *out, double *in);
+static void Lut_Lut2LabV4_16(double *out, double *in);
+static void Lut_Lab2LutV4_16(double *out, double *in);
+
+static void Lut_Lut2Y(double *out, double *in);
+static void Lut_Y2Lut(double *out, double *in);
+static void Lut_Lut2L_8(double *out, double *in);
+static void Lut_L2Lut_8(double *out, double *in);
+static void Lut_Lut2LV2_16(double *out, double *in);
+static void Lut_L2LutV2_16(double *out, double *in);
+static void Lut_Lut2LV4_16(double *out, double *in);
+static void Lut_L2LutV4_16(double *out, double *in);
+
+//~~~~888888
+/* read a PCS number. PCS can be profile PCS, profile version Lab, */
+/* or a specific type of Lab, depending on the value of csig: */
+/* icmSigPCSData, icSigXYZData, icmSigLab8Data, icSigLabData, */
+/* icmSigLabV2Data or icmSigLabV4Data */
+/* Do nothing if not one of the above. */
+static void read_PCSNumber(icc *icp, icColorSpaceSignature csig, double pcs[3], char *p) {
+
+ if (csig == icmSigPCSData)
+ csig = icp->header->pcs;
+ if (csig == icSigLabData) {
+ if (icp->ver != 0)
+ csig = icmSigLabV4Data;
+ else
+ csig = icmSigLabV2Data;
+ }
+
+ if (csig == icmSigLab8Data) {
+ pcs[0] = read_DCS8Number(p);
+ pcs[1] = read_DCS8Number(p+1);
+ pcs[2] = read_DCS8Number(p+2);
+ } else {
+ pcs[0] = read_DCS16Number(p);
+ pcs[1] = read_DCS16Number(p+2);
+ pcs[2] = read_DCS16Number(p+4);
+ }
+ switch (csig) {
+ case icSigXYZData:
+ Lut_Lut2XYZ(pcs, pcs);
+ break;
+ case icmSigLab8Data:
+ Lut_Lut2Lab_8(pcs, pcs);
+ break;
+ case icmSigLabV2Data:
+ Lut_Lut2LabV2_16(pcs, pcs);
+ break;
+ case icmSigLabV4Data:
+ Lut_Lut2LabV4_16(pcs, pcs);
+ break;
+ default:
+ break;
+ }
+}
+
+/* write a PCS number. PCS can be profile PCS, profile version Lab, */
+/* or a specific type of Lab, depending on the value of csig: */
+/* icmSigPCSData, icSigXYZData, icmSigLab8Data, icSigLabData, */
+/* icmSigLabV2Data or icmSigLabV4Data */
+/* Return 1 if error */
+static int write_PCSNumber(icc *icp, icColorSpaceSignature csig, double pcs[3], char *p) {
+ double v[3];
+ int j;
+
+ if (csig == icmSigPCSData)
+ csig = icp->header->pcs;
+ if (csig == icSigLabData) {
+ if (icp->ver != 0)
+ csig = icmSigLabV4Data;
+ else
+ csig = icmSigLabV2Data;
+ }
+
+ switch (csig) {
+ case icSigXYZData:
+ Lut_XYZ2Lut(v, pcs);
+ break;
+ case icmSigLab8Data:
+ Lut_Lab2Lut_8(v, pcs);
+ break;
+ case icmSigLabV2Data:
+ Lut_Lab2LutV2_16(v, pcs);
+ break;
+ case icmSigLabV4Data:
+ Lut_Lab2LutV4_16(v, pcs);
+ break;
+ default:
+ return 1;
+ }
+ if (csig == icmSigLab8Data) {
+ for (j = 0; j < 3; j++) {
+ if (write_DCS8Number(v[j], p+j))
+ return 1;
+ }
+ } else {
+ for (j = 0; j < 3; j++) {
+ if (write_DCS16Number(v[j], p+(2 * j)))
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+/* Read a given primitive type. Return non-zero on error */
+/* (Not currently used internaly ?) */
+/* Public: */
+int read_Primitive(icc *icp, icmPrimType ptype, void *prim, char *p) {
+
+ switch(ptype) {
+ case icmUInt8Number:
+ *((unsigned int *)prim) = read_UInt8Number(p);
+ return 0;
+ case icmUInt16Number:
+ *((unsigned int *)prim) = read_UInt16Number(p);
+ return 0;
+ case icmUInt32Number:
+ *((unsigned int *)prim) = read_UInt32Number(p);
+ return 0;
+ case icmUInt64Number:
+ read_UInt64Number((icmUint64 *)prim, p);
+ return 0;
+ case icmU8Fixed8Number:
+ *((double *)prim) = read_U8Fixed8Number(p);
+ return 0;
+ case icmU16Fixed16Number:
+ *((double *)prim) = read_U16Fixed16Number(p);
+ return 0;
+ case icmSInt8Number:
+ *((int *)prim) = read_SInt8Number(p);
+ return 0;
+ case icmSInt16Number:
+ *((int *)prim) = read_SInt16Number(p);
+ return 0;
+ case icmSInt32Number:
+ *((int *)prim) = read_SInt32Number(p);
+ return 0;
+ case icmSInt64Number:
+ read_SInt64Number((icmInt64 *)prim, p);
+ return 0;
+ case icmS15Fixed16Number:
+ *((double *)prim) = read_S15Fixed16Number(p);
+ return 0;
+ case icmDCS8Number:
+ *((double *)prim) = read_DCS8Number(p);
+ return 0;
+ case icmDCS16Number:
+ *((double *)prim) = read_DCS16Number(p);
+ return 0;
+ case icmPCSNumber:
+ read_PCSNumber(icp, icmSigPCSData, ((double *)prim), p);
+ return 0;
+ case icmPCSXYZNumber:
+ read_PCSNumber(icp, icSigXYZData, ((double *)prim), p);
+ return 0;
+ case icmPCSLab8Number:
+ read_PCSNumber(icp, icmSigLab8Data, ((double *)prim), p);
+ return 0;
+ case icmPCSLabNumber:
+ read_PCSNumber(icp, icSigLabData, ((double *)prim), p);
+ return 0;
+ case icmPCSLabV2Number:
+ read_PCSNumber(icp, icmSigLabV2Data, ((double *)prim), p);
+ return 0;
+ case icmPCSLabV4Number:
+ read_PCSNumber(icp, icmSigLabV4Data, ((double *)prim), p);
+ return 0;
+ }
+
+ return 2;
+}
+
+/* Write a given primitive type. Return non-zero on error */
+/* (Not currently used internaly ?) */
+/* Public: */
+int write_Primitive(icc *icp, icmPrimType ptype, char *p, void *prim) {
+
+ switch(ptype) {
+ case icmUInt8Number:
+ return write_UInt8Number(*((unsigned int *)prim), p);
+ case icmUInt16Number:
+ return write_UInt16Number(*((unsigned int *)prim), p);
+ case icmUInt32Number:
+ return write_UInt32Number(*((unsigned int *)prim), p);
+ case icmUInt64Number:
+ return write_UInt64Number((icmUint64 *)prim, p);
+ case icmU8Fixed8Number:
+ return write_U8Fixed8Number(*((double *)prim), p);
+ case icmU16Fixed16Number:
+ return write_U16Fixed16Number(*((double *)prim), p);
+ case icmSInt8Number:
+ return write_SInt8Number(*((int *)prim), p);
+ case icmSInt16Number:
+ return write_SInt16Number(*((int *)prim), p);
+ case icmSInt32Number:
+ return write_SInt32Number(*((int *)prim), p);
+ case icmSInt64Number:
+ return write_SInt64Number((icmInt64 *)prim, p);
+ case icmS15Fixed16Number:
+ return write_S15Fixed16Number(*((double *)prim), p);
+ case icmDCS8Number:
+ return write_DCS8Number(*((double *)prim), p);
+ case icmDCS16Number:
+ return write_DCS16Number(*((double *)prim), p);
+ case icmPCSNumber:
+ return write_PCSNumber(icp, icmSigPCSData, ((double *)prim), p);
+ case icmPCSXYZNumber:
+ return write_PCSNumber(icp, icSigXYZData, ((double *)prim), p);
+ case icmPCSLab8Number:
+ return write_PCSNumber(icp, icmSigLab8Data, ((double *)prim), p);
+ case icmPCSLabNumber:
+ return write_PCSNumber(icp, icSigLabData, ((double *)prim), p);
+ case icmPCSLabV2Number:
+ return write_PCSNumber(icp, icmSigLabV2Data, ((double *)prim), p);
+ case icmPCSLabV4Number:
+ return write_PCSNumber(icp, icmSigLabV4Data, ((double *)prim), p);
+ }
+
+ return 2;
+}
+
+/* ---------------------------------------------------------- */
+/* Auiliary function - return a string that represents a tag */
+/* Note - returned buffers are static, can only be used 5 */
+/* times before buffers get reused. */
+char *tag2str(
+ int tag
+) {
+ int i;
+ static int si = 0; /* String buffer index */
+ static char buf[5][20]; /* String buffers */
+ char *bp;
+ unsigned char c[4];
+
+ bp = buf[si++];
+ si %= 5; /* Rotate through buffers */
+
+ c[0] = 0xff & (tag >> 24);
+ c[1] = 0xff & (tag >> 16);
+ c[2] = 0xff & (tag >> 8);
+ c[3] = 0xff & (tag >> 0);
+ for (i = 0; i < 4; i++) { /* Can we represent it as a string ? */
+ if (!isprint(c[i]))
+ break;
+ }
+ if (i < 4) { /* Not printable - use hex */
+ sprintf(bp,"0x%x",tag);
+ } else { /* Printable */
+ sprintf(bp,"'%c%c%c%c'",c[0],c[1],c[2],c[3]);
+ }
+ return bp;
+}
+
+/* Auiliary function - return a tag created from a string */
+/* Note there is also the icmMakeTag() macro */
+unsigned int str2tag(
+ const char *str
+) {
+ unsigned int tag;
+ tag = (((unsigned int)str[0]) << 24)
+ + (((unsigned int)str[1]) << 16)
+ + (((unsigned int)str[2]) << 8)
+ + (((unsigned int)str[3]));
+ return tag;
+}
+
+/* helper - return 1 if the string doesn't have a */
+/* null terminator within len, return 0 has null at exactly len, */
+/* and 2 if it has null before len. */
+/* Note: will return 1 if len == 0 */
+static int check_null_string(char *cp, int len) {
+ for (; len > 0; len--) {
+ if (cp[0] == '\000')
+ break;
+ cp++;
+ }
+ if (len == 0)
+ return 1;
+ if (len > 1)
+ return 2;
+ return 0;
+}
+
+/* helper - return 1 if the string doesn't have a */
+/* null terminator within len, return 0 has null at exactly len, */
+/* and 2 if it has null before len. */
+/* Note: will return 1 if len == 0 */
+/* Unicode version */
+static int check_null_string16(char *cp, int len) {
+ for (; len > 0; len--) { /* Length is in characters */
+ if (cp[0] == 0 && cp[1] == 0)
+ break;
+ cp += 2;
+ }
+ if (len == 0)
+ return 1;
+ if (len > 1)
+ return 2;
+ return 0;
+}
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+/* Color Space to number of component conversion */
+/* Return 0 on error */
+static unsigned int number_ColorSpaceSignature(icColorSpaceSignature sig) {
+ switch(sig) {
+ case icSigXYZData:
+ return 3;
+ case icSigLabData:
+ return 3;
+ case icSigLuvData:
+ return 3;
+ case icSigYCbCrData:
+ return 3;
+ case icSigYxyData:
+ return 3;
+ case icSigRgbData:
+ return 3;
+ case icSigGrayData:
+ return 1;
+ case icSigHsvData:
+ return 3;
+ case icSigHlsData:
+ return 3;
+ case icSigCmykData:
+ return 4;
+ case icSigCmyData:
+ return 3;
+ case icSig2colorData:
+ return 2;
+ case icSig3colorData:
+ return 3;
+ case icSig4colorData:
+ return 4;
+ case icSig5colorData:
+ case icSigMch5Data:
+ return 5;
+ case icSig6colorData:
+ case icSigMch6Data:
+ return 6;
+ case icSig7colorData:
+ case icSigMch7Data:
+ return 7;
+ case icSig8colorData:
+ case icSigMch8Data:
+ return 8;
+ case icSig9colorData:
+ return 9;
+ case icSig10colorData:
+ return 10;
+ case icSig11colorData:
+ return 11;
+ case icSig12colorData:
+ return 12;
+ case icSig13colorData:
+ return 13;
+ case icSig14colorData:
+ return 14;
+ case icSig15colorData:
+ return 15;
+
+ /* Non-standard and Pseudo spaces */
+ case icmSigYData:
+ return 1;
+ case icmSigLData:
+ return 1;
+ case icmSigL8Data:
+ return 1;
+ case icmSigLV2Data:
+ return 1;
+ case icmSigLV4Data:
+ return 1;
+ case icmSigPCSData:
+ return 3;
+ case icmSigLab8Data:
+ return 3;
+ case icmSigLabV2Data:
+ return 3;
+ case icmSigLabV4Data:
+ return 3;
+
+ default:
+ break;
+ }
+ return 0;
+}
+
+/* Public version of above */
+
+/* Return the number of channels for the given color space. Return 0 if unknown. */
+ICCLIB_API unsigned int icmCSSig2nchan(icColorSpaceSignature sig) {
+ return number_ColorSpaceSignature(sig);
+}
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+/* Return the individual channel names and number of channels give a colorspace signature. */
+/* Return 0 if it is not a colorspace that itself defines particular channels, */
+/* 1 if it is a colorant based colorspace, and 2 if it is not a colorant based space */
+static int chnames_ColorSpaceSignature(
+icColorSpaceSignature sig,
+char *cvals[] /* Pointers to return for each channel */
+) {
+ switch (sig) {
+ case icSigXYZData:
+ cvals[0] = "CIE X";
+ cvals[1] = "CIE Y";
+ cvals[2] = "CIE Z";
+ return 2;
+
+ case icSigLabData:
+ cvals[0] = "CIE L*";
+ cvals[1] = "CIE a*";
+ cvals[2] = "CIE b*";
+ return 2;
+
+ case icSigLuvData:
+ cvals[0] = "CIE L*";
+ cvals[1] = "CIE u*";
+ cvals[2] = "CIE v*";
+ return 2;
+
+ /* Usually ITU-R BT.601 (was CCIR 601) */
+ case icSigYCbCrData:
+ cvals[0] = "ITU Y";
+ cvals[1] = "ITU Cb";
+ cvals[2] = "ITU Cr";
+ return 2;
+
+ case icSigYxyData:
+ cvals[0] = "CIE Y";
+ cvals[1] = "CIE x";
+ cvals[2] = "CIE y";
+ return 2;
+
+ /* Alvy Ray Smith ? */
+ case icSigHsvData:
+ cvals[0] = "RGB Hue";
+ cvals[1] = "RGB Saturation";
+ cvals[2] = "RGB Value";
+ return 2;
+
+ /* GSPC ? */
+ case icSigHlsData:
+ cvals[0] = "RGB Hue";
+ cvals[1] = "RGB Lightness";
+ cvals[2] = "RGB Saturation";
+ return 2;
+
+ case icSigCmyData:
+ cvals[0] = "Cyan";
+ cvals[1] = "Magenta";
+ cvals[2] = "Yellow";
+ return 1;
+
+ case icSigRgbData:
+ cvals[0] = "Red";
+ cvals[1] = "Green";
+ cvals[2] = "Blue";
+ return 1;
+
+ case icSigCmykData:
+ cvals[0] = "Cyan";
+ cvals[1] = "Magenta";
+ cvals[2] = "Yellow";
+ cvals[3] = "Black";
+ return 1;
+
+
+ /* Non-standard and Pseudo spaces */
+ case icmSigYData:
+ cvals[0] = "CIE Y";
+ return 2;
+
+ case icmSigLData:
+ cvals[0] = "CIE L*";
+ return 2;
+
+ default:
+ break;
+
+ }
+ return 0;
+}
+
+/* Public version of above */
+
+/* Return the individual channel names and number of channels give a colorspace signature. */
+/* Return 0 if it is not a colorspace that itself defines particular channels, */
+/* 1 if it is a colorant based colorspace, and 2 if it is not a colorant based space */
+ICCLIB_API unsigned int icmCSSig2chanNames(icColorSpaceSignature sig, char *cvals[]) {
+
+ return chnames_ColorSpaceSignature(sig, cvals);
+}
+
+/* ------------------------------------------------------- */
+/* Flag dump functions */
+/* Note - returned buffers are static, can only be used 5 */
+/* times before buffers get reused. */
+
+/* Screening Encodings */
+static char *string_ScreenEncodings(unsigned int flags) {
+ static int si = 0; /* String buffer index */
+ static char buf[5][80]; /* String buffers */
+ char *bp, *cp;
+
+ cp = bp = buf[si++];
+ si %= 5; /* Rotate through buffers */
+
+ if (flags & icPrtrDefaultScreensTrue) {
+ sprintf(cp,"Default Screen");
+ } else {
+ sprintf(cp,"No Default Screen");
+ }
+ cp = cp + strlen(cp);
+ if (flags & icLinesPerInch) {
+ sprintf(cp,", Lines Per Inch");
+ } else {
+ sprintf(cp,", Lines Per cm");
+ }
+ cp = cp + strlen(cp);
+
+ return bp;
+}
+
+/* Device attributes */
+static char *string_DeviceAttributes(unsigned int flags) {
+ static int si = 0; /* String buffer index */
+ static char buf[5][80]; /* String buffers */
+ char *bp, *cp;
+
+ cp = bp = buf[si++];
+ si %= 5; /* Rotate through buffers */
+
+ if (flags & icTransparency) {
+ sprintf(cp,"Transparency");
+ } else {
+ sprintf(cp,"Reflective");
+ }
+ cp = cp + strlen(cp);
+ if (flags & icMatte) {
+ sprintf(cp,", Matte");
+ } else {
+ sprintf(cp,", Glossy");
+ }
+ cp = cp + strlen(cp);
+ if (flags & icNegative) {
+ sprintf(cp,", Negative");
+ } else {
+ sprintf(cp,", Positive");
+ }
+ cp = cp + strlen(cp);
+ if (flags & icBlackAndWhite) {
+ sprintf(cp,", BlackAndWhite");
+ } else {
+ sprintf(cp,", Color");
+ }
+ cp = cp + strlen(cp);
+
+ return bp;
+}
+
+/* Profile header flags */
+static char *string_ProfileHeaderFlags(unsigned int flags) {
+ static int si = 0; /* String buffer index */
+ static char buf[5][80]; /* String buffers */
+ char *bp, *cp;
+
+ cp = bp = buf[si++];
+ si %= 5; /* Rotate through buffers */
+
+ if (flags & icEmbeddedProfileTrue) {
+ sprintf(cp,"Embedded Profile");
+ } else {
+ sprintf(cp,"Not Embedded Profile");
+ }
+ cp = cp + strlen(cp);
+ if (flags & icUseWithEmbeddedDataOnly) {
+ sprintf(cp,", Use with embedded data only");
+ } else {
+ sprintf(cp,", Use anywhere");
+ }
+ cp = cp + strlen(cp);
+
+ return bp;
+}
+
+
+static char *string_AsciiOrBinaryData(unsigned int flags) {
+ static int si = 0; /* String buffer index */
+ static char buf[5][80]; /* String buffers */
+ char *bp, *cp;
+
+ cp = bp = buf[si++];
+ si %= 5; /* Rotate through buffers */
+
+ if (flags & icBinaryData) {
+ sprintf(cp,"Binary");
+ } else {
+ sprintf(cp,"Ascii");
+ }
+ cp = cp + strlen(cp);
+
+ return bp;
+}
+
+/* ------------------------------------------------------------ */
+/* Enumeration dump functions */
+/* Note - returned buffers are static, can only be used once */
+/* before buffers get reused if type is unknown. */
+
+/* public tags and sizes */
+static const char *string_TagSignature(icTagSignature sig) {
+ static char buf[80];
+ switch(sig) {
+ case icSigAToB0Tag:
+ return "AToB0 Multidimentional Transform";
+ case icSigAToB1Tag:
+ return "AToB1 Multidimentional Transform";
+ case icSigAToB2Tag:
+ return "AToB2 Multidimentional Transform";
+ case icSigBlueColorantTag:
+ return "Blue Colorant";
+ case icSigBlueTRCTag:
+ return "Blue Tone Reproduction Curve";
+ case icSigBToA0Tag:
+ return "BToA0 Multidimentional Transform";
+ case icSigBToA1Tag:
+ return "BToA1 Multidimentional Transform";
+ case icSigBToA2Tag:
+ return "BToA2 Multidimentional Transform";
+ case icSigCalibrationDateTimeTag:
+ return "Calibration Date & Time";
+ case icSigCharTargetTag:
+ return "Characterization Target";
+ case icSigCopyrightTag:
+ return "Copyright";
+ case icSigCrdInfoTag:
+ return "CRD Info";
+ case icSigDeviceMfgDescTag:
+ return "Device Manufacturer Description";
+ case icSigDeviceModelDescTag:
+ return "Device Model Description";
+ case icSigGamutTag:
+ return "Gamut";
+ case icSigGrayTRCTag:
+ return "Gray Tone Reproduction Curve";
+ case icSigGreenColorantTag:
+ return "Green Colorant";
+ case icSigGreenTRCTag:
+ return "Green Tone Reproduction Curve";
+ case icSigLuminanceTag:
+ return "Luminance";
+ case icSigMeasurementTag:
+ return "Measurement";
+ case icSigMediaBlackPointTag:
+ return "Media Black Point";
+ case icSigMediaWhitePointTag:
+ return "Media White Point";
+ case icSigNamedColorTag:
+ return "Named Color";
+ case icSigNamedColor2Tag:
+ return "Named Color 2";
+ case icSigPreview0Tag:
+ return "Preview0";
+ case icSigPreview1Tag:
+ return "Preview1";
+ case icSigPreview2Tag:
+ return "Preview2";
+ case icSigProfileDescriptionTag:
+ return "Profile Description";
+ case icSigProfileSequenceDescTag:
+ return "Profile Sequence";
+ case icSigPs2CRD0Tag:
+ return "PS Level 2 CRD perceptual";
+ case icSigPs2CRD1Tag:
+ return "PS Level 2 CRD colorimetric";
+ case icSigPs2CRD2Tag:
+ return "PS Level 2 CRD saturation";
+ case icSigPs2CRD3Tag:
+ return "PS Level 2 CRD absolute";
+ case icSigPs2CSATag:
+ return "PS Level 2 color space array";
+ case icSigPs2RenderingIntentTag:
+ return "PS Level 2 Rendering Intent";
+ case icSigRedColorantTag:
+ return "Red Colorant";
+ case icSigRedTRCTag:
+ return "Red Tone Reproduction Curve";
+ case icSigScreeningDescTag:
+ return "Screening Description";
+ case icSigScreeningTag:
+ return "Screening Attributes";
+ case icSigTechnologyTag:
+ return "Device Technology";
+ case icSigUcrBgTag:
+ return "Under Color Removal & Black Generation";
+ case icSigVideoCardGammaTag:
+ return "Video Card Gamma Curve";
+ case icSigViewingCondDescTag:
+ return "Viewing Condition Description";
+ case icSigViewingConditionsTag:
+ return "Viewing Condition Paramaters";
+ default:
+ sprintf(buf,"Unrecognized - %s",tag2str(sig));
+ return buf;
+ }
+}
+
+/* technology signature descriptions */
+static const char *string_TechnologySignature(icTechnologySignature sig) {
+ static char buf[80];
+ switch(sig) {
+ case icSigDigitalCamera:
+ return "Digital Camera";
+ case icSigFilmScanner:
+ return "Film Scanner";
+ case icSigReflectiveScanner:
+ return "Reflective Scanner";
+ case icSigInkJetPrinter:
+ return "InkJet Printer";
+ case icSigThermalWaxPrinter:
+ return "Thermal WaxPrinter";
+ case icSigElectrophotographicPrinter:
+ return "Electrophotographic Printer";
+ case icSigElectrostaticPrinter:
+ return "Electrostatic Printer";
+ case icSigDyeSublimationPrinter:
+ return "DyeSublimation Printer";
+ case icSigPhotographicPaperPrinter:
+ return "Photographic Paper Printer";
+ case icSigFilmWriter:
+ return "Film Writer";
+ case icSigVideoMonitor:
+ return "Video Monitor";
+ case icSigVideoCamera:
+ return "Video Camera";
+ case icSigProjectionTelevision:
+ return "Projection Television";
+ case icSigCRTDisplay:
+ return "Cathode Ray Tube Display";
+ case icSigPMDisplay:
+ return "Passive Matrix Display";
+ case icSigAMDisplay:
+ return "Active Matrix Display";
+ case icSigPhotoCD:
+ return "Photo CD";
+ case icSigPhotoImageSetter:
+ return "Photo ImageSetter";
+ case icSigGravure:
+ return "Gravure";
+ case icSigOffsetLithography:
+ return "Offset Lithography";
+ case icSigSilkscreen:
+ return "Silkscreen";
+ case icSigFlexography:
+ return "Flexography";
+ default:
+ sprintf(buf,"Unrecognized - %s",tag2str(sig));
+ return buf;
+ }
+}
+
+/* type signatures */
+static const char *string_TypeSignature(icTagTypeSignature sig) {
+ static char buf[80];
+ switch(sig) {
+ case icSigCurveType:
+ return "Curve";
+ case icSigDataType:
+ return "Data";
+ case icSigDateTimeType:
+ return "DateTime";
+ case icSigLut16Type:
+ return "Lut16";
+ case icSigLut8Type:
+ return "Lut8";
+ case icSigMeasurementType:
+ return "Measurement";
+ case icSigNamedColorType:
+ return "Named Color";
+ case icSigProfileSequenceDescType:
+ return "Profile Sequence Desc";
+ case icSigS15Fixed16ArrayType:
+ return "S15Fixed16 Array";
+ case icSigScreeningType:
+ return "Screening";
+ case icSigSignatureType:
+ return "Signature";
+ case icSigTextType:
+ return "Text";
+ case icSigTextDescriptionType:
+ return "Text Description";
+ case icSigU16Fixed16ArrayType:
+ return "U16Fixed16 Array";
+ case icSigUcrBgType:
+ return "Under Color Removal & Black Generation";
+ case icSigUInt16ArrayType:
+ return "UInt16 Array";
+ case icSigUInt32ArrayType:
+ return "UInt32 Array";
+ case icSigUInt64ArrayType:
+ return "UInt64 Array";
+ case icSigUInt8ArrayType:
+ return "UInt8 Array";
+ case icSigVideoCardGammaType:
+ return "Video Card Gamma";
+ case icSigViewingConditionsType:
+ return "Viewing Conditions";
+ case icSigXYZType:
+ return "XYZ (Array?)";
+ case icSigNamedColor2Type:
+ return "Named Color 2";
+ case icSigCrdInfoType:
+ return "CRD Info";
+ default:
+ sprintf(buf,"Unrecognized - %s",tag2str(sig));
+ return buf;
+ }
+}
+
+/* Color Space Signatures */
+static const char *string_ColorSpaceSignature(icColorSpaceSignature sig) {
+ static char buf[80];
+ switch(sig) {
+ case icSigXYZData:
+ return "XYZ";
+ case icSigLabData:
+ return "Lab";
+ case icSigLuvData:
+ return "Luv";
+ case icSigYCbCrData:
+ return "YCbCr";
+ case icSigYxyData:
+ return "Yxy";
+ case icSigRgbData:
+ return "RGB";
+ case icSigGrayData:
+ return "Gray";
+ case icSigHsvData:
+ return "HSV";
+ case icSigHlsData:
+ return "HLS";
+ case icSigCmykData:
+ return "CMYK";
+ case icSigCmyData:
+ return "CMY";
+ case icSig2colorData:
+ return "2 Color";
+ case icSig3colorData:
+ return "3 Color";
+ case icSig4colorData:
+ return "4 Color";
+ case icSig5colorData:
+ case icSigMch5Data:
+ return "5 Color";
+ case icSig6colorData:
+ case icSigMch6Data:
+ return "6 Color";
+ case icSig7colorData:
+ case icSigMch7Data:
+ return "7 Color";
+ case icSig8colorData:
+ case icSigMch8Data:
+ return "8 Color";
+ case icSig9colorData:
+ return "9 Color";
+ case icSig10colorData:
+ return "10 Color";
+ case icSig11colorData:
+ return "11 Color";
+ case icSig12colorData:
+ return "12 Color";
+ case icSig13colorData:
+ return "13 Color";
+ case icSig14colorData:
+ return "14 Color";
+ case icSig15colorData:
+ return "15 Color";
+
+ /* Non-standard and Pseudo spaces */
+ case icmSigYData:
+ return "Y";
+ case icmSigLData:
+ return "L";
+ case icmSigL8Data:
+ return "L";
+ case icmSigLV2Data:
+ return "L";
+ case icmSigLV4Data:
+ return "L";
+ case icmSigPCSData:
+ return "PCS";
+ case icmSigLab8Data:
+ return "Lab";
+ case icmSigLabV2Data:
+ return "Lab";
+ case icmSigLabV4Data:
+ return "Lab";
+
+ default:
+ sprintf(buf,"Unrecognized - %s",tag2str(sig));
+ return buf;
+ }
+}
+
+#ifdef NEVER
+/* Public version of above */
+char *ColorSpaceSignature2str(icColorSpaceSignature sig) {
+ return string_ColorSpaceSignature(sig);
+}
+#endif
+
+
+/* profileClass enumerations */
+static const char *string_ProfileClassSignature(icProfileClassSignature sig) {
+ static char buf[80];
+ switch(sig) {
+ case icSigInputClass:
+ return "Input";
+ case icSigDisplayClass:
+ return "Display";
+ case icSigOutputClass:
+ return "Output";
+ case icSigLinkClass:
+ return "Link";
+ case icSigAbstractClass:
+ return "Abstract";
+ case icSigColorSpaceClass:
+ return "Color Space";
+ case icSigNamedColorClass:
+ return "Named Color";
+ default:
+ sprintf(buf,"Unrecognized - %s",tag2str(sig));
+ return buf;
+ }
+}
+
+/* Platform Signatures */
+static const char *string_PlatformSignature(icPlatformSignature sig) {
+ static char buf[80];
+ switch(sig) {
+ case icSigMacintosh:
+ return "Macintosh";
+ case icSigMicrosoft:
+ return "Microsoft";
+ case icSigSolaris:
+ return "Solaris";
+ case icSigSGI:
+ return "SGI";
+ case icSigTaligent:
+ return "Taligent";
+ case icmSig_nix:
+ return "*nix";
+ default:
+ sprintf(buf,"Unrecognized - %s",tag2str(sig));
+ return buf;
+ }
+}
+
+/* Measurement Geometry, used in the measurmentType tag */
+static const char *string_MeasurementGeometry(icMeasurementGeometry sig) {
+ static char buf[30];
+ switch(sig) {
+ case icGeometryUnknown:
+ return "Unknown";
+ case icGeometry045or450:
+ return "0/45 or 45/0";
+ case icGeometry0dord0:
+ return "0/d or d/0";
+ default:
+ sprintf(buf,"Unrecognized - 0x%x",sig);
+ return buf;
+ }
+}
+
+/* Rendering Intents, used in the profile header */
+static const char *string_RenderingIntent(icRenderingIntent sig) {
+ static char buf[30];
+ switch(sig) {
+ case icPerceptual:
+ return "Perceptual";
+ case icRelativeColorimetric:
+ return "Relative Colorimetric";
+ case icSaturation:
+ return "Saturation";
+ case icAbsoluteColorimetric:
+ return "Absolute Colorimetric";
+ case icmAbsolutePerceptual: /* icclib specials */
+ return "Absolute Perceptual";
+ case icmAbsoluteSaturation: /* icclib specials */
+ return "Absolute Saturation";
+ case icmDefaultIntent: /* icclib specials */
+ return "Default Intent";
+ default:
+ sprintf(buf,"Unrecognized - 0x%x",sig);
+ return buf;
+ }
+}
+
+/* Transform Lookup function */
+static const char *string_LookupFunc(icmLookupFunc sig) {
+ static char buf[30];
+ switch(sig) {
+ case icmFwd:
+ return "Forward";
+ case icmBwd:
+ return "Backward";
+ case icmGamut:
+ return "Gamut";
+ case icmPreview:
+ return "Preview";
+ default:
+ sprintf(buf,"Unrecognized - 0x%x",sig);
+ return buf;
+ }
+}
+
+
+/* Different Spot Shapes currently defined, used for screeningType */
+static const char *string_SpotShape(icSpotShape sig) {
+ static char buf[30];
+ switch(sig) {
+ case icSpotShapeUnknown:
+ return "Unknown";
+ case icSpotShapePrinterDefault:
+ return "Printer Default";
+ case icSpotShapeRound:
+ return "Round";
+ case icSpotShapeDiamond:
+ return "Diamond";
+ case icSpotShapeEllipse:
+ return "Ellipse";
+ case icSpotShapeLine:
+ return "Line";
+ case icSpotShapeSquare:
+ return "Square";
+ case icSpotShapeCross:
+ return "Cross";
+ default:
+ sprintf(buf,"Unrecognized - 0x%x",sig);
+ return buf;
+ }
+}
+
+/* Standard Observer, used in the measurmentType tag */
+static const char *string_StandardObserver(icStandardObserver sig) {
+ static char buf[30];
+ switch(sig) {
+ case icStdObsUnknown:
+ return "Unknown";
+ case icStdObs1931TwoDegrees:
+ return "1931 Two Degrees";
+ case icStdObs1964TenDegrees:
+ return "1964 Ten Degrees";
+ default:
+ sprintf(buf,"Unrecognized - 0x%x",sig);
+ return buf;
+ }
+}
+
+/* Pre-defined illuminants, used in measurement and viewing conditions type */
+static const char *string_Illuminant(icIlluminant sig) {
+ static char buf[30];
+ switch(sig) {
+ case icIlluminantUnknown:
+ return "Unknown";
+ case icIlluminantD50:
+ return "D50";
+ case icIlluminantD65:
+ return "D65";
+ case icIlluminantD93:
+ return "D93";
+ case icIlluminantF2:
+ return "F2";
+ case icIlluminantD55:
+ return "D55";
+ case icIlluminantA:
+ return "A";
+ case icIlluminantEquiPowerE:
+ return "Equi-Power(E)";
+ case icIlluminantF8:
+ return "F8";
+ default:
+ sprintf(buf,"Unrecognized - 0x%x",sig);
+ return buf;
+ }
+}
+
+/* Return a text abreviation of a color lookup algorithm */
+static const char *string_LuAlg(icmLuAlgType alg) {
+ static char buf[80];
+
+ switch(alg) {
+ case icmMonoFwdType:
+ return "MonoFwd";
+ case icmMonoBwdType:
+ return "MonoBwd";
+ case icmMatrixFwdType:
+ return "MatrixFwd";
+ case icmMatrixBwdType:
+ return "MatrixBwd";
+ case icmLutType:
+ return "Lut";
+ default:
+ sprintf(buf,"Unrecognized - %d",alg);
+ return buf;
+ }
+}
+
+/* Return a string description of the given enumeration value */
+/* Public: */
+const char *icm2str(icmEnumType etype, int enumval) {
+
+ switch(etype) {
+ case icmScreenEncodings:
+ return string_ScreenEncodings((unsigned int) enumval);
+ case icmDeviceAttributes:
+ return string_DeviceAttributes((unsigned int) enumval);
+ case icmProfileHeaderFlags:
+ return string_ProfileHeaderFlags((unsigned int) enumval);
+ case icmAsciiOrBinaryData:
+ return string_AsciiOrBinaryData((unsigned int) enumval);
+ case icmTagSignature:
+ return string_TagSignature((icTagSignature) enumval);
+ case icmTechnologySignature:
+ return string_TechnologySignature((icTechnologySignature) enumval);
+ case icmTypeSignature:
+ return string_TypeSignature((icTagTypeSignature) enumval);
+ case icmColorSpaceSignature:
+ return string_ColorSpaceSignature((icColorSpaceSignature) enumval);
+ case icmProfileClassSignature:
+ return string_ProfileClassSignature((icProfileClassSignature) enumval);
+ case icmPlatformSignature:
+ return string_PlatformSignature((icPlatformSignature) enumval);
+ case icmMeasurementGeometry:
+ return string_MeasurementGeometry((icMeasurementGeometry) enumval);
+ case icmRenderingIntent:
+ return string_RenderingIntent((icRenderingIntent) enumval);
+ case icmTransformLookupFunc:
+ return string_LookupFunc((icmLookupFunc) enumval);
+ case icmSpotShape:
+ return string_SpotShape((icSpotShape) enumval);
+ case icmStandardObserver:
+ return string_StandardObserver((icStandardObserver) enumval);
+ case icmIlluminant:
+ return string_Illuminant((icIlluminant) enumval);
+ case icmLuAlg:
+ return string_LuAlg((icmLuAlgType) enumval);
+ default:
+ return "enum2str got unknown type";
+ }
+}
+
+/* ========================================================== */
+/* Object I/O routines */
+/* ========================================================== */
+/* icmUnknown object */
+
+/* Return the number of bytes needed to write this tag */
+static unsigned int icmUnknown_get_size(
+ icmBase *pp
+) {
+ icmUnknown *p = (icmUnknown *)pp;
+ unsigned int len = 0;
+ len = sat_add(len, 8); /* 8 bytes for tag and padding */
+ len = sat_addmul(len, p->size, 1); /* 1 byte for each unknown data */
+ return len;
+}
+
+/* read the object, return 0 on success, error code on fail */
+static int icmUnknown_read(
+ icmBase *pp,
+ unsigned int len, /* tag length */
+ unsigned int of /* start offset within file */
+) {
+ icmUnknown *p = (icmUnknown *)pp;
+ icc *icp = p->icp;
+ int rv = 0;
+ unsigned int i, size;
+ char *bp, *buf;
+
+ if (len < 8) {
+ sprintf(icp->err,"icmUnknown_read: Tag too small to be legal");
+ return icp->errc = 1;
+ }
+
+ /* Allocate a file read buffer */
+ if ((buf = (char *) icp->al->malloc(icp->al, len)) == NULL) {
+ sprintf(icp->err,"icmUnknown_read: malloc() failed");
+ return icp->errc = 2;
+ }
+ bp = buf;
+
+ /* Read portion of file into buffer */
+ if ( icp->fp->seek(icp->fp, of) != 0
+ || icp->fp->read(icp->fp, bp, 1, len) != len) {
+ sprintf(icp->err,"icmUnknown_read: fseek() or fread() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ p->size = size = (len - 8)/1; /* Number of elements in the array */
+
+ if ((rv = p->allocate((icmBase *)p)) != 0) {
+ icp->al->free(icp->al, buf);
+ return rv;
+ }
+
+ /* Read type descriptor from the buffer */
+ p->uttype = (icTagTypeSignature)read_SInt32Number(bp);
+ bp += 8; /* Skip padding */
+
+ /* Read all the data from the buffer */
+ for (i = 0; i < size; i++, bp += 1) {
+ p->data[i] = read_UInt8Number(bp);
+ }
+ icp->al->free(p->icp->al, buf);
+ return 0;
+}
+
+/* Write the contents of the object. Return 0 on sucess, error code on failure */
+static int icmUnknown_write(
+ icmBase *pp,
+ unsigned int of /* File offset to write from */
+) {
+ icmUnknown *p = (icmUnknown *)pp;
+ icc *icp = p->icp;
+ unsigned int i;
+ unsigned int len;
+ char *bp, *buf; /* Buffer to write from */
+ int rv = 0;
+
+ /* Allocate a file write buffer */
+ if ((len = p->get_size((icmBase *)p)) == UINT_MAX) {
+ sprintf(icp->err,"icmUnknown_write get_size overflow");
+ return icp->errc = 1;
+ }
+ if ((buf = (char *) icp->al->malloc(icp->al, len)) == NULL) {
+ sprintf(icp->err,"icmUnknown_write malloc() failed");
+ return icp->errc = 2;
+ }
+ bp = buf;
+
+ /* Write type descriptor to the buffer */
+ if ((rv = write_SInt32Number((int)p->uttype,bp)) != 0) {
+ sprintf(icp->err,"icmUnknown_write: write_SInt32Number() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+ write_SInt32Number(0,bp+4); /* Set padding to 0 */
+ bp += 8; /* Skip padding */
+
+ /* Write all the data to the buffer */
+ for (i = 0; i < p->size; i++, bp += 1) {
+ if ((rv = write_UInt8Number(p->data[i],bp)) != 0) {
+ sprintf(icp->err,"icmUnknown_write: write_UInt8umber() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+ }
+
+ /* Write to the file */
+ if ( icp->fp->seek(icp->fp, of) != 0
+ || icp->fp->write(icp->fp, buf, 1, len) != len) {
+ sprintf(icp->err,"icmUnknown_write fseek() or fwrite() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 2;
+ }
+ icp->al->free(icp->al, buf);
+ return 0;
+}
+
+/* Dump a text description of the object */
+static void icmUnknown_dump(
+ icmBase *pp,
+ icmFile *op, /* Output to dump to */
+ int verb /* Verbosity level */
+) {
+ icmUnknown *p = (icmUnknown *)pp;
+ unsigned int i, ii, r, ph;
+
+ if (verb <= 1)
+ return;
+
+ op->gprintf(op,"Unknown:\n");
+ op->gprintf(op," Payload size in bytes = %u\n",p->size);
+
+ /* Print one row of binary and ASCII interpretation if verb == 2, All if == 3 */
+ /* else print all of it. */
+ ii = i = ph = 0;
+ for (r = 1;; r++) { /* count rows */
+ int c = 1; /* Character location */
+
+ c = 1;
+ if (ph != 0) { /* Print ASCII under binary */
+ op->gprintf(op," ");
+ i = ii; /* Swap */
+ c += 12;
+ } else {
+ op->gprintf(op," 0x%04lx: ",i);
+ ii = i; /* Swap */
+ c += 12;
+ }
+ while (i < p->size && c < 60) {
+ if (ph == 0)
+ op->gprintf(op,"%02x ",p->data[i]);
+ else {
+ if (isprint(p->data[i]))
+ op->gprintf(op,"%c ",p->data[i]);
+ else
+ op->gprintf(op," ",p->data[i]);
+ }
+ c += 3;
+ i++;
+ }
+ if (ph == 0 || i < p->size)
+ op->gprintf(op,"\n");
+
+ if (ph == 1 && i >= p->size) {
+ op->gprintf(op,"\n");
+ break;
+ }
+ if (ph == 1 && r > 1 && verb < 3) {
+ op->gprintf(op," ...\n");
+ break; /* Print 1 row if not verbose */
+ }
+
+ if (ph == 0)
+ ph = 1;
+ else
+ ph = 0;
+
+ }
+}
+
+/* Allocate variable sized data elements */
+static int icmUnknown_allocate(
+ icmBase *pp
+) {
+ icmUnknown *p = (icmUnknown *)pp;
+ icc *icp = p->icp;
+
+ if (p->size != p->_size) {
+ if (ovr_mul(p->size, sizeof(unsigned char))) {
+ sprintf(icp->err,"icmUnknown_alloc: size overflow");
+ return icp->errc = 1;
+ }
+ if (p->data != NULL)
+ icp->al->free(icp->al, p->data);
+ if ((p->data = (unsigned char *) icp->al->calloc(icp->al, p->size, sizeof(unsigned char)))
+ == NULL) {
+ sprintf(icp->err,"icmUnknown_alloc: malloc() of icmUnknown data failed");
+ return icp->errc = 2;
+ }
+ p->_size = p->size;
+ }
+ return 0;
+}
+
+/* Free all storage in the object */
+static void icmUnknown_delete(
+ icmBase *pp
+) {
+ icmUnknown *p = (icmUnknown *)pp;
+ icc *icp = p->icp;
+
+ if (p->data != NULL)
+ icp->al->free(icp->al, p->data);
+ icp->al->free(icp->al, p);
+}
+
+/* Create an empty object. Return null on error */
+static icmBase *new_icmUnknown(
+ icc *icp
+) {
+ icmUnknown *p;
+ if ((p = (icmUnknown *) icp->al->calloc(icp->al,1,sizeof(icmUnknown))) == NULL)
+ return NULL;
+ p->ttype = icmSigUnknownType;
+ p->uttype = icmSigUnknownType;
+ p->refcount = 1;
+ p->get_size = icmUnknown_get_size;
+ p->read = icmUnknown_read;
+ p->write = icmUnknown_write;
+ p->dump = icmUnknown_dump;
+ p->allocate = icmUnknown_allocate;
+ p->del = icmUnknown_delete;
+ p->icp = icp;
+
+ return (icmBase *)p;
+}
+
+/* ---------------------------------------------------------- */
+/* icmUInt8Array object */
+
+/* Return the number of bytes needed to write this tag */
+static unsigned int icmUInt8Array_get_size(
+ icmBase *pp
+) {
+ icmUInt8Array *p = (icmUInt8Array *)pp;
+ unsigned int len = 0;
+ len = sat_add(len, 8); /* 8 bytes for tag and padding */
+ len = sat_addmul(len, p->size, 1); /* 1 byte for each UInt8 */
+ return len;
+}
+
+/* read the object, return 0 on success, error code on fail */
+static int icmUInt8Array_read(
+ icmBase *pp,
+ unsigned int len, /* tag length */
+ unsigned int of /* start offset within file */
+) {
+ icmUInt8Array *p = (icmUInt8Array *)pp;
+ icc *icp = p->icp;
+ int rv = 0;
+ unsigned int i, size;
+ char *bp, *buf;
+
+ if (len < 8) {
+ sprintf(icp->err,"icmUInt8Array_read: Tag too small to be legal");
+ return icp->errc = 1;
+ }
+
+ /* Allocate a file read buffer */
+ if ((buf = (char *) icp->al->malloc(icp->al, len)) == NULL) {
+ sprintf(icp->err,"icmUInt8Array_read: malloc() failed");
+ return icp->errc = 2;
+ }
+ bp = buf;
+
+ /* Read portion of file into buffer */
+ if ( icp->fp->seek(icp->fp, of) != 0
+ || icp->fp->read(icp->fp, bp, 1, len) != len) {
+ sprintf(icp->err,"icmUInt8Array_read: fseek() or fread() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ p->size = size = (len - 8)/1; /* Number of elements in the array */
+
+ if ((rv = p->allocate((icmBase *)p)) != 0) {
+ icp->al->free(icp->al, buf);
+ return rv;
+ }
+
+ /* Read type descriptor from the buffer */
+ if (((icTagTypeSignature)read_SInt32Number(bp)) != p->ttype) {
+ icp->al->free(icp->al, buf);
+ sprintf(icp->err,"icmUInt8Array_read: Wrong tag type for icmUInt8Array");
+ return icp->errc = 1;
+ }
+ bp += 8; /* Skip padding */
+
+ /* Read all the data from the buffer */
+ for (i = 0; i < size; i++, bp += 1) {
+ p->data[i] = read_UInt8Number(bp);
+ }
+ icp->al->free(p->icp->al, buf);
+ return 0;
+}
+
+/* Write the contents of the object. Return 0 on sucess, error code on failure */
+static int icmUInt8Array_write(
+ icmBase *pp,
+ unsigned int of /* File offset to write from */
+) {
+ icmUInt8Array *p = (icmUInt8Array *)pp;
+ icc *icp = p->icp;
+ unsigned int i;
+ unsigned int len;
+ char *bp, *buf; /* Buffer to write from */
+ int rv = 0;
+
+ /* Allocate a file write buffer */
+ if ((len = p->get_size((icmBase *)p)) == UINT_MAX) {
+ sprintf(icp->err,"icmUInt8Array_write get_size overflow");
+ return icp->errc = 1;
+ }
+ if ((buf = (char *) icp->al->malloc(icp->al, len)) == NULL) {
+ sprintf(icp->err,"icmUInt8Array_write malloc() failed");
+ return icp->errc = 2;
+ }
+ bp = buf;
+
+ /* Write type descriptor to the buffer */
+ if ((rv = write_SInt32Number((int)p->ttype,bp)) != 0) {
+ sprintf(icp->err,"icmUInt8Array_write: write_SInt32Number() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+ write_SInt32Number(0,bp+4); /* Set padding to 0 */
+ bp += 8; /* Skip padding */
+
+ /* Write all the data to the buffer */
+ for (i = 0; i < p->size; i++, bp += 1) {
+ if ((rv = write_UInt8Number(p->data[i],bp)) != 0) {
+ sprintf(icp->err,"icmUInt8Array_write: write_UInt8umber() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+ }
+
+ /* Write to the file */
+ if ( icp->fp->seek(icp->fp, of) != 0
+ || icp->fp->write(icp->fp, buf, 1, len) != len) {
+ sprintf(icp->err,"icmUInt8Array_write fseek() or fwrite() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 2;
+ }
+ icp->al->free(icp->al, buf);
+ return 0;
+}
+
+/* Dump a text description of the object */
+static void icmUInt8Array_dump(
+ icmBase *pp,
+ icmFile *op, /* Output to dump to */
+ int verb /* Verbosity level */
+) {
+ icmUInt8Array *p = (icmUInt8Array *)pp;
+ if (verb <= 0)
+ return;
+
+ op->gprintf(op,"UInt8Array:\n");
+ op->gprintf(op," No. elements = %lu\n",p->size);
+ if (verb >= 2) {
+ unsigned int i;
+ for (i = 0; i < p->size; i++)
+ op->gprintf(op," %lu: %u\n",i,p->data[i]);
+ }
+}
+
+/* Allocate variable sized data elements */
+static int icmUInt8Array_allocate(
+ icmBase *pp
+) {
+ icmUInt8Array *p = (icmUInt8Array *)pp;
+ icc *icp = p->icp;
+
+ if (p->size != p->_size) {
+ if (ovr_mul(p->size, sizeof(unsigned int))) {
+ sprintf(icp->err,"icmUInt8Array_alloc: size overflow");
+ return icp->errc = 1;
+ }
+ if (p->data != NULL)
+ icp->al->free(icp->al, p->data);
+ if ((p->data = (unsigned int *) icp->al->calloc(icp->al, p->size, sizeof(unsigned int)))
+ == NULL) {
+ sprintf(icp->err,"icmUInt8Array_alloc: malloc() of icmUInt8Array data failed");
+ return icp->errc = 2;
+ }
+ p->_size = p->size;
+ }
+ return 0;
+}
+
+/* Free all storage in the object */
+static void icmUInt8Array_delete(
+ icmBase *pp
+) {
+ icmUInt8Array *p = (icmUInt8Array *)pp;
+ icc *icp = p->icp;
+
+ if (p->data != NULL)
+ icp->al->free(icp->al, p->data);
+ icp->al->free(icp->al, p);
+}
+
+/* Create an empty object. Return null on error */
+static icmBase *new_icmUInt8Array(
+ icc *icp
+) {
+ icmUInt8Array *p;
+ if ((p = (icmUInt8Array *) icp->al->calloc(icp->al,1,sizeof(icmUInt8Array))) == NULL)
+ return NULL;
+ p->ttype = icSigUInt8ArrayType;
+ p->refcount = 1;
+ p->get_size = icmUInt8Array_get_size;
+ p->read = icmUInt8Array_read;
+ p->write = icmUInt8Array_write;
+ p->dump = icmUInt8Array_dump;
+ p->allocate = icmUInt8Array_allocate;
+ p->del = icmUInt8Array_delete;
+ p->icp = icp;
+
+ return (icmBase *)p;
+}
+
+/* ---------------------------------------------------------- */
+/* icmUInt16Array object */
+
+/* Return the number of bytes needed to write this tag */
+static unsigned int icmUInt16Array_get_size(
+ icmBase *pp
+) {
+ icmUInt16Array *p = (icmUInt16Array *)pp;
+ unsigned int len = 0;
+ len = sat_add(len, 8); /* 8 bytes for tag and padding */
+ len = sat_addmul(len, p->size, 2); /* 2 bytes for each UInt16 */
+ return len;
+}
+
+/* read the object, return 0 on success, error code on fail */
+static int icmUInt16Array_read(
+ icmBase *pp,
+ unsigned int len, /* tag length */
+ unsigned int of /* start offset within file */
+) {
+ icmUInt16Array *p = (icmUInt16Array *)pp;
+ icc *icp = p->icp;
+ int rv = 0;
+ unsigned int i, size;
+ char *bp, *buf;
+
+ if (len < 8) {
+ sprintf(icp->err,"icmUInt16Array_read: Tag too small to be legal");
+ return icp->errc = 1;
+ }
+
+ /* Allocate a file read buffer */
+ if ((buf = (char *) icp->al->malloc(icp->al, len)) == NULL) {
+ sprintf(icp->err,"icmUInt16Array_read: malloc() failed");
+ return icp->errc = 2;
+ }
+ bp = buf;
+
+ /* Read portion of file into buffer */
+ if ( icp->fp->seek(icp->fp, of) != 0
+ || icp->fp->read(icp->fp, bp, 1, len) != len) {
+ sprintf(icp->err,"icmUInt16Array_read: fseek() or fread() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ p->size = size = (len - 8)/2; /* Number of elements in the array */
+
+ if ((rv = p->allocate((icmBase *)p)) != 0) {
+ icp->al->free(icp->al, buf);
+ return rv;
+ }
+
+ /* Read type descriptor from the buffer */
+ if (((icTagTypeSignature)read_SInt32Number(bp)) != p->ttype) {
+ sprintf(icp->err,"icmUInt16Array_read: Wrong tag type for icmUInt16Array");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ bp += 8; /* Skip padding */
+
+ /* Read all the data from the buffer */
+ for (i = 0; i < size; i++, bp += 2) {
+ p->data[i] = read_UInt16Number(bp);
+ }
+ icp->al->free(icp->al, buf);
+ return 0;
+}
+
+/* Write the contents of the object. Return 0 on sucess, error code on failure */
+static int icmUInt16Array_write(
+ icmBase *pp,
+ unsigned int of /* File offset to write from */
+) {
+ icmUInt16Array *p = (icmUInt16Array *)pp;
+ icc *icp = p->icp;
+ unsigned int i;
+ unsigned int len;
+ char *bp, *buf; /* Buffer to write from */
+ int rv = 0;
+
+ /* Allocate a file write buffer */
+ if ((len = p->get_size((icmBase *)p)) == UINT_MAX) {
+ sprintf(icp->err,"icmUInt16Array_write get_size overflow");
+ return icp->errc = 1;
+ }
+ if ((buf = (char *) icp->al->malloc(icp->al, len)) == NULL) {
+ sprintf(icp->err,"icmUInt16Array_write malloc() failed");
+ return icp->errc = 2;
+ }
+ bp = buf;
+
+ /* Write type descriptor to the buffer */
+ if ((rv = write_SInt32Number((int)p->ttype,bp)) != 0) {
+ sprintf(icp->err,"icmUInt16Array_write: write_SInt32Number() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+ write_SInt32Number(0,bp+4); /* Set padding to 0 */
+
+ /* Write all the data to the buffer */
+ bp += 8; /* Skip padding */
+ for (i = 0; i < p->size; i++, bp += 2) {
+ if ((rv = write_UInt16Number(p->data[i],bp)) != 0) {
+ sprintf(icp->err,"icmUInt16Array_write: write_UInt16umber() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+ }
+
+ /* Write to the file */
+ if ( icp->fp->seek(icp->fp, of) != 0
+ || icp->fp->write(icp->fp, buf, 1, len) != len) {
+ sprintf(icp->err,"icmUInt16Array_write fseek() or fwrite() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 2;
+ }
+ icp->al->free(icp->al, buf);
+ return 0;
+}
+
+/* Dump a text description of the object */
+static void icmUInt16Array_dump(
+ icmBase *pp,
+ icmFile *op, /* Output to dump to */
+ int verb /* Verbosity level */
+) {
+ icmUInt16Array *p = (icmUInt16Array *)pp;
+ if (verb <= 0)
+ return;
+
+ op->gprintf(op,"UInt16Array:\n");
+ op->gprintf(op," No. elements = %lu\n",p->size);
+ if (verb >= 2) {
+ unsigned int i;
+ for (i = 0; i < p->size; i++)
+ op->gprintf(op," %lu: %u\n",i,p->data[i]);
+ }
+}
+
+/* Allocate variable sized data elements */
+static int icmUInt16Array_allocate(
+ icmBase *pp
+) {
+ icmUInt16Array *p = (icmUInt16Array *)pp;
+ icc *icp = p->icp;
+
+ if (p->size != p->_size) {
+ if (ovr_mul(p->size, sizeof(unsigned int))) {
+ sprintf(icp->err,"icmUInt16Array_alloc:: size overflow");
+ return icp->errc = 1;
+ }
+ if (p->data != NULL)
+ icp->al->free(icp->al, p->data);
+ if ((p->data = (unsigned int *) icp->al->calloc(icp->al, p->size, sizeof(unsigned int)))
+ == NULL) {
+ sprintf(icp->err,"icmUInt16Array_alloc: malloc() of icmUInt16Array data failed");
+ return icp->errc = 2;
+ }
+ p->_size = p->size;
+ }
+ return 0;
+}
+
+/* Free all storage in the object */
+static void icmUInt16Array_delete(
+ icmBase *pp
+) {
+ icmUInt16Array *p = (icmUInt16Array *)pp;
+ icc *icp = p->icp;
+
+ if (p->data != NULL)
+ icp->al->free(icp->al, p->data);
+ icp->al->free(icp->al, p);
+}
+
+/* Create an empty object. Return null on error */
+static icmBase *new_icmUInt16Array(
+ icc *icp
+) {
+ icmUInt16Array *p;
+ if ((p = (icmUInt16Array *) icp->al->calloc(icp->al,1,sizeof(icmUInt16Array))) == NULL)
+ return NULL;
+ p->ttype = icSigUInt16ArrayType;
+ p->refcount = 1;
+ p->get_size = icmUInt16Array_get_size;
+ p->read = icmUInt16Array_read;
+ p->write = icmUInt16Array_write;
+ p->dump = icmUInt16Array_dump;
+ p->allocate = icmUInt16Array_allocate;
+ p->del = icmUInt16Array_delete;
+ p->icp = icp;
+
+ return (icmBase *)p;
+}
+
+/* ---------------------------------------------------------- */
+/* icmUInt32Array object */
+
+/* Return the number of bytes needed to write this tag */
+static unsigned int icmUInt32Array_get_size(
+ icmBase *pp
+) {
+ icmUInt32Array *p = (icmUInt32Array *)pp;
+ unsigned int len = 0;
+ len = sat_add(len, 8); /* 8 bytes for tag and padding */
+ len = sat_addmul(len, p->size, 4); /* 4 bytes for each UInt32 */
+ return len;
+}
+
+/* read the object, return 0 on success, error code on fail */
+static int icmUInt32Array_read(
+ icmBase *pp,
+ unsigned int len, /* tag length */
+ unsigned int of /* start offset within file */
+) {
+ icmUInt32Array *p = (icmUInt32Array *)pp;
+ icc *icp = p->icp;
+ int rv = 0;
+ unsigned int i, size;
+ char *bp, *buf;
+
+ if (len < 8) {
+ sprintf(icp->err,"icmUInt32Array_read: Tag too small to be legal");
+ return icp->errc = 1;
+ }
+
+ /* Allocate a file read buffer */
+ if ((buf = (char *) icp->al->malloc(icp->al, len)) == NULL) {
+ sprintf(icp->err,"icmUInt32Array_read: malloc() failed");
+ return icp->errc = 2;
+ }
+ bp = buf;
+
+ /* Read portion of file into buffer */
+ if ( icp->fp->seek(icp->fp, of) != 0
+ || icp->fp->read(icp->fp, bp, 1, len) != len) {
+ sprintf(icp->err,"icmUInt32Array_read: fseek() or fread() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ p->size = size = (len - 8)/4; /* Number of elements in the array */
+
+ if ((rv = p->allocate((icmBase *)p)) != 0) {
+ icp->al->free(icp->al, buf);
+ return rv;
+ }
+
+ /* Read type descriptor from the buffer */
+ if (((icTagTypeSignature)read_SInt32Number(bp)) != p->ttype) {
+ sprintf(icp->err,"icmUInt32Array_read: Wrong tag type for icmUInt32Array");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ bp += 8; /* Skip padding */
+
+ /* Read all the data from the buffer */
+ for (i = 0; i < size; i++, bp += 4) {
+ p->data[i] = read_UInt32Number(bp);
+ }
+ icp->al->free(icp->al, buf);
+ return 0;
+}
+
+/* Write the contents of the object. Return 0 on sucess, error code on failure */
+static int icmUInt32Array_write(
+ icmBase *pp,
+ unsigned int of /* File offset to write from */
+) {
+ icmUInt32Array *p = (icmUInt32Array *)pp;
+ icc *icp = p->icp;
+ unsigned int i;
+ unsigned int len;
+ char *bp, *buf; /* Buffer to write from */
+ int rv = 0;
+
+ /* Allocate a file write buffer */
+ if ((len = p->get_size((icmBase *)p)) == UINT_MAX) {
+ sprintf(icp->err,"icmUInt32Array_write get_size overflow");
+ return icp->errc = 1;
+ }
+ if ((buf = (char *) icp->al->malloc(icp->al, len)) == NULL) {
+ sprintf(icp->err,"icmUInt32Array_write malloc() failed");
+ return icp->errc = 2;
+ }
+ bp = buf;
+
+ /* Write type descriptor to the buffer */
+ if ((rv = write_SInt32Number((int)p->ttype,bp)) != 0) {
+ sprintf(icp->err,"icmUInt32Array_write: write_SInt32Number() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+ write_SInt32Number(0,bp+4); /* Set padding to 0 */
+
+ /* Write all the data to the buffer */
+ bp += 8; /* Skip padding */
+ for (i = 0; i < p->size; i++, bp += 4) {
+ if ((rv = write_UInt32Number(p->data[i],bp)) != 0) {
+ sprintf(icp->err,"icmUInt32Array_write: write_UInt32umber() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+ }
+
+ /* Write to the file */
+ if ( icp->fp->seek(icp->fp, of) != 0
+ || icp->fp->write(icp->fp, buf, 1, len) != len) {
+ sprintf(icp->err,"icmUInt32Array_write fseek() or fwrite() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 2;
+ }
+ icp->al->free(icp->al, buf);
+ return 0;
+}
+
+/* Dump a text description of the object */
+static void icmUInt32Array_dump(
+ icmBase *pp,
+ icmFile *op, /* Output to dump to */
+ int verb /* Verbosity level */
+) {
+ icmUInt32Array *p = (icmUInt32Array *)pp;
+ if (verb <= 0)
+ return;
+
+ op->gprintf(op,"UInt32Array:\n");
+ op->gprintf(op," No. elements = %lu\n",p->size);
+ if (verb >= 2) {
+ unsigned int i;
+ for (i = 0; i < p->size; i++)
+ op->gprintf(op," %lu: %u\n",i,p->data[i]);
+ }
+}
+
+/* Allocate variable sized data elements */
+static int icmUInt32Array_allocate(
+ icmBase *pp
+) {
+ icmUInt32Array *p = (icmUInt32Array *)pp;
+ icc *icp = p->icp;
+
+ if (p->size != p->_size) {
+ if (ovr_mul(p->size, sizeof(unsigned int))) {
+ sprintf(icp->err,"icmUInt32Array_alloc: size overflow");
+ return icp->errc = 1;
+ }
+ if (p->data != NULL)
+ icp->al->free(icp->al, p->data);
+ if ((p->data = (unsigned int *) icp->al->calloc(icp->al, p->size, sizeof(unsigned int)))
+ == NULL) {
+ sprintf(icp->err,"icmUInt32Array_alloc: malloc() of icmUInt32Array data failed");
+ return icp->errc = 2;
+ }
+ p->_size = p->size;
+ }
+ return 0;
+}
+
+/* Free all storage in the object */
+static void icmUInt32Array_delete(
+ icmBase *pp
+) {
+ icmUInt32Array *p = (icmUInt32Array *)pp;
+ icc *icp = p->icp;
+
+ if (p->data != NULL)
+ icp->al->free(icp->al, p->data);
+ icp->al->free(icp->al, p);
+}
+
+/* Create an empty object. Return null on error */
+static icmBase *new_icmUInt32Array(
+ icc *icp
+) {
+ icmUInt32Array *p;
+ if ((p = (icmUInt32Array *) icp->al->calloc(icp->al,1,sizeof(icmUInt32Array))) == NULL)
+ return NULL;
+ p->ttype = icSigUInt32ArrayType;
+ p->refcount = 1;
+ p->get_size = icmUInt32Array_get_size;
+ p->read = icmUInt32Array_read;
+ p->write = icmUInt32Array_write;
+ p->dump = icmUInt32Array_dump;
+ p->allocate = icmUInt32Array_allocate;
+ p->del = icmUInt32Array_delete;
+ p->icp = icp;
+
+ return (icmBase *)p;
+}
+
+/* ---------------------------------------------------------- */
+/* icmUInt64Array object */
+
+/* Return the number of bytes needed to write this tag */
+static unsigned int icmUInt64Array_get_size(
+ icmBase *pp
+) {
+ icmUInt64Array *p = (icmUInt64Array *)pp;
+ unsigned int len = 0;
+ len = sat_add(len, 8); /* 8 bytes for tag and padding */
+ len = sat_addmul(len, p->size, 8); /* 8 bytes for each UInt64 */
+ return len;
+}
+
+/* read the object, return 0 on success, error code on fail */
+static int icmUInt64Array_read(
+ icmBase *pp,
+ unsigned int len, /* tag length */
+ unsigned int of /* start offset within file */
+) {
+ icmUInt64Array *p = (icmUInt64Array *)pp;
+ icc *icp = p->icp;
+ int rv = 0;
+ unsigned int i, size;
+ char *bp, *buf;
+
+ if (len < 8) {
+ sprintf(icp->err,"icmUInt64Array_read: Tag too small to be legal");
+ return icp->errc = 1;
+ }
+
+ /* Allocate a file read buffer */
+ if ((buf = (char *) icp->al->malloc(icp->al, len)) == NULL) {
+ sprintf(icp->err,"icmUInt64Array_read: malloc() failed");
+ return icp->errc = 2;
+ }
+ bp = buf;
+
+ /* Read portion of file into buffer */
+ if ( icp->fp->seek(icp->fp, of) != 0
+ || icp->fp->read(icp->fp, bp, 1, len) != len) {
+ sprintf(icp->err,"icmUInt64Array_read: fseek() or fread() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ p->size = size = (len - 8)/8; /* Number of elements in the array */
+
+ if ((rv = p->allocate((icmBase *)p)) != 0) {
+ icp->al->free(icp->al, buf);
+ return rv;
+ }
+
+ /* Read type descriptor from the buffer */
+ if (((icTagTypeSignature)read_SInt32Number(bp)) != p->ttype) {
+ sprintf(icp->err,"icmUInt64Array_read: Wrong tag type for icmUInt64Array");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ bp += 8; /* Skip padding */
+
+ /* Read all the data from the buffer */
+ for (i = 0; i < size; i++, bp += 8) {
+ read_UInt64Number(&p->data[i], bp);
+ }
+ icp->al->free(icp->al, buf);
+ return 0;
+}
+
+/* Write the contents of the object. Return 0 on sucess, error code on failure */
+static int icmUInt64Array_write(
+ icmBase *pp,
+ unsigned int of /* File offset to write from */
+) {
+ icmUInt64Array *p = (icmUInt64Array *)pp;
+ icc *icp = p->icp;
+ unsigned int i;
+ unsigned int len;
+ char *bp, *buf; /* Buffer to write from */
+ int rv = 0;
+
+ /* Allocate a file write buffer */
+ if ((len = p->get_size((icmBase *)p)) == UINT_MAX) {
+ sprintf(icp->err,"icmUInt64Array_write get_size overflow");
+ return icp->errc = 1;
+ }
+ if ((buf = (char *) icp->al->malloc(icp->al, len)) == NULL) {
+ sprintf(icp->err,"icmUInt64Array_write malloc() failed");
+ return icp->errc = 2;
+ }
+ bp = buf;
+
+ /* Write type descriptor to the buffer */
+ if ((rv = write_SInt32Number((int)p->ttype,bp)) != 0) {
+ sprintf(icp->err,"icmUInt64Array_write: write_SInt32Number() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+ write_SInt32Number(0,bp+4); /* Set padding to 0 */
+
+ /* Write all the data to the buffer */
+ bp += 8; /* Skip padding */
+ for (i = 0; i < p->size; i++, bp += 8) {
+ if ((rv = write_UInt64Number(&p->data[i],bp)) != 0) {
+ sprintf(icp->err,"icmUInt64Array_write: write_UInt64umber() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+ }
+
+ /* Write to the file */
+ if ( icp->fp->seek(icp->fp, of) != 0
+ || icp->fp->write(icp->fp, buf, 1, len) != len) {
+ sprintf(icp->err,"icmUInt64Array_write fseek() or fwrite() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 2;
+ }
+ icp->al->free(icp->al, buf);
+ return 0;
+}
+
+/* Dump a text description of the object */
+static void icmUInt64Array_dump(
+ icmBase *pp,
+ icmFile *op, /* Output to dump to */
+ int verb /* Verbosity level */
+) {
+ icmUInt64Array *p = (icmUInt64Array *)pp;
+ if (verb <= 0)
+ return;
+
+ op->gprintf(op,"UInt64Array:\n");
+ op->gprintf(op," No. elements = %lu\n",p->size);
+ if (verb >= 2) {
+ unsigned int i;
+ for (i = 0; i < p->size; i++)
+ op->gprintf(op," %lu: h=%lu, l=%lu\n",i,p->data[i].h,p->data[i].l);
+ }
+}
+
+/* Allocate variable sized data elements */
+static int icmUInt64Array_allocate(
+ icmBase *pp
+) {
+ icmUInt64Array *p = (icmUInt64Array *)pp;
+ icc *icp = p->icp;
+
+ if (p->size != p->_size) {
+ if (ovr_mul(p->size, sizeof(icmUint64))) {
+ sprintf(icp->err,"icmUInt64Array_alloc: size overflow");
+ return icp->errc = 1;
+ }
+ if (p->data != NULL)
+ icp->al->free(icp->al, p->data);
+ if ((p->data = (icmUint64 *) icp->al->calloc(icp->al, p->size, sizeof(icmUint64)))
+ == NULL) {
+ sprintf(icp->err,"icmUInt64Array_alloc: malloc() of icmUInt64Array data failed");
+ return icp->errc = 2;
+ }
+ p->_size = p->size;
+ }
+ return 0;
+}
+
+/* Free all storage in the object */
+static void icmUInt64Array_delete(
+ icmBase *pp
+) {
+ icmUInt64Array *p = (icmUInt64Array *)pp;
+ icc *icp = p->icp;
+
+ if (p->data != NULL)
+ icp->al->free(icp->al, p->data);
+ icp->al->free(icp->al, p);
+}
+
+/* Create an empty object. Return null on error */
+static icmBase *new_icmUInt64Array(
+ icc *icp
+) {
+ icmUInt64Array *p;
+ if ((p = (icmUInt64Array *) icp->al->calloc(icp->al,1,sizeof(icmUInt64Array))) == NULL)
+ return NULL;
+ p->ttype = icSigUInt64ArrayType;
+ p->refcount = 1;
+ p->get_size = icmUInt64Array_get_size;
+ p->read = icmUInt64Array_read;
+ p->write = icmUInt64Array_write;
+ p->dump = icmUInt64Array_dump;
+ p->allocate = icmUInt64Array_allocate;
+ p->del = icmUInt64Array_delete;
+ p->icp = icp;
+
+ return (icmBase *)p;
+}
+
+/* ---------------------------------------------------------- */
+/* icmU16Fixed16Array object */
+
+/* Return the number of bytes needed to write this tag */
+static unsigned int icmU16Fixed16Array_get_size(
+ icmBase *pp
+) {
+ icmU16Fixed16Array *p = (icmU16Fixed16Array *)pp;
+ unsigned int len = 0;
+ len = sat_add(len, 8); /* 8 bytes for tag and padding */
+ len = sat_addmul(len, p->size, 4); /* 4 byte for each U16Fixed16 */
+ return len;
+}
+
+/* read the object, return 0 on success, error code on fail */
+static int icmU16Fixed16Array_read(
+ icmBase *pp,
+ unsigned int len, /* tag length */
+ unsigned int of /* start offset within file */
+) {
+ icmU16Fixed16Array *p = (icmU16Fixed16Array *)pp;
+ icc *icp = p->icp;
+ int rv = 0;
+ unsigned int i, size;
+ char *bp, *buf;
+
+ if (len < 8) {
+ sprintf(icp->err,"icmU16Fixed16Array_read: Tag too small to be legal");
+ return icp->errc = 1;
+ }
+
+ /* Allocate a file read buffer */
+ if ((buf = (char *) icp->al->malloc(icp->al, len)) == NULL) {
+ sprintf(icp->err,"icmU16Fixed16Array_read: malloc() failed");
+ return icp->errc = 2;
+ }
+ bp = buf;
+
+ /* Read portion of file into buffer */
+ if ( icp->fp->seek(icp->fp, of) != 0
+ || icp->fp->read(icp->fp, bp, 1, len) != len) {
+ sprintf(icp->err,"icmU16Fixed16Array_read: fseek() or fread() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ p->size = size = (len - 8)/4; /* Number of elements in the array */
+
+ if ((rv = p->allocate((icmBase *)p)) != 0) {
+ icp->al->free(icp->al, buf);
+ return rv;
+ }
+
+ /* Read type descriptor from the buffer */
+ if (((icTagTypeSignature)read_SInt32Number(bp)) != p->ttype) {
+ sprintf(icp->err,"icmU16Fixed16Array_read: Wrong tag type for icmU16Fixed16Array");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ bp += 8; /* Skip padding */
+
+ /* Read all the data from the buffer */
+ for (i = 0; i < size; i++, bp += 4) {
+ p->data[i] = read_U16Fixed16Number(bp);
+ }
+ icp->al->free(icp->al, buf);
+ return 0;
+}
+
+/* Write the contents of the object. Return 0 on sucess, error code on failure */
+static int icmU16Fixed16Array_write(
+ icmBase *pp,
+ unsigned int of /* File offset to write from */
+) {
+ icmU16Fixed16Array *p = (icmU16Fixed16Array *)pp;
+ icc *icp = p->icp;
+ unsigned int i;
+ unsigned int len;
+ char *bp, *buf; /* Buffer to write from */
+ int rv = 0;
+
+ /* Allocate a file write buffer */
+ if ((len = p->get_size((icmBase *)p)) == UINT_MAX) {
+ sprintf(icp->err,"icmU16Fixed16Array_write get_size overflow");
+ return icp->errc = 1;
+ }
+ if ((buf = (char *) icp->al->malloc(icp->al, len)) == NULL) {
+ sprintf(icp->err,"icmU16Fixed16Array_write malloc() failed");
+ return icp->errc = 2;
+ }
+ bp = buf;
+
+ /* Write type descriptor to the buffer */
+ if ((rv = write_SInt32Number((int)p->ttype,bp)) != 0) {
+ sprintf(icp->err,"icmU16Fixed16Array_write: write_SInt32Number() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+ write_SInt32Number(0,bp+4); /* Set padding to 0 */
+
+ /* Write all the data to the buffer */
+ bp += 8; /* Skip padding */
+ for (i = 0; i < p->size; i++, bp += 4) {
+ if ((rv = write_U16Fixed16Number(p->data[i],bp)) != 0) {
+ sprintf(icp->err,"icmU16Fixed16Array_write: write_U16Fixed16umber() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+ }
+
+ /* Write to the file */
+ if ( icp->fp->seek(icp->fp, of) != 0
+ || icp->fp->write(icp->fp, buf, 1, len) != len) {
+ sprintf(icp->err,"icmU16Fixed16Array_write fseek() or fwrite() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 2;
+ }
+ icp->al->free(icp->al, buf);
+ return 0;
+}
+
+/* Dump a text description of the object */
+static void icmU16Fixed16Array_dump(
+ icmBase *pp,
+ icmFile *op, /* Output to dump to */
+ int verb /* Verbosity level */
+) {
+ icmU16Fixed16Array *p = (icmU16Fixed16Array *)pp;
+ if (verb <= 0)
+ return;
+
+ op->gprintf(op,"U16Fixed16Array:\n");
+ op->gprintf(op," No. elements = %lu\n",p->size);
+ if (verb >= 2) {
+ unsigned int i;
+ for (i = 0; i < p->size; i++)
+ op->gprintf(op," %lu: %f\n",i,p->data[i]);
+ }
+}
+
+/* Allocate variable sized data elements */
+static int icmU16Fixed16Array_allocate(
+ icmBase *pp
+) {
+ icmU16Fixed16Array *p = (icmU16Fixed16Array *)pp;
+ icc *icp = p->icp;
+
+ if (p->size != p->_size) {
+ if (ovr_mul(p->size, sizeof(double))) {
+ sprintf(icp->err,"icmU16Fixed16Array_alloc: size overflow");
+ return icp->errc = 1;
+ }
+ if (p->data != NULL)
+ icp->al->free(icp->al, p->data);
+ if ((p->data = (double *) icp->al->calloc(icp->al, p->size, sizeof(double))) == NULL) {
+ sprintf(icp->err,"icmU16Fixed16Array_alloc: malloc() of icmU16Fixed16Array data failed");
+ return icp->errc = 2;
+ }
+ p->_size = p->size;
+ }
+ return 0;
+}
+
+/* Free all storage in the object */
+static void icmU16Fixed16Array_delete(
+ icmBase *pp
+) {
+ icmU16Fixed16Array *p = (icmU16Fixed16Array *)pp;
+ icc *icp = p->icp;
+
+ if (p->data != NULL)
+ icp->al->free(icp->al, p->data);
+ icp->al->free(icp->al, p);
+}
+
+/* Create an empty object. Return null on error */
+static icmBase *new_icmU16Fixed16Array(
+ icc *icp
+) {
+ icmU16Fixed16Array *p;
+ if ((p = (icmU16Fixed16Array *) icp->al->calloc(icp->al,1,sizeof(icmU16Fixed16Array))) == NULL)
+ return NULL;
+ p->ttype = icSigU16Fixed16ArrayType;
+ p->refcount = 1;
+ p->get_size = icmU16Fixed16Array_get_size;
+ p->read = icmU16Fixed16Array_read;
+ p->write = icmU16Fixed16Array_write;
+ p->dump = icmU16Fixed16Array_dump;
+ p->allocate = icmU16Fixed16Array_allocate;
+ p->del = icmU16Fixed16Array_delete;
+ p->icp = icp;
+
+ return (icmBase *)p;
+}
+
+/* ---------------------------------------------------------- */
+/* icmS15Fixed16Array object */
+
+/* Return the number of bytes needed to write this tag */
+static unsigned int icmS15Fixed16Array_get_size(
+ icmBase *pp
+) {
+ icmS15Fixed16Array *p = (icmS15Fixed16Array *)pp;
+ unsigned int len = 0;
+ len = sat_add(len, 8); /* 8 bytes for tag and padding */
+ len = sat_addmul(len, p->size, 4); /* 4 byte for each S15Fixed16 */
+ return len;
+}
+
+/* read the object, return 0 on success, error code on fail */
+static int icmS15Fixed16Array_read(
+ icmBase *pp,
+ unsigned int len, /* tag length */
+ unsigned int of /* start offset within file */
+) {
+ icmS15Fixed16Array *p = (icmS15Fixed16Array *)pp;
+ icc *icp = p->icp;
+ int rv = 0;
+ unsigned int i, size;
+ char *bp, *buf;
+
+ if (len < 8) {
+ sprintf(icp->err,"icmS15Fixed16Array_read: Tag too small to be legal");
+ return icp->errc = 1;
+ }
+
+ /* Allocate a file read buffer */
+ if ((buf = (char *) icp->al->malloc(icp->al, len)) == NULL) {
+ sprintf(icp->err,"icmS15Fixed16Array_read: malloc() failed");
+ return icp->errc = 2;
+ }
+ bp = buf;
+
+ /* Read portion of file into buffer */
+ if ( icp->fp->seek(icp->fp, of) != 0
+ || icp->fp->read(icp->fp, bp, 1, len) != len) {
+ sprintf(icp->err,"icmS15Fixed16Array_read: fseek() or fread() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ p->size = size = (len - 8)/4; /* Number of elements in the array */
+
+ if ((rv = p->allocate((icmBase *)p)) != 0) {
+ icp->al->free(icp->al, buf);
+ return rv;
+ }
+
+ /* Read type descriptor from the buffer */
+ if (((icTagTypeSignature)read_SInt32Number(bp)) != p->ttype) {
+ sprintf(icp->err,"icmS15Fixed16Array_read: Wrong tag type for icmS15Fixed16Array");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ bp += 8; /* Skip padding */
+
+ /* Read all the data from the buffer */
+ for (i = 0; i < size; i++, bp += 4) {
+ p->data[i] = read_S15Fixed16Number(bp);
+ }
+ icp->al->free(icp->al, buf);
+ return 0;
+}
+
+/* Write the contents of the object. Return 0 on sucess, error code on failure */
+static int icmS15Fixed16Array_write(
+ icmBase *pp,
+ unsigned int of /* File offset to write from */
+) {
+ icmS15Fixed16Array *p = (icmS15Fixed16Array *)pp;
+ icc *icp = p->icp;
+ unsigned int i;
+ unsigned int len;
+ char *bp, *buf; /* Buffer to write from */
+ int rv = 0;
+
+ /* Allocate a file write buffer */
+ if ((len = p->get_size((icmBase *)p)) == UINT_MAX) {
+ sprintf(icp->err,"icmS15Fixed16Array_write get_size overflow");
+ return icp->errc = 1;
+ }
+ if ((buf = (char *) icp->al->malloc(icp->al, len)) == NULL) {
+ sprintf(icp->err,"icmS15Fixed16Array_write malloc() failed");
+ return icp->errc = 2;
+ }
+ bp = buf;
+
+ /* Write type descriptor to the buffer */
+ if ((rv = write_SInt32Number((int)p->ttype,bp)) != 0) {
+ sprintf(icp->err,"icmS15Fixed16Array_write: write_SInt32Number() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+ write_SInt32Number(0,bp+4); /* Set padding to 0 */
+
+ /* Write all the data to the buffer */
+ bp += 8; /* Skip padding */
+ for (i = 0; i < p->size; i++, bp += 4) {
+ if ((rv = write_S15Fixed16Number(p->data[i],bp)) != 0) {
+ sprintf(icp->err,"icmS15Fixed16Array_write: write_S15Fixed16umber() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+ }
+
+ /* Write to the file */
+ if ( icp->fp->seek(icp->fp, of) != 0
+ || icp->fp->write(icp->fp, buf, 1, len) != len) {
+ sprintf(icp->err,"icmS15Fixed16Array_write fseek() or fwrite() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 2;
+ }
+ icp->al->free(icp->al, buf);
+ return 0;
+}
+
+/* Dump a text description of the object */
+static void icmS15Fixed16Array_dump(
+ icmBase *pp,
+ icmFile *op, /* Output to dump to */
+ int verb /* Verbosity level */
+) {
+ icmS15Fixed16Array *p = (icmS15Fixed16Array *)pp;
+ if (verb <= 0)
+ return;
+
+ op->gprintf(op,"S15Fixed16Array:\n");
+ op->gprintf(op," No. elements = %lu\n",p->size);
+ if (verb >= 2) {
+ unsigned int i;
+ for (i = 0; i < p->size; i++)
+ op->gprintf(op," %lu: %f\n",i,p->data[i]);
+ }
+}
+
+/* Allocate variable sized data elements */
+static int icmS15Fixed16Array_allocate(
+ icmBase *pp
+) {
+ icmS15Fixed16Array *p = (icmS15Fixed16Array *)pp;
+ icc *icp = p->icp;
+
+ if (p->size != p->_size) {
+ if (ovr_mul(p->size, sizeof(double))) {
+ sprintf(icp->err,"icmS15Fixed16Array_alloc: size overflow");
+ return icp->errc = 1;
+ }
+ if (p->data != NULL)
+ icp->al->free(icp->al, p->data);
+ if ((p->data = (double *) icp->al->calloc(icp->al, p->size, sizeof(double))) == NULL) {
+ sprintf(icp->err,"icmS15Fixed16Array_alloc: malloc() of icmS15Fixed16Array data failed");
+ return icp->errc = 2;
+ }
+ p->_size = p->size;
+ }
+ return 0;
+}
+
+/* Free all storage in the object */
+static void icmS15Fixed16Array_delete(
+ icmBase *pp
+) {
+ icmS15Fixed16Array *p = (icmS15Fixed16Array *)pp;
+ icc *icp = p->icp;
+
+ if (p->data != NULL)
+ icp->al->free(icp->al, p->data);
+ icp->al->free(icp->al, p);
+}
+
+/* Create an empty object. Return null on error */
+static icmBase *new_icmS15Fixed16Array(
+ icc *icp
+) {
+ icmS15Fixed16Array *p;
+ if ((p = (icmS15Fixed16Array *) icp->al->calloc(icp->al,1,sizeof(icmS15Fixed16Array))) == NULL)
+ return NULL;
+ p->ttype = icSigS15Fixed16ArrayType;
+ p->refcount = 1;
+ p->get_size = icmS15Fixed16Array_get_size;
+ p->read = icmS15Fixed16Array_read;
+ p->write = icmS15Fixed16Array_write;
+ p->dump = icmS15Fixed16Array_dump;
+ p->allocate = icmS15Fixed16Array_allocate;
+ p->del = icmS15Fixed16Array_delete;
+ p->icp = icp;
+
+ return (icmBase *)p;
+}
+
+/* ---------------------------------------------------------- */
+
+/* Data conversion support functions */
+static int write_XYZNumber(icmXYZNumber *p, char *d) {
+ int rv;
+ if ((rv = write_S15Fixed16Number(p->X, d + 0)) != 0)
+ return rv;
+ if ((rv = write_S15Fixed16Number(p->Y, d + 4)) != 0)
+ return rv;
+ if ((rv = write_S15Fixed16Number(p->Z, d + 8)) != 0)
+ return rv;
+ return 0;
+}
+
+static int read_XYZNumber(icmXYZNumber *p, char *d) {
+ p->X = read_S15Fixed16Number(d + 0);
+ p->Y = read_S15Fixed16Number(d + 4);
+ p->Z = read_S15Fixed16Number(d + 8);
+ return 0;
+}
+
+
+/* Helper: Return a string that shows the XYZ number value */
+static char *string_XYZNumber(icmXYZNumber *p) {
+ static char buf[40];
+
+ sprintf(buf,"%f, %f, %f", p->X, p->Y, p->Z);
+ return buf;
+}
+
+/* Helper: Return a string that shows the XYZ number value, */
+/* and the Lab D50 number in paren. Note the buffer will be re-used on every call. */
+static char *string_XYZNumber_and_Lab(icmXYZNumber *p) {
+ static char buf[100];
+ double lab[3];
+ lab[0] = p->X;
+ lab[1] = p->Y;
+ lab[2] = p->Z;
+ icmXYZ2Lab(&icmD50, lab, lab);
+ snprintf(buf,sizeof(buf),"%f, %f, %f [Lab %f, %f, %f]", p->X, p->Y, p->Z, lab[0], lab[1], lab[2]);
+ return buf;
+}
+
+/* icmXYZArray object */
+
+/* Return the number of bytes needed to write this tag */
+static unsigned int icmXYZArray_get_size(
+ icmBase *pp
+) {
+ icmXYZArray *p = (icmXYZArray *)pp;
+ unsigned int len = 0;
+ len = sat_add(len, 8); /* 8 bytes for tag and padding */
+ len = sat_addmul(len, p->size, 12); /* 12 bytes for each XYZ */
+ return len;
+}
+
+/* read the object, return 0 on success, error code on fail */
+static int icmXYZArray_read(
+ icmBase *pp,
+ unsigned int len, /* tag length */
+ unsigned int of /* start offset within file */
+) {
+ icmXYZArray *p = (icmXYZArray *)pp;
+ icc *icp = p->icp;
+ int rv = 0;
+ unsigned int i, size;
+ char *bp, *buf;
+
+ if (len < 8) {
+ sprintf(icp->err,"icmXYZArray_read: Tag too small to be legal");
+ return icp->errc = 1;
+ }
+
+ /* Allocate a file read buffer */
+ if ((buf = (char *) icp->al->malloc(icp->al, len)) == NULL) {
+ sprintf(icp->err,"icmXYZArray_read: malloc() failed");
+ return icp->errc = 2;
+ }
+ bp = buf;
+
+ /* Read portion of file into buffer */
+ if ( icp->fp->seek(icp->fp, of) != 0
+ || icp->fp->read(icp->fp, bp, 1, len) != len) {
+ sprintf(icp->err,"icmXYZArray_read: fseek() or fread() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ p->size = size = (len - 8)/12; /* Number of elements in the array */
+
+ if ((rv = p->allocate((icmBase *)p)) != 0) {
+ icp->al->free(icp->al, buf);
+ return rv;
+ }
+
+ /* Read type descriptor from the buffer */
+ if (((icTagTypeSignature)read_SInt32Number(bp)) != p->ttype) {
+ sprintf(icp->err,"icmXYZArray_read: Wrong tag type for icmXYZArray");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ bp += 8; /* Skip padding */
+
+ /* Read all the data from the buffer */
+ for (i = 0; i < size; i++, bp += 12) {
+ read_XYZNumber(&p->data[i], bp);
+ }
+ icp->al->free(icp->al, buf);
+ return 0;
+}
+
+/* Write the contents of the object. Return 0 on sucess, error code on failure */
+static int icmXYZArray_write(
+ icmBase *pp,
+ unsigned int of /* File offset to write from */
+) {
+ icmXYZArray *p = (icmXYZArray *)pp;
+ icc *icp = p->icp;
+ unsigned int i;
+ unsigned int len;
+ char *bp, *buf; /* Buffer to write from */
+ int rv = 0;
+
+ /* Allocate a file write buffer */
+ if ((len = p->get_size((icmBase *)p)) == UINT_MAX) {
+ sprintf(icp->err,"icmXYZArray_write get_size overflow");
+ return icp->errc = 1;
+ }
+ if ((buf = (char *) icp->al->malloc(icp->al, len)) == NULL) {
+ sprintf(icp->err,"icmXYZArray_write malloc() failed");
+ return icp->errc = 2;
+ }
+ bp = buf;
+
+ /* Write type descriptor to the buffer */
+ if ((rv = write_SInt32Number((int)p->ttype,bp)) != 0) {
+ sprintf(icp->err,"icmXYZArray_write: write_SInt32Number() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+ write_SInt32Number(0,bp+4); /* Set padding to 0 */
+
+ /* Write all the data to the buffer */
+ bp += 8; /* Skip padding */
+ for (i = 0; i < p->size; i++, bp += 12) {
+ if ((rv = write_XYZNumber(&p->data[i],bp)) != 0) {
+ sprintf(icp->err,"icmXYZArray_write: write_XYZumber() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+ }
+
+ /* Write to the file */
+ if ( icp->fp->seek(icp->fp, of) != 0
+ || icp->fp->write(icp->fp, buf, 1, len) != len) {
+ sprintf(icp->err,"icmXYZArray_write fseek() or fwrite() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 2;
+ }
+ icp->al->free(icp->al, buf);
+ return 0;
+}
+
+/* Dump a text description of the object */
+static void icmXYZArray_dump(
+ icmBase *pp,
+ icmFile *op, /* Output to dump to */
+ int verb /* Verbosity level */
+) {
+ icmXYZArray *p = (icmXYZArray *)pp;
+ if (verb <= 0)
+ return;
+
+ op->gprintf(op,"XYZArray:\n");
+ op->gprintf(op," No. elements = %lu\n",p->size);
+ if (verb >= 2) {
+ unsigned int i;
+ for (i = 0; i < p->size; i++) {
+ op->gprintf(op," %lu: %s\n",i,string_XYZNumber_and_Lab(&p->data[i]));
+
+ }
+ }
+}
+
+/* Allocate variable sized data elements */
+static int icmXYZArray_allocate(
+ icmBase *pp
+) {
+ icmXYZArray *p = (icmXYZArray *)pp;
+ icc *icp = p->icp;
+
+ if (p->size != p->_size) {
+ if (ovr_mul(p->size, sizeof(icmXYZNumber))) {
+ sprintf(icp->err,"icmXYZArray_alloc: size overflow");
+ return icp->errc = 1;
+ }
+ if (p->data != NULL)
+ icp->al->free(icp->al, p->data);
+ if ((p->data = (icmXYZNumber *) icp->al->malloc(icp->al, sat_mul(p->size, sizeof(icmXYZNumber)))) == NULL) {
+ sprintf(icp->err,"icmXYZArray_alloc: malloc() of icmXYZArray data failed");
+ return icp->errc = 2;
+ }
+ p->_size = p->size;
+ }
+ return 0;
+}
+
+/* Free all storage in the object */
+static void icmXYZArray_delete(
+ icmBase *pp
+) {
+ icmXYZArray *p = (icmXYZArray *)pp;
+ icc *icp = p->icp;
+
+ if (p->data != NULL)
+ icp->al->free(icp->al, p->data);
+ icp->al->free(icp->al, p);
+}
+
+/* Create an empty object. Return null on error */
+static icmBase *new_icmXYZArray(
+ icc *icp
+) {
+ icmXYZArray *p;
+ if ((p = (icmXYZArray *) icp->al->calloc(icp->al,1,sizeof(icmXYZArray))) == NULL)
+ return NULL;
+ p->ttype = icSigXYZArrayType;
+ p->refcount = 1;
+ p->get_size = icmXYZArray_get_size;
+ p->read = icmXYZArray_read;
+ p->write = icmXYZArray_write;
+ p->dump = icmXYZArray_dump;
+ p->allocate = icmXYZArray_allocate;
+ p->del = icmXYZArray_delete;
+ p->icp = icp;
+
+ return (icmBase *)p;
+}
+
+/* ---------------------------------------------------------- */
+/* icmCurve object */
+
+/* Do a forward lookup through the curve */
+/* Return 0 on success, 1 if clipping occured, 2 on other error */
+static int icmCurve_lookup_fwd(
+ icmCurve *p,
+ double *out,
+ double *in
+) {
+ int rv = 0;
+ if (p->flag == icmCurveLin) {
+ *out = *in;
+ } else if (p->flag == icmCurveGamma) {
+ double val = *in;
+ if (val <= 0.0)
+ *out = 0.0;
+ else
+ *out = pow(val, p->data[0]);
+ } else if (p->size == 0) { /* Table of 0 size */
+ *out = *in;
+ } else { /* Use linear interpolation */
+ unsigned int ix;
+ double val, w;
+ double inputEnt_1 = (double)(p->size-1);
+
+ val = *in * inputEnt_1;
+ if (val < 0.0) {
+ val = 0.0;
+ rv |= 1;
+ } else if (val > inputEnt_1) {
+ val = inputEnt_1;
+ rv |= 1;
+ }
+ ix = (unsigned int)floor(val); /* Coordinate */
+ if (ix > (p->size-2))
+ ix = (p->size-2);
+ w = val - (double)ix; /* weight */
+ val = p->data[ix];
+ *out = val + w * (p->data[ix+1] - val);
+ }
+ return rv;
+}
+
+/* - - - - - - - - - - - - */
+/* Support for reverse interpolation of 1D lookup tables */
+
+/* Create a reverse curve lookup acceleration table */
+/* return non-zero on error, 2 = malloc error. */
+static int icmTable_setup_bwd(
+ icc *icp, /* Base icc object */
+ icmRevTable *rt, /* Reverse table data to setup */
+ unsigned int size, /* Size of fwd table */
+ double *data /* Table */
+) {
+ unsigned int i;
+
+ rt->size = size; /* Stash pointers to these away */
+ rt->data = data;
+
+ /* Find range of output values */
+ rt->rmin = 1e300;
+ rt->rmax = -1e300;
+ for (i = 0; i < rt->size; i++) {
+ if (rt->data[i] > rt->rmax)
+ rt->rmax = rt->data[i];
+ if (rt->data[i] < rt->rmin)
+ rt->rmin = rt->data[i];
+ }
+
+ /* Decide on reverse granularity */
+ rt->rsize = sat_add(rt->size,2)/2;
+ rt->qscale = (double)rt->rsize/(rt->rmax - rt->rmin); /* Scale factor to quantize to */
+
+ if (ovr_mul(rt->size, sizeof(unsigned int *))) {
+ return 2;
+ }
+ /* Initialize the reverse lookup structures, and get overall min/max */
+ if ((rt->rlists = (unsigned int **) icp->al->calloc(icp->al, rt->rsize, sizeof(unsigned int *))) == NULL) {
+ return 2;
+ }
+
+ /* Assign each output value range bucket lists it intersects */
+ for (i = 0; i < (rt->size-1); i++) {
+ unsigned int s, e, j; /* Start and end indexes (inclusive) */
+ s = (unsigned int)((rt->data[i] - rt->rmin) * rt->qscale);
+ e = (unsigned int)((rt->data[i+1] - rt->rmin) * rt->qscale);
+ if (s >= rt->rsize)
+ s = rt->rsize-1;
+ if (e >= rt->rsize)
+ e = rt->rsize-1;
+ if (s > e) { /* swap */
+ unsigned int t;
+ t = s; s = e; e = t;
+ }
+
+ /* For all buckets that may contain this output range, add index of this output */
+ for (j = s; j <= e; j++) {
+ unsigned int as; /* Allocation size */
+ unsigned int nf; /* Next free slot */
+ if (rt->rlists[j] == NULL) { /* No allocation */
+ as = 5; /* Start with space for 5 */
+ if ((rt->rlists[j] = (unsigned int *) icp->al->calloc(icp->al, as, sizeof(unsigned int))) == NULL) {
+ return 2;
+ }
+ rt->rlists[j][0] = as;
+ nf = rt->rlists[j][1] = 2;
+ } else {
+ as = rt->rlists[j][0]; /* Allocate space for this list */
+ nf = rt->rlists[j][1]; /* Next free location in list */
+ if (nf >= as) { /* need to expand space */
+ if ((as = sat_mul(as, 2)) == UINT_MAX
+ || ovr_mul(as, sizeof(unsigned int))) {
+ return 2;
+ }
+ rt->rlists[j] = (unsigned int *) icp->al->realloc(icp->al,rt->rlists[j], as * sizeof(unsigned int));
+ if (rt->rlists[j] == NULL) {
+ return 2;
+ }
+ rt->rlists[j][0] = as;
+ }
+ }
+ rt->rlists[j][nf++] = i;
+ rt->rlists[j][1] = nf;
+ }
+ }
+ rt->inited = 1;
+ return 0;
+}
+
+/* Free up any data */
+static void icmTable_delete_bwd(
+ icc *icp, /* Base icc */
+ icmRevTable *rt /* Reverse table data to setup */
+) {
+ if (rt->inited != 0) {
+ while (rt->rsize > 0)
+ icp->al->free(icp->al, rt->rlists[--rt->rsize]);
+ icp->al->free(icp->al, rt->rlists);
+ rt->size = 0; /* Don't keep these */
+ rt->data = NULL;
+ }
+}
+
+/* Do a reverse lookup through the curve */
+/* Return 0 on success, 1 if clipping occured, 2 on other error */
+static int icmTable_lookup_bwd(
+ icmRevTable *rt,
+ double *out,
+ double *in
+) {
+ int rv = 0;
+ unsigned int ix, k, i;
+ double oval, ival = *in, val;
+ double rsize_1;
+
+ /* Find appropriate reverse list */
+ rsize_1 = (double)(rt->rsize-1);
+ val = ((ival - rt->rmin) * rt->qscale);
+ if (val < 0.0)
+ val = 0.0;
+ else if (val > rsize_1)
+ val = rsize_1;
+ ix = (unsigned int)floor(val); /* Coordinate */
+
+ if (ix > (rt->size-2))
+ ix = (rt->size-2);
+ if (rt->rlists[ix] != NULL) { /* There is a list of fwd candidates */
+ /* For each candidate forward range */
+ for (i = 2; i < rt->rlists[ix][1]; i++) { /* For all fwd indexes */
+ double lv,hv;
+ k = rt->rlists[ix][i]; /* Base index */
+ lv = rt->data[k];
+ hv = rt->data[k+1];
+ if ((ival >= lv && ival <= hv) /* If this slot contains output value */
+ || (ival >= hv && ival <= lv)) {
+ /* Reverse linear interpolation */
+ if (hv == lv) { /* Technically non-monotonic - due to quantization ? */
+ oval = (k + 0.5)/(rt->size-1.0);
+ } else
+ oval = (k + ((ival - lv)/(hv - lv)))/(rt->size-1.0);
+ /* If we kept looking, we would find multiple */
+ /* solution for non-monotonic curve */
+ *out = oval;
+ return rv;
+ }
+ }
+ }
+
+ /* We have failed to find an exact value, so return the nearest value */
+ /* (This is slow !) */
+ val = fabs(ival - rt->data[0]);
+ for (k = 0, i = 1; i < rt->size; i++) {
+ double er;
+ er = fabs(ival - rt->data[i]);
+ if (er < val) { /* new best */
+ val = er;
+ k = i;
+ }
+ }
+ *out = k/(rt->size-1.0);
+ rv |= 1;
+ return rv;
+}
+
+
+/* - - - - - - - - - - - - */
+
+/* Do a reverse lookup through the curve */
+/* Return 0 on success, 1 if clipping occured, 2 on other error */
+static int icmCurve_lookup_bwd(
+ icmCurve *p,
+ double *out,
+ double *in
+) {
+ icc *icp = p->icp;
+ int rv = 0;
+ if (p->flag == icmCurveLin) {
+ *out = *in;
+ } else if (p->flag == icmCurveGamma) {
+ double val = *in;
+ if (val <= 0.0)
+ *out = 0.0;
+ else
+ *out = pow(val, 1.0/p->data[0]);
+ } else if (p->size == 0) { /* Table of 0 size */
+ *out = *in;
+ } else { /* Use linear interpolation */
+ if (p->rt.inited == 0) {
+ rv = icmTable_setup_bwd(icp, &p->rt, p->size, p->data);
+ if (rv != 0) {
+ sprintf(icp->err,"icmCurve_lookup: Malloc failure in reverse lookup init.");
+ return icp->errc = rv;
+ }
+ }
+ rv = icmTable_lookup_bwd(&p->rt, out, in);
+ }
+ return rv;
+}
+
+/* Return the number of bytes needed to write this tag */
+static unsigned int icmCurve_get_size(
+ icmBase *pp
+) {
+ icmCurve *p = (icmCurve *)pp;
+ unsigned int len = 0;
+ len = sat_add(len, 12); /* 12 bytes for tag, padding and count */
+ len = sat_addmul(len, p->size, 2); /* 2 bytes for each UInt16 */
+ return len;
+}
+
+/* read the object, return 0 on success, error code on fail */
+static int icmCurve_read(
+ icmBase *pp,
+ unsigned int len, /* tag length */
+ unsigned int of /* start offset within file */
+) {
+ icmCurve *p = (icmCurve *)pp;
+ icc *icp = p->icp;
+ int rv = 0;
+ unsigned int i;
+ char *bp, *buf, *end;
+
+ if (len < 12) {
+ sprintf(icp->err,"icmCurve_read: Tag too small to be legal");
+ return icp->errc = 1;
+ }
+
+ /* Allocate a file read buffer */
+ if ((buf = (char *) icp->al->malloc(icp->al, len)) == NULL) {
+ sprintf(icp->err,"icmCurve_read: malloc() failed");
+ return icp->errc = 2;
+ }
+ bp = buf;
+ end = buf + len;
+
+ /* Read portion of file into buffer */
+ if ( icp->fp->seek(icp->fp, of) != 0
+ || icp->fp->read(icp->fp, bp, 1, len) != len) {
+ sprintf(icp->err,"icmCurve_read: fseek() or fread() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+
+ /* Read type descriptor from the buffer */
+ if (((icTagTypeSignature)read_SInt32Number(bp)) != p->ttype) {
+ sprintf(icp->err,"icmCurve_read: Wrong tag type for icmCurve");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+
+ p->size = read_UInt32Number(bp+8);
+ bp = bp + 12;
+
+ /* Set flag up before allocating */
+ if (p->size == 0) { /* Linear curve */
+ p->flag = icmCurveLin;
+ } else if (p->size == 1) { /* Gamma curve */
+ p->flag = icmCurveGamma;
+ } else {
+ p->flag = icmCurveSpec;
+ if (p->size > (len - 12)/2) {
+ sprintf(icp->err,"icmCurve_read: size overflow");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ }
+
+ if ((rv = p->allocate((icmBase *)p)) != 0) {
+ icp->al->free(icp->al, buf);
+ return rv;
+ }
+
+ if (p->flag == icmCurveGamma) { /* Gamma curve */
+ if (bp > end || 1 > (end - bp)) {
+ sprintf(icp->err,"icmCurve_read: Data too short for curve gamma");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ p->data[0] = read_U8Fixed8Number(bp);
+ } else if (p->flag == icmCurveSpec) {
+ /* Read all the data from the buffer */
+ for (i = 0; i < p->size; i++, bp += 2) {
+ if (bp > end || 2 > (end - bp)) {
+ sprintf(icp->err,"icmCurve_read: Data too short for curve value");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ p->data[i] = read_DCS16Number(bp);
+ }
+ }
+ icp->al->free(icp->al, buf);
+ return 0;
+}
+
+/* Write the contents of the object. Return 0 on sucess, error code on failure */
+static int icmCurve_write(
+ icmBase *pp,
+ unsigned int of /* File offset to write from */
+) {
+ icmCurve *p = (icmCurve *)pp;
+ icc *icp = p->icp;
+ unsigned int i;
+ unsigned int len;
+ char *bp, *buf; /* Buffer to write from */
+ int rv = 0;
+
+ /* Allocate a file write buffer */
+ if ((len = p->get_size((icmBase *)p)) == UINT_MAX) {
+ sprintf(icp->err,"icmCurve_write get_size overflow");
+ return icp->errc = 1;
+ }
+ if ((buf = (char *) icp->al->malloc(icp->al, len)) == NULL) {
+ sprintf(icp->err,"icmCurve_write malloc() failed");
+ return icp->errc = 2;
+ }
+ bp = buf;
+
+ /* Write type descriptor to the buffer */
+ if ((rv = write_SInt32Number((int)p->ttype,bp)) != 0) {
+ sprintf(icp->err,"icmCurve_write: write_SInt32Number() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+ write_SInt32Number(0,bp+4); /* Set padding to 0 */
+
+ /* Write count */
+ if ((rv = write_UInt32Number(p->size,bp+8)) != 0) {
+ sprintf(icp->err,"icmCurve_write: write_UInt32Number() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+
+ /* Write all the data to the buffer */
+ bp += 12; /* Skip padding */
+ if (p->flag == icmCurveLin) {
+ if (p->size != 0) {
+ sprintf(icp->err,"icmCurve_write: Must be exactly 0 entry for Linear");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ } else if (p->flag == icmCurveGamma) {
+ if (p->size != 1) {
+ sprintf(icp->err,"icmCurve_write: Must be exactly 1 entry for Gamma");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ if ((rv = write_U8Fixed8Number(p->data[0],bp)) != 0) {
+ sprintf(icp->err,"icmCurve_write: write_U8Fixed8umber(%f) failed",p->data[0]);
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+ } else if (p->flag == icmCurveSpec) {
+ if (p->size < 2) {
+ sprintf(icp->err,"icmCurve_write: Must be 2 or more entries for Specified curve");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ for (i = 0; i < p->size; i++, bp += 2) {
+ if ((rv = write_DCS16Number(p->data[i],bp)) != 0) {
+ sprintf(icp->err,"icmCurve_write: write_UInt16umber(%f) failed",p->data[i]);
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+ }
+ }
+
+ /* Write to the file */
+ if ( icp->fp->seek(icp->fp, of) != 0
+ || icp->fp->write(icp->fp, buf, 1, len) != len) {
+ sprintf(icp->err,"icmCurve_write fseek() or fwrite() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 2;
+ }
+ icp->al->free(icp->al, buf);
+ return 0;
+}
+
+/* Dump a text description of the object */
+static void icmCurve_dump(
+ icmBase *pp,
+ icmFile *op, /* Output to dump to */
+ int verb /* Verbosity level */
+) {
+ icmCurve *p = (icmCurve *)pp;
+ if (verb <= 0)
+ return;
+
+ op->gprintf(op,"Curve:\n");
+
+ if (p->flag == icmCurveLin) {
+ op->gprintf(op," Curve is linear\n");
+ } else if (p->flag == icmCurveGamma) {
+ op->gprintf(op," Curve is gamma of %f\n",p->data[0]);
+ } else {
+ op->gprintf(op," No. elements = %lu\n",p->size);
+ if (verb >= 2) {
+ unsigned int i;
+ for (i = 0; i < p->size; i++)
+ op->gprintf(op," %3lu: %f\n",i,p->data[i]);
+ }
+ }
+}
+
+/* Allocate variable sized data elements */
+static int icmCurve_allocate(
+ icmBase *pp
+) {
+ icmCurve *p = (icmCurve *)pp;
+ icc *icp = p->icp;
+
+ if (p->flag == icmCurveUndef) {
+ sprintf(icp->err,"icmCurve_alloc: flag not set");
+ return icp->errc = 1;
+ } else if (p->flag == icmCurveLin) {
+ p->size = 0;
+ } else if (p->flag == icmCurveGamma) {
+ p->size = 1;
+ }
+ if (p->size != p->_size) {
+ if (ovr_mul(p->size, sizeof(double))) {
+ sprintf(icp->err,"icmCurve_alloc: size overflow");
+ return icp->errc = 1;
+ }
+ if (p->data != NULL)
+ icp->al->free(icp->al, p->data);
+ if ((p->data = (double *) icp->al->calloc(icp->al, p->size, sizeof(double))) == NULL) {
+ sprintf(icp->err,"icmCurve_alloc: malloc() of icmCurve data failed");
+ return icp->errc = 2;
+ }
+ p->_size = p->size;
+ }
+ return 0;
+}
+
+/* Free all storage in the object */
+static void icmCurve_delete(
+ icmBase *pp
+) {
+ icmCurve *p = (icmCurve *)pp;
+ icc *icp = p->icp;
+
+ if (p->data != NULL)
+ icp->al->free(icp->al, p->data);
+ icmTable_delete_bwd(icp, &p->rt); /* Free reverse table info */
+ icp->al->free(icp->al, p);
+}
+
+/* Create an empty object. Return null on error */
+static icmBase *new_icmCurve(
+ icc *icp
+) {
+ icmCurve *p;
+ if ((p = (icmCurve *) icp->al->calloc(icp->al,1,sizeof(icmCurve))) == NULL)
+ return NULL;
+ p->ttype = icSigCurveType;
+ p->refcount = 1;
+ p->get_size = icmCurve_get_size;
+ p->read = icmCurve_read;
+ p->write = icmCurve_write;
+ p->dump = icmCurve_dump;
+ p->allocate = icmCurve_allocate;
+ p->del = icmCurve_delete;
+ p->icp = icp;
+
+ p->lookup_fwd = icmCurve_lookup_fwd;
+ p->lookup_bwd = icmCurve_lookup_bwd;
+
+ p->rt.inited = 0;
+
+ p->flag = icmCurveUndef;
+ return (icmBase *)p;
+}
+
+/* ---------------------------------------------------------- */
+/* icmData object */
+
+/* Return the number of bytes needed to write this tag */
+static unsigned int icmData_get_size(
+ icmBase *pp
+) {
+ icmData *p = (icmData *)pp;
+ unsigned int len = 0;
+ len = sat_add(len, 12); /* 12 bytes for tag and padding */
+ len = sat_addmul(len, p->size, 1); /* 1 byte for each data element */
+ return len;
+}
+
+/* read the object, return 0 on success, error code on fail */
+static int icmData_read(
+ icmBase *pp,
+ unsigned int len, /* tag length */
+ unsigned int of /* start offset within file */
+) {
+ icmData *p = (icmData *)pp;
+ icc *icp = p->icp;
+ int rv;
+ unsigned size, f;
+ char *bp, *buf;
+
+ if (len < 12) {
+ sprintf(icp->err,"icmData_read: Tag too small to be legal");
+ return icp->errc = 1;
+ }
+
+ /* Allocate a file read buffer */
+ if ((buf = (char *) icp->al->malloc(icp->al, len)) == NULL) {
+ sprintf(icp->err,"icmData_read: malloc() failed");
+ return icp->errc = 2;
+ }
+ bp = buf;
+
+ /* Read portion of file into buffer */
+ if ( icp->fp->seek(icp->fp, of) != 0
+ || icp->fp->read(icp->fp, bp, 1, len) != len) {
+ sprintf(icp->err,"icmData_read: fseek() or fread() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ p->size = size = (len - 12)/1; /* Number of elements in the array */
+
+ /* Read type descriptor from the buffer */
+ if (((icTagTypeSignature)read_SInt32Number(bp)) != p->ttype) {
+ sprintf(icp->err,"icmData_read: Wrong tag type for icmData");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ /* Read the data type flag */
+ f = read_UInt32Number(bp+8);
+ if (f == 0) {
+ p->flag = icmDataASCII;
+ } else if (f == 1) {
+ p->flag = icmDataBin;
+#ifndef ICM_STRICT /* Profile maker sometimes has a problem */
+ } else if (f == 0x01000000) {
+ p->flag = icmDataBin;
+#endif
+ } else {
+ sprintf(icp->err,"icmData_read: Unknown flag value 0x%x",f);
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ bp += 12; /* Skip padding and flag */
+
+ if (p->size > 0) {
+ if (p->flag == icmDataASCII) {
+ if ((rv = check_null_string(bp,p->size)) == 1) {
+ sprintf(icp->err,"icmData_read: ACSII is not null terminated");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ /* Haven't checked if rv == 2 is legal or not */
+ }
+ if ((rv = p->allocate((icmBase *)p)) != 0) {
+ icp->al->free(icp->al, buf);
+ return rv;
+ }
+
+ memmove((void *)p->data, (void *)bp, p->size);
+ }
+ icp->al->free(icp->al, buf);
+ return 0;
+}
+
+/* Write the contents of the object. Return 0 on sucess, error code on failure */
+static int icmData_write(
+ icmBase *pp,
+ unsigned int of /* File offset to write from */
+) {
+ icmData *p = (icmData *)pp;
+ icc *icp = p->icp;
+ unsigned int len, f;
+ char *bp, *buf; /* Buffer to write from */
+ int rv;
+
+ /* Allocate a file write buffer */
+ if ((len = p->get_size((icmBase *)p)) == UINT_MAX) {
+ sprintf(icp->err,"icmData_write get_size overflow");
+ return icp->errc = 1;
+ }
+ if ((buf = (char *) icp->al->malloc(icp->al, len)) == NULL) {
+ sprintf(icp->err,"icmData_write malloc() failed");
+ return icp->errc = 2;
+ }
+ bp = buf;
+
+ /* Write type descriptor to the buffer */
+ if ((rv = write_SInt32Number((int)p->ttype,bp)) != 0) {
+ sprintf(icp->err,"icmData_write: write_SInt32Number() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+ write_SInt32Number(0,bp+4); /* Set padding to 0 */
+ switch(p->flag) {
+ case icmDataASCII:
+ f = 0;
+ break;
+ case icmDataBin:
+ f = 1;
+ break;
+ default:
+ sprintf(icp->err,"icmData_write: Unknown Data Flag value");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ /* Write data flag descriptor to the buffer */
+ if ((rv = write_UInt32Number(f,bp+8)) != 0) {
+ sprintf(icp->err,"icmData_write: write_SInt32Number() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+ bp += 12; /* Skip padding */
+
+ if (p->data != NULL) {
+ if (p->flag == icmDataASCII) {
+ if ((rv = check_null_string((char *)p->data, p->size)) == 1) {
+ sprintf(icp->err,"icmData_write: ASCII is not null terminated");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ /* Haven't checked if rv == 2 is legal or not */
+ }
+ memmove((void *)bp, (void *)p->data, p->size);
+ }
+
+ /* Write to the file */
+ if ( icp->fp->seek(icp->fp, of) != 0
+ || icp->fp->write(icp->fp, buf, 1, len) != len) {
+ sprintf(icp->err,"icmData_write fseek() or fwrite() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 2;
+ }
+ icp->al->free(icp->al, buf);
+ return 0;
+}
+
+/* Dump a text description of the object */
+static void icmData_dump(
+ icmBase *pp,
+ icmFile *op, /* Output to dump to */
+ int verb /* Verbosity level */
+) {
+ icmData *p = (icmData *)pp;
+ unsigned int i, r, c, ii, size = 0;
+ int ph = 0; /* Phase */
+
+ if (verb <= 0)
+ return;
+
+ op->gprintf(op,"Data:\n");
+ switch(p->flag) {
+ case icmDataASCII:
+ op->gprintf(op," ASCII data\n");
+ size = p->size > 0 ? p->size-1 : 0;
+ break;
+ case icmDataBin:
+ op->gprintf(op," Binary data\n");
+ size = p->size;
+ break;
+ case icmDataUndef:
+ op->gprintf(op," Undefined data\n");
+ size = p->size;
+ break;
+ }
+ op->gprintf(op," No. elements = %lu\n",p->size);
+
+ ii = i = 0;
+ for (r = 1;; r++) { /* count rows */
+ if (i >= size) {
+ op->gprintf(op,"\n");
+ break;
+ }
+ if (r > 1 && verb < 2) {
+ op->gprintf(op,"...\n");
+ break; /* Print 1 row if not verbose */
+ }
+
+ c = 1;
+ if (ph != 0) { /* Print ASCII under binary */
+ op->gprintf(op," ");
+ i = ii;
+ c += 11;
+ } else {
+ op->gprintf(op," 0x%04lx: ",i);
+ ii = i;
+ c += 10;
+ }
+ while (i < size && c < 75) {
+ if (p->flag == icmDataASCII) {
+ if (isprint(p->data[i])) {
+ op->gprintf(op,"%c",p->data[i]);
+ c++;
+ } else {
+ op->gprintf(op,"\\%03o",p->data[i]);
+ c += 4;
+ }
+ } else {
+ if (ph == 0)
+ op->gprintf(op,"%02x ",p->data[i]);
+ else {
+ if (isprint(p->data[i]))
+ op->gprintf(op," %c ",p->data[i]);
+ else
+ op->gprintf(op," ",p->data[i]);
+ }
+ c += 3;
+ }
+ i++;
+ }
+ if (i < size)
+ op->gprintf(op,"\n");
+ if (verb > 2 && p->flag != icmDataASCII && ph == 0)
+ ph = 1;
+ else
+ ph = 0;
+ }
+}
+
+/* Allocate variable sized data elements */
+static int icmData_allocate(
+ icmBase *pp
+) {
+ icmData *p = (icmData *)pp;
+ icc *icp = p->icp;
+
+ if (p->size != p->_size) {
+ if (ovr_mul(p->size, sizeof(unsigned char))) {
+ sprintf(icp->err,"icmData_alloc: size overflow");
+ return icp->errc = 1;
+ }
+ if (p->data != NULL)
+ icp->al->free(icp->al, p->data);
+ if ((p->data = (unsigned char *) icp->al->calloc(icp->al, p->size, sizeof(unsigned char))) == NULL) {
+ sprintf(icp->err,"icmData_alloc: malloc() of icmData data failed");
+ return icp->errc = 2;
+ }
+ p->_size = p->size;
+ }
+ return 0;
+}
+
+/* Free all storage in the object */
+static void icmData_delete(
+ icmBase *pp
+) {
+ icmData *p = (icmData *)pp;
+ icc *icp = p->icp;
+
+ if (p->data != NULL)
+ icp->al->free(icp->al, p->data);
+ icp->al->free(icp->al, p);
+}
+
+/* Create an empty object. Return null on error */
+static icmBase *new_icmData(
+ icc *icp
+) {
+ icmData *p;
+ if ((p = (icmData *) icp->al->calloc(icp->al,1,sizeof(icmData))) == NULL)
+ return NULL;
+ p->ttype = icSigDataType;
+ p->refcount = 1;
+ p->get_size = icmData_get_size;
+ p->read = icmData_read;
+ p->write = icmData_write;
+ p->dump = icmData_dump;
+ p->allocate = icmData_allocate;
+ p->del = icmData_delete;
+ p->icp = icp;
+
+ p->flag = icmDataUndef;
+ return (icmBase *)p;
+}
+
+/* ---------------------------------------------------------- */
+/* icmText object */
+
+/* Return the number of bytes needed to write this tag */
+static unsigned int icmText_get_size(
+ icmBase *pp
+) {
+ icmText *p = (icmText *)pp;
+ unsigned int len = 0;
+ len = sat_add(len, 8); /* 8 bytes for tag and padding */
+ len = sat_addmul(len, p->size, 1); /* 1 byte for each character element (inc. null) */
+ return len;
+}
+
+/* read the object, return 0 on success, error code on fail */
+static int icmText_read(
+ icmBase *pp,
+ unsigned int len, /* tag length */
+ unsigned int of /* start offset within file */
+) {
+ icmText *p = (icmText *)pp;
+ icc *icp = p->icp;
+ int rv;
+ char *bp, *buf;
+
+ if (len < 8) {
+ sprintf(icp->err,"icmText_read: Tag too short to be legal");
+ return icp->errc = 1;
+ }
+
+ /* Allocate a file read buffer */
+ if ((buf = (char *) icp->al->malloc(icp->al, len)) == NULL) {
+ sprintf(icp->err,"icmText_read: malloc() failed");
+ return icp->errc = 2;
+ }
+ bp = buf;
+
+ /* Read portion of file into buffer */
+ if ( icp->fp->seek(icp->fp, of) != 0
+ || icp->fp->read(icp->fp, bp, 1, len) != len) {
+ sprintf(icp->err,"icmText_read: fseek() or fread() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ p->size = (len - 8)/1; /* Number of elements in the array */
+
+ /* Read type descriptor from the buffer */
+ if (((icTagTypeSignature)read_SInt32Number(bp)) != p->ttype) {
+ sprintf(icp->err,"icmText_read: Wrong tag type for icmText");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ bp = bp + 8;
+
+ if (p->size > 0) {
+ if ((rv = check_null_string(bp,p->size)) == 1) {
+ sprintf(icp->err,"icmText_read: text is not null terminated");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ /* Haven't checked if rv == 2 is legal or not */
+
+ if ((rv = p->allocate((icmBase *)p)) != 0) {
+ icp->al->free(icp->al, buf);
+ return rv;
+ }
+ memmove((void *)p->data, (void *)bp, p->size);
+ }
+ icp->al->free(icp->al, buf);
+ return 0;
+}
+
+/* Write the contents of the object. Return 0 on sucess, error code on failure */
+static int icmText_write(
+ icmBase *pp,
+ unsigned int of /* File offset to write from */
+) {
+ icmText *p = (icmText *)pp;
+ icc *icp = p->icp;
+ unsigned int len;
+ char *bp, *buf; /* Buffer to write from */
+ int rv;
+
+ /* Allocate a file write buffer */
+ if ((len = p->get_size((icmBase *)p)) == UINT_MAX) {
+ sprintf(icp->err,"icmText_write get_size overflow");
+ return icp->errc = 1;
+ }
+ if ((buf = (char *) icp->al->malloc(icp->al, len)) == NULL) {
+ sprintf(icp->err,"icmText_write malloc() failed");
+ return icp->errc = 2;
+ }
+ bp = buf;
+
+ /* Write type descriptor to the buffer */
+ if ((rv = write_SInt32Number((int)p->ttype,bp)) != 0) {
+ sprintf(icp->err,"icmText_write: write_SInt32Number() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+ write_SInt32Number(0,bp+4); /* Set padding to 0 */
+ bp = bp + 8;
+
+ if (p->data != NULL) {
+ if ((rv = check_null_string(p->data, p->size)) == 1) {
+ sprintf(icp->err,"icmText_write: text is not null terminated");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ /* Haven't checked if rv == 2 is legal or not */
+ memmove((void *)bp, (void *)p->data, p->size);
+ }
+
+ /* Write to the file */
+ if ( icp->fp->seek(icp->fp, of) != 0
+ || icp->fp->write(icp->fp, buf, 1, len) != len) {
+ sprintf(icp->err,"icmText_write fseek() or fwrite() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 2;
+ }
+ icp->al->free(icp->al, buf);
+ return 0;
+}
+
+/* Dump a text description of the object */
+static void icmText_dump(
+ icmBase *pp,
+ icmFile *op, /* Output to dump to */
+ int verb /* Verbosity level */
+) {
+ icmText *p = (icmText *)pp;
+ unsigned int i, r, c, size;
+
+ if (verb <= 0)
+ return;
+
+ op->gprintf(op,"Text:\n");
+ op->gprintf(op," No. chars = %lu\n",p->size);
+
+ size = p->size > 0 ? p->size-1 : 0;
+ i = 0;
+ for (r = 1;; r++) { /* count rows */
+ if (i >= size) {
+ op->gprintf(op,"\n");
+ break;
+ }
+ if (r > 1 && verb < 2) {
+ op->gprintf(op,"...\n");
+ break; /* Print 1 row if not verbose */
+ }
+ c = 1;
+ op->gprintf(op," 0x%04lx: ",i);
+ c += 10;
+ while (i < size && c < 75) {
+ if (isprint(p->data[i])) {
+ op->gprintf(op,"%c",p->data[i]);
+ c++;
+ } else {
+ op->gprintf(op,"\\%03o",p->data[i]);
+ c += 4;
+ }
+ i++;
+ }
+ if (i < size)
+ op->gprintf(op,"\n");
+ }
+}
+
+/* Allocate variable sized data elements */
+static int icmText_allocate(
+ icmBase *pp
+) {
+ icmText *p = (icmText *)pp;
+ icc *icp = p->icp;
+
+ if (p->size != p->_size) {
+ if (ovr_mul(p->size, sizeof(char))) {
+ sprintf(icp->err,"icmText_alloc: size overflow");
+ return icp->errc = 1;
+ }
+ if (p->data != NULL)
+ icp->al->free(icp->al, p->data);
+ if ((p->data = (char *) icp->al->calloc(icp->al, p->size, sizeof(char))) == NULL) {
+ sprintf(icp->err,"icmText_alloc: malloc() of icmText data failed");
+ return icp->errc = 2;
+ }
+ p->_size = p->size;
+ }
+ return 0;
+}
+
+/* Free all storage in the object */
+static void icmText_delete(
+ icmBase *pp
+) {
+ icmText *p = (icmText *)pp;
+ icc *icp = p->icp;
+
+ if (p->data != NULL)
+ icp->al->free(icp->al, p->data);
+ icp->al->free(icp->al, p);
+}
+
+/* Create an empty object. Return null on error */
+static icmBase *new_icmText(
+ icc *icp
+) {
+ icmText *p;
+ if ((p = (icmText *) icp->al->calloc(icp->al,1,sizeof(icmText))) == NULL)
+ return NULL;
+ p->ttype = icSigTextType;
+ p->refcount = 1;
+ p->get_size = icmText_get_size;
+ p->read = icmText_read;
+ p->write = icmText_write;
+ p->dump = icmText_dump;
+ p->allocate = icmText_allocate;
+ p->del = icmText_delete;
+ p->icp = icp;
+
+ return (icmBase *)p;
+}
+
+/* ---------------------------------------------------------- */
+
+/* Data conversion support functions */
+static int write_DateTimeNumber(icmDateTimeNumber *p, char *d) {
+ int rv;
+ if (p->year < 1900 || p->year > 3000
+ || p->month == 0 || p->month > 12
+ || p->day == 0 || p->day > 31
+ || p->hours > 23
+ || p->minutes > 59
+ || p->seconds > 59)
+ return 1;
+
+ if ((rv = write_UInt16Number(p->year, d + 0)) != 0)
+ return rv;
+ if ((rv = write_UInt16Number(p->month, d + 2)) != 0)
+ return rv;
+ if ((rv = write_UInt16Number(p->day, d + 4)) != 0)
+ return rv;
+ if ((rv = write_UInt16Number(p->hours, d + 6)) != 0)
+ return rv;
+ if ((rv = write_UInt16Number(p->minutes, d + 8)) != 0)
+ return rv;
+ if ((rv = write_UInt16Number(p->seconds, d + 10)) != 0)
+ return rv;
+ return 0;
+}
+
+static int read_DateTimeNumber(icmDateTimeNumber *p, char *d) {
+
+ p->year = read_UInt16Number(d + 0);
+ p->month = read_UInt16Number(d + 2);
+ p->day = read_UInt16Number(d + 4);
+ p->hours = read_UInt16Number(d + 6);
+ p->minutes = read_UInt16Number(d + 8);
+ p->seconds = read_UInt16Number(d + 10);
+
+ /* Sanity check the date and time */
+ if (p->year >= 1900 && p->year <= 3000
+ && p->month != 0 && p->month <= 12
+ && p->day != 0 && p->day <= 31
+ && p->hours <= 23
+ && p->minutes <= 59
+ && p->seconds <= 59)
+ return 0;
+
+#ifdef NEVER
+ printf("Raw year = %d, month = %d, day = %d\n",p->year, p->month, p->day);
+ printf("Raw hour = %d, minutes = %d, seconds = %d\n", p->hours, p->minutes, p->seconds);
+#endif /* NEVER */
+
+#ifdef ICM_STRICT
+ return 1; /* Not legal */
+
+#else
+ /* Be more forgiving */
+
+ /* Check for Adobe problem */
+ if (p->month >= 1900 && p->month <= 3000
+ && p->year != 0 && p->year <= 12
+ && p->hours != 0 && p->hours <= 31
+ && p->day <= 23
+ && p->seconds <= 59
+ && p->minutes <= 59) {
+ unsigned int tt;
+
+ /* Correct Adobe's faulty profile */
+ tt = p->month; p->month = p->year; p->year = tt;
+ tt = p->hours; p->hours = p->day; p->day = tt;
+ tt = p->seconds; p->seconds = p->minutes; p->minutes = tt;
+
+ return 0;
+ }
+
+ /* Hmm. some other sort of corruption. Limit values to sane */
+ if (p->year < 1900) {
+ if (p->year < 100) /* Hmm. didn't use 4 digit year, guess it's 19xx ? */
+ p->year += 1900;
+ else
+ p->year = 1900;
+ } else if (p->year > 3000)
+ p->year = 3000;
+
+ if (p->month == 0)
+ p->month = 1;
+ else if (p->month > 12)
+ p->month = 12;
+
+ if (p->day == 0)
+ p->day = 1;
+ else if (p->day > 31)
+ p->day = 31;
+
+ if (p->hours > 23)
+ p->hours = 23;
+
+ if (p->minutes > 59)
+ p->minutes = 59;
+
+ if (p->seconds > 59)
+ p->seconds = 59;
+
+ return 0;
+#endif
+}
+
+/* Return a string that shows the given date and time */
+static char *string_DateTimeNumber(icmDateTimeNumber *p) {
+ static const char *mstring[13] = {"Bad", "Jan","Feb","Mar","Apr","May","Jun",
+ "Jul","Aug","Sep","Oct","Nov","Dec"};
+ static char buf[80];
+
+ sprintf(buf,"%d %s %4d, %d:%02d:%02d",
+ p->day, mstring[p->month > 12 ? 0 : p->month], p->year,
+ p->hours, p->minutes, p->seconds);
+ return buf;
+}
+
+/* Set the DateTime structure to the current date and time */
+static void setcur_DateTimeNumber(icmDateTimeNumber *p) {
+ time_t cclk;
+ struct tm *ctm;
+
+ cclk = time(NULL);
+ ctm = localtime(&cclk);
+
+ p->year = ctm->tm_year + 1900;
+ p->month = ctm->tm_mon + 1;
+ p->day = ctm->tm_mday;
+ p->hours = ctm->tm_hour;
+ p->minutes = ctm->tm_min;
+ p->seconds = ctm->tm_sec;
+}
+
+/* Return the number of bytes needed to write this tag */
+static unsigned int icmDateTimeNumber_get_size(
+ icmBase *pp
+) {
+ unsigned int len = 0;
+ len = sat_add(len, 8); /* 8 bytes for tag and padding */
+ len = sat_add(len, 12); /* 12 bytes for Date & Time */
+ return len;
+}
+
+/* read the object, return 0 on success, error code on fail */
+static int icmDateTimeNumber_read(
+ icmBase *pp,
+ unsigned int len, /* tag length */
+ unsigned int of /* start offset within file */
+) {
+ icmDateTimeNumber *p = (icmDateTimeNumber *)pp;
+ icc *icp = p->icp;
+ int rv;
+ char *bp, *buf;
+
+ if (len < 20) {
+ sprintf(icp->err,"icmDateTimeNumber_read: Tag too small to be legal");
+ return icp->errc = 1;
+ }
+
+ /* Allocate a file read buffer */
+ if ((buf = (char *) icp->al->malloc(icp->al, len)) == NULL) {
+ sprintf(icp->err,"icmDateTimeNumber_read: malloc() failed");
+ return icp->errc = 2;
+ }
+ bp = buf;
+
+ /* Read portion of file into buffer */
+ if ( icp->fp->seek(icp->fp, of) != 0
+ || icp->fp->read(icp->fp, bp, 1, len) != len) {
+ sprintf(icp->err,"icmDateTimeNumber_read: fseek() or fread() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+
+ /* Read type descriptor from the buffer */
+ if (((icTagTypeSignature)read_SInt32Number(bp)) != p->ttype) {
+ sprintf(icp->err,"icmDateTimeNumber_read: Wrong tag type for icmDateTimeNumber");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ bp += 8; /* Skip padding */
+
+ /* Read the time and date from buffer */
+ if((rv = read_DateTimeNumber(p, bp)) != 0) {
+ sprintf(icp->err,"icmDateTimeNumber_read: Corrupted DateTime");
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+
+ icp->al->free(icp->al, buf);
+ return 0;
+}
+
+/* Write the contents of the object. Return 0 on sucess, error code on failure */
+static int icmDateTimeNumber_write(
+ icmBase *pp,
+ unsigned int of /* File offset to write from */
+) {
+ icmDateTimeNumber *p = (icmDateTimeNumber *)pp;
+ icc *icp = p->icp;
+ unsigned int len;
+ char *bp, *buf; /* Buffer to write from */
+ int rv = 0;
+
+ /* Allocate a file write buffer */
+ if ((len = p->get_size((icmBase *)p)) == UINT_MAX) {
+ sprintf(icp->err,"icmDateTimeNumber_write get_size overflow");
+ return icp->errc = 1;
+ }
+ if ((buf = (char *) icp->al->malloc(icp->al, len)) == NULL) {
+ sprintf(icp->err,"icmDateTimeNumber_write malloc() failed");
+ return icp->errc = 2;
+ }
+ bp = buf;
+
+ /* Write type descriptor to the buffer */
+ if ((rv = write_SInt32Number((int)p->ttype,bp)) != 0) {
+ sprintf(icp->err,"icmDateTimeNumber_write: write_SInt32Number() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+ write_SInt32Number(0,bp+4); /* Set padding to 0 */
+
+ /* Write all the data to the buffer */
+ bp += 8; /* Skip padding */
+ if ((rv = write_DateTimeNumber(p, bp)) != 0) {
+ sprintf(icp->err,"icmDateTimeNumber_write: write_DateTimeNumber() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+
+ /* Write to the file */
+ if ( icp->fp->seek(icp->fp, of) != 0
+ || icp->fp->write(icp->fp, buf, 1, len) != len) {
+ sprintf(icp->err,"icmDateTimeNumber_write fseek() or fwrite() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 2;
+ }
+ icp->al->free(icp->al, buf);
+ return 0;
+}
+
+/* Dump a text description of the object */
+static void icmDateTimeNumber_dump(
+ icmBase *pp,
+ icmFile *op, /* Output to dump to */
+ int verb /* Verbosity level */
+) {
+ icmDateTimeNumber *p = (icmDateTimeNumber *)pp;
+ if (verb <= 0)
+ return;
+
+ op->gprintf(op,"DateTimeNumber:\n");
+ op->gprintf(op," Date = %s\n", string_DateTimeNumber(p));
+}
+
+/* Allocate variable sized data elements */
+static int icmDateTimeNumber_allocate(
+ icmBase *pp
+) {
+ /* Nothing to do */
+ return 0;
+}
+
+/* Free all storage in the object */
+static void icmDateTimeNumber_delete(
+ icmBase *pp
+) {
+ icmDateTimeNumber *p = (icmDateTimeNumber *)pp;
+ icc *icp = p->icp;
+
+ icp->al->free(icp->al, p);
+}
+
+/* Create an empty object. Return null on error */
+static icmBase *new_icmDateTimeNumber(
+ icc *icp
+) {
+ icmDateTimeNumber *p;
+ if ((p = (icmDateTimeNumber *) icp->al->calloc(icp->al,1,sizeof(icmDateTimeNumber))) == NULL)
+ return NULL;
+ p->ttype = icSigDateTimeType;
+ p->refcount = 1;
+ p->get_size = icmDateTimeNumber_get_size;
+ p->read = icmDateTimeNumber_read;
+ p->write = icmDateTimeNumber_write;
+ p->dump = icmDateTimeNumber_dump;
+ p->allocate = icmDateTimeNumber_allocate;
+ p->del = icmDateTimeNumber_delete;
+ p->icp = icp;
+
+ setcur_DateTimeNumber(p); /* Default to current date and time */
+ return (icmBase *)p;
+}
+
+/* ---------------------------------------------------------- */
+/* icmLut object */
+
+/* Check if the matrix is non-zero */
+static int icmLut_nu_matrix(
+ icmLut *p /* Pointer to Lut object */
+) {
+ int i, j;
+
+ for (j = 0; j < 3; j++) { /* Rows */
+ for (i = 0; i < 3; i++) { /* Columns */
+ if ( (i == j && p->e[j][i] != 1.0)
+ || (i != j && p->e[j][i] != 0.0))
+ return 1;
+ }
+ }
+ return 0;
+}
+
+/* return the locations of the minimum and */
+/* maximum values of the given channel, in the clut */
+static void icmLut_min_max(
+ icmLut *p, /* Pointer to Lut object */
+ double *minp, /* Return position of min/max */
+ double *maxp,
+ int chan /* Channel, -1 for average of all */
+) {
+ double *tp;
+ double minv, maxv; /* Values */
+ unsigned int e, ee, f;
+ int gc[MAX_CHAN]; /* Grid coordinate */
+
+ minv = 1e6;
+ maxv = -1e6;
+
+ for (e = 0; e < p->inputChan; e++)
+ gc[e] = 0; /* init coords */
+
+ /* Search the whole table */
+ for (tp = p->clutTable, e = 0; e < p->inputChan; tp += p->outputChan) {
+ double v;
+ if (chan == -1) {
+ for (v = 0.0, f = 0; f < p->outputChan; f++)
+ v += tp[f];
+ } else {
+ v = tp[chan];
+ }
+ if (v < minv) {
+ minv = v;
+ for (ee = 0; ee < p->inputChan; ee++)
+ minp[ee] = gc[ee]/(p->clutPoints-1.0);
+ }
+ if (v > maxv) {
+ maxv = v;
+ for (ee = 0; ee < p->inputChan; ee++)
+ maxp[ee] = gc[ee]/(p->clutPoints-1.0);
+ }
+
+ /* Increment coord */
+ for (e = 0; e < p->inputChan; e++) {
+ if (++gc[e] < p->clutPoints)
+ break; /* No carry */
+ gc[e] = 0;
+ }
+ }
+}
+
+/* Convert XYZ throught Luts matrix */
+/* Return 0 on success, 1 if clipping occured, 2 on other error */
+static int icmLut_lookup_matrix(
+icmLut *p, /* Pointer to Lut object */
+double *out, /* Output array[outputChan] in ICC order - see Table 39 in 6.5.5 */
+double *in /* Input array[inputChan] */
+) {
+ double t0,t1; /* Take care if out == in */
+ t0 = p->e[0][0] * in[0] + p->e[0][1] * in[1] + p->e[0][2] * in[2];
+ t1 = p->e[1][0] * in[0] + p->e[1][1] * in[1] + p->e[1][2] * in[2];
+ out[2] = p->e[2][0] * in[0] + p->e[2][1] * in[1] + p->e[2][2] * in[2];
+ out[0] = t0;
+ out[1] = t1;
+
+ return 0;
+}
+
+/* Convert normalized numbers though this Luts input tables. */
+/* Return 0 on success, 1 if clipping occured, 2 on other error */
+static int icmLut_lookup_input(
+icmLut *p, /* Pointer to Lut object */
+double *out, /* Output array[inputChan] */
+double *in /* Input array[inputChan] */
+) {
+ int rv = 0;
+ unsigned int ix, n;
+ double inputEnt_1 = (double)(p->inputEnt-1);
+ double *table = p->inputTable;
+
+ if (p->inputEnt == 0) { /* Hmm. */
+ for (n = 0; n < p->inputChan; n++)
+ out[n] = in[n];
+ } else {
+ /* Use linear interpolation */
+ for (n = 0; n < p->inputChan; n++, table += p->inputEnt) {
+ double val, w;
+ val = in[n] * inputEnt_1;
+ if (val < 0.0) {
+ val = 0.0;
+ rv |= 1;
+ } else if (val > inputEnt_1) {
+ val = inputEnt_1;
+ rv |= 1;
+ }
+ ix = (unsigned int)floor(val); /* Grid coordinate */
+ if (ix > (p->inputEnt-2))
+ ix = (p->inputEnt-2);
+ w = val - (double)ix; /* weight */
+ val = table[ix];
+ out[n] = val + w * (table[ix+1] - val);
+ }
+ }
+ return rv;
+}
+
+/* Convert normalized numbers though this Luts multi-dimensional table. */
+/* using multi-linear interpolation. */
+static int icmLut_lookup_clut_nl(
+/* Return 0 on success, 1 if clipping occured, 2 on other error */
+icmLut *p, /* Pointer to Lut object */
+double *out, /* Output array[inputChan] */
+double *in /* Input array[outputChan] */
+) {
+ icc *icp = p->icp;
+ int rv = 0;
+ double *gp; /* Pointer to grid cube base */
+ double co[MAX_CHAN]; /* Coordinate offset with the grid cell */
+ double *gw, GW[1 << 8]; /* weight for each grid cube corner */
+
+ if (p->inputChan <= 8) {
+ gw = GW; /* Use stack allocation */
+ } else {
+ if ((gw = (double *) icp->al->malloc(icp->al, sat_mul((1 << p->inputChan), sizeof(double)))) == NULL) {
+ sprintf(icp->err,"icmLut_lookup_clut: malloc() failed");
+ return icp->errc = 2;
+ }
+ }
+
+ /* We are using an multi-linear (ie. Trilinear for 3D input) interpolation. */
+ /* The implementation here uses more multiplies that some other schemes, */
+ /* (for instance, see "Tri-Linear Interpolation" by Steve Hill, */
+ /* Graphics Gems IV, page 521), but has less involved bookeeping, */
+ /* needs less local storage for intermediate output values, does fewer */
+ /* output and intermediate value reads, and fp multiplies are fast on */
+ /* todays processors! */
+
+ /* Compute base index into grid and coordinate offsets */
+ {
+ unsigned int e;
+ double clutPoints_1 = (double)(p->clutPoints-1);
+ int clutPoints_2 = p->clutPoints-2;
+ gp = p->clutTable; /* Base of grid array */
+
+ for (e = 0; e < p->inputChan; e++) {
+ unsigned int x;
+ double val;
+ val = in[e] * clutPoints_1;
+ if (val < 0.0) {
+ val = 0.0;
+ rv |= 1;
+ } else if (val > clutPoints_1) {
+ val = clutPoints_1;
+ rv |= 1;
+ }
+ x = (unsigned int)floor(val); /* Grid coordinate */
+ if (x > clutPoints_2)
+ x = clutPoints_2;
+ co[e] = val - (double)x; /* 1.0 - weight */
+ gp += x * p->dinc[e]; /* Add index offset for base of cube */
+ }
+ }
+ /* Compute corner weights needed for interpolation */
+ {
+ unsigned int e;
+ int i, g = 1;
+ gw[0] = 1.0;
+ for (e = 0; e < p->inputChan; e++) {
+ for (i = 0; i < g; i++) {
+ gw[g+i] = gw[i] * co[e];
+ gw[i] *= (1.0 - co[e]);
+ }
+ g *= 2;
+ }
+ }
+ /* Now compute the output values */
+ {
+ int i;
+ unsigned int f;
+ double w = gw[0];
+ double *d = gp + p->dcube[0];
+ for (f = 0; f < p->outputChan; f++) /* Base of cube */
+ out[f] = w * d[f];
+ for (i = 1; i < (1 << p->inputChan); i++) { /* For all other corners of cube */
+ w = gw[i]; /* Strength reduce */
+ d = gp + p->dcube[i];
+ for (f = 0; f < p->outputChan; f++)
+ out[f] += w * d[f];
+ }
+ }
+ if (gw != GW)
+ icp->al->free(icp->al, (void *)gw);
+ return rv;
+}
+
+/* Convert normalized numbers though this Luts multi-dimensional table */
+/* using simplex interpolation. */
+static int icmLut_lookup_clut_sx(
+/* Return 0 on success, 1 if clipping occured, 2 on other error */
+icmLut *p, /* Pointer to Lut object */
+double *out, /* Output array[inputChan] */
+double *in /* Input array[outputChan] */
+) {
+ int rv = 0;
+ double *gp; /* Pointer to grid cube base */
+ double co[MAX_CHAN]; /* Coordinate offset with the grid cell */
+ int si[MAX_CHAN]; /* co[] Sort index, [0] = smalest */
+
+ /* We are using a simplex (ie. tetrahedral for 3D input) interpolation. */
+ /* This method is more appropriate for XYZ/RGB/CMYK input spaces, */
+
+ /* Compute base index into grid and coordinate offsets */
+ {
+ unsigned int e;
+ double clutPoints_1 = (double)(p->clutPoints-1);
+ int clutPoints_2 = p->clutPoints-2;
+ gp = p->clutTable; /* Base of grid array */
+
+ for (e = 0; e < p->inputChan; e++) {
+ unsigned int x;
+ double val;
+ val = in[e] * clutPoints_1;
+ if (val < 0.0) {
+ val = 0.0;
+ rv |= 1;
+ } else if (val > clutPoints_1) {
+ val = clutPoints_1;
+ rv |= 1;
+ }
+ x = (unsigned int)floor(val); /* Grid coordinate */
+ if (x > clutPoints_2)
+ x = clutPoints_2;
+ co[e] = val - (double)x; /* 1.0 - weight */
+ gp += x * p->dinc[e]; /* Add index offset for base of cube */
+ }
+ }
+#ifdef NEVER
+ /* Do selection sort on coordinates, smallest to largest. */
+ {
+ int e, f;
+ for (e = 0; e < p->inputChan; e++)
+ si[e] = e; /* Initial unsorted indexes */
+ for (e = 0; e < (p->inputChan-1); e++) {
+ double cosn;
+ cosn = co[si[e]]; /* Current smallest value */
+ for (f = e+1; f < p->inputChan; f++) { /* Check against rest */
+ int tt;
+ tt = si[f];
+ if (cosn > co[tt]) {
+ si[f] = si[e]; /* Exchange */
+ si[e] = tt;
+ cosn = co[tt];
+ }
+ }
+ }
+ }
+#else
+ /* Do insertion sort on coordinates, smallest to largest. */
+ {
+ int f, vf;
+ unsigned int e;
+ double v;
+ for (e = 0; e < p->inputChan; e++)
+ si[e] = e; /* Initial unsorted indexes */
+
+ for (e = 1; e < p->inputChan; e++) {
+ f = e;
+ v = co[si[f]];
+ vf = f;
+ while (f > 0 && co[si[f-1]] > v) {
+ si[f] = si[f-1];
+ f--;
+ }
+ si[f] = vf;
+ }
+ }
+#endif
+ /* Now compute the weightings, simplex vertices and output values */
+ {
+ unsigned int e, f;
+ double w; /* Current vertex weight */
+
+ w = 1.0 - co[si[p->inputChan-1]]; /* Vertex at base of cell */
+ for (f = 0; f < p->outputChan; f++)
+ out[f] = w * gp[f];
+
+ for (e = p->inputChan-1; e > 0; e--) { /* Middle verticies */
+ w = co[si[e]] - co[si[e-1]];
+ gp += p->dinc[si[e]]; /* Move to top of cell in next largest dimension */
+ for (f = 0; f < p->outputChan; f++)
+ out[f] += w * gp[f];
+ }
+
+ w = co[si[0]];
+ gp += p->dinc[si[0]]; /* Far corner from base of cell */
+ for (f = 0; f < p->outputChan; f++)
+ out[f] += w * gp[f];
+ }
+ return rv;
+}
+
+#ifdef NEVER // ~~~99 development code
+
+/* Convert normalized numbers though this Luts multi-dimensional table */
+/* using optimised simplex interpolation. */
+/* This version optimses the simplex split axis depending on the input */
+/* colorspace. */
+static int icmLut_lookup_clut_osx(
+/* Return 0 on success, 1 if clipping occured, 2 on other error */
+icmLut *p, /* Pointer to Lut object */
+double *out, /* Output array[inputChan] */
+double *in /* Input array[outputChan] */
+) {
+ int rv = 0;
+ double *gp; /* Pointer to grid cube base */
+ double co[MAX_CHAN]; /* Coordinate offset with the grid cell */
+ int si[MAX_CHAN]; /* co[] Sort index, [0] = smalest */
+ char xflip[MAX_CHAN]; /* Optimised simplex axis flip flags */
+
+ /* Compute base index into grid and coordinate offsets */
+ {
+ unsigned int e;
+ double clutPoints_1 = (double)(p->clutPoints-1);
+ int clutPoints_2 = p->clutPoints-2;
+ gp = p->clutTable; /* Base of grid array */
+
+ for (e = 0; e < p->inputChan; e++) {
+ unsigned int x;
+ double val;
+// ~~~999
+#ifdef NEVER
+ xflip[e] = p->finfo[e].bthff;
+ if (in[e] >= p->finfo[e].fth)
+ xflip[e] = p->finfo[e].athff;
+#else
+
+ xflip[e] = 0;
+ if (e == 0)
+ xflip[e] = 1;
+#endif
+ val = in[e] * clutPoints_1;
+ if (val < 0.0) {
+ val = 0.0;
+ rv |= 1;
+ } else if (val > clutPoints_1) {
+ val = clutPoints_1;
+ rv |= 1;
+ }
+ x = (unsigned int)floor(val); /* Grid coordinate */
+ if (x > clutPoints_2)
+ x = clutPoints_2;
+ co[e] = val - (double)x; /* 1.0 - weight */
+ gp += x * p->dinc[e]; /* Add index offset for base of cube */
+ if (xflip[e]) { /* Reverse sense of direction for this axis */
+ co[e] = 1.0 - co[e];
+ gp += p->dinc[e];
+ }
+ }
+ }
+//printf("*");fflush(stdout);
+#ifdef NEVER
+ /* Do selection sort on coordinates, smallest to largest. */
+ {
+ int e, f;
+ for (e = 0; e < p->inputChan; e++)
+ si[e] = e; /* Initial unsorted indexes */
+ for (e = 0; e < (p->inputChan-1); e++) {
+ double cosn;
+ cosn = co[si[e]]; /* Current smallest value */
+ for (f = e+1; f < p->inputChan; f++) { /* Check against rest */
+ int tt;
+ tt = si[f];
+ if (cosn > co[tt]) {
+ si[f] = si[e]; /* Exchange */
+ si[e] = tt;
+ cosn = co[tt];
+ }
+ }
+ }
+ }
+#else
+ /* Do insertion sort on coordinates, smallest to largest. */
+ {
+ int f, vf;
+ unsigned int e;
+ double v;
+ for (e = 0; e < p->inputChan; e++)
+ si[e] = e; /* Initial unsorted indexes */
+
+ for (e = 1; e < p->inputChan; e++) {
+ f = e;
+ v = co[si[f]];
+ vf = f;
+ while (f > 0 && co[si[f-1]] > v) {
+ si[f] = si[f-1];
+ f--;
+ }
+ si[f] = vf;
+ }
+ }
+#endif
+ /* Now compute the weightings, simplex vertices and output values */
+ {
+ unsigned int e, f;
+ double w; /* Current vertex weight */
+
+ w = 1.0 - co[si[p->inputChan-1]]; /* Vertex at base of cell */
+ for (f = 0; f < p->outputChan; f++)
+ out[f] = w * gp[f];
+
+ for (e = p->inputChan-1; e > 0; e--) { /* Middle verticies */
+ w = co[si[e]] - co[si[e-1]];
+ if (xflip[e])
+ gp -= p->dinc[si[e]]; /* Move to top of cell in next largest dimension */
+ else
+ gp += p->dinc[si[e]]; /* Move to top of cell in next largest dimension */
+ for (f = 0; f < p->outputChan; f++)
+ out[f] += w * gp[f];
+ }
+
+ w = co[si[0]];
+ if (xflip[0])
+ gp -= p->dinc[si[0]]; /* Far corner from base of cell */
+ else
+ gp += p->dinc[si[0]]; /* Far corner from base of cell */
+ for (f = 0; f < p->outputChan; f++)
+ out[f] += w * gp[f];
+ }
+ return rv;
+}
+
+#endif /* NEVER */ // ~~~99 development code
+
+
+/* Convert normalized numbers though this Luts output tables. */
+/* Return 0 on success, 1 if clipping occured, 2 on other error */
+static int icmLut_lookup_output(
+icmLut *p, /* Pointer to Lut object */
+double *out, /* Output array[outputChan] */
+double *in /* Input array[outputChan] */
+) {
+ int rv = 0;
+ unsigned int ix, n;
+ double outputEnt_1 = (double)(p->outputEnt-1);
+ double *table = p->outputTable;
+
+ if (p->outputEnt == 0) { /* Hmm. */
+ for (n = 0; n < p->outputChan; n++)
+ out[n] = in[n];
+ } else {
+ /* Use linear interpolation */
+ for (n = 0; n < p->outputChan; n++, table += p->outputEnt) {
+ double val, w;
+ val = in[n] * outputEnt_1;
+ if (val < 0.0) {
+ val = 0.0;
+ rv |= 1;
+ } else if (val > outputEnt_1) {
+ val = outputEnt_1;
+ rv |= 1;
+ }
+ ix = (unsigned int)floor(val); /* Grid coordinate */
+ if (ix > (p->outputEnt-2))
+ ix = (p->outputEnt-2);
+ w = val - (double)ix; /* weight */
+ val = table[ix];
+ out[n] = val + w * (table[ix+1] - val);
+ }
+ }
+ return rv;
+}
+
+/* ----------------------------------------------- */
+/* Pseudo - Hilbert count sequencer */
+
+/* This multi-dimensional count sequence is a distributed */
+/* Gray code sequence, with direction reversal on every */
+/* alternate power of 2 scale. */
+/* It is intended to aid cache coherence in multi-dimensional */
+/* regular sampling. It approximates the Hilbert curve sequence. */
+
+/* Initialise, returns total usable count */
+unsigned
+psh_init(
+psh *p, /* Pointer to structure to initialise */
+int di, /* Dimensionality */
+unsigned int res, /* Size per coordinate */
+int co[] /* Coordinates to initialise (May be NULL) */
+) {
+ int e;
+
+ p->di = di;
+ p->res = res;
+
+ /* Compute bits */
+ for (p->bits = 0; (1u << p->bits) < res; p->bits++)
+ ;
+
+ /* Compute the total count mask */
+ p->tmask = ((((unsigned)1) << (p->bits * di))-1);
+
+ /* Compute usable count */
+ p->count = 1;
+ for (e = 0; e < di; e++)
+ p->count *= res;
+
+ p->ix = 0;
+
+ if (co != NULL) {
+ for (e = 0; e < di; e++)
+ co[e] = 0;
+ }
+
+ return p->count;
+}
+
+/* Reset the counter */
+void
+psh_reset(
+psh *p /* Pointer to structure */
+) {
+ p->ix = 0;
+}
+
+/* Increment pseudo-hilbert coordinates */
+/* Return non-zero if count rolls over to 0 */
+int
+psh_inc(
+psh *p, /* Pointer to structure */
+int co[] /* Coordinates to return */
+) {
+ int di = p->di;
+ unsigned int res = p->res;
+ unsigned int bits = p->bits;
+ int e;
+
+ do {
+ unsigned int b;
+ int gix; /* Gray code index */
+
+ p->ix = (p->ix + 1) & p->tmask;
+
+ gix = p->ix ^ (p->ix >> 1); /* Convert to gray code index */
+
+ for (e = 0; e < di; e++)
+ co[e] = 0;
+
+ for (b = 0; b < bits; b++) { /* Distribute bits */
+ if (b & 1) {
+ for (e = di-1; e >= 0; e--) { /* In reverse order */
+ co[e] |= (gix & 1) << b;
+ gix >>= 1;
+ }
+ } else {
+ for (e = 0; e < di; e++) { /* In normal order */
+ co[e] |= (gix & 1) << b;
+ gix >>= 1;
+ }
+ }
+ }
+
+ /* Convert from Gray to binary coordinates */
+ for (e = 0; e < di; e++) {
+ unsigned int sh, tv;
+
+ for(sh = 1, tv = co[e];; sh <<= 1) {
+ unsigned ptv = tv;
+ tv ^= (tv >> sh);
+ if (ptv <= 1 || sh == 16)
+ break;
+ }
+ if (tv >= res) /* Dumbo filter - increment again if outside cube range */
+ break;
+ co[e] = tv;
+ }
+
+ } while (e < di);
+
+ return (p->ix == 0);
+}
+
+/* ------------------------------------------------------- */
+
+#ifndef COUNTERS_H
+
+/* Macros for a multi-dimensional counter. */
+
+/* Declare the counter name nn, maximum di mxdi, dimensions di, & count */
+/* This counter can have each dimension range clipped */
+
+#define FCOUNT(nn, mxdi, di) \
+ int nn[mxdi]; /* counter value */ \
+ int nn##_di = (di); /* Number of dimensions */ \
+ int nn##_stt[mxdi]; /* start count value */ \
+ int nn##_res[mxdi]; /* last count +1 */ \
+ int nn##_e /* dimension index */
+
+#define FRECONF(nn, start, endp1) \
+ for (nn##_e = 0; nn##_e < nn##_di; nn##_e++) { \
+ nn##_stt[nn##_e] = (start); /* start count value */ \
+ nn##_res[nn##_e] = (endp1); /* last count +1 */ \
+ }
+
+/* Set the counter value to 0 */
+#define FC_INIT(nn) \
+{ \
+ for (nn##_e = 0; nn##_e < nn##_di; nn##_e++) \
+ nn[nn##_e] = nn##_stt[nn##_e]; \
+ nn##_e = 0; \
+}
+
+/* Increment the counter value */
+#define FC_INC(nn) \
+{ \
+ for (nn##_e = 0; nn##_e < nn##_di; nn##_e++) { \
+ nn[nn##_e]++; \
+ if (nn[nn##_e] < nn##_res[nn##_e]) \
+ break; /* No carry */ \
+ nn[nn##_e] = nn##_stt[nn##_e]; \
+ } \
+}
+
+/* After increment, expression is TRUE if counter is done */
+#define FC_DONE(nn) \
+ (nn##_e >= nn##_di)
+
+#endif /* COUNTERS_H */
+
+/* Parameter to getNormFunc function */
+typedef enum {
+ icmFromLuti = 0, /* return "fromo Lut normalized index" conversion function */
+ icmToLuti = 1, /* return "to Lut normalized index" conversion function */
+ icmFromLutv = 2, /* return "from Lut normalized value" conversion function */
+ icmToLutv = 3 /* return "to Lut normalized value" conversion function */
+} icmNormFlag;
+
+/* Return an appropriate color space normalization function, */
+/* given the color space and Lut type */
+/* Return 0 on success, 1 on match failure */
+static int getNormFunc(
+ icc *icp,
+ icColorSpaceSignature csig,
+ icTagTypeSignature tagSig,
+ icmNormFlag flag,
+ void (**nfunc)(double *out, double *in)
+);
+
+#define CLIP_MARGIN 0.005 /* Margine to allow before reporting clipping = 0.5% */
+
+/* Helper function to set multiple Lut tables simultaneously. */
+/* Note that these tables all have to be compatible in */
+/* having the same configuration and resolution. */
+/* Set errc and return error number in underlying icc */
+/* Set warnc if there is clipping in the output values */
+/* 1 = input table, 2 = main clut, 3 = clut midpoin, 4 = midpoint interp, 5 = output table */
+int icmSetMultiLutTables(
+ int ntables, /* Number of tables to be set, 1..n */
+ icmLut **pp, /* Pointer to array of Lut objects */
+ int flags, /* Setting flags */
+ void *cbctx, /* Opaque callback context pointer value */
+ icColorSpaceSignature insig, /* Input color space */
+ icColorSpaceSignature outsig, /* Output color space */
+ void (*infunc)(void *cbctx, double *out, double *in),
+ /* Input transfer function, inspace->inspace' (NULL = default) */
+ /* Will be called ntables times for each input grid value */
+ double *inmin, double *inmax, /* Maximum range of inspace' values */
+ /* (NULL = default) */
+ void (*clutfunc)(void *cbntx, double *out, double *in),
+ /* inspace' -> outspace[ntables]' transfer function */
+ /* will be called once for each input' grid value, and */
+ /* ntables output values should be written consecutively */
+ /* to out[]. */
+ double *clutmin, double *clutmax, /* Maximum range of outspace' values */
+ /* (NULL = default) */
+ void (*outfunc)(void *cbntx, double *out, double *in))
+ /* Output transfer function, outspace'->outspace (NULL = deflt) */
+ /* Will be called ntables times on each output value */
+{
+ icmLut *p, *pn; /* Pointer to 0'th nd tn'th Lut object */
+ icc *icp; /* Pointer to common icc */
+ int tn;
+ unsigned int e, f, i, n;
+ double **clutTable2 = NULL; /* Cell center values for ICM_CLUT_SET_APXLS */
+ double *clutTable3 = NULL; /* Vertex smoothing radius values [ntables] per entry */
+ int dinc3[MAX_CHAN]; /* Dimensional increment through clut3 (in doubles) */
+ int dcube3[1 << MAX_CHAN]; /* Hyper cube offsets throught clut3 (in doubles) */
+ int ii[MAX_CHAN]; /* Index value */
+ psh counter; /* Pseudo-Hilbert counter */
+// double _iv[4 * MAX_CHAN], *iv = &_iv[MAX_CHAN], *ivn; /* Real index value/table value */
+ int maxchan; /* Actual max of input and output */
+ double *_iv, *iv, *ivn; /* Real index value/table value */
+ double imin[MAX_CHAN], imax[MAX_CHAN];
+ double omin[MAX_CHAN], omax[MAX_CHAN];
+ void (*ifromindex)(double *out, double *in); /* Index to input color space function */
+ void (*itoentry)(double *out, double *in); /* Input color space to entry function */
+ void (*ifromentry)(double *out, double *in); /* Entry to input color space function */
+ void (*otoentry)(double *out, double *in); /* Output colorspace to table value function */
+ void (*ofromentry)(double *out, double *in); /* Table value to output color space function */
+ int clip = 0;
+
+ /* Check that everything is OK to proceed */
+ if (ntables < 1 || ntables > MAX_CHAN) {
+ if (ntables >= 1) {
+ icp = pp[0]->icp;
+ sprintf(icp->err,"icmSetMultiLutTables has illegal number of tables %d",ntables);
+ return icp->errc = 1;
+ } else {
+ /* Can't write error message anywhere */
+ return 1;
+ }
+ }
+
+ p = pp[0];
+ icp = p->icp;
+
+ for (tn = 1; tn < ntables; tn++) {
+ if (pp[tn]->icp != icp) {
+ sprintf(icp->err,"icmSetMultiLutTables Tables base icc is different");
+ return icp->errc = 1;
+ }
+ if (pp[tn]->ttype != p->ttype) {
+ sprintf(icp->err,"icmSetMultiLutTables Tables have different Tage Type");
+ return icp->errc = 1;
+ }
+
+ if (pp[tn]->inputChan != p->inputChan) {
+ sprintf(icp->err,"icmSetMultiLutTables Tables have different inputChan");
+ return icp->errc = 1;
+ }
+ if (pp[tn]->outputChan != p->outputChan) {
+ sprintf(icp->err,"icmSetMultiLutTables Tables have different outputChan");
+ return icp->errc = 1;
+ }
+ if (pp[tn]->clutPoints != p->clutPoints) {
+ sprintf(icp->err,"icmSetMultiLutTables Tables have different clutPoints");
+ return icp->errc = 1;
+ }
+ }
+
+ if (getNormFunc(icp, insig, p->ttype, icmFromLuti, &ifromindex) != 0) {
+ sprintf(icp->err,"icmLut_set_tables index to input colorspace function lookup failed");
+ return icp->errc = 1;
+ }
+ if (getNormFunc(icp, insig, p->ttype, icmToLutv, &itoentry) != 0) {
+ sprintf(icp->err,"icmLut_set_tables input colorspace to table entry function lookup failed");
+ return icp->errc = 1;
+ }
+ if (getNormFunc(icp, insig, p->ttype, icmFromLutv, &ifromentry) != 0) {
+ sprintf(icp->err,"icmLut_set_tables table entry to input colorspace function lookup failed");
+ return icp->errc = 1;
+ }
+
+ if (getNormFunc(icp, outsig, p->ttype, icmToLutv, &otoentry) != 0) {
+ sprintf(icp->err,"icmLut_set_tables output colorspace to table entry function lookup failed");
+ return icp->errc = 1;
+ }
+ if (getNormFunc(icp, outsig, p->ttype, icmFromLutv, &ofromentry) != 0) {
+ sprintf(icp->err,"icmLut_set_tables table entry to output colorspace function lookup failed");
+ return icp->errc = 1;
+ }
+
+ /* Allocate an array to hold the input and output values. */
+ /* It needs to be able to hold di "index under valus as in[], */
+ /* and ntables ICM_CLUT_SET_FILTER values as out[], so we assume maxchan >= di */
+ maxchan = p->inputChan > p->outputChan ? p->inputChan : p->outputChan;
+ if ((_iv = (double *) icp->al->malloc(icp->al, sizeof(double) * maxchan * (ntables+1)))
+ == NULL) {
+ sprintf(icp->err,"icmLut_read: malloc() failed");
+ return icp->errc = 2;
+ }
+ iv = _iv + maxchan; /* Allow for "index under" and smoothing radius values */
+
+ /* Setup input table value min-max */
+ if (inmin == NULL || imax == NULL) {
+#ifdef SYMETRICAL_DEFAULT_LAB_RANGE /* Symetrical default range. */
+ /* We are assuming V2 Lab16 encoding, since this is a lut16type that always uses */
+ /* this encoding */
+ if (insig == icSigLabData) { /* Special case Lab */
+ double mn[3], mx[3];
+ /* This is to ensure that Lab 100,0,0 maps exactly to a clut grid point. */
+ /* This should work well if there is an odd grid resolution, */
+ /* and icclib is being used, as input lookup will */
+ /* be computed using floating point, so that the CLUT input value */
+ /* 0.5 can be represented exactly. */
+ /* Because the symetric range will cause slight clipping, */
+ /* only do it if the input table has sufficient resolution */
+ /* to represent the clipping faithfuly. */
+ if (p->inputEnt >= 64) {
+ if (p->ttype == icSigLut8Type) {
+ mn[0] = 0.0, mn[1] = mn[2] = -127.0;
+ mx[0] = 100.0, mx[1] = mx[2] = 127.0;
+ } else {
+ mn[0] = 0.0, mn[1] = mn[2] = -127.0 - 255.0/256.0;
+ mx[0] = 100.0, mx[1] = mx[2] = 127.0 + 255.0/256.0;
+ }
+ itoentry(imin, mn); /* Convert from input color space to table representation */
+ itoentry(imax, mx);
+ } else {
+ for (e = 0; e < p->inputChan; e++) {
+ imin[e] = 0.0;
+ imax[e] = 1.0;
+ }
+ }
+ } else
+#endif
+ {
+ for (e = 0; e < p->inputChan; e++) {
+ imin[e] = 0.0; /* We are assuming this is true for all other color spaces. */
+ imax[e] = 1.0;
+ }
+ }
+ } else {
+ itoentry(imin, inmin); /* Convert from input color space to table representation */
+ itoentry(imax, inmax);
+ }
+
+ /* Setup output table value min-max */
+ if (clutmin == NULL || clutmax == NULL) {
+#ifdef SYMETRICAL_DEFAULT_LAB_RANGE
+ /* This really isn't doing much, since the full range encoding doesn't need */
+ /* any adjustment to map a*b* 0 to an integer value. */
+ /* We are tweaking the 16 bit L* = 100 to the last index into */
+ /* the output table, which may help its accuracy slightly. */
+ /* We are assuming V2 Lab16 encoding, since this is a lut16type that always uses */
+ /* this encoding */
+ if (outsig == icSigLabData) { /* Special case Lab */
+ double mn[3], mx[3];
+ /* The output of the CLUT will be an 8 or 16 bit value, and we want to */
+ /* adjust the range so that the input grid point holding the white */
+ /* point can encode 0.0 exactly. */
+ /* Note that in the case of the a & b values, the range equates to */
+ /* normalised 0.0 .. 1.0, since 0 can be represented exactly in it. */
+ if (p->outputEnt >= 64) {
+ if (p->ttype == icSigLut8Type) {
+ mn[0] = 0.0, mn[1] = mn[2] = -128.0;
+ mx[0] = 100.0, mx[1] = mx[2] = 127.0;
+ } else {
+ mn[0] = 0.0, mn[1] = mn[2] = -128.0;
+ mx[0] = 100.0, mx[1] = mx[2] = (65535.0 * 255.0)/65280.0 - 128.0;
+ }
+ otoentry(omin, mn);/* Convert from output color space to table representation */
+ otoentry(omax, mx);
+ } else {
+ for (e = 0; e < p->inputChan; e++) {
+ omin[e] = 0.0;
+ omax[e] = 1.0;
+ }
+ }
+ } else
+#endif
+ {
+ for (f = 0; f < p->outputChan; f++) {
+ omin[f] = 0.0; /* We are assuming this is true for all other color spaces. */
+ omax[f] = 1.0;
+ }
+ }
+ } else {
+ otoentry(omin, clutmin);/* Convert from output color space to table representation */
+ otoentry(omax, clutmax);
+ }
+
+ /* Create the input table entry values */
+ for (tn = 0; tn < ntables; tn++) {
+ pn = pp[tn];
+ for (n = 0; n < pn->inputEnt; n++) {
+ double fv;
+ fv = n/(pn->inputEnt-1.0);
+ for (e = 0; e < pn->inputChan; e++)
+ iv[e] = fv;
+
+ ifromindex(iv,iv); /* Convert from index value to input color space value */
+
+ if (infunc != NULL)
+ infunc(cbctx, iv, iv); /* In colorspace -> input table -> In colorspace. */
+
+ itoentry(iv,iv); /* Convert from input color space value to table value */
+
+ /* Expand used range to 0.0 - 1.0, and clip to legal values */
+ /* Note that if the range is reduced, and clipping occurs, */
+ /* then there should be enough resolution within the input */
+ /* table, to represent the sharp edges of the clipping. */
+ for (e = 0; e < pn->inputChan; e++) {
+ double tt;
+ tt = (iv[e] - imin[e])/(imax[e] - imin[e]);
+ if (tt < 0.0) {
+ DBGSLC(("iclip: tt = %f, iv = %f, omin = %f, omax = %f\n",tt,iv[e],omin[e],omax[e]));
+ if (tt < -CLIP_MARGIN)
+ clip = 1;
+ tt = 0.0;
+ } else if (tt > 1.0) {
+ DBGSLC(("iclip: tt = %f, iv = %f, omin = %f, omax = %f\n",tt,iv[e],omin[e],omax[e]));
+ if (tt > (1.0 + CLIP_MARGIN))
+ clip = 1;
+ tt = 1.0;
+ }
+ iv[e] = tt;
+ }
+
+ for (e = 0; e < pn->inputChan; e++) /* Input tables */
+ pn->inputTable[e * pn->inputEnt + n] = iv[e];
+ }
+ }
+
+ /* Allocate space for cell center value lookup */
+ if (flags & ICM_CLUT_SET_APXLS) {
+ if ((clutTable2 = (double **) icp->al->calloc(icp->al,sizeof(double *), ntables)) == NULL) {
+ sprintf(icp->err,"icmLut_set_tables malloc of cube center array failed");
+ icp->al->free(icp->al, _iv);
+ return icp->errc = 1;
+ }
+ for (tn = 0; tn < ntables; tn++) {
+ if ((clutTable2[tn] = (double *) icp->al->calloc(icp->al,sizeof(double),
+ p->clutTable_size)) == NULL) {
+ for (--tn; tn >= 0; tn--)
+ icp->al->free(icp->al, clutTable2[tn]);
+ icp->al->free(icp->al, _iv);
+ icp->al->free(icp->al, clutTable2);
+ sprintf(icp->err,"icmLut_set_tables malloc of cube center array failed");
+ return icp->errc = 1;
+ }
+ }
+ }
+
+ /* Allocate space for smoothing radius values */
+ if (flags & ICM_CLUT_SET_FILTER) {
+ unsigned int j, g, size;
+
+ /* Private: compute dimensional increment though clut3 */
+ i = p->inputChan-1;
+ dinc3[i--] = ntables;
+ for (; i < p->inputChan; i--)
+ dinc3[i] = dinc3[i+1] * p->clutPoints;
+
+ /* Private: compute offsets from base of cube to other corners */
+ for (dcube3[0] = 0, g = 1, j = 0; j < p->inputChan; j++) {
+ for (i = 0; i < g; i++)
+ dcube3[g+i] = dcube3[i] + dinc3[j];
+ g *= 2;
+ }
+
+ if ((size = sat_mul(ntables, sat_pow(p->clutPoints,p->inputChan))) == UINT_MAX) {
+ sprintf(icp->err,"icmLut_alloc size overflow");
+ if (flags & ICM_CLUT_SET_APXLS) {
+ for (tn = 0; tn < ntables; tn++)
+ icp->al->free(icp->al, clutTable2[tn]);
+ }
+ icp->al->free(icp->al, clutTable2);
+ icp->al->free(icp->al, _iv);
+ return icp->errc = 1;
+ }
+
+ if ((clutTable3 = (double *) icp->al->calloc(icp->al,sizeof(double),
+ size)) == NULL) {
+ if (flags & ICM_CLUT_SET_APXLS) {
+ for (tn = 0; tn < ntables; tn++)
+ icp->al->free(icp->al, clutTable2[tn]);
+ }
+ icp->al->free(icp->al, clutTable2);
+ icp->al->free(icp->al, _iv);
+ sprintf(icp->err,"icmLut_set_tables malloc of vertex smoothing value array failed");
+ return icp->errc = 1;
+ }
+ }
+
+ /* Create the multi-dimensional lookup table values */
+
+ /* To make this clut function cache friendly, we use the pseudo-hilbert */
+ /* count sequence. This keeps each point close to the last in the */
+ /* multi-dimensional space. This is the point of setting multiple Luts at */
+ /* once too - the assumption is that these tables are all related (different */
+ /* gamut compressions for instance), and hence calling the clutfunc() with */
+ /* close values will maximise reverse lookup cache hit rate. */
+
+ psh_init(&counter, p->inputChan, p->clutPoints, ii); /* Initialise counter */
+
+ /* Itterate through all verticies in the grid */
+ for (;;) {
+ int ti, ti3; /* Table indexes */
+
+ for (ti = e = 0; e < p->inputChan; e++) { /* Input tables */
+ ti += ii[e] * p->dinc[e]; /* Clut index */
+ iv[e] = ii[e]/(p->clutPoints-1.0); /* Vertex coordinates */
+ iv[e] = iv[e] * (imax[e] - imin[e]) + imin[e]; /* Undo expansion to 0.0 - 1.0 */
+ *((int *)&iv[-((int)e)-1]) = ii[e]; /* Trick to supply grid index in iv[] */
+ }
+
+ if (flags & ICM_CLUT_SET_FILTER) {
+ for (ti3 = e = 0; e < p->inputChan; e++) /* Input tables */
+ ti3 += ii[e] * dinc3[e]; /* Clut3 index */
+ }
+
+ DBGSL(("\nix %s\n",icmPiv(p->inputChan, ii)));
+ DBGSL(("raw itv %s to iv'",icmPdv(p->inputChan, iv)));
+ ifromentry(iv,iv); /* Convert from table value to input color space */
+ DBGSL((" %s\n",icmPdv(p->inputChan, iv)));
+
+ /* Apply incolor -> outcolor function we want to represent for all tables */
+ DBGSL(("iv: %s to ov'",icmPdv(p->inputChan, iv)));
+ clutfunc(cbctx, iv, iv);
+ DBGSL((" %s\n",icmPdv(p->outputChan, iv)));
+
+ /* Save the results to the output tables */
+ for (tn = 0, ivn = iv; tn < ntables; ivn += p->outputChan, tn++) {
+ pn = pp[tn];
+
+ DBGSL(("tn %d, ov' %s -> otv",tn,icmPdv(p->outputChan, ivn)));
+ otoentry(ivn,ivn); /* Convert from output color space value to table value */
+ DBGSL((" %s\n -> oval",icmPdv(p->outputChan, ivn)));
+
+ /* Expand used range to 0.0 - 1.0, and clip to legal values */
+ for (f = 0; f < pn->outputChan; f++) {
+ double tt;
+ tt = (ivn[f] - omin[f])/(omax[f] - omin[f]);
+ if (tt < 0.0) {
+ DBGSLC(("lclip: tt = %f, ivn= %f, omin = %f, omax = %f\n",tt,ivn[f],omin[f],omax[f]));
+ if (tt < -CLIP_MARGIN)
+ clip = 2;
+ tt = 0.0;
+ } else if (tt > 1.0) {
+ DBGSLC(("lclip: tt = %f, ivn= %f, omin = %f, omax = %f\n",tt,ivn[f],omin[f],omax[f]));
+ if (tt > (1.0 + CLIP_MARGIN))
+ clip = 2;
+ tt = 1.0;
+ }
+ ivn[f] = tt;
+ }
+
+ for (f = 0; f < pn->outputChan; f++) /* Output chans */
+ pn->clutTable[ti + f] = ivn[f];
+ DBGSL((" %s\n",icmPdv(pn->outputChan, ivn)));
+
+ if (flags & ICM_CLUT_SET_FILTER) {
+ clutTable3[ti3 + tn] = iv[-1 -tn]; /* Filter radiuses */
+ }
+ }
+
+ /* Lookup cell center value if ICM_CLUT_SET_APXLS */
+ if (clutTable2 != NULL) {
+
+ for (e = 0; e < p->inputChan; e++) {
+ if (ii[e] >= (p->clutPoints-1))
+ break; /* Don't lookup beyond last */
+ iv[e] = (ii[e] + 0.5)/(p->clutPoints-1.0); /* Vertex coordinates + 0.5 */
+ iv[e] = iv[e] * (imax[e] - imin[e]) + imin[e]; /* Undo expansion to 0.0 - 1.0 */
+ *((int *)&iv[-((int)e)-1]) = ii[e]; /* Trick to supply grid index in iv[] */
+ /* (Not this is only the base for +0.5) */
+ }
+
+ if (e >= p->inputChan) { /* We're not on the last row */
+
+ ifromentry(iv,iv); /* Convert from table value to input color space */
+
+ /* Apply incolor -> outcolor function we want to represent */
+ clutfunc(cbctx, iv, iv);
+
+ /* Save the results to the output tables */
+ for (tn = 0, ivn = iv; tn < ntables; ivn += p->outputChan, tn++) {
+ pn = pp[tn];
+
+ otoentry(ivn,ivn); /* Convert from output color space value to table value */
+
+ /* Expand used range to 0.0 - 1.0, and clip to legal values */
+ for (f = 0; f < pn->outputChan; f++) {
+ double tt;
+ tt = (ivn[f] - omin[f])/(omax[f] - omin[f]);
+ if (tt < 0.0) {
+ DBGSLC(("lclip: tt = %f, ivn= %f, omin = %f, omax = %f\n",tt,ivn[f],omin[f],omax[f]));
+ if (tt < -CLIP_MARGIN)
+ clip = 3;
+ tt = 0.0;
+ } else if (tt > 1.0) {
+ DBGSLC(("lclip: tt = %f, ivn= %f, omin = %f, omax = %f\n",tt,ivn[f],omin[f],omax[f]));
+ if (tt > (1.0 + CLIP_MARGIN))
+ clip = 3;
+ tt = 1.0;
+ }
+ ivn[f] = tt;
+ }
+
+ for (f = 0; f < pn->outputChan; f++) /* Output chans */
+ clutTable2[tn][ti + f] = ivn[f];
+ }
+ }
+ }
+
+ /* Increment index within block (Reverse index significancd) */
+ if (psh_inc(&counter, ii))
+ break;
+ }
+
+#define APXLS_WHT 0.5
+#define APXLS_DIFF_THRHESH 0.2
+ /* Deal with cell center value, aproximate least squares adjustment. */
+ /* Subtract some of the mean of the surrounding center values from each grid value. */
+ /* Skip the edges so that things like the white point are not changed. */
+ /* Avoid modifying the value if the difference between the */
+ /* interpolated value and the current value is too great, */
+ /* and there is the possibility of different color aliases. */
+ if (clutTable2 != NULL) {
+ int ti; /* cube vertex table index */
+ int ti2; /* cube center table2 index */
+ int ee;
+ double cw = 1.0/(double)(1 << p->inputChan); /* Weight for each cube corner */
+
+ /* For each cell center point except last row */
+ for (e = 0; e < p->inputChan; e++)
+ ii[e] = 0; /* init coords */
+
+ /* Compute linear interpolated value from center values */
+ for (ee = 0; ee < p->inputChan;) {
+
+ /* Compute base index for table2 */
+ for (ti2 = e = 0; e < p->inputChan; e++) /* Input tables */
+ ti2 += ii[e] * p->dinc[e]; /* Clut index */
+
+ ti = ti2 + p->dcube[(1 << p->inputChan)-1]; /* +1 to each coord for vertex index */
+
+ for (tn = 0; tn < ntables; tn++) {
+ double mval[MAX_CHAN], vv;
+ double maxd = 0.0;
+
+ pn = pp[tn];
+
+ /* Compute mean of center values */
+ for (f = 0; f < pn->outputChan; f++) { /* Output chans */
+
+ mval[f] = 0.0;
+ for (i = 0; i < (1 << p->inputChan); i++) { /* For surrounding center values */
+ mval[f] += clutTable2[tn][ti2 + p->dcube[i] + f];
+ }
+ mval[f] = pn->clutTable[ti + f] - mval[f] * cw; /* Diff to mean */
+ vv = fabs(mval[f]);
+ if (vv > maxd)
+ maxd = vv;
+ }
+
+ if (pn->outputChan <= 3 || maxd < APXLS_DIFF_THRHESH) {
+ for (f = 0; f < pn->outputChan; f++) { /* Output chans */
+
+ vv = pn->clutTable[ti + f] + APXLS_WHT * mval[f];
+
+ /* Hmm. This is a bit crude. How do we know valid range is 0-1 ? */
+ /* What about an ink limit ? */
+ if (vv < 0.0) {
+ vv = 0.0;
+ } else if (vv > 1.0) {
+ vv = 1.0;
+ }
+ pn->clutTable[ti + f] = vv;
+ }
+ }
+ }
+
+ /* Increment coord */
+ for (ee = 0; ee < p->inputChan; ee++) {
+ if (++ii[ee] < (p->clutPoints-2)) /* Don't go through upper edge */
+ break; /* No carry */
+ ii[ee] = 0;
+ }
+ }
+
+ /* Done with center values */
+ for (tn = 0; tn < ntables; tn++)
+ icp->al->free(icp->al, clutTable2[tn]);
+ icp->al->free(icp->al, clutTable2);
+ }
+
+ /* Apply any smoothing in the clipped region to the resulting clutTable */
+ if (clutTable3 != NULL) {
+ double *clutTable1; /* Copy of current unfilted values */
+ FCOUNT(cc, MAX_CHAN, p->inputChan); /* Surrounding counter */
+
+ if ((clutTable1 = (double *) icp->al->calloc(icp->al,sizeof(double),
+ p->clutTable_size)) == NULL) {
+ icp->al->free(icp->al, clutTable3);
+ icp->al->free(icp->al, _iv);
+ sprintf(icp->err,"icmLut_set_tables malloc of grid copy failed");
+ return icp->errc = 1;
+ }
+
+ for (tn = 0; tn < ntables; tn++) {
+ int aa;
+ int ee;
+ int ti, ti3; /* Table indexes */
+
+ pn = pp[tn];
+
+ /* For each pass */
+ for (aa = 0; aa < 2; aa++) {
+
+ /* Copy current values */
+ memcpy(clutTable1, pn->clutTable, sizeof(double) * pn->clutTable_size);
+
+ /* Filter each point */
+ for (e = 0; e < pn->inputChan; e++)
+ ii[e] = 0; /* init coords */
+
+ /* Compute linear interpolated error to actual cell center value */
+ for (ee = 0; ee < pn->inputChan;) {
+ double rr; /* Filter radius */
+ int ir; /* Integer radius */
+ double tw; /* Total weight */
+
+ /* Compute base index for this cell */
+ for (ti3 = ti = e = 0; e < pn->inputChan; e++) { /* Input tables */
+ ti += ii[e] * pn->dinc[e]; /* Clut index */
+ ti3 += ii[e] * dinc3[e]; /* Clut3 index */
+ }
+ rr = clutTable3[ti3 + tn] * (pn->clutPoints-1.0);
+ ir = (int)floor(rr + 0.5); /* Don't bother unless 1/2 over vertex */
+
+ if (ir < 1)
+ goto next_vert;
+
+ //FRECONF(cc, -ir, ir + 1); /* Set size of surroundign grid */
+
+ /* Clip scanning cube to be within grid */
+ for (e = 0; e < pn->inputChan; e++) {
+ int cr = ir;
+ if ((ii[e] - ir) < 0)
+ cr = ii[e];
+ if ((ii[e] + ir) >= pn->clutPoints)
+ cr = pn->clutPoints -1 -ii[e];
+
+ cc_stt[e] = -cr;
+ cc_res[e] = cr + 1;
+ }
+
+ for (f = 0; f < pn->outputChan; f++)
+ pn->clutTable[ti + f] = 0.0;
+ tw = 0.0;
+
+ FC_INIT(cc)
+ for (tw = 0.0; !FC_DONE(cc);) {
+ double r;
+ int tti;
+
+ /* Radius of this cell */
+ for (r = 0.0, tti = e = 0; e < pn->inputChan; e++) {
+ int ix;
+ r += cc[e] * cc[e];
+ tti += (ii[e] + cc[e]) * p->dinc[e];
+ }
+ r = sqrt(r);
+
+ if (r <= rr && e >= pn->inputChan) {
+ double w = (rr - r)/rr; /* Triangle weighting */
+ w = sqrt(w);
+ for (f = 0; f < pn->outputChan; f++)
+ pn->clutTable[ti+f] += w * clutTable1[tti + f];
+ tw += w;
+ }
+ FC_INC(cc);
+ }
+ for (f = 0; f < pn->outputChan; f++) {
+ double vv = pn->clutTable[ti+f] / tw;
+ if (vv < 0.0) {
+ vv = 0.0;
+ } else if (vv > 1.0) {
+ vv = 1.0;
+ }
+ pn->clutTable[ti+f] = vv;
+ }
+
+ /* Increment coord */
+ next_vert:;
+ for (ee = 0; ee < pn->inputChan; ee++) {
+ if (++ii[ee] < (pn->clutPoints-1)) /* Don't go through upper edge */
+ break; /* No carry */
+ ii[ee] = 0;
+ }
+ } /* Next grid point to filter */
+ } /* Next pass */
+ } /* Next table */
+
+ free(clutTable1);
+ free(clutTable3);
+ }
+
+ /* Create the output table entry values */
+ for (tn = 0; tn < ntables; tn++) {
+ pn = pp[tn];
+ for (n = 0; n < pn->outputEnt; n++) {
+ double fv;
+ fv = n/(pn->outputEnt-1.0);
+ for (f = 0; f < pn->outputChan; f++)
+ iv[f] = fv;
+
+ /* Undo expansion to 0.0 - 1.0 */
+ for (f = 0; f < pn->outputChan; f++) /* Output tables */
+ iv[f] = iv[f] * (omax[f] - omin[f]) + omin[f];
+
+ ofromentry(iv,iv); /* Convert from table value to output color space value */
+
+ if (outfunc != NULL)
+ outfunc(cbctx, iv, iv); /* Out colorspace -> output table -> out colorspace. */
+
+ otoentry(iv,iv); /* Convert from output color space value to table value */
+
+ /* Clip to legal values */
+ for (f = 0; f < pn->outputChan; f++) {
+ double tt;
+ tt = iv[f];
+ if (tt < 0.0) {
+ DBGSLC(("oclip: tt = %f\n",tt));
+ if (tt < -CLIP_MARGIN)
+ clip = 5;
+ tt = 0.0;
+ } else if (tt > 1.0) {
+ DBGSLC(("oclip: tt = %f\n",tt));
+ if (tt > (1.0 + CLIP_MARGIN))
+ clip = 5;
+ tt = 1.0;
+ }
+ iv[f] = tt;
+ }
+
+ for (f = 0; f < pn->outputChan; f++) /* Input tables */
+ pn->outputTable[f * pn->outputEnt + n] = iv[f];
+ }
+ }
+
+ icp->al->free(icp->al, _iv);
+
+ icp->warnc = 0;
+ if (clip) {
+ DBGSLC(("Returning clip status = %d\n",clip));
+ icp->warnc = clip;
+ }
+
+ return 0;
+}
+
+/* Helper function to initialize a Lut tables contents */
+/* from supplied transfer functions. */
+/* Set errc and return error number */
+/* Set warnc if there is clipping in the output values */
+static int icmLut_set_tables (
+icmLut *p, /* Pointer to Lut object */
+int flags, /* Setting flags */
+void *cbctx, /* Opaque callback context pointer value */
+icColorSpaceSignature insig, /* Input color space */
+icColorSpaceSignature outsig, /* Output color space */
+void (*infunc)(void *cbcntx, double *out, double *in),
+ /* Input transfer function, inspace->inspace' (NULL = default) */
+double *inmin, double *inmax, /* Maximum range of inspace' values (NULL = default) */
+void (*clutfunc)(void *cbctx, double *out, double *in),
+ /* inspace' -> outspace' transfer function */
+double *clutmin, double *clutmax, /* Maximum range of outspace' values (NULL = default) */
+void (*outfunc)(void *cbctx, double *out, double *in)
+ /* Output transfer function, outspace'->outspace (NULL = deflt) */
+) {
+ struct _icmLut *pp[3];
+
+ /* Simply call the multiple table function with one table */
+ pp[0] = p;
+ return icmSetMultiLutTables(1, pp, flags,
+ cbctx, insig, outsig,
+ infunc,
+ inmin, inmax,
+ clutfunc,
+ clutmin, clutmax,
+ outfunc);
+}
+
+/* - - - - - - - - - - - - - - - - */
+/* Return the number of bytes needed to write this tag */
+static unsigned int icmLut_get_size(
+ icmBase *pp
+) {
+ icmLut *p = (icmLut *)pp;
+ unsigned int len = 0;
+
+ if (p->ttype == icSigLut8Type) {
+ len = sat_add(len, 48); /* tag and header */
+ len = sat_add(len, sat_mul3(1, p->inputChan, p->inputEnt));
+ len = sat_add(len, sat_mul3(1, p->outputChan, sat_pow(p->clutPoints,p->inputChan)));
+ len = sat_add(len, sat_mul3(1, p->outputChan, p->outputEnt));
+ } else {
+ len = sat_add(len, 52); /* tag and header */
+ len = sat_add(len, sat_mul3(2, p->inputChan, p->inputEnt));
+ len = sat_add(len, sat_mul3(2, p->outputChan, sat_pow(p->clutPoints,p->inputChan)));
+ len = sat_add(len, sat_mul3(2, p->outputChan, p->outputEnt));
+ }
+ return len;
+}
+
+/* read the object, return 0 on success, error code on fail */
+static int icmLut_read(
+ icmBase *pp,
+ unsigned int len, /* tag length */
+ unsigned int of /* start offset within file */
+) {
+ icmLut *p = (icmLut *)pp;
+ icc *icp = p->icp;
+ int rv = 0;
+ unsigned int i, j, g, size;
+ char *bp, *buf;
+
+ if (len < 4) {
+ sprintf(icp->err,"icmLut_read: Tag too small to be legal");
+ return icp->errc = 1;
+ }
+
+ /* Allocate a file read buffer */
+ if ((buf = (char *) icp->al->malloc(icp->al, len)) == NULL) {
+ sprintf(icp->err,"icmLut_read: malloc() failed");
+ return icp->errc = 2;
+ }
+ bp = buf;
+
+ /* Read portion of file into buffer */
+ if ( icp->fp->seek(icp->fp, of) != 0
+ || icp->fp->read(icp->fp, bp, 1, len) != len) {
+ sprintf(icp->err,"icmLut_read: fseek() or fread() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+
+ /* Read type descriptor from the buffer */
+ p->ttype = (icTagTypeSignature)read_SInt32Number(bp);
+ if (p->ttype != icSigLut8Type && p->ttype != icSigLut16Type) {
+ sprintf(icp->err,"icmLut_read: Wrong tag type for icmLut");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+
+ if (p->ttype == icSigLut8Type) {
+ if (len < 48) {
+ sprintf(icp->err,"icmLut_read: Tag too small to be legal");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ } else {
+ if (len < 52) {
+ sprintf(icp->err,"icmLut_read: Tag too small to be legal");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+ }
+
+ /* Read in the info common to 8 and 16 bit Lut */
+ p->inputChan = read_UInt8Number(bp+8);
+ p->outputChan = read_UInt8Number(bp+9);
+ p->clutPoints = read_UInt8Number(bp+10);
+
+ /* Sanity check */
+ if (p->inputChan > MAX_CHAN) {
+ sprintf(icp->err,"icmLut_read: Can't handle > %d input channels\n",MAX_CHAN);
+ return icp->errc = 1;
+ }
+
+ if (p->outputChan > MAX_CHAN) {
+ sprintf(icp->err,"icmLut_read: Can't handle > %d output channels\n",MAX_CHAN);
+ return icp->errc = 1;
+ }
+
+ /* Read 3x3 transform matrix */
+ for (j = 0; j < 3; j++) { /* Rows */
+ for (i = 0; i < 3; i++) { /* Columns */
+ p->e[j][i] = read_S15Fixed16Number(bp + 12 + ((j * 3 + i) * 4));
+ }
+ }
+ /* Read 16 bit specific stuff */
+ if (p->ttype == icSigLut8Type) {
+ p->inputEnt = 256; /* By definition */
+ p->outputEnt = 256; /* By definition */
+ bp = buf+48;
+ } else {
+ p->inputEnt = read_UInt16Number(bp+48);
+ p->outputEnt = read_UInt16Number(bp+50);
+ bp = buf+52;
+ }
+
+ /* Sanity check dimensions. This protects against */
+ /* subsequent integer overflows involving the dimensions. */
+ if ((size = icmLut_get_size((icmBase *)p)) == UINT_MAX
+ || size > len) {
+ sprintf(icp->err,"icmLut_read: Tag wrong size for contents");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;
+ }
+
+ /* Read the input tables */
+ size = (p->inputChan * p->inputEnt);
+ if ((rv = p->allocate((icmBase *)p)) != 0) {
+ icp->al->free(icp->al, buf);
+ return rv;
+ }
+ if (p->ttype == icSigLut8Type) {
+ for (i = 0; i < size; i++, bp += 1)
+ p->inputTable[i] = read_DCS8Number(bp);
+ } else {
+ for (i = 0; i < size; i++, bp += 2)
+ p->inputTable[i] = read_DCS16Number(bp);
+ }
+
+ /* Read the clut table */
+ size = (p->outputChan * sat_pow(p->clutPoints,p->inputChan));
+ if ((rv = p->allocate((icmBase *)p)) != 0) {
+ icp->al->free(icp->al, buf);
+ return rv;
+ }
+ if (p->ttype == icSigLut8Type) {
+ for (i = 0; i < size; i++, bp += 1)
+ p->clutTable[i] = read_DCS8Number(bp);
+ } else {
+ for (i = 0; i < size; i++, bp += 2)
+ p->clutTable[i] = read_DCS16Number(bp);
+ }
+
+ /* Read the output tables */
+ size = (p->outputChan * p->outputEnt);
+ if ((rv = p->allocate((icmBase *)p)) != 0) {
+ icp->al->free(icp->al, buf);
+ return rv;
+ }
+ if (p->ttype == icSigLut8Type) {
+ for (i = 0; i < size; i++, bp += 1)
+ p->outputTable[i] = read_DCS8Number(bp);
+ } else {
+ for (i = 0; i < size; i++, bp += 2)
+ p->outputTable[i] = read_DCS16Number(bp);
+ }
+
+ /* Private: compute dimensional increment though clut */
+ /* Note that first channel varies least rapidly. */
+ i = p->inputChan-1;
+ p->dinc[i--] = p->outputChan;
+ for (; i < p->inputChan; i--)
+ p->dinc[i] = p->dinc[i+1] * p->clutPoints;
+
+ /* Private: compute offsets from base of cube to other corners */
+ for (p->dcube[0] = 0, g = 1, j = 0; j < p->inputChan; j++) {
+ for (i = 0; i < g; i++)
+ p->dcube[g+i] = p->dcube[i] + p->dinc[j];
+ g *= 2;
+ }
+
+ icp->al->free(icp->al, buf);
+ return 0;
+}
+
+/* Write the contents of the object. Return 0 on sucess, error code on failure */
+static int icmLut_write(
+ icmBase *pp,
+ unsigned int of /* File offset to write from */
+) {
+ icmLut *p = (icmLut *)pp;
+ icc *icp = p->icp;
+ unsigned int i,j;
+ unsigned int len, size;
+ char *bp, *buf; /* Buffer to write from */
+ int rv = 0;
+
+ /* Allocate a file write buffer */
+ if ((len = p->get_size((icmBase *)p)) == UINT_MAX) {
+ sprintf(icp->err,"icmLut_write get_size overflow");
+ return icp->errc = 1;
+ }
+ if ((buf = (char *) icp->al->malloc(icp->al, len)) == NULL) {
+ sprintf(icp->err,"icmLut_write malloc() failed");
+ return icp->errc = 2;
+ }
+ bp = buf;
+
+ /* Write type descriptor to the buffer */
+ if ((rv = write_SInt32Number((int)p->ttype,bp)) != 0) {
+ sprintf(icp->err,"icmLut_write: write_SInt32Number() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+ write_SInt32Number(0,bp+4); /* Set padding to 0 */
+
+ /* Write the info common to 8 and 16 bit Lut */
+ if ((rv = write_UInt8Number(p->inputChan, bp+8)) != 0) {
+ sprintf(icp->err,"icmLut_write: write_UInt8Number() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+ if ((rv = write_UInt8Number(p->outputChan, bp+9)) != 0) {
+ sprintf(icp->err,"icmLut_write: write_UInt8Number() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+ if ((rv = write_UInt8Number(p->clutPoints, bp+10)) != 0) {
+ sprintf(icp->err,"icmLut_write: write_UInt8Number() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+
+ write_UInt8Number(0, bp+11); /* Set padding to 0 */
+
+ /* Write 3x3 transform matrix */
+ for (j = 0; j < 3; j++) { /* Rows */
+ for (i = 0; i < 3; i++) { /* Columns */
+ if ((rv = write_S15Fixed16Number(p->e[j][i],bp + 12 + ((j * 3 + i) * 4))) != 0) {
+ sprintf(icp->err,"icmLut_write: write_S15Fixed16Number() failed");
+ icp->al->free(icp->al, buf);
+ return icp->errc = rv;
+ }
+ }
+ }
+
+ /* Write 16 bit specific stuff */
+ if (p->ttype == icSigLut8Type) {
+ if (p->inputEnt != 256 || p->outputEnt != 256) {
+ sprintf(icp->err,"icmLut_write: 8 bit Input and Output tables must be 256 entries");
+ icp->al->free(icp->al, buf);
+ return icp->errc = 1;