From patchwork Sun Jul 14 16:28:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: uk7b@foxmail.com X-Patchwork-Id: 50533 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:2298:b0:482:c625:d099 with SMTP id fp24csp1850255vqb; Sun, 14 Jul 2024 09:29:38 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXIhK/zJDcQUbCIR9Ldn/zMNwcOcIgzjUPnwcSQUkaDQROA9ZPbt0FGn0wnR4CuSMvsgKNobAGqXyO+f54EgRbiAbUyccQe0IWYUw== X-Google-Smtp-Source: AGHT+IGSaPyUZ5nWbAQu7Q451WXMnCc9Rk4HSVi9zZjSD3EP348ynJucBSHdwUkYUFYMD+qY/mfu X-Received: by 2002:a2e:9bcc:0:b0:2ee:493f:d751 with SMTP id 38308e7fff4ca-2eeb30fd3admr120964041fa.23.1720974578009; Sun, 14 Jul 2024 09:29:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720974577; cv=none; d=google.com; s=arc-20160816; b=UHnyPqZBEAMax8NnoHgt9sJPoMTGZqa2G+3ytiQZbkNoLysRyxy+aJkjR79g/kfPVD LCCS0FC/xcxQSrzpXVqWFgGm8jNK0Kxm+tS2aJMnQRcosihY5gfIXPdOtPbH4/DYkqx9 hHuTIIABPHFDUjbUVFegv4AUUh1fIKkRokm2EgsGhKurViaYqPde1y7O1a3dTgKUwMxH tnNMme0Z7cZETgHqzxVz9n2XjD6fBMvB8DwP2r1ejOLG2BftMie/ZAsEMneCZ5oaiVFp awQMdA3bQumpZG2co1+6AH7juLKY1740RsatxNmCC3ARNrjMzM3Brc9WBkaorIHRNxER DrLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to:date :to:from:message-id:dkim-signature:delivered-to; bh=UzGhVyJyxKBN5toiO6LbhsDiVtHYWevNF04Z7RR0XTA=; fh=D0bFwGkf4X22/D/bfeDVrXKIx7S6kcXsNzy10j8ORbQ=; b=GK6Tm003pqBWIo9SNGgwJzhhqxmBgtO07ZbXY9EaN+U/JMLqYZxPUrc7ngeR+ChmRz UjM1Bh9wQFB7twkmdUBMT7xkNK7UFYPoBT439BakNH+YnstUqxFzezD3J7qKsOYMk1y8 dUUuzk0ZKH42cUtCHsMFCDMCROnXZYhLrsSnNBkUyA1JfeUab8k6boKnPq7I75T5RuNl 837lPojI51knRFjxhYy4oKxIvsXfgq6sOHhTrdm8ergCyFiTQO7P2ayGfaXy60RBGTWl I9H9q0QuHclmok7c7qlxlp4eFAcs2iomq+eayfAKXhe1qr5UtwC3zXYKUv90R7zli+VZ 0fjQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=V+pP9oA+; 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=NONE dis=NONE) header.from=foxmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 38308e7fff4ca-2eee19724bfsi9086571fa.637.2024.07.14.09.29.37; Sun, 14 Jul 2024 09:29:37 -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; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=V+pP9oA+; 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=NONE dis=NONE) header.from=foxmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1BE7868D9C7; Sun, 14 Jul 2024 19:29:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from xmbghk7.mail.qq.com (xmbghk7.mail.qq.com [43.163.128.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D187668D7F5 for ; Sun, 14 Jul 2024 19:29:23 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1720974555; bh=PS05g8FxRU7jtvkEjb6XPQKFOXklBN+H7dAnLePff50=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=V+pP9oA+wIUecXjcLO45okVcV4bGbzYeLajGC0tsrzJKdkssrlQn0UPd4cLHS3gha r6h4q7Nk6HIjxb1b9Rq0ONM8y4Gv6z4VUy76wBcu1875JZcPJqit4fJD4gY5PGAEtP feJZYHoPpYisVtcj7JL9MndyXWQ/qrUbnx3qHePs= Received: from localhost.localdomain ([42.57.187.151]) by newxmesmtplogicsvrszb9-0.qq.com (NewEsmtp) with SMTP id 74C3C47E; Mon, 15 Jul 2024 00:29:12 +0800 X-QQ-mid: xmsmtpt1720974554t80i7ssmu Message-ID: X-QQ-XMAILINFO: N5sfBKY/oC4kxGsf5WAq3/4sdhFuTA+G1KNyi61gu44FpdV1sDJLUPClifpqvf +Pnmu/WkwbnrsBJmLbxhpz2191HSB/K66BF/dgU7Z7ZJYXA+MN6W2NJ/DTL+VxwmcF1GK+RuPmBw 08vrGmRTkSiV93E7PDosaXivSlL2e6M9mmD8SDdTRITlpzIuFe4daCXK87jgBfAKLV3gLmlZ2jEF QtLaguyVyHdvesCK14ieQleWutYpHN7GtE0iaOKzGrNA4xYKBClaqrk6oXOQ0Sf+McQmpyhgEIkx JFZW5MDEV4MauAE4Ck8Gncyw3c0xMh3qexIiLmdxD1VPennWwRbTc2LslmgASEXeV+K7Pl08Aelk vGNyvvBrBx7Iq0jBTAlIg9eKtiiMW6EyUMfxTHtB6zOZ6NSR3hx9+hxDzYKzqW9EC2iHELX5ehsV VZgkeCGn73vV8vfXYvrFzO9i1xsLWDv6Vpmq7ZjzC2LEOARoB07eBv/DkvmlzLq+XFaldBzugs1q KVa+6bvP/N7BHK4+5i2IeXU48ZW7aqhVN8cRYNbAeVHI6wWfojV+PwbwfCJLJQyuJcjE/wFfkxrn ezd8t5Xv7LAUejVwJ+cli008ZjCHbshpVutHwJwyHSQ2e1PZIcOONCaWeEtjtg1jcJGzXMP8eBxr OrTIDudrwV9ahvxrnWNYX06OEC4JLVIjqHWIkGzLogx47xNkhDR1en1vCRSGBZWx7qLfe0gXrlw1 vOy+7FpLK2st/bW1uMXcUn60U6jpUIh69DazgKF7nwPaTycKX81g/DnXcjX4YCGAs57g0DJ82uDQ 5ldwxUhYxOxLL9Df6qo0cH5YV/qdRkZX+/uEQLPsxkI7UGdLda/gqg2Cc77M4L7TLnqubJAFAYFB Hx50PBdw6ygDTxS6hlXdb5bkOlhGeSgNYNyOtlB11NIxtDB/+ECg0= X-QQ-XMRINFO: OD9hHCdaPRBwq3WW+NvGbIU= From: uk7b@foxmail.com To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jul 2024 00:28:23 +0800 X-OQ-MSGID: <20240714162824.2728146-3-uk7b@foxmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240714162824.2728146-1-uk7b@foxmail.com> References: <20240714162824.2728146-1-uk7b@foxmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 3/4] lavc/vp8dsp: R-V V loop_filter_inner 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: sunyuechi Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: gisNogqonZrm From: sunyuechi C908 X60 vp8_loop_filter8uv_inner_h_c : 11.0 9.5 vp8_loop_filter8uv_inner_h_rvv_i32 : 10.5 8.7 vp8_loop_filter8uv_inner_v_c : 11.2 11.0 vp8_loop_filter8uv_inner_v_rvv_i32 : 7.7 6.2 vp8_loop_filter16y_inner_h_c : 11.2 9.0 vp8_loop_filter16y_inner_h_rvv_i32 : 8.0 6.2 vp8_loop_filter16y_inner_v_c : 11.5 10.5 vp8_loop_filter16y_inner_v_rvv_i32 : 5.2 3.7 --- libavcodec/riscv/vp8dsp_init.c | 6 ++- libavcodec/riscv/vp8dsp_rvv.S | 90 ++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 1 deletion(-) diff --git a/libavcodec/riscv/vp8dsp_init.c b/libavcodec/riscv/vp8dsp_init.c index 8c5b2c8b04..8cb21b8ceb 100644 --- a/libavcodec/riscv/vp8dsp_init.c +++ b/libavcodec/riscv/vp8dsp_init.c @@ -154,7 +154,11 @@ av_cold void ff_vp8dsp_init_riscv(VP8DSPContext *c) #define init_loop_filter(vlen) \ c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter16_simple_rvv##vlen; \ - c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter16_simple_rvv##vlen; + c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter16_simple_rvv##vlen; \ + c->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16_inner_rvv##vlen; \ + c->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16_inner_rvv##vlen; \ + c->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_rvv##vlen; \ + c->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_rvv##vlen; int flags = av_get_cpu_flags(); diff --git a/libavcodec/riscv/vp8dsp_rvv.S b/libavcodec/riscv/vp8dsp_rvv.S index 3cec4dd135..036872a29e 100644 --- a/libavcodec/riscv/vp8dsp_rvv.S +++ b/libavcodec/riscv/vp8dsp_rvv.S @@ -275,6 +275,13 @@ func ff_vp78_idct_dc_add4uv_rvv, zve64x ret endfunc +.macro filter_abs dst, mask, tmp, diff, fI + vneg.v \tmp, \diff + vmax.vv \dst, \tmp, \diff + vmsleu.vx \tmp, \dst, \fI + vmand.mm \mask, \mask, \tmp +.endm + .macro filter_fmin len, vlen, a, f1, p0f2, q0f1, p0, q0 vsetvlstatic16 \len, \vlen vsext.vf2 \q0f1, \a @@ -299,13 +306,36 @@ endfunc vle8.v v4, (t3) // p0 vle8.v v5, (\dst) // q0 vle8.v v6, (t4) // q1 + .if \normal + sub t1, t2, \stride // -3 + sub t0, t1, \stride // -4 + add t5, t4, \stride // 2 + add t6, t5, \stride // 3 + vle8.v v1, (t0) // p3 + vle8.v v2, (t1) // p2 + vle8.v v7, (t5) // q2 + vle8.v v8, (t6) // q3 + .endif .else addi t2, \dst, -2 addi t3, \dst, -1 + .if \normal + addi t1, \dst, -4 + vlsseg8e8.v v1, (t1), \stride + .else vlsseg4e8.v v3, (t2), \stride + .endif .endif vwsubu.vv v10, v3, v6 // p1-q1 vwsubu.vv v12, v5, v4 // q0-p0 +.if \normal + vwsubu.vv v30, v1, v2 // p3-p2 + vwsubu.vv v28, v2, v3 // p2-p1 + vwsubu.vv v26, v3, v4 // p1-p0 + vwsubu.vv v24, v8, v7 // q3-q2 + vwsubu.vv v22, v7, v6 // q2-q1 + vwsubu.vv v8, v6, v5 // q1-q0 +.endif vnclip.wi v16, v10, 0 // clip_int8(p1 - q1) vsetvlstatic16 \len, \vlen @@ -319,6 +349,24 @@ endfunc vmacc.vx v22, a6, v24 vmsleu.vx v0, v22, \fE +.if \normal + vneg.v v22, v26 + vmax.vv v26, v22, v26 + vmsleu.vx v1, v26, \fI + filter_abs v22, v1, v10, v28, \fI + filter_abs v22, v1, v10, v30, \fI + filter_abs v22, v1, v10, v24, \fI + filter_abs v22, v1, v10, v22, \fI + filter_abs v20, v1, v10, v8, \fI + vzext.vf2 v8, v3 // p1 + vmand.mm v1, v0, v1 // vp8_simple_limit && normal + vmsgtu.vx v26, v26, \thresh // hev: FFABS(p1 - p0) > thresh + vmsgtu.vx v3, v20, \thresh // hev: FFABS(q1 - q0) > thresh + vzext.vf2 v14, v6 // q1 + vmor.mm v3, v3, v26 // FFABS(p1 - p0) > thresh || FFABS(q1 - q0) > thresh + vmand.mm v0, v1, v3 // v0 = normal && hev + vmnot.m v3, v3 // v3 = !hv +.endif li a7, 3 li a6, 124 li t6, 123 @@ -339,6 +387,33 @@ endfunc vssseg2e8.v v30, (t3), \stride, v0.t .endif +.if \normal + vmand.mm v0, v1, v3 // vp8_normal_limit & !hv + + vnclip.wi v22, v22, 0 // clip_int8(a); + filter_fmin \len, \vlen, v22, v12, v26, v10, v24, v20 + vadd.vi v12, v12, 1 + vsra.vi v12, v12, 1 // (f1 + 1) >> 1; + vadd.vv v8, v8, v12 // p1 + a + vsub.vv v14, v14, v12 // q1 - a + + vmax.vx v8, v8, zero + vmax.vx v14, v14, zero + vsetvlstatic8 \len, \vlen + vnclipu.wi v3, v8, 0 // -2 + vnclipu.wi v4, v26, 0 // -1 + vnclipu.wi v5, v10, 0 // 0 + vnclipu.wi v6, v14, 0 // 1 + + .ifc \type,v + vse8.v v3, (t2), v0.t // -2 + vse8.v v4, (t3), v0.t // -1 + vse8.v v5, (\dst), v0.t // 0 + vse8.v v6, (t4), v0.t // 1 + .else + vssseg4e8.v v3, (t2), \stride, v0.t + .endif +.endif .endm .irp type,v,h @@ -349,6 +424,21 @@ func ff_vp8_\type\()_loop_filter16_simple_rvv\vlen, zve32x filter 16, \vlen, \type, 0, 0, a0, a1, a2, a3, a4 ret endfunc + +func ff_vp8_\type\()_loop_filter16_inner_rvv\vlen, zve32x + csrwi vxrm, 0 + vsetvlstatic8 16, \vlen + filter 16, \vlen, \type, 1, 1, a0, a1, a2, a3, a4 + ret +endfunc + +func ff_vp8_\type\()_loop_filter8uv_inner_rvv\vlen, zve32x + csrwi vxrm, 0 + vsetvlstatic8 8, \vlen + filter 8, \vlen, \type, 1, 1, a0, a2, a3, a4, a5 + filter 8, \vlen, \type, 1, 1, a1, a2, a3, a4, a5 + ret +endfunc .endr .endr