Mercurial > libavcodec.hg
annotate mdct_tablegen.c @ 10874:bcfe2acbf190 libavcodec
AAC: Compress codebook tables and optimise sign bit handling
The codebooks each consist of small number of values repeated in
groups of 2 or 4. Storing the codebooks as a packed list of 2- or
4-bit indexes into a table reduces their size substantially (from 7.5k
to 1.5k), resulting in less cache pressure.
For the band types with sign bits in the bitstream, storing the number
and position of non-zero codebook values using a few bits avoids
multiple get_bits() calls and floating-point comparisons which gcc
handles miserably.
Some float/int type punning also avoids gcc brain damage.
Overall speedup 20-35% on Cortex-A8, 20% on Core i7.
| author | mru |
|---|---|
| date | Wed, 13 Jan 2010 16:46:28 +0000 |
| parents | 3d011a01a6a0 |
| children | 8bef88bc329d |
| rev | line source |
|---|---|
|
10827
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
1 /* |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
2 * Generate a header file for hardcoded MDCT tables |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
3 * |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
4 * Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de> |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
5 * |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
6 * This file is part of FFmpeg. |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
7 * |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
8 * FFmpeg is free software; you can redistribute it and/or |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
9 * modify it under the terms of the GNU Lesser General Public |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
10 * License as published by the Free Software Foundation; either |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
11 * version 2.1 of the License, or (at your option) any later version. |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
12 * |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
13 * FFmpeg is distributed in the hope that it will be useful, |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
16 * Lesser General Public License for more details. |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
17 * |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
18 * You should have received a copy of the GNU Lesser General Public |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
19 * License along with FFmpeg; if not, write to the Free Software |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
21 */ |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
22 |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
23 #include <stdlib.h> |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
24 #define CONFIG_HARDCODED_TABLES 0 |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
25 #define av_cold |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
26 #define SINETABLE_CONST |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
27 #define SINETABLE(size) \ |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
28 float ff_sine_##size[size] |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
29 #define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
30 #ifndef M_PI |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
31 #define M_PI 3.14159265358979323846 |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
32 #endif |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
33 #include "mdct_tablegen.h" |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
34 #include "tableprint.h" |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
35 |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
36 void tableinit(void) |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
37 { |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
38 int i; |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
39 for (i = 5; i <= 12; i++) |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
40 ff_init_ff_sine_windows(i); |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
41 } |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
42 |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
43 #define SINE_TABLE_DEF(size) \ |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
44 { \ |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
45 "SINETABLE("#size")", \ |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
46 write_float_array, \ |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
47 ff_sine_##size, \ |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
48 size \ |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
49 }, |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
50 |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
51 const struct tabledef tables[] = { |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
52 SINE_TABLE_DEF( 32) |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
53 SINE_TABLE_DEF( 64) |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
54 SINE_TABLE_DEF( 128) |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
55 SINE_TABLE_DEF( 256) |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
56 SINE_TABLE_DEF( 512) |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
57 SINE_TABLE_DEF(1024) |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
58 SINE_TABLE_DEF(2048) |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
59 SINE_TABLE_DEF(4096) |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
60 { NULL } |
|
3d011a01a6a0
Add support for hard-coded MDCT-related ff_sine_windows tables.
reimar
parents:
diff
changeset
|
61 }; |
