123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- #ifndef AVUTIL_INTREADWRITE_H
- #define AVUTIL_INTREADWRITE_H
- #include <stdint.h>
- #include "config.h"
- #include "bswap.h"
- #ifdef __GNUC__
- struct unaligned_64 { uint64_t l; } __attribute__);
- struct unaligned_32 { uint32_t l; } __attribute__);
- struct unaligned_16 { uint16_t l; } __attribute__);
- #define AV_RN16 )->l)
- #define AV_RN32 )->l)
- #define AV_RN64 )->l)
- #define AV_WN16 )->l) =
- #define AV_WN32 )->l) =
- #define AV_WN64 )->l) =
- #elif defined(__DECC)
- #define AV_RN16 ))
- #define AV_RN32 ))
- #define AV_RN64 ))
- #define AV_WN16 *) =
- #define AV_WN32 *) =
- #define AV_WN64 *) =
- #else
- #define AV_RN16 ))
- #define AV_RN32 ))
- #define AV_RN64 ))
- #define AV_WN16 *) =
- #define AV_WN32 *) =
- #define AV_WN64 *) =
- #endif /* !__GNUC__ */
- /* endian macros */
- #define AV_RB8 )[0])
- #define AV_WB8 do { )[0] = ; } while
- #define AV_RL8 AV_RB8
- #define AV_WL8 AV_WB8
- #if HAVE_FAST_UNALIGNED
- # ifdef WORDS_BIGENDIAN
- # define AV_RB16 AV_RN16
- # define AV_WB16 AV_WN16
- # define AV_RL16 bswap_16)
- # define AV_WL16 AV_WN16)
- # define AV_RB32 AV_RN32
- # define AV_WB32 AV_WN32
- # define AV_RL32 bswap_32)
- # define AV_WL32 AV_WN32)
- # define AV_RB64 AV_RN64
- # define AV_WB64 AV_WN64
- # define AV_RL64 bswap_64)
- # define AV_WL64 AV_WN64)
- # else /* WORDS_BIGENDIAN */
- # define AV_RB16 bswap_16)
- # define AV_WB16 AV_WN16)
- # define AV_RL16 AV_RN16
- # define AV_WL16 AV_WN16
- # define AV_RB32 bswap_32)
- # define AV_WB32 AV_WN32)
- # define AV_RL32 AV_RN32
- # define AV_WL32 AV_WN32
- # define AV_RB64 bswap_64)
- # define AV_WB64 AV_WN64)
- # define AV_RL64 AV_RN64
- # define AV_WL64 AV_WN64
- # endif
- #else /* HAVE_FAST_UNALIGNED */
- #define AV_RB16 )[0] << 8) | )[1])
- #define AV_WB16 do { \
- )[1] = ; \
- )[0] = >>8; } while
- #define AV_RL16 )[1] << 8) | \
- )[0])
- #define AV_WL16 do { \
- )[0] = ; \
- )[1] = >>8; } while
- #define AV_RB32 )[0] << 24) | \
- )[1] << 16) | \
- )[2] << 8) | \
- )[3])
- #define AV_WB32 do { \
- )[3] = ; \
- )[2] = >>8; \
- )[1] = >>16; \
- )[0] = >>24; } while
- #define AV_RL32 )[3] << 24) | \
- )[2] << 16) | \
- )[1] << 8) | \
- )[0])
- #define AV_WL32 do { \
- )[0] = ; \
- )[1] = >>8; \
- )[2] = >>16; \
- )[3] = >>24; } while
- #define AV_RB64 )[0] << 56) | \
- )[1] << 48) | \
- )[2] << 40) | \
- )[3] << 32) | \
- )[4] << 24) | \
- )[5] << 16) | \
- )[6] << 8) | \
- )[7])
- #define AV_WB64 do { \
- )[7] = ; \
- )[6] = >>8; \
- )[5] = >>16; \
- )[4] = >>24; \
- )[3] = >>32; \
- )[2] = >>40; \
- )[1] = >>48; \
- )[0] = >>56; } while
- #define AV_RL64 )[7] << 56) | \
- )[6] << 48) | \
- )[5] << 40) | \
- )[4] << 32) | \
- )[3] << 24) | \
- )[2] << 16) | \
- )[1] << 8) | \
- )[0])
- #define AV_WL64 do { \
- )[0] = ; \
- )[1] = >>8; \
- )[2] = >>16; \
- )[3] = >>24; \
- )[4] = >>32; \
- )[5] = >>40; \
- )[6] = >>48; \
- )[7] = >>56; } while
- #endif /* HAVE_FAST_UNALIGNED */
- #define AV_RB24 )[0] << 16) | \
- )[1] << 8) | \
- )[2])
- #define AV_WB24 do { \
- )[2] = ; \
- )[1] = >>8; \
- )[0] = >>16; } while
- #define AV_RL24 )[2] << 16) | \
- )[1] << 8) | \
- )[0])
- #define AV_WL24 do { \
- )[0] = ; \
- )[1] = >>8; \
- )[2] = >>16; } while
- #endif /* AVUTIL_INTREADWRITE_H */
|