Skip to content

Commit

Permalink
Minor optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
HolyWu committed Oct 12, 2019
1 parent c04f275 commit f1b7159
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
12 changes: 9 additions & 3 deletions VMAF/VMAF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <mutex>
#include <string>
#include <thread>
#include <type_traits>

#include <VapourSynth.h>
#include <VSHelper.h>
Expand Down Expand Up @@ -69,8 +70,13 @@ static int readFrame(float * VS_RESTRICT refData, float * VS_RESTRICT mainData,

for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
refData[x] = refp[x] / d->divisor;
mainData[x] = mainp[x] / d->divisor;
if constexpr (std::is_same_v<T, uint8_t>) {
refData[x] = refp[x];
mainData[x] = mainp[x];
} else {
refData[x] = refp[x] * d->divisor;
mainData[x] = mainp[x] * d->divisor;
}
}

refp += srcStride;
Expand Down Expand Up @@ -237,7 +243,7 @@ static void VS_CC vmafCreate(const VSMap * in, VSMap * out, void * userData, VSC

d->numThreads = vsapi->getCoreInfo(core)->numThreads;

d->divisor = 1 << (d->vi->format->bitsPerSample - 8);
d->divisor = 1.0f / (1 << (d->vi->format->bitsPerSample - 8));

d->vmafThread = std::thread{ callVMAF, d.get() };
} catch (const std::string & error) {
Expand Down
1 change: 1 addition & 0 deletions VMAF/VMAF.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<WarningLevel>Level3</WarningLevel>
<BufferSecurityCheck>false</BufferSecurityCheck>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down
4 changes: 2 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project('VMAF', 'cpp',
default_options : ['buildtype=release', 'b_ndebug=if-release', 'cpp_std=c++14'],
default_options : ['buildtype=release', 'b_ndebug=if-release', 'cpp_std=c++17'],
meson_version : '>=0.48.0',
version : '5'
version : '6'
)

add_project_arguments('-ffast-math', language : 'cpp')
Expand Down

0 comments on commit f1b7159

Please sign in to comment.