Mercurial > mplayer.hg
annotate liba52/bitstream.h @ 23011:365eef1fc4f0
Disable caching of rotated glyphs.
The following commits will add perspective distortion to the glyphs rotated
with \frx and \fry. Somewhere along the way correct caching of such glyphs
will become impossible, but in the end everything will be fine.
author | eugeni |
---|---|
date | Fri, 20 Apr 2007 22:49:48 +0000 |
parents | 0783dd397f74 |
children | 49a433e2e78f |
rev | line source |
---|---|
3394 | 1 /* |
2 * bitstream.h | |
18720
4bad7f00556e
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
14991
diff
changeset
|
3 * Copyright (C) 2000-2002 Michel Lespinasse <walken@zoy.org> |
3394 | 4 * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> |
5 * | |
6 * This file is part of a52dec, a free ATSC A-52 stream decoder. | |
7 * See http://liba52.sourceforge.net/ for updates. | |
8 * | |
14991
07f1e7669772
Mark modified files as such to comply more closely with GPL ¡ø2a.
diego
parents:
10489
diff
changeset
|
9 * Modified for use with MPlayer, changes contained in liba52_changes.diff. |
18783 | 10 * detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/ |
14991
07f1e7669772
Mark modified files as such to comply more closely with GPL ¡ø2a.
diego
parents:
10489
diff
changeset
|
11 * $Id$ |
07f1e7669772
Mark modified files as such to comply more closely with GPL ¡ø2a.
diego
parents:
10489
diff
changeset
|
12 * |
3394 | 13 * a52dec is free software; you can redistribute it and/or modify |
14 * it under the terms of the GNU General Public License as published by | |
15 * the Free Software Foundation; either version 2 of the License, or | |
16 * (at your option) any later version. | |
17 * | |
18 * a52dec is distributed in the hope that it will be useful, | |
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 * GNU General Public License for more details. | |
22 * | |
23 * You should have received a copy of the GNU General Public License | |
24 * along with this program; if not, write to the Free Software | |
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
26 */ | |
27 | |
10489
b7a6edb6100e
Changed swab32 from macro to inline function, this fixes compilation on alpha (with gcc2.95). Based on patch by KotH
alex
parents:
10313
diff
changeset
|
28 /* code from ffmpeg/libavcodec */ |
b7a6edb6100e
Changed swab32 from macro to inline function, this fixes compilation on alpha (with gcc2.95). Based on patch by KotH
alex
parents:
10313
diff
changeset
|
29 #if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC_ == 3 && __GNUC_MINOR__ > 0) |
b7a6edb6100e
Changed swab32 from macro to inline function, this fixes compilation on alpha (with gcc2.95). Based on patch by KotH
alex
parents:
10313
diff
changeset
|
30 # define always_inline __attribute__((always_inline)) inline |
b7a6edb6100e
Changed swab32 from macro to inline function, this fixes compilation on alpha (with gcc2.95). Based on patch by KotH
alex
parents:
10313
diff
changeset
|
31 #else |
b7a6edb6100e
Changed swab32 from macro to inline function, this fixes compilation on alpha (with gcc2.95). Based on patch by KotH
alex
parents:
10313
diff
changeset
|
32 # define always_inline inline |
b7a6edb6100e
Changed swab32 from macro to inline function, this fixes compilation on alpha (with gcc2.95). Based on patch by KotH
alex
parents:
10313
diff
changeset
|
33 #endif |
b7a6edb6100e
Changed swab32 from macro to inline function, this fixes compilation on alpha (with gcc2.95). Based on patch by KotH
alex
parents:
10313
diff
changeset
|
34 |
10067
f9eac474eb74
this is a important patch for hpux 11.00, because it avoid the
diego
parents:
7255
diff
changeset
|
35 #if defined(__sparc__) || defined(hpux) |
7255
34b5a0b12558
The ALT_BITSTREAM_READER code does not work on SPARC, because the code accesses
jkeil
parents:
4053
diff
changeset
|
36 /* |
34b5a0b12558
The ALT_BITSTREAM_READER code does not work on SPARC, because the code accesses
jkeil
parents:
4053
diff
changeset
|
37 * the alt bitstream reader performs unaligned memory accesses; that doesn't work |
10067
f9eac474eb74
this is a important patch for hpux 11.00, because it avoid the
diego
parents:
7255
diff
changeset
|
38 * on sparc/hpux. For now, disable ALT_BITSTREAM_READER. |
7255
34b5a0b12558
The ALT_BITSTREAM_READER code does not work on SPARC, because the code accesses
jkeil
parents:
4053
diff
changeset
|
39 */ |
34b5a0b12558
The ALT_BITSTREAM_READER code does not work on SPARC, because the code accesses
jkeil
parents:
4053
diff
changeset
|
40 #undef ALT_BITSTREAM_READER |
34b5a0b12558
The ALT_BITSTREAM_READER code does not work on SPARC, because the code accesses
jkeil
parents:
4053
diff
changeset
|
41 #else |
3570 | 42 // alternative (faster) bitstram reader (reades upto 3 bytes over the end of the input) |
43 #define ALT_BITSTREAM_READER | |
10082 | 44 |
45 /* used to avoid missaligned exceptions on some archs (alpha, ...) */ | |
10313
b479b224d435
arm support by armin.gerritsen@philips.com (also seen a patch like this on openzaurus' mplayer port)
alex
parents:
10082
diff
changeset
|
46 #if defined (ARCH_X86) || defined(ARCH_ARMV4L) |
10082 | 47 # define unaligned32(a) (*(uint32_t*)(a)) |
48 #else | |
49 # ifdef __GNUC__ | |
10489
b7a6edb6100e
Changed swab32 from macro to inline function, this fixes compilation on alpha (with gcc2.95). Based on patch by KotH
alex
parents:
10313
diff
changeset
|
50 static always_inline uint32_t unaligned32(const void *v) { |
10082 | 51 struct Unaligned { |
52 uint32_t i; | |
53 } __attribute__((packed)); | |
54 | |
55 return ((const struct Unaligned *) v)->i; | |
56 } | |
57 # elif defined(__DECC) | |
58 static inline uint32_t unaligned32(const void *v) { | |
59 return *(const __unaligned uint32_t *) v; | |
60 } | |
61 # else | |
62 static inline uint32_t unaligned32(const void *v) { | |
63 return *(const uint32_t *) v; | |
64 } | |
65 # endif | |
66 #endif //!ARCH_X86 | |
67 | |
7255
34b5a0b12558
The ALT_BITSTREAM_READER code does not work on SPARC, because the code accesses
jkeil
parents:
4053
diff
changeset
|
68 #endif |
18721
722ac20fac5f
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
18720
diff
changeset
|
69 |
3394 | 70 /* (stolen from the kernel) */ |
71 #ifdef WORDS_BIGENDIAN | |
72 | |
73 # define swab32(x) (x) | |
74 | |
75 #else | |
76 | |
77 # if defined (__i386__) | |
78 | |
79 # define swab32(x) __i386_swab32(x) | |
18720
4bad7f00556e
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
14991
diff
changeset
|
80 static inline const uint32_t __i386_swab32(uint32_t x) |
3394 | 81 { |
82 __asm__("bswap %0" : "=r" (x) : "0" (x)); | |
83 return x; | |
84 } | |
85 | |
86 # else | |
87 | |
10489
b7a6edb6100e
Changed swab32 from macro to inline function, this fixes compilation on alpha (with gcc2.95). Based on patch by KotH
alex
parents:
10313
diff
changeset
|
88 # define swab32(x) __generic_swab32(x) |
b7a6edb6100e
Changed swab32 from macro to inline function, this fixes compilation on alpha (with gcc2.95). Based on patch by KotH
alex
parents:
10313
diff
changeset
|
89 static always_inline const uint32_t __generic_swab32(uint32_t x) |
b7a6edb6100e
Changed swab32 from macro to inline function, this fixes compilation on alpha (with gcc2.95). Based on patch by KotH
alex
parents:
10313
diff
changeset
|
90 { |
b7a6edb6100e
Changed swab32 from macro to inline function, this fixes compilation on alpha (with gcc2.95). Based on patch by KotH
alex
parents:
10313
diff
changeset
|
91 return ((((uint8_t*)&x)[0] << 24) | (((uint8_t*)&x)[1] << 16) | |
b7a6edb6100e
Changed swab32 from macro to inline function, this fixes compilation on alpha (with gcc2.95). Based on patch by KotH
alex
parents:
10313
diff
changeset
|
92 (((uint8_t*)&x)[2] << 8) | (((uint8_t*)&x)[3])); |
b7a6edb6100e
Changed swab32 from macro to inline function, this fixes compilation on alpha (with gcc2.95). Based on patch by KotH
alex
parents:
10313
diff
changeset
|
93 } |
3394 | 94 # endif |
95 #endif | |
96 | |
3570 | 97 #ifdef ALT_BITSTREAM_READER |
98 extern int indx; | |
99 #endif | |
3394 | 100 |
18720
4bad7f00556e
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
14991
diff
changeset
|
101 void a52_bitstream_set_ptr (a52_state_t * state, uint8_t * buf); |
4bad7f00556e
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
14991
diff
changeset
|
102 uint32_t a52_bitstream_get_bh (a52_state_t * state, uint32_t num_bits); |
4bad7f00556e
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
14991
diff
changeset
|
103 int32_t a52_bitstream_get_bh_2 (a52_state_t * state, uint32_t num_bits); |
3394 | 104 |
18720
4bad7f00556e
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
14991
diff
changeset
|
105 static inline uint32_t bitstream_get (a52_state_t * state, uint32_t num_bits) |
3394 | 106 { |
3570 | 107 #ifdef ALT_BITSTREAM_READER |
18720
4bad7f00556e
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
14991
diff
changeset
|
108 uint32_t result= swab32( unaligned32(((uint8_t *)state->buffer_start)+(indx>>3)) ); |
3570 | 109 |
110 result<<= (indx&0x07); | |
111 result>>= 32 - num_bits; | |
112 indx+= num_bits; | |
113 | |
114 return result; | |
115 #else | |
3394 | 116 uint32_t result; |
18721
722ac20fac5f
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
18720
diff
changeset
|
117 |
18720
4bad7f00556e
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
14991
diff
changeset
|
118 if (num_bits < state->bits_left) { |
4bad7f00556e
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
14991
diff
changeset
|
119 result = (state->current_word << (32 - state->bits_left)) >> (32 - num_bits); |
4bad7f00556e
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
14991
diff
changeset
|
120 state->bits_left -= num_bits; |
3394 | 121 return result; |
122 } | |
123 | |
18720
4bad7f00556e
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
14991
diff
changeset
|
124 return a52_bitstream_get_bh (state, num_bits); |
3570 | 125 #endif |
3394 | 126 } |
127 | |
18720
4bad7f00556e
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
14991
diff
changeset
|
128 static inline void bitstream_skip(a52_state_t * state, int num_bits) |
4053
75415651e3b9
bitstream_skip() instead of bitstream_get() if possible
michael
parents:
3570
diff
changeset
|
129 { |
75415651e3b9
bitstream_skip() instead of bitstream_get() if possible
michael
parents:
3570
diff
changeset
|
130 #ifdef ALT_BITSTREAM_READER |
75415651e3b9
bitstream_skip() instead of bitstream_get() if possible
michael
parents:
3570
diff
changeset
|
131 indx+= num_bits; |
75415651e3b9
bitstream_skip() instead of bitstream_get() if possible
michael
parents:
3570
diff
changeset
|
132 #else |
18720
4bad7f00556e
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
14991
diff
changeset
|
133 bitstream_get(state, num_bits); |
4053
75415651e3b9
bitstream_skip() instead of bitstream_get() if possible
michael
parents:
3570
diff
changeset
|
134 #endif |
75415651e3b9
bitstream_skip() instead of bitstream_get() if possible
michael
parents:
3570
diff
changeset
|
135 } |
75415651e3b9
bitstream_skip() instead of bitstream_get() if possible
michael
parents:
3570
diff
changeset
|
136 |
18720
4bad7f00556e
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
14991
diff
changeset
|
137 static inline int32_t bitstream_get_2 (a52_state_t * state, uint32_t num_bits) |
3394 | 138 { |
3570 | 139 #ifdef ALT_BITSTREAM_READER |
18720
4bad7f00556e
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
14991
diff
changeset
|
140 int32_t result= swab32( unaligned32(((uint8_t *)state->buffer_start)+(indx>>3)) ); |
3570 | 141 |
142 result<<= (indx&0x07); | |
143 result>>= 32 - num_bits; | |
144 indx+= num_bits; | |
145 | |
146 return result; | |
147 #else | |
3394 | 148 int32_t result; |
149 | |
18720
4bad7f00556e
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
14991
diff
changeset
|
150 if (num_bits < state->bits_left) { |
4bad7f00556e
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
14991
diff
changeset
|
151 result = (((int32_t)state->current_word) << (32 - state->bits_left)) >> (32 - num_bits); |
4bad7f00556e
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
14991
diff
changeset
|
152 state->bits_left -= num_bits; |
3394 | 153 return result; |
154 } | |
155 | |
18720
4bad7f00556e
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
14991
diff
changeset
|
156 return a52_bitstream_get_bh_2 (state, num_bits); |
3570 | 157 #endif |
3394 | 158 } |