LCOV - code coverage report
Current view: top level - libavutil - cpu.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 24 37 64.9 %
Date: 2017-10-18 21:45:51 Functions: 5 8 62.5 %

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

Generated by: LCOV version 1.13