3223 Commits

Author SHA1 Message Date
Changsheng Wu 0480cb05fa riscv64: add compile support
This patch is a basic enablement that supports riscv64 compile.
We are working on adding vector optimizations with riscv64 rvv
extensions, and will push the implementations later.
2025-09-10 09:40:56 +08:00
Konstantinos Margaritis b35605ace3 i8mm & neon hpel_filter optimization
hpel_filter_c: 47995
hpel_filter_neon: 9670
hpel_filter_i8mm: 9643

previously:
hpel_filter_neon: 10222
In the Neon implementation, replaced SSHR+SUB+ADD with a single SSRA
2025-06-08 16:24:23 +00:00
Anton Mitrofanov 291476d733 windows: Fix named pipes detection
The _wstati64 call succeeds on named pipes, so to check correctly you
must first check the result of WaitNamedPipeW.
2025-06-06 19:34:05 +00:00
Martin Storsjö 714e07b477 arm: Don't test x264_cpu_fast_neon_mrc_test on Windows
The performance counters themselves are accessible, but the PMNC
(control register) that we try to read to see if the performance
counters are accessible, is not readable, causing illegal
instructions in cpu_enable_armv7_counter.

As an alternative, we could also modify cpu_fast_neon_mrc_test to
not inspect the PMNC at all (skip calling cpu_enable_armv7_counter)
but just assume that the counters are available, in high resolution
mode. However just not calling this codepath is the simplest,
as Windows on 32 bit ARM isn't very relevant these days.
2025-06-06 14:25:43 +03:00
Coia Prant ff620d0c3c configure: Use MSYSTEM_CARCH for default arch on msys2 2025-05-27 19:44:39 +00:00
Martin Storsjö 85b5ccea1f Update gas-preprocessor.pl to the latest upstream version
This updates to the version from commit
7380ac24e1cd23a5e6d76c6af083d8fc5ab9e943 from
https://github.com/ffmpeg/gas-preprocessor.

The previous version was from 2017, from commit
ee12830747ff0b97ec6b41f4263fec63d1711365.

This includes support for assembling aarch64 code with
register ranges, such as {v0.8b-v3.8b} with armasm64 (rewritten
into an explicit list of registers), and fixes deprecated Perl
syntax broken by more modern versions of Perl.
2025-05-21 18:48:51 +00:00
Anton Mitrofanov 40617ddb88 ci: Remove vlc-contrib dependency 2025-05-19 02:42:45 +03:00
Anton Mitrofanov 4360ac3710 ci: Fix ffmpeg build
libpostproc has been removed from the ffmpeg repository.
2025-05-19 01:28:04 +03:00
Martin Storsjö 32c3b80119 lavf: Update the code to work with the latest libavutil API 2025-04-04 17:50:00 +03:00
Konstantinos Margaritis fe9e4a7f39 Provide implementations for functions using the instructions SDOT/UDOT in the DotProd Armv8 extension.
Functions implemented:
sad_16x8, sad_16x16,
sad_x3_16x8_neon, sad_x3_16x16_neon,
sad_x4_16x8_neon, sad_x4_16x16_neon,
ssd_8x4, ssd_8x8, ssd_8x16, ssd_16x8, ssd_16x16,
pixel_vsad

Performance improvement against Neon ranges from 5% to 188%.
Following is the output of ./checkasm8 --bench (run on a Graviton4 system):

sad_16x8_c: 1323
sad_16x8_neon: 224
sad_16x8_dotprod: 211
sad_16x16_c: 2619
sad_16x16_neon: 365
sad_16x16_dotprod: 320
sad_x3_16x8_c: 3836
sad_x3_16x8_neon: 403
sad_x3_16x8_dotprod: 317
sad_x3_16x16_c: 7725
sad_x3_16x16_neon: 714
sad_x3_16x16_dotprod: 532
sad_x4_16x8_c: 5080
sad_x4_16x8_neon: 438
sad_x4_16x8_dotprod: 375
sad_x4_16x16_c: 10260
sad_x4_16x16_neon: 794
sad_x4_16x16_dotprod: 655
ssd_8x4_c: 381
ssd_8x4_neon: 157
ssd_8x4_dotprod: 115
ssd_8x4_sve: 150
ssd_8x8_c: 695
ssd_8x8_neon: 238
ssd_8x8_dotprod: 161
ssd_8x8_sve: 228
ssd_8x16_c: 1335
ssd_8x16_neon: 388
ssd_8x16_dotprod: 267
ssd_16x8_c: 1342
ssd_16x8_neon: 285
ssd_16x8_dotprod: 166
ssd_16x16_c: 2623
ssd_16x16_neon: 503
ssd_16x16_dotprod: 277
vsad_c: 2786
vsad_neon: 311
vsad_dotprod: 235
2025-03-12 12:35:10 +00:00
Martin Storsjö 570f6c7080 aarch64: Add runtime detection of extensions on Windows and macOS 2025-03-12 13:23:40 +02:00
Martin Storsjö 0e48d072c2 aarch64: Add flags for runtime detection of dotprod and i8mm
Also add code for detecting them on Linux.
2025-03-12 13:23:40 +02:00
Martin Storsjö fc4012fb67 configure: Check for the dotprod and i8mm aarch64 extensions 2025-03-12 13:23:40 +02:00
Martin Storsjö 87044b210a aarch64: Use configure detected directives for enabling SVE/SVE2
By using .arch_extension (if supported) to enable the relevant
extensions, we can also disable them afterwards, so we can e.g.
cleanly enable one extension only for one subsection of a file.

This also makes it easier to enable various combinations of
supported architecture extensions.
2025-03-12 13:23:40 +02:00
Martin Storsjö f87ca18375 configure: Check for .arch and .arch_extension for enabling aarch64 extensions
This hasn't been needed for SVE/SVE2, as all toolchains have
supported just enabling it via ".arch armv8.2-a+sve". For other
arch extensions, like dotprod/i8mm, there's more combinations of
toolchain bugs in slightly older toolchains; try to detect what is
supported.

Additionally, when involving more than one architecture extension,
we may want to enable/disable individual extensions one at a time,
without needing to specify the full list in one single .arch
statement.

This is a preparatory commit for adding support for the dotprod/i8mm
extensions.

We intentionally don't add AS_ARCH_LEVEL to the CONFIG_HAVE list,
as this define isn't prefixed with "HAVE_", and we don't use the
define except in the case where we actually do set it. (It's not
a regular 0/1 define like the others.)
2025-03-12 13:23:40 +02:00
Martin Storsjö 72ce1cdecf configure: Use as_check for the main check for whether NEON is supported
This requires adding the "-c" flag to ASFLAGS before doing the
check.

This also makes sure to validate the gas-preprocessor is functional
for MSVC configurations, by testing whether the "cmeq" instruction
can be assembled at this point.
2025-03-12 13:23:40 +02:00
Martin Storsjö a0191bd8b1 configure: Use as_check for checking for aarch64 features
This is more correct than using cc_check; we're going to assemble
standalone external assembly - thus check for whether we can
build it in that form, not using inline assembly.

This allows sharing checks with the MSVC codepath (where inline
assembly isn't supported, and where assembly is built using
a tool different from the regular compiler).
2025-03-12 13:23:40 +02:00
Martin Storsjö 27d8370847 Makefile: Generate dependency information implicitly while compiling
This updates the dependecy information on each successive recompile.

When building with MSVC, dependency information is generated with
a separate command just like before, but done together with
compiling each object file. (This is quite similar to how ffmpeg does
the same.)

This avoids the serial dependency generation step. In slow
environments (in particular if using MSVC) it could take a notable
amount of time; this can now all be done in parallel.

In one example, this reduces the time for a full build from clean
with MSVC (wrapped in wine) from 23 seconds down to 9 seconds,
thanks to parallelism. (For non-parallel builds, it doesn't make
much of a difference.)
2025-03-11 22:22:24 +02:00
Martin Storsjö c80f8a2815 msvsdepend: Allow using the script for .S sources too
Previously, MSVC would warn that the .S source is unrecognized,
and the script would only produce a depenency on the main source
file itself.
2025-03-04 11:15:49 +02:00
Anton Mitrofanov 373697b467 Bump dates to 2025 2025-01-03 16:48:30 +03:00
Brad Smith 52f7694ddd Use sched_getaffinity on Android
https://android.googlesource.com/platform/bionic/+/72e6fd42421dca80fb2776a9185c186d4a04e5f7

Android has had sched_getaffinity since Android 3.0. Builds need
to use _GNU_SOURCE.
2024-12-29 17:54:57 +00:00
Martin Storsjö 450946f96b ci: Test compiling for Android 2024-12-29 17:48:58 +00:00
Brad Smith a64111b1b3 Enable use of __sync_fetch_and_add() wherever detected instead of just X86
Use __sync_fetch_and_add() wherever detected instead of being limited to
just X86.
2024-12-29 12:13:33 -05:00
Brad Smith 938601b906 Use sysctlbyname(3) hw.logicalcpu on macOS
Use of hw.ncpu has long been deprecated.
2024-12-29 15:52:24 +00:00
Brad Smith 023112c6f2 aarch64: defines involving bit shifts should be unsigned 2024-11-03 23:44:35 -05:00
Brad Smith da14df5535 Make use of sysconf(3) _SC_NPROCESSORS_ONLN and _SC_NPROCESSORS_CONF
Make use of _SC_NPROCESSORS_ONLN if it exists and fallback to
_SC_NPROCESSORS_CONF for really old operating systems. This adds
support for retrieving the number of CPUs on a few OS's such as
NetBSD, DragonFly and a few others.
2024-10-27 12:28:19 -04:00
Brad Smith b1d2de88ec Use getauxval() on Linux and elf_aux_info() on FreeBSD/OpenBSD on arm/ppc 2024-10-26 06:34:32 +00:00
Anton Mitrofanov 3a21e97bf2 Fix build with Android NDK and API < 24 for 32-bit targets
fseeko() is not available before API 24 with _FILE_OFFSET_BITS=64.
x264.c: x264cli.h must be first as it contains _FILE_OFFSET_BITS define.
2024-10-22 22:59:00 +03:00
Brad Smith 80c1c47cb2 configure: Add DragonFly support 2024-10-20 08:50:55 +00:00
Brad Smith 1243d9ffb0 Provide x264_getauxval() wrapper for getauxvaul() and elf_aux_info() 2024-10-17 06:23:19 -04:00
Brad Smith 3a8b5be2a2 aarch64: Use elf_aux_info() for CPU feature detection on FreeBSD/OpenBSD 2024-10-07 15:58:28 -04:00
Martin Storsjö c24e06c2e1 configure: Check for SVE support in MS armasm64 via as_check
This is mostly supported in armasm64 since MSVC 2022 17.10.
2024-09-17 14:07:10 +03:00
Henrik Gramner 4613ac3c15 x86inc: Improve ELF PIC support for external function calls
PLT/GOT indirections are required in some cases. Most commonly when
calling functions from other shared libraries, but also in some
scenarios when calling functions with default symbol visibility
even within the same component on certain elf64 platforms.

On elf64 we can simply use PLT relocations for all calls to external
functions. Since the linker is able to eliminate unnecessary PLT
indirections with the final output binary being identical to non-PLT
relocations there isn't really any downside to doing so. This mimics
what regular compilers normally do for calls to external functions.

On elf32 with PIC we can use a function pointer from the GOT when
calling external functions, similar to what regular compilers do when
using -fno-plt. Since this both introduces overhead and clobbers one
register, which could potentially have been used for custom calling
conventions when calling other asm functions within the same library,
it's only performed for functions declared using 'cextern_naked'.
2024-05-13 17:54:15 +02:00
Xiwei Gu 7ed753b10a loongarch: Enhance ultrafast encoding performance
Using the following command, ultrafast encoding
has improved from 182fps to 189fps:
./x264 --preset ultrafast -o out.mkv yuv_1920x1080.yuv
2024-03-21 09:18:50 +08:00
Xiwei Gu 162622863a loongarch: Fixed pixel_sa8d_16x16_lasx
Save and restore FPR
2024-03-21 09:18:32 +08:00
Xiwei Gu 5a61afdbf1 loongarch: Add checkasm_call 2024-03-21 09:18:00 +08:00
Xiwei Gu 982d32400f loongarch: Update loongson_asm.S version to 0.4.0 2024-03-21 09:17:09 +08:00
Henrik Gramner 585e01997f x86inc: Improve XMM-spilling functionality on 64-bit Windows
Prior to this change dealing with the scenario where the number of
XMM registers spilled depends on if a branch is taken or not was
complicated to handle well. There was essentially three options:

1) Always spill the largest number of XMM register. Results in
   unnecessary spills.

2) Do the spilling after the branch. Results in code duplication
   for the shared subset of spills.

3) Do the spilling manually. Optimal, but overly complex and vexing.

This adds an additional optional argument to the WIN64_SPILL_XMM
and WIN64_PUSH_XMM macros to make it possible to allocate space
for a certain number of registers but initially only push a subset
of those, with the option of pushing additional register later.
2024-03-14 23:29:26 +00:00
Henrik Gramner 4df71a75bf x86inc: Restore the stack state between stack allocations
Allows the use of multiple independent stack allocations within
a function without having to manually fiddle with stack offsets.
2024-03-14 23:29:26 +00:00
Henrik Gramner 3d8aff7e26 x86inc: Fix warnings with old nasm versions 2024-03-14 23:29:26 +00:00
Anton Mitrofanov de1bea534f ppc: Fix incompatible pointer type errors
Use correct return type for pixel_sad_x3/x4 functions.
Bug report by Dominik 'Rathann' Mierzejewski .
2024-03-12 23:10:12 +03:00
Martin Storsjö be4f0200ed aarch64: Use regular hwcaps flags instead of HWCAP_CPUID for CPU feature detection on Linux
This makes the code much simpler (especially for adding support
for other instruction set extensions), avoids needing inline
assembly for this feature, and generally is more of the canonical
way to do this.

The CPU feature detection was added in
9c3c716882, using HWCAP_CPUID.

The argument for using that, was that HWCAP_CPUID was added much
earlier in the kernel (in Linux v4.11), while the HWCAP flags for
individual features always come later. This allows detecting support
for new CPU extensions before the kernel exposes information about
them via hwcap flags.

However in practice, there's probably quite little advantage in this.
E.g. HWCAP_SVE was added in Linux v4.15, and HWCAP2_SVE2 was added in
v5.10 - later than HWCAP_CPUID, but there's probably very little
practical cases where one would run a kernel older than that on a CPU
that supports those instructions.

Additionally, we provide our own definitions of the flag values to
check (as they are fixed constants anyway), with names not conflicting
with the ones from system headers. This reduces the number of ifdefs
needed, and allows detecting those features even if building with
userland headers that are lacking the definitions of those flags.

Also, slightly older versions of QEMU, e.g. 6.2 in Ubuntu 22.04,
do expose support for these features via HWCAP flags, but the
emulated cpuid registers are missing the bits for exposing e.g. SVE2
(This issue is fixed in later versions of QEMU though.)

Also drop the ifdef check for whether AT_HWCAP is defined; it was
added to glibc in 1997. AT_HWCAP2 was added in 2013, in glibc 2.18,
which also precedes when aarch64 was commonly used anyway, so
don't guard the use of that with an ifdef.
2024-02-28 22:26:17 +00:00
Anton Mitrofanov 7241d02011 CI: Switch 32/64-bit windows builds to LLVM
Use same Docker images as VLC for contrib compilation.
2024-02-28 23:23:15 +03:00
Anton Mitrofanov ea08f58648 CI: Add config.log to job artifacts 2024-02-28 23:19:23 +03:00
Henrik Gramner 12426f5f49 x86inc: Add support for ELF CET properties
Automatically flag x86-64 asm object files as SHSTK-compatible.

Shadow Stack (SHSTK) is a part of Control-flow Enforcement Technology
(CET) which is a feature aimed at defending against ROP attacks by
verifying that 'call' and 'ret' instructions are correctly matched.

For well-written code this works transparently without any code changes,
as return addresses popped from the shadow stack should match return
addresses popped from the normal stack for performance reasons anyway.
2024-02-20 00:03:09 +01:00
Henrik Gramner 6fc4480cf0 x86inc.asm: Add the crc32 SSE4.2 GPR instruction 2024-02-20 00:03:09 +01:00
Henrik Gramner 87476b4c4d x86inc: Add a cpu flag for the Ice Lake AVX-512 subset 2024-02-20 00:03:09 +01:00
Henrik Gramner a6b561792f x86inc: Add CLMUL cpu flag
Also make the GFNI cpu flag imply the presence of both AESNI and CLMUL.
2024-02-20 00:03:09 +01:00
Henrik Gramner 5207a74e77 x86inc: Add template defines for EVEX broadcasts
Broadcasting a memory operand is a binary flag, you either broadcast
or you don't, and there's only a single possible element size for
any given instruction.

The instruction syntax however requires the broadcast semanticts
to be explicitly defined, which is an issue when using macros to
template code for multiple register widths.

Add some helper defines to alleviate the issue.
2024-02-20 00:02:59 +01:00
Henrik Gramner 436be41fc1 x86inc: Properly sort instructions in alphabetical order 2024-02-19 23:49:36 +01:00