Mercurial > libavcodec.hg
comparison tableprint.h @ 11570:e03e3df6fb7d libavcodec
Change/simplify the tableprint/tablegen API.
author | reimar |
---|---|
date | Thu, 01 Apr 2010 17:11:47 +0000 |
parents | db3588eb254a |
children | 8ad2b8f20e6a |
comparison
equal
deleted
inserted
replaced
11569:731050abce41 | 11570:e03e3df6fb7d |
---|---|
25 | 25 |
26 #include <stdint.h> | 26 #include <stdint.h> |
27 #include <stdio.h> | 27 #include <stdio.h> |
28 | 28 |
29 #define WRITE_1D_FUNC_ARGV(name, type, linebrk, fmtstr, ...)\ | 29 #define WRITE_1D_FUNC_ARGV(name, type, linebrk, fmtstr, ...)\ |
30 void write_##name##_array(const void *arg, int len, int dummy)\ | 30 void write_##name##_array(const type *data, int len)\ |
31 {\ | 31 {\ |
32 const type *data = arg;\ | |
33 int i;\ | 32 int i;\ |
34 printf(" ");\ | 33 printf(" ");\ |
35 for (i = 0; i < len - 1; i++) {\ | 34 for (i = 0; i < len - 1; i++) {\ |
36 printf(" "fmtstr",", __VA_ARGS__);\ | 35 printf(" "fmtstr",", __VA_ARGS__);\ |
37 if ((i & linebrk) == linebrk) printf("\n ");\ | 36 if ((i & linebrk) == linebrk) printf("\n ");\ |
47 {\ | 46 {\ |
48 const type *data = arg;\ | 47 const type *data = arg;\ |
49 int i;\ | 48 int i;\ |
50 printf(" {\n");\ | 49 printf(" {\n");\ |
51 for (i = 0; i < len; i++) {\ | 50 for (i = 0; i < len; i++) {\ |
52 write_##name##_array(data + i * len2, len2, 0);\ | 51 write_##name##_array(data + i * len2, len2);\ |
53 printf(i == len - 1 ? " }\n" : " }, {\n");\ | 52 printf(i == len - 1 ? " }\n" : " }, {\n");\ |
54 }\ | 53 }\ |
55 } | 54 } |
56 | 55 |
57 /** | 56 /** |
58 * \defgroup printfuncs Predefined functions for printing tables | 57 * \defgroup printfuncs Predefined functions for printing tables |
59 * | 58 * |
60 * \{ | 59 * \{ |
61 */ | 60 */ |
62 void write_int8_array (const void *, int, int); | 61 void write_int8_array (const int8_t *, int); |
63 void write_uint8_array (const void *, int, int); | 62 void write_uint8_array (const uint8_t *, int); |
64 void write_uint16_array (const void *, int, int); | 63 void write_uint16_array (const uint16_t *, int); |
65 void write_uint32_array (const void *, int, int); | 64 void write_uint32_array (const uint32_t *, int); |
66 void write_float_array (const void *, int, int); | 65 void write_float_array (const float *, int); |
67 void write_int8_2d_array (const void *, int, int); | 66 void write_int8_2d_array (const void *, int, int); |
68 void write_uint8_2d_array (const void *, int, int); | 67 void write_uint8_2d_array (const void *, int, int); |
69 void write_uint32_2d_array(const void *, int, int); | 68 void write_uint32_2d_array(const void *, int, int); |
70 /** \} */ // end of printfuncs group | 69 /** \} */ // end of printfuncs group |
71 | 70 |
72 struct tabledef { | 71 /** Write a standard file header */ |
73 /** String that declares the array. Adding " = { ..." after it should | 72 void write_fileheader(void); |
74 * make a valid initializer, adding "extern" before and ";" if possible | |
75 * should make a valid extern declaration. */ | |
76 const char *declaration; | |
77 /** Function used to print the table data (i.e. the part in {}). | |
78 * Should be one of the predefined write_*_array functions. */ | |
79 void (*printfunc)(const void *, int, int); | |
80 /** Pointer passed to the printfunc, usually a pointer to the start | |
81 * of the array to be printed. */ | |
82 const void *data; | |
83 int size; ///< size of the first dimension of the array | |
84 int size2; ///< size of the second dimension of the array if any | |
85 }; | |
86 | |
87 /** Initializes all the tables described in the tables array */ | |
88 void tableinit(void); | |
89 /** Describes the tables that should be printed */ | |
90 extern const struct tabledef tables[]; | |
91 | 73 |
92 #endif /* AVCODEC_TABLEPRINT_H */ | 74 #endif /* AVCODEC_TABLEPRINT_H */ |