[patch] NEON arm64 improvements

Issue #563 new
Former user created an issue

Hi, I am a developer of handbrake, and I am porting handbrake to apple's new arm macs. Apple contributed a x265 patch with a bunch of neon asm to improve x265 performance, but I have to say that arm64 asm is not my strong suit, so I hope someone more knowledgable could try to upstream these changes.

The patch is for x265 3.2.1: https://github.com/HandBrake/HandBrake/commit/67a490a171764eafe8eb8afb72fa1dff763a3275

These optimisation almost halves the encoding time on arm mac devkit.

Comments (12)

  1. Phil Rosenthal

    I’m surprised this issue has been sitting since 2020 with zero activity. I compared ffmpeg compiled with x265 with this patch to the current official version, and this patch has a 2X speed up.

    Is there any chance this will get merged in?

    It would be a sham if it ends up far into the future and this code can’t be merged in anymore, and x265 continues down a path slower than it could be for Apple’s M1 chips.

  2. Robert Palmer

    @vargolsoft Could we get a new point release so that this is available to the public? This would be huge for the ffmpeg project.

  3. vargolsoft

    @Robert Palmer I’m not an x265 dev, so I have no influence on creating a new point release, I just maintain my own ffmpeg build script that tries to optimise for ARM64 specifically for MacOS. There are two branches one that builds x265 from stable and includes the patch, and another that builds from head and includes the version that was merged.

  4. Robert Palmer

    @vargolsoft that’s awesome! Any chance you have a public repo with the script & binary releases?

  5. Yousuf Syed

    It looks like the last release of x265 was in 2020 if I’m not mistaken. What has happened to x265 development?

  6. Alexander Willner

    I think version 3.5 was released 2021-03-16, however, this patch was not included if I’m not mistaken.

  7. Chris Varen

    I too would love to see a new x265 release that includes this patch. That would mean it would ultimately end up in ffmpeg as well. A 2x speed up on h265 encoding sounds pretty high impact.

  8. vargolsoft

    Version 3.6 was releases 5th of April, tagged on the 4th, so there is now a release version with the NEON code.
    You just need to find a ffmpeg distro with it compiled in, or roll your own 😃 .

  9. Alexander Willner

    You just need to find a ffmpeg distro with it compiled in, or roll your own

    Seems to me that at least on macOS (using brew) it works now out of the box!

    % ffmpeg -y -i input.mp4 -c:v libx265 output.mp4 2>&1|grep "cpu capabilities"

    x265 [info]: using cpu capabilities: NEON

  10. Log in to comment