Uses the non-standard value _SC_NPROCESSORS_ONLN for sysconf() to
determine the number of CPUs.
---
configure | 2 ++
libavcodec/pthread.c | 12 ++++++++++++
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/configure b/configure
index 180578d..3871a5b 100755
--- a/configure
+++ b/configure
@@ -1136,6 +1136,7 @@ HAVE_LIST="
symver
symver_asm_label
symver_gnu_asm
+ sysconf
sys_mman_h
sys_resource_h
sys_select_h
@@ -2855,6 +2856,7 @@ check_func setrlimit
check_func strerror_r
check_func strptime
check_func strtok_r
+check_func sysconf
check_func_headers io.h setmode
check_func_headers lzo/lzo1x.h lzo1x_999_compress
check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c
index 7e03c64..ebc0514 100644
--- a/libavcodec/pthread.c
+++ b/libavcodec/pthread.c
@@ -30,6 +30,11 @@
*/
#include "config.h"
+
+#if HAVE_SYSCONF
+#include <unistd.h> /* for sysconf and _SC_NPROCESSORS_ONLN */
+#endif
+
#include "avcodec.h"
#include "internal.h"
#include "thread.h"
@@ -919,6 +924,13 @@ int ff_thread_init(AVCodecContext *avctx)
w32thread_init();
#endif
+ if (!avctx->thread_count) {
+#if HAVE_SYSCONF && defined(_SC_NPROCESSORS_ONLN)
+ avctx->thread_count = sysconf(_SC_NPROCESSORS_ONLN);
+#endif
+ av_log(avctx, AV_LOG_DEBUG, "using %d threads\n", avctx->thread_count);
+ }
+
if (avctx->codec) {
validate_thread_parameters(avctx);
--
1.7.8
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel