annotate costablegen.c @ 11690:56a2ead12502 libavcodec

Another try for fixing/improving decode_video documentation.
author reimar
date Sat, 08 May 2010 16:24:33 +0000
parents 351d1c11195b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10400
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
1 /*
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
2 * Generate a header file for hardcoded ff_cos_* tables
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
3 *
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
4 * Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
5 *
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
6 * This file is part of FFmpeg.
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
7 *
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
8 * FFmpeg is free software; you can redistribute it and/or
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
9 * modify it under the terms of the GNU Lesser General Public
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
10 * License as published by the Free Software Foundation; either
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
11 * version 2.1 of the License, or (at your option) any later version.
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
12 *
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
13 * FFmpeg is distributed in the hope that it will be useful,
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
16 * Lesser General Public License for more details.
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
17 *
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
19 * License along with FFmpeg; if not, write to the Free Software
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
21 */
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
22
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
23 #include <stdio.h>
10408
8fd8f6c1cdcc Add support for hardcoded ff_sin_* tables.
reimar
parents: 10407
diff changeset
24 #include <string.h>
10400
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
25 #include <math.h>
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
26
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
27 #ifndef M_PI
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
28 #define M_PI 3.14159265358979323846
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
29 #endif
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
30 #define BITS 16
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
31 #define FLOATFMT "%.18e"
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
32
10408
8fd8f6c1cdcc Add support for hardcoded ff_sin_* tables.
reimar
parents: 10407
diff changeset
33 int main(int argc, char *argv[])
10400
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
34 {
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
35 int i, j;
10408
8fd8f6c1cdcc Add support for hardcoded ff_sin_* tables.
reimar
parents: 10407
diff changeset
36 int do_sin = argc == 2 && !strcmp(argv[1], "sin");
8fd8f6c1cdcc Add support for hardcoded ff_sin_* tables.
reimar
parents: 10407
diff changeset
37 double (*func)(double) = do_sin ? sin : cos;
8fd8f6c1cdcc Add support for hardcoded ff_sin_* tables.
reimar
parents: 10407
diff changeset
38
10400
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
39 printf("/* This file was generated by libavcodec/costablegen */\n");
11385
351d1c11195b Fix --enable-hardcoded-tables compilation: the generate table files now
reimar
parents: 10473
diff changeset
40 printf("#include \"libavcodec/fft.h\"\n");
10400
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
41 for (i = 4; i <= BITS; i++) {
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
42 int m = 1 << i;
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
43 double freq = 2*M_PI/m;
10408
8fd8f6c1cdcc Add support for hardcoded ff_sin_* tables.
reimar
parents: 10407
diff changeset
44 printf("%s(%i) = {\n ", do_sin ? "SINTABLE" : "COSTABLE", m);
10400
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
45 for (j = 0; j < m/2 - 1; j++) {
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
46 int idx = j > m/4 ? m/2 - j : j;
10408
8fd8f6c1cdcc Add support for hardcoded ff_sin_* tables.
reimar
parents: 10407
diff changeset
47 if (do_sin && j >= m/4)
8fd8f6c1cdcc Add support for hardcoded ff_sin_* tables.
reimar
parents: 10407
diff changeset
48 idx = m/4 - j;
8fd8f6c1cdcc Add support for hardcoded ff_sin_* tables.
reimar
parents: 10407
diff changeset
49 printf(" "FLOATFMT",", func(idx*freq));
10400
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
50 if ((j & 3) == 3)
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
51 printf("\n ");
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
52 }
10408
8fd8f6c1cdcc Add support for hardcoded ff_sin_* tables.
reimar
parents: 10407
diff changeset
53 printf(" "FLOATFMT"\n};\n", func(do_sin ? -(m/4 - 1)*freq : freq));
10400
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
54 }
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
55 return 0;
866dffa620d1 Use hardcoded instead of runtime-calculated ff_cos_* tables if
reimar
parents:
diff changeset
56 }