From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 9CFBE46321 for ; Thu, 15 Jun 2023 10:37:54 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0D09568C533; Thu, 15 Jun 2023 13:37:04 +0300 (EEST) Received: from zg8tmja2lje4os4yms4ymjma.icoremail.net (zg8tmja2lje4os4yms4ymjma.icoremail.net [206.189.21.223]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2591868C519 for ; Thu, 15 Jun 2023 13:36:57 +0300 (EEST) Received: from host042-ubuntu-1804.lxd (unknown [10.12.130.38]) by app1 (Coremail) with SMTP id EwgMCgDnhMS_6Ypk6XcmAA--.44896S10; Thu, 15 Jun 2023 18:36:54 +0800 (CST) From: Peiting Shen To: ffmpeg-devel@ffmpeg.org Date: Thu, 15 Jun 2023 10:36:45 +0000 Message-Id: <20230615103645.25778-7-shenpeiting@eswincomputing.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230615103645.25778-1-shenpeiting@eswincomputing.com> References: <20230615103645.25778-1-shenpeiting@eswincomputing.com> X-CM-TRANSID: EwgMCgDnhMS_6Ypk6XcmAA--.44896S10 X-Coremail-Antispam: 1UD129KBjvJXoWxGF17tF4xZrW5GFyxGFy3Jwb_yoWrGFW8pF 4fWr13Gr1fJrZrCas3CFWrXr4rK34rWFn5Jrnrur42vr4jq3yxXrnFyryay34qqFZxAFyY 9w1rK3W3CF18J3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBS14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26r4j6ryUM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY02Avz4vE-syl42xK82 IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC2 0s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1Y6r17MIIYrxkI7VAKI48JMI IF0xvE2Ix0cI8IcVAFwI0_Gr0_Xr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF 0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJwCI42IY6I8E87 Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfU80PSUUUUU X-CM-SenderInfo: hvkh01phlwx03j6h245lqf0zpsxwx03jof0z/ Subject: [FFmpeg-devel] [PATCH 6/6] lavc/ac3dsp: RISC-V B ac3_extract_exponents X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Shen Peiting MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Shen Peiting 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 Co-Authored by: Huang Xing Co-Authored by: Zeng Fanchen Signed-off-by: Shen Peiting --- 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".