FFmpeg
tableprint_vlc.h
Go to the documentation of this file.
1 /*
2  * Helpers for generating hard-coded VLC tables
3  *
4  * Copyright (c) 2014 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
5  *
6  * This file is part of FFmpeg.
7  *
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.
12  *
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.
17  *
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
21  */
22 
23 #ifndef AVCODEC_TABLEPRINT_VLC_H
24 #define AVCODEC_TABLEPRINT_VLC_H
25 
26 #define FFMPEG_CONFIG_H
27 #define AVUTIL_LOG_H
28 #define av_log(a, ...) while(0)
29 #define ff_dlog(a, ...) while(0)
30 #define AVUTIL_MEM_H
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 #define avpriv_request_sample(...)
40 #include "tableprint.h"
41 #include "get_bits.h"
42 #include "mathtables.c"
43 #include "libavutil/reverse.c"
44 #include "bitstream.c"
45 
46 #define REPLACE_DEFINE2(type) write_##type##_array
47 #define REPLACE_DEFINE(type) REPLACE_DEFINE2(type)
48 static void write_VLC_TYPE_array(const VLC_TYPE *p, int s) {
50 }
51 
53 
54 static void write_vlc_type(const VLC *vlc, VLC_TYPE (*base_table)[2], const char *base_table_name)
55 {
56  printf(" .bits = %i,\n", vlc->bits);
57  // Unfortunately need to cast away const currently
58  printf(" .table = (VLC_TYPE (*)[2])(%s + 0x%x),\n", base_table_name, (int)(vlc->table - base_table));
59  printf(" .table_size = 0x%x,\n", vlc->table_size);
60  printf(" .table_allocated = 0x%x,\n", vlc->table_allocated);
61 }
62 
63 #define WRITE_VLC_TYPE(prefix, name, base_table) \
64  do { \
65  printf(prefix" VLC "#name" = {\n"); \
66  write_vlc_type(&name, base_table, #base_table); \
67  printf("};\n"); \
68  } while(0)
69 
70 #define WRITE_VLC_ARRAY(prefix, name, base_table) \
71  do { \
72  int i; \
73  const size_t array_size = FF_ARRAY_ELEMS(name); \
74  printf(prefix" VLC "#name"[%"FMT"] = {{\n", \
75  array_size); \
76  for (i = 0; i < array_size; i++) { \
77  write_vlc_type(name + i, \
78  base_table, #base_table); \
79  if (i != array_size - 1) printf("}, {\n"); \
80  } \
81  printf("}};\n"); \
82  } while(0)
83 
84 #endif /* AVCODEC_TABLEPRINT_VLC_H */
tableprint.h
REPLACE_DEFINE
#define REPLACE_DEFINE(type)
Definition: tableprint_vlc.h:47
VLC_TYPE
#define VLC_TYPE
Definition: vlc.h:24
s
#define s(width, name)
Definition: cbs_vp9.c:257
get_bits.h
write_VLC_TYPE_array
static void write_VLC_TYPE_array(const VLC_TYPE *p, int s)
Definition: tableprint_vlc.h:48
mathtables.c
printf
printf("static const uint8_t my_array[100] = {\n")
write_vlc_type
static void write_vlc_type(const VLC *vlc, VLC_TYPE(*base_table)[2], const char *base_table_name)
Definition: tableprint_vlc.h:54
bitstream.c
reverse.c
VLC
Definition: vlc.h:26
WRITE_2D_FUNC
#define WRITE_2D_FUNC(type)
Definition: tableprint.h:46