From patchwork Fri Dec 29 11:57:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: flow gg X-Patchwork-Id: 45384 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6623:b0:194:e134:edd4 with SMTP id n35csp4726515pzh; Fri, 29 Dec 2023 03:57:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IE0EiVv5Eru4WRq5Is5799zqwcL4F5eIcXdgmwtGaQ4T33w+vHCN4HhSDtHvNztN5STCkPM X-Received: by 2002:a17:907:948a:b0:a23:8929:97cc with SMTP id dm10-20020a170907948a00b00a23892997ccmr6856694ejc.4.1703851062538; Fri, 29 Dec 2023 03:57:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703851062; cv=none; d=google.com; s=arc-20160816; b=t/uX+I+BEb2GxfbMIZ3aNomUW1u1MSeaDffKud4IplWz5wzEh9KbLISYu1gQXLWztm eIe6Zck0YhDALTscVEXe3bCBJaeUfxxCakcwjjvWjLJRoDnLMIMxQxmiVWC0c/01PTxe teXY+Ws5Qm4ixvMKJvpneJzLtWKJTz1mYzS/BDhol8pFy3L8YhSqPiENDn0R83bIOFn8 uE+yIyKkBWedUZp4NW/0I3zYYiQRI9PfR5TJovddhlG1iqOIo9ERz/K/tA6F4Gdpfhx0 B7PJInlC1dBINA9SlsIar+oysIgm9VY1Td9vhHRfoGFr4Yooc2eglzFFRPlFkntmj2PV dC/A== 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=JUBanRKLsSgwf2SB068eCD4vesdp02zWHfmb0apStLw=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=ebVyu+iTJpV+YkKZgX5FK54AlbhvrRAUhuguGdfLzWJiWo7dPz1EwNvPYlGqDqvRRc WJBuNz4TxJKh3/HYnupo/l8zTYX5GGWDV4Fd/1sUXg1913FU80N/6wTDiY/JOx8tvUWY KF95EkhwLcFn2DtjbPMMeGwAIQGjO88x8KrAvi5NBVq4Dm+Z32VO358B6BhiSvjVWOrU tfip3gLe5UuuDny89knpOevN+/64b9tOJJRvztzwMvM+BWxE7zdADkqhkhaFeJD0i2Lz eSd21CrSOD4aBBdruWbpcKKg6Mc5+xQNbTM1qgMJM3VeS0vFppux7A/iUBxl82APmczy Iybg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b="d4Qz/3sU"; 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 wi21-20020a170906fd5500b00a26ac400698si6595748ejb.17.2023.12.29.03.57.42; Fri, 29 Dec 2023 03:57:42 -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="d4Qz/3sU"; 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 66D5768CD8E; Fri, 29 Dec 2023 13:57:39 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oi1-f171.google.com (mail-oi1-f171.google.com [209.85.167.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 96DD868CCE5 for ; Fri, 29 Dec 2023 13:57:32 +0200 (EET) Received: by mail-oi1-f171.google.com with SMTP id 5614622812f47-3bbbd4d2b4aso2083054b6e.0 for ; Fri, 29 Dec 2023 03:57:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703851051; x=1704455851; darn=ffmpeg.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=eDMWANjghN8pN1E8p1ptxF3DEN1ua6d5YFXS/d2bsNY=; b=d4Qz/3sUmVuTWOASwXnwMA8i7GNDeP0Che5oR8CntVwjKJZoUN0do5bGSZQB/DWBvA BFjj4KjjpqBE7kjb5aqQgoeiJk40J246ngXpPPDuSlaXvoxRhxcMOq1rZLumeHyC6Rvd f82RgVv5eudBUosZjHPUQ4J8cDu53h0cQx1l1b69mHutDiPlX/qHs+66jtbzj3tEculm Z2QDoSt+Y/OsTkTlKLNgFM30BI78lbBvlUMUqZwq64D5l6gnmJbJxRQq7HjQun897Kfs eLxMVvr89gnKB+83JUVwkcEdkUktW+aF5xhylneYLTyBoaC7/e1tj78HMcwZZpTv8Ap7 d/jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703851051; x=1704455851; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=eDMWANjghN8pN1E8p1ptxF3DEN1ua6d5YFXS/d2bsNY=; b=KHLYwpf4TAKJdxnl5+9W+lnUv2iQiso4Ki59ouJgze8GEA0mmd/6kZuXnMG2e63SGT SPforFxPVXZq18bMEEJJAIh5UEp6L+WYJIsRSncy451xc4Xv9fU/Vs4lKYXN0PGhDd5p WRsMChWraHFLyf83tiMhqrcz8Fc3fzTGgkGdCYdP2aQmcM46x9ccI2hZOrao/aKvdX5z sQFyoKAvO1yG2X5P2ZeVdrf+Zpk0ywsYXV7QlC2JbQiwpCi1Hb32/riftddOQA8w76Tx SiogEQ8lgXxnwDth1CO7xMjViPuS6JatUs8p7uAaE4M1ETr3TnEWflWEbDfbW6cs3036 Rr1w== X-Gm-Message-State: AOJu0YyIX8y3yPh/bTvIlAyJ45u9x9BJNK6KxTjIfNCXVPejRpjqX/12 CAEBiMFeqiV3AytcCxtLPRPe8TqxQIDdXxlQ5tsP+JpFFv4iGv7bGvQ= X-Received: by 2002:a05:6808:3c90:b0:3bb:c393:662c with SMTP id gs16-20020a0568083c9000b003bbc393662cmr6243353oib.15.1703851051059; Fri, 29 Dec 2023 03:57:31 -0800 (PST) MIME-Version: 1.0 From: flow gg Date: Fri, 29 Dec 2023 19:57:20 +0800 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: [FFmpeg-devel] [PATCH 3/3] lavc/svq1enc: R-V V ssd_int8_vs_int16 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: 8/bUYC9z9s1P C908 ssd_int8_vs_int16_c: 207.7 ssd_int8_vs_int16_rvv_i32: 28.0 From 0fd1b7a34ab8794868d80233c35f70c8ad42b9fa Mon Sep 17 00:00:00 2001 From: sunyuechi Date: Fri, 29 Dec 2023 13:27:31 +0800 Subject: [PATCH 3/3] lavc/svq1enc: R-V V ssd_int8_vs_int16 C908 ssd_int8_vs_int16_c: 207.7 ssd_int8_vs_int16_rvv_i32: 28.0 --- libavcodec/riscv/Makefile | 2 ++ libavcodec/riscv/svqenc_init.c | 41 ++++++++++++++++++++++++++++++ libavcodec/riscv/svqenc_rvv.S | 46 ++++++++++++++++++++++++++++++++++ libavcodec/svq1enc.c | 2 ++ libavcodec/svq1encdsp.h | 1 + 5 files changed, 92 insertions(+) create mode 100644 libavcodec/riscv/svqenc_init.c create mode 100644 libavcodec/riscv/svqenc_rvv.S diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index 7f253bba12..4e14c3d094 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -46,6 +46,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_SVQ1_ENCODER) += riscv/svqenc_init.o +RVV-OBJS-$(CONFIG_SVQ1_ENCODER) += riscv/svqenc_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 diff --git a/libavcodec/riscv/svqenc_init.c b/libavcodec/riscv/svqenc_init.c new file mode 100644 index 0000000000..f4c398960c --- /dev/null +++ b/libavcodec/riscv/svqenc_init.c @@ -0,0 +1,41 @@ +/* + * 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 "config.h" + +#include "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libavcodec/svq1encdsp.h" + +int ff_ssd_int8_vs_int16_rvv(const int8_t *pix1, const int16_t *pix2, + intptr_t size); + +av_cold void ff_svq1enc_init_riscv(SVQ1EncDSPContext *c) +{ +#if HAVE_RVV + int flags = av_get_cpu_flags(); + + if (flags & AV_CPU_FLAG_RVV_I32) { + if (flags & AV_CPU_FLAG_RVB_ADDR) { + c->ssd_int8_vs_int16 = ff_ssd_int8_vs_int16_rvv; + } + } +#endif +} diff --git a/libavcodec/riscv/svqenc_rvv.S b/libavcodec/riscv/svqenc_rvv.S new file mode 100644 index 0000000000..426bbe2c4a --- /dev/null +++ b/libavcodec/riscv/svqenc_rvv.S @@ -0,0 +1,46 @@ +/* + * 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_ssd_int8_vs_int16_rvv, zve32x + vsetvli t0, zero, e32, m8, ta, ma + vmv.v.x v24, zero +1: + vsetvli t0, a2, e8, m2, ta, ma + vle8.v v0, (a0) + sub a2, a2, t0 + vsetvli zero, t0, e16, m4, ta, ma + vle16.v v8, (a1) + vsetvli zero, t0, e32, m8, ta, ma + vsext.vf4 v16, v0 + vsext.vf2 v0, v8 + vsub.vv v16, v16, v0 + add a0, a0, t0 + vmacc.vv v24, v16, v16 + sh1add a1, t0, a1 + bnez a2, 1b + vsetvli t0, zero, e32, m8, ta, ma + vmv.s.x v0, zero + vredsum.vs v0, v24, v0 + vmv.x.s a0, v0 + + ret +endfunc diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c index 0dea405dec..6e7ea12aa7 100644 --- a/libavcodec/svq1enc.c +++ b/libavcodec/svq1enc.c @@ -766,6 +766,8 @@ void ff_svq1enc_init(SVQ1EncDSPContext *c) #if ARCH_PPC ff_svq1enc_init_ppc(c); +#elif ARCH_RISCV + ff_svq1enc_init_riscv(c); #elif ARCH_X86 ff_svq1enc_init_x86(c); #endif diff --git a/libavcodec/svq1encdsp.h b/libavcodec/svq1encdsp.h index 618bf8463b..5dfa35cc62 100644 --- a/libavcodec/svq1encdsp.h +++ b/libavcodec/svq1encdsp.h @@ -30,6 +30,7 @@ typedef struct SVQ1EncDSPContext { void ff_svq1enc_init(SVQ1EncDSPContext *c); void ff_svq1enc_init_ppc(SVQ1EncDSPContext *c); +void ff_svq1enc_init_riscv(SVQ1EncDSPContext *c); void ff_svq1enc_init_x86(SVQ1EncDSPContext *c); #endif /* AVCODEC_SVQ1ENCDSP_H */ -- 2.43.0