From patchwork Tue Aug 15 18:41:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= X-Patchwork-Id: 43232 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4c9d:b0:130:ccc6:6c4b with SMTP id fq29csp764668pzb; Tue, 15 Aug 2023 11:41:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEaX6b6rHh1sAAdCgzBw2mmvfq9kbrJszQsR8FbBcXFD4OlWGW1T6z6N/QDX+5IVkPYmu1+ X-Received: by 2002:a05:6402:148d:b0:522:b876:9ef5 with SMTP id e13-20020a056402148d00b00522b8769ef5mr2954203edv.8.1692124913079; Tue, 15 Aug 2023 11:41:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692124913; cv=none; d=google.com; s=arc-20160816; b=TvovoxrkMFPjso3JjJIJwPvClrBeK8D6Mp3iNB4hNS7CELi4g7eC2LkWdR+T76kFjh zOx5fEnYzKPtWPaGujiHQTNszPLUsFDDMrqT1QBNWZkGZpHduhEpx/a42yQpgakgZmVP UO3qrQYM5RuEOEbv+V+Ok4s/gLlPKs+sTTwc8+CR4aSNhs8cDpyl+J4pahgvct7CWipH WjRTz1OqRkBgnqQ3DrsMfTlj+FwYZpiwB5sTpG0+IrcFFLZni2NWTVVWAN+Jst63rGMl IoY1B4reWUzRjUFH9JYSzMwZWFTogeLwodP2NLQJJT3B/D63GLXEtBVtwDnWOzSQLMgk uJmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=mgBm6/1Z3vnwRVe0Gi77lduxV0Erl/OR7v48+2GslOg=; fh=hQcp50obTJ8bXC1it5NuEN23RGKfx0/zZ3s2gmreL+A=; b=HUKOT0/pNG7V/r43Rw8KStqiTvK6AV02CEtjuw+tJtSxkR8DoAD7BH139/958WG6Vm z87jgH6uocAqVN0bYkkgk2ZNMVQPChanH4YbfgdywqZLGYmQDXcEJPI+8TfBm14wQpj3 XqkMkWwBKzIlfXUgEDsXuHOjAAkmbCq/Krv4h/BQUCrhOIe15wf5+PLekEaGGUcHRp1Z zqOugqMj854lzNiwAIA1RXsiKMK+b/Y/Hfv6GbPqsh/P2K6YZV2Y2DXgLgEnAnDvsy31 tq6cHH9E6cXAI2VsM2oZHeZdOPhEsKo3NDBE6WfKogT14ShaH719LYmzcceAo0BNEK4X +j+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id w19-20020aa7dcd3000000b00523268929e6si9828493edu.346.2023.08.15.11.41.52; Tue, 15 Aug 2023 11:41:53 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EF10F68C6F7; Tue, 15 Aug 2023 21:41:48 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from ursule.remlab.net (vps-a2bccee9.vps.ovh.net [51.75.19.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6F84068C53F for ; Tue, 15 Aug 2023 21:41:41 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 08BE9C00C0 for ; Tue, 15 Aug 2023 21:41:40 +0300 (EEST) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Tue, 15 Aug 2023 21:41:40 +0300 Message-Id: <20230815184140.63736-1-remi@remlab.net> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lavc/g722dsp: add RISC-V V DSP function 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: GIxWg5DZvtT7 --- libavcodec/g722dsp.c | 2 + libavcodec/g722dsp.h | 1 + libavcodec/riscv/Makefile | 2 + libavcodec/riscv/g722dsp_init.c | 40 ++++++++++++++++++++ libavcodec/riscv/g722dsp_rvv.S | 66 +++++++++++++++++++++++++++++++++ 5 files changed, 111 insertions(+) create mode 100644 libavcodec/riscv/g722dsp_init.c create mode 100644 libavcodec/riscv/g722dsp_rvv.S diff --git a/libavcodec/g722dsp.c b/libavcodec/g722dsp.c index c770bfbdff..302283688f 100644 --- a/libavcodec/g722dsp.c +++ b/libavcodec/g722dsp.c @@ -71,6 +71,8 @@ av_cold void ff_g722dsp_init(G722DSPContext *c) #if ARCH_ARM ff_g722dsp_init_arm(c); +#elif ARCH_RISCV + ff_g722dsp_init_riscv(c); #elif ARCH_X86 ff_g722dsp_init_x86(c); #endif diff --git a/libavcodec/g722dsp.h b/libavcodec/g722dsp.h index c956a1e161..1aa7078a29 100644 --- a/libavcodec/g722dsp.h +++ b/libavcodec/g722dsp.h @@ -29,6 +29,7 @@ typedef struct G722DSPContext { void ff_g722dsp_init(G722DSPContext *c); void ff_g722dsp_init_arm(G722DSPContext *c); +void ff_g722dsp_init_riscv(G722DSPContext *c); void ff_g722dsp_init_x86(G722DSPContext *c); #endif /* AVCODEC_G722DSP_H */ diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index ee17a521fd..77bba7f784 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -10,6 +10,8 @@ OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_init.o \ RVV-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvv.o OBJS-$(CONFIG_FMTCONVERT) += riscv/fmtconvert_init.o RVV-OBJS-$(CONFIG_FMTCONVERT) += riscv/fmtconvert_rvv.o +OBJS-$(CONFIG_G722DSP) += riscv/g722dsp_init.o +RVV-OBJS-$(CONFIG_G722DSP) += riscv/g722dsp_rvv.o OBJS-$(CONFIG_H264CHROMA) += riscv/h264_chroma_init_riscv.o RVV-OBJS-$(CONFIG_H264CHROMA) += riscv/h264_mc_chroma.o OBJS-$(CONFIG_IDCTDSP) += riscv/idctdsp_init.o diff --git a/libavcodec/riscv/g722dsp_init.c b/libavcodec/riscv/g722dsp_init.c new file mode 100644 index 0000000000..77e29bfb56 --- /dev/null +++ b/libavcodec/riscv/g722dsp_init.c @@ -0,0 +1,40 @@ +/* + * Copyright © 2023 Rémi Denis-Courmont. + * + * 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 + +#include "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libavutil/riscv/cpu.h" +#include "libavcodec/g722dsp.h" + +extern void ff_g722_apply_qmf_rvv(const int16_t *prev_samples, int xout[2]); + +av_cold void ff_g722dsp_init_riscv(G722DSPContext *dsp) +{ +#if HAVE_RVV + int flags = av_get_cpu_flags(); + + if ((flags & AV_CPU_FLAG_RVV_I32) && ff_get_rv_vlenb() >= 16) + dsp->apply_qmf = ff_g722_apply_qmf_rvv; +#endif +} diff --git a/libavcodec/riscv/g722dsp_rvv.S b/libavcodec/riscv/g722dsp_rvv.S new file mode 100644 index 0000000000..350be8dc1f --- /dev/null +++ b/libavcodec/riscv/g722dsp_rvv.S @@ -0,0 +1,66 @@ +/* + * Copyright © 2023 Rémi Denis-Courmont. + * + * 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/riscv/asm.S" + +func ff_g722_apply_qmf_rvv, zve32x + lla t0, qmf_coeffs + vsetivli zero, 12, e16, m2, ta, ma + vlseg2e16.v v28, (a0) + vlseg2e16.v v24, (t0) + vwmul.vv v16, v28, v24 + vwmul.vv v20, v30, v26 + vsetivli zero, 12, e32, m4, ta, ma + vmv.s.x v10, zero + vredsum.vs v8, v16, v10 + vredsum.vs v9, v20, v10 + vmv.x.s t0, v8 + vmv.x.s t1, v9 + sw t0, 4(a1) + sw t1, 0(a1) + ret +endfunc + +const qmf_coeffs, align=2 + .short 3 + .short -11 + .short -11 + .short 53 + .short 12 + .short -156 + .short 32 + .short 362 + .short -210 + .short -805 + .short 951 + .short 3876 + .short 3876 + .short 951 + .short -805 + .short -210 + .short 362 + .short 32 + .short -156 + .short 12 + .short 53 + .short -11 + .short -11 + .short 3 +endconst