From: Peiting Shen <shenpeiting@eswincomputing.com> To: ffmpeg-devel@ffmpeg.org Cc: Shen Peiting <shenpeiting@eswincomputing.com> Subject: [FFmpeg-devel] [PATCH 6/6] lavc/ac3dsp: RISC-V B ac3_extract_exponents Date: Thu, 15 Jun 2023 10:36:45 +0000 Message-ID: <20230615103645.25778-7-shenpeiting@eswincomputing.com> (raw) In-Reply-To: <20230615103645.25778-1-shenpeiting@eswincomputing.com> From: Shen Peiting <shenpeiting@eswincomputing.com> Use RVB instruction clz to calculate the number of leading zeros of MSB instead of av_log2. Benchmarks on Spike(cycles): ac3_extract_exponents_c: 8226 ac3_extract_exponents_rvb: 1167 Co-Authored by: Yang Xiaojun <yangxiaojun@eswincomputing.com> Co-Authored by: Huang Xing <huangxing1@eswincomputing.com> Co-Authored by: Zeng Fanchen <zengfanchen@eswincomputing.com> Signed-off-by: Shen Peiting <shenpeiting@eswincomputing.com> --- libavcodec/riscv/Makefile | 3 ++- libavcodec/riscv/ac3dsp_init.c | 3 +++ libavcodec/riscv/ac3dsp_rvb.S | 42 ++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 libavcodec/riscv/ac3dsp_rvb.S diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index a627924cac..3d0c196cb9 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -1,7 +1,8 @@ OBJS-$(CONFIG_AAC_DECODER) += riscv/aacpsdsp_init.o RVV-OBJS-$(CONFIG_AAC_DECODER) += riscv/aacpsdsp_rvv.o OBJS-$(CONFIG_AC3DSP) += riscv/ac3dsp_init.o -RVV-OBJS-$(CONFIG_AC3DSP) += riscv/ac3dsp_rvv.o +RVV-OBJS-$(CONFIG_AC3DSP) += riscv/ac3dsp_rvv.o \ + riscv/ac3dsp_rvb.o OBJS-$(CONFIG_ALAC_DECODER) += riscv/alacdsp_init.o RVV-OBJS-$(CONFIG_ALAC_DECODER) += riscv/alacdsp_rvv.o OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_init.o \ diff --git a/libavcodec/riscv/ac3dsp_init.c b/libavcodec/riscv/ac3dsp_init.c index 4769213ebc..75cd3c7e11 100644 --- a/libavcodec/riscv/ac3dsp_init.c +++ b/libavcodec/riscv/ac3dsp_init.c @@ -26,6 +26,7 @@ void ff_ac3_exponent_min_rvv(uint8_t *exp, int num_reuse_blocks, int nb_coefs); void ff_float_to_fixed24_rvv(int32_t *dst, const float *src, unsigned int len); +void ff_ac3_extract_exponents_rvb(uint8_t *exp, int32_t *coef, int nb_coefs); void ff_ac3_sum_square_butterfly_int32_rvv(int64_t sum[4], const int32_t *coef0, const int32_t *coef1, @@ -40,6 +41,8 @@ void ff_ac3_compute_mantissa_size_rvv(uint16_t mant_cnt[6][16]); av_cold void ff_ac3dsp_init_riscv(AC3DSPContext *c) { int flags = av_get_cpu_flags(); + if (flags & AV_CPU_FLAG_RVB_BASIC) + c->extract_exponents = ff_ac3_extract_exponents_rvb; #if HAVE_RVV if (flags & AV_CPU_FLAG_RVV_I32) { c->ac3_exponent_min = ff_ac3_exponent_min_rvv; diff --git a/libavcodec/riscv/ac3dsp_rvb.S b/libavcodec/riscv/ac3dsp_rvb.S new file mode 100644 index 0000000000..3bf24c7392 --- /dev/null +++ b/libavcodec/riscv/ac3dsp_rvb.S @@ -0,0 +1,42 @@ +/* + * Copyright 2023 Beijing ESWIN Computing Technology Co., Ltd. + * + * 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 "config.h" +#include "libavutil/riscv/asm.S" + +func ff_ac3_extract_exponents_rvb, zbb + li t1, __riscv_xlen - 24 +1: + lw t0, (a1) + bgez t0, 2f + neg t0, t0 + +2: + clz t4, t0 + sub t4, t4, t1 + sb t4,(a0) + addi a2, a2, -1 + addi a1, a1, 4 + addi a0, a0, 1 + + bgtz a2, 1b + + ret +endfunc \ No newline at end of file -- 2.17.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2023-06-15 10:37 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-06-15 10:36 [FFmpeg-devel] [PATCH 0/6] RISC-V initial ac3dsp Peiting Shen 2023-06-15 10:36 ` [FFmpeg-devel] [PATCH 1/6] lavc/ac3dsp: RISC-V V ac3_exponent_min Peiting Shen 2023-06-15 18:02 ` Rémi Denis-Courmont 2023-06-15 10:36 ` [FFmpeg-devel] [PATCH 2/6] lavc/ac3dsp: RISC-V V float_to_fixed24 Peiting Shen 2023-06-15 18:06 ` Rémi Denis-Courmont 2023-06-15 10:36 ` [FFmpeg-devel] [PATCH 3/6] lavc/ac3dsp: RISC-V V ac3_sum_square_butterfly_int32 Peiting Shen 2023-06-15 19:25 ` Rémi Denis-Courmont 2023-06-16 10:15 ` 沈佩婷 2023-06-15 10:36 ` [FFmpeg-devel] [PATCH 4/6] lavc/ac3dsp: RISC-V V ac3_sum_square_butterfly_float Peiting Shen 2023-06-15 10:36 ` [FFmpeg-devel] [PATCH 5/6] lavc/ac3dsp: RISC-V V ac3_compute_mantissa_size Peiting Shen 2023-06-15 10:36 ` Peiting Shen [this message] 2023-06-15 19:18 ` [FFmpeg-devel] [PATCH 6/6] lavc/ac3dsp: RISC-V B ac3_extract_exponents Rémi Denis-Courmont 2023-06-15 13:57 ` [FFmpeg-devel] [PATCH 0/6] RISC-V initial ac3dsp Lynne 2023-06-15 19:10 ` Rémi Denis-Courmont
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230615103645.25778-7-shenpeiting@eswincomputing.com \ --to=shenpeiting@eswincomputing.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git