michael@0: /* michael@0: * Copyright (c) 2010 The WebM project authors. All Rights Reserved. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license michael@0: * that can be found in the LICENSE file in the root of the source michael@0: * tree. An additional intellectual property rights grant can be found michael@0: * in the file PATENTS. All contributing project authors may michael@0: * be found in the AUTHORS file in the root of the source tree. michael@0: */ michael@0: michael@0: michael@0: #include "vpx_config.h" michael@0: #include "vp8_rtcd.h" michael@0: #if ARCH_ARM michael@0: #include "vpx_ports/arm.h" michael@0: #elif ARCH_X86 || ARCH_X86_64 michael@0: #include "vpx_ports/x86.h" michael@0: #endif michael@0: #include "vp8/common/onyxc_int.h" michael@0: michael@0: #if CONFIG_MULTITHREAD michael@0: #if HAVE_UNISTD_H && !defined(__OS2__) michael@0: #include michael@0: #elif defined(_WIN32) michael@0: #include michael@0: typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO); michael@0: #elif defined(__OS2__) michael@0: #define INCL_DOS michael@0: #define INCL_DOSSPINLOCK michael@0: #include michael@0: #endif michael@0: #endif michael@0: michael@0: #if CONFIG_MULTITHREAD michael@0: static int get_cpu_count() michael@0: { michael@0: int core_count = 16; michael@0: michael@0: #if HAVE_UNISTD_H && !defined(__OS2__) michael@0: #if defined(_SC_NPROCESSORS_ONLN) michael@0: core_count = sysconf(_SC_NPROCESSORS_ONLN); michael@0: #elif defined(_SC_NPROC_ONLN) michael@0: core_count = sysconf(_SC_NPROC_ONLN); michael@0: #endif michael@0: #elif defined(_WIN32) michael@0: { michael@0: PGNSI pGNSI; michael@0: SYSTEM_INFO sysinfo; michael@0: michael@0: /* Call GetNativeSystemInfo if supported or michael@0: * GetSystemInfo otherwise. */ michael@0: michael@0: pGNSI = (PGNSI) GetProcAddress( michael@0: GetModuleHandle(TEXT("kernel32.dll")), "GetNativeSystemInfo"); michael@0: if (pGNSI != NULL) michael@0: pGNSI(&sysinfo); michael@0: else michael@0: GetSystemInfo(&sysinfo); michael@0: michael@0: core_count = sysinfo.dwNumberOfProcessors; michael@0: } michael@0: #elif defined(__OS2__) michael@0: { michael@0: ULONG proc_id; michael@0: ULONG status; michael@0: michael@0: core_count = 0; michael@0: for (proc_id = 1; ; proc_id++) michael@0: { michael@0: if (DosGetProcessorStatus(proc_id, &status)) michael@0: break; michael@0: michael@0: if (status == PROC_ONLINE) michael@0: core_count++; michael@0: } michael@0: } michael@0: #else michael@0: /* other platforms */ michael@0: #endif michael@0: michael@0: return core_count > 0 ? core_count : 1; michael@0: } michael@0: #endif michael@0: michael@0: void vp8_clear_system_state_c() {}; michael@0: michael@0: void vp8_machine_specific_config(VP8_COMMON *ctx) michael@0: { michael@0: #if CONFIG_MULTITHREAD michael@0: ctx->processor_core_count = get_cpu_count(); michael@0: #endif /* CONFIG_MULTITHREAD */ michael@0: michael@0: #if ARCH_ARM michael@0: ctx->cpu_caps = arm_cpu_caps(); michael@0: #elif ARCH_X86 || ARCH_X86_64 michael@0: ctx->cpu_caps = x86_simd_caps(); michael@0: #endif michael@0: }