From patchwork Thu Jul 18 19:35:42 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: 50633 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:a742:0:b0:482:c625:d099 with SMTP id f2csp198455vqm; Thu, 18 Jul 2024 12:36:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUmoFe8mUEl+bnRcWa6TK1MQQpHIF0XmE6iBrDMXh+ilfxuMcncwt8PxGRUre5tA1jVONUWheV2GmK4CIpFAceXMxIiJJaCSd5X4g== X-Google-Smtp-Source: AGHT+IHY1/cz0KpfA8YbiweKR4knv2ZZOZIBkLXAU2wAyZIwaUlW6nctrLj8NBRpaJiq2edTd6dk X-Received: by 2002:a17:906:d286:b0:a77:eb34:3b42 with SMTP id a640c23a62f3a-a7a011c1472mr478487966b.12.1721331369337; Thu, 18 Jul 2024 12:36:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721331369; cv=none; d=google.com; s=arc-20160816; b=YEs5a3ej9TcRNt0jm8uZjr7zqLXxugnt/RlTamorxlvhGOERw1GTGXPjhdZR5i68E2 TBg+A3BZ7vYmiuWf7PyvNFQUksbyzktRy52xLcv+DHqt6lJwI4YyBAYKON1LNWRxY2X8 rggExOWGsKaLrZzfjAiq+NtjSM1FsdvYnxMoByfRYnaMg8VV2vmjUQPTHtIkbl6hWcCg Ap8IqiAiDJtNKlIGbR3ydRLaiZxxncuGB8KzWdp/dD+CS2LqNaNz8UlElE5j8iv8wklW rljJNcrEGyofvI9je2In/ixOKhiXpeMI/sRWotYeMj3ophSvYID7qnIV6vdgFbFUp+Pa EOQQ== 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=5r3kcdSI0kQw3KGNrSCpIQINc3B9skRqFp/hL/wCOTU=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=k504B5gevzcyvujdn+wiDYwttOScJK7Et/JUSvZwczxKBpn2q7/WZV8zWiUrH/nrtw VU3bcyhp8w0V8YZz6/JrJtxrne4veOTPxII+OHk5ncYcZsgOMny/HPNaz5DqGIZrMGc7 aklR2/BRR2B53OJL1X3No7KX9LEoYhNvpla4H+BwaMxW7lcNQTkiPqk9rnD0Llr8zKw/ HSidhdd9U0xUxp0vAeZVEpLjMJ6CXOkQXqPAgwRAzJUJv5KnDLSEIfrZlxSeEGo0U5YR zFU0ZR+no0MFxss4oLHn+3YKv9u5Q3uxHphW1demTL4VrLS596Qvh9iBZjYHJD63/llx EmpA==; 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 a640c23a62f3a-a7a306bfeebsi8618166b.108.2024.07.18.12.36.09; Thu, 18 Jul 2024 12:36:09 -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 1C41668DB00; Thu, 18 Jul 2024 22:35:56 +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 20AAA68D6BC for ; Thu, 18 Jul 2024 22:35:48 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 1F2D4C0090 for ; Thu, 18 Jul 2024 22:35:47 +0300 (EEST) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Thu, 18 Jul 2024 22:35:42 +0300 Message-ID: <20240718193546.18939-1-remi@remlab.net> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/5] lavc/h264dsp: factor some mostly identical R-V V code 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: CSh3jjbDzxOP --- libavcodec/riscv/h264idct_rvv.S | 108 ++++++-------------------------- 1 file changed, 18 insertions(+), 90 deletions(-) diff --git a/libavcodec/riscv/h264idct_rvv.S b/libavcodec/riscv/h264idct_rvv.S index 48de65ec0b..505f491308 100644 --- a/libavcodec/riscv/h264idct_rvv.S +++ b/libavcodec/riscv/h264idct_rvv.S @@ -418,8 +418,8 @@ const ff_h264_scan8 endconst #if (__riscv_xlen == 64) -.irp depth, 8, 16 -func ff_h264_idct_add16_\depth\()_rvv, zve32x +.macro idct4_adds type, depth +func ff_h264_idct_add\type\()_\depth\()_rvv, zve32x csrwi vxrm, 0 addi sp, sp, -96 lla t0, ff_h264_scan8 @@ -455,9 +455,13 @@ func ff_h264_idct_add16_\depth\()_rvv, zve32x .endif vmsne.vi v1, v16, 0 vsetvli zero, zero, e8, m1, ta, ma +.ifc \type, 16 vmseq.vi v2, v12, 1 +.endif vmsne.vi v0, v12, 0 +.ifc \type, 16 vmand.mm v1, v1, v2 +.endif vsetvli zero, zero, e16, m2, ta, ma vmv.x.s s2, v0 vmv.x.s s3, v1 @@ -470,96 +474,9 @@ func ff_h264_idct_add16_\depth\()_rvv, zve32x andi t0, s2, 1 addi s1, s1, -1 srli s2, s2, 1 +.ifc \type, 16 beqz t0, 3f # if (nnz) - lw t2, (s5) # block_offset[i] - andi t1, s3, 1 - mv a1, s6 - mv a2, s7 - add a0, s4, t2 -.if \depth > 8 - mv a5, s8 .endif - bnez t1, 2f # if (nnz == 1 && block[i * 16]) - jal .Lidct_add4_\depth\()_rvv - j 3f -2: -.if \depth == 8 - call ff_h264_idct_dc_add_\depth\()_c -.else - jalr s9 -.endif -3: - srli s3, s3, 1 - addi s5, s5, 4 - addi s6, s6, 16 * 2 * (\depth / 8) - bnez s1, 1b - -.if \depth > 8 - ld s9, 80(sp) - ld s8, 72(sp) -.endif - ld s7, 64(sp) - ld s6, 56(sp) - ld s5, 48(sp) - ld s4, 40(sp) - ld s3, 32(sp) - ld s2, 24(sp) - ld s1, 16(sp) - ld ra, 8(sp) - ld s0, 0(sp) - addi sp, sp, 96 - ret -endfunc - -func ff_h264_idct_add16intra_\depth\()_rvv, zve32x - csrwi vxrm, 0 - addi sp, sp, -96 - lla t0, ff_h264_scan8 - sd s0, (sp) - li t1, 32 * (\depth / 8) - mv s0, sp - sd ra, 8(sp) - sd s1, 16(sp) - sd s2, 24(sp) - sd s3, 32(sp) - sd s4, 40(sp) - sd s5, 48(sp) - sd s6, 56(sp) - sd s7, 64(sp) -.if \depth > 8 - sd s8, 72(sp) - sd s9, 80(sp) - mv s8, a5 - mv s9, a6 -.endif - vsetivli zero, 16, e8, m1, ta, ma - vle8.v v8, (t0) -.if \depth == 8 - vlse16.v v16, (a2), t1 -.else - vlse32.v v16, (a2), t1 -.endif - vluxei8.v v12, (a4), v8 -.if \depth == 8 - vsetvli zero, zero, e16, m2, ta, ma -.else - vsetvli zero, zero, e32, m4, ta, ma -.endif - vmsne.vi v1, v16, 0 - vsetvli zero, zero, e8, m1, ta, ma - vmsne.vi v0, v12, 0 - vsetvli zero, zero, e16, m2, ta, ma - vmv.x.s s2, v0 - vmv.x.s s3, v1 - li s1, 16 - mv s4, a0 - mv s5, a1 - mv s6, a2 - mv s7, a3 -1: - andi t0, s2, 1 - addi s1, s1, -1 - srli s2, s2, 1 lw t2, (s5) # block_offset[i] andi t1, s3, 1 mv a1, s6 @@ -568,11 +485,17 @@ func ff_h264_idct_add16intra_\depth\()_rvv, zve32x .if \depth > 8 mv a5, s8 .endif +.ifc \type, 16 + bnez t1, 2f # if (nnz == 1 && block[i * 16]) +.else beqz t0, 2f # if (nnzc[scan8[i]]) +.endif jal .Lidct_add4_\depth\()_rvv j 3f 2: +.ifnc \type, 16 beqz t1, 3f # if (block[i * 16]) +.endif .if \depth == 8 call ff_h264_idct_dc_add_\depth\()_c .else @@ -600,6 +523,11 @@ func ff_h264_idct_add16intra_\depth\()_rvv, zve32x addi sp, sp, 96 ret endfunc +.endm + +.irp depth, 8, 16 +idct4_adds 16, \depth +idct4_adds 16intra, \depth func ff_h264_idct8_add4_\depth\()_rvv, zve32x csrwi vxrm, 0