FFmpeg
Data Structures | Macros | Functions
vlc.h File Reference
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  VLC
 
struct  RL_VLC_ELEM
 

Macros

#define VLC_TYPE   int16_t
 
#define init_vlc(vlc, nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, flags)
 
#define INIT_VLC_INPUT_LE   2
 
#define INIT_VLC_OUTPUT_LE   8
 
#define INIT_VLC_LE   (INIT_VLC_INPUT_LE | INIT_VLC_OUTPUT_LE)
 
#define INIT_VLC_USE_NEW_STATIC   4
 
#define INIT_VLC_STATIC_OVERLONG   (1 | INIT_VLC_USE_NEW_STATIC)
 
#define INIT_CUSTOM_VLC_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, h, i, j, flags, static_size)
 
#define INIT_VLC_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, h, i, j, static_size)
 
#define INIT_LE_VLC_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, h, i, j, static_size)
 
#define INIT_CUSTOM_VLC_STATIC(vlc, bits, a, b, c, d, e, f, g, flags, static_size)
 
#define INIT_VLC_STATIC(vlc, bits, a, b, c, d, e, f, g, static_size)   INIT_VLC_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, NULL, 0, 0, static_size)
 
#define INIT_LE_VLC_STATIC(vlc, bits, a, b, c, d, e, f, g, static_size)   INIT_LE_VLC_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, NULL, 0, 0, static_size)
 
#define INIT_VLC_STATIC_FROM_LENGTHS(vlc, bits, nb_codes, lens, len_wrap, symbols, symbols_wrap, symbols_size, offset, flags, static_size)
 

Functions

int ff_init_vlc_sparse (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, const void *symbols, int symbols_wrap, int symbols_size, int flags)
 
int ff_init_vlc_from_lengths (VLC *vlc, int nb_bits, int nb_codes, const int8_t *lens, int lens_wrap, const void *symbols, int symbols_wrap, int symbols_size, int offset, int flags, void *logctx)
 Build VLC decoding tables suitable for use with get_vlc2() More...
 
void ff_free_vlc (VLC *vlc)
 

Macro Definition Documentation

#define VLC_TYPE   int16_t
#define init_vlc (   vlc,
  nb_bits,
  nb_codes,
  bits,
  bits_wrap,
  bits_size,
  codes,
  codes_wrap,
  codes_size,
  flags 
)
Value:
ff_init_vlc_sparse(vlc, nb_bits, nb_codes, \
bits, bits_wrap, bits_size, \
codes, codes_wrap, codes_size, \
NULL, 0, 0, flags)
#define NULL
Definition: coverity.c:32
uint8_t bits
Definition: vp3data.h:141
int ff_init_vlc_sparse(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, const void *symbols, int symbols_wrap, int symbols_size, int flags)
Definition: bitstream.c:323
#define flags(name, subs,...)
Definition: cbs_av1.c:561

Definition at line 38 of file vlc.h.

Referenced by decode_init(), decode_rle(), dnxhd_init_vlc(), ff_cfhd_init_vlcs(), ff_dvvideo_init(), ff_h264_decode_init_vlc(), ff_hq_init_vlcs(), ff_hqx_init_vlcs(), ff_init_2d_vlc_rl(), ff_rl_init_vlc(), generate_joint_tables(), huff_reader_build_canonical(), init_coef_vlc(), init_static(), init_vlcs(), ivi_create_huff_from_desc(), mpegaudiodec_common_init_static(), read_huffman_tables(), read_old_huffman_tables(), svq1_static_init(), vc1_init_static(), vorbis_parse_setup_hdr_codebooks(), vp3_decode_init(), and wma_decode_init().

#define INIT_VLC_INPUT_LE   2

Definition at line 91 of file vlc.h.

#define INIT_VLC_OUTPUT_LE   8
#define INIT_VLC_LE   (INIT_VLC_INPUT_LE | INIT_VLC_OUTPUT_LE)
#define INIT_VLC_USE_NEW_STATIC   4
#define INIT_VLC_STATIC_OVERLONG   (1 | INIT_VLC_USE_NEW_STATIC)
#define INIT_CUSTOM_VLC_SPARSE_STATIC (   vlc,
  bits,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i,
  j,
  flags,
  static_size 
)
Value:
do { \
static VLC_TYPE table[static_size][2]; \
(vlc)->table = table; \
(vlc)->table_allocated = static_size; \
ff_init_vlc_sparse(vlc, bits, a, b, c, d, e, f, g, h, i, j, \
} while (0)
const char * g
Definition: vf_curves.c:117
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:36
#define f(width, name)
Definition: cbs_vp9.c:255
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
static const uint16_t table[]
Definition: prosumer.c:206
uint8_t bits
Definition: vp3data.h:141
#define b
Definition: input.c:41
int ff_init_vlc_sparse(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, const void *symbols, int symbols_wrap, int symbols_size, int flags)
Definition: bitstream.c:323
#define flags(name, subs,...)
Definition: cbs_av1.c:561
#define INIT_VLC_USE_NEW_STATIC
Definition: vlc.h:95
#define VLC_TYPE
Definition: vlc.h:24
int i
Definition: input.c:407

Definition at line 98 of file vlc.h.

#define INIT_VLC_SPARSE_STATIC (   vlc,
  bits,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i,
  j,
  static_size 
)
Value:
h, i, j, 0, static_size)
const char * g
Definition: vf_curves.c:117
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:36
#define f(width, name)
Definition: cbs_vp9.c:255
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
uint8_t bits
Definition: vp3data.h:141
#define b
Definition: input.c:41
#define INIT_CUSTOM_VLC_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g,h, i, j, flags, static_size)
Definition: vlc.h:98
int i
Definition: input.c:407

Definition at line 108 of file vlc.h.

Referenced by imm4_init_static_data().

#define INIT_LE_VLC_SPARSE_STATIC (   vlc,
  bits,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i,
  j,
  static_size 
)
Value:
h, i, j, INIT_VLC_LE, static_size)
const char * g
Definition: vf_curves.c:117
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:36
#define f(width, name)
Definition: cbs_vp9.c:255
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
uint8_t bits
Definition: vp3data.h:141
#define b
Definition: input.c:41
#define INIT_VLC_LE
Definition: vlc.h:94
#define INIT_CUSTOM_VLC_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g,h, i, j, flags, static_size)
Definition: vlc.h:98
int i
Definition: input.c:407

Definition at line 112 of file vlc.h.

#define INIT_CUSTOM_VLC_STATIC (   vlc,
  bits,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  flags,
  static_size 
)
Value:
NULL, 0, 0, flags, static_size)
#define NULL
Definition: coverity.c:32
const char * g
Definition: vf_curves.c:117
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:36
#define f(width, name)
Definition: cbs_vp9.c:255
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
uint8_t bits
Definition: vp3data.h:141
#define b
Definition: input.c:41
#define INIT_CUSTOM_VLC_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g,h, i, j, flags, static_size)
Definition: vlc.h:98
#define flags(name, subs,...)
Definition: cbs_av1.c:561

Definition at line 116 of file vlc.h.

#define INIT_VLC_STATIC (   vlc,
  bits,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  static_size 
)    INIT_VLC_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, NULL, 0, 0, static_size)
#define INIT_LE_VLC_STATIC (   vlc,
  bits,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  static_size 
)    INIT_LE_VLC_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, NULL, 0, 0, static_size)

Definition at line 123 of file vlc.h.

Referenced by init_vlcs().

#define INIT_VLC_STATIC_FROM_LENGTHS (   vlc,
  bits,
  nb_codes,
  lens,
  len_wrap,
  symbols,
  symbols_wrap,
  symbols_size,
  offset,
  flags,
  static_size 
)
Value:
do { \
static VLC_TYPE table[static_size][2]; \
(vlc)->table = table; \
(vlc)->table_allocated = static_size; \
ff_init_vlc_from_lengths(vlc, bits, nb_codes, lens, len_wrap, \
symbols, symbols_wrap, symbols_size, \
NULL); \
} while (0)
#define NULL
Definition: coverity.c:32
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
static const uint16_t table[]
Definition: prosumer.c:206
uint8_t bits
Definition: vp3data.h:141
int ff_init_vlc_from_lengths(VLC *vlc, int nb_bits, int nb_codes, const int8_t *lens, int lens_wrap, const void *symbols, int symbols_wrap, int symbols_size, int offset, int flags, void *logctx)
Build VLC decoding tables suitable for use with get_vlc2()
Definition: bitstream.c:381
#define flags(name, subs,...)
Definition: cbs_av1.c:561
#define INIT_VLC_USE_NEW_STATIC
Definition: vlc.h:95
#define VLC_TYPE
Definition: vlc.h:24

Definition at line 126 of file vlc.h.

Referenced by clv_init_static(), ff_mpeg4videodec_static_init(), imm4_init_static_data(), init_static_data(), ir2_init_static(), mimic_init_static(), mobiclip_init_static(), mpc7_init_static(), mpeg4_init_static(), and wnv1_init_static().

Function Documentation

int ff_init_vlc_sparse ( 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,
const void symbols,
int  symbols_wrap,
int  symbols_size,
int  flags 
)
int ff_init_vlc_from_lengths ( VLC vlc,
int  nb_bits,
int  nb_codes,
const int8_t *  lens,
int  lens_wrap,
const void symbols,
int  symbols_wrap,
int  symbols_size,
int  offset,
int  flags,
void logctx 
)

Build VLC decoding tables suitable for use with get_vlc2()

This function takes lengths and symbols and calculates the codes from them. For this the input lengths and symbols have to be sorted according to "left nodes in the corresponding tree first".

Parameters
[in,out]vlcThe VLC to be initialized; table and table_allocated must have been set when initializing a static VLC, otherwise this will be treated as uninitialized.
[in]nb_bitsThe number of bits to use for the VLC table; higher values take up more memory and cache, but allow to read codes with fewer reads.
[in]nb_codesThe number of provided length and (if supplied) symbol entries.
[in]lensThe lengths of the codes. Entries > 0 correspond to valid codes; entries == 0 will be skipped and entries with len < 0 indicate that the tree is incomplete and has an open end of length -len at this position.
[in]lens_wrapStride (in bytes) of the lengths.
[in]symbolsThe symbols, i.e. what is returned from get_vlc2() when the corresponding code is encountered. May be NULL, then 0, 1, 2, 3, 4,... will be used.
[in]symbols_wrapStride (in bytes) of the symbols.
[in]symbols_sizeSize of the symbols. 1 and 2 are supported.
[in]offsetAn offset to apply to all the valid symbols.
[in]flagsA combination of the INIT_VLC_* flags; notice that INIT_VLC_INPUT_LE is pointless and ignored.

Definition at line 381 of file bitstream.c.

Referenced by atrac3_init_static_data(), atrac9_init_vlc(), build_canonical_huff(), build_huff(), build_vlc(), clv_init_static(), ff_mjpeg_build_vlc(), huff_build(), imc_init_static(), mobiclip_init_static(), mp_decode_frame(), mpc7_init_static(), mpeg4_init_static(), mpegaudiodec_common_init_static(), mss4_init_vlc(), on2avc_decode_init(), qdmc_init_static_data(), read_code_table(), rv10_build_vlc(), rv40_init_table(), rv40_init_tables(), smacker_decode_header_tree(), smka_decode_frame(), tm2_build_huff_table(), tscc2_init_vlc(), vp3_decode_init(), wma_decode_init(), and x8_init_vlc().

void ff_free_vlc ( VLC vlc)