Mercurial > libavcodec.hg
comparison tableprint.c @ 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 | 06d8a281e045 |
comparison
equal
deleted
inserted
replaced
11521:85d679e0b591 | 11522:db3588eb254a |
---|---|
22 | 22 |
23 #include <stdio.h> | 23 #include <stdio.h> |
24 #include <inttypes.h> | 24 #include <inttypes.h> |
25 #include "tableprint.h" | 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 WRITE_1D_FUNC(int8, int8_t, "%3"PRIi8, 15) | 27 WRITE_1D_FUNC(int8, int8_t, "%3"PRIi8, 15) |
41 WRITE_1D_FUNC(uint8, uint8_t, "0x%02"PRIx8, 15) | 28 WRITE_1D_FUNC(uint8, uint8_t, "0x%02"PRIx8, 15) |
42 WRITE_1D_FUNC(uint16, uint16_t, "0x%08"PRIx16, 7) | 29 WRITE_1D_FUNC(uint16, uint16_t, "0x%08"PRIx16, 7) |
43 WRITE_1D_FUNC(uint32, uint32_t, "0x%08"PRIx32, 7) | 30 WRITE_1D_FUNC(uint32, uint32_t, "0x%08"PRIx32, 7) |
44 WRITE_1D_FUNC(float, float, "%.18e", 3) | 31 WRITE_1D_FUNC(float, float, "%.18e", 3) |
45 | |
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 | 32 |
58 WRITE_2D_FUNC(int8, int8_t) | 33 WRITE_2D_FUNC(int8, int8_t) |
59 WRITE_2D_FUNC(uint8, uint8_t) | 34 WRITE_2D_FUNC(uint8, uint8_t) |
60 WRITE_2D_FUNC(uint32, uint32_t) | 35 WRITE_2D_FUNC(uint32, uint32_t) |
61 | 36 |