summaryrefslogtreecommitdiff
path: root/apps/codecs/libwmapro/libavutil/bswap.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libwmapro/libavutil/bswap.h')
-rw-r--r--apps/codecs/libwmapro/libavutil/bswap.h101
1 files changed, 101 insertions, 0 deletions
diff --git a/apps/codecs/libwmapro/libavutil/bswap.h b/apps/codecs/libwmapro/libavutil/bswap.h
new file mode 100644
index 0000000000..74c7af3026
--- /dev/null
+++ b/apps/codecs/libwmapro/libavutil/bswap.h
@@ -0,0 +1,101 @@
1/*
2 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
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.
10 *
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.
15 *
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
19 */
20
21/**
22 * @file libavutil/bswap.h
23 * byte swapping routines
24 */
25
26#ifndef AVUTIL_BSWAP_H
27#define AVUTIL_BSWAP_H
28
29#include <stdint.h>
30#include "config.h"
31#include "attributes.h"
32
33#if ARCH_ARM
34# include "arm/bswap.h"
35#elif ARCH_AVR32
36# include "avr32/bswap.h"
37#elif ARCH_BFIN
38# include "bfin/bswap.h"
39#elif ARCH_SH4
40# include "sh4/bswap.h"
41#elif ARCH_X86
42# include "x86/bswap.h"
43#endif
44
45#ifndef bswap_16
46static av_always_inline av_const uint16_t bswap_16(uint16_t x)
47{
48 x= (x>>8) | (x<<8);
49 return x;
50}
51#endif
52
53#ifndef bswap_32
54static av_always_inline av_const uint32_t bswap_32(uint32_t x)
55{
56 x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
57 x= (x>>16) | (x<<16);
58 return x;
59}
60#endif
61
62#ifndef bswap_64
63static inline uint64_t av_const bswap_64(uint64_t x)
64{
65#if 0
66 x= ((x<< 8)&0xFF00FF00FF00FF00ULL) | ((x>> 8)&0x00FF00FF00FF00FFULL);
67 x= ((x<<16)&0xFFFF0000FFFF0000ULL) | ((x>>16)&0x0000FFFF0000FFFFULL);
68 return (x>>32) | (x<<32);
69#else
70 union {
71 uint64_t ll;
72 uint32_t l[2];
73 } w, r;
74 w.ll = x;
75 r.l[0] = bswap_32 (w.l[1]);
76 r.l[1] = bswap_32 (w.l[0]);
77 return r.ll;
78#endif
79}
80#endif
81
82// be2me ... big-endian to machine-endian
83// le2me ... little-endian to machine-endian
84
85#if HAVE_BIGENDIAN
86#define be2me_16(x) (x)
87#define be2me_32(x) (x)
88#define be2me_64(x) (x)
89#define le2me_16(x) bswap_16(x)
90#define le2me_32(x) bswap_32(x)
91#define le2me_64(x) bswap_64(x)
92#else
93#define be2me_16(x) bswap_16(x)
94#define be2me_32(x) bswap_32(x)
95#define be2me_64(x) bswap_64(x)
96#define le2me_16(x) (x)
97#define le2me_32(x) (x)
98#define le2me_64(x) (x)
99#endif
100
101#endif /* AVUTIL_BSWAP_H */