Line data Source code
1 : /*
2 : * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 : *
4 : * Use of this source code is governed by a BSD-style license
5 : * that can be found in the LICENSE file in the root of the source
6 : * tree. An additional intellectual property rights grant can be found
7 : * in the file PATENTS. All contributing project authors may
8 : * be found in the AUTHORS file in the root of the source tree.
9 : */
10 :
11 : #include "vpx_config.h"
12 : #include "vp8_rtcd.h"
13 : #if ARCH_ARM
14 : #include "vpx_ports/arm.h"
15 : #elif ARCH_X86 || ARCH_X86_64
16 : #include "vpx_ports/x86.h"
17 : #endif
18 : #include "vp8/common/onyxc_int.h"
19 : #include "vp8/common/systemdependent.h"
20 :
21 : #if CONFIG_MULTITHREAD
22 : #if HAVE_UNISTD_H && !defined(__OS2__)
23 : #include <unistd.h>
24 : #elif defined(_WIN32)
25 : #include <windows.h>
26 : typedef void(WINAPI *PGNSI)(LPSYSTEM_INFO);
27 : #elif defined(__OS2__)
28 : #define INCL_DOS
29 : #define INCL_DOSSPINLOCK
30 : #include <os2.h>
31 : #endif
32 : #endif
33 :
34 : #if CONFIG_MULTITHREAD
35 0 : static int get_cpu_count() {
36 0 : int core_count = 16;
37 :
38 : #if HAVE_UNISTD_H && !defined(__OS2__)
39 : #if defined(_SC_NPROCESSORS_ONLN)
40 0 : core_count = (int)sysconf(_SC_NPROCESSORS_ONLN);
41 : #elif defined(_SC_NPROC_ONLN)
42 : core_count = (int)sysconf(_SC_NPROC_ONLN);
43 : #endif
44 : #elif defined(_WIN32)
45 : {
46 : #if _WIN32_WINNT >= 0x0501
47 : SYSTEM_INFO sysinfo;
48 : GetNativeSystemInfo(&sysinfo);
49 : #else
50 : PGNSI pGNSI;
51 : SYSTEM_INFO sysinfo;
52 :
53 : /* Call GetNativeSystemInfo if supported or
54 : * GetSystemInfo otherwise. */
55 :
56 : pGNSI = (PGNSI)GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")),
57 : "GetNativeSystemInfo");
58 : if (pGNSI != NULL)
59 : pGNSI(&sysinfo);
60 : else
61 : GetSystemInfo(&sysinfo);
62 : #endif
63 :
64 : core_count = (int)sysinfo.dwNumberOfProcessors;
65 : }
66 : #elif defined(__OS2__)
67 : {
68 : ULONG proc_id;
69 : ULONG status;
70 :
71 : core_count = 0;
72 : for (proc_id = 1;; ++proc_id) {
73 : if (DosGetProcessorStatus(proc_id, &status)) break;
74 :
75 : if (status == PROC_ONLINE) core_count++;
76 : }
77 : }
78 : #else
79 : /* other platforms */
80 : #endif
81 :
82 0 : return core_count > 0 ? core_count : 1;
83 : }
84 : #endif
85 :
86 0 : void vp8_machine_specific_config(VP8_COMMON *ctx) {
87 : #if CONFIG_MULTITHREAD
88 0 : ctx->processor_core_count = get_cpu_count();
89 : #else
90 : (void)ctx;
91 : #endif /* CONFIG_MULTITHREAD */
92 :
93 : #if ARCH_ARM
94 : ctx->cpu_caps = arm_cpu_caps();
95 : #elif ARCH_X86 || ARCH_X86_64
96 0 : ctx->cpu_caps = x86_simd_caps();
97 : #endif
98 0 : }
|