debian/: remove watch
[mplayer.git] / ffmpeg_files / bswap.h
blob3bfa6aa6313fe05489ef098f40199f772d18112c
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
22 // This file in MPlayer is otherwise the same as in FFmpeg, except it
23 // includes "libavutil/common.h" instead of "common.h".
25 /**
26 * @file libavutil/bswap.h
27 * byte swapping routines
30 #ifndef MP_AVUTIL_BSWAP_H
31 #define MP_AVUTIL_BSWAP_H
33 #include <stdint.h>
34 #include "libavutil/common.h"
35 #include "config.h"
37 #if ARCH_ARM
38 # include "arm/bswap.h"
39 #elif ARCH_BFIN
40 # include "bfin/bswap.h"
41 #elif ARCH_SH4
42 # include "sh4/bswap.h"
43 #elif ARCH_X86
44 # include "x86/bswap.h"
45 #endif
47 #ifndef bswap_16
48 static av_always_inline av_const uint16_t bswap_16(uint16_t x)
50 x= (x>>8) | (x<<8);
51 return x;
53 #endif
55 #ifndef bswap_32
56 static av_always_inline av_const uint32_t bswap_32(uint32_t x)
58 x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
59 x= (x>>16) | (x<<16);
60 return x;
62 #endif
64 #ifndef bswap_64
65 static inline uint64_t av_const bswap_64(uint64_t x)
67 #if 0
68 x= ((x<< 8)&0xFF00FF00FF00FF00ULL) | ((x>> 8)&0x00FF00FF00FF00FFULL);
69 x= ((x<<16)&0xFFFF0000FFFF0000ULL) | ((x>>16)&0x0000FFFF0000FFFFULL);
70 return (x>>32) | (x<<32);
71 #else
72 union {
73 uint64_t ll;
74 uint32_t l[2];
75 } w, r;
76 w.ll = x;
77 r.l[0] = bswap_32 (w.l[1]);
78 r.l[1] = bswap_32 (w.l[0]);
79 return r.ll;
80 #endif
82 #endif
84 // be2me ... big-endian to machine-endian
85 // le2me ... little-endian to machine-endian
87 #ifdef WORDS_BIGENDIAN
88 #define be2me_16(x) (x)
89 #define be2me_32(x) (x)
90 #define be2me_64(x) (x)
91 #define le2me_16(x) bswap_16(x)
92 #define le2me_32(x) bswap_32(x)
93 #define le2me_64(x) bswap_64(x)
94 #else
95 #define be2me_16(x) bswap_16(x)
96 #define be2me_32(x) bswap_32(x)
97 #define be2me_64(x) bswap_64(x)
98 #define le2me_16(x) (x)
99 #define le2me_32(x) (x)
100 #define le2me_64(x) (x)
101 #endif
103 #endif /* AVUTIL_BSWAP_H */