FFmpeg
vlc.c
Go to the documentation of this file.
1 /*
2  * API for creating VLC trees
3  * Copyright (c) 2000, 2001 Fabrice Bellard
4  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
5  * Copyright (c) 2010 Loren Merritt
6  *
7  * This file is part of FFmpeg.
8  *
9  * FFmpeg is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * FFmpeg is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with FFmpeg; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23 
24 #include <inttypes.h>
25 #include <stdint.h>
26 #include <stdlib.h>
27 #include <string.h>
28 
29 #include "libavutil/attributes.h"
30 #include "libavutil/avassert.h"
31 #include "libavutil/error.h"
32 #include "libavutil/internal.h"
33 #include "libavutil/intreadwrite.h"
34 #include "libavutil/log.h"
35 #include "libavutil/macros.h"
36 #include "libavutil/mem.h"
37 #include "libavutil/qsort.h"
38 #include "libavutil/reverse.h"
39 #include "vlc.h"
40 
41 #define GET_DATA(v, table, i, wrap, size) \
42 { \
43  const uint8_t *ptr = (const uint8_t *)table + i * wrap; \
44  switch(size) { \
45  case 1: \
46  v = *(const uint8_t *)ptr; \
47  break; \
48  case 2: \
49  v = *(const uint16_t *)ptr; \
50  break; \
51  case 4: \
52  default: \
53  av_assert1(size == 4); \
54  v = *(const uint32_t *)ptr; \
55  break; \
56  } \
57 }
58 
59 
60 static int alloc_table(VLC *vlc, int size, int use_static)
61 {
62  int index = vlc->table_size;
63 
64  vlc->table_size += size;
65  if (vlc->table_size > vlc->table_allocated) {
66  if (use_static)
67  abort(); // cannot do anything, vlc_init() is used with too little memory
68  vlc->table_allocated += (1 << vlc->bits);
69  vlc->table = av_realloc_f(vlc->table, vlc->table_allocated, sizeof(*vlc->table));
70  if (!vlc->table) {
71  vlc->table_allocated = 0;
72  vlc->table_size = 0;
73  return AVERROR(ENOMEM);
74  }
75  memset(vlc->table + vlc->table_allocated - (1 << vlc->bits), 0, sizeof(*vlc->table) << vlc->bits);
76  }
77  return index;
78 }
79 
80 #define LOCALBUF_ELEMS 1500 // the maximum currently needed is 1296 by rv34
81 
82 static av_always_inline uint32_t bitswap_32(uint32_t x)
83 {
84  return (uint32_t)ff_reverse[ x & 0xFF] << 24 |
85  (uint32_t)ff_reverse[(x >> 8) & 0xFF] << 16 |
86  (uint32_t)ff_reverse[(x >> 16) & 0xFF] << 8 |
87  (uint32_t)ff_reverse[ x >> 24];
88 }
89 
90 typedef struct VLCcode {
91  uint8_t bits;
93  /** codeword, with the first bit-to-be-read in the msb
94  * (even if intended for a little-endian bitstream reader) */
95  uint32_t code;
96 } VLCcode;
97 
98 static int vlc_common_init(VLC *vlc, int nb_bits, int nb_codes,
99  VLCcode **buf, int flags)
100 {
101  vlc->bits = nb_bits;
102  vlc->table_size = 0;
103  if (flags & VLC_INIT_USE_STATIC) {
104  av_assert0(nb_codes <= LOCALBUF_ELEMS);
105  } else {
106  vlc->table = NULL;
107  vlc->table_allocated = 0;
108  }
109  if (nb_codes > LOCALBUF_ELEMS) {
110  *buf = av_malloc_array(nb_codes, sizeof(VLCcode));
111  if (!*buf)
112  return AVERROR(ENOMEM);
113  }
114 
115  return 0;
116 }
117 
118 static int compare_vlcspec(const void *a, const void *b)
119 {
120  const VLCcode *sa = a, *sb = b;
121  return (sa->code >> 1) - (sb->code >> 1);
122 }
123 
124 /**
125  * Build VLC decoding tables suitable for use with get_vlc().
126  *
127  * @param vlc the context to be initialized
128  *
129  * @param table_nb_bits max length of vlc codes to store directly in this table
130  * (Longer codes are delegated to subtables.)
131  *
132  * @param nb_codes number of elements in codes[]
133  *
134  * @param codes descriptions of the vlc codes
135  * These must be ordered such that codes going into the same subtable are contiguous.
136  * Sorting by VLCcode.code is sufficient, though not necessary.
137  */
138 static int build_table(VLC *vlc, int table_nb_bits, int nb_codes,
139  VLCcode *codes, int flags)
140 {
141  int table_size, table_index;
142  VLCElem *table;
143 
144  if (table_nb_bits > 30)
145  return AVERROR(EINVAL);
146  table_size = 1 << table_nb_bits;
147  table_index = alloc_table(vlc, table_size, flags & VLC_INIT_USE_STATIC);
148  ff_dlog(NULL, "new table index=%d size=%d\n", table_index, table_size);
149  if (table_index < 0)
150  return table_index;
151  table = &vlc->table[table_index];
152 
153  /* first pass: map codes and compute auxiliary table sizes */
154  for (int i = 0; i < nb_codes; i++) {
155  int n = codes[i].bits;
156  uint32_t code = codes[i].code;
157  int symbol = codes[i].symbol;
158  ff_dlog(NULL, "i=%d n=%d code=0x%"PRIx32"\n", i, n, code);
159  if (n <= table_nb_bits) {
160  /* no need to add another table */
161  int j = code >> (32 - table_nb_bits);
162  int nb = 1 << (table_nb_bits - n);
163  int inc = 1;
164 
165  if (flags & VLC_INIT_OUTPUT_LE) {
166  j = bitswap_32(code);
167  inc = 1 << n;
168  }
169  for (int k = 0; k < nb; k++) {
170  int bits = table[j].len;
171  int oldsym = table[j].sym;
172  ff_dlog(NULL, "%4x: code=%d n=%d\n", j, i, n);
173  if ((bits || oldsym) && (bits != n || oldsym != symbol)) {
174  av_log(NULL, AV_LOG_ERROR, "incorrect codes\n");
175  return AVERROR_INVALIDDATA;
176  }
177  table[j].len = n;
178  table[j].sym = symbol;
179  j += inc;
180  }
181  } else {
182  /* fill auxiliary table recursively */
183  uint32_t code_prefix;
184  int index, subtable_bits, j, k;
185 
186  n -= table_nb_bits;
187  code_prefix = code >> (32 - table_nb_bits);
188  subtable_bits = n;
189  codes[i].bits = n;
190  codes[i].code = code << table_nb_bits;
191  for (k = i + 1; k < nb_codes; k++) {
192  n = codes[k].bits - table_nb_bits;
193  if (n <= 0)
194  break;
195  code = codes[k].code;
196  if (code >> (32 - table_nb_bits) != code_prefix)
197  break;
198  codes[k].bits = n;
199  codes[k].code = code << table_nb_bits;
200  subtable_bits = FFMAX(subtable_bits, n);
201  }
202  subtable_bits = FFMIN(subtable_bits, table_nb_bits);
203  j = (flags & VLC_INIT_OUTPUT_LE) ? bitswap_32(code_prefix) >> (32 - table_nb_bits) : code_prefix;
204  table[j].len = -subtable_bits;
205  ff_dlog(NULL, "%4x: n=%d (subtable)\n",
206  j, codes[i].bits + table_nb_bits);
207  index = build_table(vlc, subtable_bits, k-i, codes+i, flags);
208  if (index < 0)
209  return index;
210  /* note: realloc has been done, so reload tables */
211  table = &vlc->table[table_index];
212  table[j].sym = index;
213  if (table[j].sym != index) {
214  avpriv_request_sample(NULL, "strange codes");
215  return AVERROR_PATCHWELCOME;
216  }
217  i = k-1;
218  }
219  }
220 
221  for (int i = 0; i < table_size; i++) {
222  if (table[i].len == 0)
223  table[i].sym = -1;
224  }
225 
226  return table_index;
227 }
228 
229 static int vlc_common_end(VLC *vlc, int nb_bits, int nb_codes, VLCcode *codes,
230  int flags, VLCcode localbuf[LOCALBUF_ELEMS])
231 {
232  int ret = build_table(vlc, nb_bits, nb_codes, codes, flags);
233 
234  if (flags & VLC_INIT_USE_STATIC) {
235  if (vlc->table_size != vlc->table_allocated &&
237  av_log(NULL, AV_LOG_ERROR, "needed %d had %d\n", vlc->table_size, vlc->table_allocated);
238  av_assert0(ret >= 0);
239  } else {
240  if (codes != localbuf)
241  av_free(codes);
242  if (ret < 0) {
243  av_freep(&vlc->table);
244  return ret;
245  }
246  }
247  return 0;
248 }
249 
250 int ff_vlc_init_sparse(VLC *vlc, int nb_bits, int nb_codes,
251  const void *bits, int bits_wrap, int bits_size,
252  const void *codes, int codes_wrap, int codes_size,
253  const void *symbols, int symbols_wrap, int symbols_size,
254  int flags)
255 {
256  VLCcode localbuf[LOCALBUF_ELEMS], *buf = localbuf;
257  int j, ret;
258 
259  ret = vlc_common_init(vlc, nb_bits, nb_codes, &buf, flags);
260  if (ret < 0)
261  return ret;
262 
263  av_assert0(symbols_size <= 2 || !symbols);
264  j = 0;
265 #define COPY(condition)\
266  for (int i = 0; i < nb_codes; i++) { \
267  unsigned len; \
268  GET_DATA(len, bits, i, bits_wrap, bits_size); \
269  if (!(condition)) \
270  continue; \
271  if (len > 3*nb_bits || len > 32) { \
272  av_log(NULL, AV_LOG_ERROR, "Too long VLC (%u) in vlc_init\n", len);\
273  if (buf != localbuf) \
274  av_free(buf); \
275  return AVERROR(EINVAL); \
276  } \
277  buf[j].bits = len; \
278  GET_DATA(buf[j].code, codes, i, codes_wrap, codes_size); \
279  if (buf[j].code >= (1LL<<buf[j].bits)) { \
280  av_log(NULL, AV_LOG_ERROR, "Invalid code %"PRIx32" for %d in " \
281  "vlc_init\n", buf[j].code, i); \
282  if (buf != localbuf) \
283  av_free(buf); \
284  return AVERROR(EINVAL); \
285  } \
286  if (flags & VLC_INIT_INPUT_LE) \
287  buf[j].code = bitswap_32(buf[j].code); \
288  else \
289  buf[j].code <<= 32 - buf[j].bits; \
290  if (symbols) \
291  GET_DATA(buf[j].symbol, symbols, i, symbols_wrap, symbols_size) \
292  else \
293  buf[j].symbol = i; \
294  j++; \
295  }
296  COPY(len > nb_bits);
297  // qsort is the slowest part of vlc_init, and could probably be improved or avoided
298  AV_QSORT(buf, j, struct VLCcode, compare_vlcspec);
299  COPY(len && len <= nb_bits);
300  nb_codes = j;
301 
302  return vlc_common_end(vlc, nb_bits, nb_codes, buf,
303  flags, localbuf);
304 }
305 
306 int ff_vlc_init_from_lengths(VLC *vlc, int nb_bits, int nb_codes,
307  const int8_t *lens, int lens_wrap,
308  const void *symbols, int symbols_wrap, int symbols_size,
309  int offset, int flags, void *logctx)
310 {
311  VLCcode localbuf[LOCALBUF_ELEMS], *buf = localbuf;
312  uint64_t code;
313  int ret, j, len_max = FFMIN(32, 3 * nb_bits);
314 
315  ret = vlc_common_init(vlc, nb_bits, nb_codes, &buf, flags);
316  if (ret < 0)
317  return ret;
318 
319  j = code = 0;
320  for (int i = 0; i < nb_codes; i++, lens += lens_wrap) {
321  int len = *lens;
322  if (len > 0) {
323  unsigned sym;
324 
325  buf[j].bits = len;
326  if (symbols)
327  GET_DATA(sym, symbols, i, symbols_wrap, symbols_size)
328  else
329  sym = i;
330  buf[j].symbol = sym + offset;
331  buf[j++].code = code;
332  } else if (len < 0) {
333  len = -len;
334  } else
335  continue;
336  if (len > len_max || code & ((1U << (32 - len)) - 1)) {
337  av_log(logctx, AV_LOG_ERROR, "Invalid VLC (length %u)\n", len);
338  goto fail;
339  }
340  code += 1U << (32 - len);
341  if (code > UINT32_MAX + 1ULL) {
342  av_log(logctx, AV_LOG_ERROR, "Overdetermined VLC tree\n");
343  goto fail;
344  }
345  }
346  return vlc_common_end(vlc, nb_bits, j, buf, flags, localbuf);
347 fail:
348  if (buf != localbuf)
349  av_free(buf);
350  return AVERROR_INVALIDDATA;
351 }
352 
353 static void add_level(VLC_MULTI_ELEM *table, const int is16bit,
354  const int num, const int numbits,
355  const VLCcode *buf,
356  uint32_t curcode, int curlen,
357  int curlimit, int curlevel,
358  const int minlen, const int max,
359  unsigned* levelcnt, VLC_MULTI_ELEM info)
360 {
361  int max_symbols = VLC_MULTI_MAX_SYMBOLS >> is16bit;
362  for (int i = num-1; i >= max; i--) {
363  for (int j = 0; j < 2; j++) {
364  int newlimit, sym;
365  int t = j ? i-1 : i;
366  int l = buf[t].bits;
367  uint32_t code;
368 
369  sym = buf[t].symbol;
370  if (l >= curlimit)
371  return;
372  code = curcode + (buf[t].code >> curlen);
373  newlimit = curlimit - l;
374  l += curlen;
375  if (is16bit) AV_WN16(info.val+2*curlevel, sym);
376  else info.val[curlevel] = sym&0xFF;
377 
378  if (curlevel) { // let's not add single entries
379  uint32_t val = code >> (32 - numbits);
380  uint32_t nb = val + (1U << (numbits - l));
381  info.len = l;
382  info.num = curlevel+1;
383  for (; val < nb; val++)
384  AV_COPY64(table+val, &info);
385  levelcnt[curlevel-1]++;
386  }
387 
388  if (curlevel+1 < max_symbols && newlimit >= minlen) {
389  add_level(table, is16bit, num, numbits, buf,
390  code, l, newlimit, curlevel+1,
391  minlen, max, levelcnt, info);
392  }
393  }
394  }
395 }
396 
397 static int vlc_multi_gen(VLC_MULTI_ELEM *table, const VLC *single,
398  const int is16bit, const int nb_codes, const int numbits,
399  VLCcode *buf, void *logctx)
400 {
401  int minbits, maxbits, max;
402  unsigned count[VLC_MULTI_MAX_SYMBOLS-1] = { 0, };
403  VLC_MULTI_ELEM info = { { 0, }, 0, 0, };
404  int count0 = 0;
405 
406  for (int j = 0; j < 1<<numbits; j++) {
407  if (single->table[j].len > 0) {
408  count0 ++;
409  j += (1 << (numbits - single->table[j].len)) - 1;
410  }
411  }
412 
413  minbits = 32;
414  maxbits = 0;
415 
416  for (int n = nb_codes - count0; n < nb_codes; n++) {
417  minbits = FFMIN(minbits, buf[n].bits);
418  maxbits = FFMAX(maxbits, buf[n].bits);
419  }
420  av_assert0(maxbits <= numbits);
421 
422  for (max = nb_codes; max > nb_codes - count0; max--) {
423  // We can only add a code that fits with the shortest other code into the table
424  // We assume the table is sorted by bits and we skip subtables which from our
425  // point of view are basically random corrupted entries
426  // If we have not a single useable vlc we end with max = nb_codes
427  if (buf[max - 1].bits+minbits > numbits)
428  break;
429  }
430 
431  for (int j = 0; j < 1<<numbits; j++) {
432  table[j].len = single->table[j].len;
433  table[j].num = single->table[j].len > 0 ? 1 : 0;
434  AV_WN16(table[j].val, single->table[j].sym);
435  }
436 
437  add_level(table, is16bit, nb_codes, numbits, buf,
438  0, 0, FFMIN(maxbits, numbits), 0, minbits, max, count, info);
439 
440  av_log(logctx, AV_LOG_DEBUG, "Joint: %d/%d/%d/%d/%d codes min=%ubits max=%u\n",
441  count[0], count[1], count[2], count[3], count[4], minbits, max);
442 
443  return 0;
444 }
445 
446 int ff_vlc_init_multi_from_lengths(VLC *vlc, VLC_MULTI *multi, int nb_bits, int nb_elems,
447  int nb_codes, const int8_t *lens, int lens_wrap,
448  const void *symbols, int symbols_wrap, int symbols_size,
449  int offset, int flags, void *logctx)
450 {
451  VLCcode localbuf[LOCALBUF_ELEMS], *buf = localbuf;
452  uint64_t code;
453  int ret, j, len_max = FFMIN(32, 3 * nb_bits);
454 
455  ret = vlc_common_init(vlc, nb_bits, nb_codes, &buf, flags);
456  if (ret < 0)
457  return ret;
458 
459  multi->table = av_malloc(sizeof(*multi->table) << nb_bits);
460  if (!multi->table)
461  return AVERROR(ENOMEM);
462 
463  j = code = 0;
464  for (int i = 0; i < nb_codes; i++, lens += lens_wrap) {
465  int len = *lens;
466  if (len > 0) {
467  unsigned sym;
468 
469  buf[j].bits = len;
470  if (symbols)
471  GET_DATA(sym, symbols, i, symbols_wrap, symbols_size)
472  else
473  sym = i;
474  buf[j].symbol = sym + offset;
475  buf[j++].code = code;
476  } else if (len < 0) {
477  len = -len;
478  } else
479  continue;
480  if (len > len_max || code & ((1U << (32 - len)) - 1)) {
481  av_log(logctx, AV_LOG_ERROR, "Invalid VLC (length %u)\n", len);
482  goto fail;
483  }
484  code += 1U << (32 - len);
485  if (code > UINT32_MAX + 1ULL) {
486  av_log(logctx, AV_LOG_ERROR, "Overdetermined VLC tree\n");
487  goto fail;
488  }
489  }
490  ret = vlc_common_end(vlc, nb_bits, j, buf, flags, buf);
491  if (ret < 0)
492  goto fail;
493  ret = vlc_multi_gen(multi->table, vlc, nb_elems > 256, j, nb_bits, buf, logctx);
494  if (buf != localbuf)
495  av_free(buf);
496  return ret;
497 fail:
498  if (buf != localbuf)
499  av_free(buf);
500  ff_vlc_free_multi(multi);
501  return AVERROR_INVALIDDATA;
502 }
503 
505 {
506  av_freep(&vlc->table);
507 }
508 
509 void ff_vlc_free(VLC *vlc)
510 {
511  av_freep(&vlc->table);
512 }
VLCcode::symbol
VLCBaseType symbol
Definition: vlc.c:92
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()
Definition: vlc.c:306
AVERROR
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
vlc_common_init
static int vlc_common_init(VLC *vlc, int nb_bits, int nb_codes, VLCcode **buf, int flags)
Definition: vlc.c:98
VLC_MULTI_ELEM
Definition: vlc.h:39
b
#define b
Definition: input.c:41
ff_reverse
const uint8_t ff_reverse[256]
Definition: reverse.c:23
table
static const uint16_t table[]
Definition: prosumer.c:205
VLCElem::len
VLCBaseType len
Definition: vlc.h:30
reverse.h
max
#define max(a, b)
Definition: cuda_runtime.h:33
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:30
vlc_multi_gen
static int vlc_multi_gen(VLC_MULTI_ELEM *table, const VLC *single, const int is16bit, const int nb_codes, const int numbits, VLCcode *buf, void *logctx)
Definition: vlc.c:397
vlc_common_end
static int vlc_common_end(VLC *vlc, int nb_bits, int nb_codes, VLCcode *codes, int flags, VLCcode localbuf[LOCALBUF_ELEMS])
Definition: vlc.c:229
macros.h
fail
#define fail()
Definition: checkasm.h:138
VLCElem::sym
VLCBaseType sym
Definition: vlc.h:30
val
static double val(void *priv, double ch)
Definition: aeval.c:78
avassert.h
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
intreadwrite.h
VLC_MULTI
Definition: vlc.h:45
bitswap_32
static av_always_inline uint32_t bitswap_32(uint32_t x)
Definition: vlc.c:82
info
MIPS optimizations info
Definition: mips.txt:2
ff_vlc_free_multi
void ff_vlc_free_multi(VLC_MULTI *vlc)
Definition: vlc.c:504
bits
uint8_t bits
Definition: vp3data.h:128
LOCALBUF_ELEMS
#define LOCALBUF_ELEMS
Definition: vlc.c:80
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
build_table
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().
Definition: vlc.c:138
COPY
#define COPY(condition)
av_realloc_f
#define av_realloc_f(p, o, n)
Definition: tableprint_vlc.h:32
GET_DATA
#define GET_DATA(v, table, i, wrap, size)
Definition: vlc.c:41
NULL
#define NULL
Definition: coverity.c:32
AVERROR_PATCHWELCOME
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:64
AV_COPY64
#define AV_COPY64(d, s)
Definition: intreadwrite.h:603
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()
Definition: vlc.c:446
VLC_MULTI_MAX_SYMBOLS
#define VLC_MULTI_MAX_SYMBOLS
Definition: vlc.h:24
index
int index
Definition: gxfenc.c:89
error.h
VLCcode
Definition: vlc.c:90
ff_dlog
#define ff_dlog(a,...)
Definition: tableprint_vlc.h:28
VLC::table_allocated
int table_allocated
Definition: vlc.h:36
qsort.h
compare_vlcspec
static int compare_vlcspec(const void *a, const void *b)
Definition: vlc.c:118
size
int size
Definition: twinvq_data.h:10344
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
code_prefix
static const unsigned code_prefix[]
Definition: qdmc.c:79
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
attributes.h
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
log.h
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
code
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: filter_design.txt:178
AV_QSORT
#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...
Definition: qsort.h:33
internal.h
av_malloc_array
#define av_malloc_array(a, b)
Definition: tableprint_vlc.h:31
VLCcode::bits
uint8_t bits
Definition: vlc.c:91
av_always_inline
#define av_always_inline
Definition: attributes.h:49
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
VLCcode::code
uint32_t code
codeword, with the first bit-to-be-read in the msb (even if intended for a little-endian bitstream re...
Definition: vlc.c:95
len
int len
Definition: vorbis_enc_data.h:426
add_level
static void add_level(VLC_MULTI_ELEM *table, const int is16bit, const int num, const int numbits, const VLCcode *buf, uint32_t curcode, int curlen, int curlimit, int curlevel, const int minlen, const int max, unsigned *levelcnt, VLC_MULTI_ELEM info)
Definition: vlc.c:353
VLC::bits
int bits
Definition: vlc.h:34
ff_vlc_free
void ff_vlc_free(VLC *vlc)
Definition: vlc.c:509
ret
ret
Definition: filter_design.txt:187
U
#define U(x)
Definition: vpx_arith.h:37
VLC_MULTI::table
VLC_MULTI_ELEM * table
Definition: vlc.h:46
VLC_INIT_STATIC_OVERLONG
#define VLC_INIT_STATIC_OVERLONG
Definition: vlc.h:177
bits_size
#define bits_size
Definition: bitstream.h:113
VLC
Definition: vlc.h:33
alloc_table
static int alloc_table(VLC *vlc, int size, int use_static)
Definition: vlc.c:60
VLC::table
VLCElem * table
Definition: vlc.h:35
VLC::table_size
int table_size
Definition: vlc.h:36
mem.h
avpriv_request_sample
#define avpriv_request_sample(...)
Definition: tableprint_vlc.h:36
VLC_INIT_OUTPUT_LE
#define VLC_INIT_OUTPUT_LE
Definition: vlc.h:182
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
vlc.h
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
VLC_INIT_USE_STATIC
#define VLC_INIT_USE_STATIC
Definition: vlc.h:176
VLCBaseType
int16_t VLCBaseType
Definition: vlc.h:27
AV_WN16
#define AV_WN16(p, v)
Definition: intreadwrite.h:370