Skip to content

Commit

Permalink
Update GUI for GPU acceleration
Browse files Browse the repository at this point in the history
  • Loading branch information
TianZerL committed Apr 26, 2020
1 parent f0e8e19 commit 4e974e4
Show file tree
Hide file tree
Showing 7 changed files with 235 additions and 65 deletions.
15 changes: 15 additions & 0 deletions Anime4KCore/include/Anime4K.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@ class DLL Anime4K
uint8_t postFilters = 40,
unsigned int maxThreads = std::thread::hardware_concurrency()
);
virtual ~Anime4K();
void setArguments(
int passes = 2,
int pushColorCount = 2,
double strengthColor = 0.3,
double strengthGradient = 1.0,
double zoomFactor = 2.0,
bool fastMode = false,
bool videoMode = false,
bool PreProcessing = false,
bool postProcessing = false,
uint8_t preFilters = 40,
uint8_t postFilters = 40,
unsigned int maxThreads = std::thread::hardware_concurrency()
);
void setVideoMode(const bool flag);
void loadVideo(const std::string& srcFile);
void loadImage(const std::string& srcFile);
Expand Down
4 changes: 2 additions & 2 deletions Anime4KCore/include/Anime4KGPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include<OpenCL/opencl.h>
#else
#include<CL/cl.h>
#endif // __APPLE__
#endif // SPECIAL OS


class DLL Anime4KGPU :
Expand All @@ -28,7 +28,7 @@ class DLL Anime4KGPU :
uint8_t postFilters = 40,
unsigned int maxThreads = std::thread::hardware_concurrency()
);
~Anime4KGPU();
virtual ~Anime4KGPU();
virtual void process();
static std::pair<bool,std::string> checkGPUSupport();
protected:
Expand Down
43 changes: 41 additions & 2 deletions Anime4KCore/src/Anime4K.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ Anime4K::Anime4K(
uint8_t preFilters,
uint8_t postFilters,
unsigned int maxThreads
) :
ps(passes), pcc(pushColorCount),
) : ps(passes), pcc(pushColorCount),
sc(strengthColor), sg(strengthGradient),
zf(zoomFactor), fm(fastMode), vm(videoMode),
pre(PreProcessing), post(postProcessing), pref(preFilters),
Expand All @@ -26,6 +25,46 @@ Anime4K::Anime4K(
frameCount = totalFrameCount = fps = 0;
}

Anime4K::~Anime4K()
{
orgImg.release();
dstImg.release();
videoWriter.release();
video.release();
}

void Anime4K::setArguments(
int passes,
int pushColorCount,
double strengthColor,
double strengthGradient,
double zoomFactor,
bool fastMode,
bool videoMode,
bool PreProcessing,
bool postProcessing,
uint8_t preFilters,
uint8_t postFilters,
unsigned int maxThreads
)
{
ps = passes;
pcc = pushColorCount;
sc = strengthColor;
sg = strengthGradient;
zf = zoomFactor;
fm = fastMode;
vm = videoMode;
pre = PreProcessing;
post = postProcessing;
pref = preFilters;
postf = postFilters;
mt = maxThreads;

orgH = orgW = H = W = 0;
frameCount = totalFrameCount = fps = 0;
}

void Anime4K::setVideoMode(const bool flag)
{
vm = flag;
Expand Down
14 changes: 13 additions & 1 deletion GUI/include/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "communicator.h"
#include "Anime4K.h"
#include "Anime4KGPU.h"

#include <QMainWindow>
#include <QTranslator>
Expand Down Expand Up @@ -43,6 +44,11 @@ enum FileType
IMAGE = 0, VIDEO = 1, ERROR_TYPE=2
};

enum GPUMode
{
GPUMODE_INITIALZED = 0, GPUMODE_UNINITIALZED = 1, GPUMODE_UNSUPPORT = 3
};

class MainWindow : public QMainWindow
{
Q_OBJECT
Expand All @@ -66,7 +72,7 @@ class MainWindow : public QMainWindow
bool checkFFmpeg();
QString formatSuffixList(const QString &&type, QString str);
void initAnime4K(Anime4K *&anime4K);
void releaseAnime4K(Anime4K *&anime4K);
void releaseMainAnime4K();
FileType fileType(const QFileInfo &file);
QString getOutputPrefix();

Expand Down Expand Up @@ -125,6 +131,8 @@ private slots:

void on_pushButtonPickFolder_clicked();

void on_checkBoxGPUMode_stateChanged(int arg1);

private:
Ui::MainWindow *ui;
QTranslator *translator;
Expand All @@ -136,5 +144,9 @@ private slots:
bool ffmpeg;
unsigned int totalTaskCount;
Language currLanguage;

GPUMode GPU;
Anime4K *mainAnime4kCPU;
Anime4K *mainAnime4kGPU;
};
#endif // MAINWINDOW_H
Loading

0 comments on commit 4e974e4

Please sign in to comment.