diff options
author | Christophe Gisquet <christophe.gisquet@gmail.com> | 2021-06-18 00:11:29 +0300 |
---|---|---|
committer | Henrik Gramner <henrik@gramner.com> | 2021-08-19 22:29:46 +0300 |
commit | 3bae53c0b684b7fedf2f5b0b662a3bbd84631aaf (patch) | |
tree | 979765688321745b7d86cca3c13628eab34678ed | |
parent | 12156a507b6e4c045e74bdef1dbd9447e666b232 (diff) |
refmvs: Pack the refmvs_block struct
Reduces size from 16B to 12B, while maintaining a 4-byte alignment.
-rw-r--r-- | include/common/attributes.h | 6 | ||||
-rw-r--r-- | src/levels.h | 1 | ||||
-rw-r--r-- | src/refmvs.h | 4 |
3 files changed, 9 insertions, 2 deletions
diff --git a/include/common/attributes.h b/include/common/attributes.h index 64df445..4ccc421 100644 --- a/include/common/attributes.h +++ b/include/common/attributes.h @@ -178,4 +178,10 @@ static inline int clzll(const unsigned long long mask) { static_assert(name == offsetof(type, field), #field) #endif +#ifdef _MSC_VER +#define PACKED(...) __pragma(pack(push, 1)) __VA_ARGS__ __pragma(pack(pop)) +#else +#define PACKED(...) __VA_ARGS__ __attribute__((__packed__)) +#endif + #endif /* DAV1D_COMMON_ATTRIBUTES_H */ diff --git a/src/levels.h b/src/levels.h index 571c580..0f510e9 100644 --- a/src/levels.h +++ b/src/levels.h @@ -31,6 +31,7 @@ #include <stdint.h> #include "dav1d/headers.h" +#include "common/attributes.h" enum ObuMetaType { OBU_META_HDR_CLL = 1, diff --git a/src/refmvs.h b/src/refmvs.h index 6f68a76..976d209 100644 --- a/src/refmvs.h +++ b/src/refmvs.h @@ -55,11 +55,11 @@ typedef union refmvs_mvpair { uint64_t n; } refmvs_mvpair; -typedef struct refmvs_block { +PACKED(typedef struct refmvs_block { refmvs_mvpair mv; refmvs_refpair ref; uint8_t bs, mf; // 1 = globalmv+affine, 2 = newmv -} refmvs_block; +}) ALIGN(refmvs_block, 4); typedef struct refmvs_frame { const Dav1dFrameHeader *frm_hdr; |