From 50a9063a51e0e8ce229e0accc0c446d03babd99c Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 14 Oct 2018 16:51:48 +0200 Subject: [PATCH 1/1] Support changing the interpolation quality. --- flags.cpp | 14 ++++++++++++++ flags.h | 1 + video_stream.cpp | 20 +++++++++++++++++--- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/flags.cpp b/flags.cpp index af1cfb9..b3b59fa 100644 --- 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 794e90d..ea4d423 100644 --- 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; diff --git a/video_stream.cpp b/video_stream.cpp index e89839a..015fa66 100644 --- a/video_stream.cpp +++ b/video_stream.cpp @@ -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(); -- 2.39.2