comparison golomb.h @ 1234:fc2a7eefa9cc libavcodec

svq3 decoder by anonymous
author michaelni
date Fri, 09 May 2003 22:16:14 +0000
parents 4e891257d3e2
children fa181d095027
comparison
equal deleted inserted replaced
1233:5d66713e97e2 1234:fc2a7eefa9cc
22 * @file golomb.h 22 * @file golomb.h
23 * @brief 23 * @brief
24 * exp golomb vlc stuff 24 * exp golomb vlc stuff
25 * @author Michael Niedermayer <michaelni@gmx.at> 25 * @author Michael Niedermayer <michaelni@gmx.at>
26 */ 26 */
27
28 #define INVALID_VLC 0x80000000
27 29
28 extern const uint8_t ff_golomb_vlc_len[512]; 30 extern const uint8_t ff_golomb_vlc_len[512];
29 extern const uint8_t ff_ue_golomb_vlc_code[512]; 31 extern const uint8_t ff_ue_golomb_vlc_code[512];
30 extern const int8_t ff_se_golomb_vlc_code[512]; 32 extern const int8_t ff_se_golomb_vlc_code[512];
31 extern const uint8_t ff_ue_golomb_len[256]; 33 extern const uint8_t ff_ue_golomb_len[256];
57 59
58 return buf; 60 return buf;
59 } 61 }
60 } 62 }
61 63
64 static inline int svq3_get_ue_golomb(GetBitContext *gb){
65 unsigned int buf;
66 int log;
67
68 OPEN_READER(re, gb);
69 UPDATE_CACHE(re, gb);
70 buf=GET_CACHE(re, gb)|1;
71
72 if((buf & 0xAAAAAAAA) == 0)
73 return INVALID_VLC;
74
75 for(log=31; (buf & 0x80000000) == 0; log--){
76 buf = (buf << 2) - ((buf << log) >> (log - 1)) + (buf >> 30);
77 }
78
79 LAST_SKIP_BITS(re, gb, 63 - 2*log);
80 CLOSE_READER(re, gb);
81
82 return ((buf << log) >> log) - 1;
83 }
84
62 /** 85 /**
63 * read unsigned truncated exp golomb code. 86 * read unsigned truncated exp golomb code.
64 */ 87 */
65 static inline int get_te0_golomb(GetBitContext *gb, int range){ 88 static inline int get_te0_golomb(GetBitContext *gb, int range){
66 assert(range >= 1); 89 assert(range >= 1);
108 if(buf&1) buf= -(buf>>1); 131 if(buf&1) buf= -(buf>>1);
109 else buf= (buf>>1); 132 else buf= (buf>>1);
110 133
111 return buf; 134 return buf;
112 } 135 }
136 }
137
138 static inline int svq3_get_se_golomb(GetBitContext *gb){
139 unsigned int buf;
140 int log;
141
142 OPEN_READER(re, gb);
143 UPDATE_CACHE(re, gb);
144 buf=GET_CACHE(re, gb)|1;
145
146 if((buf & 0xAAAAAAAA) == 0)
147 return INVALID_VLC;
148
149 for(log=31; (buf & 0x80000000) == 0; log--){
150 buf = (buf << 2) - ((buf << log) >> (log - 1)) + (buf >> 30);
151 }
152
153 LAST_SKIP_BITS(re, gb, 63 - 2*log);
154 CLOSE_READER(re, gb);
155
156 return (signed) (((((buf << log) >> log) - 1) ^ -(buf & 0x1)) + 1) >> 1;
113 } 157 }
114 158
115 #ifdef TRACE 159 #ifdef TRACE
116 160
117 static inline int get_ue(GetBitContext *s, char *file, char *func, int line){ 161 static inline int get_ue(GetBitContext *s, char *file, char *func, int line){