aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/pthread.c
diff options
context:
space:
mode:
authorDaniel Verkamp <daniel@drv.nu>2012-01-01 23:54:40 +0000
committerJanne Grunau <janne-libav@jannau.net>2012-01-03 14:25:57 +0100
commit02e8f4272c99f745eb201622c07b0613a8cd22ae (patch)
treee3e57f242501a0e6f6716fac1706c8ff882a3976 /libavcodec/pthread.c
parentb73ec0547317fec56a72cda068180f71e12e8f20 (diff)
downloadffmpeg-02e8f4272c99f745eb201622c07b0613a8cd22ae.tar.gz
win32: detect number of CPUs using affinity
Signed-off-by: Janne Grunau <janne-libav@jannau.net>
Diffstat (limited to 'libavcodec/pthread.c')
-rw-r--r--libavcodec/pthread.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c
index 58c5fcd638..2159a2572d 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);