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

Go to the source code of this file.

Data Structures

struct  VLCElem
 
struct  VLC
 
struct  VLC_MULTI_ELEM
 
struct  VLC_MULTI
 
struct  RL_VLC_ELEM
 

Macros

#define VLC_MULTI_MAX_SYMBOLS   6
 
#define vlc_init(vlc, nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, flags)
 
#define VLC_INIT_USE_STATIC   1
 
#define VLC_INIT_STATIC_OVERLONG   (2 | VLC_INIT_USE_STATIC)
 
#define VLC_INIT_INPUT_LE   4
 
#define VLC_INIT_OUTPUT_LE   8
 
#define VLC_INIT_LE   (VLC_INIT_INPUT_LE | VLC_INIT_OUTPUT_LE)
 
#define VLC_INIT_CUSTOM_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, h, i, j, flags, static_size)
 
#define VLC_INIT_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, h, i, j, static_size)
 
#define VLC_INIT_LE_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, h, i, j, static_size)
 
#define VLC_INIT_CUSTOM_STATIC(vlc, bits, a, b, c, d, e, f, g, flags, static_size)
 
#define VLC_INIT_STATIC(vlc, bits, a, b, c, d, e, f, g, static_size)   VLC_INIT_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, NULL, 0, 0, static_size)
 
#define VLC_INIT_LE_STATIC(vlc, bits, a, b, c, d, e, f, g, static_size)   VLC_INIT_LE_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, NULL, 0, 0, static_size)
 
#define VLC_INIT_STATIC_FROM_LENGTHS(vlc, bits, nb_codes, lens, len_wrap, symbols, symbols_wrap, symbols_size, offset, flags, static_size)
 

Typedefs

typedef int16_t VLCBaseType
 

Functions

int ff_vlc_init_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)
 Build VLC decoding tables suitable for use with get_vlc2(). More...
 
int ff_vlc_init_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...
 
int ff_vlc_init_multi_from_lengths (VLC *vlc, VLC_MULTI *multi, int nb_bits, int nb_elems, 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_vlc_multi() More...
 
void ff_vlc_free_multi (VLC_MULTI *vlc)
 
void ff_vlc_free (VLC *vlc)
 

Macro Definition Documentation

◆ VLC_MULTI_MAX_SYMBOLS

#define VLC_MULTI_MAX_SYMBOLS   6

Definition at line 24 of file vlc.h.

◆ vlc_init

#define vlc_init (   vlc,
  nb_bits,
  nb_codes,
  bits,
  bits_wrap,
  bits_size,
  codes,
  codes_wrap,
  codes_size,
  flags 
)
Value:
ff_vlc_init_sparse(vlc, nb_bits, nb_codes, \
bits, bits_wrap, bits_size, \
codes, codes_wrap, codes_size, \
NULL, 0, 0, flags)

Definition at line 56 of file vlc.h.

◆ VLC_INIT_USE_STATIC

#define VLC_INIT_USE_STATIC   1

Definition at line 176 of file vlc.h.

◆ VLC_INIT_STATIC_OVERLONG

#define VLC_INIT_STATIC_OVERLONG   (2 | VLC_INIT_USE_STATIC)

Definition at line 177 of file vlc.h.

◆ VLC_INIT_INPUT_LE

#define VLC_INIT_INPUT_LE   4

Definition at line 180 of file vlc.h.

◆ VLC_INIT_OUTPUT_LE

#define VLC_INIT_OUTPUT_LE   8

Definition at line 182 of file vlc.h.

◆ VLC_INIT_LE

#define VLC_INIT_LE   (VLC_INIT_INPUT_LE | VLC_INIT_OUTPUT_LE)

Definition at line 183 of file vlc.h.

◆ VLC_INIT_CUSTOM_SPARSE_STATIC

#define VLC_INIT_CUSTOM_SPARSE_STATIC (   vlc,
  bits,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i,
  j,
  flags,
  static_size 
)
Value:
do { \
static VLCElem table[static_size]; \
(vlc)->table = table; \
(vlc)->table_allocated = static_size; \
ff_vlc_init_sparse(vlc, bits, a, b, c, d, e, f, g, h, i, j, \
} while (0)

Definition at line 185 of file vlc.h.

◆ VLC_INIT_SPARSE_STATIC

#define VLC_INIT_SPARSE_STATIC (   vlc,
  bits,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i,
  j,
  static_size 
)
Value:
h, i, j, 0, static_size)

Definition at line 195 of file vlc.h.

◆ VLC_INIT_LE_SPARSE_STATIC

#define VLC_INIT_LE_SPARSE_STATIC (   vlc,
  bits,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i,
  j,
  static_size 
)
Value:
h, i, j, VLC_INIT_LE, static_size)

Definition at line 199 of file vlc.h.

◆ VLC_INIT_CUSTOM_STATIC

#define VLC_INIT_CUSTOM_STATIC (   vlc,
  bits,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  flags,
  static_size 
)
Value:
NULL, 0, 0, flags, static_size)

Definition at line 203 of file vlc.h.

◆ VLC_INIT_STATIC

#define VLC_INIT_STATIC (   vlc,
  bits,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  static_size 
)    VLC_INIT_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, NULL, 0, 0, static_size)

Definition at line 207 of file vlc.h.

◆ VLC_INIT_LE_STATIC

#define VLC_INIT_LE_STATIC (   vlc,
  bits,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  static_size 
)    VLC_INIT_LE_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, NULL, 0, 0, static_size)

Definition at line 210 of file vlc.h.

◆ VLC_INIT_STATIC_FROM_LENGTHS

#define VLC_INIT_STATIC_FROM_LENGTHS (   vlc,
  bits,
  nb_codes,
  lens,
  len_wrap,
  symbols,
  symbols_wrap,
  symbols_size,
  offset,
  flags,
  static_size 
)
Value:
do { \
static VLCElem table[static_size]; \
(vlc)->table = table; \
(vlc)->table_allocated = static_size; \
ff_vlc_init_from_lengths(vlc, bits, nb_codes, lens, len_wrap, \
symbols, symbols_wrap, symbols_size, \
NULL); \
} while (0)

Definition at line 213 of file vlc.h.

Typedef Documentation

◆ VLCBaseType

typedef int16_t VLCBaseType

Definition at line 27 of file vlc.h.

Function Documentation

◆ ff_vlc_init_sparse()

int ff_vlc_init_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 
)

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

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. Corresponds to the bits parameter of get_vlc2().
[in]nb_codesThe number of provided bits, codes and (if supplied) symbol entries.
[in]bitsThe lengths (in bits) of the codes. Entries > 0 correspond to valid codes; entries == 0 will be skipped.
[in]bits_wrapStride (in bytes) of the bits table.
[in]codes_sizeSize of the bits. 1, 2 and 4 are supported.
[in]codesTable which gives the bit pattern of of each vlc code.
[in]codes_wrapStride (in bytes) of the codes table.
[in]codes_sizeSize of the codes. 1, 2 and 4 are supported.
[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 table.
[in]symbols_sizeSize of the symbols. 1 and 2 are supported.
[in]flagsA combination of the VLC_INIT_* flags.

'wrap' and 'size' make it possible to use any memory configuration and types (byte/word/int) to store the 'bits', 'codes', and 'symbols' tables.

Definition at line 250 of file vlc.c.

Referenced by aac_static_table_init(), build_huff(), build_huff_tree(), build_vlc(), ccitt_unpack_init(), dnxhd_init_vlc(), generate_joint_tables(), huf_build_dec_table(), init_ralf_vlc(), read_hufftable(), and rv34_gen_vlc().

◆ ff_vlc_init_from_lengths()

int ff_vlc_init_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 VLC_INIT_* flags; notice that VLC_INIT_INPUT_LE is pointless and ignored.

Definition at line 306 of file vlc.c.

Referenced by atrac3_init_static_data(), atrac9_init_vlc(), build_canonical_huff(), build_vlc(), cfhd_init_vlc(), clv_init_static(), dv_init_static(), ff_mjpeg_build_vlc(), imc_init_static(), mobiclip_init_static(), mp_decode_frame(), mpc7_init_static(), mpegaudiodec_common_init_static(), mss4_init_vlc(), on2avc_decode_init(), qdmc_init_static_data(), read_code_table(), read_simple_vlc_prefix(), read_vlc_prefix(), 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().

◆ ff_vlc_init_multi_from_lengths()

int ff_vlc_init_multi_from_lengths ( VLC vlc,
VLC_MULTI multi,
int  nb_bits,
int  nb_elems,
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_vlc_multi()

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,out]multiThe VLC_MULTI 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_elemsThe max possible number of elements.
[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 VLC_INIT_* flags; notice that VLC_INIT_INPUT_LE is pointless and ignored.

Definition at line 446 of file vlc.c.

Referenced by build_huff(), and huff_build().

◆ ff_vlc_free_multi()

void ff_vlc_free_multi ( VLC_MULTI vlc)

◆ ff_vlc_free()

void ff_vlc_free ( VLC vlc)
b
#define b
Definition: input.c:41
table
static const uint16_t table[]
Definition: prosumer.c:205
VLC_INIT_LE
#define VLC_INIT_LE
Definition: vlc.h:183
g
const char * g
Definition: vf_curves.c:127
bits
uint8_t bits
Definition: vp3data.h:128
NULL
#define NULL
Definition: coverity.c:32
c
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
f
f
Definition: af_crystalizer.c:121
VLCElem
Definition: vlc.h:29
a
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:41
offset
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
Definition: writing_filters.txt:86
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
bits_size
#define bits_size
Definition: bitstream.h:113
ff_vlc_init_sparse
int ff_vlc_init_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)
Build VLC decoding tables suitable for use with get_vlc2().
Definition: vlc.c:250
d
d
Definition: ffmpeg_filter.c:368
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474
VLC_INIT_USE_STATIC
#define VLC_INIT_USE_STATIC
Definition: vlc.h:176
h
h
Definition: vp9dsp_template.c:2038
VLC_INIT_CUSTOM_SPARSE_STATIC
#define VLC_INIT_CUSTOM_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, h, i, j, flags, static_size)
Definition: vlc.h:185