C908: abs_pow34_c: 535.5 abs_pow34_rvv_f32: 337.2
Showing the changes to libavcodec (5 of 5 files). Show all
Unified · Split
| @@ -1440,7 +1440,9 @@ void ff_aac_dsp_init(AACEncContext *s){ · 1439 unmodified lines | ||
| 1440 | 1440 | s->abs_pow34 = abs_pow34_v; |
| 1441 | 1441 | s->quant_bands = quantize_bands; |
| 1442 | 1442 | |
| 1443 | −#if ARCH_X86 | |
| 1443 | +#if ARCH_RISCV | |
| 1444 | + ff_aac_dsp_init_riscv(s); | |
| 1445 | +#elif ARCH_X86 | |
| 1444 | 1446 | ff_aac_dsp_init_x86(s); |
| 1445 | 1447 | #endif |
| 1446 | 1448 | |
| @@ -155,6 +155,7 @@ typedef struct AACEncContext { · 154 unmodified lines | ||
| 155 | 155 | } AACEncContext; |
| 156 | 156 | |
| 157 | 157 | void ff_aac_dsp_init(AACEncContext *s); |
| 158 | +void ff_aac_dsp_init_riscv(AACEncContext *s); | |
| 158 | 159 | void ff_aac_dsp_init_x86(AACEncContext *s); |
| 159 | 160 | void ff_aac_coder_init_mips(AACEncContext *c); |
| 160 | 161 | void ff_quantize_band_cost_cache_init(struct AACEncContext *s); |
| @@ -1,5 +1,7 @@ | ||
| 1 | 1 | OBJS-$(CONFIG_AAC_DECODER) += riscv/aacpsdsp_init.o riscv/sbrdsp_init.o |
| 2 | 2 | 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 | |
| 3 | 5 | OBJS-$(CONFIG_AC3DSP) += riscv/ac3dsp_init.o |
| 4 | 6 | RV-OBJS-$(CONFIG_AC3DSP) += riscv/ac3dsp_rvb.o |
| 5 | 7 | RVV-OBJS-$(CONFIG_AC3DSP) += riscv/ac3dsp_rvv.o |
| @@ -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 | +} | |
| @@ -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 | |