Go to the documentation of this file.
40 0, 0, 0, 0, 1, 1, 1, 1,
41 2, 2, 2, 2, 3, 3, 3, 3,
42 4, 4, 5, 5, 6, 6, 7, 7,
43 8, 9,10,11,12,13,14,15,
44 16,17,18,19,20,21,22,23,
66 int words = length >> 4;
67 int bits = length & 15;
76 for (
i = 0;
i < words;
i++)
91 #define GET_DATA(v, table, i, wrap, size) \
93 const uint8_t *ptr = (const uint8_t *)table + i * wrap; \
96 v = *(const uint8_t *)ptr; \
99 v = *(const uint16_t *)ptr; \
102 v = *(const uint32_t *)ptr; \
141 return (sa->
code >> 1) - (sb->code >> 1);
161 int i, j, k, n, nb, inc;
165 if (table_nb_bits > 30)
167 table_size = 1 << table_nb_bits;
169 ff_dlog(
NULL,
"new table index=%d size=%d\n", table_index, table_size);
175 for (
i = 0;
i < nb_codes;
i++) {
180 if (n <= table_nb_bits) {
182 j =
code >> (32 - table_nb_bits);
183 nb = 1 << (table_nb_bits - n);
189 for (k = 0; k < nb; k++) {
191 int oldsym =
table[j][0];
193 if ((
bits || oldsym) && (
bits != n || oldsym != symbol)) {
198 table[j][0] = symbol;
208 for (k =
i+1; k < nb_codes; k++) {
209 n = codes[k].
bits - table_nb_bits;
216 codes[k].
code =
code << table_nb_bits;
217 subtable_bits =
FFMAX(subtable_bits, n);
219 subtable_bits =
FFMIN(subtable_bits, table_nb_bits);
221 table[j][1] = -subtable_bits;
223 j, codes[
i].
bits + table_nb_bits);
238 for (
i = 0;
i < table_size;
i++) {
274 const void *
bits,
int bits_wrap,
int bits_size,
275 const void *codes,
int codes_wrap,
int codes_size,
276 const void *symbols,
int symbols_wrap,
int symbols_size,
305 #define COPY(condition)\
306 for (i = 0; i < nb_codes; i++) { \
307 GET_DATA(buf[j].bits, bits, i, bits_wrap, bits_size); \
310 if (buf[j].bits > 3*nb_bits || buf[j].bits>32) { \
311 av_log(NULL, AV_LOG_ERROR, "Too long VLC (%d) in init_vlc\n", buf[j].bits);\
312 if (!(flags & INIT_VLC_USE_NEW_STATIC)) \
314 return AVERROR(EINVAL); \
316 GET_DATA(buf[j].code, codes, i, codes_wrap, codes_size); \
317 if (buf[j].code >= (1LL<<buf[j].bits)) { \
318 av_log(NULL, AV_LOG_ERROR, "Invalid code %"PRIx32" for %d in " \
319 "init_vlc\n", buf[j].code, i); \
320 if (!(flags & INIT_VLC_USE_NEW_STATIC)) \
322 return AVERROR(EINVAL); \
324 if (flags & INIT_VLC_LE) \
325 buf[j].code = bitswap_32(buf[j].code); \
327 buf[j].code <<= 32 - buf[j].bits; \
329 GET_DATA(buf[j].symbol, symbols, i, symbols_wrap, symbols_size) \
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().
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
static av_always_inline uint32_t bitswap_32(uint32_t x)
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
void avpriv_put_string(PutBitContext *pb, const char *string, int terminate_string)
Put the string string in the bitstream.
static const uint16_t table[]
static int put_bits_left(PutBitContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
void ff_free_vlc(VLC *vlc)
#define av_realloc_f(p, o, n)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
const uint8_t ff_log2_run[41]
#define INIT_VLC_USE_NEW_STATIC
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 avpriv_copy_bits(PutBitContext *pb, const uint8_t *src, int length)
Copy the content of src to the bitstream.
void avpriv_align_put_bits(PutBitContext *s)
Pad the bitstream with zeros up to the next byte boundary.
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[]
#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
static int put_bits_count(PutBitContext *s)
#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...
#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...
static int alloc_table(VLC *vlc, int size, int use_static)
#define FF_ARRAY_ELEMS(a)
static uint8_t * put_bits_ptr(PutBitContext *s)
Return the pointer to the byte where the bitstream writer will put the next bit.
static void skip_put_bytes(PutBitContext *s, int n)
Skip the given number of bytes.
#define avpriv_request_sample(...)
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
static int compare_vlcspec(const void *a, const void *b)
#define flags(name, subs,...)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
VLC_TYPE(* table)[2]
code, bits
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16