Revision 8de0859b libavcodec/tableprint.c

View differences:

libavcodec/tableprint.c
24 24
#include <inttypes.h>
25 25
#include "tableprint.h"
26 26

  
27
#define WRITE_1D_FUNC(name, type, fmtstr, linebrk)\
28
void write_##name##_array(const void *arg, int len, int dummy)\
29
{\
30
    const type *data = arg;\
31
    int i;\
32
    printf("   ");\
33
    for (i = 0; i < len - 1; i++) {\
34
       printf(" "fmtstr",", data[i]);\
35
       if ((i & linebrk) == linebrk) printf("\n   ");\
36
    }\
37
    printf(" "fmtstr"\n", data[i]);\
38
}
39

  
40 27
WRITE_1D_FUNC(int8,   int8_t,   "%3"PRIi8, 15)
41 28
WRITE_1D_FUNC(uint8,  uint8_t,  "0x%02"PRIx8, 15)
42 29
WRITE_1D_FUNC(uint16, uint16_t, "0x%08"PRIx16, 7)
43 30
WRITE_1D_FUNC(uint32, uint32_t, "0x%08"PRIx32, 7)
44 31
WRITE_1D_FUNC(float,  float,    "%.18e", 3)
45 32

  
46
#define WRITE_2D_FUNC(name, type)\
47
void write_##name##_2d_array(const void *arg, int len, int len2)\
48
{\
49
    const type *data = arg;\
50
    int i;\
51
    printf("    {\n");\
52
    for (i = 0; i < len; i++) {\
53
        write_##name##_array(data + i * len2, len2, 0);\
54
        printf(i == len - 1 ? "    }\n" : "    }, {\n");\
55
    }\
56
}
57

  
58 33
WRITE_2D_FUNC(int8,   int8_t)
59 34
WRITE_2D_FUNC(uint8,  uint8_t)
60 35
WRITE_2D_FUNC(uint32, uint32_t)

Also available in: Unified diff