FFmpeg
Loading...
Searching...
No Matches
cpu.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Loongson Technology Corporation Limited
3 * Contributed by Shiyou Yin <yinshiyou-hf@loongson.cn>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include <stdint.h>
23#include "cpu.h"
24#include <sys/auxv.h>
25
26#define LA_HWCAP_LSX (1<<4)
27#define LA_HWCAP_LASX (1<<5)
28static int cpu_flags_getauxval(void)
29{
30 int flags = 0;
31 int flag = (int)ff_getauxval(AT_HWCAP);
32
33 if (flag & LA_HWCAP_LSX)
35 if (flag & LA_HWCAP_LASX)
37
38 return flags;
39}
40
42{
43#if defined __linux__
44 return cpu_flags_getauxval();
45#else
46 /* Assume no SIMD ASE supported */
47 return 0;
48#endif
49}
50
52{
53 int flags = av_get_cpu_flags();
54
56 return 32;
58 return 16;
59
60 return 8;
61}
#define flag(name)
Definition cbs_h264.c:60
#define flags(name, subs,...)
Definition cbs_h264.c:74
int ff_get_cpu_flags_loongarch(void)
Definition cpu.c:41
size_t ff_get_cpu_max_align_loongarch(void)
Definition cpu.c:51
unsigned long ff_getauxval(unsigned long type)
Definition cpu.c:309
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition cpu.c:109
#define AV_CPU_FLAG_LASX
Definition cpu.h:93
#define AV_CPU_FLAG_LSX
Definition cpu.h:92
#define LA_HWCAP_LASX
Definition cpu.c:27
#define LA_HWCAP_LSX
Definition cpu.c:26
static int cpu_flags_getauxval(void)
Definition cpu.c:28
#define AT_HWCAP
Definition cpu.c:50