annotate dvdread/bswap.h @ 249:5d643668f1e3 src

I added this code myself a long time ago, but now I am quite convinced that it is wrong: Why would we filter out SPU stream change events that switch SPUs off? This breaks watching the trailer on the RC2 of "Girl, interrupted", because you always get unwanted subtitles. When I added this code, it fixed a problem with the RC2 of "Terminator", but I cannot reproduce this problem any more. Back then, the menu highlights would not show up, but they do now. I assume the problem really got fixed with proper support for forced subtitles in xine, so this crappy workaround here can go away. After all, this way it is more symmetric to audio stream change events, because these are not filtered.
author mroi
date Sun, 12 Sep 2004 15:12:43 +0000
parents 9b1b740e3fc9
children dd2560a4bb90
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
225
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
1 #ifndef BSWAP_H_INCLUDED
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
2 #define BSWAP_H_INCLUDED
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
3
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
4 /*
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
5 * Copyright (C) 2000, 2001 Billy Biggs <vektor@dumbterm.net>,
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
6 * Håkan Hjort <d95hjort@dtek.chalmers.se>
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
7 *
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
11 * (at your option) any later version.
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
12 *
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
16 * GNU General Public License for more details.
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
17 *
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
21 */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
22
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
23 #include <config.h>
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
24
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
25 #if defined(WORDS_BIGENDIAN)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
26 /* All bigendian systems are fine, just ignore the swaps. */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
27 #define B2N_16(x) (void)(x)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
28 #define B2N_32(x) (void)(x)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
29 #define B2N_64(x) (void)(x)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
30
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
31 #else
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
32
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
33 /* For __FreeBSD_version */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
34 #if defined(HAVE_SYS_PARAM_H)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
35 #include <sys/param.h>
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
36 #endif
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
37
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
38 #if defined(__linux__)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
39 #include <byteswap.h>
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
40 #define B2N_16(x) x = bswap_16(x)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
41 #define B2N_32(x) x = bswap_32(x)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
42 #define B2N_64(x) x = bswap_64(x)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
43
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
44 #elif defined(__NetBSD__)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
45 #include <sys/endian.h>
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
46 #define B2N_16(x) BE16TOH(x)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
47 #define B2N_32(x) BE32TOH(x)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
48 #define B2N_64(x) BE64TOH(x)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
49
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
50 #elif defined(__OpenBSD__)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
51 #include <sys/endian.h>
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
52 #define B2N_16(x) x = swap16(x)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
53 #define B2N_32(x) x = swap32(x)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
54 #define B2N_64(x) x = swap64(x)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
55
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
56 #elif defined(__FreeBSD__) && __FreeBSD_version >= 470000
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
57 #include <sys/endian.h>
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
58 #define B2N_16(x) x = be16toh(x)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
59 #define B2N_32(x) x = be32toh(x)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
60 #define B2N_64(x) x = be64toh(x)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
61
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
62 /* This is a slow but portable implementation, it has multiple evaluation
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
63 * problems so beware.
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
64 * Old FreeBSD's and Solaris don't have <byteswap.h> or any other such
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
65 * functionality!
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
66 */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
67
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
68 #elif defined(__FreeBSD__) || defined(__sun) || defined(__bsdi__) || defined(WIN32) || defined(__CYGWIN__)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
69 #define B2N_16(x) \
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
70 x = ((((x) & 0xff00) >> 8) | \
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
71 (((x) & 0x00ff) << 8))
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
72 #define B2N_32(x) \
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
73 x = ((((x) & 0xff000000) >> 24) | \
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
74 (((x) & 0x00ff0000) >> 8) | \
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
75 (((x) & 0x0000ff00) << 8) | \
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
76 (((x) & 0x000000ff) << 24))
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
77 #define B2N_64(x) \
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
78 x = ((((x) & 0xff00000000000000) >> 56) | \
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
79 (((x) & 0x00ff000000000000) >> 40) | \
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
80 (((x) & 0x0000ff0000000000) >> 24) | \
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
81 (((x) & 0x000000ff00000000) >> 8) | \
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
82 (((x) & 0x00000000ff000000) << 8) | \
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
83 (((x) & 0x0000000000ff0000) << 24) | \
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
84 (((x) & 0x000000000000ff00) << 40) | \
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
85 (((x) & 0x00000000000000ff) << 56))
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
86
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
87 #else
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
88
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
89 /* If there isn't a header provided with your system with this functionality
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
90 * add the relevant || define( ) to the portable implementation above.
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
91 */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
92 #error "You need to add endian swap macros for you're system"
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
93
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
94 #endif
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
95
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
96 #endif /* WORDS_BIGENDIAN */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
97
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
98 #endif /* BSWAP_H_INCLUDED */