diff options
-rw-r--r-- | apps/codecs/lib/ffmpeg_bswap.h (renamed from apps/codecs/libcook/bswap.h) | 0 | ||||
-rw-r--r-- | apps/codecs/libatrac/bitstream.h | 2 | ||||
-rw-r--r-- | apps/codecs/libatrac/bswap.h | 150 | ||||
-rw-r--r-- | apps/codecs/libcook/bitstream.h | 2 | ||||
-rw-r--r-- | apps/codecs/libwma/bitstream.h | 2 | ||||
-rw-r--r-- | apps/codecs/libwma/bswap.h | 150 |
6 files changed, 3 insertions, 303 deletions
diff --git a/apps/codecs/libcook/bswap.h b/apps/codecs/lib/ffmpeg_bswap.h index b083d10ed0..b083d10ed0 100644 --- a/apps/codecs/libcook/bswap.h +++ b/apps/codecs/lib/ffmpeg_bswap.h | |||
diff --git a/apps/codecs/libatrac/bitstream.h b/apps/codecs/libatrac/bitstream.h index b4c3136be3..c4b5496d00 100644 --- a/apps/codecs/libatrac/bitstream.h +++ b/apps/codecs/libatrac/bitstream.h | |||
@@ -26,7 +26,7 @@ | |||
26 | //#include <assert.h> | 26 | //#include <assert.h> |
27 | #include <string.h> | 27 | #include <string.h> |
28 | #include <stdio.h> | 28 | #include <stdio.h> |
29 | #include "bswap.h" | 29 | #include "../lib/ffmpeg_bswap.h" |
30 | 30 | ||
31 | /* The following 2 defines are taken from libavutil/intreadwrite.h */ | 31 | /* The following 2 defines are taken from libavutil/intreadwrite.h */ |
32 | #define AV_RB32(x) ((((const uint8_t*)(x))[0] << 24) | \ | 32 | #define AV_RB32(x) ((((const uint8_t*)(x))[0] << 24) | \ |
diff --git a/apps/codecs/libatrac/bswap.h b/apps/codecs/libatrac/bswap.h deleted file mode 100644 index ff807815a3..0000000000 --- a/apps/codecs/libatrac/bswap.h +++ /dev/null | |||
@@ -1,150 +0,0 @@ | |||
1 | /** | ||
2 | * @file bswap.h | ||
3 | * byte swap. | ||
4 | */ | ||
5 | |||
6 | #ifndef __BSWAP_H__ | ||
7 | #define __BSWAP_H__ | ||
8 | |||
9 | #ifdef HAVE_BYTESWAP_H | ||
10 | #include <byteswap.h> | ||
11 | #else | ||
12 | |||
13 | #ifdef ROCKBOX | ||
14 | #include "codecs.h" | ||
15 | |||
16 | /* rockbox' optimised inline functions */ | ||
17 | #define bswap_16(x) swap16(x) | ||
18 | #define bswap_32(x) swap32(x) | ||
19 | |||
20 | static inline uint64_t ByteSwap64(uint64_t x) | ||
21 | { | ||
22 | union { | ||
23 | uint64_t ll; | ||
24 | struct { | ||
25 | uint32_t l,h; | ||
26 | } l; | ||
27 | } r; | ||
28 | r.l.l = bswap_32 (x); | ||
29 | r.l.h = bswap_32 (x>>32); | ||
30 | return r.ll; | ||
31 | } | ||
32 | #define bswap_64(x) ByteSwap64(x) | ||
33 | |||
34 | #elif defined(ARCH_X86) | ||
35 | static inline unsigned short ByteSwap16(unsigned short x) | ||
36 | { | ||
37 | __asm("xchgb %b0,%h0" : | ||
38 | "=q" (x) : | ||
39 | "0" (x)); | ||
40 | return x; | ||
41 | } | ||
42 | #define bswap_16(x) ByteSwap16(x) | ||
43 | |||
44 | static inline unsigned int ByteSwap32(unsigned int x) | ||
45 | { | ||
46 | #if __CPU__ > 386 | ||
47 | __asm("bswap %0": | ||
48 | "=r" (x) : | ||
49 | #else | ||
50 | __asm("xchgb %b0,%h0\n" | ||
51 | " rorl $16,%0\n" | ||
52 | " xchgb %b0,%h0": | ||
53 | "=q" (x) : | ||
54 | #endif | ||
55 | "0" (x)); | ||
56 | return x; | ||
57 | } | ||
58 | #define bswap_32(x) ByteSwap32(x) | ||
59 | |||
60 | static inline unsigned long long int ByteSwap64(unsigned long long int x) | ||
61 | { | ||
62 | register union { __extension__ uint64_t __ll; | ||
63 | uint32_t __l[2]; } __x; | ||
64 | asm("xchgl %0,%1": | ||
65 | "=r"(__x.__l[0]),"=r"(__x.__l[1]): | ||
66 | "0"(bswap_32((unsigned long)x)),"1"(bswap_32((unsigned long)(x>>32)))); | ||
67 | return __x.__ll; | ||
68 | } | ||
69 | #define bswap_64(x) ByteSwap64(x) | ||
70 | |||
71 | #elif defined(ARCH_SH4) | ||
72 | |||
73 | static inline uint16_t ByteSwap16(uint16_t x) { | ||
74 | __asm__("swap.b %0,%0":"=r"(x):"0"(x)); | ||
75 | return x; | ||
76 | } | ||
77 | |||
78 | static inline uint32_t ByteSwap32(uint32_t x) { | ||
79 | __asm__( | ||
80 | "swap.b %0,%0\n" | ||
81 | "swap.w %0,%0\n" | ||
82 | "swap.b %0,%0\n" | ||
83 | :"=r"(x):"0"(x)); | ||
84 | return x; | ||
85 | } | ||
86 | |||
87 | #define bswap_16(x) ByteSwap16(x) | ||
88 | #define bswap_32(x) ByteSwap32(x) | ||
89 | |||
90 | static inline uint64_t ByteSwap64(uint64_t x) | ||
91 | { | ||
92 | union { | ||
93 | uint64_t ll; | ||
94 | struct { | ||
95 | uint32_t l,h; | ||
96 | } l; | ||
97 | } r; | ||
98 | r.l.l = bswap_32 (x); | ||
99 | r.l.h = bswap_32 (x>>32); | ||
100 | return r.ll; | ||
101 | } | ||
102 | #define bswap_64(x) ByteSwap64(x) | ||
103 | |||
104 | #else | ||
105 | |||
106 | #define bswap_16(x) (((x) & 0x00ff) << 8 | ((x) & 0xff00) >> 8) | ||
107 | |||
108 | |||
109 | // code from bits/byteswap.h (C) 1997, 1998 Free Software Foundation, Inc. | ||
110 | #define bswap_32(x) \ | ||
111 | ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ | ||
112 | (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) | ||
113 | |||
114 | /*static inline uint64_t ByteSwap64(uint64_t x) | ||
115 | { | ||
116 | union { | ||
117 | uint64_t ll; | ||
118 | uint32_t l[2]; | ||
119 | } w, r; | ||
120 | w.ll = x; | ||
121 | r.l[0] = bswap_32 (w.l[1]); | ||
122 | r.l[1] = bswap_32 (w.l[0]); | ||
123 | return r.ll; | ||
124 | }*/ | ||
125 | #define bswap_64(x) ByteSwap64(x) | ||
126 | |||
127 | #endif /* !ARCH_X86 */ | ||
128 | |||
129 | #endif /* !HAVE_BYTESWAP_H */ | ||
130 | |||
131 | // be2me ... BigEndian to MachineEndian | ||
132 | // le2me ... LittleEndian to MachineEndian | ||
133 | |||
134 | #ifdef WORDS_BIGENDIAN | ||
135 | #define be2me_16(x) (x) | ||
136 | #define be2me_32(x) (x) | ||
137 | #define be2me_64(x) (x) | ||
138 | #define le2me_16(x) bswap_16(x) | ||
139 | #define le2me_32(x) bswap_32(x) | ||
140 | #define le2me_64(x) bswap_64(x) | ||
141 | #else | ||
142 | #define be2me_16(x) bswap_16(x) | ||
143 | #define be2me_32(x) bswap_32(x) | ||
144 | #define be2me_64(x) bswap_64(x) | ||
145 | #define le2me_16(x) (x) | ||
146 | #define le2me_32(x) (x) | ||
147 | #define le2me_64(x) (x) | ||
148 | #endif | ||
149 | |||
150 | #endif /* __BSWAP_H__ */ | ||
diff --git a/apps/codecs/libcook/bitstream.h b/apps/codecs/libcook/bitstream.h index b4c3136be3..c4b5496d00 100644 --- a/apps/codecs/libcook/bitstream.h +++ b/apps/codecs/libcook/bitstream.h | |||
@@ -26,7 +26,7 @@ | |||
26 | //#include <assert.h> | 26 | //#include <assert.h> |
27 | #include <string.h> | 27 | #include <string.h> |
28 | #include <stdio.h> | 28 | #include <stdio.h> |
29 | #include "bswap.h" | 29 | #include "../lib/ffmpeg_bswap.h" |
30 | 30 | ||
31 | /* The following 2 defines are taken from libavutil/intreadwrite.h */ | 31 | /* The following 2 defines are taken from libavutil/intreadwrite.h */ |
32 | #define AV_RB32(x) ((((const uint8_t*)(x))[0] << 24) | \ | 32 | #define AV_RB32(x) ((((const uint8_t*)(x))[0] << 24) | \ |
diff --git a/apps/codecs/libwma/bitstream.h b/apps/codecs/libwma/bitstream.h index 77ccff695e..7de6411db9 100644 --- a/apps/codecs/libwma/bitstream.h +++ b/apps/codecs/libwma/bitstream.h | |||
@@ -33,7 +33,7 @@ | |||
33 | #include "ffmpeg_config.h" | 33 | #include "ffmpeg_config.h" |
34 | #include <stdlib.h> | 34 | #include <stdlib.h> |
35 | 35 | ||
36 | #include "bswap.h" | 36 | #include "../lib/ffmpeg_bswap.h" |
37 | 37 | ||
38 | extern const uint8_t ff_log2_tab[256]; | 38 | extern const uint8_t ff_log2_tab[256]; |
39 | 39 | ||
diff --git a/apps/codecs/libwma/bswap.h b/apps/codecs/libwma/bswap.h deleted file mode 100644 index 33377cfcba..0000000000 --- a/apps/codecs/libwma/bswap.h +++ /dev/null | |||
@@ -1,150 +0,0 @@ | |||
1 | /** | ||
2 | * @file bswap.h | ||
3 | * byte swap. | ||
4 | */ | ||
5 | |||
6 | #ifndef __BSWAP_H__ | ||
7 | #define __BSWAP_H__ | ||
8 | |||
9 | #ifdef HAVE_BYTESWAP_H | ||
10 | #include <byteswap.h> | ||
11 | #else | ||
12 | |||
13 | #ifdef ROCKBOX | ||
14 | #include "codecs.h" | ||
15 | |||
16 | /* rockbox' optimised inline functions */ | ||
17 | #define bswap_16(x) swap16(x) | ||
18 | #define bswap_32(x) swap32(x) | ||
19 | |||
20 | static inline uint64_t ByteSwap64(uint64_t x) | ||
21 | { | ||
22 | union { | ||
23 | uint64_t ll; | ||
24 | struct { | ||
25 | uint32_t l,h; | ||
26 | } l; | ||
27 | } r; | ||
28 | r.l.l = bswap_32 (x); | ||
29 | r.l.h = bswap_32 (x>>32); | ||
30 | return r.ll; | ||
31 | } | ||
32 | #define bswap_64(x) ByteSwap64(x) | ||
33 | |||
34 | #elif defined(ARCH_X86) | ||
35 | static inline unsigned short ByteSwap16(unsigned short x) | ||
36 | { | ||
37 | __asm("xchgb %b0,%h0" : | ||
38 | "=q" (x) : | ||
39 | "0" (x)); | ||
40 | return x; | ||
41 | } | ||
42 | #define bswap_16(x) ByteSwap16(x) | ||
43 | |||
44 | static inline unsigned int ByteSwap32(unsigned int x) | ||
45 | { | ||
46 | #if __CPU__ > 386 | ||
47 | __asm("bswap %0": | ||
48 | "=r" (x) : | ||
49 | #else | ||
50 | __asm("xchgb %b0,%h0\n" | ||
51 | " rorl $16,%0\n" | ||
52 | " xchgb %b0,%h0": | ||
53 | "=q" (x) : | ||
54 | #endif | ||
55 | "0" (x)); | ||
56 | return x; | ||
57 | } | ||
58 | #define bswap_32(x) ByteSwap32(x) | ||
59 | |||
60 | static inline unsigned long long int ByteSwap64(unsigned long long int x) | ||
61 | { | ||
62 | register union { __extension__ uint64_t __ll; | ||
63 | uint32_t __l[2]; } __x; | ||
64 | asm("xchgl %0,%1": | ||
65 | "=r"(__x.__l[0]),"=r"(__x.__l[1]): | ||
66 | "0"(bswap_32((unsigned long)x)),"1"(bswap_32((unsigned long)(x>>32)))); | ||
67 | return __x.__ll; | ||
68 | } | ||
69 | #define bswap_64(x) ByteSwap64(x) | ||
70 | |||
71 | #elif defined(ARCH_SH4) | ||
72 | |||
73 | static inline uint16_t ByteSwap16(uint16_t x) { | ||
74 | __asm__("swap.b %0,%0":"=r"(x):"0"(x)); | ||
75 | return x; | ||
76 | } | ||
77 | |||
78 | static inline uint32_t ByteSwap32(uint32_t x) { | ||
79 | __asm__( | ||
80 | "swap.b %0,%0\n" | ||
81 | "swap.w %0,%0\n" | ||
82 | "swap.b %0,%0\n" | ||
83 | :"=r"(x):"0"(x)); | ||
84 | return x; | ||
85 | } | ||
86 | |||
87 | #define bswap_16(x) ByteSwap16(x) | ||
88 | #define bswap_32(x) ByteSwap32(x) | ||
89 | |||
90 | static inline uint64_t ByteSwap64(uint64_t x) | ||
91 | { | ||
92 | union { | ||
93 | uint64_t ll; | ||
94 | struct { | ||
95 | uint32_t l,h; | ||
96 | } l; | ||
97 | } r; | ||
98 | r.l.l = bswap_32 (x); | ||
99 | r.l.h = bswap_32 (x>>32); | ||
100 | return r.ll; | ||
101 | } | ||
102 | #define bswap_64(x) ByteSwap64(x) | ||
103 | |||
104 | #else | ||
105 | |||
106 | #define bswap_16(x) (((x) & 0x00ff) << 8 | ((x) & 0xff00) >> 8) | ||
107 | |||
108 | |||
109 | // code from bits/byteswap.h (C) 1997, 1998 Free Software Foundation, Inc. | ||
110 | #define bswap_32(x) \ | ||
111 | ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ | ||
112 | (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) | ||
113 | |||
114 | static inline uint64_t ByteSwap64(uint64_t x) | ||
115 | { | ||
116 | union { | ||
117 | uint64_t ll; | ||
118 | uint32_t l[2]; | ||
119 | } w, r; | ||
120 | w.ll = x; | ||
121 | r.l[0] = bswap_32 (w.l[1]); | ||
122 | r.l[1] = bswap_32 (w.l[0]); | ||
123 | return r.ll; | ||
124 | } | ||
125 | #define bswap_64(x) ByteSwap64(x) | ||
126 | |||
127 | #endif /* !ARCH_X86 */ | ||
128 | |||
129 | #endif /* !HAVE_BYTESWAP_H */ | ||
130 | |||
131 | // be2me ... BigEndian to MachineEndian | ||
132 | // le2me ... LittleEndian to MachineEndian | ||
133 | |||
134 | #ifdef WORDS_BIGENDIAN | ||
135 | #define be2me_16(x) (x) | ||
136 | #define be2me_32(x) (x) | ||
137 | #define be2me_64(x) (x) | ||
138 | #define le2me_16(x) bswap_16(x) | ||
139 | #define le2me_32(x) bswap_32(x) | ||
140 | #define le2me_64(x) bswap_64(x) | ||
141 | #else | ||
142 | #define be2me_16(x) bswap_16(x) | ||
143 | #define be2me_32(x) bswap_32(x) | ||
144 | #define be2me_64(x) bswap_64(x) | ||
145 | #define le2me_16(x) (x) | ||
146 | #define le2me_32(x) (x) | ||
147 | #define le2me_64(x) (x) | ||
148 | #endif | ||
149 | |||
150 | #endif /* __BSWAP_H__ */ | ||