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#define CONFIG_HARDCODED_TABLES 0
26#include "aac_defines.h"
27
28#if USE_FIXED
29#define TYPE_NAME "int32_t"
30typedef int32_t INT32FLOAT;
31#define ARRAY_RENAME(x) write_int32_t_ ## x
32#define ARRAY_URENAME(x) write_uint32_t_ ## x
33#include "aacps_fixed_tablegen.h"
34#else
35#define TYPE_NAME "float"
36typedef float INT32FLOAT;
37#define ARRAY_RENAME(x) write_float_ ## x
38#define ARRAY_URENAME(x) write_float_ ## x
39#include "aacps_tablegen.h"
40#endif /* USE_FIXED */
41#include "tableprint.h"
42
43void ARRAY_RENAME(3d_array) (const void *p, int b, int c, int d)
44{
45    int i;
46    const INT32FLOAT *f = p;
47    for (i = 0; i < b; i++) {
48        printf("{\n");
49        ARRAY_URENAME(2d_array)(f, c, d);
50        printf("},\n");
51        f += c * d;
52    }
53}
54
55void ARRAY_RENAME(4d_array) (const void *p, int a, int b, int c, int d)
56{
57    int i;
58    const INT32FLOAT *f = p;
59    for (i = 0; i < a; i++) {
60        printf("{\n");
61        ARRAY_RENAME(3d_array)(f, b, c, d);
62        printf("},\n");
63        f += b * c * d;
64    }
65}
66
67int main(void)
68{
69    ps_tableinit();
70
71    write_fileheader();
72
73    printf("static const %s pd_re_smooth[8*8*8] = {\n", TYPE_NAME);
74    ARRAY_RENAME(array)(pd_re_smooth, 8*8*8);
75    printf("};\n");
76    printf("static const %s pd_im_smooth[8*8*8] = {\n", TYPE_NAME);
77    ARRAY_RENAME(array)(pd_im_smooth, 8*8*8);
78    printf("};\n");
79
80    printf("static const %s HA[46][8][4] = {\n", TYPE_NAME);
81    ARRAY_RENAME(3d_array)(HA, 46, 8, 4);
82    printf("};\n");
83    printf("static const %s HB[46][8][4] = {\n", TYPE_NAME);
84    ARRAY_RENAME(3d_array)(HB, 46, 8, 4);
85    printf("};\n");
86
87    printf("static const DECLARE_ALIGNED(16, %s, f20_0_8)[8][8][2] = {\n", TYPE_NAME);
88    ARRAY_RENAME(3d_array)(f20_0_8, 8, 8, 2);
89    printf("};\n");
90    printf("static const DECLARE_ALIGNED(16, %s, f34_0_12)[12][8][2] = {\n", TYPE_NAME);
91    ARRAY_RENAME(3d_array)(f34_0_12, 12, 8, 2);
92    printf("};\n");
93    printf("static const DECLARE_ALIGNED(16, %s, f34_1_8)[8][8][2] = {\n", TYPE_NAME);
94    ARRAY_RENAME(3d_array)(f34_1_8, 8, 8, 2);
95    printf("};\n");
96    printf("static const DECLARE_ALIGNED(16, %s, f34_2_4)[4][8][2] = {\n", TYPE_NAME);
97    ARRAY_RENAME(3d_array)(f34_2_4, 4, 8, 2);
98    printf("};\n");
99
100    printf("static const DECLARE_ALIGNED(16, %s, Q_fract_allpass)[2][50][3][2] = {\n", TYPE_NAME);
101    ARRAY_RENAME(4d_array)(Q_fract_allpass, 2, 50, 3, 2);
102    printf("};\n");
103    printf("static const DECLARE_ALIGNED(16, %s, phi_fract)[2][50][2] = {\n", TYPE_NAME);
104    ARRAY_RENAME(3d_array)(phi_fract, 2, 50, 2);
105    printf("};\n");
106
107    return 0;
108}
109