Skip to content

Commit

Permalink
vpp-nlmeansは32bitでは非対応にする。
Browse files Browse the repository at this point in the history
原因不明のコンパイルエラーのため。
  • Loading branch information
rigaya committed May 1, 2024
1 parent 5ab07f4 commit a9304e5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion NVEncC_Options.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -2205,7 +2205,7 @@ Strong noise reduction filter.
```
### --vpp-nlmeans [<param1>=<value1>[,<param2>=<value2>]...]
Non local means noise reduction filter.
Non local means noise reduction filter. Only supported in 64bit binary.
- **Parameters**
- sigma=<float> (default=0.005, 0.0 -)
Expand Down
2 changes: 1 addition & 1 deletion NVEncC_Options.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -2262,7 +2262,7 @@ yadifによるインタレ解除を行う。
```
### --vpp-nlmeans [<param1>=<value1>[,<param2>=<value2>]...]
Non local meansを用いたノイズ除去フィルタ。
Non local meansを用いたノイズ除去フィルタ。Windowsでは64bit版のみに対応。
- **パラメータ**
- sigma=<float> (default=0.005, 0.0 -)
Expand Down
14 changes: 14 additions & 0 deletions NVEncCore/NVEncFilterDenoiseNLMeans.cu
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ enum RGYFilterDenoiseNLMeansTmpBufIdx {
TMP_TOTAL,
};

#if ENABLE_VPP_NLMEANS

template<typename Type, int bit_depth>
__device__ __inline__ float8 calc_sqdiff(Type val0, float8 val1) {
float8 val0_1 = (float8)val0 - val1;
Expand Down Expand Up @@ -808,6 +810,8 @@ RGY_ERR NVEncFilterDenoiseNLMeans::denoiseFrame(RGYFrameInfo *pOutputFrame, cons
return RGY_ERR_NONE;
}

#endif //ENABLE_VPP_NLMEANS

NVEncFilterDenoiseNLMeans::NVEncFilterDenoiseNLMeans() : m_tmpBuf() {
m_name = _T("nlmeans");
}
Expand All @@ -817,6 +821,7 @@ NVEncFilterDenoiseNLMeans::~NVEncFilterDenoiseNLMeans() {
}

RGY_ERR NVEncFilterDenoiseNLMeans::init(shared_ptr<NVEncFilterParam> pParam, shared_ptr<RGYLog> pPrintMes) {
#if ENABLE_VPP_NLMEANS
RGY_ERR sts = RGY_ERR_NONE;
m_pLog = pPrintMes;
auto prm = std::dynamic_pointer_cast<NVEncFilterParamDenoiseNLMeans>(pParam);
Expand Down Expand Up @@ -921,13 +926,18 @@ RGY_ERR NVEncFilterDenoiseNLMeans::init(shared_ptr<NVEncFilterParam> pParam, sha
setFilterInfo(pParam->print());
m_param = pParam;
return sts;
#else
AddMessage(RGY_LOG_ERROR, _T("nlmeans not compiled in this build.\n"));
return RGY_ERR_UNSUPPORTED;
#endif //ENABLE_VPP_NLMEANS
}

tstring NVEncFilterParamDenoiseNLMeans::print() const {
return nlmeans.print();
}

RGY_ERR NVEncFilterDenoiseNLMeans::run_filter(const RGYFrameInfo *pInputFrame, RGYFrameInfo **ppOutputFrames, int *pOutputFrameNum, cudaStream_t stream) {
#if ENABLE_VPP_NLMEANS
RGY_ERR sts = RGY_ERR_NONE;

if (pInputFrame->ptr[0] == nullptr) {
Expand Down Expand Up @@ -960,6 +970,10 @@ RGY_ERR NVEncFilterDenoiseNLMeans::run_filter(const RGYFrameInfo *pInputFrame, R
return sts;
}
return sts;
#else
AddMessage(RGY_LOG_ERROR, _T("nlmeans not compiled in this build.\n"));
return RGY_ERR_UNSUPPORTED;
#endif
}

void NVEncFilterDenoiseNLMeans::close() {
Expand Down
8 changes: 8 additions & 0 deletions NVEncCore/NVEncFilterDenoiseNLMeans.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
#include "rgy_prm.h"
#include <array>

#if (defined(WIN32) || defined(WIN64)) && defined(_M_IX86)
#define ENABLE_VPP_NLMEANS 0
#else
#define ENABLE_VPP_NLMEANS 1
#endif

// dxdyのペアを何並列で同時計算するか
static const int RGY_NLMEANS_DXDY_STEP = 8;

Expand All @@ -53,13 +59,15 @@ class NVEncFilterDenoiseNLMeans : public NVEncFilter {
virtual ~NVEncFilterDenoiseNLMeans();
virtual RGY_ERR init(shared_ptr<NVEncFilterParam> pParam, shared_ptr<RGYLog> pPrintMes) override;
protected:
#if ENABLE_VPP_NLMEANS
RGY_ERR denoisePlane(
RGYFrameInfo *pOutputPlane,
RGYFrameInfo *pTmpUPlane, RGYFrameInfo *pTmpVPlane,
RGYFrameInfo *pTmpIWPlane,
const RGYFrameInfo *pInputPlane,
cudaStream_t stream);
RGY_ERR denoiseFrame(RGYFrameInfo *pOutputFrame, const RGYFrameInfo *pInputFrame, cudaStream_t stream);
#endif
virtual RGY_ERR run_filter(const RGYFrameInfo *pInputFrame, RGYFrameInfo **ppOutputFrames, int *pOutputFrameNum, cudaStream_t stream) override;
virtual void close() override;
std::array<std::unique_ptr<CUFrameBuf>, 2 + 1 + RGY_NLMEANS_DXDY_STEP> m_tmpBuf;
Expand Down

0 comments on commit a9304e5

Please sign in to comment.