Skip to content

Commit

Permalink
#89; Add -I/--bilinear-texture option to toggle bilinear texture inte…
Browse files Browse the repository at this point in the history
…rpolation via the command line
  • Loading branch information
jonfryd committed Jan 7, 2025
1 parent abe108a commit 9a7f504
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ struct VideoCompareConfig {
bool high_dpi_allowed{false};
bool use_10_bpc{false};
bool fast_input_alignment{false};
bool bilinear_texture_filtering{false};
bool disable_auto_filters{false};

int display_number{0};
Expand Down
8 changes: 5 additions & 3 deletions display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ Display::Display(const int display_number,
const bool high_dpi_allowed,
const bool use_10_bpc,
const bool fast_input_alignment,
const bool bilinear_texture_filtering,
const std::tuple<int, int> window_size,
const unsigned width,
const unsigned height,
Expand All @@ -176,6 +177,7 @@ Display::Display(const int display_number,
high_dpi_allowed_{high_dpi_allowed},
use_10_bpc_{use_10_bpc},
fast_input_alignment_{fast_input_alignment},
bilinear_texture_filtering_{bilinear_texture_filtering},
video_width_{static_cast<int>(width)},
video_height_{static_cast<int>(height)},
duration_{duration},
Expand Down Expand Up @@ -711,7 +713,7 @@ void Display::render_progress_dots(const float position, const float progress, c
}

SDL_Texture* Display::get_video_texture() const {
return use_bilinear_texture_filtering_ ? video_texture_linear_ : video_texture_nn_;
return bilinear_texture_filtering_ ? video_texture_linear_ : video_texture_nn_;
}

void Display::update_texture(const SDL_Rect* rect, const void* pixels, int pitch, const std::string& message) {
Expand Down Expand Up @@ -1598,8 +1600,8 @@ void Display::input() {
std::cout << "Input alignment resizing filter set to '" << (fast_input_alignment_ ? "BILINEAR (fast)" : "BICUBIC (high-quality)") << "' (takes effect for the next decoded frame)" << std::endl;
break;
case SDLK_t:
use_bilinear_texture_filtering_ = !use_bilinear_texture_filtering_;
std::cout << "Video texture filter set to '" << (use_bilinear_texture_filtering_ ? "BILINEAR" : "NEAREST NEIGHBOR") << "'" << std::endl;
bilinear_texture_filtering_ = !bilinear_texture_filtering_;
std::cout << "Video texture filter set to '" << (bilinear_texture_filtering_ ? "BILINEAR" : "NEAREST NEIGHBOR") << "'" << std::endl;
break;
case SDLK_s: {
swap_left_right_ = !swap_left_right_;
Expand Down
5 changes: 3 additions & 2 deletions display.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ class Display {
const bool fit_window_to_usable_bounds_;
const bool high_dpi_allowed_;
const bool use_10_bpc_;
bool fast_input_alignment_{true};
bool fast_input_alignment_;
bool bilinear_texture_filtering_;
const int video_width_;
const int video_height_;
const double duration_;
Expand All @@ -96,7 +97,6 @@ class Display {
bool show_left_{true};
bool show_right_{true};
bool show_hud_{true};
bool use_bilinear_texture_filtering_{false};
bool subtraction_mode_{false};
float seek_relative_{0.0F};
int frame_buffer_offset_delta_{0};
Expand Down Expand Up @@ -230,6 +230,7 @@ class Display {
const bool high_dpi_allowed,
const bool use_10_bpc,
const bool fast_input_alignment,
const bool bilinear_texture_filtering,
const std::tuple<int, int> window_size,
const unsigned width,
const unsigned height,
Expand Down
4 changes: 3 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ int main(int argc, char** argv) {
{"verbose", {"-v", "--verbose"}, "enable verbose output, including information such as library versions and rendering details", 0},
{"high-dpi", {"-d", "--high-dpi"}, "allow high DPI mode for e.g. displaying UHD content on Retina displays", 0},
{"10-bpc", {"-b", "--10-bpc"}, "use 10 bits per color component instead of 8", 0},
{"fast-alignment", {"-F", "--fast-alignment"}, "use faster bilinear scaling for aligning the resolution of input sources instead of higher-quality bicubic interpolation", 0},
{"fast-alignment", {"-F", "--fast-alignment"}, "toggle faster bilinear scaling for aligning input source resolutions, replacing higher-quality bicubic interpolation when resolutions differ", 0},
{"bilinear-texture", {"-I", "--bilinear-texture"}, "toggle bilinear video texture interpolation, replacing nearest-neighbor filtering", 0},
{"display-number", {"-n", "--display-number"}, "open main window on specific display (e.g. 0, 1 or 2), default is 0", 1},
{"display-mode", {"-m", "--mode"}, "display mode (layout), 'split' for split screen (default), 'vstack' for vertical stack, 'hstack' for horizontal stack", 1},
{"window-size", {"-w", "--window-size"}, "override window size, specified as [width]x[height] (e.g. 800x600, 1280x or x480)", 1},
Expand Down Expand Up @@ -314,6 +315,7 @@ int main(int argc, char** argv) {
config.high_dpi_allowed = args["high-dpi"];
config.use_10_bpc = args["10-bpc"];
config.fast_input_alignment = args["fast-alignment"];
config.bilinear_texture_filtering = args["bilinear-texture"];
config.disable_auto_filters = args["disable-auto-filters"];

if (args["display-number"]) {
Expand Down
1 change: 1 addition & 0 deletions video_compare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ VideoCompare::VideoCompare(const VideoCompareConfig& config)
config.high_dpi_allowed,
config.use_10_bpc,
initial_fast_input_alignment_,
config.bilinear_texture_filtering,
config.window_size,
max_width_,
max_height_,
Expand Down

0 comments on commit 9a7f504

Please sign in to comment.