diff options
author | Måns Rullgård <mans@mansr.com> | 2010-02-18 13:44:38 +0000 |
---|---|---|
committer | Måns Rullgård <mans@mansr.com> | 2010-02-18 13:44:38 +0000 |
commit | f4a7434f16afc4616a34a7cd1bd8e592ed04e89f (patch) | |
tree | ac78d65aa60c92521154dec9d816a48c1004c258 | |
parent | 7a6053ef72152c3838c714b9eec95f2dccc5c181 (diff) | |
download | ffmpeg-f4a7434f16afc4616a34a7cd1bd8e592ed04e89f.tar.gz |
Add alias-safe aligned AV_[RW]N macros
Originally committed as revision 21880 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavutil/intreadwrite.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/libavutil/intreadwrite.h b/libavutil/intreadwrite.h index 7565ef711e..b1e4e9a9a1 100644 --- a/libavutil/intreadwrite.h +++ b/libavutil/intreadwrite.h @@ -422,6 +422,38 @@ union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias; } 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 |