From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 0F7A544C64 for ; Fri, 13 Jan 2023 20:18:54 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F1A24689BD5; Fri, 13 Jan 2023 22:18:51 +0200 (EET) Received: from ursule.remlab.net (vps-a2bccee9.vps.ovh.net [51.75.19.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5F98E689BD5 for ; Fri, 13 Jan 2023 22:18:45 +0200 (EET) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id DCB79C000E for ; Fri, 13 Jan 2023 22:18:44 +0200 (EET) From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 13 Jan 2023 22:18:44 +0200 Message-Id: <20230113201844.49829-1-remi@remlab.net> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [NOT FOR MERGE] [PATCH] lavc/bswapdsp: do not assume aligned input on RISC-V 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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".