diff --git a/doc/tablegen.txt b/doc/tablegen.txt
index 203f4477b9ca8744b6713db5effe9b9042712599..8dfcd7d354d7cad9cea1b8b5bad2abbebc82c37b 100644
--- a/doc/tablegen.txt
+++ b/doc/tablegen.txt
@@ -7,32 +7,39 @@ Basic concepts
 
 A table generator consists of two files, *_tablegen.c and *_tablegen.h.
 The .h file will provide the variable declarations and initialization
-code for the tables, the .c describes the tables so they can be printed
-as a header file.
+code for the tables, the .c calls the initialization code and then prints
+the tables as a header file using the tableprint.h helpers.
 Both of these files will be compiled for the host system, so to avoid
 breakage with cross-compilation neither of them may include, directly
 or indirectly, config.h or avconfig.h.
 Due to this, the .c file or Makefile may have to provide additional defines
 or stubs, though if possible this should be avoided.
+In particular, CONFIG_HARDCODED_TABLES should always be defined to 0.
 
 The .c file
 
 This file should include the *_tablegen.h and tableprint.h files and
 anything else it needs as long as it does not depend on config.h or
 avconfig.h.
-In addition to that it must contain a void tableinit(void) function
-which initializes all tables by calling the init functions from the .h
-file.
-It must also contain a "const struct tabledef tables[]" array describing
-the tables to be generated.
-Its entries consist of (in order):
- - a string suitable for declaring the table, up to but not including the =
-   NULL terminates the table
- - a function to print the table - tableprint.h defines some defaults,
-   e.g. write_uint8_array to print a uint8_t array.
- - a pointer to the table
- - the size of the first dimension of the array
- - if applicable, the size of the second dimension of the array
+In addition to that it must contain a main() function which initializes
+all tables by calling the init functions from the .h file and then prints
+them.
+The printing code typically looks like this:
+    write_fileheader();
+    printf("static const uint8_t my_array[100] = {\n");
+    write_uint8_array(my_array, 100);
+    printf("};\n");
+
+write_fileheader() adds some minor things like a "this is a generated file"
+comment and some standard includes.
+tablegen.h defines some write functions for one- and two-dimensional arrays
+for standard types - they print only the "core" parts so they are easier
+to reuse for multi-dimensional arrays so the outermost {} must be printed
+separately.
+If there's no standard function for printing the type you need, the
+WRITE_1D_FUNC_ARGV macro is a very quick way to create one.
+See libavcodec/dv_tablegen.c for an example.
+
 
 The .h file
 
diff --git a/libavcodec/cbrt_tablegen.c b/libavcodec/cbrt_tablegen.c
index 9a0ffcfa1a64af3f64ad76c18b4c76aee8d91e32..dbbd632693d3cb9c22ce3e9ee505290b69be82fa 100644
--- a/libavcodec/cbrt_tablegen.c
+++ b/libavcodec/cbrt_tablegen.c
@@ -25,18 +25,15 @@
 #include "cbrt_tablegen.h"
 #include "tableprint.h"
 
-void tableinit(void)
+int main(void)
 {
     cbrt_tableinit();
-}
 
-const struct tabledef tables[] = {
-    {
-        "static const uint32_t cbrt_tab[1<<13]",
-        write_uint32_array,
-        cbrt_tab,
-        1 << 13,
-        0
-    },
-    { NULL }
-};
+    write_fileheader();
+
+    printf("static const uint32_t cbrt_tab[1<<13] = {\n");
+    write_uint32_array(cbrt_tab, 1 << 13);
+    printf("};\n");
+
+    return 0;
+}
diff --git a/libavcodec/dv_tablegen.c b/libavcodec/dv_tablegen.c
index 4294132cf28a773c3d9554b6099b38086266fe50..0e2b39dfb2ccbd09a392311cda00638dfe0a22dc 100644
--- a/libavcodec/dv_tablegen.c
+++ b/libavcodec/dv_tablegen.c
@@ -33,18 +33,15 @@ WRITE_1D_FUNC_ARGV(vlc_pair, struct dv_vlc_pair, 7,
                    "{0x%"PRIx32", %"PRId8"}", data[i].vlc, data[i].size)
 WRITE_2D_FUNC(vlc_pair, struct dv_vlc_pair)
 
-void tableinit(void)
+int main(void)
 {
     dv_vlc_map_tableinit();
-}
 
-const struct tabledef tables[] = {
-    {
-        "static const struct dv_vlc_pair dv_vlc_map[DV_VLC_MAP_RUN_SIZE][DV_VLC_MAP_LEV_SIZE]",
-        write_vlc_pair_2d_array,
-        dv_vlc_map,
-        DV_VLC_MAP_RUN_SIZE,
-        DV_VLC_MAP_LEV_SIZE
-    },
-    { NULL }
-};
+    write_fileheader();
+
+    printf("static const struct dv_vlc_pair dv_vlc_map[DV_VLC_MAP_RUN_SIZE][DV_VLC_MAP_LEV_SIZE] = {\n");
+    write_vlc_pair_2d_array(dv_vlc_map, DV_VLC_MAP_RUN_SIZE, DV_VLC_MAP_LEV_SIZE);
+    printf("};\n");
+
+    return 0;
+}
diff --git a/libavcodec/mdct_tablegen.c b/libavcodec/mdct_tablegen.c
index a6b13c345b7dcb630242d20e95823ae2eeda51fb..6205f06e3c49f22c1d7434df3df58950816d3b5f 100644
--- a/libavcodec/mdct_tablegen.c
+++ b/libavcodec/mdct_tablegen.c
@@ -32,29 +32,18 @@
 #include "mdct_tablegen.h"
 #include "tableprint.h"
 
-void tableinit(void)
+int main(void)
 {
     int i;
-    for (i = 5; i <= 12; i++)
-        ff_init_ff_sine_windows(i);
-}
 
-#define SINE_TABLE_DEF(size) \
-    { \
-        "SINETABLE("#size")", \
-        write_float_array, \
-        ff_sine_##size, \
-        size \
-    },
+    write_fileheader();
 
-const struct tabledef tables[] = {
-    SINE_TABLE_DEF(  32)
-    SINE_TABLE_DEF(  64)
-    SINE_TABLE_DEF( 128)
-    SINE_TABLE_DEF( 256)
-    SINE_TABLE_DEF( 512)
-    SINE_TABLE_DEF(1024)
-    SINE_TABLE_DEF(2048)
-    SINE_TABLE_DEF(4096)
-    { NULL }
-};
+    for (i = 5; i <= 12; i++) {
+        ff_init_ff_sine_windows(i);
+        printf("SINETABLE(%4i) = {\n", 1 << i);
+        write_float_array(ff_sine_windows[i], 1 << i);
+        printf("};\n");
+    }
+
+    return 0;
+}
diff --git a/libavcodec/motionpixels_tablegen.c b/libavcodec/motionpixels_tablegen.c
index 188384b5a3901843063775297d6fde7be81237f8..5f1220aff5d36c7de7aa5449ce8b1e2859b701e0 100644
--- a/libavcodec/motionpixels_tablegen.c
+++ b/libavcodec/motionpixels_tablegen.c
@@ -27,18 +27,15 @@
 #include "motionpixels_tablegen.h"
 #include "tableprint.h"
 
-void tableinit(void)
+int main(void)
 {
     motionpixels_tableinit();
-}
 
-const struct tabledef tables[] = {
-    {
-        "static const YuvPixel mp_rgb_yuv_table[1 << 15]",
-        write_int8_2d_array,
-        mp_rgb_yuv_table,
-        1 << 15,
-        3
-    },
-    { NULL }
-};
+    write_fileheader();
+
+    printf("static const YuvPixel mp_rgb_yuv_table[1 << 15] = {\n");
+    write_int8_2d_array(mp_rgb_yuv_table, 1 << 15, 3);
+    printf("};\n");
+
+    return 0;
+}
diff --git a/libavcodec/mpegaudio_tablegen.c b/libavcodec/mpegaudio_tablegen.c
index 9f832a3b0e45c229623ed04bb08eebec520b4157..70d145b20545b3af030ccc0e66579aa1b9ee4eb3 100644
--- a/libavcodec/mpegaudio_tablegen.c
+++ b/libavcodec/mpegaudio_tablegen.c
@@ -25,36 +25,27 @@
 #include "mpegaudio_tablegen.h"
 #include "tableprint.h"
 
-void tableinit(void)
+int main(void)
 {
     mpegaudio_tableinit();
-}
 
-const struct tabledef tables[] = {
-    {
-        "static const int8_t table_4_3_exp[TABLE_4_3_SIZE]",
-        write_int8_array,
-        table_4_3_exp,
-        TABLE_4_3_SIZE
-    },
-    {
-        "static const uint32_t table_4_3_value[TABLE_4_3_SIZE]",
-        write_uint32_array,
-        table_4_3_value,
-        TABLE_4_3_SIZE
-    },
-    {
-        "static const uint32_t exp_table[512]",
-        write_uint32_array,
-        exp_table,
-        512
-    },
-    {
-        "static const uint32_t expval_table[512][16]",
-        write_uint32_2d_array,
-        expval_table,
-        512,
-        16
-    },
-    { NULL }
-};
+    write_fileheader();
+
+    printf("static const int8_t table_4_3_exp[TABLE_4_3_SIZE] = {\n");
+    write_int8_array(table_4_3_exp, TABLE_4_3_SIZE);
+    printf("};\n");
+
+    printf("static const uint32_t table_4_3_value[TABLE_4_3_SIZE] = {\n");
+    write_uint32_array(table_4_3_value, TABLE_4_3_SIZE);
+    printf("};\n");
+
+    printf("static const uint32_t exp_table[512] = {\n");
+    write_uint32_array(exp_table, 512);
+    printf("};\n");
+
+    printf("static const uint32_t expval_table[512][16] = {\n");
+    write_uint32_2d_array(expval_table, 512, 16);
+    printf("};\n");
+
+    return 0;
+}
diff --git a/libavcodec/qdm2_tablegen.c b/libavcodec/qdm2_tablegen.c
index d23493c7418068ea6b78b198aa893e1501c72ff5..c225bc439169e8227c7555ae71052f9be4d95ca4 100644
--- a/libavcodec/qdm2_tablegen.c
+++ b/libavcodec/qdm2_tablegen.c
@@ -25,48 +25,33 @@
 #include "qdm2_tablegen.h"
 #include "tableprint.h"
 
-void tableinit(void)
+int main(void)
 {
     softclip_table_init();
     rnd_table_init();
     init_noise_samples();
-}
 
-const struct tabledef tables[] = {
-    {
-        "static const uint16_t softclip_table[HARDCLIP_THRESHOLD - SOFTCLIP_THRESHOLD + 1]",
-        write_uint16_array,
-        softclip_table,
-        HARDCLIP_THRESHOLD - SOFTCLIP_THRESHOLD + 1,
-        0
-    },
-    {
-        "static const float noise_table[4096]",
-        write_float_array,
-        noise_table,
-        4096,
-        0
-    },
-    {
-        "static const uint8_t random_dequant_index[256][5]",
-        write_uint8_2d_array,
-        random_dequant_index,
-        256,
-        5
-    },
-    {
-        "static const uint8_t random_dequant_type24[128][3]",
-        write_uint8_2d_array,
-        random_dequant_type24,
-        128,
-        3
-    },
-    {
-        "static const float noise_samples[128]",
-        write_float_array,
-        noise_samples,
-        128,
-        0
-    },
-    { NULL }
-};
+    write_fileheader();
+
+    printf("static const uint16_t softclip_table[HARDCLIP_THRESHOLD - SOFTCLIP_THRESHOLD + 1] = {\n");
+    write_uint16_array(softclip_table, HARDCLIP_THRESHOLD - SOFTCLIP_THRESHOLD + 1);
+    printf("};\n");
+
+    printf("static const float noise_table[4096] = {\n");
+    write_float_array(noise_table, 4096);
+    printf("};\n");
+
+    printf("static const uint8_t random_dequant_index[256][5] = {\n");
+    write_uint8_2d_array(random_dequant_index, 256, 5);
+    printf("};\n");
+
+    printf("static const uint8_t random_dequant_type24[128][3] = {\n");
+    write_uint8_2d_array(random_dequant_type24, 128, 3);
+    printf("};\n");
+
+    printf("static const float noise_samples[128] = {\n");
+    write_float_array(noise_samples, 128);
+    printf("};\n");
+
+    return 0;
+}
diff --git a/libavcodec/tableprint.c b/libavcodec/tableprint.c
index 2d8cc419e47c1215fe9deb357246503d2512d0ca..e39606bb1590f06014be999eaf4f6ce8c3b9170e 100644
--- a/libavcodec/tableprint.c
+++ b/libavcodec/tableprint.c
@@ -34,18 +34,7 @@ WRITE_2D_FUNC(int8,   int8_t)
 WRITE_2D_FUNC(uint8,  uint8_t)
 WRITE_2D_FUNC(uint32, uint32_t)
 
-int main(int argc, char *argv[])
-{
-    int i;
-
+void write_fileheader(void) {
     printf("/* This file was generated by libavcodec/tableprint */\n");
     printf("#include <stdint.h>\n");
-    tableinit();
-
-    for (i = 0; tables[i].declaration; i++) {
-        printf("%s = {\n", tables[i].declaration);
-        tables[i].printfunc(tables[i].data, tables[i].size, tables[i].size2);
-        printf("};\n");
-    }
-    return 0;
 }
diff --git a/libavcodec/tableprint.h b/libavcodec/tableprint.h
index e91ba1ec324d9057ff8c2f167a882c1681d6766d..d81af97e95b3bb8117db40f4605dee5706c10035 100644
--- a/libavcodec/tableprint.h
+++ b/libavcodec/tableprint.h
@@ -27,9 +27,8 @@
 #include <stdio.h>
 
 #define WRITE_1D_FUNC_ARGV(name, type, linebrk, fmtstr, ...)\
-void write_##name##_array(const void *arg, int len, int dummy)\
+void write_##name##_array(const type *data, int len)\
 {\
-    const type *data = arg;\
     int i;\
     printf("   ");\
     for (i = 0; i < len - 1; i++) {\
@@ -49,7 +48,7 @@ void write_##name##_2d_array(const void *arg, int len, int len2)\
     int i;\
     printf("    {\n");\
     for (i = 0; i < len; i++) {\
-        write_##name##_array(data + i * len2, len2, 0);\
+        write_##name##_array(data + i * len2, len2);\
         printf(i == len - 1 ? "    }\n" : "    }, {\n");\
     }\
 }
@@ -59,34 +58,17 @@ void write_##name##_2d_array(const void *arg, int len, int len2)\
  *
  * \{
  */
-void write_int8_array     (const void *, int, int);
-void write_uint8_array    (const void *, int, int);
-void write_uint16_array   (const void *, int, int);
-void write_uint32_array   (const void *, int, int);
-void write_float_array    (const void *, int, int);
+void write_int8_array     (const int8_t   *, int);
+void write_uint8_array    (const uint8_t  *, int);
+void write_uint16_array   (const uint16_t *, int);
+void write_uint32_array   (const uint32_t *, int);
+void write_float_array    (const float    *, int);
 void write_int8_2d_array  (const void *, int, int);
 void write_uint8_2d_array (const void *, int, int);
 void write_uint32_2d_array(const void *, int, int);
 /** \} */ // end of printfuncs group
 
-struct tabledef {
-    /** String that declares the array. Adding " = { ..." after it should
-     * make a valid initializer, adding "extern" before and ";" if possible
-     * should make a valid extern declaration. */
-    const char *declaration;
-    /** Function used to print the table data (i.e. the part in {}).
-     * Should be one of the predefined write_*_array functions. */
-    void (*printfunc)(const void *, int, int);
-    /** Pointer passed to the printfunc, usually a pointer to the start
-     * of the array to be printed. */
-    const void *data;
-    int size;   ///< size of the first dimension of the array
-    int size2;  ///< size of the second dimension of the array if any
-};
-
-/** Initializes all the tables described in the tables array */
-void tableinit(void);
-/** Describes the tables that should be printed */
-extern const struct tabledef tables[];
+/** Write a standard file header */
+void write_fileheader(void);
 
 #endif /* AVCODEC_TABLEPRINT_H */