diff mbox series

[FFmpeg-devel] avcodec/lossless_videoencdsp: Don't presume alignment in diff_bytes

Message ID GV1P250MB07372D86272D661D140D36E28F3C2@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit a4800643bba40cf8461406aa078da93e42e6ea6c
Headers show
Series [FFmpeg-devel] avcodec/lossless_videoencdsp: Don't presume alignment in diff_bytes | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt April 4, 2024, 1:58 a.m. UTC
The alignment of all the parameters in diff_bytes can be
anything the despite the documentation claiming otherwise.
8ecd38312210d48ec9e50d78fc223d60e71a30ed was based around
said documentation and is therefore insufficient to fix
e.g. the misaligned loads that happen in the huffyuvbgra
and huffyuvbgr24 vsynth FATE-tests.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/lossless_videoencdsp.c | 10 ++++------
 libavcodec/lossless_videoencdsp.h |  4 ++--
 2 files changed, 6 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/lossless_videoencdsp.c b/libavcodec/lossless_videoencdsp.c
index 8d03a5b5c6..0a3a4ec509 100644
--- a/libavcodec/lossless_videoencdsp.c
+++ b/libavcodec/lossless_videoencdsp.c
@@ -25,13 +25,11 @@ 
 #if HAVE_FAST_64BIT
 typedef uint64_t uint_native;
 #define READ   AV_RN64
-#define READA  AV_RN64A
-#define WRITEA AV_WN64A
+#define WRITE  AV_WN64
 #else
 typedef uint32_t uint_native;
 #define READ   AV_RN32
-#define READA  AV_RN32A
-#define WRITEA AV_WN32A
+#define WRITE  AV_WN32
 #endif
 // 0x7f7f7f7f or 0x7f7f7f7f7f7f7f7f or whatever, depending on the cpu's native arithmetic size
 #define pb_7f (~(uint_native)0 / 255 * 0x7f)
@@ -56,9 +54,9 @@  static void diff_bytes_c(uint8_t *dst, const uint8_t *src1, const uint8_t *src2,
     } else
 #endif
     for (i = 0; i <= w - (int) sizeof(uint_native); i += sizeof(uint_native)) {
-        uint_native a = READA(src1 + i);
+        uint_native a = READ(src1 + i);
         uint_native b = READ(src2 + i);
-        WRITEA(dst + i, ((a | pb_80) - (b & pb_7f)) ^ ((a ^ b ^ pb_80) & pb_80));
+        WRITE(dst + i, ((a | pb_80) - (b & pb_7f)) ^ ((a ^ b ^ pb_80) & pb_80));
     }
     for (; i < w; i++)
         dst[i + 0] = src1[i + 0] - src2[i + 0];
diff --git a/libavcodec/lossless_videoencdsp.h b/libavcodec/lossless_videoencdsp.h
index 07fff584af..7fd0ad32c7 100644
--- a/libavcodec/lossless_videoencdsp.h
+++ b/libavcodec/lossless_videoencdsp.h
@@ -23,8 +23,8 @@ 
 #include <stdint.h>
 
 typedef struct LLVidEncDSPContext {
-    void (*diff_bytes)(uint8_t *dst /* align 16 */,
-                       const uint8_t *src1 /* align 16 */,
+    void (*diff_bytes)(uint8_t *dst /* align 1 */,
+                       const uint8_t *src1 /* align 1 */,
                        const uint8_t *src2 /* align 1 */,
                        intptr_t w);
     /**