diff options
author | Diego Pettenò <flameeyes@gmail.com> | 2010-06-27 12:21:12 +0000 |
---|---|---|
committer | Diego Pettenò <flameeyes@gmail.com> | 2010-06-27 12:21:12 +0000 |
commit | 350120d269033f4cc206850b3c81f797ed2cb9c6 (patch) | |
tree | f6c92e9142bea1123d8154f75c3f8b17967220ae /libavcodec/tableprint.h | |
parent | ac014798ff719c69a895aff0189a794ed9046554 (diff) | |
download | ffmpeg-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.h | 20 |
1 files changed, 20 insertions, 0 deletions
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 <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 */ |