From 350120d269033f4cc206850b3c81f797ed2cb9c6 Mon Sep 17 00:00:00 2001 From: Diego Pettenò Date: Sun, 27 Jun 2010 12:21:12 +0000 Subject: 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 --- libavcodec/tableprint.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'libavcodec/tableprint.h') diff --git a/libavcodec/tableprint.h b/libavcodec/tableprint.h index 849bccf78e..97a667db33 100644 --- a/libavcodec/tableprint.h +++ b/libavcodec/tableprint.h @@ -25,6 +25,7 @@ #include #include +#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 */ -- cgit v1.2.3