FFmpeg
Data Structures | Macros | Typedefs | Functions | Variables
put_bits.h File Reference

bitstream writer API More...

#include <stdint.h>
#include <stddef.h>
#include "config.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/avassert.h"
#include "version.h"

Go to the source code of this file.

Data Structures

struct  PutBitContext
 

Macros

#define AV_WBBUF   AV_WB32
 
#define AV_WLBUF   AV_WL32
 

Typedefs

typedef uint32_t BitBuf
 

Functions

static void init_put_bits (PutBitContext *s, uint8_t *buffer, int buffer_size)
 Initialize the PutBitContext s. More...
 
static int put_bits_count (PutBitContext *s)
 
static int put_bytes_output (const PutBitContext *s)
 
static int put_bytes_count (const PutBitContext *s, int round_up)
 
static void rebase_put_bits (PutBitContext *s, uint8_t *buffer, int buffer_size)
 Rebase the bit writer onto a reallocated buffer. More...
 
static int put_bits_left (PutBitContext *s)
 
static int put_bytes_left (const PutBitContext *s, int round_up)
 
static void flush_put_bits (PutBitContext *s)
 Pad the end of the output stream with zeros. More...
 
static void flush_put_bits_le (PutBitContext *s)
 
void avpriv_align_put_bits (PutBitContext *s)
 
void avpriv_copy_bits (PutBitContext *pb, const uint8_t *src, int length)
 
void ff_put_string (PutBitContext *pb, const char *string, int terminate_string)
 Put the string string in the bitstream. More...
 
void ff_copy_bits (PutBitContext *pb, const uint8_t *src, int length)
 Copy the content of src to the bitstream. More...
 
static void put_bits_no_assert (PutBitContext *s, int n, BitBuf value)
 
static void put_bits (PutBitContext *s, int n, BitBuf value)
 Write up to 31 bits into a bitstream. More...
 
static void put_bits_le (PutBitContext *s, int n, BitBuf value)
 
static void put_sbits (PutBitContext *pb, int n, int32_t value)
 
static void av_unused put_bits32 (PutBitContext *s, uint32_t value)
 Write exactly 32 bits into a bitstream. More...
 
static void put_bits64 (PutBitContext *s, int n, uint64_t value)
 Write up to 64 bits into a bitstream. More...
 
static uint8_tput_bits_ptr (PutBitContext *s)
 Return the pointer to the byte where the bitstream writer will put the next bit. More...
 
static void skip_put_bytes (PutBitContext *s, int n)
 Skip the given number of bytes. More...
 
static void skip_put_bits (PutBitContext *s, int n)
 Skip the given number of bits. More...
 
static void set_put_bits_buffer_size (PutBitContext *s, int size)
 Change the end of the buffer. More...
 
static void align_put_bits (PutBitContext *s)
 Pad the bitstream with zeros up to the next byte boundary. More...
 

Variables

static const int BUF_BITS = 8 * sizeof(BitBuf)
 

Detailed Description

bitstream writer API

Definition in file put_bits.h.

Macro Definition Documentation

#define AV_WBBUF   AV_WB32

Definition at line 45 of file put_bits.h.

Referenced by put_bits32(), and put_bits_no_assert().

#define AV_WLBUF   AV_WL32

Definition at line 46 of file put_bits.h.

Referenced by put_bits32(), put_bits_le(), and put_bits_no_assert().

Typedef Documentation

typedef uint32_t BitBuf

Definition at line 44 of file put_bits.h.

Function Documentation

static void init_put_bits ( PutBitContext s,
uint8_t buffer,
int  buffer_size 
)
inlinestatic

Initialize the PutBitContext s.

Parameters
bufferthe buffer where to put bits
buffer_sizethe size in bytes of buffer

Definition at line 66 of file put_bits.h.

Referenced by aac_adtstoasc_filter(), aac_encode_frame(), ac3_output_frame(), adpcm_encode_frame(), adts_decode_extradata(), adts_write_frame_header(), adx_encode(), avpriv_dca_convert_bitstream(), binary_export(), cbs_vp9_assemble_fragment(), cbs_write_unit_data(), cfhd_encode_frame(), decode_init(), decode_packet(), dnxhd_encode_thread(), dv_decode_video_segment(), dv_encode_video_segment(), encode_alpha_slice_data(), encode_bitstream(), encode_block(), encode_ext_header(), encode_frame(), encode_init(), encode_picture_ls(), encode_slice(), encode_slice_plane(), encode_slices(), encode_thread(), ff_alloc_timecode_sei(), ff_dolby_e_convert_input(), ff_hevc_encode_nal_vps(), ff_isom_write_av1c(), ff_lzw_encode_init(), ff_mjpeg_find_marker(), ff_mpeg4_init_partitions(), ff_mpv_encode_picture(), flush(), flv_write_codec_header(), g726_reset(), init_cabac_encoder(), latm_write_packet(), ljpeg_encode_frame(), magy_encode_frame(), main(), mov_write_ac3_tag(), mov_write_dvc1_structs(), mov_write_eac3_tag(), MPA_encode_frame(), pack_bitstream(), pnm_decode_frame(), predictor_calc_error(), put_audio_specific_config(), put_line(), put_main_header(), put_pack_header(), put_swf_matrix(), put_swf_rect(), put_system_header(), ra144_encode_frame(), rpza_encode_frame(), s302m_encode2_frame(), save_bits(), sbc_pack_frame(), send_mode_a(), send_mode_b(), svq1_encode_frame(), svq1_encode_plane(), swf_write_header(), tta_encode_frame(), vorbis_encode_frame(), vp9_raw_reorder_make_output(), wavpack_encode_block(), wmavoice_decode_packet(), write_frame(), write_header(), write_huff_codes(), write_major_sync(), write_streaminfo(), write_substrs(), and xsub_encode().

static int put_bits_count ( PutBitContext s)
inlinestatic
static int put_bytes_output ( const PutBitContext s)
inlinestatic
static int put_bytes_count ( const PutBitContext s,
int  round_up 
)
inlinestatic
Parameters
round_upWhen set, the number of bits written so far will be rounded up to the next byte.
Returns
the number of bytes output so far.

Definition at line 104 of file put_bits.h.

Referenced by encode_superframe(), encode_thread(), ff_mjpeg_encode_picture_header(), ff_mjpeg_encode_stuffing(), ff_mpeg1_init_uni_ac_vlc(), magy_encode_frame(), put_cabac_terminate(), update_mb_info(), writtenBytes(), and xsub_encode().

static void rebase_put_bits ( PutBitContext s,
uint8_t buffer,
int  buffer_size 
)
inlinestatic

Rebase the bit writer onto a reallocated buffer.

Parameters
bufferthe buffer where to put bits
buffer_sizethe size in bytes of buffer, must be large enough to hold everything written so far

Definition at line 116 of file put_bits.h.

Referenced by ff_mpv_reallocate_putbitbuffer().

static int put_bits_left ( PutBitContext s)
inlinestatic
static int put_bytes_left ( const PutBitContext s,
int  round_up 
)
inlinestatic
Parameters
round_upWhen set, the number of bits written will be rounded up to the next byte.
Returns
the number of bytes left.

Definition at line 139 of file put_bits.h.

Referenced by dv_encode_video_segment(), encode_422_bitstream(), encode_bgra_bitstream(), encode_gray_bitstream(), encode_line_TMPL(), encode_mb(), encode_plane_bitstream(), encode_thread(), ff_mpv_encode_picture(), ff_mpv_reallocate_putbitbuffer(), ljpeg_encode_bgr(), ljpeg_encode_yuv(), svq1_encode_plane(), and xsub_encode_rle().

static void flush_put_bits ( PutBitContext s)
inlinestatic

Pad the end of the output stream with zeros.

Definition at line 147 of file put_bits.h.

Referenced by aac_adtstoasc_filter(), aac_encode_frame(), adpcm_encode_frame(), adts_decode_extradata(), adts_write_frame_header(), adx_encode(), avpriv_dca_convert_bitstream(), binary_export(), cbs_av1_write_obu(), cbs_h2645_write_slice_data(), cbs_jpeg_write_scan(), cbs_mpeg2_write_slice(), cbs_vp9_assemble_fragment(), cbs_vp9_write_unit(), cbs_write_unit_data(), cfhd_encode_frame(), dnxhd_encode_thread(), dv_decode_video_segment(), dv_encode_video_segment(), encode_alpha_slice_data(), encode_bitstream(), encode_block(), encode_ext_header(), encode_frame(), encode_hq_slice(), encode_init(), encode_picture_ls(), encode_slice(), encode_slice_plane(), encode_slices(), encode_superframe(), encode_thread(), ff_alloc_timecode_sei(), ff_copy_bits(), ff_dolby_e_convert_input(), ff_hevc_encode_nal_vps(), ff_isom_write_av1c(), ff_lzw_encode_flush(), ff_mjpeg_escape_FF(), ff_mjpeg_find_marker(), ff_mpeg4_merge_partitions(), ff_mpv_encode_picture(), flv_write_codec_header(), frame_header_obu(), g726_reset(), jpeg_put_comments(), jpeg_table_header(), latm_write_packet(), ljpeg_encode_frame(), main(), merge_context_after_encode(), mov_write_ac3_tag(), mov_write_dvc1_structs(), mov_write_eac3_tag(), MPA_encode_frame(), output_frame_end(), pack_bitstream(), pnm_decode_frame(), predictor_calc_error(), put_audio_specific_config(), put_cabac_terminate(), put_line(), put_main_header(), put_pack_header(), put_swf_matrix(), put_swf_rect(), put_system_header(), ra144_encode_frame(), rpza_encode_frame(), s302m_encode2_frame(), save_bits(), sbc_pack_frame(), send_mode_a(), send_mode_b(), svq1_encode_frame(), svq1_encode_plane(), swf_write_header(), tta_encode_frame(), vc2_encode_frame(), vorbis_encode_frame(), vp9_raw_reorder_make_output(), wavpack_encode_block(), wmavoice_decode_packet(), write_frame(), write_frame_footer(), write_frame_header(), write_header(), write_huff_codes(), write_major_sync(), write_restart_header(), write_slice_end(), write_streaminfo(), write_substrs(), and xsub_encode().

static void flush_put_bits_le ( PutBitContext s)
inlinestatic

Definition at line 168 of file put_bits.h.

Referenced by encode_frame(), ff_lzw_encode_flush(), ff_speedhq_end_slice(), and g726_reset().

void avpriv_align_put_bits ( PutBitContext s)

Definition at line 49 of file bitstream.c.

Referenced by flush_put_bits_le().

void avpriv_copy_bits ( PutBitContext pb,
const uint8_t src,
int  length 
)

Definition at line 53 of file bitstream.c.

Referenced by flush_put_bits_le().

void ff_put_string ( PutBitContext pb,
const char *  string,
int  terminate_string 
)

Put the string string in the bitstream.

Parameters
terminate_string0-terminates the written string if value is 1

Definition at line 59 of file bitstream.c.

Referenced by encode_frame(), encode_parse_info(), flush_put_bits_le(), jpeg_put_comments(), mpeg4_encode_vol_header(), and put_pce().

void ff_copy_bits ( PutBitContext pb,
const uint8_t src,
int  length 
)

Copy the content of src to the bitstream.

Parameters
lengththe number of bits of src to copy

Definition at line 69 of file bitstream.c.

Referenced by avpriv_copy_bits(), copy_bits(), encode_thread(), ff_mpeg4_merge_partitions(), flush_put_bits_le(), merge_context_after_encode(), save_bits(), and svq1_encode_plane().

static void put_bits_no_assert ( PutBitContext s,
int  n,
BitBuf  value 
)
inlinestatic

Definition at line 206 of file put_bits.h.

Referenced by put_bits(), and put_bits32().

static void put_bits ( PutBitContext s,
int  n,
BitBuf  value 
)
inlinestatic

Write up to 31 bits into a bitstream.

Use put_bits32 to write 32 bits.

Definition at line 256 of file put_bits.h.

Referenced by align_put_bits(), put_bits64(), and put_sbits().

static void put_bits_le ( PutBitContext s,
int  n,
BitBuf  value 
)
inlinestatic
static void put_sbits ( PutBitContext pb,
int  n,
int32_t  value 
)
inlinestatic
static void av_unused put_bits32 ( PutBitContext s,
uint32_t  value 
)
static
static void put_bits64 ( PutBitContext s,
int  n,
uint64_t  value 
)
inlinestatic

Write up to 64 bits into a bitstream.

Definition at line 343 of file put_bits.h.

Referenced by set_ue_golomb_long().

static uint8_t* put_bits_ptr ( PutBitContext s)
inlinestatic
static void skip_put_bytes ( PutBitContext s,
int  n 
)
inlinestatic

Skip the given number of bytes.

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

Definition at line 388 of file put_bits.h.

Referenced by cbs_av1_write_obu(), cbs_h2645_write_slice_data(), cbs_jpeg_write_scan(), cbs_mpeg2_write_slice(), cbs_vp9_write_unit(), encode_hq_slice(), encode_slices(), ff_copy_bits(), and ff_mjpeg_escape_FF().

static void skip_put_bits ( PutBitContext s,
int  n 
)
inlinestatic

Skip the given number of bits.

Must only be used if the actual values in the bitstream do not matter. If n is < 0 the behavior is undefined.

Definition at line 401 of file put_bits.h.

Referenced by ff_h263_encode_motion_vector(), and mpeg4_encode_blocks().

static void set_put_bits_buffer_size ( PutBitContext s,
int  size 
)
inlinestatic

Change the end of the buffer.

Parameters
sizethe new size in bytes of the buffer where to put bits

Definition at line 413 of file put_bits.h.

Referenced by encode_picture(), ff_mpeg4_init_partitions(), and ff_mpeg4_merge_partitions().

static void align_put_bits ( PutBitContext s)
inlinestatic

Variable Documentation

const int BUF_BITS = 8 * sizeof(BitBuf)
static