2
0

cpu.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. /*
  2. * This file is part of FFmpeg.
  3. *
  4. * FFmpeg is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * FFmpeg is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with FFmpeg; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include <stddef.h>
  19. #include <stdint.h>
  20. #include <stdatomic.h>
  21. #include "attributes.h"
  22. #include "cpu.h"
  23. #include "cpu_internal.h"
  24. #include "config.h"
  25. #include "opt.h"
  26. #include "common.h"
  27. #if HAVE_SCHED_GETAFFINITY
  28. #ifndef _GNU_SOURCE
  29. # define _GNU_SOURCE
  30. #endif
  31. #include <sched.h>
  32. #endif
  33. #if HAVE_GETPROCESSAFFINITYMASK || HAVE_WINRT
  34. #include <windows.h>
  35. #endif
  36. #if HAVE_SYSCTL
  37. #if HAVE_SYS_PARAM_H
  38. #include <sys/param.h>
  39. #endif
  40. #include <sys/types.h>
  41. #include <sys/sysctl.h>
  42. #endif
  43. #if HAVE_UNISTD_H
  44. #include <unistd.h>
  45. #endif
  46. static atomic_int cpu_flags = ATOMIC_VAR_INIT(-1);
  47. static int get_cpu_flags(void)
  48. {
  49. if (ARCH_AARCH64)
  50. return ff_get_cpu_flags_aarch64();
  51. if (ARCH_ARM)
  52. return ff_get_cpu_flags_arm();
  53. if (ARCH_PPC)
  54. return ff_get_cpu_flags_ppc();
  55. if (ARCH_X86)
  56. return ff_get_cpu_flags_x86();
  57. return 0;
  58. }
  59. void av_force_cpu_flags(int arg){
  60. if (ARCH_X86 &&
  61. (arg & ( AV_CPU_FLAG_3DNOW |
  62. AV_CPU_FLAG_3DNOWEXT |
  63. AV_CPU_FLAG_MMXEXT |
  64. AV_CPU_FLAG_SSE |
  65. AV_CPU_FLAG_SSE2 |
  66. AV_CPU_FLAG_SSE2SLOW |
  67. AV_CPU_FLAG_SSE3 |
  68. AV_CPU_FLAG_SSE3SLOW |
  69. AV_CPU_FLAG_SSSE3 |
  70. AV_CPU_FLAG_SSE4 |
  71. AV_CPU_FLAG_SSE42 |
  72. AV_CPU_FLAG_AVX |
  73. AV_CPU_FLAG_AVXSLOW |
  74. AV_CPU_FLAG_XOP |
  75. AV_CPU_FLAG_FMA3 |
  76. AV_CPU_FLAG_FMA4 |
  77. AV_CPU_FLAG_AVX2 |
  78. AV_CPU_FLAG_AVX512 ))
  79. && !(arg & AV_CPU_FLAG_MMX)) {
  80. av_log(NULL, AV_LOG_WARNING, "MMX implied by specified flags\n");
  81. arg |= AV_CPU_FLAG_MMX;
  82. }
  83. atomic_store_explicit(&cpu_flags, arg, memory_order_relaxed);
  84. }
  85. int av_get_cpu_flags(void)
  86. {
  87. int flags = atomic_load_explicit(&cpu_flags, memory_order_relaxed);
  88. if (flags == -1) {
  89. flags = get_cpu_flags();
  90. atomic_store_explicit(&cpu_flags, flags, memory_order_relaxed);
  91. }
  92. return flags;
  93. }
  94. void av_set_cpu_flags_mask(int mask)
  95. {
  96. atomic_store_explicit(&cpu_flags, get_cpu_flags() & mask,
  97. memory_order_relaxed);
  98. }
  99. int av_parse_cpu_flags(const char *s)
  100. {
  101. #define CPUFLAG_MMXEXT (AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT | AV_CPU_FLAG_CMOV)
  102. #define CPUFLAG_3DNOW (AV_CPU_FLAG_3DNOW | AV_CPU_FLAG_MMX)
  103. #define CPUFLAG_3DNOWEXT (AV_CPU_FLAG_3DNOWEXT | CPUFLAG_3DNOW)
  104. #define CPUFLAG_SSE (AV_CPU_FLAG_SSE | CPUFLAG_MMXEXT)
  105. #define CPUFLAG_SSE2 (AV_CPU_FLAG_SSE2 | CPUFLAG_SSE)
  106. #define CPUFLAG_SSE2SLOW (AV_CPU_FLAG_SSE2SLOW | CPUFLAG_SSE2)
  107. #define CPUFLAG_SSE3 (AV_CPU_FLAG_SSE3 | CPUFLAG_SSE2)
  108. #define CPUFLAG_SSE3SLOW (AV_CPU_FLAG_SSE3SLOW | CPUFLAG_SSE3)
  109. #define CPUFLAG_SSSE3 (AV_CPU_FLAG_SSSE3 | CPUFLAG_SSE3)
  110. #define CPUFLAG_SSE4 (AV_CPU_FLAG_SSE4 | CPUFLAG_SSSE3)
  111. #define CPUFLAG_SSE42 (AV_CPU_FLAG_SSE42 | CPUFLAG_SSE4)
  112. #define CPUFLAG_AVX (AV_CPU_FLAG_AVX | CPUFLAG_SSE42)
  113. #define CPUFLAG_AVXSLOW (AV_CPU_FLAG_AVXSLOW | CPUFLAG_AVX)
  114. #define CPUFLAG_XOP (AV_CPU_FLAG_XOP | CPUFLAG_AVX)
  115. #define CPUFLAG_FMA3 (AV_CPU_FLAG_FMA3 | CPUFLAG_AVX)
  116. #define CPUFLAG_FMA4 (AV_CPU_FLAG_FMA4 | CPUFLAG_AVX)
  117. #define CPUFLAG_AVX2 (AV_CPU_FLAG_AVX2 | CPUFLAG_AVX)
  118. #define CPUFLAG_BMI2 (AV_CPU_FLAG_BMI2 | AV_CPU_FLAG_BMI1)
  119. #define CPUFLAG_AESNI (AV_CPU_FLAG_AESNI | CPUFLAG_SSE42)
  120. #define CPUFLAG_AVX512 (AV_CPU_FLAG_AVX512 | CPUFLAG_AVX2)
  121. static const AVOption cpuflags_opts[] = {
  122. { "flags" , NULL, 0, AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT64_MIN, INT64_MAX, .unit = "flags" },
  123. #if ARCH_PPC
  124. { "altivec" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ALTIVEC }, .unit = "flags" },
  125. #elif ARCH_X86
  126. { "mmx" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_MMX }, .unit = "flags" },
  127. { "mmxext" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_MMXEXT }, .unit = "flags" },
  128. { "sse" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE }, .unit = "flags" },
  129. { "sse2" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE2 }, .unit = "flags" },
  130. { "sse2slow", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE2SLOW }, .unit = "flags" },
  131. { "sse3" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE3 }, .unit = "flags" },
  132. { "sse3slow", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE3SLOW }, .unit = "flags" },
  133. { "ssse3" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSSE3 }, .unit = "flags" },
  134. { "atom" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ATOM }, .unit = "flags" },
  135. { "sse4.1" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE4 }, .unit = "flags" },
  136. { "sse4.2" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE42 }, .unit = "flags" },
  137. { "avx" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_AVX }, .unit = "flags" },
  138. { "avxslow" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_AVXSLOW }, .unit = "flags" },
  139. { "xop" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_XOP }, .unit = "flags" },
  140. { "fma3" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_FMA3 }, .unit = "flags" },
  141. { "fma4" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_FMA4 }, .unit = "flags" },
  142. { "avx2" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_AVX2 }, .unit = "flags" },
  143. { "bmi1" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_BMI1 }, .unit = "flags" },
  144. { "bmi2" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_BMI2 }, .unit = "flags" },
  145. { "3dnow" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_3DNOW }, .unit = "flags" },
  146. { "3dnowext", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_3DNOWEXT }, .unit = "flags" },
  147. { "cmov", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_CMOV }, .unit = "flags" },
  148. { "aesni" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_AESNI }, .unit = "flags" },
  149. { "avx512" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_AVX512 }, .unit = "flags" },
  150. #elif ARCH_ARM
  151. { "armv5te", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV5TE }, .unit = "flags" },
  152. { "armv6", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV6 }, .unit = "flags" },
  153. { "armv6t2", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV6T2 }, .unit = "flags" },
  154. { "vfp", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFP }, .unit = "flags" },
  155. { "vfp_vm", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFP_VM }, .unit = "flags" },
  156. { "vfpv3", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFPV3 }, .unit = "flags" },
  157. { "neon", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_NEON }, .unit = "flags" },
  158. #elif ARCH_AARCH64
  159. { "armv8", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV8 }, .unit = "flags" },
  160. { "neon", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_NEON }, .unit = "flags" },
  161. { "vfp", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFP }, .unit = "flags" },
  162. #endif
  163. { NULL },
  164. };
  165. static const AVClass class = {
  166. .class_name = "cpuflags",
  167. .item_name = av_default_item_name,
  168. .option = cpuflags_opts,
  169. .version = LIBAVUTIL_VERSION_INT,
  170. };
  171. int flags = 0, ret;
  172. const AVClass *pclass = &class;
  173. if ((ret = av_opt_eval_flags(&pclass, &cpuflags_opts[0], s, &flags)) < 0)
  174. return ret;
  175. return flags & INT_MAX;
  176. }
  177. int av_parse_cpu_caps(unsigned *flags, const char *s)
  178. {
  179. static const AVOption cpuflags_opts[] = {
  180. { "flags" , NULL, 0, AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT64_MIN, INT64_MAX, .unit = "flags" },
  181. #if ARCH_PPC
  182. { "altivec" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ALTIVEC }, .unit = "flags" },
  183. #elif ARCH_X86
  184. { "mmx" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_MMX }, .unit = "flags" },
  185. { "mmx2" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_MMX2 }, .unit = "flags" },
  186. { "mmxext" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_MMX2 }, .unit = "flags" },
  187. { "sse" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_SSE }, .unit = "flags" },
  188. { "sse2" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_SSE2 }, .unit = "flags" },
  189. { "sse2slow", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_SSE2SLOW }, .unit = "flags" },
  190. { "sse3" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_SSE3 }, .unit = "flags" },
  191. { "sse3slow", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_SSE3SLOW }, .unit = "flags" },
  192. { "ssse3" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_SSSE3 }, .unit = "flags" },
  193. { "atom" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ATOM }, .unit = "flags" },
  194. { "sse4.1" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_SSE4 }, .unit = "flags" },
  195. { "sse4.2" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_SSE42 }, .unit = "flags" },
  196. { "avx" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_AVX }, .unit = "flags" },
  197. { "avxslow" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_AVXSLOW }, .unit = "flags" },
  198. { "xop" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_XOP }, .unit = "flags" },
  199. { "fma3" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_FMA3 }, .unit = "flags" },
  200. { "fma4" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_FMA4 }, .unit = "flags" },
  201. { "avx2" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_AVX2 }, .unit = "flags" },
  202. { "bmi1" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_BMI1 }, .unit = "flags" },
  203. { "bmi2" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_BMI2 }, .unit = "flags" },
  204. { "3dnow" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_3DNOW }, .unit = "flags" },
  205. { "3dnowext", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_3DNOWEXT }, .unit = "flags" },
  206. { "cmov", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_CMOV }, .unit = "flags" },
  207. { "aesni", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_AESNI }, .unit = "flags" },
  208. { "avx512" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_AVX512 }, .unit = "flags" },
  209. #define CPU_FLAG_P2 AV_CPU_FLAG_CMOV | AV_CPU_FLAG_MMX
  210. #define CPU_FLAG_P3 CPU_FLAG_P2 | AV_CPU_FLAG_MMX2 | AV_CPU_FLAG_SSE
  211. #define CPU_FLAG_P4 CPU_FLAG_P3| AV_CPU_FLAG_SSE2
  212. { "pentium2", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPU_FLAG_P2 }, .unit = "flags" },
  213. { "pentium3", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPU_FLAG_P3 }, .unit = "flags" },
  214. { "pentium4", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPU_FLAG_P4 }, .unit = "flags" },
  215. #define CPU_FLAG_K62 AV_CPU_FLAG_MMX | AV_CPU_FLAG_3DNOW
  216. #define CPU_FLAG_ATHLON CPU_FLAG_K62 | AV_CPU_FLAG_CMOV | AV_CPU_FLAG_3DNOWEXT | AV_CPU_FLAG_MMX2
  217. #define CPU_FLAG_ATHLONXP CPU_FLAG_ATHLON | AV_CPU_FLAG_SSE
  218. #define CPU_FLAG_K8 CPU_FLAG_ATHLONXP | AV_CPU_FLAG_SSE2
  219. { "k6", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_MMX }, .unit = "flags" },
  220. { "k62", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPU_FLAG_K62 }, .unit = "flags" },
  221. { "athlon", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPU_FLAG_ATHLON }, .unit = "flags" },
  222. { "athlonxp", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPU_FLAG_ATHLONXP }, .unit = "flags" },
  223. { "k8", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPU_FLAG_K8 }, .unit = "flags" },
  224. #elif ARCH_ARM
  225. { "armv5te", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV5TE }, .unit = "flags" },
  226. { "armv6", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV6 }, .unit = "flags" },
  227. { "armv6t2", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV6T2 }, .unit = "flags" },
  228. { "vfp", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFP }, .unit = "flags" },
  229. { "vfp_vm", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFP_VM }, .unit = "flags" },
  230. { "vfpv3", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFPV3 }, .unit = "flags" },
  231. { "neon", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_NEON }, .unit = "flags" },
  232. { "setend", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_SETEND }, .unit = "flags" },
  233. #elif ARCH_AARCH64
  234. { "armv8", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV8 }, .unit = "flags" },
  235. { "neon", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_NEON }, .unit = "flags" },
  236. { "vfp", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFP }, .unit = "flags" },
  237. #endif
  238. { NULL },
  239. };
  240. static const AVClass class = {
  241. .class_name = "cpuflags",
  242. .item_name = av_default_item_name,
  243. .option = cpuflags_opts,
  244. .version = LIBAVUTIL_VERSION_INT,
  245. };
  246. const AVClass *pclass = &class;
  247. return av_opt_eval_flags(&pclass, &cpuflags_opts[0], s, flags);
  248. }
  249. int av_cpu_count(void)
  250. {
  251. static volatile int printed;
  252. int nb_cpus = 1;
  253. #if HAVE_WINRT
  254. SYSTEM_INFO sysinfo;
  255. #endif
  256. #if HAVE_SCHED_GETAFFINITY && defined(CPU_COUNT)
  257. cpu_set_t cpuset;
  258. CPU_ZERO(&cpuset);
  259. if (!sched_getaffinity(0, sizeof(cpuset), &cpuset))
  260. nb_cpus = CPU_COUNT(&cpuset);
  261. #elif HAVE_GETPROCESSAFFINITYMASK
  262. DWORD_PTR proc_aff, sys_aff;
  263. if (GetProcessAffinityMask(GetCurrentProcess(), &proc_aff, &sys_aff))
  264. nb_cpus = av_popcount64(proc_aff);
  265. #elif HAVE_SYSCTL && defined(HW_NCPU)
  266. int mib[2] = { CTL_HW, HW_NCPU };
  267. size_t len = sizeof(nb_cpus);
  268. if (sysctl(mib, 2, &nb_cpus, &len, NULL, 0) == -1)
  269. nb_cpus = 0;
  270. #elif HAVE_SYSCONF && defined(_SC_NPROC_ONLN)
  271. nb_cpus = sysconf(_SC_NPROC_ONLN);
  272. #elif HAVE_SYSCONF && defined(_SC_NPROCESSORS_ONLN)
  273. nb_cpus = sysconf(_SC_NPROCESSORS_ONLN);
  274. #elif HAVE_WINRT
  275. GetNativeSystemInfo(&sysinfo);
  276. nb_cpus = sysinfo.dwNumberOfProcessors;
  277. #endif
  278. if (!printed) {
  279. av_log(NULL, AV_LOG_DEBUG, "detected %d logical cores\n", nb_cpus);
  280. printed = 1;
  281. }
  282. return nb_cpus;
  283. }
  284. size_t av_cpu_max_align(void)
  285. {
  286. if (ARCH_AARCH64)
  287. return ff_get_cpu_max_align_aarch64();
  288. if (ARCH_ARM)
  289. return ff_get_cpu_max_align_arm();
  290. if (ARCH_PPC)
  291. return ff_get_cpu_max_align_ppc();
  292. if (ARCH_X86)
  293. return ff_get_cpu_max_align_x86();
  294. return 8;
  295. }