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 VPX_ARCH_ARM 14 #include "vpx_ports/arm.h" 15 #elif VPX_ARCH_X86 || VPX_ARCH_X86_64 16 #include "vpx_ports/x86.h" 17 #elif VPX_ARCH_PPC 18 #include "vpx_ports/ppc.h" 19 #elif VPX_ARCH_MIPS 20 #include "vpx_ports/mips.h" 21 #elif VPX_ARCH_LOONGARCH 22 #include "vpx_ports/loongarch.h" 23 #endif 24 #include "vp8/common/onyxc_int.h" 25 #include "vp8/common/systemdependent.h" 26 27 #if CONFIG_MULTITHREAD 28 #if HAVE_UNISTD_H 29 #include <unistd.h> 30 #elif defined(_WIN32) 31 #include <windows.h> 32 typedef void(WINAPI *PGNSI)(LPSYSTEM_INFO); 33 #endif 34 #endif 35 36 #if CONFIG_MULTITHREAD get_cpu_count(void)37static int get_cpu_count(void) { 38 int core_count = 16; 39 40 #if HAVE_UNISTD_H 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 #error _WIN32_WINNT must target Windows XP or newer. 50 #endif 51 SYSTEM_INFO sysinfo; 52 GetNativeSystemInfo(&sysinfo); 53 core_count = (int)sysinfo.dwNumberOfProcessors; 54 } 55 #else 56 /* other platforms */ 57 #endif 58 59 return core_count > 0 ? core_count : 1; 60 } 61 #endif 62 vp8_machine_specific_config(VP8_COMMON * ctx)63void vp8_machine_specific_config(VP8_COMMON *ctx) { 64 #if CONFIG_MULTITHREAD 65 ctx->processor_core_count = get_cpu_count(); 66 #else 67 (void)ctx; 68 #endif /* CONFIG_MULTITHREAD */ 69 } 70