From patchwork Mon Aug 12 17:16:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= X-Patchwork-Id: 50994 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:1ff2:b0:489:2eb3:e4c4 with SMTP id ks18csp1500462vqb; Mon, 12 Aug 2024 10:16:25 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWDjAiY6+6V1J2qWkBNG4NodgQTSzJmFhwUGf4NLMwHql53XBus7oOwXe88fMmDT8jXrJ7vTt/TMBultDk11wUP9xhOOnY4csS5rA== X-Google-Smtp-Source: AGHT+IEG1EsNKPcfDYJOYBAL15zFZWA+TbdAhFCxBWR5RT0xrQFbsjJ/9Ig1+WlSgpQmTwHROLNw X-Received: by 2002:a05:6402:90e:b0:5a1:22d:b0ff with SMTP id 4fb4d7f45d1cf-5bd44c77c76mr582083a12.35.1723482984803; Mon, 12 Aug 2024 10:16:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723482984; cv=none; d=google.com; s=arc-20160816; b=xALjUa9kfg+3vwZBCmQmq5HGsH2zEXWl6CswQadIbX6n6q5UWCdhTo8AdyqxWdJ+/e oCwHxHpzlhosbrRKRdaXowSgOTXRBVeBMuMpcEP677Uq6kQSZm05l4KvK0gvSB8/VdPU SuGjwFMcixBrVWCsSiPXLfRUwfdlfptwnhG2O8EbONr1oYNCbOBlUmQYllpVDU7qopL6 PN2cUF4jq/SZ9Q64geqEJnmzgjaNs+sxN+e9/zYSCFIbuwI7+Jujwz/KcfQ0RS8iJcyk JlHZFOIJWPW4555bWDkOckbylbFF9taqdTsZ8IYILf20MDPCrfsyiJybUioqJcq7+x5Y A4jw== 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=xJwD9xZlXhGckBox67Ur2iEea0wqlU71r42i/NFMU8k=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=awfsYaI6KQuOt8MfimcdvORztjMDIrbGMxhRk/S8FYbWR9PqMjCgzzc/K2YuTcKMWb s5K1KDxJUNafHk8HPoK+rdFNd6lnWG1uERG1Vxm8heMw65gWeCPWLUUri/tvGB+Kwqd7 nmYY8tWsSCSR4lkzTUDtJz3Nu3SsvU5FROYWKpa8b8/LpZPNrCrwYLbVW0kUp38pWJKR b60lhq9lAfFia8ZX5xpS4H1ue+zURN/tJ4YJtaLcDIrAhfT5OszEJrqcSUfIkyHRFDQe DdUXPBnWMzbNmCepclrYaZ4r12L2KltjxK5wXvyvVx4HFp7clD8esBqXXLfCJTixWmKt sW9g==; dara=google.com 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 4fb4d7f45d1cf-5bd1a636e96si3226808a12.597.2024.08.12.10.16.24; Mon, 12 Aug 2024 10:16:24 -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 2B20068DA2C; Mon, 12 Aug 2024 20:16:21 +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 2236968D0AD for ; Mon, 12 Aug 2024 20:16:14 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 8D2A9C0140 for ; Mon, 12 Aug 2024 20:16:13 +0300 (EEST) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 12 Aug 2024 20:16:13 +0300 Message-ID: <20240812171613.16049-1-remi@remlab.net> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lavc/mpegvideoencdsp: R-V V pix_norm1 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: BDLUAompji9A T-Head C908: pix_norm1_c: 480.2 pix_norm1_rvv_i64: 146.9 SpacemiT X60: pix_norm1_c: 478.2 pix_norm1_rvv_i64: 92.7 --- libavcodec/riscv/mpegvideoencdsp_init.c | 9 ++++++--- libavcodec/riscv/mpegvideoencdsp_rvv.S | 27 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/libavcodec/riscv/mpegvideoencdsp_init.c b/libavcodec/riscv/mpegvideoencdsp_init.c index cae37ef7e1..eb5c8a5aed 100644 --- a/libavcodec/riscv/mpegvideoencdsp_init.c +++ b/libavcodec/riscv/mpegvideoencdsp_init.c @@ -24,6 +24,7 @@ #include "libavcodec/mpegvideoencdsp.h" int ff_pix_sum_rvv(const uint8_t *pix, int line_size); +int ff_pix_norm1_rvv(const uint8_t *pix, int line_size); av_cold void ff_mpegvideoencdsp_init_riscv(MpegvideoEncDSPContext *c, AVCodecContext *avctx) @@ -31,8 +32,10 @@ av_cold void ff_mpegvideoencdsp_init_riscv(MpegvideoEncDSPContext *c, #if HAVE_RVV int flags = av_get_cpu_flags(); - if ((flags & AV_CPU_FLAG_RVV_I64) && (flags & AV_CPU_FLAG_RVB) && - ff_rv_vlen_least(128)) - c->pix_sum = ff_pix_sum_rvv; + if (flags & AV_CPU_FLAG_RVV_I64) { + if ((flags & AV_CPU_FLAG_RVB) && ff_rv_vlen_least(128)) + c->pix_sum = ff_pix_sum_rvv; + c->pix_norm1 = ff_pix_norm1_rvv; + } #endif } diff --git a/libavcodec/riscv/mpegvideoencdsp_rvv.S b/libavcodec/riscv/mpegvideoencdsp_rvv.S index 83cd919b7c..2f25b00eb2 100644 --- a/libavcodec/riscv/mpegvideoencdsp_rvv.S +++ b/libavcodec/riscv/mpegvideoencdsp_rvv.S @@ -44,3 +44,30 @@ func ff_pix_sum_rvv, zve64x, b zext.h a0, a0 ret endfunc + +func ff_pix_norm1_rvv, zve64x + lpad 0 + li t1, 16 + vsetvli t0, zero, e32, m8, ta, ma + vmv.v.x v16, zero + vmv.s.x v1, zero +1: + vsetvli t0, t1, e64, m2, ta, ma + vlsseg2e64.v v8, (a0), a1 + slli t2, t0, 3 + vsetvli zero, t2, e8, m2, ta, ma + vwmulu.vv v24, v8, v8 + sub t1, t1, t0 + vwmulu.vv v28, v10, v10 + mul t3, a1, t0 + vsetvli zero, zero, e16, m4, tu, ma + vwaddu.wv v16, v16, v24 + add a0, t3, a0 + vwaddu.wv v16, v16, v28 + bnez t1, 1b + + vsetvli zero, zero, e32, m8, ta, ma + vredsum.vs v1, v16, v1 + vmv.x.s a0, v1 + ret +endfunc