Skip to content

Commit

Permalink
cumulative bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
IFeelBloated committed May 16, 2020
1 parent e9a8f10 commit fe114a3
Show file tree
Hide file tree
Showing 12 changed files with 392 additions and 467 deletions.
5 changes: 3 additions & 2 deletions src/DCTFFTW.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
#include "DCT.hpp"
#include "Include/Interface.hxx"

static auto &&g_fftw_plans_mutex = std::mutex{};

class DCTFFTW final :public DCTClass {
static inline auto g_fftw_plans_mutex = std::mutex{};
self(fSrc, static_cast<double *>(nullptr));
self(dctplan, static_cast<fftw_plan>(nullptr));
self(fSrcDCT, static_cast<double *>(nullptr));
Expand Down Expand Up @@ -38,7 +37,9 @@ class DCTFFTW final :public DCTClass {
auto &operator=(DCTFFTW &&) = delete;
auto &operator=(const DCTFFTW &) = delete;
~DCTFFTW() override {
g_fftw_plans_mutex.lock();
fftw_destroy_plan(dctplan);
g_fftw_plans_mutex.unlock();
fftw_free(fSrc);
fftw_free(fSrcDCT);
}
Expand Down
2 changes: 1 addition & 1 deletion src/FakeBlockData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ class FakeBlockData final {
return Vector;
}
auto GetSAD() const {
return reinterpret_cast<const float &>(Vector.sad);
return Vector.sad;
}
};
28 changes: 10 additions & 18 deletions src/MVBlockFPS.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -338,28 +338,20 @@ static const VSFrameRef *VS_CC mvblockfpsGetFrame(int32_t n, int32_t activationR
MakeSADMaskTime(ballsF, nBlkX, nBlkY, 4.0 / (ml * nBlkSizeX * nBlkSizeY), 1.0, nPel, smallMaskF, nBlkXP, time256, nBlkSizeX - nOverlapX, nBlkSizeY - nOverlapY);
MakeSADMaskTime(ballsB, nBlkX, nBlkY, 4.0 / (ml * nBlkSizeX * nBlkSizeY), 1.0, nPel, smallMaskB, nBlkXP, 256 - time256, nBlkSizeX - nOverlapX, nBlkSizeY - nOverlapY);
}
if (nBlkXP > nBlkX)
for (int j = 0; j < nBlkY; ++j) {
smallMaskF[j * nBlkXP + nBlkX] = smallMaskF[j * nBlkXP + nBlkX - 1];
smallMaskB[j * nBlkXP + nBlkX] = smallMaskB[j * nBlkXP + nBlkX - 1];
}
if (nBlkYP > nBlkY)
for (int i = 0; i < nBlkXP; ++i) {
smallMaskF[nBlkXP * nBlkY + i] = smallMaskF[nBlkXP * (nBlkY - 1) + i];
smallMaskB[nBlkXP * nBlkY + i] = smallMaskB[nBlkXP * (nBlkY - 1) + i];
}
upsizer->Resize(MaskFullYF, nPitchY, smallMaskF, nBlkXP);
upsizer->Resize(MaskFullYB, nPitchY, smallMaskB, nBlkXP);
CheckAndPadMaskSmall(smallMaskF, nBlkXP, nBlkYP, nBlkX, nBlkY);
CheckAndPadMaskSmall(smallMaskB, nBlkXP, nBlkYP, nBlkX, nBlkY);
upsizer->Resize(MaskFullYF, nPitchY, smallMaskF, nBlkXP, false);
upsizer->Resize(MaskFullYB, nPitchY, smallMaskB, nBlkXP, false);
if (nSuperModeYUV & UVPLANES) {
upsizerUV->Resize(MaskFullUVF, nPitchUV, smallMaskF, nBlkXP);
upsizerUV->Resize(MaskFullUVB, nPitchUV, smallMaskB, nBlkXP);
upsizerUV->Resize(MaskFullUVF, nPitchUV, smallMaskF, nBlkXP, false);
upsizerUV->Resize(MaskFullUVB, nPitchUV, smallMaskB, nBlkXP, false);
}
}
if (mode == 4 || mode == 5 || mode == 7 || mode == 8) {
MultMasks(smallMaskF, smallMaskB, smallMaskO, nBlkXP, nBlkYP);
upsizer->Resize(MaskOccY, nPitchY, smallMaskO, nBlkXP);
upsizer->Resize(MaskOccY, nPitchY, smallMaskO, nBlkXP, false);
if (nSuperModeYUV & UVPLANES)
upsizerUV->Resize(MaskOccUV, nPitchUV, smallMaskO, nBlkXP);
upsizerUV->Resize(MaskOccUV, nPitchUV, smallMaskO, nBlkXP, false);
}
auto pMaskFullYB = MaskFullYB;
auto pMaskFullYF = MaskFullYF;
Expand Down Expand Up @@ -938,9 +930,9 @@ static void VS_CC mvblockfpsCreate(const VSMap *in, VSMap *out, void *userData,
d.nWidthUV = d.bleh->nWidth / d.bleh->xRatioUV;
d.nPitchY = (d.nWidthP + 15) & (~15);
d.nPitchUV = (d.nWidthPUV + 15) & (~15);
d.upsizer = new SimpleResize<double>(d.nWidthP, d.nHeightP, d.nBlkXP, d.nBlkYP);
d.upsizer = new SimpleResize<double>(d.nWidthP, d.nHeightP, d.nBlkXP, d.nBlkYP, 0, 0, 0);
if (d.nSuperModeYUV & UVPLANES)
d.upsizerUV = new SimpleResize<double>(d.nWidthPUV, d.nHeightPUV, d.nBlkXP, d.nBlkYP);
d.upsizerUV = new SimpleResize<double>(d.nWidthPUV, d.nHeightPUV, d.nBlkXP, d.nBlkYP, 0, 0, 0);
if (d.bleh->nOverlapX || d.bleh->nOverlapY) {
d.OverWins = new OverlapWindows(d.bleh->nBlkSizeX, d.bleh->nBlkSizeY, d.bleh->nOverlapX, d.bleh->nOverlapY);
if (d.nSuperModeYUV & UVPLANES)
Expand Down
31 changes: 13 additions & 18 deletions src/MVFlow.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,7 @@ else if (activationReason == arAllFramesReady) {
auto VXSmallY = new int32_t[nBlkYP * nBlkXP];
auto VYSmallY = new int32_t[nBlkYP * nBlkXP];
MakeVectorSmallMasks(balls, nBlkX, nBlkY, VXSmallY, nBlkXP, VYSmallY, nBlkXP);
if (nBlkXP > nBlkX)
for (auto j = 0; j < nBlkY; ++j) {
VXSmallY[j * nBlkXP + nBlkX] = std::min(VXSmallY[j * nBlkXP + nBlkX - 1], 0);
VYSmallY[j * nBlkXP + nBlkX] = VYSmallY[j * nBlkXP + nBlkX - 1];
}
if (nBlkYP > nBlkY)
for (auto i = 0; i < nBlkXP; ++i) {
VXSmallY[nBlkXP * nBlkY + i] = VXSmallY[nBlkXP * (nBlkY - 1) + i];
VYSmallY[nBlkXP * nBlkY + i] = std::min(VYSmallY[nBlkXP * (nBlkY - 1) + i], 0);
}
CheckAndPadSmallY(VXSmallY, VYSmallY, nBlkXP, nBlkYP, nBlkX, nBlkY);
auto fieldShift = 0;
if (d->fields && nPel > 1 && ((nref - n) % 2 != 0)) {
auto src = vsapi->getFrameFilter(n, d->finest, frameCtx);
Expand Down Expand Up @@ -216,8 +207,8 @@ else if (activationReason == arAllFramesReady) {
for (auto j = 0; j < nBlkYP; ++j)
for (auto i = 0; i < nBlkXP; ++i)
VYSmallY[j * nBlkXP + i] += fieldShift;
d->upsizer->Resize(VXFullY, VPitchY, VXSmallY, nBlkXP);
d->upsizer->Resize(VYFullY, VPitchY, VYSmallY, nBlkXP);
d->upsizer->Resize(VXFullY, VPitchY, VXSmallY, nBlkXP, true);
d->upsizer->Resize(VYFullY, VPitchY, VYSmallY, nBlkXP, false);
auto nOffsetY = nRefPitches[0] * nVPadding * nPel + nHPadding * bytesPerSample * nPel;
auto nOffsetUV = nRefPitches[1] * nVPaddingUV * nPel + nHPaddingUV * bytesPerSample * nPel;
if (static_cast<FlowModes>(d->mode) == FlowModes::Shift)
Expand All @@ -232,8 +223,8 @@ else if (activationReason == arAllFramesReady) {
auto VYSmallUV = new int32_t[nBlkYP * nBlkXP];
VectorSmallMaskYToHalfUV(VXSmallY, nBlkXP, nBlkYP, VXSmallUV, xRatioUV);
VectorSmallMaskYToHalfUV(VYSmallY, nBlkXP, nBlkYP, VYSmallUV, yRatioUV);
d->upsizerUV->Resize(VXFullUV, VPitchUV, VXSmallUV, nBlkXP);
d->upsizerUV->Resize(VYFullUV, VPitchUV, VYSmallUV, nBlkXP);
d->upsizerUV->Resize(VXFullUV, VPitchUV, VXSmallUV, nBlkXP, true);
d->upsizerUV->Resize(VYFullUV, VPitchUV, VYSmallUV, nBlkXP, false);
if (static_cast<FlowModes>(d->mode) == FlowModes::Shift) {
if (d->vi->format->colorFamily == cmRGB) {
flowMemset(pDst[1], 1.f, nHeightUV * nDstPitches[1]);
Expand Down Expand Up @@ -408,8 +399,12 @@ auto CreateFlow(auto in, auto out, auto core, auto vsapi) {
delete d.bleh;
return d;
}
d.nBlkXP = (d.bleh->nBlkX * (d.bleh->nBlkSizeX - d.bleh->nOverlapX) + d.bleh->nOverlapX < d.bleh->nWidth) ? d.bleh->nBlkX + 1 : d.bleh->nBlkX;
d.nBlkYP = (d.bleh->nBlkY * (d.bleh->nBlkSizeY - d.bleh->nOverlapY) + d.bleh->nOverlapY < d.bleh->nHeight) ? d.bleh->nBlkY + 1 : d.bleh->nBlkY;
d.nBlkXP = d.bleh->nBlkX;
while (d.nBlkXP * (d.bleh->nBlkSizeX - d.bleh->nOverlapX) + d.bleh->nOverlapX < d.bleh->nWidth)
d.nBlkXP++;
d.nBlkYP = d.bleh->nBlkY;
while (d.nBlkYP * (d.bleh->nBlkSizeY - d.bleh->nOverlapY) + d.bleh->nOverlapY < d.bleh->nHeight)
d.nBlkYP++;
d.nWidthP = d.nBlkXP * (d.bleh->nBlkSizeX - d.bleh->nOverlapX) + d.bleh->nOverlapX;
d.nHeightP = d.nBlkYP * (d.bleh->nBlkSizeY - d.bleh->nOverlapY) + d.bleh->nOverlapY;
d.nWidthPUV = d.nWidthP / d.bleh->xRatioUV;
Expand All @@ -420,9 +415,9 @@ auto CreateFlow(auto in, auto out, auto core, auto vsapi) {
d.nVPaddingUV = d.bleh->nVPadding / d.bleh->yRatioUV;
d.VPitchY = (d.nWidthP + 15) & (~15);
d.VPitchUV = (d.nWidthPUV + 15) & (~15);
d.upsizer = new SimpleResize<int32_t>(d.bleh->nWidth, d.bleh->nHeight, d.bleh->nBlkX, d.bleh->nBlkY);
d.upsizer = new SimpleResize<int32_t>(d.bleh->nWidth, d.bleh->nHeight, d.bleh->nBlkX, d.bleh->nBlkY, d.bleh->nWidth, d.bleh->nHeight, d.bleh->nPel);
if (d.vi->format->colorFamily != cmGray)
d.upsizerUV = new SimpleResize<int32_t>(d.nWidthUV, d.nHeightUV, d.bleh->nBlkX, d.bleh->nBlkY);
d.upsizerUV = new SimpleResize<int32_t>(d.nWidthUV, d.nHeightUV, d.bleh->nBlkX, d.bleh->nBlkY, d.nWidthUV, d.nHeightUV, d.bleh->nPel);
if (static_cast<FlowModes>(d.mode) == FlowModes::Fetch)
d.flow_function = flowFetch;
else if (static_cast<FlowModes>(d.mode) == FlowModes::Shift)
Expand Down
20 changes: 10 additions & 10 deletions src/MVFlowBlur.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,10 @@ static const VSFrameRef *VS_CC mvflowblurGetFrame(int32_t n, int32_t activationR
MakeVectorSmallMasks(ballsF, nBlkX, nBlkY, VXSmallYF, nBlkX, VYSmallYF, nBlkX);


d->upsizer->Resize(VXFullYB, VPitchY, VXSmallYB, nBlkX);
d->upsizer->Resize(VYFullYB, VPitchY, VYSmallYB, nBlkX);
d->upsizer->Resize(VXFullYF, VPitchY, VXSmallYF, nBlkX);
d->upsizer->Resize(VYFullYF, VPitchY, VYSmallYF, nBlkX);
d->upsizer->Resize(VXFullYB, VPitchY, VXSmallYB, nBlkX, true);
d->upsizer->Resize(VYFullYB, VPitchY, VYSmallYB, nBlkX, false);
d->upsizer->Resize(VXFullYF, VPitchY, VXSmallYF, nBlkX, true);
d->upsizer->Resize(VYFullYF, VPitchY, VYSmallYF, nBlkX, false);

FlowBlur(pDst[0], nDstPitches[0], pRef[0] + nOffsetY, nRefPitches[0],
VXFullYB, VXFullYF, VYFullYB, VYFullYF, VPitchY,
Expand All @@ -322,11 +322,11 @@ static const VSFrameRef *VS_CC mvflowblurGetFrame(int32_t n, int32_t activationR
VectorSmallMaskYToHalfUV(VXSmallYF, nBlkX, nBlkY, VXSmallUVF, xRatioUV);
VectorSmallMaskYToHalfUV(VYSmallYF, nBlkX, nBlkY, VYSmallUVF, yRatioUV);

d->upsizerUV->Resize(VXFullUVB, VPitchUV, VXSmallUVB, nBlkX);
d->upsizerUV->Resize(VYFullUVB, VPitchUV, VYSmallUVB, nBlkX);
d->upsizerUV->Resize(VXFullUVB, VPitchUV, VXSmallUVB, nBlkX, true);
d->upsizerUV->Resize(VYFullUVB, VPitchUV, VYSmallUVB, nBlkX, false);

d->upsizerUV->Resize(VXFullUVF, VPitchUV, VXSmallUVF, nBlkX);
d->upsizerUV->Resize(VYFullUVF, VPitchUV, VYSmallUVF, nBlkX);
d->upsizerUV->Resize(VXFullUVF, VPitchUV, VXSmallUVF, nBlkX, true);
d->upsizerUV->Resize(VYFullUVF, VPitchUV, VYSmallUVF, nBlkX, false);


FlowBlur(pDst[1], nDstPitches[1], pRef[1] + nOffsetUV, nRefPitches[1],
Expand Down Expand Up @@ -614,9 +614,9 @@ static void VS_CC mvflowblurCreate(const VSMap *in, VSMap *out, void *userData,
d.nVPaddingUV = d.bleh->nVPadding / d.bleh->yRatioUV;
d.VPitchY = d.bleh->nWidth;
d.VPitchUV = d.nWidthUV;
d.upsizer = new SimpleResize<int32_t>(d.bleh->nWidth, d.bleh->nHeight, d.bleh->nBlkX, d.bleh->nBlkY);
d.upsizer = new SimpleResize<int32_t>(d.bleh->nWidth, d.bleh->nHeight, d.bleh->nBlkX, d.bleh->nBlkY, d.mvClipB->nWidth, d.mvClipB->nHeight, d.mvClipB->nPel);
if (d.vi->format->colorFamily != cmGray)
d.upsizerUV = new SimpleResize<int32_t>(d.nWidthUV, d.nHeightUV, d.bleh->nBlkX, d.bleh->nBlkY);
d.upsizerUV = new SimpleResize<int32_t>(d.nWidthUV, d.nHeightUV, d.bleh->nBlkX, d.bleh->nBlkY, d.nWidthUV, d.nHeightUV, d.mvClipB->nPel);
data = new MVFlowBlurData;
*data = d;
vsapi->createFilter(in, out, "FlowBlur", mvflowblurInit, mvflowblurGetFrame, mvflowblurFree, fmParallel, 0, data, core);
Expand Down
Loading

0 comments on commit fe114a3

Please sign in to comment.