mirror of
https://github.com/k4yt3x/video2x.git
synced 2026-02-04 03:22:07 +08:00
feat(realcugan): add support for Real-CUGAN ncnn Vulkan (#1268)
Signed-off-by: k4yt3x <i@k4yt3x.com>
This commit is contained in:
63
include/libvideo2x/filter_realcugan.h
Normal file
63
include/libvideo2x/filter_realcugan.h
Normal file
@@ -0,0 +1,63 @@
|
||||
#pragma once
|
||||
|
||||
extern "C" {
|
||||
#include <libavcodec/avcodec.h>
|
||||
}
|
||||
|
||||
#include "processor.h"
|
||||
#include "realcugan.h"
|
||||
|
||||
namespace video2x {
|
||||
namespace processors {
|
||||
|
||||
// FilterRealcugan class definition
|
||||
class FilterRealcugan : public Filter {
|
||||
public:
|
||||
// Constructor
|
||||
FilterRealcugan(
|
||||
int gpuid = 0,
|
||||
bool tta_mode = false,
|
||||
int scaling_factor = 4,
|
||||
int noise_level = -1,
|
||||
int num_threads = 1,
|
||||
int syncgap = 3,
|
||||
const fsutils::StringType model_name = STR("models-pro")
|
||||
);
|
||||
|
||||
// Destructor
|
||||
virtual ~FilterRealcugan() override;
|
||||
|
||||
// Initializes the filter with decoder and encoder contexts
|
||||
int init(AVCodecContext *dec_ctx, AVCodecContext *enc_ctx, AVBufferRef *hw_ctx) override;
|
||||
|
||||
// Processes an input frame and returns the processed frame
|
||||
int filter(AVFrame *in_frame, AVFrame **out_frame) override;
|
||||
|
||||
// Returns the filter's type
|
||||
ProcessorType get_processor_type() const override { return ProcessorType::RealCUGAN; }
|
||||
|
||||
// Returns the filter's output dimensions
|
||||
void get_output_dimensions(
|
||||
const ProcessorConfig &proc_cfg,
|
||||
int in_width,
|
||||
int in_height,
|
||||
int &out_width,
|
||||
int &out_height
|
||||
) const override;
|
||||
|
||||
private:
|
||||
RealCUGAN *realcugan_;
|
||||
int gpuid_;
|
||||
bool tta_mode_;
|
||||
int scaling_factor_;
|
||||
int noise_level_;
|
||||
int num_threads_;
|
||||
int syncgap_;
|
||||
const fsutils::StringType model_name_;
|
||||
AVRational in_time_base_;
|
||||
AVRational out_time_base_;
|
||||
AVPixelFormat out_pix_fmt_;
|
||||
};
|
||||
|
||||
} // namespace processors
|
||||
} // namespace video2x
|
||||
@@ -23,6 +23,7 @@ enum class ProcessorType {
|
||||
None,
|
||||
Libplacebo,
|
||||
RealESRGAN,
|
||||
RealCUGAN,
|
||||
RIFE,
|
||||
};
|
||||
|
||||
@@ -35,6 +36,13 @@ struct RealESRGANConfig {
|
||||
fsutils::StringType model_name;
|
||||
};
|
||||
|
||||
struct RealCUGANConfig {
|
||||
bool tta_mode = false;
|
||||
int num_threads = 1;
|
||||
int syncgap = 3;
|
||||
fsutils::StringType model_name;
|
||||
};
|
||||
|
||||
struct RIFEConfig {
|
||||
bool tta_mode = false;
|
||||
bool tta_temporal_mode = false;
|
||||
@@ -49,9 +57,10 @@ struct ProcessorConfig {
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
int scaling_factor = 0;
|
||||
int noise_level = -1;
|
||||
int frm_rate_mul = 0;
|
||||
float scn_det_thresh = 0.0f;
|
||||
std::variant<LibplaceboConfig, RealESRGANConfig, RIFEConfig> config;
|
||||
std::variant<LibplaceboConfig, RealESRGANConfig, RealCUGANConfig, RIFEConfig> config;
|
||||
};
|
||||
|
||||
class Processor {
|
||||
|
||||
Reference in New Issue
Block a user