Go to the documentation of this file.
40 #define GET_DATA(v, table, i, wrap, size) \
42 const uint8_t *ptr = (const uint8_t *)table + i * wrap; \
45 v = *(const uint8_t *)ptr; \
48 v = *(const uint16_t *)ptr; \
52 av_assert1(size == 4); \
53 v = *(const uint32_t *)ptr; \
79 #define LOCALBUF_ELEMS 1500 // the maximum currently needed is 1296 by rv34
120 return (sa->
code >> 1) - (sb->code >> 1);
140 int table_size, table_index;
143 if (table_nb_bits > 30)
145 table_size = 1 << table_nb_bits;
147 ff_dlog(
NULL,
"new table index=%d size=%d\n", table_index, table_size);
153 for (
int i = 0;
i < nb_codes;
i++) {
154 int n = codes[
i].
bits;
158 if (n <= table_nb_bits) {
160 int j =
code >> (32 - table_nb_bits);
161 int nb = 1 << (table_nb_bits - n);
168 for (
int k = 0; k < nb; k++) {
170 int oldsym =
table[j].sym;
172 if ((
bits || oldsym) && (
bits != n || oldsym != symbol)) {
177 table[j].sym = symbol;
183 int index, subtable_bits, j, k;
190 for (k =
i + 1; k < nb_codes; k++) {
191 n = codes[k].
bits - table_nb_bits;
198 codes[k].
code =
code << table_nb_bits;
199 subtable_bits =
FFMAX(subtable_bits, n);
201 subtable_bits =
FFMIN(subtable_bits, table_nb_bits);
203 table[j].len = -subtable_bits;
205 j, codes[
i].
bits + table_nb_bits);
220 for (
int i = 0;
i < table_size;
i++) {
239 if (codes != localbuf)
274 const void *codes,
int codes_wrap,
int codes_size,
275 const void *symbols,
int symbols_wrap,
int symbols_size,
287 #define COPY(condition)\
288 for (int i = 0; i < nb_codes; i++) { \
290 GET_DATA(len, bits, i, bits_wrap, bits_size); \
293 if (len > 3*nb_bits || len > 32) { \
294 av_log(NULL, AV_LOG_ERROR, "Too long VLC (%u) in init_vlc\n", len);\
295 if (buf != localbuf) \
297 return AVERROR(EINVAL); \
300 GET_DATA(buf[j].code, codes, i, codes_wrap, codes_size); \
301 if (buf[j].code >= (1LL<<buf[j].bits)) { \
302 av_log(NULL, AV_LOG_ERROR, "Invalid code %"PRIx32" for %d in " \
303 "init_vlc\n", buf[j].code, i); \
304 if (buf != localbuf) \
306 return AVERROR(EINVAL); \
308 if (flags & INIT_VLC_INPUT_LE) \
309 buf[j].code = bitswap_32(buf[j].code); \
311 buf[j].code <<= 32 - buf[j].bits; \
313 GET_DATA(buf[j].symbol, symbols, i, symbols_wrap, symbols_size) \
329 const int8_t *lens,
int lens_wrap,
330 const void *symbols,
int symbols_wrap,
int symbols_size,
335 int ret, j, len_max =
FFMIN(32, 3 * nb_bits);
342 for (
int i = 0;
i < nb_codes;
i++, lens += lens_wrap) {
349 GET_DATA(sym, symbols,
i, symbols_wrap, symbols_size)
354 }
else if (
len < 0) {
358 if (
len > len_max ||
code & ((1
U << (32 -
len)) - 1)) {
363 if (
code > UINT32_MAX + 1ULL) {
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
#define INIT_VLC_OUTPUT_LE
static int vlc_common_init(VLC *vlc, int nb_bits, int nb_codes, VLCcode **buf, int flags)
const uint8_t ff_reverse[256]
static const uint16_t table[]
static int vlc_common_end(VLC *vlc, int nb_bits, int nb_codes, VLCcode *codes, int flags, VLCcode localbuf[LOCALBUF_ELEMS])
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_always_inline uint32_t bitswap_32(uint32_t x)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
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().
#define av_realloc_f(p, o, n)
#define GET_DATA(v, table, i, wrap, size)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
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()
#define INIT_VLC_USE_NEW_STATIC
static int compare_vlcspec(const void *a, const void *b)
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
static const unsigned code_prefix[]
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
#define i(width, name, range_min, range_max)
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
#define AV_QSORT(p, num, type, cmp)
Quicksort This sort is fast, and fully inplace but not stable and it is possible to construct input t...
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)
#define av_malloc_array(a, b)
uint32_t code
codeword, with the first bit-to-be-read in the msb (even if intended for a little-endian bitstream re...
void ff_free_vlc(VLC *vlc)
#define INIT_VLC_STATIC_OVERLONG
static int alloc_table(VLC *vlc, int size, int use_static)
#define avpriv_request_sample(...)
#define flags(name, subs,...)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.