1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libvpx/vp8/common/generic/systemdependent.c Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,98 @@ 1.4 +/* 1.5 + * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 1.6 + * 1.7 + * Use of this source code is governed by a BSD-style license 1.8 + * that can be found in the LICENSE file in the root of the source 1.9 + * tree. An additional intellectual property rights grant can be found 1.10 + * in the file PATENTS. All contributing project authors may 1.11 + * be found in the AUTHORS file in the root of the source tree. 1.12 + */ 1.13 + 1.14 + 1.15 +#include "vpx_config.h" 1.16 +#include "vp8_rtcd.h" 1.17 +#if ARCH_ARM 1.18 +#include "vpx_ports/arm.h" 1.19 +#elif ARCH_X86 || ARCH_X86_64 1.20 +#include "vpx_ports/x86.h" 1.21 +#endif 1.22 +#include "vp8/common/onyxc_int.h" 1.23 + 1.24 +#if CONFIG_MULTITHREAD 1.25 +#if HAVE_UNISTD_H && !defined(__OS2__) 1.26 +#include <unistd.h> 1.27 +#elif defined(_WIN32) 1.28 +#include <windows.h> 1.29 +typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO); 1.30 +#elif defined(__OS2__) 1.31 +#define INCL_DOS 1.32 +#define INCL_DOSSPINLOCK 1.33 +#include <os2.h> 1.34 +#endif 1.35 +#endif 1.36 + 1.37 +#if CONFIG_MULTITHREAD 1.38 +static int get_cpu_count() 1.39 +{ 1.40 + int core_count = 16; 1.41 + 1.42 +#if HAVE_UNISTD_H && !defined(__OS2__) 1.43 +#if defined(_SC_NPROCESSORS_ONLN) 1.44 + core_count = sysconf(_SC_NPROCESSORS_ONLN); 1.45 +#elif defined(_SC_NPROC_ONLN) 1.46 + core_count = sysconf(_SC_NPROC_ONLN); 1.47 +#endif 1.48 +#elif defined(_WIN32) 1.49 + { 1.50 + PGNSI pGNSI; 1.51 + SYSTEM_INFO sysinfo; 1.52 + 1.53 + /* Call GetNativeSystemInfo if supported or 1.54 + * GetSystemInfo otherwise. */ 1.55 + 1.56 + pGNSI = (PGNSI) GetProcAddress( 1.57 + GetModuleHandle(TEXT("kernel32.dll")), "GetNativeSystemInfo"); 1.58 + if (pGNSI != NULL) 1.59 + pGNSI(&sysinfo); 1.60 + else 1.61 + GetSystemInfo(&sysinfo); 1.62 + 1.63 + core_count = sysinfo.dwNumberOfProcessors; 1.64 + } 1.65 +#elif defined(__OS2__) 1.66 + { 1.67 + ULONG proc_id; 1.68 + ULONG status; 1.69 + 1.70 + core_count = 0; 1.71 + for (proc_id = 1; ; proc_id++) 1.72 + { 1.73 + if (DosGetProcessorStatus(proc_id, &status)) 1.74 + break; 1.75 + 1.76 + if (status == PROC_ONLINE) 1.77 + core_count++; 1.78 + } 1.79 + } 1.80 +#else 1.81 + /* other platforms */ 1.82 +#endif 1.83 + 1.84 + return core_count > 0 ? core_count : 1; 1.85 +} 1.86 +#endif 1.87 + 1.88 +void vp8_clear_system_state_c() {}; 1.89 + 1.90 +void vp8_machine_specific_config(VP8_COMMON *ctx) 1.91 +{ 1.92 +#if CONFIG_MULTITHREAD 1.93 + ctx->processor_core_count = get_cpu_count(); 1.94 +#endif /* CONFIG_MULTITHREAD */ 1.95 + 1.96 +#if ARCH_ARM 1.97 + ctx->cpu_caps = arm_cpu_caps(); 1.98 +#elif ARCH_X86 || ARCH_X86_64 1.99 + ctx->cpu_caps = x86_simd_caps(); 1.100 +#endif 1.101 +}