| Index: patched-ffmpeg-mt/libavutil/intreadwrite.h
|
| ===================================================================
|
| --- patched-ffmpeg-mt/libavutil/intreadwrite.h (revision 41250)
|
| +++ patched-ffmpeg-mt/libavutil/intreadwrite.h (working copy)
|
| @@ -22,7 +22,29 @@
|
| #include <stdint.h>
|
| #include "config.h"
|
| #include "bswap.h"
|
| +#include "common.h"
|
|
|
| +typedef union {
|
| + uint64_t u64;
|
| + uint32_t u32[2];
|
| + uint16_t u16[4];
|
| + uint8_t u8 [8];
|
| + double f64;
|
| + float f32[2];
|
| +} av_alias av_alias64;
|
| +
|
| +typedef union {
|
| + uint32_t u32;
|
| + uint16_t u16[2];
|
| + uint8_t u8 [4];
|
| + float f32;
|
| +} av_alias av_alias32;
|
| +
|
| +typedef union {
|
| + uint16_t u16;
|
| + uint8_t u8 [2];
|
| +} av_alias av_alias16;
|
| +
|
| /*
|
| * Arch-specific headers can provide any combination of
|
| * AV_[RW][BLN](16|24|32|64) and AV_(COPY|SWAP|ZERO)(64|128) macros.
|
| @@ -38,6 +60,8 @@
|
| # include "mips/intreadwrite.h"
|
| #elif ARCH_PPC
|
| # include "ppc/intreadwrite.h"
|
| +#elif ARCH_TOMI
|
| +# include "tomi/intreadwrite.h"
|
| #elif ARCH_X86
|
| # include "x86/intreadwrite.h"
|
| #endif
|
| @@ -155,12 +179,12 @@
|
|
|
| #if HAVE_ATTRIBUTE_PACKED
|
|
|
| -struct unaligned_64 { uint64_t l; } __attribute__((packed));
|
| -struct unaligned_32 { uint32_t l; } __attribute__((packed));
|
| -struct unaligned_16 { uint16_t l; } __attribute__((packed));
|
| +union unaligned_64 { uint64_t l; } __attribute__((packed)) av_alias;
|
| +union unaligned_32 { uint32_t l; } __attribute__((packed)) av_alias;
|
| +union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
|
|
|
| -# define AV_RN(s, p) (((const struct unaligned_##s *) (p))->l)
|
| -# define AV_WN(s, p, v) ((((struct unaligned_##s *) (p))->l) = (v))
|
| +# define AV_RN(s, p) (((const union unaligned_##s *) (p))->l)
|
| +# define AV_WN(s, p, v) ((((union unaligned_##s *) (p))->l) = (v))
|
|
|
| #elif defined(__DECC)
|
|
|
| @@ -169,8 +193,8 @@
|
|
|
| #elif HAVE_FAST_UNALIGNED
|
|
|
| -# define AV_RN(s, p) (*((const uint##s##_t*)(p)))
|
| -# define AV_WN(s, p, v) (*((uint##s##_t*)(p)) = (v))
|
| +# define AV_RN(s, p) (((const av_alias##s*)(p))->u##s)
|
| +# define AV_WN(s, p, v) (((av_alias##s*)(p))->u##s = (v))
|
|
|
| #else
|
|
|
| @@ -400,14 +424,51 @@
|
| } while(0)
|
| #endif
|
|
|
| +/*
|
| + * The AV_[RW]NA macros access naturally aligned data
|
| + * in a type-safe way.
|
| + */
|
| +
|
| +#define AV_RNA(s, p) (((const av_alias##s*)(p))->u##s)
|
| +#define AV_WNA(s, p, v) (((av_alias##s*)(p))->u##s = (v))
|
| +
|
| +#ifndef AV_RN16A
|
| +# define AV_RN16A(p) AV_RNA(16, p)
|
| +#endif
|
| +
|
| +#ifndef AV_RN32A
|
| +# define AV_RN32A(p) AV_RNA(32, p)
|
| +#endif
|
| +
|
| +#ifndef AV_RN64A
|
| +# define AV_RN64A(p) AV_RNA(64, p)
|
| +#endif
|
| +
|
| +#ifndef AV_WN16A
|
| +# define AV_WN16A(p, v) AV_WNA(16, p, v)
|
| +#endif
|
| +
|
| +#ifndef AV_WN32A
|
| +# define AV_WN32A(p, v) AV_WNA(32, p, v)
|
| +#endif
|
| +
|
| +#ifndef AV_WN64A
|
| +# define AV_WN64A(p, v) AV_WNA(64, p, v)
|
| +#endif
|
| +
|
| /* Parameters for AV_COPY*, AV_SWAP*, AV_ZERO* must be
|
| * naturally aligned. They may be implemented using MMX,
|
| * so emms_c() must be called before using any float code
|
| * afterwards.
|
| */
|
|
|
| -#define AV_COPY(n, d, s) (*(uint##n##_t*)(d) = *(const uint##n##_t*)(s))
|
| +#define AV_COPY(n, d, s) \
|
| + (((av_alias##n*)(d))->u##n = ((const av_alias##n*)(s))->u##n)
|
|
|
| +#ifndef AV_COPY16
|
| +# define AV_COPY16(d, s) AV_COPY(16, d, s)
|
| +#endif
|
| +
|
| #ifndef AV_COPY32
|
| # define AV_COPY32(d, s) AV_COPY(32, d, s)
|
| #endif
|
| @@ -424,14 +485,22 @@
|
| } while(0)
|
| #endif
|
|
|
| -#define AV_SWAP(n, a, b) FFSWAP(uint##n##_t, *(uint##n##_t*)(a), *(uint##n##_t*)(b))
|
| +#define AV_SWAP(n, a, b) FFSWAP(av_alias##n, *(av_alias##n*)(a), *(av_alias##n*)(b))
|
|
|
| #ifndef AV_SWAP64
|
| # define AV_SWAP64(a, b) AV_SWAP(64, a, b)
|
| #endif
|
|
|
| -#define AV_ZERO(n, d) (*(uint##n##_t*)(d) = 0)
|
| +#define AV_ZERO(n, d) (((av_alias##n*)(d))->u##n = 0)
|
|
|
| +#ifndef AV_ZERO16
|
| +# define AV_ZERO16(d) AV_ZERO(16, d)
|
| +#endif
|
| +
|
| +#ifndef AV_ZERO32
|
| +# define AV_ZERO32(d) AV_ZERO(32, d)
|
| +#endif
|
| +
|
| #ifndef AV_ZERO64
|
| # define AV_ZERO64(d) AV_ZERO(64, d)
|
| #endif
|
|
|