[FFmpeg-devel] [PATCH 1/2] tableprint: use the type name as-is for the functions' names.

Diego Elio 'Flameeyes' Pettenò flameeyes
Sun Jun 27 02:40:52 CEST 2010


This drops one parameter from the functions' macros, and require structures
to be typedeffed, but ensures that it is possible to map 1-to-1 the type to
the function name.
---
 libavcodec/cbrt_tablegen.c         |    2 +-
 libavcodec/dv_tablegen.c           |    6 +++---
 libavcodec/dv_tablegen.h           |    4 ++--
 libavcodec/motionpixels_tablegen.c |    2 +-
 libavcodec/mpegaudio_tablegen.c    |    8 ++++----
 libavcodec/pcm_tablegen.c          |    4 ++--
 libavcodec/qdm2_tablegen.c         |    6 +++---
 libavcodec/tableprint.c            |   18 +++++++++---------
 libavcodec/tableprint.h            |   32 ++++++++++++++++----------------
 9 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/libavcodec/cbrt_tablegen.c b/libavcodec/cbrt_tablegen.c
index dbbd632..5cbceb2 100644
--- a/libavcodec/cbrt_tablegen.c
+++ b/libavcodec/cbrt_tablegen.c
@@ -32,7 +32,7 @@ int main(void)
     write_fileheader();
 
     printf("static const uint32_t cbrt_tab[1<<13] = {\n");
-    write_uint32_array(cbrt_tab, 1 << 13);
+    write_uint32_t_array(cbrt_tab, 1 << 13);
     printf("};\n");
 
     return 0;
diff --git a/libavcodec/dv_tablegen.c b/libavcodec/dv_tablegen.c
index 0e2b39d..5d3793e 100644
--- a/libavcodec/dv_tablegen.c
+++ b/libavcodec/dv_tablegen.c
@@ -29,9 +29,9 @@
 #include "tableprint.h"
 #include <inttypes.h>
 
-WRITE_1D_FUNC_ARGV(vlc_pair, struct dv_vlc_pair, 7,
+WRITE_1D_FUNC_ARGV(dv_vlc_pair, 7,
                    "{0x%"PRIx32", %"PRId8"}", data[i].vlc, data[i].size)
-WRITE_2D_FUNC(vlc_pair, struct dv_vlc_pair)
+WRITE_2D_FUNC(dv_vlc_pair)
 
 int main(void)
 {
@@ -40,7 +40,7 @@ int main(void)
     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);
+    write_dv_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/dv_tablegen.h b/libavcodec/dv_tablegen.h
index ee6e822..47e8c36 100644
--- a/libavcodec/dv_tablegen.h
+++ b/libavcodec/dv_tablegen.h
@@ -35,10 +35,10 @@
 #endif
 
 /* VLC encoding lookup table */
-struct dv_vlc_pair {
+typedef struct dv_vlc_pair {
    uint32_t vlc;
    uint32_t size;
-};
+} dv_vlc_pair;
 
 #if CONFIG_HARDCODED_TABLES
 #define dv_vlc_map_tableinit()
diff --git a/libavcodec/motionpixels_tablegen.c b/libavcodec/motionpixels_tablegen.c
index 5f1220a..31e5cdf 100644
--- a/libavcodec/motionpixels_tablegen.c
+++ b/libavcodec/motionpixels_tablegen.c
@@ -34,7 +34,7 @@ int main(void)
     write_fileheader();
 
     printf("static const YuvPixel mp_rgb_yuv_table[1 << 15] = {\n");
-    write_int8_2d_array(mp_rgb_yuv_table, 1 << 15, 3);
+    write_int8_t_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 bb1c7ea..57e239c 100644
--- a/libavcodec/mpegaudio_tablegen.c
+++ b/libavcodec/mpegaudio_tablegen.c
@@ -32,15 +32,15 @@ int main(void)
     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);
+    write_int8_t_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);
+    write_uint32_t_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);
+    write_uint32_t_array(exp_table, 512);
     printf("};\n");
 
     printf("static const float exp_table_float[512] = {\n");
@@ -48,7 +48,7 @@ int main(void)
     printf("};\n");
 
     printf("static const uint32_t expval_table[512][16] = {\n");
-    write_uint32_2d_array(expval_table, 512, 16);
+    write_uint32_t_2d_array(expval_table, 512, 16);
     printf("};\n");
 
     printf("static const float expval_table_float[512][16] = {\n");
diff --git a/libavcodec/pcm_tablegen.c b/libavcodec/pcm_tablegen.c
index 57ecb43..13b33dd 100644
--- a/libavcodec/pcm_tablegen.c
+++ b/libavcodec/pcm_tablegen.c
@@ -33,11 +33,11 @@ int main(void)
     write_fileheader();
 
     printf("static const uint8_t linear_to_alaw[1 << 14] = {\n");
-    write_uint8_array(linear_to_alaw, 1 << 14);
+    write_uint8_t_array(linear_to_alaw, 1 << 14);
     printf("};\n");
 
     printf("static const uint8_t linear_to_ulaw[1 << 14] = {\n");
-    write_uint8_array(linear_to_ulaw, 1 << 14);
+    write_uint8_t_array(linear_to_ulaw, 1 << 14);
     printf("};\n");
 
     return 0;
diff --git a/libavcodec/qdm2_tablegen.c b/libavcodec/qdm2_tablegen.c
index c225bc4..d11599b 100644
--- a/libavcodec/qdm2_tablegen.c
+++ b/libavcodec/qdm2_tablegen.c
@@ -34,7 +34,7 @@ int main(void)
     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);
+    write_uint16_t_array(softclip_table, HARDCLIP_THRESHOLD - SOFTCLIP_THRESHOLD + 1);
     printf("};\n");
 
     printf("static const float noise_table[4096] = {\n");
@@ -42,11 +42,11 @@ int main(void)
     printf("};\n");
 
     printf("static const uint8_t random_dequant_index[256][5] = {\n");
-    write_uint8_2d_array(random_dequant_index, 256, 5);
+    write_uint8_t_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);
+    write_uint8_t_2d_array(random_dequant_type24, 128, 3);
     printf("};\n");
 
     printf("static const float noise_samples[128] = {\n");
diff --git a/libavcodec/tableprint.c b/libavcodec/tableprint.c
index 0f422eb..52f6ac2 100644
--- a/libavcodec/tableprint.c
+++ b/libavcodec/tableprint.c
@@ -24,16 +24,16 @@
 #include <inttypes.h>
 #include "tableprint.h"
 
-WRITE_1D_FUNC(int8,   int8_t,   "%3"PRIi8, 15)
-WRITE_1D_FUNC(uint8,  uint8_t,  "0x%02"PRIx8, 15)
-WRITE_1D_FUNC(uint16, uint16_t, "0x%08"PRIx16, 7)
-WRITE_1D_FUNC(uint32, uint32_t, "0x%08"PRIx32, 7)
-WRITE_1D_FUNC(float,  float,    "%.18e", 3)
+WRITE_1D_FUNC(int8_t,   "%3"PRIi8, 15)
+WRITE_1D_FUNC(uint8_t,  "0x%02"PRIx8, 15)
+WRITE_1D_FUNC(uint16_t, "0x%08"PRIx16, 7)
+WRITE_1D_FUNC(uint32_t, "0x%08"PRIx32, 7)
+WRITE_1D_FUNC(float,    "%.18e", 3)
 
-WRITE_2D_FUNC(int8,   int8_t)
-WRITE_2D_FUNC(uint8,  uint8_t)
-WRITE_2D_FUNC(uint32, uint32_t)
-WRITE_2D_FUNC(float,  float)
+WRITE_2D_FUNC(int8_t)
+WRITE_2D_FUNC(uint8_t)
+WRITE_2D_FUNC(uint32_t)
+WRITE_2D_FUNC(float)
 
 void write_fileheader(void) {
     printf("/* This file was generated by libavcodec/tableprint */\n");
diff --git a/libavcodec/tableprint.h b/libavcodec/tableprint.h
index 76ab802..849bccf 100644
--- a/libavcodec/tableprint.h
+++ b/libavcodec/tableprint.h
@@ -26,8 +26,8 @@
 #include <stdint.h>
 #include <stdio.h>
 
-#define WRITE_1D_FUNC_ARGV(name, type, linebrk, fmtstr, ...)\
-void write_##name##_array(const type *data, int len)\
+#define WRITE_1D_FUNC_ARGV(type, linebrk, fmtstr, ...)\
+void write_##type##_array(const type *data, int len)\
 {\
     int i;\
     printf("   ");\
@@ -38,17 +38,17 @@ void write_##name##_array(const type *data, int len)\
     printf(" "fmtstr"\n", __VA_ARGS__);\
 }
 
-#define WRITE_1D_FUNC(name, type, fmtstr, linebrk)\
-    WRITE_1D_FUNC_ARGV(name, type, linebrk, fmtstr, data[i])
+#define WRITE_1D_FUNC(type, fmtstr, linebrk)\
+    WRITE_1D_FUNC_ARGV(type, linebrk, fmtstr, data[i])
 
-#define WRITE_2D_FUNC(name, type)\
-void write_##name##_2d_array(const void *arg, int len, int len2)\
+#define WRITE_2D_FUNC(type)\
+void write_##type##_2d_array(const void *arg, int len, int len2)\
 {\
     const type *data = arg;\
     int i;\
     printf("    {\n");\
     for (i = 0; i < len; i++) {\
-        write_##name##_array(data + i * len2, len2);\
+        write_##type##_array(data + i * len2, len2);\
         printf(i == len - 1 ? "    }\n" : "    }, {\n");\
     }\
 }
@@ -58,15 +58,15 @@ void write_##name##_2d_array(const void *arg, int len, int len2)\
  *
  * \{
  */
-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);
-void write_float_2d_array (const void *, int, int);
+void write_int8_t_array     (const int8_t   *, int);
+void write_uint8_t_array    (const uint8_t  *, int);
+void write_uint16_t_array   (const uint16_t *, int);
+void write_uint32_t_array   (const uint32_t *, int);
+void write_float_array      (const float    *, int);
+void write_int8_t_2d_array  (const void *, int, int);
+void write_uint8_t_2d_array (const void *, int, int);
+void write_uint32_t_2d_array(const void *, int, int);
+void write_float_2d_array   (const void *, int, int);
 /** \} */ // end of printfuncs group
 
 /** Write a standard file header */
-- 
1.7.1




More information about the ffmpeg-devel mailing list