1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-01-08 13:22:53 +02:00

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>
(cherry picked from commit a4800643bb)
This commit is contained in:
Andreas Rheinhardt 2024-04-04 03:45:57 +02:00
parent 0e3a46720a
commit 82aa188281
2 changed files with 6 additions and 8 deletions

View File

@ -25,13 +25,11 @@
#if HAVE_FAST_64BIT #if HAVE_FAST_64BIT
typedef uint64_t uint_native; typedef uint64_t uint_native;
#define READ AV_RN64 #define READ AV_RN64
#define READA AV_RN64A #define WRITE AV_WN64
#define WRITEA AV_WN64A
#else #else
typedef uint32_t uint_native; typedef uint32_t uint_native;
#define READ AV_RN32 #define READ AV_RN32
#define READA AV_RN32A #define WRITE AV_WN32
#define WRITEA AV_WN32A
#endif #endif
// 0x7f7f7f7f or 0x7f7f7f7f7f7f7f7f or whatever, depending on the cpu's native arithmetic size // 0x7f7f7f7f or 0x7f7f7f7f7f7f7f7f or whatever, depending on the cpu's native arithmetic size
#define pb_7f (~(uint_native)0 / 255 * 0x7f) #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 } else
#endif #endif
for (i = 0; i <= w - (int) sizeof(uint_native); i += sizeof(uint_native)) { 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); 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++) for (; i < w; i++)
dst[i + 0] = src1[i + 0] - src2[i + 0]; dst[i + 0] = src1[i + 0] - src2[i + 0];

View File

@ -23,8 +23,8 @@
#include <stdint.h> #include <stdint.h>
typedef struct LLVidEncDSPContext { typedef struct LLVidEncDSPContext {
void (*diff_bytes)(uint8_t *dst /* align 16 */, void (*diff_bytes)(uint8_t *dst /* align 1 */,
const uint8_t *src1 /* align 16 */, const uint8_t *src1 /* align 1 */,
const uint8_t *src2 /* align 1 */, const uint8_t *src2 /* align 1 */,
intptr_t w); intptr_t w);
/** /**