| 7 |
|
*/ |
| 8 |
|
|
| 9 |
|
#include "platform.h" |
| 10 |
– |
#include "paths.h" |
| 11 |
– |
#include "paths.h" |
| 10 |
|
#include "pcond.h" |
| 11 |
|
|
| 12 |
|
|
| 13 |
|
#define LDMAX 100 /* default max. display luminance */ |
| 14 |
< |
#define LDDYN 32 /* default dynamic range */ |
| 14 |
> |
#define LDDYN 100 /* default dynamic range */ |
| 15 |
|
|
| 16 |
|
int what2do = 0; /* desired adjustments */ |
| 17 |
|
|
| 19 |
|
double lddyn = LDDYN; /* display dynamic range */ |
| 20 |
|
double Bldmin, Bldmax; /* Bl(ldmax/lddyn) and Bl(ldmax) */ |
| 21 |
|
|
| 24 |
– |
char *progname; /* global argv[0] */ |
| 25 |
– |
|
| 22 |
|
char *infn; /* input file name */ |
| 23 |
|
FILE *infp; /* input stream */ |
| 24 |
|
FILE *mapfp = NULL; /* tone-mapping function stream */ |
| 56 |
|
{ |
| 57 |
|
static RGBPRIMS outprimS; |
| 58 |
|
int i; |
| 59 |
< |
#define bool(flg) switch (argv[i][2]) { \ |
| 59 |
> |
#define check_bool(flg) switch (argv[i][2]) { \ |
| 60 |
|
case '\0': what2do ^= flg; break; \ |
| 61 |
|
case 'y': case 'Y': case 't': case 'T': \ |
| 62 |
|
case '+': case '1': what2do |= flg; break; \ |
| 64 |
|
case '-': case '0': what2do &= ~(flg); break; \ |
| 65 |
|
default: goto userr; } |
| 66 |
|
|
| 67 |
< |
progname = argv[0]; |
| 67 |
> |
fixargv0(argv[0]); /* sets global progname */ |
| 68 |
|
|
| 69 |
|
for (i = 1; i < argc && argv[i][0] == '-'; i++) |
| 70 |
|
switch (argv[i][1]) { |
| 71 |
|
case 'h': |
| 72 |
< |
bool(DO_HUMAN); |
| 72 |
> |
check_bool(DO_HUMAN); |
| 73 |
|
break; |
| 74 |
|
case 'a': |
| 75 |
< |
bool(DO_ACUITY); |
| 75 |
> |
check_bool(DO_ACUITY); |
| 76 |
|
break; |
| 77 |
|
case 'v': |
| 78 |
< |
bool(DO_VEIL); |
| 78 |
> |
check_bool(DO_VEIL); |
| 79 |
|
break; |
| 80 |
|
case 's': |
| 81 |
< |
bool(DO_HSENS); |
| 81 |
> |
check_bool(DO_HSENS); |
| 82 |
|
break; |
| 83 |
|
case 'c': |
| 84 |
< |
bool(DO_COLOR); |
| 84 |
> |
check_bool(DO_COLOR); |
| 85 |
|
break; |
| 86 |
|
case 'w': |
| 87 |
< |
bool(DO_CWEIGHT); |
| 87 |
> |
check_bool(DO_CWEIGHT); |
| 88 |
|
break; |
| 89 |
|
case 'i': |
| 90 |
|
if (i+1 >= argc) goto userr; |
| 93 |
|
else what2do &= ~DO_FIXHIST; |
| 94 |
|
break; |
| 95 |
|
case 'I': |
| 96 |
< |
bool(DO_PREHIST); |
| 96 |
> |
check_bool(DO_PREHIST); |
| 97 |
|
break; |
| 98 |
|
case 'l': |
| 99 |
< |
bool(DO_LINEAR); |
| 99 |
> |
check_bool(DO_LINEAR); |
| 100 |
|
break; |
| 101 |
|
case 'p': |
| 102 |
|
if (i+8 >= argc) goto userr; |
| 191 |
|
progname); |
| 192 |
|
exit(1); |
| 193 |
|
return 1; /* pro forma return */ |
| 194 |
< |
#undef bool |
| 194 |
> |
#undef check_bool |
| 195 |
|
} |
| 196 |
|
|
| 197 |
|
|
| 213 |
|
) |
| 214 |
|
{ |
| 215 |
|
static RGBPRIMS inprimS; |
| 216 |
< |
char fmt[32]; |
| 216 |
> |
char fmt[MAXFMTLEN]; |
| 217 |
|
|
| 218 |
|
if (formatval(fmt, s)) { /* check if format string */ |
| 219 |
< |
if (!strcmp(fmt,COLRFMT)) lumf = rgblum; |
| 220 |
< |
else if (!strcmp(fmt,CIEFMT)) lumf = cielum; |
| 221 |
< |
else lumf = NULL; |
| 219 |
> |
if (!strcmp(fmt,COLRFMT) || !strcmp(fmt,SPECFMT)) |
| 220 |
> |
lumf = rgblum; |
| 221 |
> |
else if (!strcmp(fmt,CIEFMT)) |
| 222 |
> |
lumf = cielum; |
| 223 |
> |
else |
| 224 |
> |
lumf = NULL; |
| 225 |
|
return(0); /* don't echo */ |
| 226 |
|
} |
| 227 |
< |
if (isprims(s)) { /* get input primaries */ |
| 228 |
< |
primsval(inprimS, s); |
| 229 |
< |
inprims= inprimS; |
| 227 |
> |
if (isncomp(s)) { |
| 228 |
> |
NCSAMP = ncompval(s); |
| 229 |
> |
return(0); |
| 230 |
> |
} |
| 231 |
> |
if (iswlsplit(s)) { |
| 232 |
> |
wlsplitval(WLPART, s); |
| 233 |
> |
return(0); |
| 234 |
> |
} |
| 235 |
> |
/* get input primaries */ |
| 236 |
> |
if (isprims(s) && primsval(inprimS, s)) { |
| 237 |
> |
inprims = inprimS; |
| 238 |
|
return(0); /* don't echo */ |
| 239 |
|
} |
| 240 |
|
if (isexpos(s)) { /* picture exposure */ |
| 356 |
|
if (fgetresolu(&x, &y, fp) < 0 || (x != fvxr) | (y != fvyr)) |
| 357 |
|
goto readerr; |
| 358 |
|
for (y = 0; y < fvyr; y++) |
| 359 |
< |
if (freadscan(fovscan(y), fvxr, fp) < 0) |
| 359 |
> |
if (fread2scan(fovscan(y), fvxr, fp, NCSAMP, WLPART) < 0) |
| 360 |
|
goto readerr; |
| 361 |
|
pclose(fp); |
| 362 |
|
return; |