2024-10-08 02:29:00 +00:00
|
|
|
#ifndef LIBVIDEO2X_H
|
|
|
|
#define LIBVIDEO2X_H
|
|
|
|
|
2024-10-10 07:23:13 +00:00
|
|
|
#include <stdbool.h>
|
2024-10-08 02:29:00 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#ifdef LIBVIDEO2X_EXPORTS
|
|
|
|
#define LIBVIDEO2X_API __declspec(dllexport)
|
|
|
|
#else
|
|
|
|
#define LIBVIDEO2X_API __declspec(dllimport)
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
#define LIBVIDEO2X_API
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2024-10-10 07:23:13 +00:00
|
|
|
#include <libavcodec/avcodec.h>
|
|
|
|
#include <libavformat/avformat.h>
|
|
|
|
|
2024-10-08 02:29:00 +00:00
|
|
|
// Enum to specify filter type
|
|
|
|
enum FilterType {
|
|
|
|
FILTER_LIBPLACEBO,
|
|
|
|
FILTER_REALESRGAN
|
|
|
|
};
|
|
|
|
|
2024-10-14 02:46:59 +00:00
|
|
|
// Enum to specify log level
|
|
|
|
enum Libvideo2xLogLevel {
|
|
|
|
LIBVIDEO2X_LOG_LEVEL_TRACE,
|
|
|
|
LIBVIDEO2X_LOG_LEVEL_DEBUG,
|
|
|
|
LIBVIDEO2X_LOG_LEVEL_INFO,
|
|
|
|
LIBVIDEO2X_LOG_LEVEL_WARNING,
|
|
|
|
LIBVIDEO2X_LOG_LEVEL_ERROR,
|
|
|
|
LIBVIDEO2X_LOG_LEVEL_CRITICAL,
|
|
|
|
LIBVIDEO2X_LOG_LEVEL_OFF
|
|
|
|
};
|
|
|
|
|
2024-10-08 02:29:00 +00:00
|
|
|
// Configuration for Libplacebo filter
|
|
|
|
struct LibplaceboConfig {
|
2024-10-21 23:54:22 +00:00
|
|
|
int out_width;
|
|
|
|
int out_height;
|
2024-10-08 02:29:00 +00:00
|
|
|
const char *shader_path;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Configuration for RealESRGAN filter
|
|
|
|
struct RealESRGANConfig {
|
|
|
|
int gpuid;
|
2024-10-10 07:23:13 +00:00
|
|
|
bool tta_mode;
|
2024-10-08 02:29:00 +00:00
|
|
|
int scaling_factor;
|
|
|
|
const char *model;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Unified filter configuration
|
|
|
|
struct FilterConfig {
|
|
|
|
enum FilterType filter_type;
|
|
|
|
union {
|
|
|
|
struct LibplaceboConfig libplacebo;
|
|
|
|
struct RealESRGANConfig realesrgan;
|
|
|
|
} config;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Encoder configuration
|
|
|
|
struct EncoderConfig {
|
2024-10-21 23:54:22 +00:00
|
|
|
int out_width;
|
|
|
|
int out_height;
|
2024-10-10 07:23:13 +00:00
|
|
|
bool copy_streams;
|
2024-10-08 02:29:00 +00:00
|
|
|
enum AVCodecID codec;
|
|
|
|
enum AVPixelFormat pix_fmt;
|
|
|
|
const char *preset;
|
|
|
|
int64_t bit_rate;
|
|
|
|
float crf;
|
|
|
|
};
|
|
|
|
|
2024-10-10 07:23:13 +00:00
|
|
|
// Video processing context
|
|
|
|
struct VideoProcessingContext {
|
2024-10-08 02:29:00 +00:00
|
|
|
int64_t processed_frames;
|
|
|
|
int64_t total_frames;
|
|
|
|
time_t start_time;
|
2024-10-10 07:23:13 +00:00
|
|
|
bool pause;
|
|
|
|
bool abort;
|
|
|
|
bool completed;
|
2024-10-08 02:29:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// C-compatible process_video function
|
|
|
|
LIBVIDEO2X_API int process_video(
|
2024-10-21 23:54:22 +00:00
|
|
|
const char *in_fname,
|
|
|
|
const char *out_fname,
|
2024-10-14 02:46:59 +00:00
|
|
|
enum Libvideo2xLogLevel log_level,
|
2024-10-10 07:23:13 +00:00
|
|
|
bool benchmark,
|
|
|
|
enum AVHWDeviceType hw_device_type,
|
2024-10-08 02:29:00 +00:00
|
|
|
const struct FilterConfig *filter_config,
|
|
|
|
struct EncoderConfig *encoder_config,
|
2024-10-10 07:23:13 +00:00
|
|
|
struct VideoProcessingContext *proc_ctx
|
2024-10-08 02:29:00 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // LIBVIDEO2X_H
|