Skip to content

Commit

Permalink
style(*): format source code under tools with clang-format
Browse files Browse the repository at this point in the history
Signed-off-by: k4yt3x <i@k4yt3x.com>
  • Loading branch information
k4yt3x committed Jan 14, 2025
1 parent 031c0a7 commit 54b3964
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 38 deletions.
10 changes: 5 additions & 5 deletions tools/video2x/include/argparse.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ struct Arguments {
[[nodiscard]] int parse_args(
int argc,
#ifdef _WIN32
wchar_t *argv[],
wchar_t* argv[],
#else
char *argv[],
char* argv[],
#endif
Arguments &arguments,
video2x::processors::ProcessorConfig &proc_cfg,
video2x::encoder::EncoderConfig &enc_cfg
Arguments& arguments,
video2x::processors::ProcessorConfig& proc_cfg,
video2x::encoder::EncoderConfig& enc_cfg
);
6 changes: 3 additions & 3 deletions tools/video2x/include/newline_safe_sink.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ class newline_safe_sink : public spdlog::sinks::ansicolor_stdout_sink_mt {
newline_safe_sink() = default;
~newline_safe_sink() = default;

newline_safe_sink(const newline_safe_sink &) = delete;
newline_safe_sink &operator=(const newline_safe_sink &) = delete;
newline_safe_sink(const newline_safe_sink&) = delete;
newline_safe_sink& operator=(const newline_safe_sink&) = delete;

void log(const spdlog::details::log_msg &msg);
void log(const spdlog::details::log_msg& msg);

void set_needs_newline(bool needs_newline) { needs_newline_.store(needs_newline); };
bool get_needs_newline() { return needs_newline_.load(); };
Expand Down
18 changes: 9 additions & 9 deletions tools/video2x/include/validators.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace po = boost::program_options;

template <typename T>
void validate_positive(const T &value, const std::string &option_name) {
void validate_positive(const T& value, const std::string& option_name) {
if (value < 0) {
throw po::validation_error(
po::validation_error::invalid_option_value,
Expand All @@ -17,7 +17,7 @@ void validate_positive(const T &value, const std::string &option_name) {
}

template <typename T>
void validate_min(const T &value, const std::string &option_name, const T &min) {
void validate_min(const T& value, const std::string& option_name, const T& min) {
if (value < min) {
throw po::validation_error(
po::validation_error::invalid_option_value,
Expand All @@ -28,7 +28,7 @@ void validate_min(const T &value, const std::string &option_name, const T &min)
}

template <typename T>
void validate_max(const T &value, const std::string &option_name, const T &max) {
void validate_max(const T& value, const std::string& option_name, const T& max) {
if (value > max) {
throw po::validation_error(
po::validation_error::invalid_option_value,
Expand All @@ -39,7 +39,7 @@ void validate_max(const T &value, const std::string &option_name, const T &max)
}

template <typename T>
void validate_range(const T &value, const std::string &option_name, const T &min, const T &max) {
void validate_range(const T& value, const std::string& option_name, const T& min, const T& max) {
if (value < min || value > max) {
throw po::validation_error(
po::validation_error::invalid_option_value,
Expand All @@ -51,7 +51,7 @@ void validate_range(const T &value, const std::string &option_name, const T &min
}

template <typename T>
void validate_greater_equal_one(const T &value, const std::string &option_name) {
void validate_greater_equal_one(const T& value, const std::string& option_name) {
if (value < 1) {
throw po::validation_error(
po::validation_error::invalid_option_value,
Expand All @@ -61,10 +61,10 @@ void validate_greater_equal_one(const T &value, const std::string &option_name)
}
}

void validate_anime4k_shader_name(const video2x::fsutils::StringType &shader_name);
void validate_anime4k_shader_name(const video2x::fsutils::StringType& shader_name);

void validate_realesrgan_model_name(const video2x::fsutils::StringType &model_name);
void validate_realesrgan_model_name(const video2x::fsutils::StringType& model_name);

void validate_realcugan_model_name(const video2x::fsutils::StringType &model_name);
void validate_realcugan_model_name(const video2x::fsutils::StringType& model_name);

void validate_rife_model_name(const video2x::fsutils::StringType &model_name);
void validate_rife_model_name(const video2x::fsutils::StringType& model_name);
2 changes: 1 addition & 1 deletion tools/video2x/include/vulkan_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

int list_vulkan_devices();

int get_vulkan_device_prop(uint32_t vk_device_index, VkPhysicalDeviceProperties *dev_props);
int get_vulkan_device_prop(uint32_t vk_device_index, VkPhysicalDeviceProperties* dev_props);
22 changes: 11 additions & 11 deletions tools/video2x/src/argparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
namespace po = boost::program_options;

#ifdef _WIN32
std::string wstring_to_u8string(const std::wstring &wstr) {
std::string wstring_to_u8string(const std::wstring& wstr) {
if (wstr.empty()) {
return std::string();
}
Expand All @@ -46,21 +46,21 @@ std::string wstring_to_u8string(const std::wstring &wstr) {
return converted_str;
}
#else
std::string wstring_to_u8string(const std::string &str) {
std::string wstring_to_u8string(const std::string& str) {
return str;
}
#endif

int parse_args(
int argc,
#ifdef _WIN32
wchar_t *argv[],
wchar_t* argv[],
#else
char *argv[],
char* argv[],
#endif
Arguments &arguments,
video2x::processors::ProcessorConfig &proc_cfg,
video2x::encoder::EncoderConfig &enc_cfg
Arguments& arguments,
video2x::processors::ProcessorConfig& proc_cfg,
video2x::encoder::EncoderConfig& enc_cfg
) {
try {
// clang-format off
Expand Down Expand Up @@ -310,7 +310,7 @@ int parse_args(
enc_cfg.codec = AV_CODEC_ID_H264;
if (vm.count("codec")) {
video2x::fsutils::StringType codec_str = vm["codec"].as<video2x::fsutils::StringType>();
const AVCodec *codec =
const AVCodec* codec =
avcodec_find_encoder_by_name(wstring_to_u8string(codec_str).c_str());
if (codec == nullptr) {
video2x::logger()->critical(
Expand Down Expand Up @@ -342,7 +342,7 @@ int parse_args(

// Parse extra AVOptions
if (vm.count("extra-encoder-option")) {
for (const auto &opt :
for (const auto& opt :
vm["extra-encoder-option"].as<std::vector<video2x::fsutils::StringType>>()) {
size_t eq_pos = opt.find('=');
if (eq_pos != video2x::fsutils::StringType::npos) {
Expand Down Expand Up @@ -467,10 +467,10 @@ int parse_args(
video2x::logger()->critical("Invalid processor type.");
return -1;
}
} catch (const po::error &e) {
} catch (const po::error& e) {
video2x::logger()->critical("Error parsing arguments: {}", e.what());
return -1;
} catch (const std::exception &e) {
} catch (const std::exception& e) {
video2x::logger()->critical(
"Unexpected exception caught while parsing options: {}", e.what()
);
Expand Down
2 changes: 1 addition & 1 deletion tools/video2x/src/newline_safe_sink.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "newline_safe_sink.h"

void newline_safe_sink::log(const spdlog::details::log_msg &msg) {
void newline_safe_sink::log(const spdlog::details::log_msg& msg) {
if (needs_newline_.exchange(false)) {
std::fputs("\n", stdout);
}
Expand Down
8 changes: 4 additions & 4 deletions tools/video2x/src/validators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <unordered_set>

void validate_anime4k_shader_name(const video2x::fsutils::StringType &shader_name) {
void validate_anime4k_shader_name(const video2x::fsutils::StringType& shader_name) {
static const std::unordered_set<video2x::fsutils::StringType> valid_anime4k_shaders = {
STR("anime4k-v4-a"),
STR("anime4k-v4-a+a"),
Expand All @@ -22,7 +22,7 @@ void validate_anime4k_shader_name(const video2x::fsutils::StringType &shader_nam
}
}

void validate_realesrgan_model_name(const video2x::fsutils::StringType &model_name) {
void validate_realesrgan_model_name(const video2x::fsutils::StringType& model_name) {
static const std::unordered_set<video2x::fsutils::StringType> valid_realesrgan_models = {
STR("realesrgan-plus"), STR("realesrgan-plus-anime"), STR("realesr-animevideov3")
};
Expand All @@ -36,7 +36,7 @@ void validate_realesrgan_model_name(const video2x::fsutils::StringType &model_na
}
}

void validate_realcugan_model_name(const video2x::fsutils::StringType &model_name) {
void validate_realcugan_model_name(const video2x::fsutils::StringType& model_name) {
static const std::unordered_set<video2x::fsutils::StringType> valid_realcugan_models = {
STR("models-nose"), STR("models-pro"), STR("models-se")
};
Expand All @@ -49,7 +49,7 @@ void validate_realcugan_model_name(const video2x::fsutils::StringType &model_nam
}
}

void validate_rife_model_name(const video2x::fsutils::StringType &model_name) {
void validate_rife_model_name(const video2x::fsutils::StringType& model_name) {
static const std::unordered_set<video2x::fsutils::StringType> valid_rife_models = {
STR("rife"),
STR("rife-HD"),
Expand Down
4 changes: 2 additions & 2 deletions tools/video2x/src/video2x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ std::tuple<int, int, int> calculate_time_components(int time_elapsed) {
}

#ifdef _WIN32
int wmain(int argc, wchar_t *argv[]) {
int wmain(int argc, wchar_t* argv[]) {
// Set console output code page to UTF-8
SetConsoleOutputCP(CP_UTF8);

Expand All @@ -51,7 +51,7 @@ int wmain(int argc, wchar_t *argv[]) {
console_mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
SetConsoleMode(console_handle, console_mode);
#else
int main(int argc, char **argv) {
int main(int argc, char** argv) {
#endif
// Initialize newline-safe logger with custom formatting pattern
std::shared_ptr<newline_safe_sink> logger_sink = std::make_shared<newline_safe_sink>();
Expand Down
4 changes: 2 additions & 2 deletions tools/video2x/src/vulkan_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <libvideo2x/logger_manager.h>

static int enumerate_vulkan_devices(VkInstance *instance, std::vector<VkPhysicalDevice> &devices) {
static int enumerate_vulkan_devices(VkInstance* instance, std::vector<VkPhysicalDevice>& devices) {
// Create a Vulkan instance
VkInstanceCreateInfo create_info{};
create_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
Expand Down Expand Up @@ -96,7 +96,7 @@ int list_vulkan_devices() {
return 0;
}

int get_vulkan_device_prop(uint32_t vk_device_index, VkPhysicalDeviceProperties *dev_props) {
int get_vulkan_device_prop(uint32_t vk_device_index, VkPhysicalDeviceProperties* dev_props) {
if (dev_props == nullptr) {
video2x::logger()->error("Invalid device properties pointer.");
return -1;
Expand Down

0 comments on commit 54b3964

Please sign in to comment.