Mercurial > libavcodec.hg
comparison dv_tablegen.h @ 11523:3367dd5913a0 libavcodec
Add support for hard-coding the 256kB large dv_vlc_map table.
author | reimar |
---|---|
date | Sun, 21 Mar 2010 16:03:45 +0000 |
parents | |
children | 59f399926c12 |
comparison
equal
deleted
inserted
replaced
11522:db3588eb254a | 11523:3367dd5913a0 |
---|---|
1 /* | |
2 * Header file for hardcoded DV tables | |
3 * | |
4 * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de> | |
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 #ifndef DV_TABLEGEN_H | |
24 #define DV_TABLEGEN_H | |
25 | |
26 #include <stdint.h> | |
27 #include "dv_vlc_data.h" | |
28 | |
29 #if CONFIG_SMALL | |
30 #define DV_VLC_MAP_RUN_SIZE 15 | |
31 #define DV_VLC_MAP_LEV_SIZE 23 | |
32 #else | |
33 #define DV_VLC_MAP_RUN_SIZE 64 | |
34 #define DV_VLC_MAP_LEV_SIZE 512 //FIXME sign was removed so this should be /2 but needs check | |
35 #endif | |
36 | |
37 /* VLC encoding lookup table */ | |
38 struct dv_vlc_pair { | |
39 uint32_t vlc; | |
40 uint32_t size; | |
41 }; | |
42 | |
43 #if CONFIG_HARDCODED_TABLES | |
44 #define dv_vlc_map_tableinit() | |
45 #include "libavcodec/dv_tables.h" | |
46 #else | |
47 static struct dv_vlc_pair dv_vlc_map[DV_VLC_MAP_RUN_SIZE][DV_VLC_MAP_LEV_SIZE]; | |
48 | |
49 static void dv_vlc_map_tableinit(void) | |
50 { | |
51 int i, j; | |
52 for (i = 0; i < NB_DV_VLC - 1; i++) { | |
53 if (dv_vlc_run[i] >= DV_VLC_MAP_RUN_SIZE) | |
54 continue; | |
55 #if CONFIG_SMALL | |
56 if (dv_vlc_level[i] >= DV_VLC_MAP_LEV_SIZE) | |
57 continue; | |
58 #endif | |
59 | |
60 if (dv_vlc_map[dv_vlc_run[i]][dv_vlc_level[i]].size != 0) | |
61 continue; | |
62 | |
63 dv_vlc_map[dv_vlc_run[i]][dv_vlc_level[i]].vlc = | |
64 dv_vlc_bits[i] << (!!dv_vlc_level[i]); | |
65 dv_vlc_map[dv_vlc_run[i]][dv_vlc_level[i]].size = | |
66 dv_vlc_len[i] + (!!dv_vlc_level[i]); | |
67 } | |
68 for (i = 0; i < DV_VLC_MAP_RUN_SIZE; i++) { | |
69 #if CONFIG_SMALL | |
70 for (j = 1; j < DV_VLC_MAP_LEV_SIZE; j++) { | |
71 if (dv_vlc_map[i][j].size == 0) { | |
72 dv_vlc_map[i][j].vlc = dv_vlc_map[0][j].vlc | | |
73 (dv_vlc_map[i-1][0].vlc << (dv_vlc_map[0][j].size)); | |
74 dv_vlc_map[i][j].size = dv_vlc_map[i-1][0].size + | |
75 dv_vlc_map[0][j].size; | |
76 } | |
77 } | |
78 #else | |
79 for (j = 1; j < DV_VLC_MAP_LEV_SIZE/2; j++) { | |
80 if (dv_vlc_map[i][j].size == 0) { | |
81 dv_vlc_map[i][j].vlc = dv_vlc_map[0][j].vlc | | |
82 (dv_vlc_map[i-1][0].vlc << (dv_vlc_map[0][j].size)); | |
83 dv_vlc_map[i][j].size = dv_vlc_map[i-1][0].size + | |
84 dv_vlc_map[0][j].size; | |
85 } | |
86 dv_vlc_map[i][((uint16_t)(-j))&0x1ff].vlc = | |
87 dv_vlc_map[i][j].vlc | 1; | |
88 dv_vlc_map[i][((uint16_t)(-j))&0x1ff].size = | |
89 dv_vlc_map[i][j].size; | |
90 } | |
91 #endif | |
92 } | |
93 } | |
94 #endif /* CONFIG_HARDCODED_TABLES */ | |
95 | |
96 #endif /* DV_TABLEGEN_H */ |