History

lavc/aacencdsp: R-V V abs_pow34

C908: abs_pow34_c: 535.5 abs_pow34_rvv_f32: 337.2

sunyuechi committed 2 years ago

Commit 98596f91 parent 1c3620b5 files · +86 −1Browse files

Showing the changes to libavcodec (5 of 5 files). Show all

Unified · Split

5 files
  1. libavcodec/aacenc.c +3 −1
  2. libavcodec/aacenc.h +1 −0
  3. libavcodec/riscv/Makefile +2 −0
  4. libavcodec/riscv/aacencdsp_init.c +42 −0
  5. libavcodec/riscv/aacencdsp_rvv.S +38 −0
libavcodec/aacenc.c+3−1
@@ -1440,7 +1440,9 @@ void ff_aac_dsp_init(AACEncContext *s){ · 1439 unmodified lines
14401440 s->abs_pow34 = abs_pow34_v;
14411441 s->quant_bands = quantize_bands;
14421442
1443−#if ARCH_X86
1443+#if ARCH_RISCV
1444+ ff_aac_dsp_init_riscv(s);
1445+#elif ARCH_X86
14441446 ff_aac_dsp_init_x86(s);
14451447 #endif
14461448
libavcodec/aacenc.h+1−0
@@ -155,6 +155,7 @@ typedef struct AACEncContext { · 154 unmodified lines
155155 } AACEncContext;
156156
157157 void ff_aac_dsp_init(AACEncContext *s);
158+void ff_aac_dsp_init_riscv(AACEncContext *s);
158159 void ff_aac_dsp_init_x86(AACEncContext *s);
159160 void ff_aac_coder_init_mips(AACEncContext *c);
160161 void ff_quantize_band_cost_cache_init(struct AACEncContext *s);
libavcodec/riscv/Makefile+2−0
@@ -1,5 +1,7 @@
11 OBJS-$(CONFIG_AAC_DECODER) += riscv/aacpsdsp_init.o riscv/sbrdsp_init.o
22 RVV-OBJS-$(CONFIG_AAC_DECODER) += riscv/aacpsdsp_rvv.o riscv/sbrdsp_rvv.o
3+OBJS-$(CONFIG_AAC_ENCODER) += riscv/aacencdsp_init.o
4+RVV-OBJS-$(CONFIG_AAC_ENCODER) += riscv/aacencdsp_rvv.o
35 OBJS-$(CONFIG_AC3DSP) += riscv/ac3dsp_init.o
46 RV-OBJS-$(CONFIG_AC3DSP) += riscv/ac3dsp_rvb.o
57 RVV-OBJS-$(CONFIG_AC3DSP) += riscv/ac3dsp_rvv.o
libavcodec/riscv/aacencdsp_init.c+42−0
@@ -0,0 +1,42 @@
1+/*
2+ * AAC encoder assembly optimizations
3+ * Copyright (c) 2023 Institue of Software Chinese Academy of Sciences (ISCAS).
4+ *
5+ * This file is part of FFmpeg.
6+ *
7+ * FFmpeg is free software; you can redistribute it and/or
8+ * modify it under the terms of the GNU Lesser General Public
9+ * License as published by the Free Software Foundation; either
10+ * version 2.1 of the License, or (at your option) any later version.
11+ *
12+ * FFmpeg is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+ * Lesser General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU Lesser General Public
18+ * License along with FFmpeg; if not, write to the Free Software
19+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+ */
21+
22+#include "config.h"
23+
24+#include "libavutil/attributes.h"
25+#include "libavutil/float_dsp.h"
26+#include "libavutil/cpu.h"
27+#include "libavcodec/aacenc.h"
28+
29+void ff_abs_pow34_rvv(float *out, const float *in, const int size);
30+
31+av_cold void ff_aac_dsp_init_riscv(AACEncContext *s)
32+{
33+#if HAVE_RVV
34+ int flags = av_get_cpu_flags();
35+
36+ if (flags & AV_CPU_FLAG_RVV_F32) {
37+ if (flags & AV_CPU_FLAG_RVB_ADDR) {
38+ s->abs_pow34 = ff_abs_pow34_rvv;
39+ }
40+ }
41+#endif
42+}
libavcodec/riscv/aacencdsp_rvv.S+38−0
@@ -0,0 +1,38 @@
1+/*
2+ * Copyright (c) 2023 Institue of Software Chinese Academy of Sciences (ISCAS).
3+ *
4+ * This file is part of FFmpeg.
5+ *
6+ * FFmpeg is free software; you can redistribute it and/or
7+ * modify it under the terms of the GNU Lesser General Public
8+ * License as published by the Free Software Foundation; either
9+ * version 2.1 of the License, or (at your option) any later version.
10+ *
11+ * FFmpeg is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+ * Lesser General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU Lesser General Public
17+ * License along with FFmpeg; if not, write to the Free Software
18+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19+ */
20+
21+#include "libavutil/riscv/asm.S"
22+
23+func ff_abs_pow34_rvv, zve32f
24+1:
25+ vsetvli t0, a2, e32, m8, ta, ma
26+ sub a2, a2, t0
27+ vle32.v v0, (a1)
28+ sh2add a1, t0, a1
29+ vfabs.v v0, v0
30+ vfsqrt.v v8, v0
31+ vfmul.vv v8, v8, v0
32+ vfsqrt.v v8, v8
33+ vse32.v v8, (a0)
34+ sh2add a0, t0, a0
35+ bnez a2, 1b
36+
37+ ret
38+endfunc

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t