FFmpeg
Data Structures | Macros | Functions
bitstream_template.h File Reference

Go to the source code of this file.

Data Structures

struct   BSCTX
 

Macros

#define  BS_SUFFIX_LOWER   _be
 
#define  BS_SUFFIX_UPPER   BE
 
#define  BS_JOIN(x, y, z)   x ## y ## z
 
#define  BS_JOIN3(x, y, z)   BS_JOIN(x, y, z)
 
#define  BS_FUNC(x)   BS_JOIN3(bits_, x, BS_SUFFIX_LOWER)
 
#define  BSCTX   BS_JOIN3(Bitstream, Context, BS_SUFFIX_UPPER)
 

Functions

static int BS_FUNC()  priv_refill_64 (BSCTX *bc)
 
static int BS_FUNC()  priv_refill_32 (BSCTX *bc)
 
static int BS_FUNC()  init (BSCTX *bc, const uint8_t *buffer, unsigned int bit_size)
  Initialize BitstreamContext. More...
 
static int BS_FUNC()  init8 (BSCTX *bc, const uint8_t *buffer, unsigned int byte_size)
  Initialize BitstreamContext. More...
 
static int BS_FUNC()  tell (const BSCTX *bc)
  Return number of bits already read. More...
 
static int BS_FUNC()  size (const BSCTX *bc)
  Return buffer size in bits. More...
 
static int BS_FUNC()  left (const BSCTX *bc)
  Return the number of the bits left in a buffer. More...
 
static uint64_t BS_FUNC()  priv_val_show (BSCTX *bc, unsigned int n)
 
static void BS_FUNC()  priv_skip_remaining (BSCTX *bc, unsigned int n)
 
static uint64_t BS_FUNC()  priv_val_get (BSCTX *bc, unsigned int n)
 
static unsigned int BS_FUNC()  read_bit (BSCTX *bc)
  Return one bit from the buffer. More...
 
static uint32_t BS_FUNC()  read_nz (BSCTX *bc, unsigned int n)
  Return n bits from the buffer, n has to be in the 1-32 range. More...
 
static uint32_t BS_FUNC()  read (BSCTX *bc, unsigned int n)
  Return n bits from the buffer, n has to be in the 0-32 range. More...
 
static uint64_t BS_FUNC()  read_63 (BSCTX *bc, unsigned int n)
  Return n bits from the buffer, n has to be in the 0-63 range. More...
 
static uint64_t BS_FUNC()  read_64 (BSCTX *bc, unsigned int n)
  Return n bits from the buffer, n has to be in the 0-64 range. More...
 
static int32_t BS_FUNC()  read_signed_nz (BSCTX *bc, unsigned int n)
  Return n bits from the buffer as a signed integer, n has to be in the 1-32 range. More...
 
static int32_t BS_FUNC()  read_signed (BSCTX *bc, unsigned int n)
  Return n bits from the buffer as a signed integer. More...
 
static uint32_t BS_FUNC()  peek_nz (BSCTX *bc, unsigned int n)
  Return n bits from the buffer but do not change the buffer state. More...
 
static uint32_t BS_FUNC()  peek (BSCTX *bc, unsigned int n)
  Return n bits from the buffer but do not change the buffer state. More...
 
static int BS_FUNC()  peek_signed_nz (BSCTX *bc, unsigned int n)
  Return n bits from the buffer as a signed integer, do not change the buffer state. More...
 
static int BS_FUNC()  peek_signed (BSCTX *bc, unsigned int n)
  Return n bits from the buffer as a signed integer, do not change the buffer state. More...
 
static void BS_FUNC()  skip (BSCTX *bc, unsigned int n)
  Skip n bits in the buffer. More...
 
static void BS_FUNC()  seek (BSCTX *bc, unsigned pos)
  Seek to the given bit position. More...
 
static const uint8_t *BS_FUNC()  align (BSCTX *bc)
  Skip bits to a byte boundary. More...
 
static int BS_FUNC()  read_xbits (BSCTX *bc, unsigned int n)
  Read MPEG-1 dc-style VLC (sign bit + mantissa with no MSB). More...
 
static int BS_FUNC()  decode012 (BSCTX *bc)
  Return decoded truncated unary code for the values 0, 1, 2. More...
 
static int BS_FUNC()  decode210 (BSCTX *bc)
  Return decoded truncated unary code for the values 2, 1, 0. More...
 
static int BS_FUNC()  apply_sign (BSCTX *bc, int val)
 
static int BS_FUNC()  skip_1stop_8data (BSCTX *s)
 
static int BS_FUNC()  priv_set_idx (BSCTX *bc, int code, int *n, int *nb_bits, const VLCElem *table)
  Return the LUT element for the given bitstream configuration. More...
 
static int BS_FUNC()  read_vlc (BSCTX *bc, const VLCElem *table, int bits, int max_depth)
  Parse a vlc code. More...
 
static int BS_FUNC()  read_vlc_multi (BSCTX *bc, uint8_t dst[8], const VLC_MULTI_ELEM *const Jtable, const VLCElem *const table, const int bits, const int max_depth, const int symbols_size)
  Parse a vlc / vlc_multi code. More...
 

Macro Definition Documentation

BS_SUFFIX_LOWER

#define BS_SUFFIX_LOWER   _be

Definition at line 25 of file bitstream_template.h.

BS_SUFFIX_UPPER

#define BS_SUFFIX_UPPER   BE

Definition at line 26 of file bitstream_template.h.

BS_JOIN

#define BS_JOIN (   x,
  y,
  z 
)    x ## y ## z

Definition at line 29 of file bitstream_template.h.

BS_JOIN3

#define BS_JOIN3 (   x,
  y,
  z 
)    BS_JOIN(x, y, z)

Definition at line 30 of file bitstream_template.h.

BS_FUNC

#define BS_FUNC (   x )    BS_JOIN3(bits_, x, BS_SUFFIX_LOWER)

Definition at line 31 of file bitstream_template.h.

BSCTX

#define BSCTX   BS_JOIN3(Bitstream, Context, BS_SUFFIX_UPPER)

Definition at line 33 of file bitstream_template.h.

Function Documentation

priv_refill_64()

static int BS_FUNC() priv_refill_64 ( BSCTXbc )
inlinestatic
Returns
  • 0 on successful refill
  • a negative number when bitstream end is hit

Always succeeds when UNCHECKED_BITSTREAM_READER is enabled.

Definition at line 50 of file bitstream_template.h.

Referenced by init(), read_63(), read_bit(), and skip().

priv_refill_32()

static int BS_FUNC() priv_refill_32 ( BSCTXbc )
inlinestatic
Returns
  • 0 on successful refill
  • a negative number when bitstream end is hit

Always succeeds when UNCHECKED_BITSTREAM_READER is enabled.

Definition at line 75 of file bitstream_template.h.

Referenced by peek_nz(), and read_nz().

init()

static int BS_FUNC() init ( BSCTXbc,
const uint8_t *  buffer,
unsigned int  bit_size 
)
inlinestatic

Initialize BitstreamContext.

Parameters
buffer bitstream buffer, must be AV_INPUT_BUFFER_PADDING_SIZE bytes larger than the actual read bits because some optimized bitstream readers read 32 or 64 bits at once and could read over the end
bit_size the size of the buffer in bits
Returns
0 on success, AVERROR_INVALIDDATA if the buffer_size would overflow.

Definition at line 101 of file bitstream_template.h.

Referenced by init8().

init8()

static int BS_FUNC() init8 ( BSCTXbc,
const uint8_t *  buffer,
unsigned int  byte_size 
)
inlinestatic

Initialize BitstreamContext.

Parameters
buffer bitstream buffer, must be AV_INPUT_BUFFER_PADDING_SIZE bytes larger than the actual read bits because some optimized bitstream readers read 32 or 64 bits at once and could read over the end
byte_size the size of the buffer in bytes
Returns
0 on success, AVERROR_INVALIDDATA if the buffer_size would overflow

Definition at line 135 of file bitstream_template.h.

tell()

static int BS_FUNC() tell ( const BSCTXbc )
inlinestatic

Return number of bits already read.

Definition at line 146 of file bitstream_template.h.

Referenced by align(), and quant_band_template().

size()

static int BS_FUNC() size ( const BSCTXbc )
inlinestatic

Return buffer size in bits.

Definition at line 154 of file bitstream_template.h.

left()

static int BS_FUNC() left ( const BSCTXbc )
inlinestatic

Return the number of the bits left in a buffer.

Definition at line 162 of file bitstream_template.h.

Referenced by read_63(), and skip_1stop_8data().

priv_val_show()

static uint64_t BS_FUNC() priv_val_show ( BSCTXbc,
unsigned int  n 
)
inlinestatic

Definition at line 167 of file bitstream_template.h.

Referenced by peek_nz(), and priv_val_get().

priv_skip_remaining()

static void BS_FUNC() priv_skip_remaining ( BSCTXbc,
unsigned int  n 
)
inlinestatic

Definition at line 178 of file bitstream_template.h.

Referenced by priv_val_get(), read_vlc(), read_vlc_multi(), read_xbits(), and skip().

priv_val_get()

static uint64_t BS_FUNC() priv_val_get ( BSCTXbc,
unsigned int  n 
)
inlinestatic

Definition at line 188 of file bitstream_template.h.

Referenced by read_63(), read_bit(), and read_nz().

read_bit()

static unsigned int BS_FUNC() read_bit ( BSCTXbc )
inlinestatic

Return one bit from the buffer.

Definition at line 203 of file bitstream_template.h.

Referenced by decode012(), decode210(), read_64(), and skip_1stop_8data().

read_nz()

static uint32_t BS_FUNC() read_nz ( BSCTXbc,
unsigned int  n 
)
inlinestatic

Return n bits from the buffer, n has to be in the 1-32 range.

May be faster than bits_read() when n is not a compile-time constant and is known to be non-zero;

Definition at line 216 of file bitstream_template.h.

Referenced by read(), and read_signed_nz().

read()

static uint32_t BS_FUNC() read ( BSCTXbc,
unsigned int  n 
)
inlinestatic

Return n bits from the buffer, n has to be in the 0-32 range.

Examples
ffhash.c.

Definition at line 231 of file bitstream_template.h.

Referenced by audio_read_packet(), av_file_map(), cache_read(), check(), ebml_read_num(), ff_amf_read_number(), ff_get_cpu_flags_ppc(), ff_iamf_read_packet(), file_read(), flv_set_video_codec(), ftp_read(), get_strl(), headphone_convolute(), jpegxl_anim_read_header(), lag_decode_arith_plane(), main(), mlp_read_header(), mxf_parse_klv(), read_key(), read_line_to_bprint_escaped(), read_string_to_bprint(), retry_transfer_wrapper(), rtmp_packet_read_one_chunk(), skip_icc_profile(), smush_read_header(), sofalizer_convolute(), str_read_packet(), and tls_read_cb().

read_63()

static uint64_t BS_FUNC() read_63 ( BSCTXbc,
unsigned int  n 
)
inlinestatic

Return n bits from the buffer, n has to be in the 0-63 range.

Definition at line 244 of file bitstream_template.h.

Referenced by read_64().

read_64()

static uint64_t BS_FUNC() read_64 ( BSCTXbc,
unsigned int  n 
)
inlinestatic

Return n bits from the buffer, n has to be in the 0-64 range.

Definition at line 278 of file bitstream_template.h.

read_signed_nz()

static int32_t BS_FUNC() read_signed_nz ( BSCTXbc,
unsigned int  n 
)
inlinestatic

Return n bits from the buffer as a signed integer, n has to be in the 1-32 range.

May be faster than bits_read_signed() when n is not a compile-time constant and is known to be non-zero;

Definition at line 298 of file bitstream_template.h.

Referenced by read_signed().

read_signed()

static int32_t BS_FUNC() read_signed ( BSCTXbc,
unsigned int  n 
)
inlinestatic

Return n bits from the buffer as a signed integer.

n has to be in the 0-32 range.

Definition at line 308 of file bitstream_template.h.

Referenced by apply_sign().

peek_nz()

static uint32_t BS_FUNC() peek_nz ( BSCTXbc,
unsigned int  n 
)
inlinestatic

Return n bits from the buffer but do not change the buffer state.

n has to be in the 1-32 range. May

Definition at line 322 of file bitstream_template.h.

Referenced by peek(), and peek_signed_nz().

peek()

static uint32_t BS_FUNC() peek ( BSCTXbc,
unsigned int  n 
)
inlinestatic

Return n bits from the buffer but do not change the buffer state.

n has to be in the 0-32 range.

Definition at line 336 of file bitstream_template.h.

Referenced by priv_set_idx(), read_vlc(), read_vlc_multi(), read_xbits(), and receive_for_stream().

peek_signed_nz()

static int BS_FUNC() peek_signed_nz ( BSCTXbc,
unsigned int  n 
)
inlinestatic

Return n bits from the buffer as a signed integer, do not change the buffer state.

n has to be in the 1-32 range. May be faster than bits_peek_signed() when n is not a compile-time constant and is known to be non-zero;

Definition at line 351 of file bitstream_template.h.

Referenced by peek_signed().

peek_signed()

static int BS_FUNC() peek_signed ( BSCTXbc,
unsigned int  n 
)
inlinestatic

Return n bits from the buffer as a signed integer, do not change the buffer state.

n has to be in the 0-32 range.

Definition at line 362 of file bitstream_template.h.

skip()

static void BS_FUNC() skip ( BSCTXbc,
unsigned int  n 
)
inlinestatic

Skip n bits in the buffer.

Definition at line 375 of file bitstream_template.h.

Referenced by aax_read_packet(), ac3_decode_frame(), align(), append_flv_data(), asf_read_multiple_payload(), av_read_image_line2(), av_write_image_line2(), avui_decode_frame(), avui_encode_frame(), cbs_h264_discarded_nal_unit(), cbs_h265_discarded_nal_unit(), cdtoons_render_sprite(), clv_decode_frame(), conv_down(), convert_coeffs(), convert_frame(), convert_frame_partial(), cpia_decode_frame(), cri_decode_frame(), decode_555(), decode_block(), decode_dct(), decode_frame(), decode_header_trees(), decode_inter_block(), decode_inter_blocks(), decode_inter_plane(), decode_intra_block(), decode_intra_blocks(), decode_intra_plane(), decode_long_vertical_delta2(), decode_mad1(), decode_motion_vectors(), decode_mvdv(), decode_rle(), decode_scale_factors(), decode_tdlt(), decompress_5(), decompress_68(), draw(), dshow_cycle_devices(), dtshd_read_header(), dwa_uncompress(), dwt_plane(), dxv_decompress_yo(), encode_slices(), end_ebml_master_crc32(), escape124_decode_frame(), escape130_decode_frame(), ff_cbs_discard_units(), ff_configure_buffers_for_index(), ff_dovi_configure_ext(), ff_h264_decode_mb_cabac(), ff_hevc_hls_filter(), ff_htmlmarkup_to_ass(), ff_iamf_parse_obu_header(), ff_libwebp_get_frame(), ff_mjpeg_decode_frame_from_buf(), ff_mjpeg_find_marker(), ff_rm_read_mdpr_codecdata(), ff_tx_decompose_length(), ff_vk_filter_init_context(), fic_decode_frame(), filter_channel(), filter_start(), find_frame_end(), finished_reading_packet(), flush(), flv_data_packet(), flv_read_packet(), forward(), frame_data_apply(), g722_decode_frame(), gif_read_header(), gxf_packet(), handle_notify(), ipvideo_decode_format_10_opcodes(), is_animated_webp_packet(), load_enabled_qfs(), main(), min_cb_nz_tl_init(), mp_decode_layer3(), mpc7_decode_frame(), mpegps_read_packet(), mpegps_read_pes_header(), mpegts_push_data(), mss4_decode_dct(), mxf_read_packet(), nut_read_packet(), old_codec47(), opus_packet(), output_chunk_list(), pnm_parse(), qpeg_decode_inter(), qtrle_decode_1bpp(), r3d_read_packet(), read_code(), read_header(), read_kuki_chunk(), read_packet(), rm_read_index(), rm_sync(), rtmp_write(), rtp_asf_fix_header(), seek(), sga_read_header(), skip_1stop_8data(), swf_read_packet(), tm2_read_stream(), ulti_decode_frame(), vc1_decode_ac_coeff(), vc1_decode_i_block(), vc1_decode_i_block_adv(), vc1_decode_intra_block(), vc1_decode_p_block(), vc1_unescape_buffer_neon(), vorbis_packet(), vpk_read_packet(), and webvtt_event_to_ass().

seek()

static void BS_FUNC() seek ( BSCTXbc,
unsigned  pos 
)
inlinestatic

Seek to the given bit position.

Definition at line 399 of file bitstream_template.h.

Referenced by avio_alloc_context(), ffio_init_context(), id3v2_parse(), and main().

align()

static const uint8_t* BS_FUNC() align ( BSCTXbc )
inlinestatic

Skip bits to a byte boundary.

Definition at line 411 of file bitstream_template.h.

Referenced by ads_read_header(), av_frame_get_buffer(), av_image_alloc(), av_image_copy_to_buffer(), av_image_fill_arrays(), av_image_get_buffer_size(), av_samples_alloc(), av_samples_alloc_array_and_samples(), av_samples_fill_arrays(), av_samples_get_buffer_size(), avcodec_align_dimensions(), avcodec_fill_audio_frame(), check_for_slice(), check_idct(), dcstr_read_header(), decode_0(), decode_block(), decode_frame(), ff_create_memory_sample(), ff_default_get_audio_buffer(), ff_default_get_video_buffer2(), ff_frame_pool_audio_init(), ff_frame_pool_get_audio_config(), ff_frame_pool_get_video_config(), ff_frame_pool_video_init(), ff_mjpeg_escape_FF(), genh_read_header(), get_audio_buffer(), get_video_buffer(), main(), read_vblock(), run_single_test(), save_bits(), svag_read_header(), sws_receive_slice(), and v210_stride().

read_xbits()

static int BS_FUNC() read_xbits ( BSCTXbc,
unsigned int  n 
)
inlinestatic

Read MPEG-1 dc-style VLC (sign bit + mantissa with no MSB).

If MSB not set it is negative.

Parameters
n length in bits

Definition at line 424 of file bitstream_template.h.

decode012()

static int BS_FUNC() decode012 ( BSCTXbc )
inlinestatic

Return decoded truncated unary code for the values 0, 1, 2.

Definition at line 436 of file bitstream_template.h.

Referenced by decode_frame_header(), ff_msmpeg4_decode_picture_header(), ff_vc1_parse_frame_header(), ff_vc1_parse_frame_header_adv(), ff_wmv2_decode_secondary_picture_header(), msmpeg4v34_decode_mb(), mss4_decode_frame(), vc1_decode_b_mb(), vc1_decode_b_mb_intfi(), vc1_decode_b_mb_intfr(), vc1_decode_p_block(), wmv2_decode_inter_block(), and wmv2_decode_mb().

decode210()

static int BS_FUNC() decode210 ( BSCTXbc )
inlinestatic

Return decoded truncated unary code for the values 2, 1, 0.

Definition at line 447 of file bitstream_template.h.

Referenced by decode_mb(), ff_vc1_parse_frame_header_adv(), and vc1_decode_ac_coeff().

apply_sign()

static int BS_FUNC() apply_sign ( BSCTXbc,
int  val 
)
inlinestatic

Definition at line 456 of file bitstream_template.h.

skip_1stop_8data()

static int BS_FUNC() skip_1stop_8data ( BSCTXs )
inlinestatic

Definition at line 462 of file bitstream_template.h.

priv_set_idx()

static int BS_FUNC() priv_set_idx ( BSCTXbc,
int  code,
int *  n,
int *  nb_bits,
const VLCElemtable 
)
inlinestatic

Return the LUT element for the given bitstream configuration.

Definition at line 479 of file bitstream_template.h.

Referenced by read_vlc(), and read_vlc_multi().

read_vlc()

static int BS_FUNC() read_vlc ( BSCTXbc,
const VLCElemtable,
int  bits,
int  max_depth 
)
inlinestatic

Parse a vlc code.

Parameters
bits is the number of bits which will be read at once, must be identical to nb_bits in vlc_init()
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 If the vlc code is invalid and max_depth=1, then no bits will be removed. If the vlc code is invalid and max_depth>1, then the number of bits removed is undefined.

Definition at line 502 of file bitstream_template.h.

read_vlc_multi()

static int BS_FUNC() read_vlc_multi ( BSCTXbc,
uint8_t  dst[8],
const VLC_MULTI_ELEM *const  Jtable,
const VLCElem *const  table,
const int  bits,
const int  max_depth,
const int  symbols_size 
)
inlinestatic

Parse a vlc / vlc_multi code.

Parameters
bits is the number of bits which will be read at once, must be identical to nb_bits in vlc_init()
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
dst the parsed symbol(s) will be stored here. Up to 8 bytes are written
Returns
number of symbols parsed If the vlc code is invalid and max_depth=1, then no bits will be removed. If the vlc code is invalid and max_depth>1, then the number of bits removed is undefined.

Definition at line 536 of file bitstream_template.h.


Generated on Fri Aug 22 2025 13:59:50 for FFmpeg by   doxygen 1.8.17

AltStyle によって変換されたページ (->オリジナル) /