bitstream.h File Reference

bitstream api header. More...

Include dependency graph for bitstream.h:

Go to the source code of this file.

Data Structures

struct  PutBitContext
struct  GetBitContext
struct  VLC
struct  RL_VLC_ELEM

Defines

#define av_always_inline   inline
#define attribute_deprecated
#define ALT_BITSTREAM_READER
#define LIBMPEG2_BITSTREAM_READER_HACK
#define NEG_SSR32(a, s)   ((( int32_t)(a))>>(32-(s)))
#define NEG_USR32(a, s)   (((uint32_t)(a))>>(32-(s)))
#define VLC_TYPE   int16_t
#define unaligned(x)
#define MIN_CACHE_BITS   25
#define OPEN_READER(name, gb)
#define CLOSE_READER(name, gb)   (gb)->index= name##_index;\
#define UPDATE_CACHE(name, gb)   name##_cache= unaligned32_be( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) << (name##_index&0x07);\
#define SKIP_CACHE(name, gb, num)   name##_cache <<= (num);
#define SKIP_COUNTER(name, gb, num)   name##_index += (num);\
#define SKIP_BITS(name, gb, num)
#define LAST_SKIP_BITS(name, gb, num)   SKIP_COUNTER(name, gb, num)
#define LAST_SKIP_CACHE(name, gb, num)   ;
#define SHOW_UBITS(name, gb, num)   NEG_USR32(name##_cache, num)
#define SHOW_SBITS(name, gb, num)   NEG_SSR32(name##_cache, num)
#define GET_CACHE(name, gb)   ((uint32_t)name##_cache)
#define INIT_VLC_USE_STATIC   1
#define INIT_VLC_LE   2
#define GET_VLC(code, name, gb, table, bits, max_depth)
 if the vlc code is invalid and max_depth=1 than no bits will be removed if the vlc code is invalid and max_depth>1 than the number of bits removed is undefined
#define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update)
#define tprintf(p,...)   {}

Functions

static int av_log2 (unsigned int v)
static void init_put_bits (PutBitContext *s, uint8_t *buffer, int buffer_size)
static int put_bits_count (PutBitContext *s)
static void flush_put_bits (PutBitContext *s)
void align_put_bits (PutBitContext *s)
void ff_put_string (PutBitContext *pbc, char *s, int put_zero)
static uint16_t unaligned16 (const void *v)
static uint32_t unaligned32 (const void *v)
static uint64_t unaligned64 (const void *v)
static void put_bits (PutBitContext *s, int n, unsigned int value)
static uint8_t * pbBufPtr (PutBitContext *s)
static void skip_put_bytes (PutBitContext *s, int n)
 PutBitContext must be flushed & aligned to a byte boundary before calling this.
static void skip_put_bits (PutBitContext *s, int n)
 skips the given number of bits.
static void set_put_bits_buffer_size (PutBitContext *s, int size)
 Changes the end of the buffer.
static int unaligned32_be (const void *v)
static int unaligned32_le (const void *v)
static int get_bits_count (GetBitContext *s)
static void skip_bits_long (GetBitContext *s, int n)
static int get_xbits (GetBitContext *s, int n)
 read mpeg1 dc style vlc (sign bit + mantisse with no MSB).
static int get_sbits (GetBitContext *s, int n)
static unsigned int get_bits (GetBitContext *s, int n)
 reads 1-17 bits.
static unsigned int show_bits (GetBitContext *s, int n)
 shows 1-17 bits.
static void skip_bits (GetBitContext *s, int n)
static unsigned int get_bits1 (GetBitContext *s)
static unsigned int show_bits1 (GetBitContext *s)
static void skip_bits1 (GetBitContext *s)
static unsigned int get_bits_long (GetBitContext *s, int n)
 reads 0-32 bits.
static unsigned int show_bits_long (GetBitContext *s, int n)
 shows 0-32 bits.
static void init_get_bits (GetBitContext *s, const uint8_t *buffer, int bit_size)
 init GetBitContext.
static void align_get_bits (GetBitContext *s)
int init_vlc (VLC *vlc, int nb_bits, int nb_codes, const void *bits, int bits_wrap, int bits_size, const void *codes, int codes_wrap, int codes_size, int flags)
void free_vlc (VLC *vlc)
static int get_vlc2 (GetBitContext *s, int16_t(*table)[2], int bits, int max_depth)
 parses a vlc code, faster then get_vlc()
static int decode012 (GetBitContext *gb)

Variables

const uint8_t ff_log2_tab [256]
const uint8_t ff_reverse [256]


Detailed Description

bitstream api header.


Define Documentation

#define ALT_BITSTREAM_READER

#define attribute_deprecated

#define av_always_inline   inline

#define CLOSE_READER ( name,
gb   )     (gb)->index= name##_index;\

#define GET_CACHE ( name,
gb   )     ((uint32_t)name##_cache)

Referenced by get_xbits().

#define GET_RL_VLC ( level,
run,
name,
gb,
table,
bits,
max_depth,
need_update   ) 

Value:

{\
    int n, index, nb_bits;\
\
    index= SHOW_UBITS(name, gb, bits);\
    level = table[index].level;\
    n     = table[index].len;\
\
    if(max_depth > 1 && n < 0){\
        SKIP_BITS(name, gb, bits)\
        if(need_update){\
            UPDATE_CACHE(name, gb)\
        }\
\
        nb_bits = -n;\
\
        index= SHOW_UBITS(name, gb, nb_bits) + level;\
        level = table[index].level;\
        n     = table[index].len;\
    }\
    run= table[index].run;\
    SKIP_BITS(name, gb, n)\
}

#define GET_VLC ( code,
name,
gb,
table,
bits,
max_depth   ) 

Value:

{\
    int n, index, nb_bits;\
\
    index= SHOW_UBITS(name, gb, bits);\
    code = table[index][0];\
    n    = table[index][1];\
\
    if(max_depth > 1 && n < 0){\
        LAST_SKIP_BITS(name, gb, bits)\
        UPDATE_CACHE(name, gb)\
\
        nb_bits = -n;\
\
        index= SHOW_UBITS(name, gb, nb_bits) + code;\
        code = table[index][0];\
        n    = table[index][1];\
        if(max_depth > 2 && n < 0){\
            LAST_SKIP_BITS(name, gb, nb_bits)\
            UPDATE_CACHE(name, gb)\
\
            nb_bits = -n;\
\
            index= SHOW_UBITS(name, gb, nb_bits) + code;\
            code = table[index][0];\
            n    = table[index][1];\
        }\
    }\
    SKIP_BITS(name, gb, n)\
}
if the vlc code is invalid and max_depth=1 than no bits will be removed if the vlc code is invalid and max_depth>1 than the number of bits removed is undefined

Referenced by get_vlc2().

#define INIT_VLC_LE   2

Referenced by build_table().

#define INIT_VLC_USE_STATIC   1

#define LAST_SKIP_BITS ( name,
gb,
num   )     SKIP_COUNTER(name, gb, num)

#define LAST_SKIP_CACHE ( name,
gb,
num   )     ;

#define LIBMPEG2_BITSTREAM_READER_HACK

#define MIN_CACHE_BITS   25

#define NEG_SSR32 ( a,
 )     ((( int32_t)(a))>>(32-(s)))

#define NEG_USR32 ( a,
 )     (((uint32_t)(a))>>(32-(s)))

Referenced by get_xbits().

#define OPEN_READER ( name,
gb   ) 

Value:

int name##_index= (gb)->index;\
        int name##_cache= 0;\

Referenced by get_bits(), get_sbits(), get_vlc2(), get_xbits(), show_bits(), and skip_bits().

#define SHOW_SBITS ( name,
gb,
num   )     NEG_SSR32(name##_cache, num)

Referenced by get_sbits().

#define SHOW_UBITS ( name,
gb,
num   )     NEG_USR32(name##_cache, num)

Referenced by get_bits(), and show_bits().

#define SKIP_BITS ( name,
gb,
num   ) 

Value:

{\
            SKIP_CACHE(name, gb, num)\
            SKIP_COUNTER(name, gb, num)\
        }\

#define SKIP_CACHE ( name,
gb,
num   )     name##_cache <<= (num);

#define SKIP_COUNTER ( name,
gb,
num   )     name##_index += (num);\

#define tprintf ( p,
...   )     {}

#define unaligned (  ) 

Value:

static inline uint##x##_t unaligned##x(const void *v) {         \
    return *(const uint##x##_t *) v;                            \
}

Referenced by Copy2d(), CopyPlane(), and SplitPlanes().

#define UPDATE_CACHE ( name,
gb   )     name##_cache= unaligned32_be( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) << (name##_index&0x07);\

#define VLC_TYPE   int16_t

Referenced by build_table().


Function Documentation

static void align_get_bits ( GetBitContext s  )  [inline, static]

References get_bits_count(), and skip_bits().

Referenced by wma_decode_block().

void align_put_bits ( PutBitContext s  ) 

References PutBitContext::bit_left, and put_bits().

Referenced by flush_put_bits().

static int av_log2 ( unsigned int  v  )  [inline, static]

References ff_log2_tab.

Referenced by wma_decode_block(), and wma_decode_init().

static int decode012 ( GetBitContext gb  )  [inline, static]

References get_bits1().

void ff_put_string ( PutBitContext pbc,
char *  s,
int  put_zero 
)

References put_bits().

static void flush_put_bits ( PutBitContext s  )  [inline, static]

void free_vlc ( VLC vlc  ) 

static unsigned int get_bits ( GetBitContext s,
int  n 
) [inline, static]

reads 1-17 bits.

Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't

References CLOSE_READER, LAST_SKIP_BITS, OPEN_READER, SHOW_UBITS, and UPDATE_CACHE.

Referenced by decode_exp_lsp(), decode_exp_vlc(), get_bits1(), get_bits_long(), wma_decode_block(), wma_decode_superframe_frame(), and wma_decode_superframe_init().

static unsigned int get_bits1 ( GetBitContext s  )  [inline, static]

static int get_bits_count ( GetBitContext s  )  [inline, static]

static unsigned int get_bits_long ( GetBitContext s,
int  n 
) [inline, static]

reads 0-32 bits.

References get_bits().

Referenced by show_bits_long().

static int get_sbits ( GetBitContext s,
int  n 
) [inline, static]

static int get_vlc2 ( GetBitContext s,
int16_t(*)  table[2],
int  bits,
int  max_depth 
) [inline, static]

parses a vlc code, faster then get_vlc()

Parameters:
bits is the number of bits which will be read at once, must be identical to nb_bits in init_vlc()
max_depth is the number of times bits bits must be read to completely read the longest vlc code = (max_vlc_length + bits - 1) / bits

References CLOSE_READER, GET_VLC, OPEN_READER, and UPDATE_CACHE.

Referenced by decode_exp_vlc(), and wma_decode_block().

static int get_xbits ( GetBitContext s,
int  n 
) [inline, static]

read mpeg1 dc style vlc (sign bit + mantisse with no MSB).

if MSB not set it is negative

Parameters:
n length in bits
Author:
BERO

References CLOSE_READER, GET_CACHE, LAST_SKIP_BITS, NEG_USR32, OPEN_READER, and UPDATE_CACHE.

static void init_get_bits ( GetBitContext s,
const uint8_t *  buffer,
int  bit_size 
) [inline, static]

init GetBitContext.

Parameters:
buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger then the actual read bits because some optimized bitstream readers read 32 or 64 bit at once and could read over the end
bit_size the size of the buffer in bits

References GetBitContext::buffer, GetBitContext::buffer_end, GetBitContext::index, GetBitContext::size_in_bits, and skip_bits_long().

Referenced by wma_decode_superframe_frame(), and wma_decode_superframe_init().

static void init_put_bits ( PutBitContext s,
uint8_t *  buffer,
int  buffer_size 
) [inline, static]

int init_vlc ( VLC vlc,
int  nb_bits,
int  nb_codes,
const void *  bits,
int  bits_wrap,
int  bits_size,
const void *  codes,
int  codes_wrap,
int  codes_size,
int  flags 
)

static uint8_t* pbBufPtr ( PutBitContext s  )  [inline, static]

static void put_bits ( PutBitContext s,
int  n,
unsigned int  value 
) [inline, static]

static int put_bits_count ( PutBitContext s  )  [inline, static]

static void set_put_bits_buffer_size ( PutBitContext s,
int  size 
) [inline, static]

Changes the end of the buffer.

References PutBitContext::buf, and PutBitContext::buf_end.

static unsigned int show_bits ( GetBitContext s,
int  n 
) [inline, static]

shows 1-17 bits.

Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't

References OPEN_READER, SHOW_UBITS, and UPDATE_CACHE.

Referenced by show_bits1(), and show_bits_long().

static unsigned int show_bits1 ( GetBitContext s  )  [inline, static]

References show_bits().

static unsigned int show_bits_long ( GetBitContext s,
int  n 
) [inline, static]

shows 0-32 bits.

References get_bits_long(), and show_bits().

static void skip_bits ( GetBitContext s,
int  n 
) [inline, static]

static void skip_bits1 ( GetBitContext s  )  [inline, static]

References skip_bits().

static void skip_bits_long ( GetBitContext s,
int  n 
) [inline, static]

References GetBitContext::index.

Referenced by init_get_bits().

static void skip_put_bits ( PutBitContext s,
int  n 
) [inline, static]

skips the given number of bits.

must only be used if the actual values in the bitstream dont matter

References PutBitContext::bit_left, and PutBitContext::buf_ptr.

static void skip_put_bytes ( PutBitContext s,
int  n 
) [inline, static]

PutBitContext must be flushed & aligned to a byte boundary before calling this.

References PutBitContext::buf_ptr.

static uint16_t unaligned16 ( const void *  v  )  [inline, static]

static uint32_t unaligned32 ( const void *  v  )  [inline, static]

Referenced by unaligned32_be(), and unaligned32_le().

static int unaligned32_be ( const void *  v  )  [inline, static]

References be2me_32, and unaligned32().

static int unaligned32_le ( const void *  v  )  [inline, static]

References le2me_32, and unaligned32().

static uint64_t unaligned64 ( const void *  v  )  [inline, static]


Variable Documentation

const uint8_t ff_log2_tab[256]

Referenced by av_log2().

const uint8_t ff_reverse[256]


Generated on Tue May 25 08:05:14 2010 for VLC by  doxygen 1.5.6