1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

tableprint: use the type name as-is for the functions' names.

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.

Originally committed as revision 23820 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Diego Pettenò 2010-06-27 12:20:39 +00:00
parent 07ece20c69
commit ac014798ff
9 changed files with 41 additions and 41 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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()

View File

@ -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;

View File

@ -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");

View File

@ -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;

View File

@ -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");

View File

@ -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");

View File

@ -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 */