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 12 #include "vpx_config.h" 13 #include "vp8_rtcd.h" 14 #if ARCH_ARM 15 #include "vpx_ports/arm.h" 16 #elif ARCH_X86 || ARCH_X86_64 17 #include "vpx_ports/x86.h" 18 #endif 19 #include "vp8/common/onyxc_int.h" 20 #include "vp8/common/systemdependent.h" 21 22 #if CONFIG_MULTITHREAD 23 #if HAVE_UNISTD_H && !defined(__OS2__) 24 #include <unistd.h> 25 #elif defined(_WIN32) 26 #include <windows.h> 27 typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO); 28 #elif defined(__OS2__) 29 #define INCL_DOS 30 #define INCL_DOSSPINLOCK 31 #include <os2.h> 32 #endif 33 #endif 34 35 #if CONFIG_MULTITHREAD get_cpu_count()36static int get_cpu_count() 37 { 38 int core_count = 16; 39 40 #if HAVE_UNISTD_H && !defined(__OS2__) 41 #if defined(_SC_NPROCESSORS_ONLN) 42 core_count = sysconf(_SC_NPROCESSORS_ONLN); 43 #elif defined(_SC_NPROC_ONLN) 44 core_count = 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( 59 GetModuleHandle(TEXT("kernel32.dll")), "GetNativeSystemInfo"); 60 if (pGNSI != NULL) 61 pGNSI(&sysinfo); 62 else 63 GetSystemInfo(&sysinfo); 64 #endif 65 66 core_count = 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 { 76 if (DosGetProcessorStatus(proc_id, &status)) 77 break; 78 79 if (status == PROC_ONLINE) 80 core_count++; 81 } 82 } 83 #else 84 /* other platforms */ 85 #endif 86 87 return core_count > 0 ? core_count : 1; 88 } 89 #endif 90 vp8_clear_system_state_c()91void vp8_clear_system_state_c() {}; 92 vp8_machine_specific_config(VP8_COMMON * ctx)93void vp8_machine_specific_config(VP8_COMMON *ctx) 94 { 95 #if CONFIG_MULTITHREAD 96 ctx->processor_core_count = get_cpu_count(); 97 #endif /* CONFIG_MULTITHREAD */ 98 99 #if ARCH_ARM 100 ctx->cpu_caps = arm_cpu_caps(); 101 #elif ARCH_X86 || ARCH_X86_64 102 ctx->cpu_caps = x86_simd_caps(); 103 #endif 104 } 105