Mercurial > libavcodec.hg
annotate costablegen.c @ 11352:6e0af2cfdcfe libavcodec
Do MC and IDCT in coding (hilbert) order
This increases the slice size to 64 pixels, due to having to decode an
entire chroma superblock row per slice.
This can be up to 6% slower depending on clip and CPU, but is necessary
for future optimizations that gain significantly more than was lost.
author | conrad |
---|---|
date | Wed, 03 Mar 2010 23:27:40 +0000 |
parents | 36a16fb5c497 |
children | 351d1c11195b |
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 | 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 | 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 | 36 int do_sin = argc == 2 && !strcmp(argv[1], "sin"); |
37 double (*func)(double) = do_sin ? sin : cos; | |
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"); |
10473
36a16fb5c497
Fix out-of-tree builds with --enable-hardcoded-tables
reimar
parents:
10408
diff
changeset
|
40 printf("#include \"libavcodec/dsputil.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 | 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 | 47 if (do_sin && j >= m/4) |
48 idx = m/4 - j; | |
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 | 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 } |