hvirtual/quicktime/ffmpeg/libavcodec/bitstream.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  PutBitContext
struct  GetBitContext
struct  VLC
struct  RL_VLC_ELEM

Defines

#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 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)
#define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update)
#define tprintf(...)   {}

Functions

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 put_string (PutBitContext *pbc, char *s, int put_zero)
static uint32_t unaligned32 (const void *v)
static void put_bits (PutBitContext *s, int n, unsigned int value)
 ARCH_X86.
static uint8_t * pbBufPtr (PutBitContext *s)
static void skip_put_bytes (PutBitContext *s, int n)
static void skip_put_bits (PutBitContext *s, int n)
static void set_put_bits_buffer_size (PutBitContext *s, int size)
static int unaligned32_be (const void *v)
static int unaligned32_le (const void *v)
static int get_bits_count (GetBitContext *s)
static int get_xbits (GetBitContext *s, int n)
static int get_sbits (GetBitContext *s, int n)
static unsigned int get_bits (GetBitContext *s, int n)
unsigned int get_bits_long (GetBitContext *s, int n)
static unsigned int show_bits (GetBitContext *s, int n)
unsigned int show_bits_long (GetBitContext *s, int n)
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 void init_get_bits (GetBitContext *s, const uint8_t *buffer, int bit_size)
int check_marker (GetBitContext *s, const char *msg)
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_vlc (GetBitContext *s, VLC *vlc)
static always_inline int get_vlc2 (GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
static int decode012 (GetBitContext *gb)

Variables

const uint8_t ff_reverse [256]


Define Documentation

#define ALT_BITSTREAM_READER

Definition at line 12 of file bitstream.h.

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

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

#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)\
}

Definition at line 760 of file bitstream.h.

Referenced by mdec_decode_block_intra(), mpeg1_decode_block_inter(), mpeg1_decode_block_intra(), mpeg1_fast_decode_block_inter(), mpeg2_decode_block_intra(), mpeg2_decode_block_non_intra(), mpeg2_fast_decode_block_intra(), mpeg2_fast_decode_block_non_intra(), mpeg4_decode_block(), and msmpeg4_decode_block().

#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

Definition at line 729 of file bitstream.h.

Referenced by get_vlc(), and get_vlc2().

#define INIT_VLC_LE   2

Definition at line 720 of file bitstream.h.

Referenced by build_table(), ir2_decode_init(), and vorbis_parse_setup_hdr_codebooks().

#define INIT_VLC_USE_STATIC   1

Definition at line 719 of file bitstream.h.

Referenced by build_table(), and ir2_decode_init().

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

#define LAST_SKIP_CACHE ( name,
gb,
num   )     ;

Definition at line 416 of file bitstream.h.

Referenced by mpeg4_decode_block(), and msmpeg4_decode_block().

#define LIBMPEG2_BITSTREAM_READER_HACK

Definition at line 15 of file bitstream.h.

#define MIN_CACHE_BITS   25

Definition at line 382 of file bitstream.h.

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

Definition at line 36 of file bitstream.h.

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

Definition at line 37 of file bitstream.h.

Referenced by dv_decode_ac(), and get_xbits().

#define OPEN_READER ( name,
gb   ) 

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

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

#define SKIP_BITS ( name,
gb,
num   ) 

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

Definition at line 401 of file bitstream.h.

Referenced by mpeg4_decode_block(), and msmpeg4_decode_block().

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

Definition at line 406 of file bitstream.h.

Referenced by mpeg4_decode_block(), and msmpeg4_decode_block().

#define tprintf ( ...   )     {}

#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

Definition at line 119 of file bitstream.h.

Referenced by alloc_table(), build_table(), and get_vlc().


Function Documentation

void align_get_bits ( GetBitContext s  ) 

void align_put_bits ( PutBitContext s  ) 

Definition at line 31 of file bitstream.c.

References PutBitContext::bit_left, and put_bits().

Referenced by encode_frame(), ff_h261_encode_picture_header(), and flush_put_bits().

Here is the call graph for this function:

int check_marker ( GetBitContext s,
const char *  msg 
)

Definition at line 82 of file bitstream.c.

References av_log(), AV_LOG_INFO, get_bits1(), and NULL.

Referenced by decode_vol_header(), decode_vop_header(), and mpeg4_decode_video_packet_header().

Here is the call graph for this function:

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

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

void free_vlc ( VLC vlc  ) 

Definition at line 289 of file bitstream.c.

References av_free(), and VLC::table.

Referenced by decode_end(), dvvideo_init(), mjpeg_decode_dht(), mjpeg_decode_end(), read_huffman_tables(), read_old_huffman_tables(), vorbis_free(), and wma_decode_end().

Here is the call graph for this function:

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

reads 0-17 bits. Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't

Definition at line 603 of file bitstream.h.

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

Referenced by adpcm_decode_frame(), alac_decode_frame(), asv1_decode_block(), asv2_get_bits(), bastardized_rice_decompress(), bit_copy(), bitplane_decoding(), decode_b_picture_primary_header(), decode_b_picture_secondary_header(), decode_colskip(), decode_exp_lsp(), decode_exp_vlc(), decode_ext_header(), decode_frame(), decode_hrd_parameters(), decode_i_picture_primary_header(), decode_i_picture_secondary_header(), decode_line(), decode_mb_cavlc(), decode_p_picture_primary_header(), decode_p_picture_secondary_header(), decode_picture_parameter_set(), decode_residual(), decode_residuals(), decode_rowskip(), decode_seq_parameter_set(), decode_sequence_header(), decode_slice_header(), decode_subframe(), decode_subframe_lpc(), decode_user_data(), decode_vol_header(), decode_vop_header(), decode_vui_parameters(), dv_decode_video_segment(), dvbsub_read_2bit_string(), dvbsub_read_4bit_string(), ff_h263_decode_mba(), ff_mpeg4_decode_mb(), ff_mpeg4_decode_partitions(), ff_mpeg4_decode_picture_header(), ff_wmv2_decode_picture_header(), flac_decode_frame(), flv_h263_decode_picture_header(), g726_decode_frame(), get_bits1(), get_bits_long(), get_bits_long_le(), get_bitsz(), get_fragment_run_length(), get_mode_code(), get_motion_vector_fixed(), get_motion_vector_vlc(), get_prefix(), get_qscale(), get_superblock_run_length(), get_utf8(), h261_decode_block(), h261_decode_gob_header(), h261_decode_mb(), h261_decode_picture_header(), h263_decode_block(), h263_decode_dquant(), h263_decode_gob_header(), h263_decode_motion(), h263_decode_picture_header(), FormatBits::handle_event(), intel_h263_decode_picture_header(), metadata_streaminfo(), mjpeg_decode_app(), mjpeg_decode_com(), mjpeg_decode_dht(), mjpeg_decode_dqt(), mjpeg_decode_dri(), mjpeg_decode_sof(), mjpeg_decode_sos(), mp_decode_frame(), mp_decode_layer1(), mp_decode_layer2(), mp_decode_layer3(), mpeg1_decode_picture(), mpeg1_decode_sequence(), mpeg4_decode_dc(), mpeg4_decode_gop_header(), mpeg4_decode_partition_a(), mpeg4_decode_partition_b(), mpeg4_decode_video_packet_header(), mpeg_decode_extension(), mpeg_decode_gop(), mpeg_decode_mb(), mpeg_decode_motion(), mpeg_decode_picture_coding_extension(), mpeg_decode_quant_matrix_extension(), mpeg_decode_sequence_display_extension(), mpeg_decode_sequence_extension(), msmpeg4_decode_dc(), msmpeg4_decode_ext_header(), msmpeg4_decode_motion(), msmpeg4_decode_picture_header(), msmpeg4v2_decode_motion(), parse_mb_skip(), read_huffman_tree(), read_len_table(), rv10_decode_picture_header(), rv20_decode_picture_header(), rv_decode_dc(), shorten_decode_frame(), sonic_decode_init(), standard_decode_picture_primary_header(), svq1_decode_frame(), svq1_decode_frame_header(), svq1_parse_string(), svq3_decode_frame(), svq3_decode_mb(), svq3_decode_slice_header(), theora_decode_header(), theora_decode_init(), theora_decode_tables(), unpack_dct_coeffs(), unpack_modes(), unpack_superblocks(), unpack_token(), unpack_vectors(), unpack_vlcs(), vc9_decode_b_mb(), vc9_decode_block(), vc9_decode_i_mb(), vc9_decode_init(), vc9_decode_p_mb(), vop_dquant_decoding(), vorbis_decode_init(), vorbis_floor1_decode(), vorbis_parse_audio_packet(), vorbis_parse_id_hdr(), vorbis_parse_setup_hdr(), vorbis_parse_setup_hdr_codebooks(), vorbis_parse_setup_hdr_floors(), vorbis_parse_setup_hdr_mappings(), vorbis_parse_setup_hdr_modes(), vorbis_parse_setup_hdr_residues(), vorbis_parse_setup_hdr_tdtransforms(), vp3_decode_frame(), wma_decode_block(), wma_decode_superframe(), and wnv1_get_code().

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

Definition at line 638 of file bitstream.h.

References GetBitContext::buffer, get_bits(), and GetBitContext::index.

Referenced by bastardized_rice_decompress(), check_marker(), decode012(), decode_ext_header(), decode_frame(), decode_hrd_parameters(), decode_line(), decode_mb_cavlc(), decode_mb_skip(), decode_mv_component(), decode_picture_parameter_set(), decode_ref_pic_list_reordering(), decode_ref_pic_marking(), decode_residual(), decode_seq_parameter_set(), decode_slice_header(), decode_subframe(), decode_vol_header(), decode_vop_header(), decode_vui_parameters(), dv_decode_video_segment(), ff_h263_decode_mb(), ff_mpeg4_decode_mb(), ff_wmv2_decode_picture_header(), ff_wmv2_decode_secondary_picture_header(), flv_h263_decode_picture_header(), get_dmv(), get_te0_golomb(), get_te_golomb(), get_utf8(), h261_decode_block(), h261_decode_gob_header(), h261_decode_picture_header(), h263_decode_block(), h263_decode_dquant(), h263_decode_gob_header(), h263_decode_motion(), h263_decode_picture_header(), h263p_decode_umotion(), huffman_decode(), intel_h263_decode_picture_header(), mpeg1_decode_picture(), mpeg1_decode_sequence(), mpeg4_decode_dc(), mpeg4_decode_partition_a(), mpeg4_decode_partition_b(), mpeg4_decode_video_packet_header(), mpeg4_is_resync(), mpeg_decode_gop(), mpeg_decode_mb(), mpeg_decode_motion(), mpeg_decode_picture_coding_extension(), mpeg_decode_quant_matrix_extension(), mpeg_decode_sequence_display_extension(), mpeg_decode_sequence_extension(), mpeg_decode_slice(), msmpeg4_decode_dc(), msmpeg4_decode_ext_header(), msmpeg4_decode_picture_header(), msmpeg4v12_decode_mb(), msmpeg4v2_decode_motion(), msmpeg4v34_decode_mb(), parse_mb_skip(), pred_weight_table(), preview_obmc(), rv20_decode_picture_header(), sonic_decode_init(), svq1_decode_motion_vector(), svq3_decode_frame(), svq3_decode_slice_header(), vorbis_floor1_decode(), vorbis_len2vlc(), vorbis_parse_audio_packet(), vorbis_parse_id_hdr(), vorbis_parse_setup_hdr(), vorbis_parse_setup_hdr_codebooks(), vorbis_parse_setup_hdr_mappings(), vorbis_parse_setup_hdr_residues(), vp3_decode_frame(), wmv2_decode_mb(), wmv2_decode_motion(), and wmv2_pred_motion().

Here is the call graph for this function:

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

unsigned int get_bits_long ( GetBitContext s,
int  n 
)

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

static int get_vlc ( GetBitContext s,
VLC vlc 
) [inline, static]

static always_inline int get_vlc2 ( GetBitContext s,
VLC_TYPE(*)  table[2],
int  bits,
int  max_depth 
) [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 readed to completly read the longest vlc code = (max_vlc_length + bits - 1) / bits

Definition at line 807 of file bitstream.h.

References CLOSE_READER, GET_VLC, OPEN_READER, and UPDATE_CACHE.

Referenced by asv1_decode_block(), asv1_get_level(), asv2_decode_block(), asv2_get_level(), bitplane_decoding(), decode_422_bitstream(), decode_b_picture_primary_header(), decode_bgr_bitstream(), decode_block(), decode_dc(), decode_gray_bitstream(), decode_i_block(), decode_i_frame(), decode_mv_component(), decode_p_block(), decode_residual(), ff_h263_decode_mb(), ff_mpeg4_decode_mb(), h261_decode_block(), h261_decode_mb(), h263_decode_block(), h263_decode_motion(), ir2_get_code(), mjpeg_decode_dc(), mpeg4_decode_dc(), mpeg4_decode_partition_a(), mpeg4_decode_partition_b(), mpeg_decode_mb(), mpeg_decode_motion(), mpeg_decode_slice(), msmpeg4_decode_dc(), msmpeg4_decode_motion(), msmpeg4v12_decode_mb(), msmpeg4v2_decode_motion(), msmpeg4v34_decode_mb(), preview_obmc(), rv_decode_dc(), svq1_decode_block_intra(), svq1_decode_block_non_intra(), svq1_decode_delta_block(), svq1_decode_motion_vector(), unpack_modes(), unpack_superblocks(), unpack_vectors(), unpack_vlcs(), vc9_decode_b_mb(), vc9_decode_block(), vc9_decode_i_mb(), vc9_decode_p_mb(), vorbis_floor1_decode(), vorbis_residue_decode(), wmv2_decode_mb(), and wnv1_get_code().

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

Definition at line 571 of file