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.10 by greg, Mon Apr 18 22:39:13 2016 UTC

# Line 4 | Line 4 | static const char      RCSid[] = "$Id$";
4   /*
5   *  ranimove2.c
6   *
7 < *  Frame refinement routines for ranimate(1).
7 > *  Frame refinement routines for ranimove(1).
8   *
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 radiance@radsite.lbl.gov.
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 +
29   int
30 < refine_first()                  /* initial refinement pass */
30 > refine_first(void)                      /* initial refinement pass */
31   {
32          int     *esamp = (int *)zprev;  /* OK to reuse */
33          int     hl_erri = errori(HL_ERR);
34          int     nextra = 0;
35          int     x, y, xp, yp;
36          int     neigh;
37 <        register int    n, np;
37 >        int     n, np;
38  
39          if (sizeof(int) < sizeof(*zprev))
40                  error(CONSISTENCY, "code error in refine_first");
# 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 >        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 >        struct ConspSum *cdest,
147 >        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 >        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 270 | Line 233 | register struct ConspSum       *cs;
233                                                  /* worth the bother? */
234          if (eest <= .01)
235                  return;
236 <                                                /* sum into map */
236 >                                                /* put into map */
237          for ( ; y0 < y1; y0++) {
238                  float   *em0 = cerrmap + fndx(x0, y0);
239 <                register float  *emp = em0 + (x1-x0);
239 >                float   *emp = em0 + (x1-x0);
240                  while (emp-- > em0)
241 <                        *emp += eest;
241 >                        if (eest > *emp)
242 >                                *emp = eest;
243          }
244          cerrzero = 0;
245   }
246  
247   static void
248 < subconspicuity(x0,y0,x1,y1, cs) /* compute subportion of conspicuity */
249 < int     x0, y0, x1, y1;
250 < struct ConspSum *cs;
248 > subconspicuity( /* compute subportion of conspicuity */
249 >        int     x0,
250 >        int     y0,
251 >        int     x1,
252 >        int     y1,
253 >        struct ConspSum *cs
254 > )
255   {
256          struct ConspSum mysum;
257          int     i;
258  
259 <        if ((x0 >= x1 | y0 >= y1))
259 >        if ((x0 >= x1) | (y0 >= y1))
260                  error(CONSISTENCY, "bad call to subconspicuity");
261  
262          clr_consp(&mysum);                      /* prepare sum */
263  
264 <        if ((x0 == x1-1 & y0 == y1-1)) {        /* single pixel */
264 >        if ((x0 == x1-1) & (y0 == y1-1)) {      /* single pixel */
265                  double  hls;
266 <                register int    n = fndx(x0, y0);
266 >                int     n = fndx(x0, y0);
267                  if (sbuffer[n]) {
268                          copycolor(mysum.vsum, cbuffer[n]);
269                          copycolor(mysum.v2sum, val2map[n]);
# Line 343 | Line 311 | struct ConspSum        *cs;
311   }
312  
313   void
314 < conspicuity()                   /* compute conspicuous error map */
314 > conspicuity(void)                       /* compute conspicuous error map */
315   {
316          int     fhres, fvres;
317          int     fx, fy;
318                                          /* reuse previous z-buffer */
319          cerrmap = (float *)zprev;
320 <        bzero((void *)cerrmap, sizeof(float)*hres*vres);
320 >        memset((void *)cerrmap, '\0', sizeof(float)*hres*vres);
321          cerrzero = 1;
322                                          /* compute base pixel frequency */
323          pixel_deg = .5*(hres/vw.horiz + vres/vw.vert);
# Line 383 | Line 351 | static struct AmbSum {
351  
352  
353   static int
354 < ppri_cmp(pp1, pp2)              /* pixel priority comparison */
355 < const void *pp1, *pp2;
354 > ppri_cmp(               /* pixel priority comparison */
355 >        const void *pp1,
356 >        const void *pp2
357 > )
358   {
359          double  se1 = cerrmap[*(const int *)pp1];
360          double  se2 = cerrmap[*(const int *)pp2];
# Line 404 | Line 374 | const void *pp1, *pp2;
374  
375  
376   static int
377 < ray_refine(n)                   /* refine the given pixel by tracing a ray */
378 < register int    n;
377 > ray_refine(                     /* refine the given pixel by tracing a ray */
378 >        int     n
379 > )
380   {
381          RAY     ir;
411        int     neigh[NSAMPOK];
412        int     nc;
382          COLOR   ctmp;
383          int     i;
384  
# Line 427 | Line 396 | register int   n;
396                          return(-1);
397                  if (nprocs > 1) {
398                          int     rval;
399 <                        rayorigin(&ir, NULL, PRIMARY, 1.0);
399 >                        rayorigin(&ir, PRIMARY, NULL, NULL);
400                          ir.rno = n;
401                          rval = ray_pqueue(&ir);
402                          if (!rval)
# Line 442 | Line 411 | register int   n;
411                  if (sbuffer[n] != 1)
412                          error(CONSISTENCY, "bad code in ray_refine");
413                  if (getambcolor(ctmp, obuffer[n]) &&
414 <                                (colval(ctmp,RED) > 0.01 &
415 <                                 colval(ctmp,GRN) > 0.01 &
416 <                                 colval(ctmp,BLU) > 0.01)) {
414 >                                (colval(ctmp,RED) > 0.01) &
415 >                                (colval(ctmp,GRN) > 0.01) &
416 >                                (colval(ctmp,BLU) > 0.01)) {
417                          for (i = 0; i < 3; i++)
418                                  asump->diffsum[i] +=
419                                      (colval(ir.rcol,i) - colval(cbuffer[n],i))
# Line 472 | Line 441 | register int   n;
441  
442  
443   static long
444 < refine_rays(nrays)              /* compute refinement rays */
445 < long    nrays;
444 > refine_rays(            /* compute refinement rays */
445 >        long    nrays
446 > )
447   {
448          int     *pord;
449          int     ntodo;
# Line 481 | Line 451 | long   nrays;
451          int     i;
452                                          /* skip if nothing significant */
453          if (ndtset && cerrzero)
454 <                return;
454 >                return(0);
455                                          /* initialize priority list */
456          pord = (int *)malloc(sizeof(int)*hres*vres);
457          for (i = hres*vres; i--; )
# Line 517 | Line 487 | long   nrays;
487  
488  
489   int
490 < refine_frame(pass)              /* refine current frame */
491 < int     pass;
490 > refine_frame(           /* refine current frame */
491 >        int     pass
492 > )
493   {
494          static double   rtime_used = 0;
495          static long     ray_cnt = 0;
496          static double   ctime_used = 0;
497          static int      csp_cnt = 0;
498 <        int     timed = (fcur > fbeg | pass > 0 | quickstart);
498 >        int     timed = (fcur > fbeg) | (pass > 0) | (quickstart);
499          double  time_start, rtime_start, time_done;
500          struct AmbSum   myAmbSum;
501          long    rays_todo, nr;
502 <        register int    n;
502 >        int     n;
503                                          /* IBR refinement? */
504 <        if ((pass == 0 & fcur > fbeg))
504 >        if ((pass == 0) & (fcur > fbeg))
505                  return(refine_first());
506                                          /* any time left? */
507          time_start = getTime();
# Line 607 | Line 578 | if (pass == 1) {
578                                          /* compute refinement rays */
579          if (!silent) {
580                  printf("\tRefinement pass %d...",
581 <                                pass+1, rays_todo);
581 >                                pass+1); /*, rays_todo); */
582                  fflush(stdout);
583          }
584          if (asump != NULL)              /* flag low-quality samples */
# Line 617 | Line 588 | if (pass == 1) {
588                                          /* trace those rays */
589          nr = refine_rays(rays_todo);
590          if (!silent)
591 <                printf("traced %d HQ rays\n", nr);
591 >                printf("traced %ld HQ rays\n", nr);
592          if (nr <= 0)
593                  return(0);
594                                          /* update timing stats */
# Line 652 | Line 623 | if (pass == 1) {
623          return(1);
624   nomore:
625                                          /* make sure error map is updated */
626 <        if ((fcur == fbeg | pass > 1))
626 >        if ((fcur == fbeg) | (pass > 1))
627                  comp_frame_error();
628          return(0);
629   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines