FFmpeg
libavutil
loongarch
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)
28
static
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
)
34
flags
|=
AV_CPU_FLAG_LSX
;
35
if
(
flag
&
LA_HWCAP_LASX
)
36
flags
|=
AV_CPU_FLAG_LASX
;
37
38
return
flags
;
39
}
40
41
int
ff_get_cpu_flags_loongarch
(
void
)
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
51
size_t
ff_get_cpu_max_align_loongarch
(
void
)
52
{
53
int
flags
=
av_get_cpu_flags
();
54
55
if
(
flags
&
AV_CPU_FLAG_LASX
)
56
return
32;
57
if
(
flags
&
AV_CPU_FLAG_LSX
)
58
return
16;
59
60
return
8;
61
}
AT_HWCAP
#define AT_HWCAP
Definition:
cpu.c:50
AV_CPU_FLAG_LSX
#define AV_CPU_FLAG_LSX
Definition:
cpu.h:83
ff_get_cpu_max_align_loongarch
size_t ff_get_cpu_max_align_loongarch(void)
Definition:
cpu.c:51
ff_get_cpu_flags_loongarch
int ff_get_cpu_flags_loongarch(void)
Definition:
cpu.c:41
av_get_cpu_flags
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition:
cpu.c:107
LA_HWCAP_LASX
#define LA_HWCAP_LASX
Definition:
cpu.c:27
cpu_flags_getauxval
static int cpu_flags_getauxval(void)
Definition:
cpu.c:28
ff_getauxval
unsigned long ff_getauxval(unsigned long type)
Definition:
cpu.c:295
flag
int flag
Definition:
cpu.c:40
AV_CPU_FLAG_LASX
#define AV_CPU_FLAG_LASX
Definition:
cpu.h:84
LA_HWCAP_LSX
#define LA_HWCAP_LSX
Definition:
cpu.c:26
flags
#define flags(name, subs,...)
Definition:
cbs_av1.c:482
cpu.h
Generated on Mon Nov 25 2024 19:22:39 for FFmpeg by
1.8.17