Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: "Rémi Denis-Courmont" <remi@remlab.net>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 2/6] lavc/pixblockdsp: aligned R-V V 8-bit functions
Date: Fri, 27 Oct 2023 22:25:36 +0300
Message-ID: <20231027192540.27373-2-remi@remlab.net> (raw)

If the scan lines are aligned, we can load each row as a 64-bit value,
thus avoiding segmentation. And then we can factor the conversion or
subtraction.

In principle, the same optimisation should be possible for high depth,
but would require 128-bit elements, for which no FFmpeg CPU flag
exists.
---
 libavcodec/riscv/pixblockdsp_init.c | 11 +++++++++++
 libavcodec/riscv/pixblockdsp_rvv.S  | 21 +++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/libavcodec/riscv/pixblockdsp_init.c b/libavcodec/riscv/pixblockdsp_init.c
index 8f24281217..7d259a032f 100644
--- a/libavcodec/riscv/pixblockdsp_init.c
+++ b/libavcodec/riscv/pixblockdsp_init.c
@@ -32,10 +32,14 @@ void ff_get_pixels_8_rvi(int16_t *block, const uint8_t *pixels,
 void ff_get_pixels_16_rvi(int16_t *block, const uint8_t *pixels,
                           ptrdiff_t stride);
 
+void ff_get_pixels_8_rvv(int16_t *block, const uint8_t *pixels,
+                         ptrdiff_t stride);
 void ff_get_pixels_unaligned_8_rvv(int16_t *block, const uint8_t *pixels,
                                    ptrdiff_t stride);
 void ff_get_pixels_unaligned_16_rvv(int16_t *block, const uint8_t *pixels,
                                     ptrdiff_t stride);
+void ff_diff_pixels_rvv(int16_t *block, const uint8_t *s1,
+                        const uint8_t *s2, ptrdiff_t stride);
 void ff_diff_pixels_unaligned_rvv(int16_t *block, const uint8_t *s1,
                                   const uint8_t *s2, ptrdiff_t stride);
 
@@ -64,6 +68,13 @@ av_cold void ff_pixblockdsp_init_riscv(PixblockDSPContext *c,
 
         c->diff_pixels = ff_diff_pixels_unaligned_rvv;
         c->diff_pixels_unaligned = ff_diff_pixels_unaligned_rvv;
+
+        if (cpu_flags & AV_CPU_FLAG_RVV_I64) {
+            if (!high_bit_depth)
+                c->get_pixels = ff_get_pixels_8_rvv;
+
+            c->diff_pixels = ff_diff_pixels_rvv;
+        }
     }
 #endif
 }
diff --git a/libavcodec/riscv/pixblockdsp_rvv.S b/libavcodec/riscv/pixblockdsp_rvv.S
index e3a2fcc6ef..80c7415acf 100644
--- a/libavcodec/riscv/pixblockdsp_rvv.S
+++ b/libavcodec/riscv/pixblockdsp_rvv.S
@@ -20,6 +20,16 @@
 
 #include "libavutil/riscv/asm.S"
 
+func ff_get_pixels_8_rvv, zve64x
+        vsetivli zero, 8, e8, mf2, ta, ma
+        li      t0, 8 * 8
+        vlse64.v v16, (a1), a2
+        vsetvli zero, t0, e8, m4, ta, ma
+        vwcvtu.x.x.v v8, v16
+        vse16.v v8, (a0)
+        ret
+endfunc
+
 func ff_get_pixels_unaligned_8_rvv, zve32x
         vsetivli     zero, 8, e8, mf2, ta, ma
         vlsseg8e8.v  v16, (a1), a2
@@ -42,6 +52,17 @@ func ff_get_pixels_unaligned_16_rvv, zve32x
         ret
 endfunc
 
+func ff_diff_pixels_rvv, zve64x
+        vsetivli zero, 8, e8, mf2, ta, ma
+        li      t0, 8 * 8
+        vlse64.v v16, (a1), a3
+        vlse64.v v24, (a2), a3
+        vsetvli zero, t0, e8, m4, ta, ma
+        vwsubu.vv v8, v16, v24
+        vse16.v v8, (a0)
+        ret
+endfunc
+
 func ff_diff_pixels_unaligned_rvv, zve32x
         vsetivli    zero, 8, e8, mf2, ta, ma
         vlsseg8e8.v v16, (a1), a3
-- 
2.42.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

                 reply	other threads:[~2023-10-27 19:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231027192540.27373-2-remi@remlab.net \
    --to=remi@remlab.net \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git