diff --git a/README.md b/README.md index d221a42..18bdd76 100644 --- a/README.md +++ b/README.md @@ -49,4 +49,5 @@ Requires `libvmaf`. ``` meson build ninja -C build +ninja -C build install ``` diff --git a/VMAF/VMAF.cpp b/VMAF/VMAF.cpp index 31bd9f6..1585aa6 100644 --- a/VMAF/VMAF.cpp +++ b/VMAF/VMAF.cpp @@ -43,10 +43,10 @@ struct VMAFData { char * fmt, * logFmt, * pool; std::unique_ptr modelPath, logPath; bool psnr, ssim, ms_ssim, ci, frameSet, eof; + int numThreads, error; std::thread vmafThread; std::mutex mtx; std::condition_variable cond; - int error; }; template @@ -94,9 +94,9 @@ static int readFrame(float * VS_RESTRICT refData, float * VS_RESTRICT mainData, static void callVMAF(VMAFData * const VS_RESTRICT d) noexcept { if (d->vi->format->bytesPerSample == 1) - d->error = compute_vmaf(&d->vmafScore, d->fmt, d->vi->width, d->vi->height, readFrame, d, d->modelPath.get(), d->logPath.get(), d->logFmt, 0, 0, 0, 0, d->psnr, d->ssim, d->ms_ssim, d->pool, 0, 1, d->ci); + d->error = compute_vmaf(&d->vmafScore, d->fmt, d->vi->width, d->vi->height, readFrame, d, d->modelPath.get(), d->logPath.get(), d->logFmt, 0, 0, 0, 0, d->psnr, d->ssim, d->ms_ssim, d->pool, d->numThreads, 1, d->ci); else - d->error = compute_vmaf(&d->vmafScore, d->fmt, d->vi->width, d->vi->height, readFrame, d, d->modelPath.get(), d->logPath.get(), d->logFmt, 0, 0, 0, 0, d->psnr, d->ssim, d->ms_ssim, d->pool, 0, 1, d->ci); + d->error = compute_vmaf(&d->vmafScore, d->fmt, d->vi->width, d->vi->height, readFrame, d, d->modelPath.get(), d->logPath.get(), d->logFmt, 0, 0, 0, 0, d->psnr, d->ssim, d->ms_ssim, d->pool, d->numThreads, 1, d->ci); if (d->error) { d->mtx.lock(); @@ -122,7 +122,7 @@ static const VSFrameRef *VS_CC vmafGetFrame(int n, int activationReason, void ** d->cond.wait(lck); if (d->error) { - vsapi->setFilterError(std::string{ "VMAF: libvmaf error" }.c_str(), frameCtx); + vsapi->setFilterError("VMAF: libvmaf error", frameCtx); return nullptr; } @@ -244,6 +244,8 @@ static void VS_CC vmafCreate(const VSMap *in, VSMap *out, void *userData, VSCore else d->pool = const_cast("min"); + d->numThreads = vsapi->getCoreInfo(core)->numThreads; + d->vmafThread = std::thread{ callVMAF, d.get() }; } catch (const std::string & error) { vsapi->setError(out, ("VMAF: " + error).c_str()); diff --git a/VMAF/VMAF.vcxproj b/VMAF/VMAF.vcxproj index baedcd6..0872436 100644 --- a/VMAF/VMAF.vcxproj +++ b/VMAF/VMAF.vcxproj @@ -41,7 +41,6 @@ Level3 Column false - Fast true true @@ -49,7 +48,7 @@ true true Windows - libpthread-static.lib;libvmaf.lib;ptools.lib;%(AdditionalDependencies) + libvmaf.lib;pthreads.lib;ptools.lib;%(AdditionalDependencies) diff --git a/meson.build b/meson.build index b6fee70..bcef686 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project('VMAF', 'cpp', default_options : ['buildtype=release', 'b_ndebug=if-release', 'cpp_std=c++14'], meson_version : '>=0.48.0', - version : '2' + version : '3' ) add_project_arguments('-ffast-math', language : 'cpp')