History

Add some documentation about the table generation code.

Originally committed as revision 22722 to svn://svn.ffmpeg.org/ffmpeg/trunk

Reimar Döffinger committed 16 years ago

Commit 4f798a61 parent 5b9c11f1 file · +57 −0Browse files

Unified · Split

doc/tablegen.txt+57−0
@@ -0,0 +1,57 @@
1Writing a table generator
2
3This documentation is preliminary.
4Parts of the API are not good and should be changed.
5
6Basic concepts
7
8A table generator consists of two files, *_tablegen.c and *_tablegen.h.
9The .h file will provide the variable declarations and initialization
10code for the tables, the .c describes the tables so they can be printed
11as a header file.
12Both of these files will be compiled for the host system, so to avoid
13breakage with cross-compilation neither of them may include, directly
14or indirectly, config.h or avconfig.h.
15Due to this, the .c file or Makefile may have to provide additional defines
16or stubs, though if possible this should be avoided.
17
18The .c file
19
20This file should include the *_tablegen.h and tableprint.h files and
21anything else it needs as long as it does not depend on config.h or
22avconfig.h.
23In addition to that it must contain a void tableinit(void) function
24which initializes all tables by calling the init functions from the .h
25file.
26It must also contain a "const struct tabledef tables[]" array describing
27the tables to be generated.
28Its entries consist of (in order):
29 - a string suitable for declaring the table, up to but not including the =
30 NULL terminates the table
31 - a function to print the table - tableprint.h defines some defaults,
32 e.g. write_uint8_array to print a uint8_t array.
33 - a pointer to the table
34 - the size of the first dimension of the array
35 - if applicable, the size of the second dimension of the array
36
37The .h file
38
39This file should contain:
40 - one or more initialization functions
41 - the table variable declarations
42If CONFIG_HARDCODED_TABLES is set, the initialization functions should
43not do anything, and instead of the variable declarations the
44generated *_tables.h file should be included.
45Since that will be generated in the build directory, the path must be
46included, i.e.
47#include "libavcodec/example_tables.h"
48not
49#include "example_tables.h"
50
51Makefile changes
52
53To make the automatic table creation work, you must manually declare the
54new dependency.
55For this add a line similar to this:
56$(SUBDIR)example.o: $(SUBDIR)example_tables.h
57under the "ifdef CONFIG_HARDCODED_TABLES" section in the Makefile.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t