Skip to content

Enable NEON for arm / aarch64#89

Merged
ralfbiedert merged 1 commit into
ralfbiedert:masterfrom
thomasdangl:master
Jan 21, 2026
Merged

Enable NEON for arm / aarch64#89
ralfbiedert merged 1 commit into
ralfbiedert:masterfrom
thomasdangl:master

Conversation

@thomasdangl

Copy link
Copy Markdown
Contributor

This PR enables the NEON (SIMD) extension for arm / aarch64, which should give us a nice performance boost.

It does so by:

  1. removing the arm / aarch64 handling from the nasm path (nasm is x86 only and cannot compile arm assembly)
  2. dynamically adding the appropriate defines, includes and compilation units (compare to https://github.com/cisco/openh264/blob/cf568c83f71a18778f9a16e344effaf40c11b752/meson.build#L79-L88)

Best,
Thomas

@ralfbiedert

Copy link
Copy Markdown
Owner

Sorry, didn't see this in a flood of CI notifications ...

@ralfbiedert

ralfbiedert commented Jan 21, 2026

Copy link
Copy Markdown
Owner

The build failure log is humongous. An agent summary of what went wrong is attached below. I'm not sure if this is caused by your changes, or if this is a CI / platform bug (we've had the latter). I'm tentatively assuming its the former though.


The CI build failed when compiling openh264-sys2 v0.9.1 for the ARM64 Windows target (aarch64-pc-windows-msvc).

Root Cause

The build system tried to compile ARM64 NEON assembly files (.S files) using MSVC's C++ compiler (cl.exe), which doesn't support assembly source files. This caused the linker to fail with:

LINK : fatal error LNK1181: cannot open input file
'...\out\2a171e1abf1f6202-copy_mb_aarch64_neon.o'

Key Issues

  1. Missing ARM64 assembler: MSVC's cl.exe cannot compile .S assembly files. The warnings show:
    cl : Command line warning D9024 : unrecognized source file type
    'upstream/codec/common.\arm64\copy_mb_aarch64_neon.S', object file assumed
    cl : Command line warning D9027 : source file '...' ignored
  2. No NASM configured: The build output states:
    No NASM configuration found for target, not using any assembly.
  3. Cross-compilation issue: The build is using -Ctarget-cpu=native in RUSTFLAGS while cross-compiling from x86_64 host to aarch64 target, which is problematic.

Affected Files

  • copy_mb_aarch64_neon.S
  • deblocking_aarch64_neon.S
  • expand_picture_aarch64_neon.S
  • intra_pred_common_aarch64_neon.S
  • mc_aarch64_neon.S

The build needs either a proper ARM64 assembler (like armasm64.exe) or the build script should be configured to skip assembly optimizations for this target.

@ralfbiedert ralfbiedert added the enhancement New feature or request label Jan 21, 2026
@thomasdangl

Copy link
Copy Markdown
Contributor Author

Oops, my bad! Did not consider that cl.exe does not have an assembler.
As I don't have access to a Windows aarch64 machine for testing, I disabled the proposed optimization for that target.

I added the following comment that explains how to proceed from here if someone else wants to add it in the future.

// cl.exe cannot assemble .S files.
// TODO: generalize try_compile_nasm and invoke armasm64.exe.
if !matches!(target.os, TargetOs::Windows) {

If you rerun the CI, it should work fine now and yield a speed-up of around 200-250% on the respective platforms (tested for 1080p24 on Cortex A76/Linux and Apple M4/MacOS).

Best,
Thomas

@ralfbiedert ralfbiedert merged commit 75d27cf into ralfbiedert:master Jan 21, 2026
14 checks passed
@ralfbiedert

Copy link
Copy Markdown
Owner

Thanks!

@ralfbiedert

Copy link
Copy Markdown
Owner

Should be in 0.9.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants