FFmpeg
Loading...
Searching...
No Matches
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>
28
29#include "dvdata.h"
30
31#if CONFIG_SMALL
32#define DV_VLC_MAP_RUN_SIZE 15
33#define DV_VLC_MAP_LEV_SIZE 23
34#else
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
37#endif
38
39/* VLC encoding lookup table */
40typedef struct dv_vlc_pair {
41 uint32_t vlc;
42 uint32_t size;
44
45#if CONFIG_HARDCODED_TABLES
46#define dv_vlc_map_tableinit()
47#include "libavcodec/dv_tables.h"
48#else
50
52{
53 uint32_t code = 0;
54 for (int i = 0; i < NB_DV_VLC; i++) {
55 uint32_t cur_code = code >> (32 - ff_dv_vlc_len[i]);
56 code += 1U << (32 - ff_dv_vlc_len[i]);
58 continue;
59#if CONFIG_SMALL
61 continue;
62#endif
63
65 continue;
66
68 cur_code << (!!ff_dv_vlc_level[i]);
71 }
72 for (int i = 0; i < DV_VLC_MAP_RUN_SIZE; i++) {
73#if CONFIG_SMALL
74 for (int j = 1; j < DV_VLC_MAP_LEV_SIZE; j++) {
75 if (dv_vlc_map[i][j].size == 0) {
76 dv_vlc_map[i][j].vlc = dv_vlc_map[0][j].vlc |
77 (dv_vlc_map[i - 1][0].vlc <<
78 dv_vlc_map[0][j].size);
79 dv_vlc_map[i][j].size = dv_vlc_map[i - 1][0].size +
80 dv_vlc_map[0][j].size;
81 }
82 }
83#else
84 for (int j = 1; j < DV_VLC_MAP_LEV_SIZE / 2; j++) {
85 if (dv_vlc_map[i][j].size == 0) {
86 dv_vlc_map[i][j].vlc = dv_vlc_map[0][j].vlc |
87 (dv_vlc_map[i - 1][0].vlc <<
88 dv_vlc_map[0][j].size);
89 dv_vlc_map[i][j].size = dv_vlc_map[i - 1][0].size +
90 dv_vlc_map[0][j].size;
91 }
92 dv_vlc_map[i][((uint16_t) (-j)) & 0x1ff].vlc = dv_vlc_map[i][j].vlc | 1;
93 dv_vlc_map[i][((uint16_t) (-j)) & 0x1ff].size = dv_vlc_map[i][j].size;
94 }
95#endif
96 }
97}
98#endif /* CONFIG_HARDCODED_TABLES */
99
100#endif /* AVCODEC_DV_TABLEGEN_H */
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
static av_cold void dv_vlc_map_tableinit(void)
Definition dv_tablegen.h:51
#define DV_VLC_MAP_RUN_SIZE
Definition dv_tablegen.h:35
#define DV_VLC_MAP_LEV_SIZE
Definition dv_tablegen.h:36
static struct dv_vlc_pair dv_vlc_map[DV_VLC_MAP_RUN_SIZE][DV_VLC_MAP_LEV_SIZE]
Definition dv_tablegen.h:49
const uint8_t ff_dv_vlc_len[NB_DV_VLC]
Definition dvdata.c:77
const uint8_t ff_dv_vlc_run[NB_DV_VLC]
Definition dvdata.c:131
const uint8_t ff_dv_vlc_level[NB_DV_VLC]
Definition dvdata.c:185
#define NB_DV_VLC
Definition dvdata.h:29
Macro definitions for various function/variable attributes.
#define av_cold
Definition attributes.h:117
const uint8_t * code
Definition spdifenc.c:433
uint32_t size
Definition dv_tablegen.h:42
uint32_t vlc
Definition dv_tablegen.h:41
int size