Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
bcc73960
Commit
bcc73960
authored
Dec 23, 2011
by
Janne Grunau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
threads: add sysconf based number of CPUs detection
Can act as fallback and should work on a couple of Unix systems.
parent
937ff3a1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
0 deletions
+9
-0
configure
configure
+2
-0
pthread.c
libavcodec/pthread.c
+7
-0
No files found.
configure
View file @
bcc73960
...
...
@@ -1138,6 +1138,7 @@ HAVE_LIST="
symver
symver_asm_label
symver_gnu_asm
sysconf
sysctl
sys_mman_h
sys_param_h
...
...
@@ -2858,6 +2859,7 @@ check_func strerror_r
check_func strptime
check_func strtok_r
check_func sched_getaffinity
check_func sysconf
check_func sysctl
check_func_headers io.h setmode
check_func_headers lzo/lzo1x.h lzo1x_999_compress
...
...
libavcodec/pthread.c
View file @
bcc73960
...
...
@@ -45,6 +45,9 @@
#include <sys/types.h>
#include <sys/sysctl.h>
#endif
#if HAVE_SYSCONF
#include <unistd.h>
#endif
#include "avcodec.h"
#include "internal.h"
...
...
@@ -177,6 +180,10 @@ static int get_logical_cpus(AVCodecContext *avctx)
ret
=
sysctl
(
mib
,
2
,
&
nb_cpus
,
&
len
,
NULL
,
0
);
if
(
ret
==
-
1
)
nb_cpus
=
0
;
#elif HAVE_SYSCONF && defined(_SC_NPROC_ONLN)
nb_cpus
=
sysconf
(
_SC_NPROC_ONLN
);
#elif HAVE_SYSCONF && defined(_SC_NPROCESSORS_ONLN)
nb_cpus
=
sysconf
(
_SC_NPROCESSORS_ONLN
);
#endif
av_log
(
avctx
,
AV_LOG_DEBUG
,
"detected %d logical cores
\n
"
,
nb_cpus
);
return
FFMIN
(
nb_cpus
,
MAX_AUTO_THREADS
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment