[FFmpeg-cvslog] windows: use number of CPUs as automatic thread count

Janne Grunau git at videolan.org
Fri Dec 23 03:38:00 CET 2011


ffmpeg | branch: master | Janne Grunau <janne-libav at jannau.net> | Wed Dec 21 01:26:19 2011 +0100| [ad29ecbff0aa41adc535c118cbd956b93dab7289] | committer: Janne Grunau

windows: use number of CPUs as automatic thread count

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ad29ecbff0aa41adc535c118cbd956b93dab7289
---

 configure            |    2 ++
 libavcodec/pthread.c |    6 ++++++
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/configure b/configure
index b5ee3b5..64233cc 100755
--- a/configure
+++ b/configure
@@ -1086,6 +1086,7 @@ HAVE_LIST="
     gethrtime
     GetProcessMemoryInfo
     GetProcessTimes
+    GetSystemInfo
     getrusage
     gnu_as
     ibm_asm
@@ -2859,6 +2860,7 @@ 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 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 1800f29..bf6733f 100644
--- a/libavcodec/pthread.c
+++ b/libavcodec/pthread.c
@@ -34,6 +34,8 @@
 #if HAVE_SCHED_GETAFFINITY
 #define _GNU_SOURCE
 #include <sched.h>
+#elif HAVE_GETSYSTEMINFO
+#include <windows.h>
 #endif
 
 #include "avcodec.h"
@@ -156,6 +158,10 @@ 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;
 #endif
     av_log(avctx, AV_LOG_DEBUG, "detected %d logical cores\n", nb_cpus);
     return FFMIN(nb_cpus, MAX_AUTO_THREADS);



More information about the ffmpeg-cvslog mailing list