Data Structures | Macros | Functions | Variables
bitstream.c File Reference

bitstream api. More...

#include "libavutil/avassert.h"
#include "libavutil/qsort.h"
#include "avcodec.h"
#include "internal.h"
#include "mathops.h"
#include "put_bits.h"
#include "vlc.h"

Go to the source code of this file.

Data Structures

struct  VLCcode


#define GET_DATA(v, table, i, wrap, size)
#define COPY(condition)


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 int alloc_table (VLC *vlc, int size, int use_static)
static int compare_vlcspec (const void *a, const void *b)
static int build_table (VLC *vlc, int table_nb_bits, int nb_codes, VLCcode *codes, int flags)
 Build VLC decoding tables suitable for use with get_vlc(). More...
int ff_init_vlc_sparse (VLC *vlc_arg, int nb_bits, int nb_codes, const void *bits, int bits_wrap, int bits_size, const void *codes, int codes_wrap, int codes_size, const void *symbols, int symbols_wrap, int symbols_size, int flags)
void ff_free_vlc (VLC *vlc)


const uint8_t ff_log2_run [41]

Detailed Description

bitstream api.

Definition in file bitstream.c.

Macro Definition Documentation

#define GET_DATA (   v,
{ \
const uint8_t *ptr = (const uint8_t *)table + i * wrap; \
switch(size) { \
case 1: \
v = *(const uint8_t *)ptr; \
break; \
case 2: \
v = *(const uint16_t *)ptr; \
break; \
case 4: \
v = *(const uint32_t *)ptr; \
break; \
default: \
} \
ptrdiff_t size
Definition: opengl_enc.c:100
static const uint16_t table[]
Definition: prosumer.c:206
#define wrap(func)
Definition: neontest.h:65
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:53
int i
Definition: input.c:407

Definition at line 96 of file bitstream.c.

#define COPY (   condition)
for (i = 0; i < nb_codes; i++) { \
unsigned len; \
GET_DATA(len, bits, i, bits_wrap, bits_size); \
if (!(condition)) \
continue; \
if (len > 3*nb_bits || len > 32) { \
av_log(NULL, AV_LOG_ERROR, "Too long VLC (%u) in init_vlc\n", len);\
if (buf != localbuf) \
av_free(buf); \
} \
buf[j].bits = len; \
GET_DATA(buf[j].code, codes, i, codes_wrap, codes_size); \
if (buf[j].code >= (1LL<<buf[j].bits)) { \
av_log(NULL, AV_LOG_ERROR, "Invalid code %"PRIx32" for %d in " \
"init_vlc\n", buf[j].code, i); \
if (buf != localbuf) \
av_free(buf); \
} \
buf[j].code = bitswap_32(buf[j].code); \
else \
buf[j].code <<= 32 - buf[j].bits; \
if (symbols) \
GET_DATA(buf[j].symbol, symbols, i, symbols_wrap, symbols_size) \
else \
buf[j].symbol = i; \
j++; \
#define NULL
Definition: coverity.c:32
#define GET_DATA(v, table, i, wrap, size)
Definition: bitstream.c:96
static av_always_inline uint32_t bitswap_32(uint32_t x)
Definition: mathops.h:243
#define av_log(a,...)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:194
uint8_t bits
Definition: vp3data.h:202
#define flags(name, subs,...)
Definition: cbs_av1.c:560
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
Definition: vlc.h:56
#define av_free(p)
int len
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a it should return
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Frame references ownership and permissions
int i
Definition: input.c:407

Referenced by ff_init_vlc_sparse().

Function Documentation

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.

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.

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 int alloc_table ( VLC vlc,
int  size,
int  use_static 

Definition at line 115 of file bitstream.c.

Referenced by build_table(), and mp_decode_layer2().

static int compare_vlcspec ( const void a,
const void b 

Definition at line 143 of file bitstream.c.

Referenced by ff_init_vlc_sparse().

static int build_table ( VLC vlc,
int  table_nb_bits,
int  nb_codes,
VLCcode codes,
int  flags 

Build VLC decoding tables suitable for use with get_vlc().

vlcthe context to be initialized
table_nb_bitsmax length of vlc codes to store directly in this table (Longer codes are delegated to subtables.)
nb_codesnumber of elements in codes[]
codesdescriptions of the vlc codes These must be ordered such that codes going into the same subtable are contiguous. Sorting by VLCcode.code is sufficient, though not necessary.

Definition at line 162 of file bitstream.c.

Referenced by ff_init_vlc_sparse().

int ff_init_vlc_sparse ( VLC vlc_arg,
int  nb_bits,
int  nb_codes,
const void bits,
int  bits_wrap,
int  bits_size,
const void codes,
int  codes_wrap,
int  codes_size,
const void symbols,
int  symbols_wrap,
int  symbols_size,
int  flags 
void ff_free_vlc ( VLC vlc)

Variable Documentation

const uint8_t ff_log2_run[41]
Initial value:
0, 0, 0, 0, 1, 1, 1, 1,
2, 2, 2, 2, 3, 3, 3, 3,
4, 4, 5, 5, 6, 6, 7, 7,
8, 9,10,11,12,13,14,15,

Definition at line 39 of file bitstream.c.

Referenced by decode_line_TMPL(), encode_line_TMPL(), ls_decode_line(), ls_encode_line(), and ls_encode_run().