annotate golomb.h @ 1168:5af9aeadbdc3 libavcodec

H264 decoder & demuxer
author michaelni
date Fri, 04 Apr 2003 14:42:28 +0000
parents
children 4e891257d3e2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1168
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
1 /*
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
2 * exp golomb vlc stuff
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
3 * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
4 *
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
9 *
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
13 * Lesser General Public License for more details.
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
14 *
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
16 * License along with this library; if not, write to the Free Software
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
18 *
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
19 */
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
20
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
21 /**
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
22 * @file golomb.h
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
23 * @brief
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
24 * exp golomb vlc stuff
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
25 * @author Michael Niedermayer <michaelni@gmx.at>
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
26 */
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
27
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
28 extern const uint8_t ff_golomb_vlc_len[512];
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
29 extern const uint8_t ff_ue_golomb_vlc_code[512];
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
30 extern const int8_t ff_se_golomb_vlc_code[512];
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
31 extern const uint8_t ff_ue_golomb_len[256];
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
32
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
33
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
34 /**
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
35 * read unsigned exp golomb code.
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
36 */
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
37 static inline int get_ue_golomb(GetBitContext *gb){
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
38 unsigned int buf;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
39 int log;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
40
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
41 OPEN_READER(re, gb);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
42 UPDATE_CACHE(re, gb);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
43 buf=GET_CACHE(re, gb);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
44
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
45 if(buf >= (1<<27)){
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
46 buf >>= 32 - 9;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
47 LAST_SKIP_BITS(re, gb, ff_golomb_vlc_len[buf]);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
48 CLOSE_READER(re, gb);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
49
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
50 return ff_ue_golomb_vlc_code[buf];
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
51 }else{
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
52 log= 2*av_log2(buf) - 31;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
53 buf>>= log;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
54 buf--;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
55 LAST_SKIP_BITS(re, gb, 32 - log);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
56 CLOSE_READER(re, gb);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
57
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
58 return buf;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
59 }
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
60 }
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
61
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
62 /**
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
63 * read unsigned truncated exp golomb code.
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
64 */
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
65 static inline int get_te0_golomb(GetBitContext *gb, int range){
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
66 assert(range >= 1);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
67
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
68 if(range==1) return 0;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
69 else if(range==2) return get_bits1(gb);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
70 else return get_ue_golomb(gb);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
71 }
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
72
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
73 /**
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
74 * read unsigned truncated exp golomb code.
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
75 */
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
76 static inline int get_te_golomb(GetBitContext *gb, int range){
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
77 assert(range >= 1);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
78
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
79 if(range==2) return get_bits1(gb);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
80 else return get_ue_golomb(gb);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
81 }
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
82
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
83
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
84 /**
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
85 * read signed exp golomb code.
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
86 */
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
87 static inline int get_se_golomb(GetBitContext *gb){
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
88 unsigned int buf;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
89 int log;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
90
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
91 OPEN_READER(re, gb);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
92 UPDATE_CACHE(re, gb);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
93 buf=GET_CACHE(re, gb);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
94
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
95 if(buf >= (1<<27)){
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
96 buf >>= 32 - 9;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
97 LAST_SKIP_BITS(re, gb, ff_golomb_vlc_len[buf]);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
98 CLOSE_READER(re, gb);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
99
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
100 return ff_se_golomb_vlc_code[buf];
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
101 }else{
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
102 log= 2*av_log2(buf) - 31;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
103 buf>>= log;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
104
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
105 LAST_SKIP_BITS(re, gb, 32 - log);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
106 CLOSE_READER(re, gb);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
107
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
108 if(buf&1) buf= -(buf>>1);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
109 else buf= (buf>>1);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
110
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
111 return buf;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
112 }
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
113 }
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
114
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
115 #ifdef TRACE
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
116
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
117 static inline int get_ue(GetBitContext *s, char *file, char *func, int line){
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
118 int show= show_bits(s, 24);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
119 int pos= get_bits_count(s);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
120 int i= get_ue_golomb(s);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
121 int len= get_bits_count(s) - pos;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
122 int bits= show>>(24-len);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
123
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
124 print_bin(bits, len);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
125
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
126 printf("%5d %2d %3d ue @%5d in %s %s:%d\n", bits, len, i, pos, file, func, line);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
127
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
128 return i;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
129 }
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
130
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
131 static inline int get_se(GetBitContext *s, char *file, char *func, int line){
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
132 int show= show_bits(s, 24);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
133 int pos= get_bits_count(s);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
134 int i= get_se_golomb(s);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
135 int len= get_bits_count(s) - pos;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
136 int bits= show>>(24-len);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
137
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
138 print_bin(bits, len);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
139
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
140 printf("%5d %2d %3d se @%5d in %s %s:%d\n", bits, len, i, pos, file, func, line);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
141
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
142 return i;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
143 }
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
144
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
145 static inline int get_te(GetBitContext *s, int r, char *file, char *func, int line){
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
146 int show= show_bits(s, 24);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
147 int pos= get_bits_count(s);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
148 int i= get_te0_golomb(s, r);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
149 int len= get_bits_count(s) - pos;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
150 int bits= show>>(24-len);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
151
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
152 print_bin(bits, len);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
153
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
154 printf("%5d %2d %3d te @%5d in %s %s:%d\n", bits, len, i, pos, file, func, line);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
155
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
156 return i;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
157 }
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
158
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
159 #define get_ue_golomb(a) get_ue(a, __FILE__, __PRETTY_FUNCTION__, __LINE__)
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
160 #define get_se_golomb(a) get_se(a, __FILE__, __PRETTY_FUNCTION__, __LINE__)
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
161 #define get_te_golomb(a, r) get_te(a, r, __FILE__, __PRETTY_FUNCTION__, __LINE__)
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
162 #define get_te0_golomb(a, r) get_te(a, r, __FILE__, __PRETTY_FUNCTION__, __LINE__)
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
163
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
164 #endif
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
165
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
166 /**
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
167 * write unsigned exp golomb code.
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
168 */
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
169 static inline void set_ue_golomb(PutBitContext *pb, int i){
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
170 int e;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
171
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
172 assert(i>=0);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
173
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
174 #if 0
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
175 if(i=0){
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
176 put_bits(pb, 1, 1);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
177 return;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
178 }
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
179 #endif
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
180 if(i<256)
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
181 put_bits(pb, ff_ue_golomb_len[i], i+1);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
182 else{
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
183 e= av_log2(i+1);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
184
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
185 put_bits(pb, 2*e+1, i+1);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
186 }
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
187 }
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
188
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
189 /**
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
190 * write truncated unsigned exp golomb code.
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
191 */
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
192 static inline void set_te_golomb(PutBitContext *pb, int i, int range){
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
193 assert(range >= 1);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
194 assert(i<=range);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
195
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
196 if(range==2) put_bits(pb, 1, i);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
197 else set_ue_golomb(pb, i);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
198 }
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
199
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
200 /**
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
201 * write signed exp golomb code.
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
202 */
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
203 static inline void set_se_golomb(PutBitContext *pb, int i){
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
204 #if 0
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
205 if(i<=0) i= -2*i;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
206 else i= 2*i-1;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
207 #elif 1
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
208 i= 2*i-1;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
209 if(i<0) i^= -1; //FIXME check if gcc does the right thing
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
210 #else
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
211 i= 2*i-1;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
212 i^= (i>>31);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
213 #endif
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
214 set_ue_golomb(pb, i);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
215 }