summaryrefslogtreecommitdiffstats
path: root/libavcodec/tableprint.h
diff options
context:
space:
mode:
authorDiego Pettenò <flameeyes@gmail.com>2010-06-27 12:21:12 +0000
committerDiego Pettenò <flameeyes@gmail.com>2010-06-27 12:21:12 +0000
commit350120d269033f4cc206850b3c81f797ed2cb9c6 (patch)
treef6c92e9142bea1123d8154f75c3f8b17967220ae /libavcodec/tableprint.h
parentac014798ff719c69a895aff0189a794ed9046554 (diff)
downloadffmpeg-streaming-350120d269033f4cc206850b3c81f797ed2cb9c6.zip
ffmpeg-streaming-350120d269033f4cc206850b3c81f797ed2cb9c6.tar.gz
tablegen: implement and use WRITE_ARRAY macros
Two macros (WRITE_ARRAY and WRITE_ARRAY_2D) take the prefix (modifiers) (not all tables are static, and they might not be constant either), the type, and the name of the array. It'll be copied with same name and type, and with the correct size of the currently-defined object. Originally committed as revision 23821 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/tableprint.h')
-rw-r--r--libavcodec/tableprint.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/libavcodec/tableprint.h b/libavcodec/tableprint.h
index 849bccf..97a667d 100644
--- a/libavcodec/tableprint.h
+++ b/libavcodec/tableprint.h
@@ -25,6 +25,7 @@
#include <stdint.h>
#include <stdio.h>
+#include "libavutil/common.h"
#define WRITE_1D_FUNC_ARGV(type, linebrk, fmtstr, ...)\
void write_##type##_array(const type *data, int len)\
@@ -72,4 +73,23 @@ void write_float_2d_array (const void *, int, int);
/** Write a standard file header */
void write_fileheader(void);
+#define WRITE_ARRAY(prefix, type, name) \
+ do { \
+ const size_t array_size = FF_ARRAY_ELEMS(name); \
+ printf(prefix" "#type" "#name"[%zu] = {\n", \
+ array_size); \
+ write_##type##_array(name, array_size); \
+ printf("};\n"); \
+ } while(0)
+
+#define WRITE_2D_ARRAY(prefix, type, name) \
+ do { \
+ const size_t array_size1 = FF_ARRAY_ELEMS(name); \
+ const size_t array_size2 = FF_ARRAY_ELEMS(name[0]); \
+ printf(prefix" "#type" "#name"[%zu][%zu] = {\n", \
+ array_size1, array_size2 ); \
+ write_##type##_2d_array(name, array_size1, array_size2); \
+ printf("};\n"); \
+ } while(0)
+
#endif /* AVCODEC_TABLEPRINT_H */
OpenPOWER on IntegriCloud