mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
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
This commit is contained in:
parent
ac014798ff
commit
350120d269
@ -31,9 +31,7 @@ int main(void)
|
||||
|
||||
write_fileheader();
|
||||
|
||||
printf("const float ff_aac_pow2sf_tab[428] = {\n");
|
||||
write_float_array(ff_aac_pow2sf_tab, 428);
|
||||
printf("};\n");
|
||||
WRITE_ARRAY("const", float, ff_aac_pow2sf_tab);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -31,9 +31,7 @@ int main(void)
|
||||
|
||||
write_fileheader();
|
||||
|
||||
printf("static const uint32_t cbrt_tab[1<<13] = {\n");
|
||||
write_uint32_t_array(cbrt_tab, 1 << 13);
|
||||
printf("};\n");
|
||||
WRITE_ARRAY("static const", uint32_t, cbrt_tab);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -31,29 +31,12 @@ int main(void)
|
||||
|
||||
write_fileheader();
|
||||
|
||||
printf("static const int8_t table_4_3_exp[TABLE_4_3_SIZE] = {\n");
|
||||
write_int8_t_array(table_4_3_exp, TABLE_4_3_SIZE);
|
||||
printf("};\n");
|
||||
|
||||
printf("static const uint32_t table_4_3_value[TABLE_4_3_SIZE] = {\n");
|
||||
write_uint32_t_array(table_4_3_value, TABLE_4_3_SIZE);
|
||||
printf("};\n");
|
||||
|
||||
printf("static const uint32_t exp_table[512] = {\n");
|
||||
write_uint32_t_array(exp_table, 512);
|
||||
printf("};\n");
|
||||
|
||||
printf("static const float exp_table_float[512] = {\n");
|
||||
write_float_array(exp_table_float, 512);
|
||||
printf("};\n");
|
||||
|
||||
printf("static const uint32_t expval_table[512][16] = {\n");
|
||||
write_uint32_t_2d_array(expval_table, 512, 16);
|
||||
printf("};\n");
|
||||
|
||||
printf("static const float expval_table_float[512][16] = {\n");
|
||||
write_float_2d_array(expval_table_float, 512, 16);
|
||||
printf("};\n");
|
||||
WRITE_ARRAY("static const", int8_t, table_4_3_exp);
|
||||
WRITE_ARRAY("static const", uint32_t, table_4_3_value);
|
||||
WRITE_ARRAY("static const", uint32_t, exp_table);
|
||||
WRITE_ARRAY("static const", float, exp_table_float);
|
||||
WRITE_2D_ARRAY("static const", uint32_t, expval_table);
|
||||
WRITE_2D_ARRAY("static const", float, expval_table_float);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -32,13 +32,8 @@ int main(void)
|
||||
|
||||
write_fileheader();
|
||||
|
||||
printf("static const uint8_t linear_to_alaw[1 << 14] = {\n");
|
||||
write_uint8_t_array(linear_to_alaw, 1 << 14);
|
||||
printf("};\n");
|
||||
|
||||
printf("static const uint8_t linear_to_ulaw[1 << 14] = {\n");
|
||||
write_uint8_t_array(linear_to_ulaw, 1 << 14);
|
||||
printf("};\n");
|
||||
WRITE_ARRAY("static const", uint8_t, linear_to_alaw);
|
||||
WRITE_ARRAY("static const", uint8_t, linear_to_ulaw);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -33,25 +33,12 @@ int main(void)
|
||||
|
||||
write_fileheader();
|
||||
|
||||
printf("static const uint16_t softclip_table[HARDCLIP_THRESHOLD - SOFTCLIP_THRESHOLD + 1] = {\n");
|
||||
write_uint16_t_array(softclip_table, HARDCLIP_THRESHOLD - SOFTCLIP_THRESHOLD + 1);
|
||||
printf("};\n");
|
||||
WRITE_ARRAY("static const", uint16_t, softclip_table);
|
||||
WRITE_ARRAY("static const", float, noise_table);
|
||||
WRITE_ARRAY("static const", float, noise_samples);
|
||||
|
||||
printf("static const float noise_table[4096] = {\n");
|
||||
write_float_array(noise_table, 4096);
|
||||
printf("};\n");
|
||||
|
||||
printf("static const uint8_t random_dequant_index[256][5] = {\n");
|
||||
write_uint8_t_2d_array(random_dequant_index, 256, 5);
|
||||
printf("};\n");
|
||||
|
||||
printf("static const uint8_t random_dequant_type24[128][3] = {\n");
|
||||
write_uint8_t_2d_array(random_dequant_type24, 128, 3);
|
||||
printf("};\n");
|
||||
|
||||
printf("static const float noise_samples[128] = {\n");
|
||||
write_float_array(noise_samples, 128);
|
||||
printf("};\n");
|
||||
WRITE_2D_ARRAY("static const", uint8_t, random_dequant_index);
|
||||
WRITE_2D_ARRAY("static const", uint8_t, random_dequant_type24);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user