Revision 8de0859b

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)
libavcodec/tableprint.h
24 24
#define AVCODEC_TABLEPRINT_H
25 25

  
26 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 58
 * \defgroup printfuncs Predefined functions for printing tables

Also available in: Unified diff