--- ray/src/px/pmblur2.c 2012/10/05 00:59:38 2.1 +++ ray/src/px/pmblur2.c 2012/10/05 18:54:40 2.4 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: pmblur2.c,v 2.1 2012/10/05 00:59:38 greg Exp $"; +static const char RCSid[] = "$Id: pmblur2.c,v 2.4 2012/10/05 18:54:40 greg Exp $"; #endif /* * pmblur2.c - program to computer better motion blur from ranimove frames. @@ -111,6 +111,10 @@ loadprev(int fno) exprev = ih.ev; if (!fgetsresolu(&rs, fp)) goto readerr; + if (rs.rt != PIXSTANDARD) { + sprintf(errmsg, "unsupported orientation in picture \"%s\"", fname); + error(USER, errmsg); + } if (!imres.xr) { /* allocate buffers */ imres = rs; imsum = (COLOR *)ecalloc(imres.xr*imres.yr, sizeof(COLOR)); @@ -146,15 +150,15 @@ readerr: /* Interpolate between two image pixels */ /* XXX skipping expensive ray vector calculations for now */ static void -interp_pixel(COLOR con, const VIEW *vwn, int xn, int yn, double zn, - double pos, int xp, int yp) +interp_pixel(COLOR con, const VIEW *vwn, int xn, int yn, double zval, + double pos, int xp, int yp, int interpOK) { const int hres = scanlen(&imres); RREAL ipos; FVECT wprev, wcoor, rdir; int np, xd, yd, nd; COLOR cpr; - double sf, zval; + double sf; /* check if off image */ if ((xp < 0) | (xp >= hres)) return; @@ -164,17 +168,20 @@ interp_pixel(COLOR con, const VIEW *vwn, int xn, int y xd = (1.-pos)*xp + pos*xn + .5; yd = (1.-pos)*yp + pos*yn + .5; nd = yd*hres + xd; - /* check interpolated depth */ - zval = (1.-pos)*zprev[np] + pos*zn; + /* check depth */ + if (interpOK) + zval = (1.-pos)*zprev[np] + pos*zval; if (zval >= zbuf[nd]) return; - copycolor(imbuf[nd], con); /* assign interpolated color */ + zbuf[nd] = zval; /* assign new depth */ + copycolor(imbuf[nd], con); /* assign new color */ + if (!interpOK) + return; scalecolor(imbuf[nd], pos); sf = (1.-pos)/exprev; colr_color(cpr, imprev[np]); scalecolor(cpr, sf); addcolor(imbuf[nd], cpr); - zbuf[nd] = zval; /* assign new depth */ } @@ -258,6 +265,10 @@ addframe(double fpos) error(USER, err); if (!fgetsresolu(&rs, fpimg)) goto readerr; + if (rs.rt != PIXSTANDARD) { + sprintf(errmsg, "unsupported orientation in picture \"%s\"", fname); + error(USER, errmsg); + } if ((rs.xr != imres.xr) | (rs.yr != imres.yr)) { sprintf(errmsg, "resolution mismatch for picture \"%s\"", fname); error(USER, errmsg); @@ -311,7 +322,8 @@ addframe(double fpos) scalecolor(cval, sf); interp_pixel(cval, &fvw, h, n, zscan[h], fpos, h + (int)mscan[3*h] - 32768, - n - (int)mscan[3*h+1] + 32768); + n - (int)mscan[3*h+1] + 32768, + mscan[3*h+2]); } } /* fill in missing pixels */ @@ -384,31 +396,39 @@ main(int argc, char *argv[]) SET_DEFAULT_BINARY(); if (argc != 5) goto userr; - /* get frame range */ - switch (sscanf(argv[1], "%lf,%lf", &fstart, &fend)) { + /* get frame range & sampling */ + switch (sscanf(argv[1], "%lf,%lf/%d", &fstart, &fend, &nsamps)) { case 1: fend = fstart; + nsamps = 0; break; case 2: + nsamps = 0; + /* fall through */ + case 3: if (fend < fstart) goto userr; + if (fend <= fstart+FTINY) + nsamps = 0; break; default: goto userr; } if (fstart < 1) goto userr; - hdrspec = argv[2]; - zbfspec = argv[3]; - mvospec = argv[4]; - nsamps = (fend - fstart)*12.; + if (nsamps <= 0) + nsamps = (fend - fstart)*17.; if (nsamps) { + if (nsamps > 100) nsamps = 100; fstep = (fend - fstart)/nsamps; } else { fstep = 1.; fstart -= .5; nsamps = 1; } + hdrspec = argv[2]; + zbfspec = argv[3]; + mvospec = argv[4]; /* load and filter each subframe */ for (fcur = fstart + .5*fstep; fcur <= fend; fcur += fstep) addframe(fcur); @@ -420,6 +440,6 @@ main(int argc, char *argv[]) write_average(stdout); return(fflush(stdout) == EOF); userr: - fprintf(stderr, "Usage: %s f0,f1 HDRspec ZBUFspec MVOspec\n", progname); + fprintf(stderr, "Usage: %s f0,f1[/n] HDRspec ZBUFspec MVOspec\n", progname); return(1); }