00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef AVCODEC_TABLEPRINT_H
00024 #define AVCODEC_TABLEPRINT_H
00025
00026 #include <inttypes.h>
00027 #include <stdio.h>
00028
00029 #include "libavutil/common.h"
00030
00031 #define WRITE_1D_FUNC_ARGV(type, linebrk, fmtstr, ...)\
00032 void write_##type##_array(const type *data, int len)\
00033 {\
00034 int i;\
00035 printf(" ");\
00036 for (i = 0; i < len - 1; i++) {\
00037 printf(" "fmtstr",", __VA_ARGS__);\
00038 if ((i & linebrk) == linebrk) printf("\n ");\
00039 }\
00040 printf(" "fmtstr"\n", __VA_ARGS__);\
00041 }
00042
00043 #define WRITE_1D_FUNC(type, fmtstr, linebrk)\
00044 WRITE_1D_FUNC_ARGV(type, linebrk, fmtstr, data[i])
00045
00046 #define WRITE_2D_FUNC(type)\
00047 void write_##type##_2d_array(const void *arg, int len, int len2)\
00048 {\
00049 const type *data = arg;\
00050 int i;\
00051 printf(" {\n");\
00052 for (i = 0; i < len; i++) {\
00053 write_##type##_array(data + i * len2, len2);\
00054 printf(i == len - 1 ? " }\n" : " }, {\n");\
00055 }\
00056 }
00057
00063 void write_int8_t_array (const int8_t *, int);
00064 void write_uint8_t_array (const uint8_t *, int);
00065 void write_uint16_t_array (const uint16_t *, int);
00066 void write_uint32_t_array (const uint32_t *, int);
00067 void write_float_array (const float *, int);
00068 void write_int8_t_2d_array (const void *, int, int);
00069 void write_uint8_t_2d_array (const void *, int, int);
00070 void write_uint32_t_2d_array(const void *, int, int);
00071 void write_float_2d_array (const void *, int, int);
00073
00074 #define WRITE_ARRAY(prefix, type, name) \
00075 do { \
00076 const size_t array_size = FF_ARRAY_ELEMS(name); \
00077 printf(prefix" "#type" "#name"[%zu] = {\n", \
00078 array_size); \
00079 write_##type##_array(name, array_size); \
00080 printf("};\n"); \
00081 } while(0)
00082
00083 #define WRITE_2D_ARRAY(prefix, type, name) \
00084 do { \
00085 const size_t array_size1 = FF_ARRAY_ELEMS(name); \
00086 const size_t array_size2 = FF_ARRAY_ELEMS(name[0]); \
00087 printf(prefix" "#type" "#name"[%zu][%zu] = {\n", \
00088 array_size1, array_size2 ); \
00089 write_##type##_2d_array(name, array_size1, array_size2); \
00090 printf("};\n"); \
00091 } while(0)
00092
00093
00094 WRITE_1D_FUNC(int8_t, "%3"PRIi8, 15)
00095 WRITE_1D_FUNC(uint8_t, "0x%02"PRIx8, 15)
00096 WRITE_1D_FUNC(uint16_t, "0x%08"PRIx16, 7)
00097 WRITE_1D_FUNC(uint32_t, "0x%08"PRIx32, 7)
00098 WRITE_1D_FUNC(float, "%.18e", 3)
00099
00100 WRITE_2D_FUNC(int8_t)
00101 WRITE_2D_FUNC(uint8_t)
00102 WRITE_2D_FUNC(uint32_t)
00103 WRITE_2D_FUNC(float)
00104
00105 static inline void write_fileheader(void)
00106 {
00107 printf("/* This file was automatically generated. */\n");
00108 printf("#include <stdint.h>\n");
00109 }
00110
00111 #endif