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_32 || ARCH_X86_64 17 #include "vpx_ports/x86.h" 18 #endif 19 #include "vp8/common/onyxc_int.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 get_cpu_count()35static int get_cpu_count() 36 { 37 int core_count = 16; 38 39 #if HAVE_UNISTD_H && !defined(__OS2__) 40 #if defined(_SC_NPROCESSORS_ONLN) 41 core_count = sysconf(_SC_NPROCESSORS_ONLN); 42 #elif defined(_SC_NPROC_ONLN) 43 core_count = sysconf(_SC_NPROC_ONLN); 44 #endif 45 #elif defined(_WIN32) 46 { 47 PGNSI pGNSI; 48 SYSTEM_INFO sysinfo; 49 50 /* Call GetNativeSystemInfo if supported or 51 * GetSystemInfo otherwise. */ 52 53 pGNSI = (PGNSI) GetProcAddress( 54 GetModuleHandle(TEXT("kernel32.dll")), "GetNativeSystemInfo"); 55 if (pGNSI != NULL) 56 pGNSI(&sysinfo); 57 else 58 GetSystemInfo(&sysinfo); 59 60 core_count = sysinfo.dwNumberOfProcessors; 61 } 62 #elif defined(__OS2__) 63 { 64 ULONG proc_id; 65 ULONG status; 66 67 core_count = 0; 68 for (proc_id = 1; ; proc_id++) 69 { 70 if (DosGetProcessorStatus(proc_id, &status)) 71 break; 72 73 if (status == PROC_ONLINE) 74 core_count++; 75 } 76 } 77 #else 78 /* other platforms */ 79 #endif 80 81 return core_count > 0 ? core_count : 1; 82 } 83 #endif 84 vp8_clear_system_state_c()85void vp8_clear_system_state_c() {}; 86 vp8_machine_specific_config(VP8_COMMON * ctx)87void vp8_machine_specific_config(VP8_COMMON *ctx) 88 { 89 #if CONFIG_MULTITHREAD 90 ctx->processor_core_count = get_cpu_count(); 91 #endif /* CONFIG_MULTITHREAD */ 92 93 #if ARCH_ARM 94 ctx->cpu_caps = arm_cpu_caps(); 95 #elif ARCH_X86_32 || ARCH_X86_64 96 ctx->cpu_caps = x86_simd_caps(); 97 #endif 98 } 99