Skip to content

Commit 5c46fec

Browse files
committed
project: Update for 4.0 merge
1 parent 3c4cc9f commit 5c46fec

File tree

8 files changed

+188
-39
lines changed

8 files changed

+188
-39
lines changed

SMP/SMP.patch

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
diff --git a/source/common/ringmem.cpp b/source/common/ringmem.cpp
2+
index cfd44e83d..14ec3d316 100644
3+
--- a/source/common/ringmem.cpp
4+
+++ b/source/common/ringmem.cpp
5+
@@ -135,6 +135,19 @@ namespace X265_NS {
6+
int32_t shrMemSize = (itemSize * itemCnt + sizeof(ShrMemCtrl) + RINGMEM_ALLIGNMENT - 1) & ~(RINGMEM_ALLIGNMENT - 1);
7+
8+
#ifdef _WIN32
9+
+# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PC_APP || WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
10+
+ WCHAR wnameBuf[MAX_PATH];
11+
+ if (MultiByteToWideChar(CP_UTF8, 0, nameBuf, -1, wnameBuf, MAX_PATH) == 0) {
12+
+ return false;
13+
+ }
14+
+ HANDLE h = OpenFileMappingFromApp(FILE_MAP_WRITE | FILE_MAP_READ, FALSE, wnameBuf);
15+
+ if (!h)
16+
+ {
17+
+ return false;
18+
+ }
19+
+
20+
+ void* pool = MapViewOfFile3FromApp(h, GetCurrentProcess(), NULL, 0, 0, 0, PAGE_READWRITE, NULL, 0);
21+
+# else
22+
HANDLE h = OpenFileMappingA(FILE_MAP_WRITE | FILE_MAP_READ, FALSE, nameBuf);
23+
if (!h)
24+
{
25+
@@ -149,6 +162,7 @@ namespace X265_NS {
26+
}
27+
28+
void *pool = MapViewOfFile(h, FILE_MAP_ALL_ACCESS, 0, 0, 0);
29+
+# endif
30+
31+
///< should not close the handle here, otherwise the OpenFileMapping would fail
32+
//CloseHandle(h);
33+
diff --git a/source/common/threadpool.cpp b/source/common/threadpool.cpp
34+
index 9c27be783..5dde29e34 100644
35+
--- a/source/common/threadpool.cpp
36+
+++ b/source/common/threadpool.cpp
37+
@@ -71,7 +71,7 @@
38+
# define strcasecmp _stricmp
39+
#endif
40+
41+
-#if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7
42+
+#ifdef USE_WIN32_AFFINITY
43+
const uint64_t m1 = 0x5555555555555555; //binary: 0101...
44+
const uint64_t m2 = 0x3333333333333333; //binary: 00110011..
45+
const uint64_t m3 = 0x0f0f0f0f0f0f0f0f; //binary: 4 zeros, 4 ones ...
46+
@@ -262,14 +262,14 @@ ThreadPool* ThreadPool::allocThreadPools(x265_param* p, int& numPools, bool isTh
47+
int numNumaNodes = X265_MIN(getNumaNodeCount(), MAX_NODE_NUM);
48+
bool bNumaSupport = false;
49+
50+
-#if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7
51+
+#ifdef USE_WIN32_AFFINITY
52+
bNumaSupport = true;
53+
#elif HAVE_LIBNUMA
54+
bNumaSupport = numa_available() >= 0;
55+
#endif
56+
57+
58+
-#if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7
59+
+#ifdef USE_WIN32_AFFINITY
60+
PGROUP_AFFINITY groupAffinityPointer = new GROUP_AFFINITY;
61+
for (int i = 0; i < numNumaNodes; i++)
62+
{
63+
@@ -475,7 +475,7 @@ bool ThreadPool::create(int numThreads, int maxProviders, uint64_t nodeMask)
64+
{
65+
X265_CHECK(numThreads <= MAX_POOL_THREADS, "a single thread pool cannot have more than MAX_POOL_THREADS threads\n");
66+
67+
-#if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7
68+
+#ifdef USE_WIN32_AFFINITY
69+
memset(&m_groupAffinity, 0, sizeof(GROUP_AFFINITY));
70+
for (int i = 0; i < getNumaNodeCount(); i++)
71+
{
72+
@@ -568,7 +568,7 @@ void ThreadPool::setCurrentThreadAffinity()
73+
74+
void ThreadPool::setThreadNodeAffinity(void *numaMask)
75+
{
76+
-#if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7
77+
+#ifdef USE_WIN32_AFFINITY
78+
UNREFERENCED_PARAMETER(numaMask);
79+
GROUP_AFFINITY groupAffinity;
80+
memset(&groupAffinity, 0, sizeof(GROUP_AFFINITY));
81+
@@ -597,7 +597,7 @@ void ThreadPool::setThreadNodeAffinity(void *numaMask)
82+
/* static */
83+
int ThreadPool::getNumaNodeCount()
84+
{
85+
-#if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7
86+
+#ifdef USE_WIN32_AFFINITY
87+
ULONG num = 1;
88+
if (GetNumaHighestNodeNumber(&num))
89+
num++;
90+
@@ -615,7 +615,7 @@ int ThreadPool::getNumaNodeCount()
91+
/* static */
92+
int ThreadPool::getCpuCount()
93+
{
94+
-#if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7
95+
+#ifdef USE_WIN32_AFFINITY
96+
enum { MAX_NODE_NUM = 127 };
97+
int cpus = 0;
98+
int numNumaNodes = X265_MIN(getNumaNodeCount(), MAX_NODE_NUM);
99+
diff --git a/source/common/threadpool.h b/source/common/threadpool.h
100+
index 867539f3a..8c92090f2 100644
101+
--- a/source/common/threadpool.h
102+
+++ b/source/common/threadpool.h
103+
@@ -44,6 +44,14 @@ static const sleepbitmap_t ALL_POOL_THREADS = (sleepbitmap_t)-1;
104+
enum { MAX_POOL_THREADS = sizeof(sleepbitmap_t) * 8 };
105+
enum { INVALID_SLICE_PRIORITY = 10 }; // a value larger than any X265_TYPE_* macro
106+
107+
+#if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7
108+
+# include <winapifamily.h>
109+
+# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
110+
+// GetNumaNodeProcessorMaskEx is not available in UWP apps
111+
+# define USE_WIN32_AFFINITY 1
112+
+# endif
113+
+#endif
114+
+
115+
// Frame level job providers. FrameEncoder and Lookahead derive from
116+
// this class and implement findJob()
117+
class JobProvider
118+
@@ -84,7 +92,7 @@ public:
119+
int m_numProviders;
120+
int m_numWorkers;
121+
void* m_numaMask; // node mask in linux, cpu mask in windows
122+
-#if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7
123+
+#ifdef USE_WIN32_AFFINITY
124+
GROUP_AFFINITY m_groupAffinity;
125+
#endif
126+
bool m_isActive;
127+
diff --git a/source/common/x86/h-ipfilter8.asm b/source/common/x86/h-ipfilter8.asm
128+
index 757efc509..53d7f2d3c 100644
129+
--- a/source/common/x86/h-ipfilter8.asm
130+
+++ b/source/common/x86/h-ipfilter8.asm
131+
@@ -125,9 +125,6 @@ const pb_8tap_hps_0, times 2 db 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8
132+
ALIGN 32
133+
interp4_hps_shuf: times 2 db 0, 1, 2, 3, 1, 2, 3, 4, 8, 9, 10, 11, 9, 10, 11, 12
134+
135+
-ALIGN 32
136+
-const interp_4tap_8x8_horiz_shuf, dd 0, 4, 1, 5, 2, 6, 3, 7
137+
-
138+
SECTION .text
139+
140+
cextern pw_1
141+
@@ -1462,6 +1459,8 @@ cglobal interp_4tap_horiz_pp_4x32, 4, 6, 5, src, srcstride, dst, dststride
142+
143+
RET
144+
145+
+ALIGN 32
146+
+const interp_4tap_8x8_horiz_shuf, dd 0, 4, 1, 5, 2, 6, 3, 7
147+
148+
%macro FILTER_H4_w6 3
149+
movu %1, [srcq - 1]

SMP/libx265.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
EXPORTS
2-
x265_encoder_open_209
2+
x265_encoder_open_212
33
x265_param_default
44
x265_param_default_preset
55
x265_param_parse
@@ -20,7 +20,7 @@ x265_encoder_get_stats
2020
x265_encoder_log
2121
x265_encoder_close
2222
x265_cleanup
23-
x265_api_get_209
23+
x265_api_get_212
2424
x265_api_query
2525
x265_encoder_intra_refresh
2626
x265_encoder_ctu_info

SMP/libx265.vcxproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</ImportGroup>
1414
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
1515
<ClCompile>
16-
<PreprocessorDefinitions>X265_VERSION=3.6;X265_ARCH_X86=1;HAVE_INT_TYPES_H=1;ENABLE_HDR10_PLUS=1;LINKED_10BIT=1;LINKED_12BIT=1;X265_NS=x265;EXPORT_C_API=1;ENABLE_ASSEMBLY=1;HIGH_BIT_DEPTH=0;X265_DEPTH=8;%(PreprocessorDefinitions)</PreprocessorDefinitions>
16+
<PreprocessorDefinitions>X265_VERSION=4.0;X265_ARCH_X86=1;HAVE_INT_TYPES_H=1;ENABLE_HDR10_PLUS=1;LINKED_10BIT=1;LINKED_12BIT=1;X265_NS=x265;EXPORT_C_API=1;ENABLE_ASSEMBLY=1;HIGH_BIT_DEPTH=0;X265_DEPTH=8;%(PreprocessorDefinitions)</PreprocessorDefinitions>
1717
<AdditionalIncludeDirectories>.\;..\source;..\source\Lib;..\source\common;..\source\encoder;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
1818
</ClCompile>
1919
<Lib>
@@ -64,7 +64,7 @@ del /f /q $(OutDir)\licenses\x265.txt
6464
</ItemDefinitionGroup>
6565
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
6666
<ClCompile>
67-
<PreprocessorDefinitions>X265_VERSION=3.6;X265_ARCH_X86=1;HAVE_INT_TYPES_H=1;ENABLE_HDR10_PLUS=1;LINKED_10BIT=1;LINKED_12BIT=1;X265_NS=x265;EXPORT_C_API=1;ENABLE_ASSEMBLY=1;HIGH_BIT_DEPTH=0;X265_DEPTH=8;X86_64=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
67+
<PreprocessorDefinitions>X265_VERSION=4.0;X265_ARCH_X86=1;HAVE_INT_TYPES_H=1;ENABLE_HDR10_PLUS=1;LINKED_10BIT=1;LINKED_12BIT=1;X265_NS=x265;EXPORT_C_API=1;ENABLE_ASSEMBLY=1;HIGH_BIT_DEPTH=0;X265_DEPTH=8;X86_64=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
6868
<AdditionalIncludeDirectories>.\;..\source;..\source\Lib;..\source\common;..\source\encoder;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
6969
</ClCompile>
7070
<Lib>
@@ -115,7 +115,7 @@ del /f /q $(OutDir)\licenses\x265.txt
115115
</ItemDefinitionGroup>
116116
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugDLL|Win32'">
117117
<ClCompile>
118-
<PreprocessorDefinitions>X265_VERSION=3.6;X265_ARCH_X86=1;HAVE_INT_TYPES_H=1;ENABLE_HDR10_PLUS=1;LINKED_10BIT=1;LINKED_12BIT=1;X265_NS=x265;EXPORT_C_API=1;ENABLE_ASSEMBLY=1;HIGH_BIT_DEPTH=0;X265_DEPTH=8;%(PreprocessorDefinitions)</PreprocessorDefinitions>
118+
<PreprocessorDefinitions>X265_VERSION=4.0;X265_ARCH_X86=1;HAVE_INT_TYPES_H=1;ENABLE_HDR10_PLUS=1;LINKED_10BIT=1;LINKED_12BIT=1;X265_NS=x265;EXPORT_C_API=1;ENABLE_ASSEMBLY=1;HIGH_BIT_DEPTH=0;X265_DEPTH=8;%(PreprocessorDefinitions)</PreprocessorDefinitions>
119119
<AdditionalIncludeDirectories>.\;..\source;..\source\Lib;..\source\common;..\source\encoder;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
120120
</ClCompile>
121121
<Link>
@@ -167,7 +167,7 @@ del /f /q $(OutDir)\licenses\x265.txt
167167
</ItemDefinitionGroup>
168168
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugDLL|x64'">
169169
<ClCompile>
170-
<PreprocessorDefinitions>X265_VERSION=3.6;X265_ARCH_X86=1;HAVE_INT_TYPES_H=1;ENABLE_HDR10_PLUS=1;LINKED_10BIT=1;LINKED_12BIT=1;X265_NS=x265;EXPORT_C_API=1;ENABLE_ASSEMBLY=1;HIGH_BIT_DEPTH=0;X265_DEPTH=8;X86_64=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
170+
<PreprocessorDefinitions>X265_VERSION=4.0;X265_ARCH_X86=1;HAVE_INT_TYPES_H=1;ENABLE_HDR10_PLUS=1;LINKED_10BIT=1;LINKED_12BIT=1;X265_NS=x265;EXPORT_C_API=1;ENABLE_ASSEMBLY=1;HIGH_BIT_DEPTH=0;X265_DEPTH=8;X86_64=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
171171
<AdditionalIncludeDirectories>.\;..\source;..\source\Lib;..\source\common;..\source\encoder;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
172172
</ClCompile>
173173
<Link>
@@ -219,7 +219,7 @@ del /f /q $(OutDir)\licenses\x265.txt
219219
</ItemDefinitionGroup>
220220
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
221221
<ClCompile>
222-
<PreprocessorDefinitions>X265_VERSION=3.6;X265_ARCH_X86=1;HAVE_INT_TYPES_H=1;ENABLE_HDR10_PLUS=1;LINKED_10BIT=1;LINKED_12BIT=1;X265_NS=x265;EXPORT_C_API=1;ENABLE_ASSEMBLY=1;HIGH_BIT_DEPTH=0;X265_DEPTH=8;%(PreprocessorDefinitions)</PreprocessorDefinitions>
222+
<PreprocessorDefinitions>X265_VERSION=4.0;X265_ARCH_X86=1;HAVE_INT_TYPES_H=1;ENABLE_HDR10_PLUS=1;LINKED_10BIT=1;LINKED_12BIT=1;X265_NS=x265;EXPORT_C_API=1;ENABLE_ASSEMBLY=1;HIGH_BIT_DEPTH=0;X265_DEPTH=8;%(PreprocessorDefinitions)</PreprocessorDefinitions>
223223
<AdditionalIncludeDirectories>.\;..\source;..\source\Lib;..\source\common;..\source\encoder;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
224224
</ClCompile>
225225
<Lib>
@@ -270,7 +270,7 @@ del /f /q $(OutDir)\licenses\x265.txt
270270
</ItemDefinitionGroup>
271271
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
272272
<ClCompile>
273-
<PreprocessorDefinitions>X265_VERSION=3.6;X265_ARCH_X86=1;HAVE_INT_TYPES_H=1;ENABLE_HDR10_PLUS=1;LINKED_10BIT=1;LINKED_12BIT=1;X265_NS=x265;EXPORT_C_API=1;ENABLE_ASSEMBLY=1;HIGH_BIT_DEPTH=0;X265_DEPTH=8;X86_64=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
273+
<PreprocessorDefinitions>X265_VERSION=4.0;X265_ARCH_X86=1;HAVE_INT_TYPES_H=1;ENABLE_HDR10_PLUS=1;LINKED_10BIT=1;LINKED_12BIT=1;X265_NS=x265;EXPORT_C_API=1;ENABLE_ASSEMBLY=1;HIGH_BIT_DEPTH=0;X265_DEPTH=8;X86_64=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
274274
<AdditionalIncludeDirectories>.\;..\source;..\source\Lib;..\source\common;..\source\encoder;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
275275
</ClCompile>
276276
<Lib>
@@ -321,7 +321,7 @@ del /f /q $(OutDir)\licenses\x265.txt
321321
</ItemDefinitionGroup>
322322
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseDLL|Win32'">
323323
<ClCompile>
324-
<PreprocessorDefinitions>X265_VERSION=3.6;X265_ARCH_X86=1;HAVE_INT_TYPES_H=1;ENABLE_HDR10_PLUS=1;LINKED_10BIT=1;LINKED_12BIT=1;X265_NS=x265;EXPORT_C_API=1;ENABLE_ASSEMBLY=1;HIGH_BIT_DEPTH=0;X265_DEPTH=8;%(PreprocessorDefinitions)</PreprocessorDefinitions>
324+
<PreprocessorDefinitions>X265_VERSION=4.0;X265_ARCH_X86=1;HAVE_INT_TYPES_H=1;ENABLE_HDR10_PLUS=1;LINKED_10BIT=1;LINKED_12BIT=1;X265_NS=x265;EXPORT_C_API=1;ENABLE_ASSEMBLY=1;HIGH_BIT_DEPTH=0;X265_DEPTH=8;%(PreprocessorDefinitions)</PreprocessorDefinitions>
325325
<AdditionalIncludeDirectories>.\;..\source;..\source\Lib;..\source\common;..\source\encoder;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
326326
</ClCompile>
327327
<Link>
@@ -373,7 +373,7 @@ del /f /q $(OutDir)\licenses\x265.txt
373373
</ItemDefinitionGroup>
374374
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseDLL|x64'">
375375
<ClCompile>
376-
<PreprocessorDefinitions>X265_VERSION=3.6;X265_ARCH_X86=1;HAVE_INT_TYPES_H=1;ENABLE_HDR10_PLUS=1;LINKED_10BIT=1;LINKED_12BIT=1;X265_NS=x265;EXPORT_C_API=1;ENABLE_ASSEMBLY=1;HIGH_BIT_DEPTH=0;X265_DEPTH=8;X86_64=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
376+
<PreprocessorDefinitions>X265_VERSION=4.0;X265_ARCH_X86=1;HAVE_INT_TYPES_H=1;ENABLE_HDR10_PLUS=1;LINKED_10BIT=1;LINKED_12BIT=1;X265_NS=x265;EXPORT_C_API=1;ENABLE_ASSEMBLY=1;HIGH_BIT_DEPTH=0;X265_DEPTH=8;X86_64=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
377377
<AdditionalIncludeDirectories>.\;..\source;..\source\Lib;..\source\common;..\source\encoder;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
378378
</ClCompile>
379379
<Link>

0 commit comments

Comments
 (0)