mirror of
https://mirror.skon.top/https://github.com/FFmpeg/FFmpeg
synced 2026-04-20 21:00:41 +08:00
libavcodec/huffyuvdsp: Add NEON optimization for the add_int16 function
Benchmark Results (1024 iterations, Raspberry Pi 5 - Cortex-A76): add_int16_128_c: 914.0 ( 1.00x) add_int16_128_neon: 516.9 ( 1.77x) add_int16_rnd_width_c: 914.0 ( 1.00x) add_int16_rnd_width_neon: 517.5 ( 1.77x) Co-Authored-By: Martin Storsjö <martin@martin.st>
This commit is contained in:
committed by
Martin Storsjö
parent
8324c8ea89
commit
1fc7464cf7
@@ -4,6 +4,7 @@ OBJS-$(CONFIG_FDCTDSP) += aarch64/fdctdsp_init_aarch64.o
|
||||
OBJS-$(CONFIG_FMTCONVERT) += aarch64/fmtconvert_init.o
|
||||
OBJS-$(CONFIG_H264CHROMA) += aarch64/h264chroma_init_aarch64.o
|
||||
OBJS-$(CONFIG_H264DSP) += aarch64/h264dsp_init_aarch64.o
|
||||
OBJS-$(CONFIG_HUFFYUVDSP) += aarch64/huffyuvdsp_init_aarch64.o
|
||||
OBJS-$(CONFIG_H264PRED) += aarch64/h264pred_init.o
|
||||
OBJS-$(CONFIG_H264QPEL) += aarch64/h264qpel_init_aarch64.o
|
||||
OBJS-$(CONFIG_HPELDSP) += aarch64/hpeldsp_init_aarch64.o
|
||||
@@ -51,6 +52,7 @@ NEON-OBJS-$(CONFIG_H264PRED) += aarch64/h264pred_neon.o
|
||||
NEON-OBJS-$(CONFIG_H264QPEL) += aarch64/h264qpel_neon.o \
|
||||
aarch64/hpeldsp_neon.o
|
||||
NEON-OBJS-$(CONFIG_HPELDSP) += aarch64/hpeldsp_neon.o
|
||||
NEON-OBJS-$(CONFIG_HUFFYUVDSP) += aarch64/huffyuvdsp_neon.o
|
||||
NEON-OBJS-$(CONFIG_IDCTDSP) += aarch64/idctdsp_neon.o \
|
||||
aarch64/simple_idct_neon.o
|
||||
NEON-OBJS-$(CONFIG_ME_CMP) += aarch64/me_cmp_neon.o
|
||||
|
||||
35
libavcodec/aarch64/huffyuvdsp_init_aarch64.c
Normal file
35
libavcodec/aarch64/huffyuvdsp_init_aarch64.c
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2025
|
||||
*
|
||||
* 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/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavutil/aarch64/cpu.h"
|
||||
#include "libavcodec/huffyuvdsp.h"
|
||||
|
||||
void ff_add_int16_neon(uint16_t *dst, const uint16_t *src, unsigned mask, int w);
|
||||
|
||||
av_cold void ff_huffyuvdsp_init_aarch64(HuffYUVDSPContext *c, enum AVPixelFormat pix_fmt)
|
||||
{
|
||||
int cpu_flags = av_get_cpu_flags();
|
||||
|
||||
if (have_neon(cpu_flags)) {
|
||||
c->add_int16 = ff_add_int16_neon;
|
||||
}
|
||||
}
|
||||
76
libavcodec/aarch64/huffyuvdsp_neon.S
Normal file
76
libavcodec/aarch64/huffyuvdsp_neon.S
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2025
|
||||
*
|
||||
* 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/aarch64/asm.S"
|
||||
|
||||
// Add int16 array with masking
|
||||
// On entry:
|
||||
// x0 -> destination array (uint16_t*)
|
||||
// x1 -> source array (const uint16_t*)
|
||||
// w2 = mask value
|
||||
// w3 = number of elements
|
||||
function ff_add_int16_neon, export=1
|
||||
dup v31.8h, w2
|
||||
mov x4, x0
|
||||
|
||||
// Process 32 elements (64 bytes) if available
|
||||
1: cmp w3, #32
|
||||
b.lt 2f
|
||||
ld1 {v0.8h, v1.8h}, [x1], #32
|
||||
ld1 {v2.8h, v3.8h}, [x0], #32
|
||||
sub w3, w3, #32
|
||||
add v0.8h, v0.8h, v2.8h
|
||||
ld1 {v4.8h, v5.8h}, [x1], #32
|
||||
add v1.8h, v1.8h, v3.8h
|
||||
ld1 {v6.8h, v7.8h}, [x0], #32
|
||||
and v0.16b, v0.16b, v31.16b
|
||||
and v1.16b, v1.16b, v31.16b
|
||||
|
||||
add v4.8h, v4.8h, v6.8h
|
||||
add v5.8h, v5.8h, v7.8h
|
||||
st1 {v0.8h, v1.8h}, [x4], #32
|
||||
and v4.16b, v4.16b, v31.16b
|
||||
and v5.16b, v5.16b, v31.16b
|
||||
st1 {v4.8h, v5.8h}, [x4], #32
|
||||
b 1b
|
||||
|
||||
// Process 8 elements (16 bytes) if available
|
||||
2: cmp w3, #8
|
||||
b.lt 3f
|
||||
ld1 {v0.8h}, [x1], #16
|
||||
ld1 {v1.8h}, [x0]
|
||||
sub w3, w3, #8
|
||||
add v0.8h, v0.8h, v1.8h
|
||||
and v0.16b, v0.16b, v31.16b
|
||||
st1 {v0.8h}, [x0], #16
|
||||
b 2b
|
||||
|
||||
// Scalar path for remaining elements
|
||||
3: cbz w3, 4f
|
||||
ldrh w5, [x1], #2
|
||||
ldrh w6, [x0]
|
||||
add w5, w5, w6
|
||||
and w5, w5, w2
|
||||
strh w5, [x0], #2
|
||||
subs w3, w3, #1
|
||||
b.ne 3b
|
||||
|
||||
4: ret
|
||||
endfunc
|
||||
@@ -87,7 +87,9 @@ av_cold void ff_huffyuvdsp_init(HuffYUVDSPContext *c, enum AVPixelFormat pix_fmt
|
||||
c->add_hfyu_median_pred_int16 = add_hfyu_median_pred_int16_c;
|
||||
c->add_hfyu_left_pred_bgr32 = add_hfyu_left_pred_bgr32_c;
|
||||
|
||||
#if ARCH_RISCV
|
||||
#if ARCH_AARCH64
|
||||
ff_huffyuvdsp_init_aarch64(c, pix_fmt);
|
||||
#elif ARCH_RISCV
|
||||
ff_huffyuvdsp_init_riscv(c, pix_fmt);
|
||||
#elif ARCH_X86 && HAVE_X86ASM
|
||||
ff_huffyuvdsp_init_x86(c, pix_fmt);
|
||||
|
||||
@@ -34,6 +34,8 @@ typedef struct HuffYUVDSPContext {
|
||||
} HuffYUVDSPContext;
|
||||
|
||||
void ff_huffyuvdsp_init(HuffYUVDSPContext *c, enum AVPixelFormat pix_fmt);
|
||||
void ff_huffyuvdsp_init_aarch64(HuffYUVDSPContext *c,
|
||||
enum AVPixelFormat pix_fmt);
|
||||
void ff_huffyuvdsp_init_riscv(HuffYUVDSPContext *c,
|
||||
enum AVPixelFormat pix_fmt);
|
||||
void ff_huffyuvdsp_init_x86(HuffYUVDSPContext *c, enum AVPixelFormat pix_fmt);
|
||||
|
||||
Reference in New Issue
Block a user