Add a LPC filter
[ffmpeg-lucabe.git] / libavutil / bswap.h
blobc14676e6abdae1d0de721e8013cc7ca9a4f0c8b3
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 bswap.h
23 * byte swapping routines
26 #ifndef AVUTIL_BSWAP_H
27 #define AVUTIL_BSWAP_H
29 #include <stdint.h>
30 #include "config.h"
31 #include "common.h"
33 #if defined(ARCH_ARMV4L)
34 # include "arm/bswap.h"
35 #elif defined(ARCH_BFIN)
36 # include "bfin/bswap.h"
37 #elif defined(ARCH_SH4)
38 # include "sh4/bswap.h"
39 #elif defined(ARCH_X86)
40 # include "x86/bswap.h"
41 #endif
43 #ifndef bswap_16
44 static av_always_inline av_const uint16_t bswap_16(uint16_t x)
46 x= (x>>8) | (x<<8);
47 return x;
49 #endif
51 #ifndef bswap_32
52 static av_always_inline av_const uint32_t bswap_32(uint32_t x)
54 x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
55 x= (x>>16) | (x<<16);
56 return x;
58 #endif
60 #ifndef bswap_64
61 static inline uint64_t av_const bswap_64(uint64_t x)
63 #if 0
64 x= ((x<< 8)&0xFF00FF00FF00FF00ULL) | ((x>> 8)&0x00FF00FF00FF00FFULL);
65 x= ((x<<16)&0xFFFF0000FFFF0000ULL) | ((x>>16)&0x0000FFFF0000FFFFULL);
66 return (x>>32) | (x<<32);
67 #else
68 union {
69 uint64_t ll;
70 uint32_t l[2];
71 } w, r;
72 w.ll = x;
73 r.l[0] = bswap_32 (w.l[1]);
74 r.l[1] = bswap_32 (w.l[0]);
75 return r.ll;
76 #endif
78 #endif
80 // be2me ... BigEndian to MachineEndian
81 // le2me ... LittleEndian to MachineEndian
83 #ifdef WORDS_BIGENDIAN
84 #define be2me_16(x) (x)
85 #define be2me_32(x) (x)
86 #define be2me_64(x) (x)
87 #define le2me_16(x) bswap_16(x)
88 #define le2me_32(x) bswap_32(x)
89 #define le2me_64(x) bswap_64(x)
90 #else
91 #define be2me_16(x) bswap_16(x)
92 #define be2me_32(x) bswap_32(x)
93 #define be2me_64(x) bswap_64(x)
94 #define le2me_16(x) (x)
95 #define le2me_32(x) (x)
96 #define le2me_64(x) (x)
97 #endif
99 #endif /* AVUTIL_BSWAP_H */