comparison tableprint.h @ 11522:db3588eb254a libavcodec

Extend and move macros to create table printing functions to header. Simplifies creating custom functions for printing DV VLC-related tables.
author reimar
date Sun, 21 Mar 2010 14:46:32 +0000
parents 62da6bfd50fd
children e03e3df6fb7d
comparison
equal deleted inserted replaced
11521:85d679e0b591 11522:db3588eb254a
22 22
23 #ifndef AVCODEC_TABLEPRINT_H 23 #ifndef AVCODEC_TABLEPRINT_H
24 #define AVCODEC_TABLEPRINT_H 24 #define AVCODEC_TABLEPRINT_H
25 25
26 #include <stdint.h> 26 #include <stdint.h>
27 #include <stdio.h>
28
29 #define WRITE_1D_FUNC_ARGV(name, type, linebrk, fmtstr, ...)\
30 void write_##name##_array(const void *arg, int len, int dummy)\
31 {\
32 const type *data = arg;\
33 int i;\
34 printf(" ");\
35 for (i = 0; i < len - 1; i++) {\
36 printf(" "fmtstr",", __VA_ARGS__);\
37 if ((i & linebrk) == linebrk) printf("\n ");\
38 }\
39 printf(" "fmtstr"\n", __VA_ARGS__);\
40 }
41
42 #define WRITE_1D_FUNC(name, type, fmtstr, linebrk)\
43 WRITE_1D_FUNC_ARGV(name, type, linebrk, fmtstr, data[i])
44
45 #define WRITE_2D_FUNC(name, type)\
46 void write_##name##_2d_array(const void *arg, int len, int len2)\
47 {\
48 const type *data = arg;\
49 int i;\
50 printf(" {\n");\
51 for (i = 0; i < len; i++) {\
52 write_##name##_array(data + i * len2, len2, 0);\
53 printf(i == len - 1 ? " }\n" : " }, {\n");\
54 }\
55 }
27 56
28 /** 57 /**
29 * \defgroup printfuncs Predefined functions for printing tables 58 * \defgroup printfuncs Predefined functions for printing tables
30 * 59 *
31 * \{ 60 * \{