1
/* (C) 2008 Jean-Marc Valin, CSIRO
4
Redistribution and use in source and binary forms, with or without
5
modification, are permitted provided that the following conditions
8
- Redistributions of source code must retain the above copyright
9
notice, this list of conditions and the following disclaimer.
11
- Redistributions in binary form must reproduce the above copyright
12
notice, this list of conditions and the following disclaimer in the
13
documentation and/or other materials provided with the distribution.
15
- Neither the name of the Xiph.org Foundation nor the names of its
16
contributors may be used to endorse or promote products derived from
17
this software without specific prior written permission.
19
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
23
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54
void dump_modes(FILE *file, CELTMode **modes, int nb_modes)
57
fprintf(file, "/* The contents of this file is automatically generated and contains static\n");
58
fprintf(file, " definitions for some pre-defined modes */\n");
59
fprintf(file, "#include \"modes.h\"\n");
60
fprintf(file, "#include \"rate.h\"\n");
63
for (i=0;i<nb_modes;i++)
65
CELTMode *mode = modes[i];
66
fprintf(file, "#ifndef DEF_EBANDS%d_%d\n", mode->Fs, mode->mdctSize);
67
fprintf(file, "#define DEF_EBANDS%d_%d\n", mode->Fs, mode->mdctSize);
68
fprintf (file, "static const celt_int16_t eBands%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbEBands+2);
69
for (j=0;j<mode->nbEBands+2;j++)
70
fprintf (file, "%d, ", mode->eBands[j]);
71
fprintf (file, "};\n");
72
fprintf(file, "#endif\n");
76
fprintf(file, "#ifndef DEF_PBANDS%d_%d\n", mode->Fs, mode->mdctSize);
77
fprintf(file, "#define DEF_PBANDS%d_%d\n", mode->Fs, mode->mdctSize);
78
fprintf (file, "static const celt_int16_t pBands%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbPBands+2);
79
for (j=0;j<mode->nbPBands+2;j++)
80
fprintf (file, "%d, ", mode->pBands[j]);
82
fprintf(file, "#endif\n");
86
fprintf(file, "#ifndef DEF_WINDOW%d\n", mode->overlap);
87
fprintf(file, "#define DEF_WINDOW%d\n", mode->overlap);
88
fprintf (file, "static const celt_word16_t window%d[%d] = {\n", mode->overlap, mode->overlap);
89
for (j=0;j<mode->overlap;j++)
90
fprintf (file, WORD16 ", ", mode->window[j]);
92
fprintf(file, "#endif\n");
95
fprintf(file, "#ifndef DEF_PSY%d\n", mode->Fs);
96
fprintf(file, "#define DEF_PSY%d\n", mode->Fs);
97
fprintf (file, "static const celt_word16_t psy_decayR_%d[%d] = {\n", mode->Fs, MAX_PERIOD/2);
98
for (j=0;j<MAX_PERIOD/2;j++)
99
fprintf (file, WORD16 ", ", mode->psy.decayR[j]);
101
fprintf(file, "#endif\n");
105
fprintf(file, "#ifndef DEF_ALLOC_VECTORS%d_%d\n", mode->Fs, mode->mdctSize);
106
fprintf(file, "#define DEF_ALLOC_VECTORS%d_%d\n", mode->Fs, mode->mdctSize);
107
fprintf (file, "static const celt_int16_t allocVectors%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbEBands*mode->nbAllocVectors);
108
for (j=0;j<mode->nbAllocVectors;j++)
111
for (k=0;k<mode->nbEBands;k++)
112
fprintf (file, "%2d, ", mode->allocVectors[j*mode->nbEBands+k]);
113
fprintf (file, "\n");
115
fprintf (file, "};\n");
116
fprintf(file, "#endif\n");
119
fprintf(file, "#ifndef DEF_ALLOC_CACHE%d_%d_%d\n", mode->Fs, mode->mdctSize, mode->nbChannels);
120
fprintf(file, "#define DEF_ALLOC_CACHE%d_%d_%d\n", mode->Fs, mode->mdctSize, mode->nbChannels);
121
for (j=0;j<mode->nbEBands;j++)
124
if (j==0 || (mode->bits[j] != mode->bits[j-1]))
126
fprintf (file, "static const celt_int16_t allocCache_band%d_%d_%d_%d[MAX_PULSES] = {\n", j, mode->Fs, mode->mdctSize, mode->nbChannels);
127
for (k=0;k<MAX_PULSES;k++)
128
fprintf (file, "%2d, ", mode->bits[j][k]);
129
fprintf (file, "};\n");
131
fprintf (file, "#define allocCache_band%d_%d_%d_%d allocCache_band%d_%d_%d_%d\n", j, mode->Fs, mode->mdctSize, mode->nbChannels, j-1, mode->Fs, mode->mdctSize, mode->nbChannels);
134
fprintf (file, "static const celt_int16_t *allocCache%d_%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbChannels, mode->nbEBands);
135
for (j=0;j<mode->nbEBands;j++)
137
fprintf (file, "allocCache_band%d_%d_%d_%d, ", j, mode->Fs, mode->mdctSize, mode->nbChannels);
139
fprintf (file, "};\n");
140
fprintf(file, "#endif\n");
144
fprintf(file, "static const CELTMode mode%d_%d_%d_%d = {\n", mode->Fs, mode->nbChannels, mode->mdctSize, mode->overlap);
145
fprintf(file, "0x%x,\t/* marker */\n", 0xa110ca7e);
146
fprintf(file, INT32 ",\t/* Fs */\n", mode->Fs);
147
fprintf(file, "%d,\t/* overlap */\n", mode->overlap);
148
fprintf(file, "%d,\t/* mdctSize */\n", mode->mdctSize);
149
fprintf(file, "%d,\t/* nbMdctBlocks */\n", mode->nbMdctBlocks);
150
fprintf(file, "%d,\t/* nbChannels */\n", mode->nbChannels);
151
fprintf(file, "%d,\t/* nbEBands */\n", mode->nbEBands);
152
fprintf(file, "%d,\t/* nbPBands */\n", mode->nbPBands);
153
fprintf(file, "%d,\t/* pitchEnd */\n", mode->pitchEnd);
154
fprintf(file, "eBands%d_%d,\t/* eBands */\n", mode->Fs, mode->mdctSize);
155
fprintf(file, "pBands%d_%d,\t/* pBands */\n", mode->Fs, mode->mdctSize);
156
fprintf(file, WORD16 ",\t/* ePredCoef */\n", mode->ePredCoef);
157
fprintf(file, "%d,\t/* nbAllocVectors */\n", mode->nbAllocVectors);
158
fprintf(file, "allocVectors%d_%d,\t/* allocVectors */\n", mode->Fs, mode->mdctSize);
159
fprintf(file, "allocCache%d_%d_%d,\t/* bits */\n", mode->Fs, mode->mdctSize, mode->nbChannels);
160
fprintf(file, "{%d, 0, 0},\t/* mdct */\n", 2*mode->mdctSize);
161
fprintf(file, "window%d,\t/* window */\n", mode->overlap);
162
fprintf(file, "{psy_decayR_%d},\t/* psy */\n", mode->Fs);
163
fprintf(file, "0x%x,\t/* marker */\n", 0xa110ca7e);
164
fprintf(file, "};\n");
167
fprintf(file, "/* List of all the available modes */\n");
168
fprintf(file, "#define TOTAL_MODES %d\n", nb_modes);
169
fprintf(file, "static const CELTMode * const static_mode_list[TOTAL_MODES] = {\n");
170
for (i=0;i<nb_modes;i++)
172
CELTMode *mode = modes[i];
173
fprintf(file, "&mode%d_%d_%d_%d,\n", mode->Fs, mode->nbChannels, mode->mdctSize, mode->overlap);
175
fprintf(file, "};\n");
182
m[0] = celt_mode_create(44100, 1, 256, 128, NULL);
183
m[1] = celt_mode_create(48000, 1, 256, 128, NULL);
184
m[2] = celt_mode_create(51200, 1, 256, 128, NULL);
185
dump_modes(stdout, m, 1);