Mercurial > libavcodec.hg
comparison bitstream.h @ 5512:28dcc5cd79d2 libavcodec
* getting rid of code duplication
author | romansh |
---|---|
date | Wed, 08 Aug 2007 23:58:23 +0000 |
parents | 9fce88cf7f94 |
children | d92fa6e5fc8c |
comparison
equal
deleted
inserted
replaced
5511:7617e066481e | 5512:28dcc5cd79d2 |
---|---|
29 #include <stdint.h> | 29 #include <stdint.h> |
30 #include <stdlib.h> | 30 #include <stdlib.h> |
31 #include <assert.h> | 31 #include <assert.h> |
32 #include "common.h" | 32 #include "common.h" |
33 #include "bswap.h" | 33 #include "bswap.h" |
34 #include "intreadwrite.h" | |
34 #include "log.h" | 35 #include "log.h" |
35 | 36 |
36 #if defined(ALT_BITSTREAM_READER_LE) && !defined(ALT_BITSTREAM_READER) | 37 #if defined(ALT_BITSTREAM_READER_LE) && !defined(ALT_BITSTREAM_READER) |
37 # define ALT_BITSTREAM_READER | 38 # define ALT_BITSTREAM_READER |
38 #endif | 39 #endif |
404 is equivalent to SKIP_LAST_CACHE; SKIP_COUNTER | 405 is equivalent to SKIP_LAST_CACHE; SKIP_COUNTER |
405 | 406 |
406 for examples see get_bits, show_bits, skip_bits, get_vlc | 407 for examples see get_bits, show_bits, skip_bits, get_vlc |
407 */ | 408 */ |
408 | 409 |
409 static inline int unaligned32_be(const void *v) | |
410 { | |
411 #ifdef CONFIG_ALIGN | |
412 const uint8_t *p=v; | |
413 return (((p[0]<<8) | p[1])<<16) | (p[2]<<8) | (p[3]); | |
414 #else | |
415 return be2me_32( unaligned32(v)); //original | |
416 #endif | |
417 } | |
418 | |
419 static inline int unaligned32_le(const void *v) | |
420 { | |
421 #ifdef CONFIG_ALIGN | |
422 const uint8_t *p=v; | |
423 return (((p[3]<<8) | p[2])<<16) | (p[1]<<8) | (p[0]); | |
424 #else | |
425 return le2me_32( unaligned32(v)); //original | |
426 #endif | |
427 } | |
428 | |
429 #ifdef ALT_BITSTREAM_READER | 410 #ifdef ALT_BITSTREAM_READER |
430 # define MIN_CACHE_BITS 25 | 411 # define MIN_CACHE_BITS 25 |
431 | 412 |
432 # define OPEN_READER(name, gb)\ | 413 # define OPEN_READER(name, gb)\ |
433 int name##_index= (gb)->index;\ | 414 int name##_index= (gb)->index;\ |
436 # define CLOSE_READER(name, gb)\ | 417 # define CLOSE_READER(name, gb)\ |
437 (gb)->index= name##_index;\ | 418 (gb)->index= name##_index;\ |
438 | 419 |
439 # ifdef ALT_BITSTREAM_READER_LE | 420 # ifdef ALT_BITSTREAM_READER_LE |
440 # define UPDATE_CACHE(name, gb)\ | 421 # define UPDATE_CACHE(name, gb)\ |
441 name##_cache= unaligned32_le( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) >> (name##_index&0x07);\ | 422 name##_cache= AV_RL32( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) >> (name##_index&0x07);\ |
442 | 423 |
443 # define SKIP_CACHE(name, gb, num)\ | 424 # define SKIP_CACHE(name, gb, num)\ |
444 name##_cache >>= (num); | 425 name##_cache >>= (num); |
445 # else | 426 # else |
446 # define UPDATE_CACHE(name, gb)\ | 427 # define UPDATE_CACHE(name, gb)\ |
447 name##_cache= unaligned32_be( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) << (name##_index&0x07);\ | 428 name##_cache= AV_RB32( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) << (name##_index&0x07);\ |
448 | 429 |
449 # define SKIP_CACHE(name, gb, num)\ | 430 # define SKIP_CACHE(name, gb, num)\ |
450 name##_cache <<= (num); | 431 name##_cache <<= (num); |
451 # endif | 432 # endif |
452 | 433 |