summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-01-05 12:34:34 +0100
committerDiogo Franco (Kovensky) <diogomfranco@gmail.com>2015-01-25 17:00:18 +0900
commit12c316d95e19d3135528e28683bef9da1726efcd (patch)
treeb5065c1732ac4fe7593939d4ae119df18ee85741
parentcf997ff6914a46136aead7293cfcc7c2b8682a5c (diff)
downloadmpv-12c316d95e19d3135528e28683bef9da1726efcd.tar.bz2
mpv-12c316d95e19d3135528e28683bef9da1726efcd.tar.xz
player: use libavutil API to get number of CPUs
Our own code was introduced when FFmpeg didn't provide this API (or maybe didn't even have a way to determine the CPU count). But now, av_cpu_count() is available for all FFmpeg/Libav versions we support, and there's no reason to have our own code. libavutil's code seems to be slightly more sophisticated than our's, and it's possible that the detected CPU count is different on some platforms after this change.
-rw-r--r--common/av_common.c5
-rw-r--r--old-makefile1
-rw-r--r--osdep/numcores.c66
-rw-r--r--osdep/numcores.h1
-rw-r--r--wscript_build.py1
5 files changed, 2 insertions, 72 deletions
diff --git a/common/av_common.c b/common/av_common.c
index eb357d9f05..2d976bbc8d 100644
--- a/common/av_common.c
+++ b/common/av_common.c
@@ -22,6 +22,7 @@
#include <libavutil/dict.h>
#include <libavutil/opt.h>
#include <libavutil/error.h>
+#include <libavutil/cpu.h>
#include <libavcodec/avcodec.h>
#include "common/common.h"
@@ -30,8 +31,6 @@
#include "av_common.h"
#include "codecs.h"
-#include "osdep/numcores.h"
-
int mp_lavc_set_extradata(AVCodecContext *avctx, void *ptr, int size)
{
if (size) {
@@ -129,7 +128,7 @@ void mp_set_av_packet(AVPacket *dst, struct demux_packet *mpkt, AVRational *tb)
void mp_set_avcodec_threads(struct mp_log *l, AVCodecContext *avctx, int threads)
{
if (threads == 0) {
- threads = default_thread_count();
+ threads = av_cpu_count();
if (threads < 1) {
mp_warn(l, "Could not determine thread count to use, defaulting to 1.\n");
threads = 1;
diff --git a/old-makefile b/old-makefile
index 7408b3c089..e1bd5a39a8 100644
--- a/old-makefile
+++ b/old-makefile
@@ -191,7 +191,6 @@ SOURCES = audio/audio.c \
options/parse_configfile.c \
options/path.c \
osdep/io.c \
- osdep/numcores.c \
osdep/semaphore_osx.c \
osdep/subprocess-posix.c \
osdep/terminal-unix.c \
diff --git a/osdep/numcores.c b/osdep/numcores.c
deleted file mode 100644
index 86a327e041..0000000000
--- a/osdep/numcores.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * This file is part of MPlayer.
- *
- * MPlayer is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * MPlayer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-
-#include "numcores.h"
-
-#ifdef _SC_NPROCESSORS_ONLN
-#define SCNAME _SC_NPROCESSORS_ONLN
-#elif defined _SC_NPROC_ONLN
-#define SCNAME _SC_NPROC_ONLN
-#elif defined _SC_CRAY_NCPU
-#define SCNAME _SC_CRAY_NCPU
-#endif
-
-#ifdef _WIN32
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-int default_thread_count(void)
-{
- SYSTEM_INFO info;
- GetSystemInfo(&info);
- int count = info.dwNumberOfProcessors;
- if (count > 0)
- return count;
- return -1;
-}
-
-#elif defined SCNAME
-
-int default_thread_count(void)
-{
- long nprocs = sysconf(SCNAME);
- if (nprocs < 1)
- return -1;
- return nprocs;
-}
-
-#else
-
-int default_thread_count(void)
-{
- return -2;
-}
-
-#endif
diff --git a/osdep/numcores.h b/osdep/numcores.h
deleted file mode 100644
index b999d9e275..0000000000
--- a/osdep/numcores.h
+++ /dev/null
@@ -1 +0,0 @@
-int default_thread_count(void);
diff --git a/wscript_build.py b/wscript_build.py
index 07b67ce31f..5abefa0885 100644
--- a/wscript_build.py
+++ b/wscript_build.py
@@ -375,7 +375,6 @@ def build(ctx):
## osdep
( getch2_c ),
( "osdep/io.c" ),
- ( "osdep/numcores.c"),
( "osdep/timer.c" ),
( timer_c ),
( "osdep/threads.c" ),