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 #elif ARCH_PPC 18 #include "vpx_ports/ppc.h" 19 #endif 20 #include "vp8/common/onyxc_int.h" 21 #include "vp8/common/systemdependent.h" 22 23 #if CONFIG_MULTITHREAD 24 #if HAVE_UNISTD_H && !defined(__OS2__) 25 #include <unistd.h> 26 #elif defined(_WIN32) 27 #include <windows.h> 28 typedef void(WINAPI *PGNSI)(LPSYSTEM_INFO); 29 #elif defined(__OS2__) 30 #define INCL_DOS 31 #define INCL_DOSSPINLOCK 32 #include <os2.h> 33 #endif 34 #endif 35 36 #if CONFIG_MULTITHREAD get_cpu_count()37static int get_cpu_count() { 38 int core_count = 16; 39 40 #if HAVE_UNISTD_H && !defined(__OS2__) 41 #if defined(_SC_NPROCESSORS_ONLN) 42 core_count = (int)sysconf(_SC_NPROCESSORS_ONLN); 43 #elif defined(_SC_NPROC_ONLN) 44 core_count = (int)sysconf(_SC_NPROC_ONLN); 45 #endif 46 #elif defined(_WIN32) 47 { 48 #if _WIN32_WINNT >= 0x0501 49 SYSTEM_INFO sysinfo; 50 GetNativeSystemInfo(&sysinfo); 51 #else 52 PGNSI pGNSI; 53 SYSTEM_INFO sysinfo; 54 55 /* Call GetNativeSystemInfo if supported or 56 * GetSystemInfo otherwise. */ 57 58 pGNSI = (PGNSI)GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), 59 "GetNativeSystemInfo"); 60 if (pGNSI != NULL) 61 pGNSI(&sysinfo); 62 else 63 GetSystemInfo(&sysinfo); 64 #endif 65 66 core_count = (int)sysinfo.dwNumberOfProcessors; 67 } 68 #elif defined(__OS2__) 69 { 70 ULONG proc_id; 71 ULONG status; 72 73 core_count = 0; 74 for (proc_id = 1;; ++proc_id) { 75 if (DosGetProcessorStatus(proc_id, &status)) break; 76 77 if (status == PROC_ONLINE) core_count++; 78 } 79 } 80 #else 81 /* other platforms */ 82 #endif 83 84 return core_count > 0 ? core_count : 1; 85 } 86 #endif 87 vp8_machine_specific_config(VP8_COMMON * ctx)88void vp8_machine_specific_config(VP8_COMMON *ctx) { 89 #if CONFIG_MULTITHREAD 90 ctx->processor_core_count = get_cpu_count(); 91 #else 92 (void)ctx; 93 #endif /* CONFIG_MULTITHREAD */ 94 95 #if ARCH_ARM 96 ctx->cpu_caps = arm_cpu_caps(); 97 #elif ARCH_X86 || ARCH_X86_64 98 ctx->cpu_caps = x86_simd_caps(); 99 #elif ARCH_PPC 100 ctx->cpu_caps = ppc_simd_caps(); 101 #endif 102 } 103