FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dv_tablegen.h
Go to the documentation of this file.
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 AVCODEC_DV_TABLEGEN_H
24 #define AVCODEC_DV_TABLEGEN_H
25 
26 #include <stdint.h>
27 
28 #include "dv_vlc_data.h"
29 
30 #if CONFIG_SMALL
31 #define DV_VLC_MAP_RUN_SIZE 15
32 #define DV_VLC_MAP_LEV_SIZE 23
33 #else
34 #define DV_VLC_MAP_RUN_SIZE 64
35 #define DV_VLC_MAP_LEV_SIZE 512 //FIXME sign was removed so this should be /2 but needs check
36 #endif
37 
38 /* VLC encoding lookup table */
39 typedef struct dv_vlc_pair {
40  uint32_t vlc;
41  uint32_t size;
42 } dv_vlc_pair;
43 
44 #if CONFIG_HARDCODED_TABLES
45 #define dv_vlc_map_tableinit()
46 #include "libavcodec/dv_tables.h"
47 #else
49 
50 static void dv_vlc_map_tableinit(void)
51 {
52  int i, j;
53  for (i = 0; i < NB_DV_VLC - 1; i++) {
55  continue;
56 #if CONFIG_SMALL
58  continue;
59 #endif
60 
61  if (dv_vlc_map[dv_vlc_run[i]][dv_vlc_level[i]].size != 0)
62  continue;
63 
65  dv_vlc_bits[i] << (!!dv_vlc_level[i]);
67  dv_vlc_len[i] + (!!dv_vlc_level[i]);
68  }
69  for (i = 0; i < DV_VLC_MAP_RUN_SIZE; i++) {
70 #if CONFIG_SMALL
71  for (j = 1; j < DV_VLC_MAP_LEV_SIZE; j++) {
72  if (dv_vlc_map[i][j].size == 0) {
73  dv_vlc_map[i][j].vlc = dv_vlc_map[0][j].vlc |
74  (dv_vlc_map[i-1][0].vlc << (dv_vlc_map[0][j].size));
75  dv_vlc_map[i][j].size = dv_vlc_map[i-1][0].size +
76  dv_vlc_map[0][j].size;
77  }
78  }
79 #else
80  for (j = 1; j < DV_VLC_MAP_LEV_SIZE/2; j++) {
81  if (dv_vlc_map[i][j].size == 0) {
82  dv_vlc_map[i][j].vlc = dv_vlc_map[0][j].vlc |
83  (dv_vlc_map[i-1][0].vlc << (dv_vlc_map[0][j].size));
84  dv_vlc_map[i][j].size = dv_vlc_map[i-1][0].size +
85  dv_vlc_map[0][j].size;
86  }
87  dv_vlc_map[i][((uint16_t)(-j))&0x1ff].vlc =
88  dv_vlc_map[i][j].vlc | 1;
89  dv_vlc_map[i][((uint16_t)(-j))&0x1ff].size =
90  dv_vlc_map[i][j].size;
91  }
92 #endif
93  }
94 }
95 #endif /* CONFIG_HARDCODED_TABLES */
96 
97 #endif /* AVCODEC_DV_TABLEGEN_H */