[FFmpeg-cvslog] win32: detect number of CPUs using affinity
Daniel Verkamp
git at videolan.org
Wed Jan 4 01:39:32 CET 2012
ffmpeg | branch: master | Daniel Verkamp <daniel at drv.nu> | Sun Jan 1 23:54:40 2012 +0000| [02e8f4272c99f745eb201622c07b0613a8cd22ae] | committer: Janne Grunau
win32: detect number of CPUs using affinity
Signed-off-by: Janne Grunau <janne-libav at jannau.net>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=02e8f4272c99f745eb201622c07b0613a8cd22ae
---
configure | 4 ++--
libavcodec/pthread.c | 11 ++++++-----
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/configure b/configure
index b7f0acd..481f0ea 100755
--- a/configure
+++ b/configure
@@ -1084,9 +1084,9 @@ HAVE_LIST="
fork
getaddrinfo
gethrtime
+ GetProcessAffinityMask
GetProcessMemoryInfo
GetProcessTimes
- GetSystemInfo
getrusage
gnu_as
ibm_asm
@@ -2864,8 +2864,8 @@ check_func sysctl
check_func_headers io.h setmode
check_func_headers lzo/lzo1x.h lzo1x_999_compress
check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
+check_func_headers windows.h GetProcessAffinityMask
check_func_headers windows.h GetProcessTimes
-check_func_headers windows.h GetSystemInfo
check_func_headers windows.h MapViewOfFile
check_func_headers windows.h VirtualAlloc
diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c
index 58c5fcd..2159a25 100644
--- a/libavcodec/pthread.c
+++ b/libavcodec/pthread.c
@@ -35,7 +35,7 @@
#define _GNU_SOURCE
#include <sched.h>
#endif
-#if HAVE_GETSYSTEMINFO
+#if HAVE_GETPROCESSAFFINITYMASK
#include <windows.h>
#endif
#if HAVE_SYSCTL
@@ -169,10 +169,11 @@ static int get_logical_cpus(AVCodecContext *avctx)
if (!ret) {
nb_cpus = CPU_COUNT(&cpuset);
}
-#elif HAVE_GETSYSTEMINFO
- SYSTEM_INFO sysinfo;
- GetSystemInfo(&sysinfo);
- nb_cpus = sysinfo.dwNumberOfProcessors;
+#elif HAVE_GETPROCESSAFFINITYMASK
+ DWORD_PTR proc_aff, sys_aff;
+ ret = GetProcessAffinityMask(GetCurrentProcess(), &proc_aff, &sys_aff);
+ if (ret)
+ nb_cpus = av_popcount64(proc_aff);
#elif HAVE_SYSCTL && defined(HW_NCPU)
int mib[2] = { CTL_HW, HW_NCPU };
size_t len = sizeof(nb_cpus);
More information about the ffmpeg-cvslog
mailing list