Skip to content

Commit

Permalink
use int for padding instead of bool
Browse files Browse the repository at this point in the history
  • Loading branch information
TNTwise committed Oct 17, 2024
1 parent f10d217 commit 9424f2a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 23 deletions.
8 changes: 4 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ int main(int argc, char** argv)

bool rife_v2 = false;
bool rife_v4 = false;
bool extra_padding = false;
int padding = 32;
if (model.find(PATHSTR("rife-v2")) != path_t::npos)
{
// fine
Expand Down Expand Up @@ -714,11 +714,11 @@ int main(int argc, char** argv)
rife_v4 = true;
if (model.find(PATHSTR("rife-v4.25")) != path_t::npos)
{
extra_padding = true;
padding = 64;
}
if (model.find(PATHSTR("rife-v4.26")) != path_t::npos)
{
extra_padding = true;
padding = 64;
}
}
else if (model.find(PATHSTR("rife-v5")) != path_t::npos)
Expand Down Expand Up @@ -876,7 +876,7 @@ int main(int argc, char** argv)
{
int num_threads = gpuid[i] == -1 ? jobs_proc[i] : 1;

rife[i] = new RIFE(gpuid[i], tta_mode, tta_temporal_mode, uhd_mode, num_threads, rife_v2, rife_v4, extra_padding);
rife[i] = new RIFE(gpuid[i], tta_mode, tta_temporal_mode, uhd_mode, num_threads, rife_v2, rife_v4, padding);

rife[i]->load(modeldir);
}
Expand Down
25 changes: 8 additions & 17 deletions src/rife.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

DEFINE_LAYER_CREATOR(Warp)

RIFE::RIFE(int gpuid, bool _tta_mode, bool _tta_temporal_mode, bool _uhd_mode, int _num_threads, bool _rife_v2, bool _rife_v4, bool _extra_padding)
RIFE::RIFE(int gpuid, bool _tta_mode, bool _tta_temporal_mode, bool _uhd_mode, int _num_threads, bool _rife_v2, bool _rife_v4, int _padding)
{
vkdev = gpuid == -1 ? 0 : ncnn::get_gpu_device(gpuid);

Expand All @@ -44,7 +44,7 @@ RIFE::RIFE(int gpuid, bool _tta_mode, bool _tta_temporal_mode, bool _uhd_mode, i
num_threads = _num_threads;
rife_v2 = _rife_v2;
rife_v4 = _rife_v4;
extra_padding = _extra_padding;
padding = _padding;
}

RIFE::~RIFE()
Expand Down Expand Up @@ -2498,13 +2498,9 @@ int RIFE::process_v4(const ncnn::Mat& in0image, const ncnn::Mat& in1image, float

// pad to 32n
int w_padded, h_padded;
if (extra_padding) {
w_padded = (w + 63) / 64 * 64;
h_padded = (h + 63) / 64 * 64;
} else {
w_padded = (w + 31) / 32 * 32;
h_padded = (h + 31) / 32 * 32;
}

w_padded = (w + padding - 1) / padding * padding;
h_padded = (h + padding) / padding * padding;

const size_t in_out_tile_elemsize = opt.use_fp16_storage ? 2u : 4u;

Expand Down Expand Up @@ -3234,14 +3230,9 @@ int RIFE::process_v4_cpu(const ncnn::Mat& in0image, const ncnn::Mat& in1image, f

// pad to 32n
int w_padded, h_padded;
if (extra_padding) {
w_padded = (w + 63) / 64 * 64;
h_padded = (h + 63) / 64 * 64;
} else {
w_padded = (w + 31) / 32 * 32;
h_padded = (h + 31) / 32 * 32;
}

w_padded = (w + padding - 1) / padding * padding;
h_padded = (h + padding) / padding * padding;

ncnn::Mat in0;
ncnn::Mat in1;
{
Expand Down
4 changes: 2 additions & 2 deletions src/rife.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class RIFE
{
public:
RIFE(int gpuid, bool tta_mode = false, bool tta_temporal_mode = false, bool uhd_mode = false, int num_threads = 1, bool rife_v2 = false, bool rife_v4 = false, bool extra_padding = false);
RIFE(int gpuid, bool tta_mode = false, bool tta_temporal_mode = false, bool uhd_mode = false, int num_threads = 1, bool rife_v2 = false, bool rife_v4 = false, int padding = 32);
~RIFE();

#if _WIN32
Expand Down Expand Up @@ -49,7 +49,7 @@ class RIFE
int num_threads;
bool rife_v2;
bool rife_v4;
bool extra_padding;
int padding;
};

#endif // RIFE_H

0 comments on commit 9424f2a

Please sign in to comment.