Browse code

get_bits: whitespace (mostly) cosmetics

Signed-off-by: Mans Rullgard <mans@mansr.com>

Mans Rullgard authored on 2011/12/17 10:05:35
Showing 1 changed files
... ...
@@ -125,33 +125,37 @@ for examples see get_bits, show_bits, skip_bits, get_vlc
125 125
 #   define MIN_CACHE_BITS 25
126 126
 #endif
127 127
 
128
-#   define OPEN_READER(name, gb)                \
128
+#define OPEN_READER(name, gb)                   \
129 129
     unsigned int name##_index = (gb)->index;    \
130 130
     unsigned int av_unused name##_cache = 0
131 131
 
132
-#   define CLOSE_READER(name, gb) (gb)->index = name##_index
132
+#define CLOSE_READER(name, gb) (gb)->index = name##_index
133
+
134
+#ifdef ALT_BITSTREAM_READER_LE
133 135
 
134
-# ifdef ALT_BITSTREAM_READER_LE
135 136
 # ifdef LONG_BITSTREAM_READER
136
-#   define UPDATE_CACHE(name, gb) \
137
-    name##_cache = AV_RL64((gb)->buffer+(name##_index>>3)) >> (name##_index&0x07)
137
+#   define UPDATE_CACHE(name, gb) name##_cache = \
138
+        AV_RL64((gb)->buffer + (name##_index >> 3)) >> (name##_index & 7)
138 139
 # else
139
-#   define UPDATE_CACHE(name, gb) \
140
-    name##_cache = AV_RL32((gb)->buffer+(name##_index>>3)) >> (name##_index&0x07)
140
+#   define UPDATE_CACHE(name, gb) name##_cache = \
141
+        AV_RL32((gb)->buffer + (name##_index >> 3)) >> (name##_index & 7)
141 142
 # endif
142 143
 
143
-#   define SKIP_CACHE(name, gb, num) name##_cache >>= (num)
144
-# else
144
+# define SKIP_CACHE(name, gb, num) name##_cache >>= (num)
145
+
146
+#else
147
+
145 148
 # ifdef LONG_BITSTREAM_READER
146
-#   define UPDATE_CACHE(name, gb) \
147
-    name##_cache = AV_RB64((gb)->buffer+(name##_index >> 3)) >> (32 - (name##_index & 0x07))
149
+#   define UPDATE_CACHE(name, gb) name##_cache = \
150
+        AV_RB64((gb)->buffer + (name##_index >> 3)) >> (32 - (name##_index & 7))
148 151
 # else
149
-#   define UPDATE_CACHE(name, gb) \
150
-    name##_cache = AV_RB32((gb)->buffer+(name##_index>>3)) << (name##_index&0x07)
152
+#   define UPDATE_CACHE(name, gb) name##_cache = \
153
+        AV_RB32((gb)->buffer + (name##_index >> 3)) << (name##_index & 7)
151 154
 # endif
152 155
 
153
-#   define SKIP_CACHE(name, gb, num) name##_cache <<= (num)
154
-# endif
156
+# define SKIP_CACHE(name, gb, num) name##_cache <<= (num)
157
+
158
+#endif
155 159
 
156 160
 // FIXME name?
157 161
 #if UNCHECKED_BITSTREAM_READER
... ...
@@ -161,27 +165,26 @@ for examples see get_bits, show_bits, skip_bits, get_vlc
161 161
     name##_index = FFMIN((gb)->size_in_bits_plus8, name##_index + (num))
162 162
 #endif
163 163
 
164
-#   define SKIP_BITS(name, gb, num) do {        \
164
+#define SKIP_BITS(name, gb, num) do {           \
165 165
         SKIP_CACHE(name, gb, num);              \
166 166
         SKIP_COUNTER(name, gb, num);            \
167 167
     } while (0)
168 168
 
169
-#   define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num)
170
-#   define LAST_SKIP_CACHE(name, gb, num)
169
+#define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num)
170
+#define LAST_SKIP_CACHE(name, gb, num)
171 171
 
172
-# ifdef ALT_BITSTREAM_READER_LE
172
+#ifdef ALT_BITSTREAM_READER_LE
173 173
 #   define SHOW_UBITS(name, gb, num) zero_extend(name##_cache, num)
174
-
175 174
 #   define SHOW_SBITS(name, gb, num) sign_extend(name##_cache, num)
176
-# else
175
+#else
177 176
 #   define SHOW_UBITS(name, gb, num) NEG_USR32(name##_cache, num)
178
-
179 177
 #   define SHOW_SBITS(name, gb, num) NEG_SSR32(name##_cache, num)
180
-# endif
178
+#endif
181 179
 
182
-#   define GET_CACHE(name, gb) ((uint32_t)name##_cache)
180
+#define GET_CACHE(name, gb) ((uint32_t)name##_cache)
183 181
 
184
-static inline int get_bits_count(const GetBitContext *s){
182
+static inline int get_bits_count(const GetBitContext *s)
183
+{
185 184
     return s->index;
186 185
 }
187 186
 
... ...
@@ -199,7 +202,8 @@ static inline void skip_bits_long(GetBitContext *s, int n){
199 199
  * @param n length in bits
200 200
  * @author BERO
201 201
  */
202
-static inline int get_xbits(GetBitContext *s, int n){
202
+static inline int get_xbits(GetBitContext *s, int n)
203
+{
203 204
     register int sign;
204 205
     register int32_t cache;
205 206
     OPEN_READER(re, s);
... ...
@@ -211,7 +215,8 @@ static inline int get_xbits(GetBitContext *s, int n){
211 211
     return (NEG_USR32(sign ^ cache, n) ^ sign) - sign;
212 212
 }
213 213
 
214
-static inline int get_sbits(GetBitContext *s, int n){
214
+static inline int get_sbits(GetBitContext *s, int n)
215
+{
215 216
     register int tmp;
216 217
     OPEN_READER(re, s);
217 218
     UPDATE_CACHE(re, s);
... ...
@@ -224,7 +229,8 @@ static inline int get_sbits(GetBitContext *s, int n){
224 224
 /**
225 225
  * Read 1-25 bits.
226 226
  */
227
-static inline unsigned int get_bits(GetBitContext *s, int n){
227
+static inline unsigned int get_bits(GetBitContext *s, int n)
228
+{
228 229
     register int tmp;
229 230
     OPEN_READER(re, s);
230 231
     UPDATE_CACHE(re, s);
... ...
@@ -237,7 +243,8 @@ static inline unsigned int get_bits(GetBitContext *s, int n){
237 237
 /**
238 238
  * Show 1-25 bits.
239 239
  */
240
-static inline unsigned int show_bits(GetBitContext *s, int n){
240
+static inline unsigned int show_bits(GetBitContext *s, int n)
241
+{
241 242
     register int tmp;
242 243
     OPEN_READER(re, s);
243 244
     UPDATE_CACHE(re, s);
... ...
@@ -245,7 +252,8 @@ static inline unsigned int show_bits(GetBitContext *s, int n){
245 245
     return tmp;
246 246
 }
247 247
 
248
-static inline void skip_bits(GetBitContext *s, int n){
248
+static inline void skip_bits(GetBitContext *s, int n)
249
+{
249 250
  //Note gcc seems to optimize this to s->index+=n for the ALT_READER :))
250 251
     OPEN_READER(re, s);
251 252
     UPDATE_CACHE(re, s);
... ...
@@ -253,7 +261,8 @@ static inline void skip_bits(GetBitContext *s, int n){
253 253
     CLOSE_READER(re, s);
254 254
 }
255 255
 
256
-static inline unsigned int get_bits1(GetBitContext *s){
256
+static inline unsigned int get_bits1(GetBitContext *s)
257
+{
257 258
     unsigned int index = s->index;
258 259
     uint8_t result = s->buffer[index>>3];
259 260
 #ifdef ALT_BITSTREAM_READER_LE
... ...
@@ -272,19 +281,23 @@ static inline unsigned int get_bits1(GetBitContext *s){
272 272
     return result;
273 273
 }
274 274
 
275
-static inline unsigned int show_bits1(GetBitContext *s){
275
+static inline unsigned int show_bits1(GetBitContext *s)
276
+{
276 277
     return show_bits(s, 1);
277 278
 }
278 279
 
279
-static inline void skip_bits1(GetBitContext *s){
280
+static inline void skip_bits1(GetBitContext *s)
281
+{
280 282
     skip_bits(s, 1);
281 283
 }
282 284
 
283 285
 /**
284 286
  * Read 0-32 bits.
285 287
  */
286
-static inline unsigned int get_bits_long(GetBitContext *s, int n){
287
-    if (n <= MIN_CACHE_BITS) return get_bits(s, n);
288
+static inline unsigned int get_bits_long(GetBitContext *s, int n)
289
+{
290
+    if (n <= MIN_CACHE_BITS)
291
+        return get_bits(s, n);
288 292
     else {
289 293
 #ifdef ALT_BITSTREAM_READER_LE
290 294
         int ret = get_bits(s, 16);
... ...
@@ -299,15 +312,18 @@ static inline unsigned int get_bits_long(GetBitContext *s, int n){
299 299
 /**
300 300
  * Read 0-32 bits as a signed integer.
301 301
  */
302
-static inline int get_sbits_long(GetBitContext *s, int n) {
302
+static inline int get_sbits_long(GetBitContext *s, int n)
303
+{
303 304
     return sign_extend(get_bits_long(s, n), n);
304 305
 }
305 306
 
306 307
 /**
307 308
  * Show 0-32 bits.
308 309
  */
309
-static inline unsigned int show_bits_long(GetBitContext *s, int n){
310
-    if (n <= MIN_CACHE_BITS) return show_bits(s, n);
310
+static inline unsigned int show_bits_long(GetBitContext *s, int n)
311
+{
312
+    if (n <= MIN_CACHE_BITS)
313
+        return show_bits(s, n);
311 314
     else {
312 315
         GetBitContext gb = *s;
313 316
         return get_bits_long(&gb, n);
... ...
@@ -332,8 +348,8 @@ static inline int check_marker(GetBitContext *s, const char *msg)
332 332
  * While GetBitContext stores the buffer size, for performance reasons you are
333 333
  * responsible for checking for the buffer end yourself (take advantage of the padding)!
334 334
  */
335
-static inline void init_get_bits(GetBitContext *s,
336
-                   const uint8_t *buffer, int bit_size)
335
+static inline void init_get_bits(GetBitContext *s, const uint8_t *buffer,
336
+                                 int bit_size)
337 337
 {
338 338
     int buffer_size = (bit_size+7)>>3;
339 339
     if (buffer_size < 0 || bit_size < 0) {
... ...
@@ -387,7 +403,8 @@ void free_vlc(VLC *vlc);
387 387
  * If the vlc code is invalid and max_depth>1, then the number of bits removed
388 388
  * is undefined.
389 389
  */
390
-#define GET_VLC(code, name, gb, table, bits, max_depth) do {    \
390
+#define GET_VLC(code, name, gb, table, bits, max_depth)         \
391
+    do {                                                        \
391 392
         int n, nb_bits;                                         \
392 393
         unsigned int index;                                     \
393 394
                                                                 \
... ...
@@ -418,7 +435,8 @@ void free_vlc(VLC *vlc);
418 418
         SKIP_BITS(name, gb, n);                                 \
419 419
     } while (0)
420 420
 
421
-#define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update) do { \
421
+#define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update) \
422
+    do {                                                                \
422 423
         int n, nb_bits;                                                 \
423 424
         unsigned int index;                                             \
424 425
                                                                         \
... ...
@@ -452,7 +470,7 @@ void free_vlc(VLC *vlc);
452 452
  *                  = (max_vlc_length + bits - 1) / bits
453 453
  */
454 454
 static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2],
455
-                                  int bits, int max_depth)
455
+                                     int bits, int max_depth)
456 456
 {
457 457
     int code;
458 458
 
... ...
@@ -465,7 +483,8 @@ static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2],
465 465
     return code;
466 466
 }
467 467
 
468
-static inline int decode012(GetBitContext *gb){
468
+static inline int decode012(GetBitContext *gb)
469
+{
469 470
     int n;
470 471
     n = get_bits1(gb);
471 472
     if (n == 0)
... ...
@@ -474,7 +493,8 @@ static inline int decode012(GetBitContext *gb){
474 474
         return get_bits1(gb) + 1;
475 475
 }
476 476
 
477
-static inline int decode210(GetBitContext *gb){
477
+static inline int decode210(GetBitContext *gb)
478
+{
478 479
     if (get_bits1(gb))
479 480
         return 0;
480 481
     else
... ...
@@ -489,7 +509,8 @@ static inline int get_bits_left(GetBitContext *gb)
489 489
 //#define TRACE
490 490
 
491 491
 #ifdef TRACE
492
-static inline void print_bin(int bits, int n){
492
+static inline void print_bin(int bits, int n)
493
+{
493 494
     int i;
494 495
 
495 496
     for (i = n-1; i >= 0; i--) {
... ...
@@ -500,7 +521,8 @@ static inline void print_bin(int bits, int n){
500 500
 }
501 501
 
502 502
 static inline int get_bits_trace(GetBitContext *s, int n, char *file,
503
-                                 const char *func, int line){
503
+                                 const char *func, int line)
504
+{
504 505
     int r = get_bits(s, n);
505 506
 
506 507
     print_bin(r, n);
... ...
@@ -510,7 +532,8 @@ static inline int get_bits_trace(GetBitContext *s, int n, char *file,
510 510
 }
511 511
 static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2],
512 512
                                 int bits, int max_depth, char *file,
513
-                                const char *func, int line){
513
+                                const char *func, int line)
514
+{
514 515
     int show  = show_bits(s, 24);
515 516
     int pos   = get_bits_count(s);
516 517
     int r     = get_vlc2(s, table, bits, max_depth);
... ...
@@ -524,7 +547,8 @@ static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2],
524 524
     return r;
525 525
 }
526 526
 static inline int get_xbits_trace(GetBitContext *s, int n, char *file,
527
-                                  const char *func, int line){
527
+                                  const char *func, int line)
528
+{
528 529
     int show = show_bits(s, n);
529 530
     int r    = get_xbits(s, n);
530 531