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