feat(rife): add support for frame interpolation and RIFE (#1244)

* feat: add RIFE files and processor/interpolator abstractions
* feat: add `rife` as processor option
* feat: add frame interpolation math except first frame
* feat: complete motion interpolation and add scene detection
* feat: improve Vulkan device validation
* fix: fix casting issues and variable names
* refactor: improve error-checking; add abstractions and factories
* refactor: improve readability of the frames processor
* docs: update changelog

Signed-off-by: k4yt3x <i@k4yt3x.com>
This commit is contained in:
K4YT3X
2024-12-01 09:55:56 +00:00
committed by GitHub
parent 2fc89e3883
commit 627f3d84a4
84 changed files with 4914 additions and 615 deletions

View File

@@ -30,13 +30,17 @@ extern "C" {
extern "C" {
#endif
// Enum to specify filter type
enum FilterType {
FILTER_LIBPLACEBO,
FILTER_REALESRGAN
enum ProcessingMode {
PROCESSING_MODE_FILTER,
PROCESSING_MODE_INTERPOLATE,
};
enum ProcessorType {
PROCESSOR_LIBPLACEBO,
PROCESSOR_REALESRGAN,
PROCESSOR_RIFE,
};
// Enum to specify log level
enum Libvideo2xLogLevel {
LIBVIDEO2X_LOG_LEVEL_TRACE,
LIBVIDEO2X_LOG_LEVEL_DEBUG,
@@ -47,26 +51,37 @@ enum Libvideo2xLogLevel {
LIBVIDEO2X_LOG_LEVEL_OFF
};
// Configuration for Libplacebo filter
struct LibplaceboConfig {
int out_width;
int out_height;
const CharType *shader_path;
};
// Configuration for RealESRGAN filter
struct RealESRGANConfig {
bool tta_mode;
int scaling_factor;
const CharType *model_name;
};
struct RIFEConfig {
bool tta_mode;
bool tta_temporal_mode;
bool uhd_mode;
int num_threads;
bool rife_v2;
bool rife_v4;
const CharType *model_name;
};
// Unified filter configuration
struct FilterConfig {
enum FilterType filter_type;
struct ProcessorConfig {
enum ProcessorType processor_type;
int width;
int height;
int scaling_factor;
int frm_rate_mul;
float scn_det_thresh;
union {
struct LibplaceboConfig libplacebo;
struct RealESRGANConfig realesrgan;
struct RIFEConfig rife;
} config;
};
@@ -140,7 +155,7 @@ LIBVIDEO2X_API int process_video(
bool benchmark,
uint32_t vk_device_index,
enum AVHWDeviceType hw_device_type,
const struct FilterConfig *filter_config,
const struct ProcessorConfig *filter_config,
struct EncoderConfig *encoder_config,
struct VideoProcessingContext *proc_ctx
);