2 * Header file for hardcoded DV tables
4 * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
6 * This file is part of FFmpeg.
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.
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.
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
23 #ifndef AVCODEC_DV_TABLEGEN_H
24 #define AVCODEC_DV_TABLEGEN_H
27 #include "libavutil/attributes.h"
32 #define DV_VLC_MAP_RUN_SIZE 15
33 #define DV_VLC_MAP_LEV_SIZE 23
35 #define DV_VLC_MAP_RUN_SIZE 64
36 #define DV_VLC_MAP_LEV_SIZE 512 // FIXME sign was removed so this should be /2 but needs check
39 /* VLC encoding lookup table */
40 typedef struct dv_vlc_pair
{
45 #if CONFIG_HARDCODED_TABLES
46 #define dv_vlc_map_tableinit()
47 #include "libavcodec/dv_tables.h"
49 static struct dv_vlc_pair dv_vlc_map
[DV_VLC_MAP_RUN_SIZE
][DV_VLC_MAP_LEV_SIZE
];
51 static av_cold
void dv_vlc_map_tableinit(void)
54 for (i
= 0; i
< NB_DV_VLC
- 1; i
++) {
55 if (ff_dv_vlc_run
[i
] >= DV_VLC_MAP_RUN_SIZE
)
58 if (ff_dv_vlc_level
[i
] >= DV_VLC_MAP_LEV_SIZE
)
62 if (dv_vlc_map
[ff_dv_vlc_run
[i
]][ff_dv_vlc_level
[i
]].size
!= 0)
65 dv_vlc_map
[ff_dv_vlc_run
[i
]][ff_dv_vlc_level
[i
]].vlc
=
66 ff_dv_vlc_bits
[i
] << (!!ff_dv_vlc_level
[i
]);
67 dv_vlc_map
[ff_dv_vlc_run
[i
]][ff_dv_vlc_level
[i
]].size
=
68 ff_dv_vlc_len
[i
] + (!!ff_dv_vlc_level
[i
]);
70 for (i
= 0; i
< DV_VLC_MAP_RUN_SIZE
; i
++) {
72 for (j
= 1; j
< DV_VLC_MAP_LEV_SIZE
; j
++) {
73 if (dv_vlc_map
[i
][j
].size
== 0) {
74 dv_vlc_map
[i
][j
].vlc
= dv_vlc_map
[0][j
].vlc
|
75 (dv_vlc_map
[i
- 1][0].vlc
<<
76 dv_vlc_map
[0][j
].size
);
77 dv_vlc_map
[i
][j
].size
= dv_vlc_map
[i
- 1][0].size
+
78 dv_vlc_map
[0][j
].size
;
82 for (j
= 1; j
< DV_VLC_MAP_LEV_SIZE
/ 2; j
++) {
83 if (dv_vlc_map
[i
][j
].size
== 0) {
84 dv_vlc_map
[i
][j
].vlc
= dv_vlc_map
[0][j
].vlc
|
85 (dv_vlc_map
[i
- 1][0].vlc
<<
86 dv_vlc_map
[0][j
].size
);
87 dv_vlc_map
[i
][j
].size
= dv_vlc_map
[i
- 1][0].size
+
88 dv_vlc_map
[0][j
].size
;
90 dv_vlc_map
[i
][((uint16_t) (-j
)) & 0x1ff].vlc
= dv_vlc_map
[i
][j
].vlc
| 1;
91 dv_vlc_map
[i
][((uint16_t) (-j
)) & 0x1ff].size
= dv_vlc_map
[i
][j
].size
;
96 #endif /* CONFIG_HARDCODED_TABLES */
98 #endif /* AVCODEC_DV_TABLEGEN_H */