2 * This file is part of FFmpeg.
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 #define VLC_TYPE int16_t
28 VLC_TYPE (*table)[2]; ///< code, bits
29 int table_size, table_allocated;
32 typedef struct RL_VLC_ELEM {
38 #define INIT_VLC_DEFAULT_SIZES(ptr) \
39 (ptr), sizeof((ptr)[0]), sizeof((ptr)[0])
41 #define init_vlc(...) init_vlc2(__VA_ARGS__)
43 #define init_vlc2(vlc, nb_bits, nb_codes, \
44 bits, bits_wrap, bits_size, \
45 codes, codes_wrap, codes_size, \
47 ff_init_vlc_sparse(vlc, nb_bits, nb_codes, \
48 bits, bits_wrap, bits_size, \
49 codes, codes_wrap, codes_size, \
52 int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
53 const void *bits, int bits_wrap, int bits_size,
54 const void *codes, int codes_wrap, int codes_size,
55 const void *symbols, int symbols_wrap, int symbols_size,
57 void ff_free_vlc(VLC *vlc);
60 #define INIT_VLC_USE_NEW_STATIC 4
62 #define INIT_VLC_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, h, i, j, static_size) \
64 static VLC_TYPE table[static_size][2]; \
65 (vlc)->table = table; \
66 (vlc)->table_allocated = static_size; \
67 ff_init_vlc_sparse(vlc, bits, a, b, c, d, e, f, g, h, i, j, \
68 INIT_VLC_USE_NEW_STATIC); \
71 #define INIT_LE_VLC_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, h, i, j, static_size) \
73 static VLC_TYPE table[static_size][2]; \
74 (vlc)->table = table; \
75 (vlc)->table_allocated = static_size; \
76 ff_init_vlc_sparse(vlc, bits, a, b, c, d, e, f, g, h, i, j, \
77 INIT_VLC_USE_NEW_STATIC | INIT_VLC_LE); \
80 #define INIT_VLC_STATIC(vlc, bits, a, b, c, d, e, f, g, static_size) \
81 INIT_VLC_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, NULL, 0, 0, static_size)
83 #define INIT_LE_VLC_STATIC(vlc, bits, a, b, c, d, e, f, g, static_size) \
84 INIT_LE_VLC_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, NULL, 0, 0, static_size)
86 #endif /* AVCODEC_VLC_H */