Skip to content

Commit

Permalink
Add mt parameter to enable / disable plane based multi-threading
Browse files Browse the repository at this point in the history
  • Loading branch information
msg7086 committed Jan 2, 2021
1 parent f7a8712 commit 1d87ff8
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/fft3d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ struct FFT3D final : Filter {
EngineParams* ep {nullptr};
FFTFunctionPointers fftfp;
int fft_threads {2};
bool mt {false};

bool crop;

Expand Down Expand Up @@ -66,7 +67,8 @@ struct FFT3D final : Filter {
Param {"r", Integer},
Param {"b", Integer},
Param {"opt", Integer},
Param {"ncpu", Integer}
Param {"ncpu", Integer},
Param {"mt", Boolean}
};
}
void Initialize(InDelegator* in, DSVideoInfo in_vi, FetchFrameFunctor* fetch_frame) override
Expand Down Expand Up @@ -163,6 +165,7 @@ struct FFT3D final : Filter {
in->Read("u", process[1]);
in->Read("v", process[2]);
}
in->Read("mt", mt);
in->Read("ncpu", fft_threads);
if (fft_threads < 1)
fft_threads = 1;
Expand Down Expand Up @@ -224,12 +227,8 @@ struct FFT3D final : Filter {
if (engine_count == 0) return src;
auto dst = src.Create(false);

#ifdef ENABLE_PAR
std::for_each_n(PAR_POLICY, reinterpret_cast<char*>(0), ep->vi.Format.Planes, [&](char&idx) {
auto core = [&](char&idx) {
int i = static_cast<int>(reinterpret_cast<intptr_t>(&idx));
#else
for (int i = 0; i < ep->vi.Format.Planes; i++) {
#endif
bool chroma = ep->vi.Format.IsFamilyYUV && i > 0 && i < 3;

if (process[i] == 3) {
Expand All @@ -249,10 +248,15 @@ struct FFT3D final : Filter {
else
copy_frame<true>(dst, src, i, chroma);
}
}
};

#ifdef ENABLE_PAR
);
if(mt)
std::for_each_n(PAR_POLICY, reinterpret_cast<char*>(0), ep->vi.Format.Planes, core);
else
#endif
for (intptr_t i = 0; i < ep->vi.Format.Planes; i++)
core(*reinterpret_cast<char*>(i));

return dst;
}
Expand Down

0 comments on commit 1d87ff8

Please sign in to comment.