X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=futatabi%2Fflags.cpp;h=1c606b13e53d62b97d556e2b8eb34f2dc8137bd8;hb=85e1c098fb61869cba7edf20a6281b2f87a7b9ed;hp=0de7b0261937f42b1133e82b95e42d742acbab28;hpb=52336c086b8bc355b55e2046e3a055b1b4c70ef7;p=nageru diff --git a/futatabi/flags.cpp b/futatabi/flags.cpp index 0de7b02..1c606b1 100644 --- a/futatabi/flags.cpp +++ b/futatabi/flags.cpp @@ -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,9 +26,12 @@ 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 1 = fastest\n"); + fprintf(stderr, " -q, --interpolation-quality N 0 = off\n"); + fprintf(stderr, " 1 = fastest\n"); fprintf(stderr, " 2 = default (realtime 720p on fast embedded GPUs)\n"); fprintf(stderr, " 3 = good (realtime 720p on GTX 970 or so)\n"); fprintf(stderr, " 4 = best (not realtime on any current GPU)\n"); @@ -41,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' }, @@ -49,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; @@ -61,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; @@ -84,8 +102,8 @@ void parse_flags(int argc, char * const argv[]) } } - if (global_flags.interpolation_quality < 1 || global_flags.interpolation_quality > 4) { - fprintf(stderr, "Interpolation quality must be 1, 2, 3 or 4.\n"); + if (global_flags.interpolation_quality < 0 || global_flags.interpolation_quality > 4) { + fprintf(stderr, "Interpolation quality must be 0, 1, 2, 3 or 4.\n"); usage(); exit(1); }