mirror of
https://github.com/k4yt3x/video2x.git
synced 2026-02-04 03:22:07 +08:00
style: added platform-dependent type aliases for char and string
Signed-off-by: k4yt3x <i@k4yt3x.com>
This commit is contained in:
22
include/libvideo2x/char_defs.h
Normal file
22
include/libvideo2x/char_defs.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef CHAR_DEFS_H
|
||||
#define CHAR_DEFS_H
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef wchar_t CharType;
|
||||
#define STR(x) L##x
|
||||
#else
|
||||
typedef char CharType;
|
||||
#define STR(x) x
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <string>
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef std::wstring StringType;
|
||||
#else
|
||||
typedef std::string StringType;
|
||||
#endif
|
||||
|
||||
#endif // __cplusplus
|
||||
#endif // CHAR_DEFS_H
|
||||
@@ -2,11 +2,18 @@
|
||||
#define FSUTILS_H
|
||||
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
|
||||
#include "char_defs.h"
|
||||
|
||||
bool filepath_is_readable(const std::filesystem::path &path);
|
||||
|
||||
std::filesystem::path find_resource_file(const std::filesystem::path &path);
|
||||
|
||||
std::string path_to_string(const std::filesystem::path& path);
|
||||
std::string path_to_u8string(const std::filesystem::path &path);
|
||||
|
||||
StringType path_to_string_type(const std::filesystem::path &path);
|
||||
|
||||
StringType to_string_type(int value);
|
||||
|
||||
#endif // FSUTILS_H
|
||||
|
||||
@@ -5,6 +5,17 @@
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "char_defs.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef LIBVIDEO2X_EXPORTS
|
||||
#define LIBVIDEO2X_API __declspec(dllexport)
|
||||
@@ -19,9 +30,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavformat/avformat.h>
|
||||
|
||||
// Enum to specify filter type
|
||||
enum FilterType {
|
||||
FILTER_LIBPLACEBO,
|
||||
@@ -43,11 +51,7 @@ enum Libvideo2xLogLevel {
|
||||
struct LibplaceboConfig {
|
||||
int out_width;
|
||||
int out_height;
|
||||
#ifdef _WIN32
|
||||
const wchar_t *shader_path;
|
||||
#else
|
||||
const char *shader_path;
|
||||
#endif
|
||||
const CharType *shader_path;
|
||||
};
|
||||
|
||||
// Configuration for RealESRGAN filter
|
||||
@@ -55,11 +59,7 @@ struct RealESRGANConfig {
|
||||
int gpuid;
|
||||
bool tta_mode;
|
||||
int scaling_factor;
|
||||
#ifdef _WIN32
|
||||
const wchar_t *model_name;
|
||||
#else
|
||||
const char *model_name;
|
||||
#endif
|
||||
const CharType *model_name;
|
||||
};
|
||||
|
||||
// Unified filter configuration
|
||||
@@ -93,15 +93,22 @@ struct VideoProcessingContext {
|
||||
bool completed;
|
||||
};
|
||||
|
||||
// C-compatible process_video function
|
||||
/**
|
||||
* @brief Process a video file using the selected filter and encoder settings.
|
||||
*
|
||||
* @param[in] in_fname Path to the input video file
|
||||
* @param[in] out_fname Path to the output video file
|
||||
* @param[in] log_level Log level
|
||||
* @param[in] benchmark Flag to enable benchmarking mode
|
||||
* @param[in] hw_type Hardware device type
|
||||
* @param[in] filter_config Filter configurations
|
||||
* @param[in] encoder_config Encoder configurations
|
||||
* @param[in,out] proc_ctx Video processing context
|
||||
* @return int 0 on success, non-zero value on error
|
||||
*/
|
||||
LIBVIDEO2X_API int process_video(
|
||||
#ifdef _WIN32
|
||||
const wchar_t *in_fname,
|
||||
const wchar_t *out_fname,
|
||||
#else
|
||||
const char *in_fname,
|
||||
const char *out_fname,
|
||||
#endif
|
||||
const CharType *in_fname,
|
||||
const CharType *out_fname,
|
||||
enum Libvideo2xLogLevel log_level,
|
||||
bool benchmark,
|
||||
enum AVHWDeviceType hw_device_type,
|
||||
|
||||
@@ -5,6 +5,7 @@ extern "C" {
|
||||
#include <libavcodec/avcodec.h>
|
||||
}
|
||||
|
||||
#include "char_defs.h"
|
||||
#include "filter.h"
|
||||
#include "realesrgan.h"
|
||||
|
||||
@@ -15,11 +16,7 @@ class RealesrganFilter : public Filter {
|
||||
int gpuid;
|
||||
bool tta_mode;
|
||||
int scaling_factor;
|
||||
#ifdef _WIN32
|
||||
const std::wstring model_name;
|
||||
#else
|
||||
const std::string model_name;
|
||||
#endif
|
||||
const StringType model_name;
|
||||
AVRational in_time_base;
|
||||
AVRational out_time_base;
|
||||
AVPixelFormat out_pix_fmt;
|
||||
@@ -30,11 +27,7 @@ class RealesrganFilter : public Filter {
|
||||
int gpuid = 0,
|
||||
bool tta_mode = false,
|
||||
int scaling_factor = 4,
|
||||
#ifdef _WIN32
|
||||
const std::wstring model_name = L"realesr-animevideov3"
|
||||
#else
|
||||
const std::string model_name = "realesr-animevideov3"
|
||||
#endif
|
||||
const StringType model_name = STR("realesr-animevideov3")
|
||||
);
|
||||
|
||||
// Destructor
|
||||
|
||||
Reference in New Issue
Block a user