]> git.sesse.net Git - nageru/blobdiff - futatabi/flags.cpp
Fix a Clang warning.
[nageru] / futatabi / flags.cpp
index 11ae71da864bdc62d9e9240b02ccf54bf7b86559..1c606b13e53d62b97d556e2b8eb34f2dc8137bd8 100644 (file)
@@ -10,6 +10,7 @@
 using namespace std;
 
 Flags global_flags;
+int flow_initialized_interpolation_quality;
 
 // Long options that have no corresponding short option.
 enum LongOption {
@@ -25,6 +26,8 @@ void usage()
        fprintf(stderr, "      --help                      print usage information\n");
        fprintf(stderr, "  -w, --width                     output width in pixels (default 1280)\n");
        fprintf(stderr, "  -h, --height                    output height in pixels (default 720)\n");
+       fprintf(stderr, "  -r, --frame-rate NUM[/NUM]      output frame rate, as a float or fraction\n");
+       fprintf(stderr, "                                    (default 60000/1001 ~= 59.94)\n");
        fprintf(stderr, "      --slow-down-input           slow down input to realtime (default on if no\n");
        fprintf(stderr, "                                    source URL given)\n");
        fprintf(stderr, "  -q, --interpolation-quality N   0 = off\n");
@@ -42,6 +45,7 @@ void parse_flags(int argc, char * const argv[])
                { "help", no_argument, 0, OPTION_HELP },
                { "width", required_argument, 0, 'w' },
                { "height", required_argument, 0, 'h' },
+               { "frame-rate", required_argument, 0, 'r' },
                { "slow-down-input", no_argument, 0, OPTION_SLOW_DOWN_INPUT },
                { "interpolation-quality", required_argument, 0, 'q' },
                { "working-directory", required_argument, 0, 'd' },
@@ -50,7 +54,7 @@ void parse_flags(int argc, char * const argv[])
        };
        for ( ;; ) {
                int option_index = 0;
-               int c = getopt_long(argc, argv, "w:h:q:d:", long_options, &option_index);
+               int c = getopt_long(argc, argv, "w:h:r:q:d:", long_options, &option_index);
 
                if (c == -1) {
                        break;
@@ -62,11 +66,24 @@ void parse_flags(int argc, char * const argv[])
                case 'h':
                        global_flags.height = atoi(optarg);
                        break;
+               case 'r': {
+                       double num, den;
+                       if (sscanf(optarg, "%lf/%lf", &num, &den) == 2) {
+                               global_flags.output_framerate = num / den;
+                       } else if (sscanf(optarg, "%lf", &num) == 1) {
+                               global_flags.output_framerate = num;
+                       } else {
+                               fprintf(stderr, "Invalid frame rate given (must be on the form N or N/M)\n");
+                               exit(1);
+                       }
+                       break;
+               }
                case OPTION_SLOW_DOWN_INPUT:
                        global_flags.slow_down_input = true;
                        break;
                case 'q':
                        global_flags.interpolation_quality = atoi(optarg);
+                       global_flags.interpolation_quality_set = true;
                        break;
                case 'd':
                        global_flags.working_directory = optarg;