--- ray/src/util/rttree_reduce.c 2016/08/18 00:52:48 2.16 +++ ray/src/util/rttree_reduce.c 2020/06/30 17:18:22 2.20 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rttree_reduce.c,v 2.16 2016/08/18 00:52:48 greg Exp $"; +static const char RCSid[] = "$Id: rttree_reduce.c,v 2.20 2020/06/30 17:18:22 greg Exp $"; #endif /* * A utility called by genBSDF.pl to reduce tensor tree samples and output @@ -19,8 +19,8 @@ int log2g = 4; /* log2 of grid resolution */ int infmt = 'a'; /* input format ('a','f','d') */ double pctcull = 95.; /* target culling percentile */ -#define dval3(ix,ox,oy) datarr[((((ix)<vmax - (tp)->vmin) / \ +#define var_measure(tp) sqrt( ((tp)->vmax - (tp)->vmin) / \ (sqrt((tp)->vavg) + .03) ) #define above_threshold(tp) (var_measure(tp) > tthresh) @@ -223,7 +223,8 @@ read_double(float *rowp, int n) return(0); } if (rblen < n) { - rowbuf = (double *)realloc(rowbuf, sizeof(double)*(rblen=n)); + if (rblen) free(rowbuf); + rowbuf = (double *)malloc(sizeof(double)*(rblen=n)); if (rowbuf == NULL) error(SYSTEM, "out of memory in read_double"); } @@ -283,16 +284,13 @@ load_data(void) int ix, ox; for (ix = 0; ix < 1<<(log2g-1); ix++) for (ox = 0; ox < 1< 0; ox++) + for (oy = 0; oy < siz; oy++) { v1p = &dval4(siz-1-ix,siz-1-iy,ox,oy); v2p = &dval4(siz-1-ox,siz-1-oy,ix,iy); *v1p = *v2p = .5f*( *v1p + *v2p ); + if (--cnt <= 0) + break; } + } } } @@ -400,10 +402,10 @@ main(int argc, char *argv[]) if (recipavg) do_reciprocity(); if (doheader) { - for (i = 0; i < argc; i++) { - fputs(argv[i], stdout); - fputc(i < argc-1 ? ' ' : '\n', stdout); - } + newheader("RADIANCE", stdout); + printargs(argc, argv, stdout); + fputnow(stdout); + fputformat("ascii", stdout); fputc('\n', stdout); } gtree.kid = NULL; /* create our tree */