diff options
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | include/QuickMedia.hpp | 8 | ||||
-rw-r--r-- | src/QuickMedia.cpp | 23 |
3 files changed, 25 insertions, 7 deletions
@@ -17,6 +17,7 @@ OPTIONS: --tor Use tor. Disabled by default --use-system-mpv-config Use system mpv config instead of no config. Disabled by default --upscale-images Upscale low-resolution manga pages using waifu2x-ncnn-vulkan. Disabled by default + --upscale-images-force Upscale manga pages using waifu2x-ncnn-vulkan, no matter what the original image resolution is. Disabled by default --dir Set the start directory when using file-manager -p Change the placeholder text for dmenu EXAMPLES: diff --git a/include/QuickMedia.hpp b/include/QuickMedia.hpp index 155adc7..62cee6b 100644 --- a/include/QuickMedia.hpp +++ b/include/QuickMedia.hpp @@ -78,6 +78,12 @@ namespace QuickMedia { void save_recommendations_from_related_videos(); private: + enum class UpscaleImageAction { + NO, + LOW_RESOLUTION, + FORCE + }; + Display *disp; sf::RenderWindow window; int monitor_hz; @@ -119,7 +125,7 @@ namespace QuickMedia { bool use_tor = false; bool no_video = false; bool use_system_mpv_config = false; - bool upscale_images = false; + UpscaleImageAction upscale_image_action = UpscaleImageAction::NO; bool running = false; // TODO: Save this to config file when switching modes ImageViewMode image_view_mode = ImageViewMode::SINGLE; diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index dfd4551..8865adb 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -252,7 +252,7 @@ namespace QuickMedia { } Program::~Program() { - if(upscale_images && running) { + if(upscale_image_action != UpscaleImageAction::NO && running) { running = false; { std::unique_lock<std::mutex> lock(image_upscale_mutex); @@ -299,6 +299,7 @@ namespace QuickMedia { fprintf(stderr, " --tor Use tor. Disabled by default\n"); fprintf(stderr, " --use-system-mpv-config Use system mpv config instead of no config. Disabled by default\n"); fprintf(stderr, " --upscale-images Upscale low-resolution manga pages using waifu2x-ncnn-vulkan. Disabled by default\n"); + fprintf(stderr, " --upscale-images-force Upscale manga pages using waifu2x-ncnn-vulkan, no matter what the original image resolution is. Disabled by default\n"); fprintf(stderr, " --dir Set the start directory when using file-manager\n"); fprintf(stderr, " -p Change the placeholder text for dmenu\n"); fprintf(stderr, "EXAMPLES:\n"); @@ -381,7 +382,9 @@ namespace QuickMedia { } else if(strcmp(argv[i], "--use-system-mpv-config") == 0) { use_system_mpv_config = true; } else if(strcmp(argv[i], "--upscale-images") == 0) { - upscale_images = true; + upscale_image_action = UpscaleImageAction::LOW_RESOLUTION; + } else if(strcmp(argv[i], "--upscale-images-force") == 0) { + upscale_image_action = UpscaleImageAction::FORCE; } else if(strcmp(argv[i], "--dir") == 0) { if(i < argc - 1) { start_dir = argv[i + 1]; @@ -434,14 +437,14 @@ namespace QuickMedia { return -2; } - if(upscale_images) { + if(upscale_image_action != UpscaleImageAction::NO) { if(!current_plugin->is_manga()) { - fprintf(stderr, "Option --upscale-images is only valid for manganelo, mangatown and mangadex\n"); + fprintf(stderr, "Option --upscale-images/-upscale-images-force is only valid for manganelo, mangatown and mangadex\n"); return -2; } if(!is_program_executable_by_name("waifu2x-ncnn-vulkan")) { - fprintf(stderr, "waifu2x-ncnn-vulkan needs to be installed (and accessible from PATH environment variable) when using the --upscale-images option\n"); + fprintf(stderr, "waifu2x-ncnn-vulkan needs to be installed (and accessible from PATH environment variable) when using the --upscale-images/--upscale-images-force option\n"); return -2; } @@ -2040,7 +2043,7 @@ namespace QuickMedia { } bool rename_immediately = true; - if(upscale_images) { + if(upscale_image_action == UpscaleImageAction::LOW_RESOLUTION) { int screen_width, screen_height; get_screen_resolution(disp, &screen_width, &screen_height); @@ -2060,6 +2063,14 @@ namespace QuickMedia { } else { fprintf(stderr, "Warning: failed to upscale %s because QuickMedia failed to recognize the resolution of the image\n", image_filepath_tmp.data.c_str()); } + } else if(upscale_image_action == UpscaleImageAction::FORCE) { + rename_immediately = false; + CopyOp copy_op; + copy_op.source = image_filepath_tmp; + copy_op.destination = image_filepath; + std::unique_lock<std::mutex> lock(image_upscale_mutex); + images_to_upscale.push_back(std::move(copy_op)); + image_upscale_cv.notify_one(); } if(rename_immediately) { |