This commit is contained in:
2025-08-27 15:09:05 +09:00
parent 57961d84de
commit a13f66d917
9896 changed files with 2193048 additions and 730 deletions
+8
View File
@@ -0,0 +1,8 @@
OBJS += aarch64/cpu.o \
aarch64/float_dsp_init.o \
aarch64/tx_float_init.o \
NEON-OBJS += aarch64/float_dsp_neon.o \
aarch64/tx_float_neon.o \
SVE-OBJS += aarch64/cpu_sve.o \
+278
View File
@@ -0,0 +1,278 @@
/*
* Copyright (c) 2008 Mans Rullgard <mans@mansr.com>
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#ifdef __ELF__
# define ELF
#else
# define ELF #
#endif
#if HAVE_AS_FUNC
# define FUNC
#else
# define FUNC #
#endif
#ifndef __has_feature
# define __has_feature(x) 0
#endif
#if HAVE_AS_ARCH_DIRECTIVE
.arch AS_ARCH_LEVEL
#endif
#if HAVE_AS_ARCHEXT_DOTPROD_DIRECTIVE
#define ENABLE_DOTPROD .arch_extension dotprod
#define DISABLE_DOTPROD .arch_extension nodotprod
#else
#define ENABLE_DOTPROD
#define DISABLE_DOTPROD
#endif
#if HAVE_AS_ARCHEXT_I8MM_DIRECTIVE
#define ENABLE_I8MM .arch_extension i8mm
#define DISABLE_I8MM .arch_extension noi8mm
#else
#define ENABLE_I8MM
#define DISABLE_I8MM
#endif
#if HAVE_AS_ARCHEXT_SVE_DIRECTIVE
#define ENABLE_SVE .arch_extension sve
#define DISABLE_SVE .arch_extension nosve
#else
#define ENABLE_SVE
#define DISABLE_SVE
#endif
#if HAVE_AS_ARCHEXT_SVE2_DIRECTIVE
#define ENABLE_SVE2 .arch_extension sve2
#define DISABLE_SVE2 .arch_extension nosve2
#else
#define ENABLE_SVE2
#define DISABLE_SVE2
#endif
DISABLE_DOTPROD
DISABLE_I8MM
DISABLE_SVE
DISABLE_SVE2
/* Support macros for
* - Armv8.3-A Pointer Authentication and
* - Armv8.5-A Branch Target Identification
* features which require emitting a .note.gnu.property section with the
* appropriate architecture-dependent feature bits set.
*
* |AARCH64_SIGN_LINK_REGISTER| and |AARCH64_VALIDATE_LINK_REGISTER| expand to
* PACIxSP and AUTIxSP, respectively. |AARCH64_SIGN_LINK_REGISTER| should be
* used immediately before saving the LR register (x30) to the stack.
* |AARCH64_VALIDATE_LINK_REGISTER| should be used immediately after restoring
* it. Note |AARCH64_SIGN_LINK_REGISTER|'s modifications to LR must be undone
* with |AARCH64_VALIDATE_LINK_REGISTER| before RET. The SP register must also
* have the same value at the two points. For example:
*
* .global f
* f:
* AARCH64_SIGN_LINK_REGISTER
* stp x29, x30, [sp, #-96]!
* mov x29, sp
* ...
* ldp x29, x30, [sp], #96
* AARCH64_VALIDATE_LINK_REGISTER
* ret
*
* |AARCH64_VALID_CALL_TARGET| expands to BTI 'c'. Either it, or
* |AARCH64_SIGN_LINK_REGISTER|, must be used at every point that may be an
* indirect call target. In particular, all symbols exported from a file must
* begin with one of these macros. For example, a leaf function that does not
* save LR can instead use |AARCH64_VALID_CALL_TARGET|:
*
* .globl return_zero
* return_zero:
* AARCH64_VALID_CALL_TARGET
* mov x0, #0
* ret
*
* A non-leaf function which does not immediately save LR may need both macros
* because |AARCH64_SIGN_LINK_REGISTER| appears late. For example, the function
* may jump to an alternate implementation before setting up the stack:
*
* .globl with_early_jump
* with_early_jump:
* AARCH64_VALID_CALL_TARGET
* cmp x0, #128
* b.lt .Lwith_early_jump_128
* AARCH64_SIGN_LINK_REGISTER
* stp x29, x30, [sp, #-96]!
* mov x29, sp
* ...
* ldp x29, x30, [sp], #96
* AARCH64_VALIDATE_LINK_REGISTER
* ret
*
* .Lwith_early_jump_128:
* ...
* ret
*
* These annotations are only required with indirect calls. Private symbols that
* are only the target of direct calls do not require annotations. Also note
* that |AARCH64_VALID_CALL_TARGET| is only valid for indirect calls (BLR), not
* indirect jumps (BR). Indirect jumps in assembly are supported through
* |AARCH64_VALID_JUMP_TARGET|. Landing Pads which shall serve for jumps and
* calls can be created using |AARCH64_VALID_JUMP_CALL_TARGET|.
*
* Although not necessary, it is safe to use these macros in 32-bit ARM
* assembly. This may be used to simplify dual 32-bit and 64-bit files.
*
* References:
* - "ELF for the Arm® 64-bit Architecture"
* https: *github.com/ARM-software/abi-aa/blob/master/aaelf64/aaelf64.rst
* - "Providing protection for complex software"
* https://developer.arm.com/architectures/learn-the-architecture/providing-protection-for-complex-software
*/
#if defined(__ARM_FEATURE_BTI_DEFAULT) && (__ARM_FEATURE_BTI_DEFAULT == 1)
# define GNU_PROPERTY_AARCH64_BTI (1 << 0) // Has BTI
# define AARCH64_VALID_CALL_TARGET hint #34 // BTI 'c'
# define AARCH64_VALID_JUMP_TARGET hint #38 // BTI 'j'
#else
# define GNU_PROPERTY_AARCH64_BTI 0 // No BTI
# define AARCH64_VALID_CALL_TARGET
# define AARCH64_VALID_JUMP_TARGET
#endif
#if defined(__ARM_FEATURE_PAC_DEFAULT)
# if ((__ARM_FEATURE_PAC_DEFAULT & (1 << 0)) != 0) // authentication using key A
# define AARCH64_SIGN_LINK_REGISTER paciasp
# define AARCH64_VALIDATE_LINK_REGISTER autiasp
# elif ((__ARM_FEATURE_PAC_DEFAULT & (1 << 1)) != 0) // authentication using key B
# define AARCH64_SIGN_LINK_REGISTER pacibsp
# define AARCH64_VALIDATE_LINK_REGISTER autibsp
# else
# error Pointer authentication defines no valid key!
# endif
# if ((__ARM_FEATURE_PAC_DEFAULT & (1 << 2)) != 0)
# error Authentication of leaf functions is enabled but not supported in FFmpeg!
# endif
# define GNU_PROPERTY_AARCH64_PAC (1 << 1)
#else
# define GNU_PROPERTY_AARCH64_PAC 0
# define AARCH64_SIGN_LINK_REGISTER
# define AARCH64_VALIDATE_LINK_REGISTER
#endif
#if (GNU_PROPERTY_AARCH64_BTI != 0 || GNU_PROPERTY_AARCH64_PAC != 0) && defined(__ELF__)
.pushsection .note.gnu.property, "a"
.balign 8
.long 4
.long 0x10
.long 0x5
.asciz "GNU"
.long 0xc0000000 /* GNU_PROPERTY_AARCH64_FEATURE_1_AND */
.long 4
.long (GNU_PROPERTY_AARCH64_BTI | GNU_PROPERTY_AARCH64_PAC)
.long 0
.popsection
#endif
.macro function name, export=0, align=4
.macro endfunc
ELF .size \name, . - \name
FUNC .endfunc
.purgem endfunc
.endm
.text
.align \align
.if \export
.global EXTERN_ASM\name
ELF .type EXTERN_ASM\name, %function
FUNC .func EXTERN_ASM\name
EXTERN_ASM\name:
AARCH64_VALID_CALL_TARGET
.else
ELF .type \name, %function
FUNC .func \name
\name:
.endif
.endm
.macro const name, align=4, relocate=0
.macro endconst
ELF .size \name, . - \name
.purgem endconst
.endm
#if HAVE_SECTION_DATA_REL_RO
.if \relocate
.section .data.rel.ro
.else
.section .rodata
.endif
#elif defined(_WIN32)
.section .rdata
#elif !defined(__MACH__)
.section .rodata
#else
.const_data
#endif
.align \align
\name:
.endm
.macro movrel rd, val, offset=0
#if CONFIG_PIC && defined(__APPLE__)
.if \offset < 0
adrp \rd, \val@PAGE
add \rd, \rd, \val@PAGEOFF
sub \rd, \rd, -(\offset)
.else
adrp \rd, \val+(\offset)@PAGE
add \rd, \rd, \val+(\offset)@PAGEOFF
.endif
#elif CONFIG_PIC && defined(_WIN32)
.if \offset < 0
adrp \rd, \val
add \rd, \rd, :lo12:\val
sub \rd, \rd, -(\offset)
.else
adrp \rd, \val+(\offset)
add \rd, \rd, :lo12:\val+(\offset)
.endif
#elif CONFIG_PIC
# if __has_feature(hwaddress_sanitizer)
adrp \rd, :pg_hi21_nc:\val+(\offset)
# else
adrp \rd, \val+(\offset)
# endif
add \rd, \rd, :lo12:\val+(\offset)
#else
ldr \rd, =\val+\offset
#endif
.endm
#define GLUE(a, b) a ## b
#define JOIN(a, b) GLUE(a, b)
#define X(s) JOIN(EXTERN_ASM, s)
#define x18 do_not_use_x18
#define w18 do_not_use_w18
+179
View File
@@ -0,0 +1,179 @@
/*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/cpu.h"
#include "libavutil/cpu_internal.h"
#include "config.h"
#if HAVE_GETAUXVAL || HAVE_ELF_AUX_INFO
#include <stdint.h>
#include <sys/auxv.h>
#define HWCAP_AARCH64_ASIMDDP (1 << 20)
#define HWCAP_AARCH64_SVE (1 << 22)
#define HWCAP2_AARCH64_SVE2 (1 << 1)
#define HWCAP2_AARCH64_I8MM (1 << 13)
static int detect_flags(void)
{
int flags = 0;
unsigned long hwcap = ff_getauxval(AT_HWCAP);
unsigned long hwcap2 = ff_getauxval(AT_HWCAP2);
if (hwcap & HWCAP_AARCH64_ASIMDDP)
flags |= AV_CPU_FLAG_DOTPROD;
if (hwcap & HWCAP_AARCH64_SVE)
flags |= AV_CPU_FLAG_SVE;
if (hwcap2 & HWCAP2_AARCH64_SVE2)
flags |= AV_CPU_FLAG_SVE2;
if (hwcap2 & HWCAP2_AARCH64_I8MM)
flags |= AV_CPU_FLAG_I8MM;
return flags;
}
#elif defined(__APPLE__) && HAVE_SYSCTLBYNAME
#include <sys/sysctl.h>
static int have_feature(const char *feature) {
uint32_t value = 0;
size_t size = sizeof(value);
if (!sysctlbyname(feature, &value, &size, NULL, 0))
return value;
return 0;
}
static int detect_flags(void)
{
int flags = 0;
if (have_feature("hw.optional.arm.FEAT_DotProd"))
flags |= AV_CPU_FLAG_DOTPROD;
if (have_feature("hw.optional.arm.FEAT_I8MM"))
flags |= AV_CPU_FLAG_I8MM;
return flags;
}
#elif defined(__OpenBSD__)
#include <machine/armreg.h>
#include <machine/cpu.h>
#include <sys/types.h>
#include <sys/sysctl.h>
static int detect_flags(void)
{
int flags = 0;
#ifdef CPU_ID_AA64ISAR0
int mib[2];
uint64_t isar0;
uint64_t isar1;
size_t len;
mib[0] = CTL_MACHDEP;
mib[1] = CPU_ID_AA64ISAR0;
len = sizeof(isar0);
if (sysctl(mib, 2, &isar0, &len, NULL, 0) != -1) {
if (ID_AA64ISAR0_DP(isar0) >= ID_AA64ISAR0_DP_IMPL)
flags |= AV_CPU_FLAG_DOTPROD;
}
mib[0] = CTL_MACHDEP;
mib[1] = CPU_ID_AA64ISAR1;
len = sizeof(isar1);
if (sysctl(mib, 2, &isar1, &len, NULL, 0) != -1) {
#ifdef ID_AA64ISAR1_I8MM_IMPL
if (ID_AA64ISAR1_I8MM(isar1) >= ID_AA64ISAR1_I8MM_IMPL)
flags |= AV_CPU_FLAG_I8MM;
#endif
}
#endif
return flags;
}
#elif defined(_WIN32)
#include <windows.h>
static int detect_flags(void)
{
int flags = 0;
#ifdef PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE
if (IsProcessorFeaturePresent(PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE))
flags |= AV_CPU_FLAG_DOTPROD;
#endif
#ifdef PF_ARM_SVE_I8MM_INSTRUCTIONS_AVAILABLE
/* There's no PF_* flag that indicates whether plain I8MM is available
* or not. But if SVE_I8MM is available, that also implies that
* regular I8MM is available. */
if (IsProcessorFeaturePresent(PF_ARM_SVE_I8MM_INSTRUCTIONS_AVAILABLE))
flags |= AV_CPU_FLAG_I8MM;
#endif
#ifdef PF_ARM_SVE_INSTRUCTIONS_AVAILABLE
if (IsProcessorFeaturePresent(PF_ARM_SVE_INSTRUCTIONS_AVAILABLE))
flags |= AV_CPU_FLAG_SVE;
#endif
#ifdef PF_ARM_SVE2_INSTRUCTIONS_AVAILABLE
if (IsProcessorFeaturePresent(PF_ARM_SVE2_INSTRUCTIONS_AVAILABLE))
flags |= AV_CPU_FLAG_SVE2;
#endif
return flags;
}
#else
static int detect_flags(void)
{
return 0;
}
#endif
int ff_get_cpu_flags_aarch64(void)
{
int flags = AV_CPU_FLAG_ARMV8 * HAVE_ARMV8 |
AV_CPU_FLAG_NEON * HAVE_NEON;
#ifdef __ARM_FEATURE_DOTPROD
flags |= AV_CPU_FLAG_DOTPROD;
#endif
#ifdef __ARM_FEATURE_MATMUL_INT8
flags |= AV_CPU_FLAG_I8MM;
#endif
#ifdef __ARM_FEATURE_SVE
flags |= AV_CPU_FLAG_SVE;
#endif
#ifdef __ARM_FEATURE_SVE2
flags |= AV_CPU_FLAG_SVE2;
#endif
flags |= detect_flags();
return flags;
}
size_t ff_get_cpu_max_align_aarch64(void)
{
int flags = av_get_cpu_flags();
if (flags & AV_CPU_FLAG_NEON)
return 16;
return 8;
}
+37
View File
@@ -0,0 +1,37 @@
/*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVUTIL_AARCH64_CPU_H
#define AVUTIL_AARCH64_CPU_H
#include "libavutil/cpu.h"
#include "libavutil/cpu_internal.h"
#define have_armv8(flags) CPUEXT(flags, ARMV8)
#define have_neon(flags) CPUEXT(flags, NEON)
#define have_vfp(flags) CPUEXT(flags, VFP)
#define have_dotprod(flags) CPUEXT(flags, DOTPROD)
#define have_i8mm(flags) CPUEXT(flags, I8MM)
#define have_sve(flags) CPUEXT(flags, SVE)
#define have_sve2(flags) CPUEXT(flags, SVE2)
#if HAVE_SVE
int ff_aarch64_sve_length(void);
#endif
#endif /* AVUTIL_AARCH64_CPU_H */
+29
View File
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2023 Martin Storsjo
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#include "asm.S"
ENABLE_SVE
function ff_aarch64_sve_length, export=1
cntb x0
ret
endfunc
+69
View File
@@ -0,0 +1,69 @@
/*
* ARM NEON optimised Float DSP functions
* Copyright (c) 2008 Mans Rullgard <mans@mansr.com>
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdint.h>
#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
#include "libavutil/float_dsp.h"
#include "cpu.h"
void ff_vector_fmul_neon(float *dst, const float *src0, const float *src1,
int len);
void ff_vector_fmac_scalar_neon(float *dst, const float *src, float mul,
int len);
void ff_vector_fmul_scalar_neon(float *dst, const float *src, float mul,
int len);
void ff_vector_dmul_scalar_neon(double *dst, const double *src, double mul,
int len);
void ff_vector_fmul_window_neon(float *dst, const float *src0,
const float *src1, const float *win, int len);
void ff_vector_fmul_add_neon(float *dst, const float *src0, const float *src1,
const float *src2, int len);
void ff_vector_fmul_reverse_neon(float *dst, const float *src0,
const float *src1, int len);
void ff_butterflies_float_neon(float *v1, float *v2, int len);
float ff_scalarproduct_float_neon(const float *v1, const float *v2, int len);
av_cold void ff_float_dsp_init_aarch64(AVFloatDSPContext *fdsp)
{
int cpu_flags = av_get_cpu_flags();
if (have_neon(cpu_flags)) {
fdsp->butterflies_float = ff_butterflies_float_neon;
fdsp->scalarproduct_float = ff_scalarproduct_float_neon;
fdsp->vector_dmul_scalar = ff_vector_dmul_scalar_neon;
fdsp->vector_fmul = ff_vector_fmul_neon;
fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_neon;
fdsp->vector_fmul_add = ff_vector_fmul_add_neon;
fdsp->vector_fmul_reverse = ff_vector_fmul_reverse_neon;
fdsp->vector_fmul_scalar = ff_vector_fmul_scalar_neon;
fdsp->vector_fmul_window = ff_vector_fmul_window_neon;
}
}
+202
View File
@@ -0,0 +1,202 @@
/*
* ARM NEON optimised Float DSP functions
* Copyright (c) 2008 Mans Rullgard <mans@mansr.com>
* Copyright (c) 2014 Janne Grunau <janne-libav@jannau.net>
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#include "asm.S"
function ff_vector_fmul_neon, export=1
1: subs w3, w3, #16
ld1 {v0.4s, v1.4s}, [x1], #32
ld1 {v2.4s, v3.4s}, [x1], #32
ld1 {v4.4s, v5.4s}, [x2], #32
ld1 {v6.4s, v7.4s}, [x2], #32
fmul v16.4s, v0.4s, v4.4s
fmul v17.4s, v1.4s, v5.4s
fmul v18.4s, v2.4s, v6.4s
fmul v19.4s, v3.4s, v7.4s
st1 {v16.4s, v17.4s}, [x0], #32
st1 {v18.4s, v19.4s}, [x0], #32
b.ne 1b
ret
endfunc
function ff_vector_fmac_scalar_neon, export=1
mov x3, #-32
1: subs w2, w2, #16
ld1 {v16.4s, v17.4s}, [x0], #32
ld1 {v18.4s, v19.4s}, [x0], x3
ld1 {v4.4s, v5.4s}, [x1], #32
ld1 {v6.4s, v7.4s}, [x1], #32
fmla v16.4s, v4.4s, v0.s[0]
fmla v17.4s, v5.4s, v0.s[0]
fmla v18.4s, v6.4s, v0.s[0]
fmla v19.4s, v7.4s, v0.s[0]
st1 {v16.4s, v17.4s}, [x0], #32
st1 {v18.4s, v19.4s}, [x0], #32
b.ne 1b
ret
endfunc
function ff_vector_fmul_scalar_neon, export=1
mov w4, #15
bics w3, w2, w4
dup v16.4s, v0.s[0]
b.eq 3f
ld1 {v0.4s, v1.4s}, [x1], #32
1: subs w3, w3, #16
fmul v0.4s, v0.4s, v16.4s
ld1 {v2.4s, v3.4s}, [x1], #32
fmul v1.4s, v1.4s, v16.4s
fmul v2.4s, v2.4s, v16.4s
st1 {v0.4s, v1.4s}, [x0], #32
fmul v3.4s, v3.4s, v16.4s
b.eq 2f
ld1 {v0.4s, v1.4s}, [x1], #32
st1 {v2.4s, v3.4s}, [x0], #32
b 1b
2: ands w2, w2, #15
st1 {v2.4s, v3.4s}, [x0], #32
b.eq 4f
3: ld1 {v0.4s}, [x1], #16
fmul v0.4s, v0.4s, v16.4s
st1 {v0.4s}, [x0], #16
subs w2, w2, #4
b.gt 3b
4: ret
endfunc
function ff_vector_dmul_scalar_neon, export=1
dup v16.2d, v0.d[0]
ld1 {v0.2d, v1.2d}, [x1], #32
1: subs w2, w2, #8
fmul v0.2d, v0.2d, v16.2d
ld1 {v2.2d, v3.2d}, [x1], #32
fmul v1.2d, v1.2d, v16.2d
fmul v2.2d, v2.2d, v16.2d
st1 {v0.2d, v1.2d}, [x0], #32
fmul v3.2d, v3.2d, v16.2d
ld1 {v0.2d, v1.2d}, [x1], #32
st1 {v2.2d, v3.2d}, [x0], #32
b.gt 1b
ret
endfunc
function ff_vector_fmul_window_neon, export=1
sxtw x4, w4 // len
sub x2, x2, #8
sub x5, x4, #2
add x2, x2, x5, lsl #2 // src1 + 4 * (len - 4)
add x6, x3, x5, lsl #3 // win + 8 * (len - 2)
add x5, x0, x5, lsl #3 // dst + 8 * (len - 2)
mov x7, #-16
ld1 {v0.4s}, [x1], #16 // s0
ld1 {v2.4s}, [x3], #16 // wi
ld1 {v1.4s}, [x2], x7 // s1
1: ld1 {v3.4s}, [x6], x7 // wj
subs x4, x4, #4
fmul v17.4s, v0.4s, v2.4s // s0 * wi
rev64 v4.4s, v1.4s
rev64 v5.4s, v3.4s
rev64 v17.4s, v17.4s
ext v4.16b, v4.16b, v4.16b, #8 // s1_r
ext v5.16b, v5.16b, v5.16b, #8 // wj_r
ext v17.16b, v17.16b, v17.16b, #8 // (s0 * wi)_rev
fmul v16.4s, v0.4s, v5.4s // s0 * wj_r
fmla v17.4s, v1.4s, v3.4s // (s0 * wi)_rev + s1 * wj
b.eq 2f
ld1 {v0.4s}, [x1], #16
fmls v16.4s, v4.4s, v2.4s // s0 * wj_r - s1_r * wi
st1 {v17.4s}, [x5], x7
ld1 {v2.4s}, [x3], #16
ld1 {v1.4s}, [x2], x7
st1 {v16.4s}, [x0], #16
b 1b
2:
fmls v16.4s, v4.4s, v2.4s // s0 * wj_r - s1_r * wi
st1 {v17.4s}, [x5], x7
st1 {v16.4s}, [x0], #16
ret
endfunc
function ff_vector_fmul_add_neon, export=1
ld1 {v0.4s, v1.4s}, [x1], #32
ld1 {v2.4s, v3.4s}, [x2], #32
ld1 {v4.4s, v5.4s}, [x3], #32
1: subs w4, w4, #8
fmla v4.4s, v0.4s, v2.4s
fmla v5.4s, v1.4s, v3.4s
b.eq 2f
ld1 {v0.4s, v1.4s}, [x1], #32
ld1 {v2.4s, v3.4s}, [x2], #32
st1 {v4.4s, v5.4s}, [x0], #32
ld1 {v4.4s, v5.4s}, [x3], #32
b 1b
2: st1 {v4.4s, v5.4s}, [x0], #32
ret
endfunc
function ff_vector_fmul_reverse_neon, export=1
sxtw x3, w3
add x2, x2, x3, lsl #2
sub x2, x2, #32
mov x4, #-32
ld1 {v2.4s, v3.4s}, [x2], x4
ld1 {v0.4s, v1.4s}, [x1], #32
1: subs x3, x3, #8
rev64 v3.4s, v3.4s
rev64 v2.4s, v2.4s
ext v3.16b, v3.16b, v3.16b, #8
ext v2.16b, v2.16b, v2.16b, #8
fmul v16.4s, v0.4s, v3.4s
fmul v17.4s, v1.4s, v2.4s
b.eq 2f
ld1 {v2.4s, v3.4s}, [x2], x4
ld1 {v0.4s, v1.4s}, [x1], #32
st1 {v16.4s, v17.4s}, [x0], #32
b 1b
2: st1 {v16.4s, v17.4s}, [x0], #32
ret
endfunc
function ff_butterflies_float_neon, export=1
1: ld1 {v0.4s}, [x0]
ld1 {v1.4s}, [x1]
subs w2, w2, #4
fsub v2.4s, v0.4s, v1.4s
fadd v3.4s, v0.4s, v1.4s
st1 {v2.4s}, [x1], #16
st1 {v3.4s}, [x0], #16
b.gt 1b
ret
endfunc
function ff_scalarproduct_float_neon, export=1
movi v2.4s, #0
1: ld1 {v0.4s}, [x0], #16
ld1 {v1.4s}, [x1], #16
subs w2, w2, #4
fmla v2.4s, v0.4s, v1.4s
b.gt 1b
faddp v0.4s, v2.4s, v2.4s
faddp s0, v0.2s
ret
endfunc
+42
View File
@@ -0,0 +1,42 @@
/*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVUTIL_AARCH64_INTREADWRITE_H
#define AVUTIL_AARCH64_INTREADWRITE_H
#if HAVE_INTRINSICS_NEON
#include <arm_neon.h>
#define AV_COPY128 AV_COPY128
static av_always_inline void AV_COPY128(void *d, const void *s)
{
uint8x16_t tmp = vld1q_u8((const uint8_t *)s);
vst1q_u8((uint8_t *)d, tmp);
}
#define AV_ZERO128 AV_ZERO128
static av_always_inline void AV_ZERO128(void *d)
{
uint8x16_t zero = vdupq_n_u8(0);
vst1q_u8((uint8_t *)d, zero);
}
#endif /* HAVE_INTRINSICS_NEON */
#endif /* AVUTIL_AARCH64_INTREADWRITE_H */
+70
View File
@@ -0,0 +1,70 @@
/*
* check NEON registers for clobbering
* Copyright (c) 2008 Ramiro Polla <ramiro.polla@gmail.com>
* Copyright (c) 2013 Martin Storsjo
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVUTIL_AARCH64_NEONTEST_H
#define AVUTIL_AARCH64_NEONTEST_H
#include <inttypes.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include "libavutil/bswap.h"
#define storeneonregs(mem) \
__asm__ volatile( \
"stp d8, d9, [%0]\n\t" \
"stp d10, d11, [%0, #16]\n\t" \
"stp d12, d13, [%0, #32]\n\t" \
"stp d14, d15, [%0, #48]\n\t" \
:: "r"(mem) : "memory")
#define testneonclobbers(func, ctx, ...) \
uint64_t neon[2][8]; \
int ret; \
storeneonregs(neon[0]); \
ret = __real_ ## func(ctx, __VA_ARGS__); \
storeneonregs(neon[1]); \
if (memcmp(neon[0], neon[1], sizeof(neon[0]))) { \
int i; \
av_log(ctx, AV_LOG_ERROR, \
"NEON REGS CLOBBERED IN %s!\n", #func); \
for (i = 0; i < 8; i ++) \
if (neon[0][i] != neon[1][i]) { \
av_log(ctx, AV_LOG_ERROR, \
"d%-2d = %016"PRIx64"\n", \
8 + i, av_bswap64(neon[0][i])); \
av_log(ctx, AV_LOG_ERROR, \
" -> %016"PRIx64"\n", \
av_bswap64(neon[1][i])); \
} \
abort(); \
} \
return ret
#define wrap(func) \
int __real_ ## func; \
int __wrap_ ## func; \
int __wrap_ ## func
#endif /* AVUTIL_AARCH64_NEONTEST_H */
+53
View File
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2015 Janne Grunau <janne-libav@jannau.net>
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVUTIL_AARCH64_TIMER_H
#define AVUTIL_AARCH64_TIMER_H
#include <stdint.h>
#include "config.h"
#if HAVE_INLINE_ASM
#define AV_READ_TIME read_time
static inline uint64_t read_time(void)
{
uint64_t cycle_counter;
__asm__ volatile(
"isb \t\n"
#if defined(__ANDROID__) || defined(__APPLE__)
// cntvct_el0 has lower resolution than pmccntr_el0, but is usually
// accessible from user space by default.
"mrs %0, cntvct_el0 "
#else
// pmccntr_el0 has higher resolution, but is usually not accessible
// from user space by default (but access can be enabled with a custom
// kernel module).
"mrs %0, pmccntr_el0 "
#endif
: "=r"(cycle_counter) :: "memory" );
return cycle_counter;
}
#endif /* HAVE_INLINE_ASM */
#endif /* AVUTIL_AARCH64_TIMER_H */
+64
View File
@@ -0,0 +1,64 @@
/*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#define TX_FLOAT
#include "libavutil/tx_priv.h"
#include "libavutil/attributes.h"
#include "libavutil/aarch64/cpu.h"
TX_DECL_FN(fft2, neon)
TX_DECL_FN(fft4_fwd, neon)
TX_DECL_FN(fft4_inv, neon)
TX_DECL_FN(fft8, neon)
TX_DECL_FN(fft8_ns, neon)
TX_DECL_FN(fft16, neon)
TX_DECL_FN(fft16_ns, neon)
TX_DECL_FN(fft32, neon)
TX_DECL_FN(fft32_ns, neon)
TX_DECL_FN(fft_sr, neon)
TX_DECL_FN(fft_sr_ns, neon)
static av_cold int neon_init(AVTXContext *s, const FFTXCodelet *cd,
uint64_t flags, FFTXCodeletOptions *opts,
int len, int inv, const void *scale)
{
ff_tx_init_tabs_float(len);
if (cd->max_len == 2)
return ff_tx_gen_ptwo_revtab(s, opts);
else
return ff_tx_gen_split_radix_parity_revtab(s, len, inv, opts, 8, 0);
}
const FFTXCodelet * const ff_tx_codelet_list_float_aarch64[] = {
TX_DEF(fft2, FFT, 2, 2, 2, 0, 128, NULL, neon, NEON, AV_TX_INPLACE, 0),
TX_DEF(fft2, FFT, 2, 2, 2, 0, 192, neon_init, neon, NEON, AV_TX_INPLACE | FF_TX_PRESHUFFLE, 0),
TX_DEF(fft4_fwd, FFT, 4, 4, 2, 0, 128, NULL, neon, NEON, AV_TX_INPLACE | FF_TX_FORWARD_ONLY, 0),
TX_DEF(fft4_fwd, FFT, 4, 4, 2, 0, 192, neon_init, neon, NEON, AV_TX_INPLACE | FF_TX_PRESHUFFLE, 0),
TX_DEF(fft4_inv, FFT, 4, 4, 2, 0, 128, NULL, neon, NEON, AV_TX_INPLACE | FF_TX_INVERSE_ONLY, 0),
TX_DEF(fft8, FFT, 8, 8, 2, 0, 128, neon_init, neon, NEON, AV_TX_INPLACE, 0),
TX_DEF(fft8_ns, FFT, 8, 8, 2, 0, 192, neon_init, neon, NEON, AV_TX_INPLACE | FF_TX_PRESHUFFLE, 0),
TX_DEF(fft16, FFT, 16, 16, 2, 0, 128, neon_init, neon, NEON, AV_TX_INPLACE, 0),
TX_DEF(fft16_ns, FFT, 16, 16, 2, 0, 192, neon_init, neon, NEON, AV_TX_INPLACE | FF_TX_PRESHUFFLE, 0),
TX_DEF(fft32, FFT, 32, 32, 2, 0, 128, neon_init, neon, NEON, AV_TX_INPLACE, 0),
TX_DEF(fft32_ns, FFT, 32, 32, 2, 0, 192, neon_init, neon, NEON, AV_TX_INPLACE | FF_TX_PRESHUFFLE, 0),
TX_DEF(fft_sr, FFT, 64, 131072, 2, 0, 128, neon_init, neon, NEON, 0, 0),
TX_DEF(fft_sr_ns, FFT, 64, 131072, 2, 0, 192, neon_init, neon, NEON, AV_TX_INPLACE | FF_TX_PRESHUFFLE, 0),
NULL,
};
File diff suppressed because it is too large Load Diff