From patchwork Mon Dec 18 15:15:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: flow gg X-Patchwork-Id: 45228 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1225:b0:181:818d:5e7f with SMTP id v37csp7401809pzf; Mon, 18 Dec 2023 07:16:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IHP7BjRTIH0AufgiZL9jhi1I3wy6Ldb8i/8dbm/OhqGpU8u3lPPqQDq2Net6wQ5cTqYW4ew X-Received: by 2002:a05:600c:1e0c:b0:40d:1c37:c4fd with SMTP id ay12-20020a05600c1e0c00b0040d1c37c4fdmr401923wmb.175.1702912563845; Mon, 18 Dec 2023 07:16:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702912563; cv=none; d=google.com; s=arc-20160816; b=q7jUrer9xcFZBNHBKaTus9gMzupxXhJ1N2+6crsqtU5HJcJUd8djV/gZAWQwcFMK6U OIuT9JGN91uCsuMWo/bm/XoBb4rsDMJq5+fjDhRxD7cjd+xkQJtqR3k0KfRIW6O69giq cKQgEen7ZUNalPLkEzvM3Lrcq86OiL7gfEV87huOQwiSuadi2WwjfpeIdwG8jQZLO93D qRK5DKcYkfUSvYrIE+d1PWqtp9J2ZVKL4wr3he2iG4hF/urLuLM4t0BvxRwEpXaXzDlx on78SkUtMOClCQnJwLumhPWjAIhii0OqwZtgMCXoqYhwe1iSp6DvEqOmnjZ4WdZ/+lRK syIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :message-id:date:from:mime-version:dkim-signature:delivered-to; bh=RkM7MlBWKfQbe+w0QrLshHZ/5CG4vyrESGa+5NNbXAU=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=V6X183Gw3pdkVlfa7KDoYK11qx4g2daAcGbtSGDH/mrYJ+9UMjjfftLHcnTqhi4HDt d86Vbl+yNYxOLFJnXorRuYep510OK9CCVCGDYdyyj2vN/LztKPBNi3SuZgF/hGg8zua6 +sBJDYqK8hvjdguXxtCLAVdZLQblg2ik5fUT9AoEmyFv9jea2j9cAiDbbVi0UPlZFVwC gDKYORCvxD+ZrvewKc/4qH3NJ1wieb+W/N+4Lkx7Vk47Ryf3SAXW/QwQaQcWnWxtBJjG 1/03Qr4xdHKcWpEqUrGRZO8IMh7e67o1WxEVmquZtOnAM/WKOJtnwN1kHfE9yZk9T/1Z 8DGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=X3bFw9aU; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id gt19-20020a170906f21300b00a23490602a1si1379364ejb.84.2023.12.18.07.16.03; Mon, 18 Dec 2023 07:16:03 -0800 (PST) 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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=X3bFw9aU; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 389E868D294; Mon, 18 Dec 2023 17:16:01 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oi1-f172.google.com (mail-oi1-f172.google.com [209.85.167.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7EB3468CFAA for ; Mon, 18 Dec 2023 17:15:54 +0200 (EET) Received: by mail-oi1-f172.google.com with SMTP id 5614622812f47-3b9f8c9307dso3213663b6e.0 for ; Mon, 18 Dec 2023 07:15:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702912552; x=1703517352; darn=ffmpeg.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=IMLrxox4igr3rotY3+NXs3gCwsMJlJYMfxoWX7NEuBc=; b=X3bFw9aU7dJaQ7RSM6+KzAdCeChHpHXEKgpy6mzjaDMvK0OoHoX7VghiwUMiSzRdC0 nJINmEypiK33vUfNhhc9qC+vMph0/Px9I4nygjG2xN7a/xOazjlgloDGR6m5WWV0DpuG NECnduK/kNraNGxeX12mG08X75dtbstsZMmyuVlJOXE0jErygEimfZcAn8vpyzVfOkG0 Fbuvsg+3m+0/OgIrnjIa0wQSyYnRl3Agls9uLJDFoIyaUvFeBLV55tu7TLHw0xop4Ay8 Qa8A62uQ6rQrpAO4NGuIpR4czVHtEw/Y1t8GbTbNmZMXIu6Walhx0ECqUf4tnm3BzDIf 6Qmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702912552; x=1703517352; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=IMLrxox4igr3rotY3+NXs3gCwsMJlJYMfxoWX7NEuBc=; b=a8hQkfuWKiBZGvzhcOnYieLAvj9nSMktF8SZgREa3Fmb2DkTkoDG1eV6PeFpI1EZhD pb9nE80kIrFj4D6qWaihLo8mcmWbC++cb7Q7Nc8rOOCXZocT/wtHZtPJHjquvJevt3Ph LqwHTWgop4QmzKWEq7j9I5/sS12xqFDOn11+SHf8O2fmtyGpUyTmdqGtLLB+f7su4ern YEuaz7YTLrBfISFR4X12zNfKFgnf2Q6NYKhVUs+suq69cneru0Kjr/SIrQl4bwIo3juW Ii80lrWSgKUtLS0UtMi0kPipss0rz7GdCSmzJpQReeLvf5flLcrmIEuxmnpLVuibkThI n8PQ== X-Gm-Message-State: AOJu0Yz7Z/QMXS3DeFTnNZPEXd5Pz2c+d9Kwb2ZOzK0Cri7JqqqdyNEx zdofh5ecZ5YqLprbmLSuhXtppjsm9m/wnYrZNzhf6phnJJG5QGf7 X-Received: by 2002:a05:6358:419d:b0:170:936d:8afe with SMTP id w29-20020a056358419d00b00170936d8afemr20481938rwc.49.1702912552524; Mon, 18 Dec 2023 07:15:52 -0800 (PST) MIME-Version: 1.0 From: flow gg Date: Mon, 18 Dec 2023 23:15:41 +0800 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: [FFmpeg-devel] [PATCH 4/6] lavc/takdsp: R-V V decorrelate_ls 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: Tm4iYUVGw+BU C908: decorrelate_ls_c: 69.7 decorrelate_ls_rvv_i32: 27.2 From 03fad46e6db1846596c31918fc4e34b58246efc4 Mon Sep 17 00:00:00 2001 From: sunyuechi Date: Mon, 18 Dec 2023 22:49:21 +0800 Subject: [PATCH 4/6] lavc/takdsp: R-V V decorrelate_ls C908: decorrelate_ls_c: 69.7 decorrelate_ls_rvv_i32: 27.2 --- libavcodec/riscv/Makefile | 2 ++ libavcodec/riscv/takdsp_init.c | 39 ++++++++++++++++++++++++++++++++++ libavcodec/riscv/takdsp_rvv.S | 35 ++++++++++++++++++++++++++++++ libavcodec/takdsp.c | 4 +++- libavcodec/takdsp.h | 1 + 5 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 libavcodec/riscv/takdsp_init.c create mode 100644 libavcodec/riscv/takdsp_rvv.S diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index 6f7cb8791f..aa758eba1c 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -42,6 +42,8 @@ RVV-OBJS-$(CONFIG_OPUS_DECODER) += riscv/opusdsp_rvv.o OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_init.o RV-OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_rvi.o RVV-OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_rvv.o +OBJS-$(CONFIG_TAK_DECODER) += riscv/takdsp_init.o +RVV-OBJS-$(CONFIG_TAK_DECODER) += riscv/takdsp_rvv.o OBJS-$(CONFIG_UTVIDEO_DECODER) += riscv/utvideodsp_init.o RVV-OBJS-$(CONFIG_UTVIDEO_DECODER) += riscv/utvideodsp_rvv.o OBJS-$(CONFIG_VC1DSP) += riscv/vc1dsp_init.o diff --git a/libavcodec/riscv/takdsp_init.c b/libavcodec/riscv/takdsp_init.c new file mode 100644 index 0000000000..fcf0c5f37b --- /dev/null +++ b/libavcodec/riscv/takdsp_init.c @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Institue of Software Chinese Academy of Sciences (ISCAS). + * + * 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 + +#include "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libavutil/riscv/cpu.h" +#include "libavcodec/takdsp.h" + +void ff_decorrelate_ls_rvv(int32_t *p1, int32_t *p2, int length); + +av_cold void ff_takdsp_init_riscv(TAKDSPContext *dsp) +{ +#if HAVE_RVV + int flags = av_get_cpu_flags(); + + if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB_ADDR)) { + dsp->decorrelate_ls = ff_decorrelate_ls_rvv; + } +#endif +} diff --git a/libavcodec/riscv/takdsp_rvv.S b/libavcodec/riscv/takdsp_rvv.S new file mode 100644 index 0000000000..00e8e38fdf --- /dev/null +++ b/libavcodec/riscv/takdsp_rvv.S @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Institue of Software Chinese Academy of Sciences (ISCAS). + * + * 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_decorrelate_ls_rvv, zve32x +1: + vsetvli t0, a2, e32, m8, ta, ma + vle32.v v0, (a0) + sub a2, a2, t0 + vle32.v v8, (a1) + vadd.vv v16, v0, v8 + vse32.v v16, (a1) + sh2add a0, t0, a0 + sh2add a1, t0, a1 + bnez a2, 1b + ret +endfunc diff --git a/libavcodec/takdsp.c b/libavcodec/takdsp.c index b646a063db..25cac558ce 100644 --- a/libavcodec/takdsp.c +++ b/libavcodec/takdsp.c @@ -77,7 +77,9 @@ av_cold void ff_takdsp_init(TAKDSPContext *c) c->decorrelate_sm = decorrelate_sm; c->decorrelate_sf = decorrelate_sf; -#if ARCH_X86 +#if ARCH_RISCV + ff_takdsp_init_riscv(c); +#elif ARCH_X86 ff_takdsp_init_x86(c); #endif } diff --git a/libavcodec/takdsp.h b/libavcodec/takdsp.h index c05b5741a4..55f1a10cd3 100644 --- a/libavcodec/takdsp.h +++ b/libavcodec/takdsp.h @@ -29,6 +29,7 @@ typedef struct TAKDSPContext { } TAKDSPContext; void ff_takdsp_init(TAKDSPContext *c); +void ff_takdsp_init_riscv(TAKDSPContext *c); void ff_takdsp_init_x86(TAKDSPContext *c); #endif /* AVCODEC_TAKDSP_H */ -- 2.43.0