00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifdef WORDS_BIGENDIAN
00026
00027 # define swab32(x) (x)
00028
00029 #else
00030
00031 # define swab32(x)\
00032 ((((uint8_t*)&x)[0] << 24) | (((uint8_t*)&x)[1] << 16) | \
00033 (((uint8_t*)&x)[2] << 8) | (((uint8_t*)&x)[3]))
00034
00035 #endif
00036
00037 #ifdef WORDS_BIGENDIAN
00038
00039 # define swable32(x)\
00040 ((((uint8_t*)&x)[0] << 16) | (((uint8_t*)&x)[1] << 24) | \
00041 (((uint8_t*)&x)[2]) | (((uint8_t*)&x)[3] << 8))
00042
00043 #else
00044
00045 # define swable32(x)\
00046 ((((uint16_t*)&x)[0] << 16) | (((uint16_t*)&x)[1]))
00047
00048 #endif
00049
00050 void dts_bitstream_init (dts_state_t * state, uint8_t * buf, int word_mode,
00051 int endian_mode);
00052 uint32_t dts_bitstream_get_bh (dts_state_t * state, uint32_t num_bits);
00053
00054 static inline uint32_t bitstream_get (dts_state_t * state, uint32_t num_bits)
00055 {
00056 uint32_t result;
00057
00058 if (num_bits < state->bits_left) {
00059 result = (state->current_word << (32 - state->bits_left))
00060 >> (32 - num_bits);
00061
00062 state->bits_left -= num_bits;
00063 return result;
00064 }
00065
00066 return dts_bitstream_get_bh (state, num_bits);
00067 }