aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>2010-04-01 17:11:47 +0000
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>2010-04-01 17:11:47 +0000
commit8eaa6e0e04c3c340d7c44a97613ebc6dbcc0a51d (patch)
tree6b40a6af3963c4f53e90e1e9a6dbbd05eb98ca3e /libavcodec
parent27eecec3598b0c35b7aeb10c08f2c5e42b1fdd4f (diff)
downloadffmpeg-8eaa6e0e04c3c340d7c44a97613ebc6dbcc0a51d.tar.gz
Change/simplify the tableprint/tablegen API.
Originally committed as revision 22761 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/cbrt_tablegen.c21
-rw-r--r--libavcodec/dv_tablegen.c21
-rw-r--r--libavcodec/mdct_tablegen.c33
-rw-r--r--libavcodec/motionpixels_tablegen.c21
-rw-r--r--libavcodec/mpegaudio_tablegen.c51
-rw-r--r--libavcodec/qdm2_tablegen.c65
-rw-r--r--libavcodec/tableprint.c13
-rw-r--r--libavcodec/tableprint.h36
8 files changed, 94 insertions, 167 deletions
diff --git a/libavcodec/cbrt_tablegen.c b/libavcodec/cbrt_tablegen.c
index 9a0ffcfa1a..dbbd632693 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 4294132cf2..0e2b39dfb2 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 a6b13c345b..6205f06e3c 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 188384b5a3..5f1220aff5 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 9f832a3b0e..70d145b205 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 d23493c741..c225bc4391 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 2d8cc419e4..e39606bb15 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 e91ba1ec32..d81af97e95 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 */