History

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. 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.

Andreas Rheinhardt committed 2 years ago

Commit a4800641 parent e54696b2 files · +6 −8Browse files

Unified · Split

2 files
  1. libavcodec/lossless_videoencdsp.c +4 −6
  2. libavcodec/lossless_videoencdsp.h +2 −2
libavcodec/lossless_videoencdsp.c+4−6
@@ -25,13 +25,11 @@ · 24 unmodified lines
25#if HAVE_FAST_64BIT25#if HAVE_FAST_64BIT
26typedef uint64_t uint_native;26typedef uint64_t uint_native;
27#define READ AV_RN6427#define READ AV_RN64
28#define READA AV_RN64A28#define WRITE AV_WN64
29#define WRITEA AV_WN64A
30#else29#else
31typedef uint32_t uint_native;30typedef uint32_t uint_native;
32#define READ AV_RN3231#define READ AV_RN32
33#define READA AV_RN32A32#define WRITE AV_WN32
34#define WRITEA AV_WN32A
35#endif33#endif
36// 0x7f7f7f7f or 0x7f7f7f7f7f7f7f7f or whatever, depending on the cpu's native arithmetic size34// 0x7f7f7f7f or 0x7f7f7f7f7f7f7f7f or whatever, depending on the cpu's native arithmetic size
37#define pb_7f (~(uint_native)0 / 255 * 0x7f)35#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, · 18 unmodified lines
56 } else54 } else
57#endif55#endif
58 for (i = 0; i <= w - (int) sizeof(uint_native); i += sizeof(uint_native)) {56 for (i = 0; i <= w - (int) sizeof(uint_native); i += sizeof(uint_native)) {
59 uint_native a = READA(src1 + i);57 uint_native a = READ(src1 + i);
60 uint_native b = READ(src2 + i);58 uint_native b = READ(src2 + i);
61 WRITEA(dst + i, ((a | pb_80) - (b & pb_7f)) ^ ((a ^ b ^ pb_80) & pb_80));59 WRITE(dst + i, ((a | pb_80) - (b & pb_7f)) ^ ((a ^ b ^ pb_80) & pb_80));
62 }60 }
63 for (; i < w; i++)61 for (; i < w; i++)
64 dst[i + 0] = src1[i + 0] - src2[i + 0];62 dst[i + 0] = src1[i + 0] - src2[i + 0];
libavcodec/lossless_videoencdsp.h+2−2
@@ -23,8 +23,8 @@ · 22 unmodified lines
23#include <stdint.h>23#include <stdint.h>
24 24
25typedef struct LLVidEncDSPContext {25typedef struct LLVidEncDSPContext {
26 void (*diff_bytes)(uint8_t *dst /* align 16 */,26 void (*diff_bytes)(uint8_t *dst /* align 1 */,
27 const uint8_t *src1 /* align 16 */,27 const uint8_t *src1 /* align 1 */,
28 const uint8_t *src2 /* align 1 */,28 const uint8_t *src2 /* align 1 */,
29 intptr_t w);29 intptr_t w);
30 /**30 /**

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t