]> iEval git - fdkaac.git/blame_incremental - src/m4af_endian.h
fix to use libFDKAAC signaling mode 1
[fdkaac.git] / src / m4af_endian.h
... / ...
CommitLineData
1/*
2 * Copyright (C) 2013 nu774
3 * For conditions of distribution and use, see copyright notice in COPYING
4 */
5#ifndef M4AF_ENDIAN_H
6#define M4AF_ENDIAN_H
7
8#if HAVE_CONFIG_H
9# include "config.h"
10#endif
11#if HAVE_STDINT_H
12# include <stdint.h>
13#endif
14
15#if HAVE_ENDIAN_H
16# include <endian.h>
17# define m4af_htob16(x) htobe16(x)
18# define m4af_htob32(x) htobe32(x)
19# define m4af_htob64(x) htobe64(x)
20# define m4af_btoh16(x) be16toh(x)
21# define m4af_btoh32(x) be32toh(x)
22# define m4af_btoh64(x) be64toh(x)
23# define m4af_htol16(x) htole16(x)
24# define m4af_htol32(x) htole32(x)
25# define m4af_htol64(x) htole64(x)
26# define m4af_ltoh16(x) le16toh(x)
27# define m4af_ltoh32(x) le32toh(x)
28# define m4af_ltoh64(x) le64toh(x)
29#elif WORDS_BIGENDIAN
30# define m4af_htob16(x) (x)
31# define m4af_htob32(x) (x)
32# define m4af_htob64(x) (x)
33# define m4af_btoh16(x) (x)
34# define m4af_btoh32(x) (x)
35# define m4af_btoh64(x) (x)
36# define m4af_ltoh16(x) m4af_swap16(x)
37# define m4af_ltoh32(x) m4af_swap32(x)
38# define m4af_ltoh64(x) m4af_swap64(x)
39# define m4af_htol16(x) m4af_swap16(x)
40# define m4af_htol32(x) m4af_swap32(x)
41# define m4af_htol64(x) m4af_swap64(x)
42#else
43# define m4af_htob16(x) m4af_swap16(x)
44# define m4af_htob32(x) m4af_swap32(x)
45# define m4af_htob64(x) m4af_swap64(x)
46# define m4af_btoh16(x) m4af_swap16(x)
47# define m4af_btoh32(x) m4af_swap32(x)
48# define m4af_btoh64(x) m4af_swap64(x)
49# define m4af_ltoh16(x) (x)
50# define m4af_ltoh32(x) (x)
51# define m4af_ltoh64(x) (x)
52# define m4af_htol16(x) (x)
53# define m4af_htol32(x) (x)
54# define m4af_htol64(x) (x)
55#endif
56
57#if _MSC_VER >= 1400
58# include <stdlib.h>
59# define m4af_swap16(x) _byteswap_ushort(x)
60# define m4af_swap32(x) _byteswap_ulong(x)
61# define m4af_swap64(x) _byteswap_uint64(x)
62#elif HAVE_BYTESWAP_H
63# include <byteswap.h>
64# define m4af_swap16(x) bswap_16(x)
65# define m4af_swap32(x) bswap_32(x)
66# define m4af_swap64(x) bswap_64(x)
67#else
68static inline uint16_t m4af_swap16(uint16_t x)
69{
70 return (x >> 8) | (x << 8);
71}
72
73static inline uint32_t m4af_swap32(uint32_t x)
74{
75 return (m4af_htob16(x) << 16) | m4af_htob16(x >> 16);
76}
77
78static inline uint64_t m4af_swap64(uint64_t x)
79{
80 return ((uint64_t)m4af_htob32(x) << 32) | m4af_htob32(x >> 32);
81}
82#endif
83
84#endif /* M4AF_ENDIAN_H */
85
This page took 0.01989 seconds and 4 git commands to generate.