ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/ranimove2.c
(Generate patch)

Comparing ray/src/util/ranimove2.c (file contents):
Revision 3.1 by greg, Sat Feb 22 02:07:30 2003 UTC vs.
Revision 3.6 by schorsch, Fri Mar 26 21:36:20 2004 UTC

# Line 9 | Line 9 | static const char      RCSid[] = "$Id$";
9   *  Created by Gregory Ward on Wed Jan 08 2003.
10   */
11  
12 < /* ====================================================================
13 < * The Radiance Software License, Version 1.0
14 < *
15 < * Copyright (c) 1990 - 2002 The Regents of the University of California,
16 < * through Lawrence Berkeley National Laboratory.   All rights reserved.
17 < *
18 < * Redistribution and use in source and binary forms, with or without
19 < * modification, are permitted provided that the following conditions
20 < * are met:
21 < *
22 < * 1. Redistributions of source code must retain the above copyright
23 < *         notice, this list of conditions and the following disclaimer.
24 < *
25 < * 2. Redistributions in binary form must reproduce the above copyright
26 < *       notice, this list of conditions and the following disclaimer in
27 < *       the documentation and/or other materials provided with the
28 < *       distribution.
29 < *
30 < * 3. The end-user documentation included with the redistribution,
31 < *           if any, must include the following acknowledgment:
32 < *             "This product includes Radiance software
33 < *                 (http://radsite.lbl.gov/)
34 < *                 developed by the Lawrence Berkeley National Laboratory
35 < *               (http://www.lbl.gov/)."
36 < *       Alternately, this acknowledgment may appear in the software itself,
37 < *       if and wherever such third-party acknowledgments normally appear.
38 < *
39 < * 4. The names "Radiance," "Lawrence Berkeley National Laboratory"
40 < *       and "The Regents of the University of California" must
41 < *       not be used to endorse or promote products derived from this
42 < *       software without prior written permission. For written
43 < *       permission, please contact [email protected].
44 < *
45 < * 5. Products derived from this software may not be called "Radiance",
46 < *       nor may "Radiance" appear in their name, without prior written
47 < *       permission of Lawrence Berkeley National Laboratory.
48 < *
49 < * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
50 < * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
51 < * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
52 < * DISCLAIMED.   IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR
53 < * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
54 < * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
55 < * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
56 < * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
57 < * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
58 < * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
59 < * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 < * SUCH DAMAGE.
61 < * ====================================================================
62 < *
63 < * This software consists of voluntary contributions made by many
64 < * individuals on behalf of Lawrence Berkeley National Laboratory.   For more
65 < * information on Lawrence Berkeley National Laboratory, please see
66 < * <http://www.lbl.gov/>.
67 < */
12 > #include "copyright.h"
13  
14 + #include <string.h>
15 +
16   #include "ranimove.h"
17   #include "random.h"
18  
# Line 74 | Line 21 | static const char      RCSid[] = "$Id$";
21  
22   int     cerrzero;               /* is cerrmap all zeroes? */
23  
24 + static int ppri_cmp(const void *pp1, const void *pp2);
25 + static int ray_refine(int       n);
26 + static long refine_rays(long    nrays);
27  
28 < int
29 < refine_first()                  /* initial refinement pass */
28 >
29 > extern int
30 > refine_first(void)                      /* initial refinement pass */
31   {
32          int     *esamp = (int *)zprev;  /* OK to reuse */
33          int     hl_erri = errori(HL_ERR);
# Line 91 | Line 42 | refine_first()                 /* initial refinement pass */
42                  printf("\tFirst refinement pass...");
43                  fflush(stdout);
44          }
45 <        bzero((void *)esamp, sizeof(int)*hres*vres);
45 >        memset((void *)esamp, '\0', sizeof(int)*hres*vres);
46          /*
47           * In our initial pass, we look for lower error pixels from
48           * the same objects in the previous frame, and copy them here.
# Line 104 | Line 55 | refine_first()                 /* initial refinement pass */
55                  if (xmbuffer[n] == MO_UNK)
56                          continue;
57                  xp = x + xmbuffer[n];
58 <                if ((xp < 0 | xp >= hres))
58 >                if ((xp < 0) | (xp >= hres))
59                          continue;
60                  yp = y + ymbuffer[n];
61 <                if ((yp < 0 | yp >= vres))
61 >                if ((yp < 0) | (yp >= vres))
62                          continue;
63                  np = fndx(xp, yp);
64                                          /* make sure we hit same object */
# Line 170 | Line 121 | struct ConspSum {
121   static double   pixel_deg;      /* base pixel frequency */
122   static int      fhsiz, fvsiz;   /* foveal subimage size */
123  
124 + static void clr_consp(struct ConspSum *cs);
125 + static void sum_consp(struct ConspSum *cdest, struct ConspSum *cs);
126 + static void est_consp(int x0, int y0, int x1, int y1, struct ConspSum *cs);
127 + static void subconspicuity(int x0, int y0, int x1, int y1, struct ConspSum *cs);
128 +
129   static void
130 < clr_consp(cs)                   /* initialize a conspicuity sum */
131 < register struct ConspSum        *cs;
130 > clr_consp(                      /* initialize a conspicuity sum */
131 >        register struct ConspSum        *cs
132 > )
133   {
134          if (cs == NULL)
135                  return;
# Line 185 | Line 142 | register struct ConspSum       *cs;
142   }
143  
144   static void
145 < sum_consp(cdest, cs)            /* sum in conspicuity result */
146 < register struct ConspSum        *cdest, *cs;
145 > sum_consp(              /* sum in conspicuity result */
146 >        register struct ConspSum        *cdest,
147 >        register struct ConspSum        *cs
148 > )
149   {
150 <        if ((cdest == NULL | cs == NULL))
150 >        if ((cdest == NULL) | (cs == NULL))
151                  return;
152          addcolor(cdest->vsum, cs->vsum);
153          addcolor(cdest->v2sum, cs->v2sum);
# Line 201 | Line 160 | register struct ConspSum       *cdest, *cs;
160   }
161  
162   static void
163 < est_consp(x0,y0,x1,y1, cs)      /* estimate error conspicuity & update */
164 < int     x0, y0, x1, y1;
165 < register struct ConspSum        *cs;
163 > est_consp(      /* estimate error conspicuity & update */
164 >        int     x0,
165 >        int     y0,
166 >        int     x1,
167 >        int     y1,
168 >        register struct ConspSum        *cs
169 > )
170   {
171          double  rad2, mtn2, cpd, vm, vr, csf, eest;
172                                                  /* do we care? */
# Line 218 | Line 181 | register struct ConspSum       *cs;
181          } else
182                  eest = estimaterr(cs->vsum, cs->v2sum, cs->nsamp, cs->nsamp);
183          
184 <        if ((x0 == x1-1 & y0 == y1-1)) {        /* update pixel error */
184 >        if ((x0 == x1-1) & (y0 == y1-1)) {      /* update pixel error */
185                  int     n = fndx(x0, y0);
186                  int     ai;
187                  int     ne;
# Line 281 | Line 244 | register struct ConspSum       *cs;
244   }
245  
246   static void
247 < subconspicuity(x0,y0,x1,y1, cs) /* compute subportion of conspicuity */
248 < int     x0, y0, x1, y1;
249 < struct ConspSum *cs;
247 > subconspicuity( /* compute subportion of conspicuity */
248 >        int     x0,
249 >        int     y0,
250 >        int     x1,
251 >        int     y1,
252 >        struct ConspSum *cs
253 > )
254   {
255          struct ConspSum mysum;
256          int     i;
257  
258 <        if ((x0 >= x1 | y0 >= y1))
258 >        if ((x0 >= x1) | (y0 >= y1))
259                  error(CONSISTENCY, "bad call to subconspicuity");
260  
261          clr_consp(&mysum);                      /* prepare sum */
262  
263 <        if ((x0 == x1-1 & y0 == y1-1)) {        /* single pixel */
263 >        if ((x0 == x1-1) & (y0 == y1-1)) {      /* single pixel */
264                  double  hls;
265                  register int    n = fndx(x0, y0);
266                  if (sbuffer[n]) {
# Line 342 | Line 309 | struct ConspSum        *cs;
309          sum_consp(cs, &mysum);
310   }
311  
312 < void
313 < conspicuity()                   /* compute conspicuous error map */
312 > extern void
313 > conspicuity(void)                       /* compute conspicuous error map */
314   {
315          int     fhres, fvres;
316          int     fx, fy;
317                                          /* reuse previous z-buffer */
318          cerrmap = (float *)zprev;
319 <        bzero((void *)cerrmap, sizeof(float)*hres*vres);
319 >        memset((void *)cerrmap, '\0', sizeof(float)*hres*vres);
320          cerrzero = 1;
321                                          /* compute base pixel frequency */
322          pixel_deg = .5*(hres/vw.horiz + vres/vw.vert);
# Line 383 | Line 350 | static struct AmbSum {
350  
351  
352   static int
353 < ppri_cmp(pp1, pp2)              /* pixel priority comparison */
354 < const void *pp1, *pp2;
353 > ppri_cmp(               /* pixel priority comparison */
354 >        const void *pp1,
355 >        const void *pp2
356 > )
357   {
358          double  se1 = cerrmap[*(const int *)pp1];
359          double  se2 = cerrmap[*(const int *)pp2];
# Line 404 | Line 373 | const void *pp1, *pp2;
373  
374  
375   static int
376 < ray_refine(n)                   /* refine the given pixel by tracing a ray */
377 < register int    n;
376 > ray_refine(                     /* refine the given pixel by tracing a ray */
377 >        register int    n
378 > )
379   {
380          RAY     ir;
411        int     neigh[NSAMPOK];
412        int     nc;
381          COLOR   ctmp;
382          int     i;
383  
# Line 442 | Line 410 | register int   n;
410                  if (sbuffer[n] != 1)
411                          error(CONSISTENCY, "bad code in ray_refine");
412                  if (getambcolor(ctmp, obuffer[n]) &&
413 <                                (colval(ctmp,RED) > 0.01 &
414 <                                 colval(ctmp,GRN) > 0.01 &
415 <                                 colval(ctmp,BLU) > 0.01)) {
413 >                                (colval(ctmp,RED) > 0.01) &
414 >                                (colval(ctmp,GRN) > 0.01) &
415 >                                (colval(ctmp,BLU) > 0.01)) {
416                          for (i = 0; i < 3; i++)
417                                  asump->diffsum[i] +=
418                                      (colval(ir.rcol,i) - colval(cbuffer[n],i))
# Line 472 | Line 440 | register int   n;
440  
441  
442   static long
443 < refine_rays(nrays)              /* compute refinement rays */
444 < long    nrays;
443 > refine_rays(            /* compute refinement rays */
444 >        long    nrays
445 > )
446   {
447          int     *pord;
448          int     ntodo;
# Line 481 | Line 450 | long   nrays;
450          int     i;
451                                          /* skip if nothing significant */
452          if (ndtset && cerrzero)
453 <                return;
453 >                return(0);
454                                          /* initialize priority list */
455          pord = (int *)malloc(sizeof(int)*hres*vres);
456          for (i = hres*vres; i--; )
# Line 516 | Line 485 | long   nrays;
485   }
486  
487  
488 < int
489 < refine_frame(pass)              /* refine current frame */
490 < int     pass;
488 > extern int
489 > refine_frame(           /* refine current frame */
490 >        int     pass
491 > )
492   {
493          static double   rtime_used = 0;
494          static long     ray_cnt = 0;
495          static double   ctime_used = 0;
496          static int      csp_cnt = 0;
497 <        int     timed = (fcur > fbeg | pass > 0 | quickstart);
497 >        int     timed = (fcur > fbeg) | (pass > 0) | (quickstart);
498          double  time_start, rtime_start, time_done;
499          struct AmbSum   myAmbSum;
500          long    rays_todo, nr;
501          register int    n;
502                                          /* IBR refinement? */
503 <        if ((pass == 0 & fcur > fbeg))
503 >        if ((pass == 0) & (fcur > fbeg))
504                  return(refine_first());
505                                          /* any time left? */
506          time_start = getTime();
# Line 607 | Line 577 | if (pass == 1) {
577                                          /* compute refinement rays */
578          if (!silent) {
579                  printf("\tRefinement pass %d...",
580 <                                pass+1, rays_todo);
580 >                                pass+1); /*, rays_todo); */
581                  fflush(stdout);
582          }
583          if (asump != NULL)              /* flag low-quality samples */
# Line 617 | Line 587 | if (pass == 1) {
587                                          /* trace those rays */
588          nr = refine_rays(rays_todo);
589          if (!silent)
590 <                printf("traced %d HQ rays\n", nr);
590 >                printf("traced %ld HQ rays\n", nr);
591          if (nr <= 0)
592                  return(0);
593                                          /* update timing stats */
# Line 652 | Line 622 | if (pass == 1) {
622          return(1);
623   nomore:
624                                          /* make sure error map is updated */
625 <        if ((fcur == fbeg | pass > 1))
625 >        if ((fcur == fbeg) | (pass > 1))
626                  comp_frame_error();
627          return(0);
628   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines