Enable ff_copy_bits in ffmpeg_bitstream.c and put_bits.h and intreadwrite.h to codeclib.
[kugel-rb.git] / apps / codecs / libwmapro / libavutil / bswap.h
blob82ed2271ac9ccb157a9aea6e41a2fd2bf2c1ba72
1 /*
2 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
4 * This file is part of FFmpeg.
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 /**
22 * @file libavutil/bswap.h
23 * byte swapping routines
26 #ifndef AVUTIL_BSWAP_H
27 #define AVUTIL_BSWAP_H
29 #include <stdint.h>
30 //#include "config.h"
32 #ifndef bswap_16
33 static inline uint16_t bswap_16(uint16_t x)
35 x= (x>>8) | (x<<8);
36 return x;
38 #endif
40 #ifndef bswap_32
41 static inline uint32_t bswap_32(uint32_t x)
43 x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
44 x= (x>>16) | (x<<16);
45 return x;
47 #endif
49 #ifndef bswap_64
50 static inline uint64_t bswap_64(uint64_t x)
52 #if 0
53 x= ((x<< 8)&0xFF00FF00FF00FF00ULL) | ((x>> 8)&0x00FF00FF00FF00FFULL);
54 x= ((x<<16)&0xFFFF0000FFFF0000ULL) | ((x>>16)&0x0000FFFF0000FFFFULL);
55 return (x>>32) | (x<<32);
56 #else
57 union {
58 uint64_t ll;
59 uint32_t l[2];
60 } w, r;
61 w.ll = x;
62 r.l[0] = bswap_32 (w.l[1]);
63 r.l[1] = bswap_32 (w.l[0]);
64 return r.ll;
65 #endif
67 #endif
69 // be2me ... big-endian to machine-endian
70 // le2me ... little-endian to machine-endian
72 #define HAVE_BIGENDIAN 0
73 #if HAVE_BIGENDIAN
74 #define be2me_16(x) (x)
75 #define be2me_32(x) (x)
76 #define be2me_64(x) (x)
77 #define le2me_16(x) bswap_16(x)
78 #define le2me_32(x) bswap_32(x)
79 #define le2me_64(x) bswap_64(x)
80 #else
81 #define be2me_16(x) bswap_16(x)
82 #define be2me_32(x) bswap_32(x)
83 #define be2me_64(x) bswap_64(x)
84 #define le2me_16(x) (x)
85 #define le2me_32(x) (x)
86 #define le2me_64(x) (x)
87 #endif
89 #endif /* AVUTIL_BSWAP_H */