commit e9b99fea7c53ea7350ae2f38a5cb2265968bcfa0
parent 7f31e62724072d85a7a64b75386a270568b916ca
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 17 Apr 2019 11:13:41 +0200
Add support of the per realisation time estimation
Diffstat:
2 files changed, 47 insertions(+), 16 deletions(-)
diff --git a/doc/htpp.1.txt b/doc/htpp.1.txt
@@ -1,4 +1,4 @@
-// Copyright (C) 2018 CNRS, |Meso|Star>, Université Paul Sabatier
+// Copyright (C) 2018-2019 CNRS, |Meso|Star>, Université Paul Sabatier
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -79,6 +79,10 @@ OPTIONS
regular colors but no XYZ to sRGB conversion is applied on the tone mapped
values.
+*-T*::
+ Generate an image of the per radiative path computation time rather than an
+ image of the estimated radiance.
+
*-t* _threads-count_::
Hint on the number of threads to use. By default use as many threads as CPU
cores.
diff --git a/src/htpp.c b/src/htpp.c
@@ -30,18 +30,24 @@
#include <sys/stat.h> /* S_IRUSR & S_IWUSR */
#include <unistd.h> /* getopt */
+enum pixel_data {
+ PIXEL_RADIANCE,
+ PIXEL_UNCERTAINTY,
+ PIXEL_TIME
+};
+
struct args {
const char* input;
const char* output;
double exposure;
double white_scale;
- int uncertainties;
+ enum pixel_data pixdata;
int verbose;
int force_overwrite;
int nthreads;
int quit;
};
-#define ARGS_DEFAULT__ {NULL,NULL,1.0,-1.0,0,0,0,INT_MAX,0}
+#define ARGS_DEFAULT__ {NULL,NULL,1.0,-1.0,PIXEL_RADIANCE,0,0,INT_MAX,0}
static const struct args ARGS_DEFAULT = ARGS_DEFAULT__;
struct img {
@@ -77,7 +83,9 @@ print_help(const char* cmd)
" -o OUTPUT write PPM image to OUTPUT. If not defined, write results\n"
" to standard output.\n");
printf(
-" -u dump per channel uncertainties rather than luminance.\n");
+" -u dump per channel uncertainties rather than radiance.\n");
+ printf(
+" -T dump per realiastion time rather than radiance.\n");
printf(
" -t THREADS hint on the number of threads to use. By default use as\n"
" many threads as CPU cores.\n");
@@ -122,7 +130,7 @@ args_init(struct args* args, const int argc, char** argv)
}
}
- while((opt = getopt(argc, argv, "e:fho:t:uvw:")) != -1) {
+ while((opt = getopt(argc, argv, "e:fho:Tt:uvw:")) != -1) {
switch(opt) {
case 'e':
res = cstr_to_double(optarg, &args->exposure);
@@ -135,11 +143,12 @@ args_init(struct args* args, const int argc, char** argv)
args->quit = 1;
goto exit;
case 'o': args->output = optarg; break;
+ case 'T': args->pixdata = PIXEL_TIME; break;
case 't':
res = cstr_to_int(optarg, &args->nthreads);
if(res == RES_OK && args->nthreads <= 0) res = RES_BAD_ARG;
break;
- case 'u': args->uncertainties = 1; break;
+ case 'u': args->pixdata = PIXEL_UNCERTAINTY; break;
case 'v': args->verbose = 1; break;
case 'w':
res = cstr_to_double(optarg, &args->white_scale);
@@ -339,7 +348,7 @@ img_release(struct img* img)
static res_T
img_load
(struct img* img,
- const int uncertainties, /* Load uncertainties rather than color */
+ const enum pixel_data pixdata,
FILE* stream,
const char* stream_name)
{
@@ -382,7 +391,7 @@ img_load
FOR_EACH(y, 0, img->height) {
double* row = (double*)(img->pixels + y*img->pitch);
FOR_EACH(x, 0, img->width) {
- double tmp[6];
+ double tmp[8] = {0};
double* pixel = row + x*3;
if(!read_line(&b, stream)) {
fprintf(stderr,
@@ -391,15 +400,31 @@ img_load
res = RES_IO_ERR;
goto error;
}
- if(cstr_to_list_double(b, ' ', tmp, 0, 6) != RES_OK) {
- fprintf(stderr, "%s: invalid XYZ value for the (%lu, %lu) pixel.\n",
+ if(cstr_to_list_double(b, ' ', tmp, 0, 8) != RES_OK /* X, Y, Z, Time */
+ && cstr_to_list_double(b, ' ', tmp, 0, 6) != RES_OK /* X, Y, Z */) {
+ fprintf(stderr, "%s: invalid XYZ[Time] value for the (%lu, %lu) pixel.\n",
stream_name, (unsigned long)x, (unsigned long)y);
res = RES_BAD_ARG;
goto error;
}
- pixel[0] = tmp[uncertainties+0];
- pixel[1] = tmp[uncertainties+2];
- pixel[2] = tmp[uncertainties+4];
+ switch(pixdata) {
+ case PIXEL_RADIANCE:
+ pixel[0] = tmp[0];
+ pixel[1] = tmp[2];
+ pixel[2] = tmp[4];
+ break;
+ case PIXEL_UNCERTAINTY:
+ pixel[0] = tmp[1];
+ pixel[1] = tmp[3];
+ pixel[2] = tmp[5];
+ break;
+ case PIXEL_TIME:
+ pixel[0] = tmp[6];
+ pixel[1] = tmp[6];
+ pixel[2] = tmp[6];
+ break;
+ default: FATAL("Unreachable code.\n"); break;
+ }
img->Yrange[0] = MMIN(img->Yrange[0], pixel[1]);
img->Yrange[1] = MMAX(img->Yrange[1], pixel[1]);
}
@@ -497,6 +522,7 @@ main(int argc, char** argv)
struct img img = IMG_NULL;
struct args args = ARGS_DEFAULT;
double Ymax;
+ int img_is_loaded = 0;
int err = 0;
int64_t i;
res_T res = RES_OK;
@@ -518,8 +544,9 @@ main(int argc, char** argv)
fprintf(stderr, "Read image from standard input.\n");
}
- res = img_load(&img, args.uncertainties, stream_in, stream_in_name);
+ res = img_load(&img, args.pixdata, stream_in, stream_in_name);
if(res != RES_OK) goto error;
+ img_is_loaded = 1;
if(args.white_scale > 0) {
Ymax = args.white_scale;
@@ -538,7 +565,7 @@ main(int argc, char** argv)
double* pixel = row + x*3;
filmic_tone_mapping(pixel, args.exposure, Ymax); /* Tone map the RGB pixel */
- if(!args.uncertainties) {
+ if(args.pixdata == PIXEL_RADIANCE) {
XYZ_to_RGB(pixel); /* Convert in RGB color space */
RGB_to_sRGB(pixel); /* Convert in sRGB color space (i.e. gamma correction) */
}
@@ -550,8 +577,8 @@ main(int argc, char** argv)
exit:
if(stream_out && stream_out != stdout) fclose(stream_out);
if(stream_in && stream_in != stdin) fclose(stream_in);
+ if(img_is_loaded) img_release(&img);
args_release(&args);
- img_release(&img);
return err;
error:
err = -1;