2 * Helpers for generating hard-coded VLC tables
4 * Copyright (c) 2014 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
6 * This file is part of FFmpeg.
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #ifndef AVCODEC_TABLEPRINT_VLC_H
24 #define AVCODEC_TABLEPRINT_VLC_H
26 #define FFMPEG_CONFIG_H
28 #define av_log(a, ...) while(0)
29 #define ff_dlog(a, ...) while(0)
31 #define av_malloc(s) NULL
32 #define av_malloc_array(a, b) NULL
33 #define av_realloc_f(p, o, n) NULL
34 #define av_free(p) while(0)
35 #define av_freep(p) while(0)
36 #define AVCODEC_AVCODEC_H
37 #define AVCODEC_INTERNAL_H
38 #define AV_INPUT_BUFFER_PADDING_SIZE 64 // the value does not matter for this
39 #include "tableprint.h"
41 #include "mathtables.c"
42 #include "libavutil/reverse.c"
43 #include "bitstream.c"
45 #define REPLACE_DEFINE2(type) write_##type##_array
46 #define REPLACE_DEFINE(type) REPLACE_DEFINE2(type)
47 static void write_VLC_TYPE_array(const VLC_TYPE *p, int s) {
48 REPLACE_DEFINE(VLC_TYPE)(p, s);
51 WRITE_2D_FUNC(VLC_TYPE)
53 static void write_vlc_type(const VLC *vlc, VLC_TYPE (*base_table)[2], const char *base_table_name)
55 printf(" .bits = %i,\n", vlc->bits);
56 // Unfortunately need to cast away const currently
57 printf(" .table = (VLC_TYPE (*)[2])(%s + 0x%x),\n", base_table_name, (int)(vlc->table - base_table));
58 printf(" .table_size = 0x%x,\n", vlc->table_size);
59 printf(" .table_allocated = 0x%x,\n", vlc->table_allocated);
62 #define WRITE_VLC_TYPE(prefix, name, base_table) \
64 printf(prefix" VLC "#name" = {\n"); \
65 write_vlc_type(&name, base_table, #base_table); \
69 #define WRITE_VLC_ARRAY(prefix, name, base_table) \
72 const size_t array_size = FF_ARRAY_ELEMS(name); \
73 printf(prefix" VLC "#name"[%"FMT"] = {{\n", \
75 for (i = 0; i < array_size; i++) { \
76 write_vlc_type(name + i, \
77 base_table, #base_table); \
78 if (i != array_size - 1) printf("}, {\n"); \
83 #endif /* AVCODEC_TABLEPRINT_VLC_H */