Coverage Report

Created: 2024-09-06 07:53

/src/libvpx/vp8/common/generic/systemdependent.c
Line
Count
Source (jump to first uncovered line)
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
37
4.91k
static int get_cpu_count(void) {
38
4.91k
  int core_count = 16;
39
40
4.91k
#if HAVE_UNISTD_H
41
4.91k
#if defined(_SC_NPROCESSORS_ONLN)
42
4.91k
  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
4.91k
  return core_count > 0 ? core_count : 1;
60
4.91k
}
61
#endif
62
63
4.91k
void vp8_machine_specific_config(VP8_COMMON *ctx) {
64
4.91k
#if CONFIG_MULTITHREAD
65
4.91k
  ctx->processor_core_count = get_cpu_count();
66
#else
67
  (void)ctx;
68
#endif /* CONFIG_MULTITHREAD */
69
4.91k
}