diff options
author | M Joonas Pihlaja <jpihlaja@cc.helsinki.fi> | 2009-01-13 03:33:26 +0200 |
---|---|---|
committer | M Joonas Pihlaja <jpihlaja@cc.helsinki.fi> | 2009-01-13 03:43:16 +0200 |
commit | 342cac39e84d02c11d0ea894cc29086d99c0faed (patch) | |
tree | a7c688d8817ecc32a272d348fa34a29f8e7b037d | |
parent | c510b18e94b9dd47ec540fcf8be4b208af1e0b79 (diff) |
Move numeric arguments to the environment.
-rw-r--r-- | unpremultiply.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/unpremultiply.c b/unpremultiply.c index 8e6a25d..027477b 100644 --- a/unpremultiply.c +++ b/unpremultiply.c @@ -406,22 +406,33 @@ fill_empty(uint32_t *buf, size_t n) memset(buf, 0, 4*n); } +static long +getenvlong(char const *name, long default_value) +{ + char *val = getenv(name); + return val ? atol(val) : default_value; +} + int main(int argc, char **argv) { - long nloops = argc > 1 ? atol(argv[1]) : 1; - size_t n = 2*1024*1024*0 + (256*1024/4)/2; + long nloops = getenvlong("loops", 50); + size_t n = getenvlong("pixels", 2*1024*1024); + long ofs = getenvlong("offset", 0); uint32_t *dst = calloc(n, 4); uint32_t *src = calloc(n, 4); char const *method = "lut"; int verify = 0; int i; + dst = (uint32_t*)((uintptr_t)dst + ofs); + src = (uint32_t*)((uintptr_t)src + ofs); + make_division_table(); make_reciprocal_table_A(); make_reciprocal_table_B(); - for (i=2; i<argc; i++) { + for (i=1; i<argc; i++) { if (0 == strcmp(argv[i], "verify")) { verify = 1; } |