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] [NOT FOR MERGE] [PATCH] lavc/bswapdsp: do not assume aligned input on RISC-V
Date: Fri, 13 Jan 2023 22:18:44 +0200
Message-ID: <20230113201844.49829-1-remi@remlab.net> (raw)

This fixes the RISC-V B code not to assume alignment. Unfortunately,
the whole idea behind the optimisation does not really work if the
input is unaligned, and the C code works just as well.

Notes:
- This does not fix the call prototypes, whose second parameter
  is expected to change to `const void *` separately.
- The RISC-V Vector code does not assume any alignment of either input
  or output buffers.
---
 libavcodec/bswapdsp.c           | 4 ++--
 libavcodec/bswapdsp.h           | 2 ++
 libavcodec/riscv/bswapdsp_rvb.S | 5 +++++
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/libavcodec/bswapdsp.c b/libavcodec/bswapdsp.c
index f0ea2b55c5..901610c96d 100644
--- a/libavcodec/bswapdsp.c
+++ b/libavcodec/bswapdsp.c
@@ -22,7 +22,7 @@
 #include "libavutil/bswap.h"
 #include "bswapdsp.h"
 
-static void bswap_buf(uint32_t *dst, const uint32_t *src, int w)
+void ff_bswap32_buf(uint32_t *dst, const uint32_t *src, int w)
 {
     int i;
 
@@ -48,7 +48,7 @@ static void bswap16_buf(uint16_t *dst, const uint16_t *src, int len)
 
 av_cold void ff_bswapdsp_init(BswapDSPContext *c)
 {
-    c->bswap_buf   = bswap_buf;
+    c->bswap_buf   = ff_bswap32_buf;
     c->bswap16_buf = bswap16_buf;
 
 #if ARCH_RISCV
diff --git a/libavcodec/bswapdsp.h b/libavcodec/bswapdsp.h
index 6f4db66115..fa199b3be9 100644
--- a/libavcodec/bswapdsp.h
+++ b/libavcodec/bswapdsp.h
@@ -30,4 +30,6 @@ void ff_bswapdsp_init(BswapDSPContext *c);
 void ff_bswapdsp_init_riscv(BswapDSPContext *c);
 void ff_bswapdsp_init_x86(BswapDSPContext *c);
 
+void ff_bswap32_buf(uint32_t *dst, const uint32_t *src, int w);
+
 #endif /* AVCODEC_BSWAPDSP_H */
diff --git a/libavcodec/riscv/bswapdsp_rvb.S b/libavcodec/riscv/bswapdsp_rvb.S
index 91b47bf82d..795e44f478 100644
--- a/libavcodec/riscv/bswapdsp_rvb.S
+++ b/libavcodec/riscv/bswapdsp_rvb.S
@@ -23,7 +23,9 @@
 
 #if (__riscv_xlen >= 64)
 func ff_bswap32_buf_rvb, zbb
+        andi    t1, a1, 3
         andi    t0, a1, 4
+        bnez    t1, 6f
         beqz    t0, 1f
         /* Align a1 (input) to 64-bit */
         lwu     t0, (a1)
@@ -64,5 +66,8 @@ func ff_bswap32_buf_rvb, zbb
         sw      t0, -4(a0)
 5:
         ret
+
+6:      /* No worthy optimisation if unaligned */
+        tail    ff_bswap32_buf
 endfunc
 #endif
-- 
2.39.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-01-13 20:18 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=20230113201844.49829-1-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