Blob Blame History Raw
diff --strip-trailing-cr -c -r Argyll_V1.0.1/doc/printtarg.html Argyll_V1.0.2/doc/printtarg.html
*** Argyll_V1.0.1/doc/printtarg.html	Mon Jul 14 14:11:45 2008
--- Argyll_V1.0.2/doc/printtarg.html	Sun Jul 20 02:25:32 2008
***************
*** 95,101 ****
   href="#C">-C</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  Don't use TIFF compression</span></small><br>
  <small><span style="font-family: monospace;">&nbsp;<a href="#N">-N</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
! Use TIFF alpha N channels more than 4<br style="font-family: monospace;">
  </span><span style="font-family: monospace;">&nbsp;</span><a
   style="font-family: monospace;" href="#R">-R rsnum</a><span
   style="font-family: monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
--- 95,103 ----
   href="#C">-C</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  Don't use TIFF compression</span></small><br>
  <small><span style="font-family: monospace;">&nbsp;<a href="#N">-N</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
! Use TIFF alpha N channels more than 4<br>
! &nbsp;<a href="#Q">-Q nbits</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
! Quantize test values to fit in nbits<br style="font-family: monospace;">
  </span><span style="font-family: monospace;">&nbsp;</span><a
   style="font-family: monospace;" href="#R">-R rsnum</a><span
   style="font-family: monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
***************
*** 320,325 ****
--- 322,343 ----
  flag causes all the channels greater than 4 to be labelled as "Alpha"
  channels, which may be more palatable.<br>
  <br>
+ <a name="Q"></a><span style="font-weight: bold;">-Q:</span> Normally
+ the target device values are floating point numbers that may get
+ rounded and quantized in the process of printing them or reproducing
+ them on the printing or display device. If some of this quantization
+ can be accounted for, it may improve the accuracy of the resulting
+ profile, and the <span style="font-weight: bold;">Q</span> parameter
+ allows this quantization to be specified. The parameter is the number
+ of binary digits (bits) that the device values should be quantized to.
+ In many systems the right value would be 8 bits. Note that if 8 bit TIFF<span
+  style="font-weight: bold;"></span> output is selected (<span
+  style="font-weight: bold;">-t</span>) that the values will by default
+ be quanized to 8 bits, and that if 16 bit TIFF<span
+  style="font-weight: bold;"></span> output is selected (<span
+  style="font-weight: bold;">-T</span>) that the values will by default
+ be quanized to 16 bits.<br>
+ <br>
  <a name="R"></a> The <b>-R</b> parameter allows setting the random
  layout seed. Normally the seed is chosen at random, but sometimes it is
  useful to be able to generate a chart with the same layout, so a
diff --strip-trailing-cr -c -r Argyll_V1.0.1/h/config.h Argyll_V1.0.2/h/config.h
*** Argyll_V1.0.1/h/config.h	Mon Jul 14 14:11:41 2008
--- Argyll_V1.0.2/h/config.h	Sun Jul 20 02:25:28 2008
***************
*** 10,17 ****
  /* minor number = 8 bits */
  /* major number = 8 bits */
  
! #define ARGYLL_VERSION 0x01001
! #define ARGYLL_VERSION_STR "1.0.1"
  
  /* Maximum file path length */
  #define MAXNAMEL 512
--- 10,17 ----
  /* minor number = 8 bits */
  /* major number = 8 bits */
  
! #define ARGYLL_VERSION 0x01002
! #define ARGYLL_VERSION_STR "1.0.2"
  
  /* Maximum file path length */
  #define MAXNAMEL 512
diff --strip-trailing-cr -c -r Argyll_V1.0.1/imdi/Jamfile Argyll_V1.0.2/imdi/Jamfile
*** Argyll_V1.0.1/imdi/Jamfile	Mon Jul 14 14:11:32 2008
--- Argyll_V1.0.2/imdi/Jamfile	Sun Jul 20 02:25:18 2008
***************
*** 49,55 ****
  # TIFF file monochrome conversion utlity
  #Main greytiff : greytiff.c ;
  Main greytiff : greytiff.c : : : ../spectro ../xicc ../gamut ../rspl ../cgats $(TIFFINC)
!               : : ../xicc/libxicc ../gamut/libgamut ../rspl/librspl ../cgats/libcgats $(TIFFLIB) ;
  
  # ssort generation code
  #Main ssort : ssort.c ;
--- 49,56 ----
  # TIFF file monochrome conversion utlity
  #Main greytiff : greytiff.c ;
  Main greytiff : greytiff.c : : : ../spectro ../xicc ../gamut ../rspl ../cgats $(TIFFINC)
!               : : ../xicc/libxicc ../gamut/libgamut ../rspl/librspl ../cgats/libcgats
!                   ../plot/libplot $(TIFFLIB) ;
  
  # ssort generation code
  #Main ssort : ssort.c ;
diff --strip-trailing-cr -c -r Argyll_V1.0.1/log.txt Argyll_V1.0.2/log.txt
*** Argyll_V1.0.1/log.txt	Mon Jul 14 14:11:03 2008
--- Argyll_V1.0.2/log.txt	Sun Jul 20 02:24:46 2008
***************
*** 3,8 ****
--- 3,40 ----
  =====================
  
  
+ Version 1.0.2 bug fix release (open) 
+ -----------------------------
+ 
+ *	Modified MSWindows display enumeration to not ignore displays
+ 	that have EnumDisplayDevices() fail, but ignore displays
+ 	with a name \\.\\DISPLAYV*. This us to get it working under VMWARE. 
+ 
+ *	Added device target value quantization option to
+ 	target/printtarg, as well as making it default for TIFF output files.
+ 
+ *	Fixed a bad memory leak in render/render.c, that was
+ 	affecting target/printtarg. Probably improved the
+ 	anti-aliased rendering speed too.
+ 
+ *	Fix typo in spectro/dispwin.c that sometimes causes a crash
+ 	when the system has XRandR 1.2.
+ 
+ *	Fix latent bug in xicc/xfit.c that could affect
+ 	profiles that are not white point corrected (ie. colorof -u inputdevice). 
+ 
+ *	Fixed problem with an i1pro that has had it's
+ 	EEProm reset after a firmware upgrade - a previous
+ 	calibration EEPRom integration time of 0.0 is increased
+ 	to the minimum integration time to prevent divide by zero etc.
+ 
+ *	Added Argyll version number to the i1pro calibration file,	
+ 	to try and make sure that old files are invalidated with
+ 	each potentialy incompatible update.
+ 
+ *	Fix LUT entry depth reporting bug, and add yet another
+ 	workaround for the GCC/PPC optimizer bug.
+ 
  Version 1.0.1 bug fix release (14th July 2008) 
  -----------------------------
  
diff --strip-trailing-cr -c -r Argyll_V1.0.1/makepackagebin.sh Argyll_V1.0.2/makepackagebin.sh
*** Argyll_V1.0.1/makepackagebin.sh	Mon Jul 14 14:11:03 2008
--- Argyll_V1.0.2/makepackagebin.sh	Sun Jul 20 02:24:46 2008
***************
*** 25,30 ****
--- 25,32 ----
  # Set the environment string VERSION from the #define, ie 1.0.0
  VERSION=`grep ARGYLL_VERSION_STR h/config.h | sed 's/#define ARGYLL_VERSION_STR //' | sed 's/"//g'`
  
+ echo "About to make Argyll binary distribution $PACKAGE"
+ 
  TOPDIR=Argyll_V$VERSION
  
  if [ X$OS != "XWindows_NT" ] ; then
diff --strip-trailing-cr -c -r Argyll_V1.0.1/profile/Jamfile Argyll_V1.0.2/profile/Jamfile
*** Argyll_V1.0.1/profile/Jamfile	Mon Jul 14 14:11:35 2008
--- Argyll_V1.0.2/profile/Jamfile	Sun Jul 20 02:25:21 2008
***************
*** 26,32 ****
  Library libprof : profin.c profout.c ;
  
  
! LINKLIBS = ../rspl/librspl ../icc/libicc ../cgats/libcgats ../numlib/libnum ;
  
  # Simple profile generator
  Main simpprof : simpprof.c ;
--- 26,32 ----
  Library libprof : profin.c profout.c ;
  
  
! LINKLIBS = ../rspl/librspl ../icc/libicc ../cgats/libcgats ../numlib/libnum ../plot/libplot ;
  
  # Simple profile generator
  Main simpprof : simpprof.c ;
diff --strip-trailing-cr -c -r Argyll_V1.0.1/render/render.c Argyll_V1.0.2/render/render.c
*** Argyll_V1.0.1/render/render.c	Mon Jul 14 14:11:37 2008
--- Argyll_V1.0.2/render/render.c	Sun Jul 20 02:25:23 2008
***************
*** 162,172 ****
--- 162,176 ----
  	int noix;					/* Number in x list */
  	color2d *pixv0, *_pixv0;	/* Storage for pixel values around current */
  	color2d *pixv1, *_pixv1;
+ 	sobol *so;					/* Random sampler for anti-aliasing */
  	int i, j;
  
  	double rx0, rx1, ry0, ry1;	/* Box being processed, newest sample is rx1, ry1 */
  	int x, y;				/* Pixel x & y index */
  
+ 	if ((so = new_sobol(2)) == NULL)
+ 		return 1;
+ 
  	switch (s->csp) {
  		case w_2d:			/* Video style grey */
  			samplesperpixel = 1;
***************
*** 373,382 ****
  				 || pixv0[x-1][PRIX2D] != cc[PRIX2D] && colordiff(s, pixv0[x-1], cc)
  				 || pixv1[x-1][PRIX2D] != cc[PRIX2D] && colordiff(s, pixv1[x-1], cc)) {
  					double nn = 0;
- 					sobol *so;
  
! 					if ((so = new_sobol(2)) == NULL)
! 						return 1;
  
  					for (j = 0; j < s->ncc; j++)
  						cc[j] = 0.0;
--- 377,384 ----
  				 || pixv0[x-1][PRIX2D] != cc[PRIX2D] && colordiff(s, pixv0[x-1], cc)
  				 || pixv1[x-1][PRIX2D] != cc[PRIX2D] && colordiff(s, pixv1[x-1], cc)) {
  					double nn = 0;
  
! 					so->reset(so);
  
  					for (j = 0; j < s->ncc; j++)
  						cc[j] = 0.0;
***************
*** 418,424 ****
  					cc[1] = 0.0;
  					cc[2] = 1.0;
  #endif
- 
  				} else {
  
  					/* Compute output value as mean of surrounding samples */
--- 420,425 ----
***************
*** 451,457 ****
  							p[j] = (int)(cc[j] + 0.5);
  					} else {
  						for (j = 0; j < s->ncc; j++)
! 							p[j] = (int)(65525.0 * cc[j] + 0.5);
  					}
  				}
  			}
--- 452,458 ----
  							p[j] = (int)(cc[j] + 0.5);
  					} else {
  						for (j = 0; j < s->ncc; j++)
! 							p[j] = (int)(65535.0 * cc[j] + 0.5);
  					}
  				}
  			}
***************
*** 479,484 ****
--- 480,487 ----
  	_TIFFfree(outbuf);
  	TIFFClose(wh);		/* Close Output file */
  
+ 	so->del(so);
+ 
  	return 0;
  }
  
diff --strip-trailing-cr -c -r Argyll_V1.0.1/spectro/Jamfile Argyll_V1.0.2/spectro/Jamfile
*** Argyll_V1.0.1/spectro/Jamfile	Mon Jul 14 14:11:29 2008
--- Argyll_V1.0.2/spectro/Jamfile	Sun Jul 20 02:25:15 2008
***************
*** 1,7 ****
  
  
! PREF_CCFLAGS 	+= $(CCOPTFLAG) ;		# Turn optimisation on
! #PREF_CCFLAGS    += $(CCDEBUGFLAG) ;		# Debugging flags
  PREF_LINKFLAGS	+= $(LINKDEBUGFLAG) ;
  
  # Setup the right hardware access libraries
--- 1,7 ----
  
  
! #PREF_CCFLAGS 	+= $(CCOPTFLAG) ;		# Turn optimisation on
! PREF_CCFLAGS    += $(CCDEBUGFLAG) ;		# Debugging flags
  PREF_LINKFLAGS	+= $(LINKDEBUGFLAG) ;
  
  # Setup the right hardware access libraries
diff --strip-trailing-cr -c -r Argyll_V1.0.1/spectro/dispcal.c Argyll_V1.0.2/spectro/dispcal.c
*** Argyll_V1.0.1/spectro/dispcal.c	Mon Jul 14 14:11:29 2008
--- Argyll_V1.0.2/spectro/dispcal.c	Sun Jul 20 02:25:15 2008
***************
*** 766,771 ****
--- 766,774 ----
  #if defined(__APPLE__) && defined(__POWERPC__)
  
  /* Workaround for a ppc gcc 3.3 optimiser bug... */
+ /* It seems to cause a segmentation fault instead of */
+ /* converting an integer loop index into a float, */
+ /* when there are sufficient variables in play. */
  static int gcc_bug_fix(int i) {
  	static int nn;
  	nn += i;
***************
*** 1737,1743 ****
  		double vct, vct_de;
  		double vdt, vdt_de;
  		double cgamma, w[3], wp[2];
! 		int sigbits;	/* Number of significant bits in VideoLUT/display/instrument */
  
  		if ((rv = dr->read(dr, tcols, 3, 1, 3, 1, 0)) != 0) {
  			dr->del(dr);
--- 1740,1746 ----
  		double vct, vct_de;
  		double vdt, vdt_de;
  		double cgamma, w[3], wp[2];
! 		int sigbits = 0;	/* Number of significant bits in VideoLUT/display/instrument */
  
  		if ((rv = dr->read(dr, tcols, 3, 1, 3, 1, 0)) != 0) {
  			dr->del(dr);
***************
*** 1785,1790 ****
--- 1788,1796 ----
  				/* Do the test */
  				for (n = 0; n < res_samps; n++) {
  					double v;
+ #if defined(__APPLE__) && defined(__POWERPC__)
+ 					gcc_bug_fix(sigbits);
+ #endif
  					v = (5 << (sigbits-3))/((1 << sigbits) - 1.0);
  					if ((n % 3) == 2)
  						v += 1.0/((1 << sigbits) - 1.0);
***************
*** 1900,1909 ****
  		printf("White        Visual Color Temperature = %.0fK, DE to locus = %4.1f\n",vct,vct_de);
  		printf("White     Visual Daylight Temperature = %.0fK, DE to locus = %4.1f\n",vdt,vdt_de);
  #ifdef	MEAS_RES
! 		if (sigbits == 0) {
! 			warning("Unable to determine LUT entry bit depth - problems ?");
! 		} else if (verb) {
! 			printf("Effective LUT entry depth seems to be %d bits\n",sigbits);
  		}
  #endif	/* MEAS_RES */
  		dr->del(dr);
--- 1906,1917 ----
  		printf("White        Visual Color Temperature = %.0fK, DE to locus = %4.1f\n",vct,vct_de);
  		printf("White     Visual Daylight Temperature = %.0fK, DE to locus = %4.1f\n",vdt,vdt_de);
  #ifdef	MEAS_RES
! 		if (doreport == 1) {
! 			if (sigbits == 0) {
! 				warning("Unable to determine LUT entry bit depth - problems ?");
! 			} else if (verb) {
! 				printf("Effective LUT entry depth seems to be %d bits\n",sigbits);
! 			}
  		}
  #endif	/* MEAS_RES */
  		dr->del(dr);
diff --strip-trailing-cr -c -r Argyll_V1.0.1/spectro/dispwin.c Argyll_V1.0.2/spectro/dispwin.c
*** Argyll_V1.0.1/spectro/dispwin.c	Mon Jul 14 14:11:31 2008
--- Argyll_V1.0.2/spectro/dispwin.c	Sun Jul 20 02:25:17 2008
***************
*** 108,113 ****
--- 108,126 ----
  	
  	debugrr2((errout, "MonitorEnumProc() called with hMonitor = 0x%x\n",hMonitor));
  
+ 	/* Get some more information */
+ 	pmi.cbSize = sizeof(MONITORINFOEX);
+ 	if (GetMonitorInfo(hMonitor, (MONITORINFO *)&pmi) == 0) {
+ 		debugrr("get_displays failed GetMonitorInfo - ignoring display\n");
+ 		return TRUE;
+ 	}
+ 
+ 	/* See if it seems to be a pseudo-display */
+ 	if (strncmp(pmi.szDevice, "\\\\.\\DISPLAYV", 12) == 0) {
+ 		debugrr("Seems to be invisible pseudo-display - ignoring it\n");
+ 		return TRUE;
+ 	}
+ 
  	/* Add the display to the list */
  	if (disps == NULL) {
  		if ((disps = (disppath **)calloc(sizeof(disppath *), 1 + 1)) == NULL) {
***************
*** 131,142 ****
  		return FALSE;
  	}
  
- 	pmi.cbSize = sizeof(MONITORINFOEX);
- 	if (GetMonitorInfo(hMonitor, (MONITORINFO *)&pmi) == 0) {
- 		debugrr("get_displays failed GetMonitorInfo\n");
- 		return FALSE;
- 	}
- 
  	if ((disps[ndisps]->name = strdup(pmi.szDevice)) == NULL) {
  		debugrr("malloc failed\n");
  		return FALSE;
--- 144,149 ----
***************
*** 240,246 ****
  
  	/* Now locate detailed information about displays */
  	for (i = 0; ; i++) {
! 		if (disps[i] == NULL)
  			break;
  
  		dd.cb = sizeof(dd);
--- 247,253 ----
  
  	/* Now locate detailed information about displays */
  	for (i = 0; ; i++) {
! 		if (disps == NULL || disps[i] == NULL)
  			break;
  
  		dd.cb = sizeof(dd);
***************
*** 250,255 ****
--- 257,265 ----
  		for (j = 0; ;j++) {
  			if ((*pEnumDisplayDevices)(disps[i]->name, j, &dd, 0) == 0) {
  				debugrr2((errout,"EnumDisplayDevices failed on '%s' Mon = %d\n",disps[i]->name,j));
+ 				if (j == 0) {
+ 					strcpy(disps[i]->monid, "");		/* We won't be able to set a profile */
+ 				}
  				break;
  			}
  			if (callback_ddebug) {
***************
*** 260,274 ****
  				fprintf(errout,"Mon %d, key '%s'\n",j,dd.DeviceKey);
  			}
  			if (j == 0) {
- 				strcpy(disps[i]->monname, dd.DeviceName);
  				strcpy(disps[i]->monid, dd.DeviceID);
  			}
  		}
- 		if (j == 0) {		/* Hmm. Ignore this display */
- 			del_disppath(disps, i);
- 			i--;
- 			continue;
- 		}
  
  		sprintf(buf,"%s, at %d, %d, width %d, height %d%s",disps[i]->name+4,
  	        disps[i]->sx, disps[i]->sy, disps[i]->sw, disps[i]->sh,
--- 270,278 ----
***************
*** 626,632 ****
  				        disps[ndisps]->sx, disps[ndisps]->sy, disps[ndisps]->sw, disps[ndisps]->sh);
  
  					/* See if it is a clone */
! 					for (k = 0; 0 < ndisps; k++) {
  						if (disps[k]->crtc == disps[ndisps]->crtc) {
  							sprintf(desc1, "[ Clone of %d ]",k+1);
  							strcat(desc2, desc1);
--- 630,636 ----
  				        disps[ndisps]->sx, disps[ndisps]->sy, disps[ndisps]->sw, disps[ndisps]->sh);
  
  					/* See if it is a clone */
! 					for (k = 0; k < ndisps; k++) {
  						if (disps[k]->crtc == disps[ndisps]->crtc) {
  							sprintf(desc1, "[ Clone of %d ]",k+1);
  							strcat(desc2, desc1);
***************
*** 2832,2838 ****
  			dispwin_del(p);
  			return NULL;
  		}
- 		strcpy(p->monname, disp->monname);
  		strcpy(p->monid, disp->monid);
  
  		disp_hsz = GetDeviceCaps(p->hdc, HORZSIZE);	/* mm */
--- 2836,2841 ----
diff --strip-trailing-cr -c -r Argyll_V1.0.1/spectro/dispwin.h Argyll_V1.0.2/spectro/dispwin.h
*** Argyll_V1.0.1/spectro/dispwin.h	Mon Jul 14 14:11:31 2008
--- Argyll_V1.0.2/spectro/dispwin.h	Sun Jul 20 02:25:17 2008
***************
*** 78,84 ****
  	int sx,sy;			/* Displays offset in pixels */
  	int sw,sh;			/* Displays width and height in pixels*/
  #ifdef NT
- 	char monname[32];	/* Monitor Name */
  	char monid[128];	/* Monitor ID */
  	int prim;			/* NZ if primary display monitor */
  #endif /* NT */
--- 78,83 ----
***************
*** 163,169 ****
  	char *callout;		/* if not NULL - set color Shell callout routine */
  
  #ifdef NT
- 	char monname[32];	/* Monitor Name (ie. '\\.\DISPLAY1\Monitor0') */
  	char monid[128];	/* Monitor ID (ie. 'Monitor\MEA1773\{4D36E96E-E325-11CE-BFC1-08002BE10318}\0015'*/
  	HDC hdc;			/* Handle to display */
  	char *AppName;
--- 162,167 ----
diff --strip-trailing-cr -c -r Argyll_V1.0.1/spectro/huey.c Argyll_V1.0.2/spectro/huey.c
*** Argyll_V1.0.1/spectro/huey.c	Mon Jul 14 14:11:30 2008
--- Argyll_V1.0.2/spectro/huey.c	Sun Jul 20 02:25:16 2008
***************
*** 62,68 ****
  static inst_code huey_check_unlock(huey *p);
  
  #define CALFACTOR 3.428         /* Emissive magic calibration factor */
! #define AMB_SCALE_FACTOR 7.806e-3	/* Ambient mode scale factor */ 
  									/* This is only approximate, and were derived */
  									/* by matching readings from the i1pro. */
  
--- 62,69 ----
  static inst_code huey_check_unlock(huey *p);
  
  #define CALFACTOR 3.428         /* Emissive magic calibration factor */
! //#define AMB_SCALE_FACTOR 7.806e-3	/* Ambient mode scale factor */ 
! #define AMB_SCALE_FACTOR 5.772e-3	/* Ambient mode scale factor */ 
  									/* This is only approximate, and were derived */
  									/* by matching readings from the i1pro. */
  
diff --strip-trailing-cr -c -r Argyll_V1.0.1/spectro/i1pro_imp.c Argyll_V1.0.2/spectro/i1pro_imp.c
*** Argyll_V1.0.1/spectro/i1pro_imp.c	Mon Jul 14 14:11:30 2008
--- Argyll_V1.0.2/spectro/i1pro_imp.c	Sun Jul 20 02:25:16 2008
***************
*** 232,238 ****
  	if ((m = (i1proimp *)calloc(1, sizeof(i1proimp))) == NULL) {
  		DBG((dbgo,"add_i1proimp malloc %d bytes failed (1)\n",sizeof(i1proimp)))
  		if (p->verb) printf("Malloc %d bytes failed (1)\n",sizeof(i1proimp));
! 		I1PRO_INT_MALLOC;
  	}
  	m->p = p;
  
--- 232,238 ----
  	if ((m = (i1proimp *)calloc(1, sizeof(i1proimp))) == NULL) {
  		DBG((dbgo,"add_i1proimp malloc %d bytes failed (1)\n",sizeof(i1proimp)))
  		if (p->verb) printf("Malloc %d bytes failed (1)\n",sizeof(i1proimp));
! 		return I1PRO_INT_MALLOC;
  	}
  	m->p = p;
  
***************
*** 553,559 ****
  				case i1p_refl_spot:
  					s->reflective = 1;
  					s->adaptive = 1;
! 					s->inttime = 0.02366;		/* Should get this from the log */ 
  
  					s->dadaptime = 0.10;
  					s->wadaptime = 0.10;
--- 553,559 ----
  				case i1p_refl_spot:
  					s->reflective = 1;
  					s->adaptive = 1;
! 					s->inttime = 0.02366;		/* Should get this from the log ?? */ 
  
  					s->dadaptime = 0.10;
  					s->wadaptime = 0.10;
***************
*** 962,975 ****
  	 || (s->emiss && !s->adaptive && *calc == inst_calc_man_em_dark)
  	 || (s->trans && !s->adaptive && *calc == inst_calc_man_trans_dark)) {
  
- 		DBG((dbgo,"Doing initial black calibration with current int_time %f, gainmode %d\n", s->inttime, s->gainmode))
- 
  		nummeas = i1pro_comp_nummeas(p, s->dcaltime, s->inttime);
  		if ((ev = i1pro_dark_measure(p, s->dark_data, nummeas, &s->inttime, s->gainmode))
  	                                                                         != I1PRO_OK)
  			return ev;
  		if (s->emiss && !s->scan && !s->adaptive) {
  			nummeas = i1pro_comp_nummeas(p, s->dcaltime2, s->dark_int_time2);
  			if ((ev = i1pro_dark_measure(p, s->dark_data2, nummeas, &s->dark_int_time2,
  			                                                   s->gainmode)) != I1PRO_OK)
  				return ev;
--- 962,976 ----
  	 || (s->emiss && !s->adaptive && *calc == inst_calc_man_em_dark)
  	 || (s->trans && !s->adaptive && *calc == inst_calc_man_trans_dark)) {
  
  		nummeas = i1pro_comp_nummeas(p, s->dcaltime, s->inttime);
+ 
+ 		DBG((dbgo,"Doing initial black calibration with dcaltime %f, int_time %f, nummeas %d, gainmode %d\n", s->dcaltime, s->inttime, nummeas, s->gainmode))
  		if ((ev = i1pro_dark_measure(p, s->dark_data, nummeas, &s->inttime, s->gainmode))
  	                                                                         != I1PRO_OK)
  			return ev;
  		if (s->emiss && !s->scan && !s->adaptive) {
  			nummeas = i1pro_comp_nummeas(p, s->dcaltime2, s->dark_int_time2);
+ 			DBG((dbgo,"Doing 2nd initial black calibration with dcaltime2 %f, dark_int_time2 %f, nummeas %d, gainmode %d\n", s->dcaltime2, s->dark_int_time2, nummeas, s->gainmode))
  			if ((ev = i1pro_dark_measure(p, s->dark_data2, nummeas, &s->dark_int_time2,
  			                                                   s->gainmode)) != I1PRO_OK)
  				return ev;
***************
*** 990,1016 ****
  		/* The black reference is probably temeprature dependent, but */
  		/* there's not much we can do about this. */
  	
- 		DBG((dbgo,"Doing adaptive interpolated black calibration\n"))
  
  		s->idark_int_time[0] = 0.01;
  		nummeas = i1pro_comp_nummeas(p, s->dcaltime, s->idark_int_time[0]);
  		if ((ev = i1pro_dark_measure(p, s->idark_data[0], nummeas, &s->idark_int_time[0], 0))
  		                                                                          != I1PRO_OK)
  			return ev;
  	
  		s->idark_int_time[1] = 1.0;
  		nummeas = i1pro_comp_nummeas(p, s->dcaltime, s->idark_int_time[1]);
  		if ((ev = i1pro_dark_measure(p, s->idark_data[1], nummeas, &s->idark_int_time[1], 0))
  		                                                                          != I1PRO_OK)
  			return ev;
  	
  		s->idark_int_time[2] = 0.01;
  		nummeas = i1pro_comp_nummeas(p, s->dcaltime, s->idark_int_time[2]);
  		if ((ev = i1pro_dark_measure(p, s->idark_data[2], nummeas, &s->idark_int_time[2], 1))
  		                                                                          != I1PRO_OK)
  			return ev;
  	
  		s->idark_int_time[3] = 1.0;
  		nummeas = i1pro_comp_nummeas(p, s->dcaltime, s->idark_int_time[3]);
  		if ((ev = i1pro_dark_measure(p, s->idark_data[3], nummeas, &s->idark_int_time[3], 1))
  		                                                                          != I1PRO_OK)
--- 991,1020 ----
  		/* The black reference is probably temeprature dependent, but */
  		/* there's not much we can do about this. */
  	
  
  		s->idark_int_time[0] = 0.01;
  		nummeas = i1pro_comp_nummeas(p, s->dcaltime, s->idark_int_time[0]);
+ 		DBG((dbgo,"Doing adaptive interpolated black calibration, dcaltime %f, idark_int_time[0] %f, nummeas %d, gainmode %d\n", s->dcaltime, s->idark_int_time[0], nummeas, s->gainmode))
  		if ((ev = i1pro_dark_measure(p, s->idark_data[0], nummeas, &s->idark_int_time[0], 0))
  		                                                                          != I1PRO_OK)
  			return ev;
  	
  		s->idark_int_time[1] = 1.0;
  		nummeas = i1pro_comp_nummeas(p, s->dcaltime, s->idark_int_time[1]);
+ 		DBG((dbgo,"Doing adaptive interpolated black calibration, dcaltime %f, idark_int_time[1] %f, nummeas %d, gainmode %d\n", s->dcaltime, s->idark_int_time[1], nummeas, s->gainmode))
  		if ((ev = i1pro_dark_measure(p, s->idark_data[1], nummeas, &s->idark_int_time[1], 0))
  		                                                                          != I1PRO_OK)
  			return ev;
  	
  		s->idark_int_time[2] = 0.01;
  		nummeas = i1pro_comp_nummeas(p, s->dcaltime, s->idark_int_time[2]);
+ 		DBG((dbgo,"Doing adaptive interpolated black calibration, dcaltime %f, idark_int_time[2] %f, nummeas %d, gainmode %d\n", s->dcaltime, s->idark_int_time[2], nummeas, s->gainmode))
  		if ((ev = i1pro_dark_measure(p, s->idark_data[2], nummeas, &s->idark_int_time[2], 1))
  		                                                                          != I1PRO_OK)
  			return ev;
  	
  		s->idark_int_time[3] = 1.0;
+ 		DBG((dbgo,"Doing adaptive interpolated black calibration, dcaltime %f, idark_int_time[3] %f, nummeas %d, gainmode %d\n", s->dcaltime, s->idark_int_time[3], nummeas, s->gainmode))
  		nummeas = i1pro_comp_nummeas(p, s->dcaltime, s->idark_int_time[3]);
  		if ((ev = i1pro_dark_measure(p, s->idark_data[3], nummeas, &s->idark_int_time[3], 1))
  		                                                                          != I1PRO_OK)
***************
*** 1062,1068 ****
  
  	}
  
! 	/* Deal with an emsisive/transmisive adaptive black reference */
  	/* when in scan mode. */
  	if ((s->emiss && s->adaptive && s->scan && *calc == inst_calc_man_em_dark)
  	 || (s->trans && s->adaptive && s->scan && *calc == inst_calc_man_trans_dark)) {
--- 1066,1072 ----
  
  	}
  
! 	/* Deal with an emissive/transmisive adaptive black reference */
  	/* when in scan mode. */
  	if ((s->emiss && s->adaptive && s->scan && *calc == inst_calc_man_em_dark)
  	 || (s->trans && s->adaptive && s->scan && *calc == inst_calc_man_trans_dark)) {
***************
*** 1072,1087 ****
  		/* but we don't know what gain mode will be used, so measure both, */
  		/* and choose the appropriate one on the fly. */
  	
- 		DBG((dbgo,"Doing adaptive scan black calibration\n"))
  
  		s->idark_int_time[0] = s->inttime;
  		nummeas = i1pro_comp_nummeas(p, s->dcaltime, s->idark_int_time[0]);
  		if ((ev = i1pro_dark_measure(p, s->idark_data[0], nummeas, &s->idark_int_time[0], 0))
  		                                                                          != I1PRO_OK)
  			return ev;
  	
  		s->idark_int_time[2] = s->inttime;
  		nummeas = i1pro_comp_nummeas(p, s->dcaltime, s->idark_int_time[2]);
  		if ((ev = i1pro_dark_measure(p, s->idark_data[2], nummeas, &s->idark_int_time[2], 1))
  		                                                                          != I1PRO_OK)
  			return ev;
--- 1076,1092 ----
  		/* but we don't know what gain mode will be used, so measure both, */
  		/* and choose the appropriate one on the fly. */
  	
  
  		s->idark_int_time[0] = s->inttime;
  		nummeas = i1pro_comp_nummeas(p, s->dcaltime, s->idark_int_time[0]);
+ 		DBG((dbgo,"Doing adaptive scan black calibration, dcaltime %f, idark_int_time[0] %f, nummeas %d, gainmode %d\n", s->dcaltime, s->idark_int_time[0], nummeas, s->gainmode))
  		if ((ev = i1pro_dark_measure(p, s->idark_data[0], nummeas, &s->idark_int_time[0], 0))
  		                                                                          != I1PRO_OK)
  			return ev;
  	
  		s->idark_int_time[2] = s->inttime;
  		nummeas = i1pro_comp_nummeas(p, s->dcaltime, s->idark_int_time[2]);
+ 		DBG((dbgo,"Doing adaptive scan black calibration, dcaltime %f, idark_int_time[2] %f, nummeas %d, gainmode %d\n", s->dcaltime, s->idark_int_time[2], nummeas, s->gainmode))
  		if ((ev = i1pro_dark_measure(p, s->idark_data[2], nummeas, &s->idark_int_time[2], 1))
  		                                                                          != I1PRO_OK)
  			return ev;
***************
*** 1146,1154 ****
  						s->cal_valid = 0;
  
  					if (*calc == inst_calc_man_ref_white) {
- 						DBG((dbgo,"Doing another black calibration with min inttime %f, gainmode %d\n",
- 						                                                  s->inttime,s->gainmode))
  						nummeas = i1pro_comp_nummeas(p, s->dadaptime, s->inttime);
  						if ((ev = i1pro_dark_measure(p, s->dark_data, nummeas, &s->inttime,
  						                                              s->gainmode)) != I1PRO_OK)
  							return ev;
--- 1151,1158 ----
  						s->cal_valid = 0;
  
  					if (*calc == inst_calc_man_ref_white) {
  						nummeas = i1pro_comp_nummeas(p, s->dadaptime, s->inttime);
+ 						DBG((dbgo,"Doing another black calibration with dadaptime %f, min inttime %f, nummeas %d, gainmode %d\n", s->dadaptime, s->inttime, nummeas, s->gainmode))
  						if ((ev = i1pro_dark_measure(p, s->dark_data, nummeas, &s->inttime,
  						                                              s->gainmode)) != I1PRO_OK)
  							return ev;
***************
*** 1186,1194 ****
  				                                                      s->inttime,s->gainmode))
  			
  				if (*calc == inst_calc_man_ref_white) {
- 					DBG((dbgo,"Doing final black calibration with opt inttime %f, gainmode %d\n",
- 					                                                s->inttime,s->gainmode))
  					nummeas = i1pro_comp_nummeas(p, s->dcaltime, s->inttime);
  					if ((ev = i1pro_dark_measure(p, s->dark_data, nummeas, &s->inttime,
  					                                              s->gainmode)) != I1PRO_OK)
  						return ev;
--- 1190,1197 ----
  				                                                      s->inttime,s->gainmode))
  			
  				if (*calc == inst_calc_man_ref_white) {
  					nummeas = i1pro_comp_nummeas(p, s->dcaltime, s->inttime);
+ 					DBG((dbgo,"Doing final black calibration with dcaltime %f, opt inttime %f, nummeas %d, gainmode %d\n", s->dcaltime, s->inttime, nummeas, s->gainmode))
  					if ((ev = i1pro_dark_measure(p, s->dark_data, nummeas, &s->inttime,
  					                                              s->gainmode)) != I1PRO_OK)
  						return ev;
***************
*** 1254,1262 ****
  			}
  
  			if (*calc == inst_calc_man_ref_white) {
- 				DBG((dbgo,"Doing final black calibration with opt inttime %f, gainmode %d\n",
- 				                                                s->inttime,s->gainmode))
  				nummeas = i1pro_comp_nummeas(p, s->dcaltime, s->inttime);
  				if ((ev = i1pro_dark_measure(p, s->dark_data, nummeas, &s->inttime,
  				                                              s->gainmode)) != I1PRO_OK)
  					return ev;
--- 1257,1264 ----
  			}
  
  			if (*calc == inst_calc_man_ref_white) {
  				nummeas = i1pro_comp_nummeas(p, s->dcaltime, s->inttime);
+ 				DBG((dbgo,"Doing final black calibration with dcaltime %f, opt inttime %f, nummeas %d, gainmode %d\n", s->dcaltime, s->inttime, nummeas, s->gainmode))
  				if ((ev = i1pro_dark_measure(p, s->dark_data, nummeas, &s->inttime,
  				                                              s->gainmode)) != I1PRO_OK)
  					return ev;
***************
*** 1616,1622 ****
  
  		DISDPLOT
  
! 		DBG((dbgo,"Doing on the fly black calibration with nummeas %d int_time %f, gainmode %d\n",
  		                                                   nummeas, s->inttime, s->gainmode))
  
  		if ((ev = i1pro_dark_measure_1(p, nummeas, &s->inttime, s->gainmode, buf, bsize))
--- 1618,1624 ----
  
  		DISDPLOT
  
! 		DBG((dbgo,"Doing on the fly black calibration_1 with nummeas %d int_time %f, gainmode %d\n",
  		                                                   nummeas, s->inttime, s->gainmode))
  
  		if ((ev = i1pro_dark_measure_1(p, nummeas, &s->inttime, s->gainmode, buf, bsize))
***************
*** 1658,1663 ****
--- 1660,1666 ----
  
  		/* Complete black reference measurement */
  		if (s->reflective) {
+ 			DBG((dbgo,"Doing black calibration_2 with nummeas %d, inttime %f, gainmode %d\n", nummeas, s->inttime,s->gainmode))
  			if ((ev = i1pro_dark_measure_2(p, s->dark_data, nummeas, s->inttime, s->gainmode,
  			                                                      buf, bsize)) != I1PRO_OK) {
  				free_dmatrix(specrd, 0, nvals-1, 0, m->nwav-1);
***************
*** 1743,1748 ****
--- 1746,1753 ----
  	i1key offst = 0;							/* Offset to copy to use */
  	i1pro_code ev = I1PRO_OK;
  
+ 	DBG((dbgo,"Doing Restoring reflective spot calibration information from the EEProm\n"))
+ 
  	chsum1 = m->data->checksum(m->data, 0);
  	if ((chsum2 = m->data->get_int(m->data, key_checksum, 0)) == NULL || chsum1 != *chsum2) {
  		offst = key_2logoff;
***************
*** 1770,1775 ****
--- 1775,1782 ----
  		return I1PRO_OK;
  	}
  	s->inttime = dp[0];
+ 	if (s->inttime < m->min_int_time)	/* Hmm. EEprom is occasionaly screwed up */
+ 		s->inttime = m->min_int_time;
  
  	/* Get the dark data */
  	if ((ip = m->data->get_ints(m->data, &count, key_darkreading + offst)) == NULL
***************
*** 1785,1790 ****
--- 1792,1798 ----
  	}
  
  	/* Convert to calibration data */
+ 	DBG((dbgo,"Doing black calibration_2 with nummeas %d, inttime %f, gainmode %d\n", 1, s->inttime,s->gainmode))
  	if ((ev = i1pro_dark_measure_2(p, s->dark_data, 1, s->inttime, s->gainmode,
  		                                                 buf, 256)) != I1PRO_OK) {
  		if (p->verb) printf("Failed to convert EEProm dark data to calibration\n");
***************
*** 2074,2079 ****
--- 2082,2088 ----
  	FILE *fp;
  	i1pnonv x;
  	int ss;
+ 	int argyllversion = ARGYLL_VERSION;
  
  	strcpy(nmode, "w");
  #if defined(O_BINARY) || defined(_O_BINARY)
***************
*** 2101,2106 ****
--- 2110,2116 ----
  	ss = sizeof(i1pro_state) + sizeof(i1proimp);
  
  	/* Some file identification */
+ 	write_ints(&x, fp, &argyllversion, 1);
  	write_ints(&x, fp, &ss, 1);
  	write_ints(&x, fp, &m->serno, 1);
  	write_ints(&x, fp, &m->nraw, 1);
***************
*** 2174,2179 ****
--- 2184,2190 ----
  	char *path;
  	FILE *fp;
  	i1pnonv x;
+ 	int argyllversion;
  	int ss, serno, nraw, nwav1, nwav2, chsum1, chsum2;
  
  	strcpy(nmode, "r");
***************
*** 2199,2210 ****
--- 2210,2223 ----
  	x.chsum = 0;
  
  	/* Check the file identification */
+ 	read_ints(&x, fp, &argyllversion, 1);
  	read_ints(&x, fp, &ss, 1);
  	read_ints(&x, fp, &serno, 1);
  	read_ints(&x, fp, &nraw, 1);
  	read_ints(&x, fp, &nwav1, 1);
  	read_ints(&x, fp, &nwav2, 1);
  	if (x.ef != 0
+ 	 || argyllversion != ARGYLL_VERSION
  	 || ss != (sizeof(i1pro_state) + sizeof(i1proimp))
  	 || serno != m->serno
  	 || nraw != m->nraw
***************
*** 2294,2299 ****
--- 2307,2313 ----
  	rewind(fp);
  
  	/* Read the identification */
+ 	read_ints(&x, fp, &argyllversion, 1);
  	read_ints(&x, fp, &ss, 1);
  	read_ints(&x, fp, &m->serno, 1);
  	read_ints(&x, fp, &m->nraw, 1);
diff --strip-trailing-cr -c -r Argyll_V1.0.1/target/printtarg.c Argyll_V1.0.2/target/printtarg.c
*** Argyll_V1.0.1/target/printtarg.c	Mon Jul 14 14:11:33 2008
--- Argyll_V1.0.2/target/printtarg.c	Sun Jul 20 02:25:19 2008
***************
*** 2497,2502 ****
--- 2497,2503 ----
  	fprintf(stderr," -T [res]        Output 16 bit TIFF raster file, optional res DPI (default 100)\n");
  	fprintf(stderr," -C              Don't use TIFF compression\n");
  	fprintf(stderr," -N              Use TIFF alpha N channels more than 4\n");
+ 	fprintf(stderr," -Q nbits        Quantize test values to fit in nbits\n");
  	fprintf(stderr," -R rsnum        Use given random start number\n");
  	fprintf(stderr," -x pattern      Use given strip indexing pattern (Default = \"%s\")\n",DEF_SIXPAT);
  	fprintf(stderr," -y pattern      Use given patch indexing pattern (Default = \"%s\")\n",DEF_PIXPAT);
***************
*** 2521,2526 ****
--- 2522,2528 ----
  	double pscale = 1.0;	/* Patch size scale */
  	double sscale = 1.0;	/* Spacer size scale */
  	int rand = 1;
+ 	int qbits = 0;			/* Quantization bits */
  	int oft = 0;			/* Ouput File type, 0 = PS, 1 = EPS , 2 = TIFF */
  	depth2d tiffdpth = bpc8_2d;	/* TIFF pixel depth */
  	double tiffres = 100.0;	/* TIFF resolution in DPI */
***************
*** 2662,2671 ****
  			/* Specify random seed */
  			else if (argv[fa][1] == 'R') {
  				fa = nfa;
! 				if (na == NULL) usage("Expected argument to -t");
  				rstart = atoi(na);
  				if (rstart < 0)
! 					usage("Argument to -t must be positive");
  			}
  
  			/* Enable DeviceN color fallback */
--- 2664,2673 ----
  			/* Specify random seed */
  			else if (argv[fa][1] == 'R') {
  				fa = nfa;
! 				if (na == NULL) usage("Expected argument to -R");
  				rstart = atoi(na);
  				if (rstart < 0)
! 					usage("Argument to -R must be positive");
  			}
  
  			/* Enable DeviceN color fallback */
***************
*** 2752,2757 ****
--- 2754,2768 ----
  				tiffcomp = 0;
  			}
  
+ 			/* Specify quantization bits */
+ 			else if (argv[fa][1] == 'Q') {
+ 				fa = nfa;
+ 				if (na == NULL) usage("Expected argument to -Q");
+ 				qbits = atoi(na);
+ 				if (qbits < 1 || qbits > 32)
+ 					usage("Argument to -Q must be between 1 and 32");
+ 			}
+ 
  			/* Specify strip index pattern */
  			else if (argv[fa][1] == 'x' || argv[fa][1] == 'X') {
  				fa = nfa;
***************
*** 2829,2834 ****
--- 2840,2853 ----
  	strcat(inname,".ti1");
  	strcat(outname,".ti2");
  
+ 	/* Set default qantization for known output */
+ 	if (qbits == 0 && oft == 2) { 
+ 		if (tiffdpth == bpc16_2d)
+ 			qbits = 16;
+ 		else if (tiffdpth == bpc8_2d)
+ 			qbits = 8;
+ 	}
+ 
  	if (hex && itype != instSpectroScan) {
  		if (verb)
  			printf("Can only select hexagonal patches for SpectrScan - ignored!\n");
***************
*** 2923,2928 ****
--- 2942,2948 ----
  		int xyzix[3];			/* XYZ chanel indexes */
  		char *ident;
  		char *xyzfname[3] = { "XYZ_X", "XYZ_Y", "XYZ_Z" };
+ 		double qscale = (1 << qbits) - 1.0;
  
  		if ((ii = icg->find_kword(icg, 0, "TOTAL_INK_LIMIT")) >= 0)
  			ocg->add_kword(ocg, 0, "TOTAL_INK_LIMIT",icg->t[0].kdata[ii], NULL);
***************
*** 2959,2965 ****
  
  		ocg->add_kword(ocg, 0, "COLOR_REP", ident, NULL);
  
! 		/* Read all the test patches in */
  		for (i = 0; i < npat; i++) {
  			cols[i].i = i;
  			cols[i].t = T_N | T_XYZ;
--- 2979,2985 ----
  
  		ocg->add_kword(ocg, 0, "COLOR_REP", ident, NULL);
  
! 		/* Read all the test patches in, and quantize them */
  		for (i = 0; i < npat; i++) {
  			cols[i].i = i;
  			cols[i].t = T_N | T_XYZ;
***************
*** 2970,2977 ****
  			cols[i].n  = nchan;
  			cols[i].id = ((char *)icg->t[0].fdata[i][si]);
  			sprintf(cols[i].loc, "???");
! 			for (j = 0; j < nchan; j++)
! 				cols[i].dev[j] = *((double *)icg->t[0].fdata[i][chix[j]]) / 100.0;
  			for (j = 0; j < 3; j++)
  				cols[i].XYZ[j] = *((double *)icg->t[0].fdata[i][xyzix[j]]) / 100.0;
  			col_convert(&cols[i], wp);	/* Ensure other representations */
--- 2990,3006 ----
  			cols[i].n  = nchan;
  			cols[i].id = ((char *)icg->t[0].fdata[i][si]);
  			sprintf(cols[i].loc, "???");
! 			for (j = 0; j < nchan; j++) {
! 				double vr, vv = *((double *)icg->t[0].fdata[i][chix[j]]) / 100.0;
! 				if (qbits > 0) {
! 					vv *= qscale;
! 					vr = floor(vv + 0.5);
! 					if ((vr - vv) == 0.5 && (((int)vr) & 1) != 0) /* Round to even */
! 						vr -= 1.0;
! 					vv = vr/qscale;
! 				}
! 				cols[i].dev[j] = vv;
! 			}
  			for (j = 0; j < 3; j++)
  				cols[i].XYZ[j] = *((double *)icg->t[0].fdata[i][xyzix[j]]) / 100.0;
  			col_convert(&cols[i], wp);	/* Ensure other representations */
diff --strip-trailing-cr -c -r Argyll_V1.0.1/target/targen.c Argyll_V1.0.2/target/targen.c
*** Argyll_V1.0.1/target/targen.c	Mon Jul 14 14:11:33 2008
--- Argyll_V1.0.2/target/targen.c	Sun Jul 20 02:25:19 2008
***************
*** 17,31 ****
  
  /* TTBD:
  
! 	Should add an option to quantize the device values -
! 	ie. to 8 bits, so that quantizing error isn't introduced
! 	through a reproduction path. Should this be a default ?
  
  	Using adaptive patch creation for grey colorspace is broken.
  	This should really be disabled for grey space, or fixed.
  
  	Adaptive only does a first go placement, itterative improvement
  	is turned off, because the algorithm doesn't work.
  	The useful level for the -A parameter (degree of adapatation)
  	hasn't been determined.
  
--- 17,31 ----
  
  /* TTBD:
  
! 	Should add an option to generate grey and near grey
! 	test points based on the previous profile.
  
  	Using adaptive patch creation for grey colorspace is broken.
  	This should really be disabled for grey space, or fixed.
  
  	Adaptive only does a first go placement, itterative improvement
  	is turned off, because the algorithm doesn't work.
+ 	It would be good to figure out a way of fixing this.
  	The useful level for the -A parameter (degree of adapatation)
  	hasn't been determined.
  
diff --strip-trailing-cr -c -r Argyll_V1.0.1/xicc/xfit.c Argyll_V1.0.2/xicc/xfit.c
*** Argyll_V1.0.1/xicc/xfit.c	Mon Jul 14 14:11:27 2008
--- Argyll_V1.0.2/xicc/xfit.c	Sun Jul 20 02:25:13 2008
***************
*** 87,93 ****
  
  /* - - - - - - - - - - - - - - - - - */
  
! #ifdef NEVER	/* Not currently used */
  
  /* Lookup a value though an input position curve */
  static double xfit_poscurve(xfit *p, double in, int chan) {
--- 87,93 ----
  
  /* - - - - - - - - - - - - - - - - - */
  
! #ifdef DEBUG_PLOT	/* Not currently used in runtime code*/
  
  /* Lookup a value though an input position curve */
  static double xfit_poscurve(xfit *p, double in, int chan) {
***************
*** 132,138 ****
  		out[e] = val;
  	}
  }
! #endif /* NEVER */
  
  /* - - - - - - - - - - - - - - - - - */
  /* Lookup a value though input shape curve */
--- 132,138 ----
  		out[e] = val;
  	}
  }
! #endif /* DEBUG_PLOT */
  
  /* - - - - - - - - - - - - - - - - - */
  /* Lookup a value though input shape curve */
***************
*** 482,487 ****
--- 482,491 ----
  		} else {
  			icmMulBy3x3(out, p->fromAbs, in);
  		}
+ 	} else {
+ 		out[0] = in[0];
+ 		out[1] = in[1];
+ 		out[2] = in[2];
  	}
  }
  
***************
*** 661,667 ****
  		} else {
  			del = p->to_de2(p->cntx2, out, p->rpoints[i].v);
  		}
- 
  		tw += p->rpoints[i].w;
  		ev += p->rpoints[i].w * del;
  	}
--- 665,670 ----
***************
*** 1384,1397 ****
  					break;			/* Don't bother looking further */
  			}
  		}
- 
  		xfit_abs_to_rel(p, ov, p->ipoints[bk].v);
  
  		for (f = 0; f < fdi; f++)
  			b[f * (1 << di) + e] = ov[f];
  	}
  
- 
  	/* Setup output curves to be linear initially */
  	b = p->v + p->out_off;
  	for (f = 0; f < fdi; b += p->oluord[f], f++) {
--- 1387,1398 ----
***************
*** 1446,1451 ****
--- 1447,1453 ----
  
  	if ((p->tcomb & oc_ipo) != 0
  	 && (p->tcomb & oc_m) == oc_m) {	/* Only bother with matrix if in and/or out */
+ 		double rerr;
  
  		if (p->verb)
  			printf("About to optimise temporary matrix\n");
***************
*** 1464,1474 ****
  		setup_xfit(p, p->wv, p->sa, 0.0, 0.5); 
  
  #ifdef NODDV
! 		if (powell(NULL, p->opt_cnt, p->wv, p->sa, POWTOL, MAXITS, xfitfunc, (void *)p) != 0)
! 			warning("xfit_fit: Powell failed to converge");
  #else
! 		if (conjgrad(NULL, p->opt_cnt, p->wv, p->sa, POWTOL, MAXITS, xfitfunc, dxfitfunc, (void *)p) != 0)
! 			warning("xfit_fit: Conjgrad failed to converge");
  #endif
  		for (i = 0; i < p->opt_cnt; i++)		/* Copy optimised values back */
  			p->v[p->opt_off + i] = p->wv[i];
--- 1466,1476 ----
  		setup_xfit(p, p->wv, p->sa, 0.0, 0.5); 
  
  #ifdef NODDV
! 		if (powell(&rerr, p->opt_cnt, p->wv, p->sa, POWTOL, MAXITS, xfitfunc, (void *)p) != 0)
! 			warning("xfit_fit: Powell failed to converge, residual error = %f",rerr);
  #else
! 		if (conjgrad(&rerr, p->opt_cnt, p->wv, p->sa, POWTOL, MAXITS, xfitfunc, dxfitfunc, (void *)p) != 0)
! 			warning("xfit_fit: Conjgrad failed to converge, residual error = %f", rerr);
  #endif
  		for (i = 0; i < p->opt_cnt; i++)		/* Copy optimised values back */
  			p->v[p->opt_off + i] = p->wv[i];
***************
*** 1481,1486 ****
--- 1483,1489 ----
  
  	/* Optimise input and matrix together */
  	if ((p->tcomb & oc_im) == oc_im) {
+ 		double rerr;
  
  		if (p->verb)
  			printf("\nAbout to optimise input curves and matrix\n");
***************
*** 1492,1504 ****
  		p->opt_ch = -1;
  		p->opt_msk = oc_im;
  		setup_xfit(p, p->wv, p->sa, 0.5, 0.3); 
  #ifdef NODDV
! 		if (powell(NULL, p->opt_cnt, p->wv, p->sa, POWTOL, MAXITS, xfitfunc, (void *)p) != 0)
! 			warning("xfit_fit: Powell failed to converge");
  #else
! 		if (conjgrad(NULL, p->opt_cnt, p->wv, p->sa, POWTOL, MAXITS, xfitfunc, dxfitfunc, (void *)p) != 0)
! 			warning("xfit_fit: Conjgrad failed to converge");
  #endif
  		for (i = 0; i < p->opt_cnt; i++)		/* Copy optimised values back */
  			p->v[p->opt_off + i] = p->wv[i];
  #ifdef DEBUG
--- 1495,1516 ----
  		p->opt_ch = -1;
  		p->opt_msk = oc_im;
  		setup_xfit(p, p->wv, p->sa, 0.5, 0.3); 
+ 		/* Supress the warnings the first time through - it's better to cut off the */
+ 		/* itterations and move on to the output curve, and worry about it not */
+ 		/* converging the second time through. */
  #ifdef NODDV
! 		if (powell(&rerr, p->opt_cnt, p->wv, p->sa, POWTOL, MAXITS, xfitfunc, (void *)p) != 0) {
! #ifdef DEBUG
! 			warning("xfit_fit: Powell failed to converge, residual error = %f",rerr);
! #endif
! 		}
  #else
! 		if (conjgrad(&rerr, p->opt_cnt, p->wv, p->sa, POWTOL, MAXITS, xfitfunc, dxfitfunc, (void *)p) != 0) {
! #ifdef DEBUG
! 			warning("xfit_fit: Conjgrad failed to converge, residual error = %f",rerr);
  #endif
+ 		}
+ #endif	/* !NODDV */
  		for (i = 0; i < p->opt_cnt; i++)		/* Copy optimised values back */
  			p->v[p->opt_off + i] = p->wv[i];
  #ifdef DEBUG
***************
*** 1509,1514 ****
--- 1521,1527 ----
  
  	/* Optimise the matrix and output curves together */
  	if ((p->tcomb & oc_mo) == oc_mo) {
+ 		double rerr;
  
  		if (p->verb)
  			printf("\nAbout to optimise output curves and matrix\n");
***************
*** 1521,1531 ****
  		p->opt_msk = oc_mo;
  		setup_xfit(p, p->wv, p->sa, 0.3, 0.3); 
  #ifdef NODDV
! 		if (powell(NULL, p->opt_cnt, p->wv, p->sa, POWTOL, MAXITS, xfitfunc, (void *)p) != 0)
! 			warning("xfit_fit: Powell failed to converge");
  #else
! 		if (conjgrad(NULL, p->opt_cnt, p->wv, p->sa, POWTOL, MAXITS, xfitfunc, dxfitfunc, (void *)p) != 0)
! 			warning("xfit_fit: Conjgrad failed to converge");
  #endif
  		for (i = 0; i < p->opt_cnt; i++)		/* Copy optimised values back */
  			p->v[p->opt_off + i] = p->wv[i];
--- 1534,1544 ----
  		p->opt_msk = oc_mo;
  		setup_xfit(p, p->wv, p->sa, 0.3, 0.3); 
  #ifdef NODDV
! 		if (powell(&rerr, p->opt_cnt, p->wv, p->sa, POWTOL, MAXITS, xfitfunc, (void *)p) != 0)
! 			warning("xfit_fit: Powell failed to converge, residual error = %f",rerr);
  #else
! 		if (conjgrad(&rerr, p->opt_cnt, p->wv, p->sa, POWTOL, MAXITS, xfitfunc, dxfitfunc, (void *)p) != 0)
! 			warning("xfit_fit: Conjgrad failed to converge, residual error = %f",rerr);
  #endif
  		for (i = 0; i < p->opt_cnt; i++)		/* Copy optimised values back */
  			p->v[p->opt_off + i] = p->wv[i];
***************
*** 1548,1558 ****
  			p->opt_msk = oc_im;
  			setup_xfit(p, p->wv, p->sa, 0.2, 0.2); 
  #ifdef NODDV
! 			if (powell(NULL, p->opt_cnt, p->wv, p->sa, POWTOL, MAXITS, xfitfunc, (void *)p) != 0)
! 				warning("xfit_fit: Powell failed to converge");
  #else
! 			if (conjgrad(NULL, p->opt_cnt, p->v, p->sa, POWTOL, MAXITS, xfitfunc, dxfitfunc, (void *)p) != 0)
! 				warning("xfit_fit: Conjgrad failed to converge");
  #endif
  			for (i = 0; i < p->opt_cnt; i++)		/* Copy optimised values back */
  				p->v[p->opt_off + i] = p->wv[i];
--- 1561,1571 ----
  			p->opt_msk = oc_im;
  			setup_xfit(p, p->wv, p->sa, 0.2, 0.2); 
  #ifdef NODDV
! 			if (powell(&rerr, p->opt_cnt, p->wv, p->sa, POWTOL, MAXITS, xfitfunc, (void *)p) != 0)
! 				warning("xfit_fit: Powell failed to converge, residual error = %f",rerr);
  #else
! 			if (conjgrad(&rerr, p->opt_cnt, p->v, p->sa, POWTOL, MAXITS, xfitfunc, dxfitfunc, (void *)p) != 0)
! 				warning("xfit_fit: Conjgrad failed to converge, residual error = %f",rerr);
  #endif
  			for (i = 0; i < p->opt_cnt; i++)		/* Copy optimised values back */
  				p->v[p->opt_off + i] = p->wv[i];
***************
*** 1576,1583 ****
  			p->opt_ch = -1;
  			p->opt_msk = oc_imo;
  			setup_xfit(p, p->wv, p->sa, 0.1, 0.1); 
! 			if (conjgrad(NULL, p->opt_cnt, p->wv, p->sa, POWTOL, MAXITS, xfitfunc, dxfitfunc, (void *)p) != 0)
! 				warning("xfit_fit: Conjgrad failed to converge");
  			for (i = 0; i < p->opt_cnt; i++)		/* Copy optimised values back */
  				p->v[p->opt_off + i] = p->wv[i];
  
--- 1589,1596 ----
  			p->opt_ch = -1;
  			p->opt_msk = oc_imo;
  			setup_xfit(p, p->wv, p->sa, 0.1, 0.1); 
! 			if (conjgrad(&rerr, p->opt_cnt, p->wv, p->sa, POWTOL, MAXITS, xfitfunc, dxfitfunc, (void *)p) != 0)
! 				warning("xfit_fit: Conjgrad failed to converge, residual error = %f",rerr);
  			for (i = 0; i < p->opt_cnt; i++)		/* Copy optimised values back */
  				p->v[p->opt_off + i] = p->wv[i];
  
***************
*** 1604,1611 ****
  				p->opt_ch = f;
  				p->wv[0] = p->v[p->out_offs[f]];	/* Current parameter value */
  				p->sa[0] = 0.1;					/* Search radius */
! 				if (powell(NULL, 1, p->wv, p->sa, 0.0000001, 1000, symoptfunc, (void *)p) != 0)
! 					error("xfit_fit: Powell failed to converge");
  				p->v[p->out_offs[f]] = p->wv[0];	/* Copy results back */
  			}
  		}
--- 1617,1624 ----
  				p->opt_ch = f;
  				p->wv[0] = p->v[p->out_offs[f]];	/* Current parameter value */
  				p->sa[0] = 0.1;					/* Search radius */
! 				if (powell(&rerr, 1, p->wv, p->sa, 0.0000001, 1000, symoptfunc, (void *)p) != 0)
! 					error("xfit_fit: Powell failed to converge, residual error = %f",rerr);
  				p->v[p->out_offs[f]] = p->wv[0];	/* Copy results back */
  			}
  		}
***************
*** 1867,1873 ****
  				p->rpoints[i].v[f] = p->ipoints[i].v[f];
  			xfit_abs_to_rel(p, p->rpoints[i].v, p->rpoints[i].v);
  			xfit_invoutcurves(p, p->rpoints[i].v, p->rpoints[i].v);
- // ~~999
  //printf("~1 point %d, w %f, %f %f %f %f -> %f %f %f\n",
  //i,p->rpoints[i].w,p->rpoints[i].p[0], p->rpoints[i].p[1], p->rpoints[i].p[2], p->rpoints[i].p[3],
  //p->rpoints[i].v[0], p->rpoints[i].v[1], p->rpoints[i].v[2]);
--- 1880,1885 ----
***************
*** 1923,1931 ****
  		if (p->verb)
  			printf("Create final clut from scattered data\n");
  
- // ~~~999
- //out_max[0] = 100.390625;
- 
  		p->clut->fit_rspl_w(p->clut, rsplflags, p->rpoints, p->nodp, in_min, in_max, gres,
  			out_min, out_max, smooth, oavgdev, iwidth);
  		if (p->verb) printf("\n");
--- 1935,1940 ----
***************
*** 2079,2085 ****
  				maxe = ev;
  			avee += ev;
  		}
! 		printf("Max err = %f, avg err = %f\n",maxe, avee/(double)p->nodp);
  
  		/* Evaluate each input axis in turn */
  		for (ee = 0; ee < p->di; ee++) {
--- 2088,2094 ----
  				maxe = ev;
  			avee += ev;
  		}
! 		printf("Max resid err = %f, avg err = %f\n",maxe, avee/(double)p->nodp);
  
  		/* Evaluate each input axis in turn */
  		for (ee = 0; ee < p->di; ee++) {