avcodec/lossless_videoencdsp: Don't presume alignment in diff_bytes

The alignment of all the parameters in diff_bytes can be
anything the despite the documentation claiming otherwise.
8ecd383122 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>
This commit is contained in:
Andreas Rheinhardt 2024-04-04 03:45:57 +02:00
parent e54696bcaa
commit a4800643bb
2 changed files with 6 additions and 8 deletions

View File

@ -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];

View File

@ -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);
/**