FFmpeg
aacps_tablegen_template.c
Go to the documentation of this file.
1 /*
2  * Generate a header file for hardcoded Parametric Stereo tables
3  *
4  * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com>
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #include <stdlib.h>
24 #define BUILD_TABLES
25 #include "config.h"
26 #undef CONFIG_HARDCODED_TABLES
27 #define CONFIG_HARDCODED_TABLES 0
28 #include "aac_defines.h"
29 
30 #if USE_FIXED
31 #define TYPE_NAME "int32_t"
32 typedef int32_t INT32FLOAT;
33 #define ARRAY_RENAME(x) write_int32_t_ ## x
34 #define ARRAY_URENAME(x) write_uint32_t_ ## x
35 #include "aacps_fixed_tablegen.h"
36 #else
37 #define TYPE_NAME "float"
38 typedef float INT32FLOAT;
39 #define ARRAY_RENAME(x) write_float_ ## x
40 #define ARRAY_URENAME(x) write_float_ ## x
41 #include "aacps_tablegen.h"
42 #endif /* USE_FIXED */
43 #include "tableprint.h"
44 
45 void ARRAY_RENAME(3d_array) (const void *p, int b, int c, int d)
46 {
47  int i;
48  const INT32FLOAT *f = p;
49  for (i = 0; i < b; i++) {
50  printf("{\n");
51  ARRAY_URENAME(2d_array)(f, c, d);
52  printf("},\n");
53  f += c * d;
54  }
55 }
56 
57 void ARRAY_RENAME(4d_array) (const void *p, int a, int b, int c, int d)
58 {
59  int i;
60  const INT32FLOAT *f = p;
61  for (i = 0; i < a; i++) {
62  printf("{\n");
63  ARRAY_RENAME(3d_array)(f, b, c, d);
64  printf("},\n");
65  f += b * c * d;
66  }
67 }
68 
69 int main(void)
70 {
71  ps_tableinit();
72 
74 
75  printf("static const %s pd_re_smooth[8*8*8] = {\n", TYPE_NAME);
77  printf("};\n");
78  printf("static const %s pd_im_smooth[8*8*8] = {\n", TYPE_NAME);
80  printf("};\n");
81 
82  printf("static const %s HA[46][8][4] = {\n", TYPE_NAME);
83  ARRAY_RENAME(3d_array)(HA, 46, 8, 4);
84  printf("};\n");
85  printf("static const %s HB[46][8][4] = {\n", TYPE_NAME);
86  ARRAY_RENAME(3d_array)(HB, 46, 8, 4);
87  printf("};\n");
88 
89  printf("static const DECLARE_ALIGNED(16, %s, f20_0_8)[8][8][2] = {\n", TYPE_NAME);
90  ARRAY_RENAME(3d_array)(f20_0_8, 8, 8, 2);
91  printf("};\n");
92  printf("static const DECLARE_ALIGNED(16, %s, f34_0_12)[12][8][2] = {\n", TYPE_NAME);
93  ARRAY_RENAME(3d_array)(f34_0_12, 12, 8, 2);
94  printf("};\n");
95  printf("static const DECLARE_ALIGNED(16, %s, f34_1_8)[8][8][2] = {\n", TYPE_NAME);
96  ARRAY_RENAME(3d_array)(f34_1_8, 8, 8, 2);
97  printf("};\n");
98  printf("static const DECLARE_ALIGNED(16, %s, f34_2_4)[4][8][2] = {\n", TYPE_NAME);
99  ARRAY_RENAME(3d_array)(f34_2_4, 4, 8, 2);
100  printf("};\n");
101 
102  printf("static const DECLARE_ALIGNED(16, %s, Q_fract_allpass)[2][50][3][2] = {\n", TYPE_NAME);
103  ARRAY_RENAME(4d_array)(Q_fract_allpass, 2, 50, 3, 2);
104  printf("};\n");
105  printf("static const DECLARE_ALIGNED(16, %s, phi_fract)[2][50][2] = {\n", TYPE_NAME);
106  ARRAY_RENAME(3d_array)(phi_fract, 2, 50, 2);
107  printf("};\n");
108 
109  return 0;
110 }
f34_2_4
static int f34_2_4[4][8][2]
Definition: aacps_fixed_tablegen.h:59
pd_im_smooth
static int pd_im_smooth[8 *8 *8]
Definition: aacps_fixed_tablegen.h:53
Q_fract_allpass
static TABLE_CONST int Q_fract_allpass[2][50][3][2]
Definition: aacps_fixed_tablegen.h:60
tableprint.h
b
#define b
Definition: input.c:41
aacps_fixed_tablegen.h
f20_0_8
static int f20_0_8[8][8][2]
Definition: aacps_fixed_tablegen.h:56
f34_0_12
static int f34_0_12[12][8][2]
Definition: aacps_fixed_tablegen.h:57
TYPE_NAME
#define TYPE_NAME
Definition: aacps_tablegen_template.c:37
ARRAY_RENAME
#define ARRAY_RENAME(x)
Definition: aacps_tablegen_template.c:39
pd_re_smooth
static int pd_re_smooth[8 *8 *8]
Definition: aacps_fixed_tablegen.h:52
aacps_tablegen.h
write_fileheader
write_fileheader() adds some minor things like a "this is a generated file" comment and some standard includes. tablegen.h defines some write functions for one- and two-dimensional arrays for standard types - they print only the "core" parts so they are easier to reuse for multi-dimensional arrays so the outermost
Definition: tablegen.txt:39
HA
static int HA[46][8][4]
Definition: aacps_fixed_tablegen.h:54
INT32FLOAT
float INT32FLOAT
Definition: aacps_tablegen_template.c:38
f34_1_8
static int f34_1_8[8][8][2]
Definition: aacps_fixed_tablegen.h:58
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
HB
static int HB[46][8][4]
Definition: aacps_fixed_tablegen.h:55
f
f
Definition: af_crystalizer.c:121
printf
printf("static const uint8_t my_array[100] = {\n")
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
main
int main(void)
Definition: aacps_tablegen_template.c:69
array
static int array[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:111
phi_fract
static int phi_fract[2][50][2]
Definition: aacps_fixed_tablegen.h:61
ARRAY_URENAME
#define ARRAY_URENAME(x)
Definition: aacps_tablegen_template.c:40
ps_tableinit
static void ps_tableinit(void)
Definition: aacps_fixed_tablegen.h:140
d
d
Definition: ffmpeg_filter.c:409
int32_t
int32_t
Definition: audioconvert.c:56
aac_defines.h