Skip to content

Commit

Permalink
Fixed #85; Replaced --hq-alignment with --fast-alignment to prevent a…
Browse files Browse the repository at this point in the history
…liasing issues, while retaining bilinear scaling as the default when the resolution is identical on both sides for performance reasons
  • Loading branch information
jonfryd committed Nov 28, 2024
1 parent fbf8458 commit d2fb09a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion config.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct VideoCompareConfig {
bool fit_window_to_usable_bounds{false};
bool high_dpi_allowed{false};
bool use_10_bpc{false};
bool high_quality_input_alignment{false};
bool fast_input_alignment{false};
bool disable_auto_filters{false};

int display_number{0};
Expand Down
4 changes: 2 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ 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},
{"hq-alignment", {"-q", "--hq-alignment"}, "use higher-quality bicubic interpolation for aligning the resolution of input sources instead of faster bilinear scaling", 0},
{"fast-alignment", {"-F", "--fast-alignment"}, "use faster bilinear scaling for aligning the resolution of input sources instead of higher-quality bicubic interpolation", 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 @@ -279,7 +279,7 @@ int main(int argc, char** argv) {
config.fit_window_to_usable_bounds = args["window-fit-display"];
config.high_dpi_allowed = args["high-dpi"];
config.use_10_bpc = args["10-bpc"];
config.high_quality_input_alignment = args["hq-alignment"];
config.fast_input_alignment = args["fast-alignment"];
config.disable_auto_filters = args["disable-auto-filters"];

if (args["display-number"]) {
Expand Down
15 changes: 6 additions & 9 deletions video_compare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,8 @@ static inline AVPixelFormat determine_pixel_format(const VideoCompareConfig& con
return config.use_10_bpc ? AV_PIX_FMT_RGB48LE : AV_PIX_FMT_RGB24;
}

static inline int determine_sws_flags(const bool high_quality) {
return high_quality ? SWS_BICUBIC : SWS_FAST_BILINEAR;
}

static inline int determine_sws_flags(const VideoCompareConfig& config) {
return determine_sws_flags(config.high_quality_input_alignment);
static inline int determine_sws_flags(const bool fast) {
return fast ? SWS_FAST_BILINEAR : SWS_BICUBIC;
}

static void sleep_for_ms(const uint32_t ms) {
Expand Down Expand Up @@ -136,6 +132,7 @@ VideoCompare::VideoCompare(const VideoCompareConfig& config)
config.disable_auto_filters)},
max_width_{std::max(video_filterers_[LEFT]->dest_width(), video_filterers_[RIGHT]->dest_width())},
max_height_{std::max(video_filterers_[LEFT]->dest_height(), video_filterers_[RIGHT]->dest_height())},
fast_scaling_default_{config.fast_input_alignment || ((video_filterers_[LEFT]->dest_width() == video_filterers_[RIGHT]->dest_width()) && (video_filterers_[LEFT]->dest_height() == video_filterers_[RIGHT]->dest_height()))},
shortest_duration_{std::min(demuxers_[LEFT]->duration(), demuxers_[RIGHT]->duration()) * AV_TIME_TO_SEC},
format_converters_{std::make_unique<FormatConverter>(video_filterers_[LEFT]->dest_width(),
video_filterers_[LEFT]->dest_height(),
Expand All @@ -145,7 +142,7 @@ VideoCompare::VideoCompare(const VideoCompareConfig& config)
determine_pixel_format(config),
video_decoders_[LEFT]->color_space(),
video_decoders_[LEFT]->color_range(),
determine_sws_flags(config)),
determine_sws_flags(fast_scaling_default_)),
std::make_unique<FormatConverter>(video_filterers_[RIGHT]->dest_width(),
video_filterers_[RIGHT]->dest_height(),
max_width_,
Expand All @@ -154,14 +151,14 @@ VideoCompare::VideoCompare(const VideoCompareConfig& config)
determine_pixel_format(config),
video_decoders_[RIGHT]->color_space(),
video_decoders_[RIGHT]->color_range(),
determine_sws_flags(config))},
determine_sws_flags(fast_scaling_default_))},
display_{std::make_unique<Display>(config.display_number,
config.display_mode,
config.verbose,
config.fit_window_to_usable_bounds,
config.high_dpi_allowed,
config.use_10_bpc,
config.high_quality_input_alignment,
!fast_scaling_default_,
config.window_size,
max_width_,
max_height_,
Expand Down
1 change: 1 addition & 0 deletions video_compare.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class VideoCompare {

size_t max_width_;
size_t max_height_;
bool fast_scaling_default_;
double shortest_duration_;

std::unique_ptr<FormatConverter> format_converters_[Side::Count];
Expand Down

0 comments on commit d2fb09a

Please sign in to comment.