]> git.sesse.net Git - nageru/commitdiff
Support changing the interpolation quality.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 14 Oct 2018 14:51:48 +0000 (16:51 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 14 Oct 2018 14:51:48 +0000 (16:51 +0200)
flags.cpp
flags.h
video_stream.cpp

index af1cfb971feafffd754608d2409b1054dfb624ee..b3b59fab41f0fd30d99c934e1cad0ea2f8c24175 100644 (file)
--- a/flags.cpp
+++ b/flags.cpp
@@ -24,6 +24,10 @@ void usage()
        fprintf(stderr, "      --help                      print usage information\n");
        fprintf(stderr, "      --slow-down-input           slow down input to realtime (default on if no\n");
        fprintf(stderr, "                                    source URL given)");
+       fprintf(stderr, "  -q, --interpolation-quality N   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");
 }
 
 void parse_flags(int argc, char * const argv[])
@@ -31,6 +35,7 @@ void parse_flags(int argc, char * const argv[])
        static const option long_options[] = {
                { "help", no_argument, 0, OPTION_HELP },
                { "slow-down-input", no_argument, 0, OPTION_SLOW_DOWN_INPUT },
+               { "interpolation-quality", required_argument, 0, 'q' },
                { 0, 0, 0, 0 }
        };
        for ( ;; ) {
@@ -44,6 +49,9 @@ void parse_flags(int argc, char * const argv[])
                case OPTION_SLOW_DOWN_INPUT:
                        global_flags.slow_down_input = true;
                        break;
+               case 'q':
+                       global_flags.interpolation_quality = atoi(optarg);
+                       break;
                case OPTION_HELP:
                        usage();
                        exit(0);
@@ -54,4 +62,10 @@ void parse_flags(int argc, char * const argv[])
                        exit(1);
                }
        }
+
+       if (global_flags.interpolation_quality < 1 || global_flags.interpolation_quality > 4) {
+               fprintf(stderr, "Interpolation quality must be 1, 2, 3 or 4.\n");
+               usage();
+               exit(1);
+       }
 }
diff --git a/flags.h b/flags.h
index 794e90d37005eef2a60a4acc0fff60d02382e05a..ea4d423ed5dd6768dcf93b197de3076e84f89285 100644 (file)
--- a/flags.h
+++ b/flags.h
@@ -6,6 +6,7 @@
 struct Flags {
        std::string stream_source;
        bool slow_down_input = false;
+       int interpolation_quality = 2;
 };
 extern Flags global_flags;
 
index e89839a6314f963f410f577dc7607f135499a579..015fa66613d473bc860841c41ea37598efd3b22a 100644 (file)
@@ -7,6 +7,7 @@ extern "C" {
 
 #include "chroma_subsampler.h"
 #include "context.h"
+#include "flags.h"
 #include "flow.h"
 #include "httpd.h"
 #include "jpeg_frame_view.h"
@@ -222,9 +223,22 @@ VideoStream::VideoStream()
 
        check_error();
 
-       compute_flow.reset(new DISComputeFlow(width, height, operating_point2));
-       interpolate.reset(new Interpolate(operating_point2, /*split_ycbcr_output=*/true));
-       interpolate_no_split.reset(new Interpolate(operating_point2, /*split_ycbcr_output=*/false));
+       OperatingPoint op;
+       if (global_flags.interpolation_quality == 1) {
+               op = operating_point1;
+       } else if (global_flags.interpolation_quality == 2) {
+               op = operating_point2;
+       } else if (global_flags.interpolation_quality == 3) {
+               op = operating_point3;
+       } else if (global_flags.interpolation_quality == 4) {
+               op = operating_point4;
+       } else {
+               assert(false);
+       }
+
+       compute_flow.reset(new DISComputeFlow(width, height, op));
+       interpolate.reset(new Interpolate(op, /*split_ycbcr_output=*/true));
+       interpolate_no_split.reset(new Interpolate(op, /*split_ycbcr_output=*/false));
        chroma_subsampler.reset(new ChromaSubsampler);
        check_error();