add option to store rendered image at a different prefix
authorAndreas Eversberg <jolly@eversberg.eu>
Sat, 10 Oct 2015 09:07:55 +0000 (11:07 +0200)
committerAndreas Eversberg <jolly@eversberg.eu>
Sat, 14 May 2016 10:55:53 +0000 (12:55 +0200)
src/colorize.c

index 4190854..fe50913 100644 (file)
@@ -186,6 +186,7 @@ again:
 
 static int in_itr_num = 5, out_itr_num = 1, quick = 0, optical_flow = 1, bright_contrast = 1, alpha_change = 1;
 int scale = 1, scalexyz = 999;
+static char output_prefix[256] = "";
 
 static enum test test = NO_TEST;
 
@@ -230,6 +231,7 @@ static int handle_options(int argc, char **argv)
                static struct option long_options[] = {
                        {"help", 0, 0, 'h'},
                        {"depth", 1, 0, 'd'},
+                       {"output-prefix", 1, 0, 'O'},
                        {"in-itr-num", 1, 0, 'i'},
                        {"out-itr-num", 1, 0, 'o'},
                        {"quick", 0, 0, 'q'},
@@ -241,7 +243,7 @@ static int handle_options(int argc, char **argv)
                        {0, 0, 0, 0},
                };
 
-               c = getopt_long(argc, argv, "hd:i:o:qz:b:f:s:t:", long_options, &option_index);
+               c = getopt_long(argc, argv, "hd:O:i:o:qz:b:f:s:t:", long_options, &option_index);
 
                if (c == -1)
                        break;
@@ -254,6 +256,10 @@ static int handle_options(int argc, char **argv)
                        save_depth = atoi(optarg);
                        skip_args += 2;
                        break;
+               case 'O':
+                       strcpy(output_prefix, optarg);
+                       skip_args += 2;
+                       break;
                case 'i':
                        in_itr_num = atoi(optarg);
                        skip_args += 2;
@@ -322,6 +328,7 @@ static void print_help(const char *app)
        printf("\nOptions:\n");
        printf(" -h --help                           This help\n");
        printf(" -d --depth <bits>                   Save images with given color bit depth (default=%d)\n", save_depth);
+       printf(" -O --output-prefix <path>/<prefix>  Store result image of a sequence using this prefix\n");
        printf(" -i --in-itr-num <num>               Alter inner iterations (weightening count) of colorization algorithm (default=%d)\n", in_itr_num);
        printf(" -o --out-itr-num <num>              Alter outer iterations (complete turns) of colorization algorithm (default=%d)\n", out_itr_num);
        printf(" -q --quick                          Use quick render, but sufaces may be colorized incomplete\n");
@@ -684,9 +691,13 @@ next_sequence:
                        p = sequence[z].filename;
                        while((q = strchr(p, DIR_SEPERATOR)))
                                p = q + 1;
-                       strcpy(name, sequence[z].filename);
-                       name[p - sequence[z].filename] = '\0';
-                       strcat(name, "colorized_");
+                       if (output_prefix[0] == '\0') {
+                               strcpy(name, sequence[z].filename);
+                               name[p - sequence[z].filename] = '\0';
+                               strcat(name, "colorized_");
+                       } else {
+                               strcpy(name, output_prefix);
+                       }
                        strcat(name, p);
                        filename = name;
                } else